struct attr attr;
int sats=0, sats_used=0;
- if (vehicle_get_attr(v, attr_position_speed, &attr))
+ if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
sprintf (buffer, "%02.02f km/h", *attr.u.numd);
else
strcpy (buffer, "N/A");
CEGUI::WindowManager::getSingleton().getWindow("OSD/SpeedoMeter")->setText(buffer);
- if (vehicle_get_attr(v, attr_position_height, &attr))
+ if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
sprintf (buffer, "%.f m", *attr.u.numd);
else
strcpy (buffer, "N/A");
CEGUI::WindowManager::getSingleton().getWindow("OSD/Altimeter")->setText(buffer);
- if (vehicle_get_attr(v, attr_position_sats, &attr))
+ if (vehicle_get_attr(v, attr_position_sats, &attr, NULL))
sats=attr.u.num;
- if (vehicle_get_attr(v, attr_position_sats_used, &attr))
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
sats_used=attr.u.num;
// printf(" sats : %i, used %i: \n",sats,sats_used);
// Sat image hardcoded for now. may break the TaharezSkin
strcpy(this->route_text, buffer);
gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
}
- if (!vehicle_get_attr(v, attr_position_coord_geo, &attr))
+ if (!vehicle_get_attr(v, attr_position_coord_geo, &attr, NULL))
return;
lng=attr.u.coord_geo->lng;
lat=attr.u.coord_geo->lat;
lat=-lat;
lat_c='S';
}
- if (vehicle_get_attr(v, attr_position_direction, &attr))
+ if (vehicle_get_attr(v, attr_position_direction, &attr, NULL))
direction=*(attr.u.numd);
direction=fmod(direction,360);
if (direction < 0)
direction+=360;
dir_idx=(direction+22.5)/45;
dir=dirs[dir_idx];
- if (vehicle_get_attr(v, attr_position_height, &attr))
+ if (vehicle_get_attr(v, attr_position_height, &attr, NULL))
height=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_speed, &attr))
+ if (vehicle_get_attr(v, attr_position_speed, &attr, NULL))
speed=*(attr.u.numd);
- if (vehicle_get_attr(v, attr_position_sats_used, &attr))
+ if (vehicle_get_attr(v, attr_position_sats_used, &attr, NULL))
sats=attr.u.num;
- if (vehicle_get_attr(v, attr_position_qual, &attr))
+ if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
qual=attr.u.num;
sprintf(this->gps_text,"GPS %2d/%1d %02.0f%07.4f%c %03.0f%07.4f%c %4.0fm %3.0f°%-2s %3.0fkm/h", sats, qual, floor(lat), fmod(lat*60,60), lat_c, floor(lng), fmod(lng*60,60), lng_c, height, direction, dir, speed);
gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
iter=navit_attr_iter_new();
while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr);
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
name=g_strdup_printf("Vehicle %d", count++);
data=g_new(struct action_cb_data, 1);
data->gui=this;
gui_internal_widget_append(wb, w);
iter=navit_attr_iter_new();
while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr);
+ vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
wl=gui_internal_button_navit_attr_new(this, vattr.u.str, gravity_left_center|orientation_horizontal|flags_fill,
&attr, NULL);
gui_internal_widget_append(w, wl);
this->clickp_valid=1;
}
if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
- && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp)) {
+ && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
this->vehiclep.pro=transform_get_projection(trans);
transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
this->vehiclep.x=c.x;
static void navit_vehicle_update(struct navit *this_, struct navit_vehicle *nv);
static void navit_vehicle_draw(struct navit *this_, struct navit_vehicle *nv, struct point *pnt);
+static int navit_add_vehicle(struct navit *this_, struct vehicle *v);
void
navit_add_mapset(struct navit *this_, struct mapset *ms)
case attr_recent_dest:
this_->recentdest_count = attr->u.num;
break;
+ case attr_vehicle:
+ return navit_add_vehicle(this_, attr->u.vehicle);
default:
return 0;
}
if (this_->ready != 3)
return;
- if (! vehicle_get_attr(nv->vehicle, attr_position_direction, &attr_dir) ||
- ! vehicle_get_attr(nv->vehicle, attr_position_speed, &attr_speed) ||
- ! vehicle_get_attr(nv->vehicle, attr_position_coord_geo, &attr_pos))
+ if (! vehicle_get_attr(nv->vehicle, attr_position_direction, &attr_dir, NULL) ||
+ ! vehicle_get_attr(nv->vehicle, attr_position_speed, &attr_speed, NULL) ||
+ ! vehicle_get_attr(nv->vehicle, attr_position_coord_geo, &attr_pos, NULL))
return;
nv->dir=*attr_dir.u.numd;
nv->speed=*attr_speed.u.numd;
navit_draw(this_);
}
+static void
+navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv)
+{
+ this_->vehicle=nv;
+}
+
/**
* Register a new vehicle
*
* @param navit The navit instance
* @param v The vehicle instance
- * @param name Guess? :)
- * @param c The color to use for the cursor, currently only used in GTK
- * @param update Wether to refresh the map each time this vehicle position changes (instead of only when it reaches a border)
- * @param follow Wether to center the map on this vehicle position
- * @returns a vehicle instance
+ * @returns 1 for success
*/
-struct navit_vehicle *
-navit_add_vehicle(struct navit *this_, struct vehicle *v, struct attr **attrs)
+static int
+navit_add_vehicle(struct navit *this_, struct vehicle *v)
{
struct navit_vehicle *nv=g_new0(struct navit_vehicle, 1);
- struct attr *update,*follow,*color,*active, *color2, *animate;
+ struct attr update,follow,color,active, color2, animate;
nv->vehicle=v;
nv->update=1;
nv->follow=0;
nv->animate_cursor=0;
- if ((update=attr_search(attrs, NULL, attr_update)))
- nv->update=nv->update=update->u.num;
- if ((follow=attr_search(attrs, NULL, attr_follow)))
- nv->follow=nv->follow=follow->u.num;
- if ((color=attr_search(attrs, NULL, attr_color)))
- nv->c=*(color->u.color);
- if ((color2=attr_search(attrs, NULL, attr_color2)))
- nv->c2=color2->u.color;
+ if ((vehicle_get_attr(v, attr_update, &update, NULL)))
+ nv->update=nv->update=update.u.num;
+ if ((vehicle_get_attr(v, attr_follow, &follow, NULL)))
+ nv->follow=nv->follow=follow.u.num;
+ if ((vehicle_get_attr(v, attr_color, &color, NULL)))
+ nv->c=*(color.u.color);
+ if ((vehicle_get_attr(v, attr_color2, &color2, NULL)))
+ nv->c2=color2.u.color;
else
nv->c2=NULL;
nv->update_curr=nv->update;
nv->follow_curr=nv->follow;
this_->vehicles=g_list_append(this_->vehicles, nv);
- if ((active=attr_search(attrs, NULL, attr_active)) && active->u.num)
+ if ((vehicle_get_attr(v, attr_active, &active, NULL)) && active.u.num)
navit_set_vehicle(this_, nv);
- if ((animate=attr_search(attrs, NULL, attr_animate)))
- nv->animate_cursor=animate->u.num;
- return nv;
-}
-
-void
-navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv)
-{
- this_->vehicle=nv;
+ if ((vehicle_get_attr(v, attr_animate, &animate, NULL)))
+ nv->animate_cursor=animate.u.num;
+ return 1;
}
void
void navit_add_callback(struct navit *this_, struct callback *cb);
void navit_remove_callback(struct navit *this_, struct callback *cb);
void navit_set_position(struct navit *this_, struct pcoord *c);
-struct navit_vehicle *navit_add_vehicle(struct navit *this_, struct vehicle *v, struct attr **attrs);
-void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv);
void navit_tracking_add(struct navit *this_, struct tracking *tracking);
void navit_set_speech(struct navit *this_, struct speech *speech);
struct gui *navit_get_gui(struct navit *this_);
p.x=30;
p.y=30;
graphics_draw_circle(this->gr, this->white, &p, 50);
- if (v && vehicle_get_attr(v, attr_position_direction, &attr_dir)) {
+ if (v && vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL)) {
vdir=*attr_dir.u.numd;
handle(this->gr, this->white, &p, 20, -vdir);
}
- if (navit_get_attr(nav, attr_destination, &destination_attr, NULL) && v && vehicle_get_attr(v, attr_position_coord_geo, &position_attr)) {
+ if (navit_get_attr(nav, attr_destination, &destination_attr, NULL) && v && vehicle_get_attr(v, attr_position_coord_geo, &position_attr, NULL)) {
pro=destination_attr.u.pcoord->pro;
transform_from_geo(pro, position_attr.u.coord_geo, &c1);
c2.x=destination_attr.u.pcoord->x;
}
struct vehicle *
-vehicle_new(struct attr **attrs)
+vehicle_new(struct attr *parent, struct attr **attrs)
{
struct vehicle *this_;
struct attr *source;
}
int
-vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr)
+vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
{
switch (type) {
case attr_name:
};
/* prototypes */
-struct vehicle *vehicle_new(struct attr **attrs);
-int vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr);
+struct vehicle *vehicle_new(struct attr *parent, struct attr **attrs);
+int vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
int vehicle_set_attr(struct vehicle *this_, struct attr *attr, struct attr **attrs);
int vehicle_add_attr(struct vehicle *this_, struct attr *attr);
int vehicle_remove_attr(struct vehicle *this_, struct attr *attr);
}
static int
-xmlconfig_vehicle(struct xmlstate *state)
-{
- struct attr **attrs;
- attrs=convert_to_attrs(state);
-
- state->element_attr.u.data = vehicle_new(attrs);
- if (! state->element_attr.u.data)
- return 0;
- navit_add_vehicle(state->parent->element_attr.u.data, state->element_attr.u.data, attrs);
- return 1;
-}
-
-static int
-xmlconfig_log_vehicle(struct xmlstate *state)
-{
- struct attr attr;
- struct attr **attrs;
- attrs=convert_to_attrs(state);
- state->element_attr.u.data = log_new(attrs);
- if (! state->element_attr.u.data)
- return 0;
- attr.type=attr_log;
- attr.u.log=state->element_attr.u.data;
- if (vehicle_add_attr(state->parent->element_attr.u.data, &attr))
- return 0;
- return 1;
-}
-
-static int
-xmlconfig_log_navit(struct xmlstate *state)
-{
- struct attr attr;
- struct attr **attrs;
- attrs=convert_to_attrs(state);
- state->element_attr.u.data = log_new(attrs);
- if (! state->element_attr.u.data)
- return 0;
- attr.type=attr_log;
- attr.u.log=state->element_attr.u.data;
- if (navit_add_attr(state->parent->element_attr.u.data, &attr))
- return 0;
- return 1;
-}
-
-
-static int
xmlconfig_window_items(struct xmlstate *state)
{
int distance=-1;
{ "tracking", "navit", xmlconfig_tracking},
{ "route", "navit", xmlconfig_route},
{ "speed", "route", xmlconfig_speed},
- { "vehicle", "navit", xmlconfig_vehicle},
- { "log", "vehicle", xmlconfig_log_vehicle},
- { "log", "navit", xmlconfig_log_navit},
+ { "vehicle", "navit", NULL, NEW(vehicle_new)},
+ { "log", "vehicle", NULL, NEW(log_new)},
+ { "log", "navit", NULL, NEW(log_new)},
{ "window_items", "navit", xmlconfig_window_items},
{ "plugins", "config", NULL, NEW(plugins_new), NULL, INIT(plugins_init), NULL},
{ "plugin", "plugins", xmlconfig_plugin},