pavi  0.0
Map Path Viewer
track_layer.bas File Reference

Source for advanced tracks layer. More...

#include "cairo/cairo.bi"
#include "Gir/OsmGpsMap-1.0.bi"
#include "Gir/_GLibMacros-2.0.bi"
#include "Gir/_GObjectMacros-2.0.bi"
#include "track_layer.bi"
#include "track_store.bi"
#include "gui.bi"
#include "debug.bi"
#include "string.bi"
Include dependency graph for track_layer.bas:

Go to the source code of this file.

Classes

class  _TrackLayerPrivate
 Private data. More...
 

Typedefs

typedef single float
 

Enumerations

enum  {
  PROP_0, PROP_TL_W, PROP_TL_H, PROP__MAP,
  PROP_PREF, PROP_LOAD, PROP_FSIZ, PROP_FTYP
}
 Enumerators for property IDs. More...
 

Functions

SUB_CDECL track_layer_interface_init (BYVAL_AS_OsmGpsMapLayerIface_PTR Iface)
 Initialise the interface functions. More...
 
SUB_CDECL render_info (BYVAL_AS_TrackLayer_PTR Lay, BYVAL_AS_OsmGpsMap_PTR Map)
 Render the info pad. More...
 
SUB_CDECL track_layer_render (BYVAL_AS_OsmGpsMapLayer_PTR Lay, BYVAL_AS_OsmGpsMap_PTR Map)
 Render all enabled tracks. More...
 
SUB_CDECL track_layer_draw (BYVAL_AS_OsmGpsMapLayer_PTR Lay, BYVAL_AS_OsmGpsMap_PTR Map, BYVAL_AS_cairo_t_PTR Cr)
 Callback for drawing the layer surfaces. More...
 
FUNCTION_CDECL_AS_gboolean track_layer_busy (BYVAL_AS_OsmGpsMapLayer_PTR Lay)
 Callback for busy layer. More...
 
FUNCTION_CDECL_AS_gboolean track_layer_button_press (BYVAL_AS_OsmGpsMapLayer_PTR Lay, BYVAL_AS_OsmGpsMap_PTR Map, BYVAL_AS_GdkEventButton_PTR Event)
 Callback for button event. More...
 
SUB_CDECL track_layer_get_property (BYVAL_AS_Gobject_PTR Obj, BYVAL_AS_guint Property_id, BYVAL_AS_GValue_PTR Value, BYVAL_AS_GParamSpec_PTR Pspec)
 Handling property fetching. More...
 
SUB_CDECL track_layer_set_property (BYVAL_AS_Gobject_PTR Obj, BYVAL_AS_guint Property_id, BYVAL_AS_CONST_GValue_PTR Value, BYVAL_AS_GParamSpec_PTR Pspec)
 Handling property setting. More...
 
FUNCTION_CDECL_AS_Gobject_PTR track_layer_constructor (BYVAL_AS_GType Typ, BYVAL_AS_guint N_prop, BYVAL_AS_GObjectConstructParam_PTR Prop)
 GObjectClass CTOR. More...
 
SUB_CDECL track_layer_finalize (BYVAL_AS_Gobject_PTR Obj)
 GObjectClass finalisation. More...
 
SUB_CDECL track_layer_class_init (BYVAL_AS_TrackLayerClass_PTR klass)
 GObjectClass initialization. More...
 
SUB_CDECL track_layer_init (BYVAL_AS_TrackLayer_PTR Self)
 GObject init procedure. More...
 
FUNCTION_CDECL_AS_gboolean on_MAP_configure_event (BYVAL_AS_GtkWidget_PTR Wid, BYVAL_AS_GdkEventConfigure_PTR Event, BYVAL_AS_GPOINTER UDat)
 Callback fetching map size. More...
 
FUNCTION_AS_TrackLayer_PTR track_layer_new (BYVAL_AS_GObject_PTR Map)
 Creates a new instance of TrackLayer. More...
 
SUB render_rtext (BYVAL_AS_cairo_t_PTR Cr, BYREF_AS_LONG Y, BYREF_AS_LONG W, BYREF_AS_STRING S)
 Render right alligned text, bottom up. More...
 
FUNCTION_AS_STRING lat2str (BYVAL_AS_float V)
 Format a latitude as string. More...
 
FUNCTION_AS_STRING lon2str (BYVAL_AS_float V)
 Format a longitude as string. More...
 
FUNCTION_CDECL_AS_gboolean render_track (BYVAL_AS_GtkTreeModel_PTR Model, BYVAL_AS_GtkTreePath_PTR Path, BYVAL_AS_GtkTreeIter_PTR Iter, BYVAL_AS_gpointer TLPriv)
 Render an enabled track. More...
 
