]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikcoordlayer.c
Tidy up: simpler and better use of trackpoint free methods in TRW Layer.
[andy/viking.git] / src / vikcoordlayer.c
index 2302d65e70945351368085257d4453ad1e7da63d..e6aaf593ab179255ece253e70e95ed507586e633 100644 (file)
@@ -32,8 +32,8 @@
 
 static void coord_layer_marshall( VikCoordLayer *vcl, guint8 **data, gint *len );
 static VikCoordLayer *coord_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp );
 
 static void coord_layer_marshall( VikCoordLayer *vcl, guint8 **data, gint *len );
 static VikCoordLayer *coord_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp );
-static gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamData data, VikViewport *vp );
-static VikLayerParamData coord_layer_get_param ( VikCoordLayer *vcl, guint16 id );
+static gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamData data, VikViewport *vp, gboolean is_file_operation );
+static VikLayerParamData coord_layer_get_param ( VikCoordLayer *vcl, guint16 id, gboolean is_file_operation );
 static void coord_layer_update_gc ( VikCoordLayer *vcl, VikViewport *vp, const gchar *color );
 static void coord_layer_post_read ( VikLayer *vl, VikViewport *vp, gboolean from_file );
 
 static void coord_layer_update_gc ( VikCoordLayer *vcl, VikViewport *vp, const gchar *color );
 static void coord_layer_post_read ( VikLayer *vl, VikViewport *vp, gboolean from_file );
 
@@ -52,7 +52,8 @@ static VikLayerParam coord_layer_params[] = {
 enum { PARAM_COLOR = 0, PARAM_MIN_INC, PARAM_LINE_THICKNESS, NUM_PARAMS };
 
 VikLayerInterface vik_coord_layer_interface = {
 enum { PARAM_COLOR = 0, PARAM_MIN_INC, PARAM_LINE_THICKNESS, NUM_PARAMS };
 
 VikLayerInterface vik_coord_layer_interface = {
-  "Coord",
+  N_("Coordinate"),
+  NULL,
   &vikcoordlayer_pixbuf,
 
   NULL,
   &vikcoordlayer_pixbuf,
 
   NULL,
@@ -82,6 +83,9 @@ VikLayerInterface vik_coord_layer_interface = {
 
   (VikLayerFuncSublayerRenameRequest)   NULL,
   (VikLayerFuncSublayerToggleVisible)   NULL,
 
   (VikLayerFuncSublayerRenameRequest)   NULL,
   (VikLayerFuncSublayerToggleVisible)   NULL,
+  (VikLayerFuncSublayerTooltip)         NULL,
+  (VikLayerFuncLayerTooltip)            NULL,
+  (VikLayerFuncLayerSelected)           NULL,
 
   (VikLayerFuncMarshall)               coord_layer_marshall,
   (VikLayerFuncUnmarshall)             coord_layer_unmarshall,
 
   (VikLayerFuncMarshall)               coord_layer_marshall,
   (VikLayerFuncUnmarshall)             coord_layer_unmarshall,
@@ -93,10 +97,16 @@ VikLayerInterface vik_coord_layer_interface = {
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
   (VikLayerFuncWriteFileData)           NULL,
 
   (VikLayerFuncDeleteItem)              NULL,
+  (VikLayerFuncCutItem)                 NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
   (VikLayerFuncDragDropRequest)                NULL,
   (VikLayerFuncCopyItem)                NULL,
   (VikLayerFuncPasteItem)               NULL,
   (VikLayerFuncFreeCopiedItem)          NULL,
   (VikLayerFuncDragDropRequest)                NULL,
+
+  (VikLayerFuncSelectClick)             NULL,
+  (VikLayerFuncSelectMove)              NULL,
+  (VikLayerFuncSelectRelease)           NULL,
+  (VikLayerFuncSelectedViewportMenu)    NULL,
 };
 
 struct _VikCoordLayer {
 };
 
 struct _VikCoordLayer {
@@ -138,12 +148,12 @@ static void coord_layer_marshall( VikCoordLayer *vcl, guint8 **data, gint *len )
 
 static VikCoordLayer *coord_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp )
 {
 
 static VikCoordLayer *coord_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp )
 {
-  VikCoordLayer *rv = vik_coord_layer_new ( vvp );
+  VikCoordLayer *rv = vik_coord_layer_new ();
   vik_layer_unmarshall_params ( VIK_LAYER(rv), data, len, vvp );
   return rv;
 }
 
   vik_layer_unmarshall_params ( VIK_LAYER(rv), data, len, vvp );
   return rv;
 }
 
-gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamData data, VikViewport *vp )
+gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamData data, VikViewport *vp, gboolean is_file_operation )
 {
   switch ( id )
   {
 {
   switch ( id )
   {
@@ -154,7 +164,7 @@ gboolean coord_layer_set_param ( VikCoordLayer *vcl, guint16 id, VikLayerParamDa
   return TRUE;
 }
 
   return TRUE;
 }
 
-static VikLayerParamData coord_layer_get_param ( VikCoordLayer *vcl, guint16 id )
+static VikLayerParamData coord_layer_get_param ( VikCoordLayer *vcl, guint16 id, gboolean is_file_operation )
 {
   VikLayerParamData rv;
   switch ( id )
 {
   VikLayerParamData rv;
   switch ( id )
@@ -332,6 +342,17 @@ void vik_coord_layer_draw ( VikCoordLayer *vcl, gpointer data )
       max.lat = (topleft.lat > topright.lat) ? topleft.lat : topright.lat;
     }
 
       max.lat = (topleft.lat > topright.lat) ? topleft.lat : topright.lat;
     }
 
+    /* Can zoom out more than whole world and so the above can give invalid positions */
+    /* Restrict values properly so drawing doesn't go into a near 'infinite' loop */
+    if ( min.lon < -180.0 )
+      min.lon = -180.0;
+    if ( max.lon > 180.0 )
+      max.lon = 180.0;
+    if ( min.lat < -90.0 )
+      min.lat = -90.0;
+    if ( max.lat > 90.0 )
+      max.lat = 90.0;
+
     lon = ((double) ((long) ((min.lon)/ vcl->deg_inc))) * vcl->deg_inc;
     ll.lon = ll2.lon = lon;
 
     lon = ((double) ((long) ((min.lon)/ vcl->deg_inc))) * vcl->deg_inc;
     ll.lon = ll2.lon = lon;