navit  0.5.3-trunk
vehicle.c File Reference
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <time.h>
#include <math.h>
#include "config.h"
#include "debug.h"
#include "coord.h"
#include "item.h"
#include "xmlconfig.h"
#include "log.h"
#include "plugin.h"
#include "transform.h"
#include "util.h"
#include "event.h"
#include "projection.h"
#include "point.h"
#include "graphics.h"
#include "callback.h"
#include "color.h"
#include "layout.h"
#include "vehicle.h"
#include "navit_nls.h"

Data Structures

struct  vehicle
 

Functions

static void vehicle_set_default_name (struct vehicle *this)
 
static void vehicle_draw_do (struct vehicle *this_)
 
static void vehicle_log_nmea (struct vehicle *this_, struct log *log)
 Writes to an NMEA log. More...
 
static void vehicle_log_gpx (struct vehicle *this_, struct log *log)
 Writes a trackpoint to a GPX log. More...
 
static void vehicle_log_textfile (struct vehicle *this_, struct log *log)
 Writes to a text log. More...
 
static void vehicle_log_binfile (struct vehicle *this_, struct log *log)
 Writes to a binary log. More...
 
static int vehicle_add_log (struct vehicle *this_, struct log *log)
 Registers a new log to receive data. More...
 
struct vehiclevehicle_new (struct attr *parent, struct attr **attrs)
 Creates a new vehicle. More...
 
void vehicle_destroy (struct vehicle *this_)
 Destroys a vehicle. More...
 
struct attr_itervehicle_attr_iter_new (void *unused)
 
void vehicle_attr_iter_destroy (struct attr_iter *iter)
 
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)
 
int vehicle_add_attr (struct vehicle *this_, struct attr *attr)
 
int vehicle_remove_attr (struct vehicle *this_, struct attr *attr)
 Generic remove function. More...
 
void vehicle_set_cursor (struct vehicle *this_, struct cursor *cursor, int overwrite)
 
void vehicle_draw (struct vehicle *this_, struct graphics *gra, struct point *pnt, int angle, int speed)
 
int vehicle_get_cursor_data (struct vehicle *this, struct point *pnt, int *angle, int *speed)
 
void vehicle_log_gpx_add_tag (char *tag, char **logstr)
 

Variables

struct object_func vehicle_func
 

Function Documentation

◆ vehicle_add_attr()

int vehicle_add_attr ( struct vehicle this_,
struct attr attr 
)

Generic add function

Parameters
this_A vehicle
attrThe attribute to add
Returns
true if the attribute was added, false if not.

References attr_generic_add_attr(), attr::callback, callback_list_add(), vehicle::cbl, attr::cursor, vehicle::cursor_fixed, attr::log, attr::type, attr::u, vehicle_add_log(), and vehicle_set_cursor().

Referenced by navit_add_vehicle(), and pedestrian_navit_init().

◆ vehicle_add_log()

static int vehicle_add_log ( struct vehicle this_,
struct log log 
)
static

Registers a new log to receive data.

Parameters
this_The vehicle supplying data
logThe log to write to
Returns
False if the log is of an unknown type, true otherwise (including when
attr_type
Definition: attr.h:34
is missing).

References callback_cast, callback_list_add(), callback_new_attr_2, vehicle::cbl, log_get_attr(), log_set_header(), log_set_trailer(), vehicle::log_to_cb, attr::str, attr::u, vehicle_log_binfile(), vehicle_log_gpx(), vehicle_log_nmea(), and vehicle_log_textfile().

Referenced by vehicle_add_attr().

◆ vehicle_attr_iter_destroy()

void vehicle_attr_iter_destroy ( struct attr_iter iter)

Destroys a vehicle attribute iterator

Parameters
itera vehicle attr_iter

References attr_iter::iter.

Referenced by NGQProxyVehicle::dropIterFunc(), and save_vehicle_xml().

◆ vehicle_attr_iter_new()

struct attr_iter* vehicle_attr_iter_new ( void *  unused)

Creates an attribute iterator to be used with vehicles

Referenced by NGQProxyVehicle::getIterFunc(), and save_vehicle_xml().

◆ vehicle_destroy()

◆ vehicle_draw()

void vehicle_draw ( struct vehicle this_,
struct graphics gra,
struct point pnt,
int  angle,
int  speed 
)

Draws a vehicle on top of a graphics.

Parameters
this_The vehicle
graThe graphics
pntScreen coordinates of the vehicle.
angleThe angle relative to the map.
speedThe speed of the vehicle.

References vehicle::angle, vehicle::bg, c, vehicle::cursor, vehicle::cursor_pnt, dbg, vehicle::gra, graphics_background_gc(), graphics_gc_new(), graphics_gc_set_foreground(), graphics_init(), graphics_overlay_new(), graphics_overlay_resize(), cursor::h, lvl_debug, navit_sqrt, vehicle::need_resize, vehicle::real_h, vehicle::real_w, vehicle::speed, vehicle::trans, transform_set_screen_center(), vehicle_draw_do(), cursor::w, point::x, and point::y.

Referenced by navit_vehicle_draw().

◆ vehicle_draw_do()

◆ vehicle_get_attr()

int vehicle_get_attr ( struct vehicle this_,
enum attr_type  type,
struct attr attr,
struct attr_iter iter 
)

◆ vehicle_get_cursor_data()