FUNCTION_CDECL_AS_TrackLayerDefault_PTR track_layer_get_default (BYVAL_AS_TrackLayer_PTR Lay)
 Provide the next default setting. More...
 
FUNCTION_CDECL_AS_TrackLoader_PTR track_layer_get_loader (BYVAL_AS_TrackLayer_PTR Lay)
 Provide pointer to the active track. More...
 
SUB_CDECL track_layer_center_track (BYVAL_AS_TrackLayer_PTR Lay)
 Show complete track. More...
 
SUB_CDECL track_layer_set_loader (BYVAL_AS_TrackLayer_PTR Lay, BYVAL_AS_TrackLoader_PTR Loa)
 Set active track. More...
 
SUB_CDECL track_layer_redraw (BYVAL_AS_TrackLayer_PTR Lay)
 Redraw surface. More...
 
FUNCTION_CDECL_AS_gint track_layer_get_point (BYVAL_AS_TrackLayer_PTR Lay)
 Get current point in active track. More...
 
SUB_CDECL track_layer_set_point (BYVAL_AS_TrackLayer_PTR Lay, BYVAL_AS_gint N)
 Set current point in active track. More...
 
SUB_CDECL track_layer_set_bbox (BYVAL_AS_TrackLayer_PTR Lay, BYVAL_AS_float La0, BYVAL_AS_float La1, BYVAL_AS_float Lo0, BYVAL_AS_float Lo1)
 Set map segment to the given bounding box. More...
 
SUB_CDECL track_layer_point_move (BYVAL_AS_TrackLayer_PTR Lay, BYVAL_AS_gchar_PTR S)
 Move current point. More...
 

Variables

static TrackLayerDefault DEFAULT_ENTRIES [...]
 Array of default setting for loaded tracks. More...
 

Detailed Description

Source for advanced tracks layer.

FIXME

Since
0.0

Definition in file track_layer.bas.


Class Documentation

◆ _TrackLayerPrivate

class _TrackLayerPrivate

Private data.

This structure holds the private (internal) data for the TrackLayer GObject.

Since
0.0

Definition at line 58 of file track_layer.bas.

Collaboration diagram for _TrackLayerPrivate:
Class Members
OsmGpsMap_PTR Map
TrackLoader_PTR Loader
TrackLayerDefault_PTR Default default values width/color (prop "defaults")
cairo_t_PTR Cr layer
cairo_surface_t_PTR Surface layer surface (track background)
cairo_surface_t_PTR InfoSurface surface for info pad
gchar_PTR FTyp font family (prop "font-type")
gint Nxt next index (defaults)
gint TIx info surface x position
gint TIy info surface y position
gint TIw info surface width
gint TIh info surface height
gint TLz map zoom
gint TLx map X
gint TLy map Y
gint TLw map width (prop "width")
gint TLh map height (prop "height")
gint FSiz font size (prop "font-size")
gboolean LayReSurf flag for layer surface redo

Typedef Documentation

◆ float

typedef single float

Definition at line 19 of file track_layer.bas.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Enumerators for property IDs.

Enumerator
PROP_0 
PROP_TL_W 
PROP_TL_H 
PROP__MAP 
PROP_PREF 
PROP_LOAD 
PROP_FSIZ 
PROP_FTYP 

Definition at line 39 of file track_layer.bas.

Function Documentation

◆ track_layer_interface_init()

SUB_CDECL track_layer_interface_init ( BYVAL_AS_OsmGpsMapLayerIface_PTR  Iface)

Initialise the interface functions.

Parameters
IfaceThe interface to modify

This procedure is part of the OsmGpsMapLayer implementation. It initialises the interface functions.

Since
0.0

Definition at line 111 of file track_layer.bas.

Here is the call graph for this function:

◆ render_info()

SUB render_info ( BYVAL_AS_TrackLayer_PTR  Lay,
BYVAL_AS_OsmGpsMap_PTR  Map 
)

Render the info pad.

Parameters
LayThe layer instance
MapMap instance calling

Procedure renders new values in to the info pad (in the right bottom corner when Layer enabled). On a transparent background either only the coordinates of the map center, or - when a track is active - additionaly the current track point details get rendered to the TrackLayerPrivate.InfoSurface, to be shown in the next call to track_layer_draw().

Since
0.0

Definition at line 599 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ track_layer_render()

SUB_CDECL track_layer_render ( BYVAL_AS_OsmGpsMapLayer_PTR  Lay,
BYVAL_AS_OsmGpsMap_PTR  Map 
)

Render all enabled tracks.

Parameters
LayThe layer we're working at
MapThe parent map widget

This procedure is part of the OsmGpsMapLayer implementation. It takes care that the TrackLayerPriv.Surface matches the map size (width/height) and renders all enabled tracks (line/points) to that surface. Additionaly it renders the info pad, when enabled.

Since
0.0

Definition at line 766 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ track_layer_draw()

SUB_cdecl track_layer_draw ( BYVAL_AS_OsmGpsMapLayer_PTR  Lay,
BYVAL_AS_OsmGpsMap_PTR  Map,
BYVAL_AS_cairo_t_PTR  Cr 
)

Callback for drawing the layer surfaces.

Parameters
LayLayer instance
MapMap widget sending the signal
CrCairl contents to draw on

This function is part of the OsmGpsMapLayer implementation. It handles the (re)drawing of the layer surface, ie when a part of the widget gets covered by another widget.

Since
0.0

Definition at line 357 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_busy()

FUNCTION_CDECL_AS_gboolean track_layer_busy ( BYVAL_AS_OsmGpsMapLayer_PTR  Lay)

Callback for busy layer.

Parameters
LayLayer instance
Returns
FALSE

This function is part of the OsmGpsMapLayer implementation. It returns if there're pending operations on the layer, ie like unfinished animations. Here it returns always FALSE.

Since
0.0

Definition at line 388 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_button_press()

FUNCTION_CDECL_AS_gboolean track_layer_button_press ( BYVAL_AS_OsmGpsMapLayer_PTR  Lay,
BYVAL_AS_OsmGpsMap_PTR  Map,
BYVAL_AS_GdkEventButton_PTR  Event 
)

Callback for button event.

Parameters
LayLayer receiving the event
MapMap widget propagating the event
EventEvent sended
Returns
FALSE to propagate event further, TRUE when handled

This function is part of the OsmGpsMapLayer implementation. It handles button events (mouse clicks) on the map, only clicks with <shift> or <control> keys pressed in this case.

A <shift> click searches in the active track for the point nearest to the click poisition. If the distance is below a certain value, that nearest point gets the current point in the active track.

In case of a <shift><control> click not only the active, but all tracks are searched for the nearest point. When that nearest point is in another track, this track gets the active track.

Since
0.0

Definition at line 413 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ track_layer_get_property()

SUB_CDECL track_layer_get_property ( BYVAL_AS_Gobject_PTR  Obj,
BYVAL_AS_guint  Property_id,
BYVAL_AS_GValue_PTR  Value,
BYVAL_AS_GParamSpec_PTR  Pspec 
)

Handling property fetching.

Parameters
ObjGObject instance
Property_idRegistration number
ValueThe value to fetch
PspecSpecification (for warning message)

This procedure is part of the GObject implementation. It gets a value from a certain property.

Since
0.0

Definition at line 130 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_set_property()

SUB_CDECL track_layer_set_property ( BYVAL_AS_Gobject_PTR  Obj,
BYVAL_AS_guint  Property_id,
BYVAL_AS_CONST_GValue_PTR  Value,
BYVAL_AS_GParamSpec_PTR  Pspec 
)

Handling property setting.

Parameters
ObjGObject instance
Property_idRegistration number
ValueThe new value
PspecSpecification (for warning message)

This procedure is part of the GObject implementation. It sets a new value for a certain property.

Since
0.0

Definition at line 162 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_constructor()

FUNCTION_CDECL_AS_Gobject_PTR track_layer_constructor ( BYVAL_AS_GType  Typ,
BYVAL_AS_guint  N_prop,
BYVAL_AS_GObjectConstructParam_PTR  Prop 
)

GObjectClass CTOR.

Parameters
TypObjects GType
N_propNumber of properties
PropConstruction parameters
Returns
The constructed GObject

This function is part of the GObject implementation. That constructor is setting the start values in the _TrackLayerPrivate structure, after chaining up to the parents constructor.

Since
0.0

Definition at line 198 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_finalize()

SUB_CDECL track_layer_finalize ( BYVAL_AS_Gobject_PTR  Obj)

GObjectClass finalisation.

Parameters
ObjThe instance to work on

This procedure is part of the GObject implementation. It handles the freeing of the used surfaces in this case, chaining up to the parents finalisation.

Since
0.0

Definition at line 231 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_class_init()

SUB_CDECL track_layer_class_init ( BYVAL_AS_TrackLayerClass_PTR  klass)

GObjectClass initialization.

Parameters
klassClass to initiate

This procedure is part of the GObjectClass implementation. It handles the interface setting and the properties in this case.

Since
0.0

The width property.

The height property.