int vehicle_get_cursor_data ( struct vehicle this,
struct point pnt,
int *  angle,
int *  speed 
)

◆ vehicle_log_binfile()

static void vehicle_log_binfile ( struct vehicle this_,
struct log log 
)
static

◆ vehicle_log_gpx()

static void vehicle_log_gpx ( struct vehicle this_,
struct log log 
)
static

◆ vehicle_log_gpx_add_tag()

void vehicle_log_gpx_add_tag ( char *  tag,
char **  logstr 
)

Add a tag to the extensions section of a GPX trackpoint.

Parameters
tagThe tag to add
logstrPointer to a pointer to a string to be inserted into the log. When calling this function,
*logstr
must point to the substring into which the new tag is to be inserted. If
*logstr
is NULL, a new string will be created for the extensions section. Upon returning,
*logstr
will point to the new string with the additional tag inserted.

References attr::str.

Referenced by pedestrian_log().

◆ vehicle_log_nmea()

static void vehicle_log_nmea ( struct vehicle this_,
struct log log 
)
static

Writes to an NMEA log.

Parameters
this_The vehicle supplying data
logThe log to write to

References log_write(), vehicle::meth, vehicle_methods::position_attr_get, vehicle::priv, attr::str, and attr::u.

Referenced by vehicle_add_log().

◆ vehicle_log_textfile()

static void vehicle_log_textfile ( struct vehicle this_,
struct log log 
)
static

Writes to a text log.

Parameters
this_The vehicle supplying data
logThe log to write to

References callback_list_call_attr_1, vehicle::cbl, attr::coord_geo, coord_geo::lat, coord_geo::lng, log_write(), vehicle::meth, attr::num, vehicle_methods::position_attr_get, vehicle::priv, and attr::u.

Referenced by vehicle_add_log().

◆ vehicle_new()

struct vehicle* vehicle_new ( struct attr parent,
struct attr **  attrs 
)

Creates a new vehicle.

Parameters
parent
attrsPoints to a null-terminated array of pointers to the attributes for the new vehicle type.
Returns
The newly created vehicle object

References attr_list_dup(), attr_search(), attr::attrs, callback_list_destroy(), callback_list_new(), cbl, vehicle::cbl, center, dbg, vehicle::log_to_cb, lvl_debug, lvl_error, vehicle::meth, navit_object_ref(), vehicle::priv, projection_screen, attr::str, vehicle::trans, transform_new(), type, attr::u, vehicle_func, and vehicle_set_default_name().

◆ vehicle_remove_attr()

int vehicle_remove_attr ( struct vehicle this_,
struct attr attr 
)

Generic remove function.

Used to remove a callback from the vehicle.

Parameters
this_A vehicle
attr

References attr_generic_remove_attr(), attr::callback, callback_list_remove(), vehicle::cbl, attr::log, vehicle::log_to_cb, attr::type, and attr::u.

◆ vehicle_set_attr()

int vehicle_set_attr ( struct vehicle this_,
struct attr attr 
)

◆ vehicle_set_cursor()

void vehicle_set_cursor ( struct vehicle this_,
struct cursor cursor,
int  overwrite 
)

◆ vehicle_set_default_name()

static void vehicle_set_default_name ( struct vehicle this)
static

Variable Documentation

◆ vehicle_func

struct object_func vehicle_func
Initial value:
= {
attr_vehicle,
}
int vehicle_set_attr(struct vehicle *this_, struct attr *attr)
Definition: vehicle.c:233
int vehicle_remove_attr(struct vehicle *this_, struct attr *attr)
Generic remove function.
Definition: vehicle.c:286
void vehicle_attr_iter_destroy(struct attr_iter *iter)
Definition: vehicle.c:197
struct vehicle * vehicle_new(struct attr *parent, struct attr **attrs)
Creates a new vehicle.
Definition: vehicle.c:107
struct attr_iter * vehicle_attr_iter_new(void *unused)
Definition: vehicle.c:188
void vehicle_destroy(struct vehicle *this_)
Destroys a vehicle.
Definition: vehicle.c:167
int vehicle_get_attr(struct vehicle *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: vehicle.c:212
int vehicle_add_attr(struct vehicle *this_, struct attr *attr)
Definition: vehicle.c:257
void * navit_object_unref(struct navit_object *obj)
Definition: xmlconfig.c:1313
struct navit_object * navit_object_ref(struct navit_object *obj)
Definition: xmlconfig.c:1307
void(* object_func_iter_destroy)(struct attr_iter *)
Definition: xmlconfig.h:57
void *(* object_func_new)(struct attr *parent, struct attr **attrs)
Definition: xmlconfig.h:54
int(* object_func_remove_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:60
void *(* object_func_ref)(void *)
Definition: xmlconfig.h:64
struct attr_iter *(* object_func_iter_new)(void *)
Definition: xmlconfig.h:56
int(* object_func_init)(void *)
Definition: xmlconfig.h:61
void *(* object_func_dup)(void *)
Definition: xmlconfig.h:63
int(* object_func_add_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:59
void(* object_func_destroy)(void *)
Definition: xmlconfig.h:62
int(* object_func_set_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:58
int(* object_func_get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: xmlconfig.h:55
void *(* object_func_unref)(void *)
Definition: xmlconfig.h:65

Referenced by object_func_lookup(), and vehicle_new().