The map property.

The defaults property.

The loader property.

The font-size property.

The font-type property.

Definition at line 248 of file track_layer.bas.

Here is the call graph for this function:

◆ track_layer_init()

SUB_CDECL track_layer_init ( BYVAL_AS_TrackLayer_PTR  Self)

GObject init procedure.

Parameters
SelfObject to initiate

This procedure is part of the GObject implementation. It sets the pointer to the _TrackLayerPrivate structure in this case.

Since
0.0

Definition at line 340 of file track_layer.bas.

◆ on_MAP_configure_event()

FUNCTION_CDECL_AS_gboolean on_MAP_configure_event ( BYVAL_AS_GtkWidget_PTR  Wid,
BYVAL_AS_GdkEventConfigure_PTR  Event,
BYVAL_AS_GPOINTER  UDat 
)

Callback fetching map size.

Parameters
WidWidget getting configured (=MAP, unused)
EventThe new data
UDatUnused here
Returns
FALSE to propagate the event further

Callback to hook into the configure event for the map widget. When the map width or height changes due to a user action (ie. full screen), the layer needs an adapted surface.

Since
0.0

Definition at line 474 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_new()

FUNCTION_AS_TrackLayer_PTR track_layer_new ( BYVAL_AS_GObject_PTR  Map)

Creates a new instance of TrackLayer.

Parameters
MapMap object to connect to
Returns
The newly created TrackLayer instance (transfer full)

A new TrackLayer instance gets created and added to the osm_gps_map given as parameter. Also a callback gets connected in order to track any configure changes of the map window.

Note
Use g_object_unref() to finalize the instance.
Since
0.0

Definition at line 497 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_rtext()

SUB render_rtext ( BYVAL_AS_cairo_t_PTR  Cr,
BYREF_AS_LONG  Y,
BYREF_AS_LONG  W,
BYREF_AS_STRING  S 
)

Render right alligned text, bottom up.

Parameters
CrCairo context to work on
YVertical position (line)
WWidth of the surface
SString to render

Procedure to render a right alligned text in to the _TrackLayerPrivate.InfoSurface. The black text gets a white border, in order to be readable on dark backgrounds. The next line position gets returned in parameter Y.

Since
0.0

Definition at line 527 of file track_layer.bas.

Here is the caller graph for this function:

◆ lat2str()

FUNCTION_AS_STRING lat2str ( BYVAL_AS_float  V)

Format a latitude as string.

Parameters
VValue to format [degree]
Returns
Formated string

Function to format a latitude value in to a human readable string.

Todo:
Add other string formats.
Since
0.0

< signless value degrees minutes

Definition at line 560 of file track_layer.bas.

Here is the caller graph for this function:

◆ lon2str()

FUNCTION_AS_STRING lon2str ( BYVAL_AS_float  V)

Format a longitude as string.

Parameters
VValue to format [degree]
Returns
Formated string

Function to format a longitude value in to a human readable string.

Todo:
Add other string formats.
Since
0.0

Definition at line 578 of file track_layer.bas.

Here is the caller graph for this function:

◆ render_track()

FUNCTION_CDECL_AS_gboolean render_track ( BYVAL_AS_GtkTreeModel_PTR  Model,
BYVAL_AS_GtkTreePath_PTR  Path,
BYVAL_AS_GtkTreeIter_PTR  Iter,
BYVAL_AS_gpointer  TLPriv 
)

Render an enabled track.

Parameters
ModelGtkTreeModel to work on
PathLine in model (unused here)
IterData Position
TLPrivTrackLayerPriv pointer
Returns
FALSE to continue foreach calls

Callback designed as a GtkTreeModelForeachFunc. It greps the track data from the model at iter position, doing nothing when that track is disabled. Otherwise, when enabled, it renders line and points to the TrackLayerPriv.Surface to be shown in the next call to track_layer_draw().

Since
0.0

Definition at line 655 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_get_default()

FUNCTION_CDECL_AS_TrackLayerDefault_PTR track_layer_get_default ( BYVAL_AS_TrackLayer_PTR  Lay)

Provide the next default setting.

Parameters
LayLayer instance
Returns
Pointer to default setting for the next track

The TrackLayer instance holds a number of default settings for line and point color and width, used as start values when loading a new track. This function returns a pointer to the next setting, reseting to the first when all defaults were used.

Since
0.0

Definition at line 815 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_get_loader()

FUNCTION_CDECL_AS_TrackLoader_PTR track_layer_get_loader ( BYVAL_AS_TrackLayer_PTR  Lay)

Provide pointer to the active track.

Parameters
LayLayer instance
Returns
Pointer to currently active track

In the TrackLayer instance one of the loaded tracks is the active track. This function returns the pointer to that track.

Since
0.0

Definition at line 836 of file track_layer.bas.

◆ track_layer_center_track()

SUB_CDECL track_layer_center_track ( BYVAL_AS_TrackLayer_PTR  Lay)

Show complete track.

Parameters
LayLayer instance

Procedure setting map position (center) and zoom to show the active track completely on the map.

Since
0.0

Definition at line 853 of file track_layer.bas.

◆ track_layer_set_loader()

SUB_CDECL track_layer_set_loader ( BYVAL_AS_TrackLayer_PTR  Lay,
BYVAL_AS_TrackLoader_PTR  Loa 
)

Set active track.

Parameters
LayLayer instance
LoaTrack to activate (or NULL)

Procedure receiving a track to make it the active one. When Loa is NULL, no track is active.

Since
0.0

Definition at line 875 of file track_layer.bas.

Here is the caller graph for this function:

◆ track_layer_redraw()

SUB_CDECL track_layer_redraw ( BYVAL_AS_TrackLayer_PTR  Lay)

Redraw surface.

Parameters
LayLayer instance

Procedure forcing a redraw of the TrackLayerPriv.Surface, ie to show adapted track settings.

Since
0.0

Definition at line 897 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ track_layer_get_point()

FUNCTION_CDECL_AS_gint track_layer_get_point ( BYVAL_AS_TrackLayer_PTR  Lay)

Get current point in active track.

Parameters
LayLayer instance
Returns
The point number (or -1)

When the TrackLayer holds an active track, a current point in that track can get centered on the map. This function provides the point index (0 <= p# <= AZ).

Since
0.0

Definition at line 915 of file track_layer.bas.

◆ track_layer_set_point()

SUB_CDECL track_layer_set_point ( BYVAL_AS_TrackLayer_PTR  Lay,
BYVAL_AS_gint  N 
)

Set current point in active track.

Parameters
LayLayer instance
NNew current point index

When the TrackLayer holds an active track, a current point in that track can get centered on the map. This function sets a point index to for the next current point. The N parameter gets clamped to the allowed range (0 <= N <= AZ).

Since
0.0

Definition at line 935 of file track_layer.bas.

◆ track_layer_set_bbox()

SUB_CDECL track_layer_set_bbox ( BYVAL_AS_TrackLayer_PTR  Lay,
BYVAL_AS_float  La0,
BYVAL_AS_float  La1,
BYVAL_AS_float  Lo0,
BYVAL_AS_float  Lo1 
)

Set map segment to the given bounding box.

Parameters
LayLayer instance
La0Top latitude [radians]
La1Bottom latitude [radians]
Lo0Left longitude [radians]
Lo1Right longitude [radians]

Procedure setting the map center and zoom in order to show a given rectangle.

Note
Coordinates in radians here!
Since
0.0

Definition at line 964 of file track_layer.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ track_layer_point_move()

SUB_CDECL track_layer_point_move ( BYVAL_AS_TrackLayer_PTR  Lay,
BYVAL_AS_gchar_PTR  S 
)

Move current point.

Parameters
LayLayer instance
SMovement type

Procedure adapting the index of the current point, showing that new current point centered on the map (at current zoom level).

Since
0.0

Definition at line 988 of file track_layer.bas.

Variable Documentation

◆ DEFAULT_ENTRIES

TrackLayerDefault DEFAULT_ENTRIES[...]
static
Initial value:
= {
, TYPE(@!"\&b01000111" "rgba(0xCE,0x5C,0x00,1)", @!"\1" "#FCAF3E")
, TYPE(@!"\&b10010111" "rgba(0xC4,0xA0,0x00,1)", @!"\1" "#FCE94F")
, TYPE(@!"\&h34" "rgba(0x4E,0x9A,0x06,1)", @!"\4" "#8AE234")
, TYPE(@!"\&h35" "rgba(0x20,0x4A,0x87,1)", @!"\5" "#729FCF")
, TYPE(@!"\&h35" "rgba(0x5C,0x35,0x66,1)", @!"\4" "#AD7FA8")
, TYPE(@!"\&h35" "rgba(0x8F,0x59,0x02,1)", @!"\5" "#E9B96E")
, TYPE(@!"\&h34" "rgba(0x2E,0x34,0x36,1)", @!"\4" "#888A85")
, TYPE(@!"\&h34" "rgba(0xBA,0xBD,0xB6,1)", @!"\4" "#EEEEEC")
, TYPE(NULL, NULL)}

Array of default setting for loaded tracks.

Definition at line 25 of file track_layer.bas.