GeoCanvas

GeoCanvas — the main widget for the geographic canvas.

Synopsis




enum        GeoFunctionState;
#define     GEO_TYPE_FUNCTION_STATE
            GeoCanvasPrivate;
            GeoCanvas;
            GeoCanvasClass;
GType       geo_canvas_get_type             (void);
void        geo_canvas_center_on            (GeoCanvas *canvas,
                                             double lon,
                                             double lat);
void        geo_canvas_set_viewport_g       (GeoCanvas *canvas,
                                             double lon1,
                                             double lat1,
                                             double lon2,
                                             double lat2);
void        geo_canvas_set_viewport_w       (GeoCanvas *canvas,
                                             double wx1,
                                             double wy1,
                                             double wx2,
                                             double wy2);
void        geo_canvas_get_viewport_w       (GeoCanvas *canvas,
                                             double *wx1,
                                             double *wy1,
                                             double *wx2,
                                             double *wy2);
void        geo_canvas_zoom                 (GeoCanvas *canvas,
                                             double z);
void        geo_canvas_max_extents          (GeoCanvas *canvas);
void        geo_canvas_set_max_extents      (GeoCanvas *canvas,
                                             double lon1,
                                             double lat1,
                                             double lon2,
                                             double lat2);
void        geo_canvas_activate_reference   (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);
void        geo_canvas_deactivate_reference (GeoCanvas *canvas);
void        geo_canvas_activate_pan         (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);
void        geo_canvas_deactivate_pan       (GeoCanvas *canvas);
void        geo_canvas_activate_zoombox     (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);
void        geo_canvas_deactivate_zoombox   (GeoCanvas *canvas);
void        geo_canvas_activate_center      (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);
void        geo_canvas_deactivate_center    (GeoCanvas *canvas);
GeoCanvas*  geo_canvas_new_replace          (GtkWidget *window,
                                             const gchar *canvas_name);

Object Hierarchy


  GObject
   +----GtkObject
         +----GtkWidget
               +----GtkContainer
                     +----GtkLayout
                           +----FooCanvas
                                 +----GeoCanvas

Implemented Interfaces

GeoCanvas implements AtkImplementorIface.

Properties


  "center-button"        gint                  : Read / Write
  "center-cursor"        gint                  : Read / Write
  "center-state"         GeoFunctionState      : Read / Write
  "extents-level"        gint                  : Read
  "pan-button"           gint                  : Read / Write
  "pan-cursor"           gint                  : Read / Write
  "pan-state"            GeoFunctionState      : Read / Write
  "projection"           GeoProjection         : Read / Write
  "reference-button"     gint                  : Read / Write
  "reference-cursor"     gint                  : Read / Write
  "reference-state"      GeoFunctionState      : Read / Write
  "zoombox-button"       gint                  : Read / Write
  "zoombox-cursor"       gint                  : Read / Write
  "zoombox-fill-color-rgba" gulong                : Read / Write
  "zoombox-outline-color-rgba" gulong                : Read / Write
  "zoombox-state"        GeoFunctionState      : Read / Write

Signal Prototypes


"before-update"
            void        user_function      (GeoCanvas *geocanvas,
                                            gpointer user_data);
"projection-changed"
            void        user_function      (GeoCanvas *geocanvas,
                                            gpointer user_data);
"scroll-region-changed"
            void        user_function      (GeoCanvas *geocanvas,
                                            gpointer user_data);
"viewport-changed"
            void        user_function      (GeoCanvas *geocanvas,
                                            gpointer user_data);

Description

The GeoCanvas widget adds scroll area and viewport area management functionality to the GnomeCanvas. Such functionality becomes relevant when dealing with geography because the 'geo' view is bounded by longitude and latitude coordinates. Any stock GnomeCanvasItem can be represented on the GeoCanvas; however, all items should be made aware of the additional mapping between GnomeCanvas 'world' coordinates and GeoCanvas 'geo' coordinates. The GeoCanvasLnarr and GeoCanvasPlace items have this awareness built-in.

Creating the canvas is essentially the same as creating a GnomeCanvas.


GtkWidget *canvas, *scrolledwindow;

scrolledwindow = gtk_scrolled_window_new (NULL, NULL);

canvas = GTK_WIDGET(g_object_new(GEO_TYPE_CANVAS, NULL));

gtk_widget_show (canvas);

gtk_container_add (GTK_CONTAINER (scrolledwindow), canvas);

Details

enum GeoFunctionState

typedef enum {
        GEO_INACTIVE,
        GEO_SINGLE_ACTIVE,
        GEO_CONTINUOUS_ACTIVE
} GeoFunctionState;


GEO_TYPE_FUNCTION_STATE

#define GEO_TYPE_FUNCTION_STATE geo_function_state_get_type()


GeoCanvasPrivate

typedef struct _GeoCanvasPrivate GeoCanvasPrivate;

This implementation has been hidden from global view.


GeoCanvas

typedef struct _GeoCanvas GeoCanvas;


GeoCanvasClass

typedef struct {
        FooCanvasClass parent_class;

        /* Signals go here */

        /**
         * projection_changed:
         * @canvas:
         *
         * This indicates either that the canvas is using a new projection
         * object or that some property of the existing projection object has
         * changed.  Canvas items should use this signal instead of the signal
         * that comes directly from the projection.
         **/
        void (*projection_changed)(GeoCanvas *canvas);

        /**
         * viewport_changed:
         * @canvas:
         *
         * This signal is emitted one second after the user stops manipulating
         * the zoom, pan, horizontal, or vertical adjustments.
         **/
        void (*viewport_changed)(GeoCanvas *canvas);

        /**
         * scroll_region_changed:
         * @canvas:
         *
         * This signal is emitted whenever the GeoCanvas automatically modifies
         * the scrolling region.  As the user zooms in, the GeoCanvas
         * automatically shrinks the scrolling region so that it is not
         * unreasonably large and to prevent recursion issues during the render
         * phase of the AA canvas. As the user zooms out the GeoCanvas will
         * increase the scrolling region.
         **/
        void (*scroll_region_changed)(GeoCanvas *canvas);

        /**
          * before_update:
          * @canvas:
          *
          * This signal is emitted just prior to a canvas update.  It is an idle
          * handler on a higher priority than the canvas. This is a good
          * time to add or remove canvas items that may be queued up.
          **/
        void (*before_update)(GeoCanvas *canvas);
} GeoCanvasClass;


geo_canvas_get_type ()

GType       geo_canvas_get_type             (void);

Returns :

geo_canvas_center_on ()

void        geo_canvas_center_on            (GeoCanvas *canvas,
                                             double lon,
                                             double lat);

Centers around a geographic point. This does not change the projection reference point, so unless you are zoomed in and using a cylyndrical projection, this routine is really of little use.

canvas :
lon : Longitude in degrees.
lat : Latitude in degrees.

geo_canvas_set_viewport_g ()

void        geo_canvas_set_viewport_g       (GeoCanvas *canvas,
                                             double lon1,
                                             double lat1,
                                             double lon2,
                                             double lat2);

Sets the canvas viewport in geographic coordinates. This will reset the reference point for the projection to the center of the viewport.

canvas :
lon1 : Longitude in degrees.
lat1 : Latitude in degrees.
lon2 : Longitude in degrees.
lat2 : Latitude in degrees.

geo_canvas_set_viewport_w ()

void        geo_canvas_set_viewport_w       (GeoCanvas *canvas,
                                             double wx1,
                                             double wy1,
                                             double wx2,
                                             double wy2);

Sets the screen viewport in canvas world coordinates. This will reset the reference point for the projection to the center of the viewport.

canvas :
wx1 : Canvas world coordinate left.
wy1 : Canvas world coordinate top.
wx2 : Canvas world coordinate right.
wy2 : Canvas world coordinate bottom.

geo_canvas_get_viewport_w ()

void        geo_canvas_get_viewport_w       (GeoCanvas *canvas,
                                             double *wx1,
                                             double *wy1,
                                             double *wx2,
                                             double *wy2);

Gets the screen viewport in canvas world coordinates.

canvas :
wx1 : Canvas world coordinate left.
wy1 : Canvas world coordinate top.
wx2 : Canvas world coordinate right.
wy2 : Canvas world coordinate bottom.

geo_canvas_zoom ()

void        geo_canvas_zoom                 (GeoCanvas *canvas,
                                             double z);

Zooms in or out around the present center point. For example a z value of 2 will zoom reduce the viewed area by 2. A z value of 0.5 will increase the viewed area by 2.

canvas :
z : The percentage to zoom in or out.

geo_canvas_max_extents ()

void        geo_canvas_max_extents          (GeoCanvas *canvas);

Sets the viewport to show the most optimum view of the whole world.

canvas :

geo_canvas_set_max_extents ()

void        geo_canvas_set_max_extents      (GeoCanvas *canvas,
                                             double lon1,
                                             double lat1,
                                             double lon2,
                                             double lat2);

Forces the boundaries of the map to fixed locations. Scrolling and zooming will not allow the map to show more than this area. Calling this function overrides the canvas automatic extent setting mechanism. WARNING: If map data is provided that covers an area much larger than this, then things can get really messed up. Be careful with what you try to draw after calling this.

canvas :
lon1 : Longitude in degrees.
lat1 : Latitude in degrees.
lon2 : Longitude in degrees.
lat2 : Latitude in degrees.

geo_canvas_activate_reference ()

void        geo_canvas_activate_reference   (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);

Activates a reference select from the cursor. When the user clicks on the canvas, that reference point will be selected. This function is also available via the reference-state property.

canvas :
button : Which mouse button to use (left = 1, middle = 2, right = 3).
onetime : FALSE cause this to remain activated when the action is complete.

geo_canvas_deactivate_reference ()

void        geo_canvas_deactivate_reference (GeoCanvas *canvas);

Deactivates the reference select function. This function is also available via the reference-state property.

canvas :

geo_canvas_activate_pan ()

void        geo_canvas_activate_pan         (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);

Activates a pan select from the cursor. When the user clicks and drags on the canvas, the canvas will pan to the cursor motion. This function is also available via the pan-state property.

canvas :
button : Which mouse button to use (left = 1, middle = 2, right = 3).
onetime : FALSE cause this to remain activated when the action is complete.

geo_canvas_deactivate_pan ()

void        geo_canvas_deactivate_pan       (GeoCanvas *canvas);

Deactivates the panning function. This function is also available via the pan-state property.

canvas :

geo_canvas_activate_zoombox ()

void        geo_canvas_activate_zoombox     (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);

Activates a zoom box select from the cursor. When the user clicks and drags on the canvas, a zoom box will appear around the click center point. This function is also available via the zoombox-state property.

canvas :
button : Which mouse button to use (left = 1, middle = 2, right = 3).
onetime : FALSE cause this to remain activated when the action is complete.

geo_canvas_deactivate_zoombox ()

void        geo_canvas_deactivate_zoombox   (GeoCanvas *canvas);

Deactivates the zoombox function. This function is also available via the zoombox-state property.

canvas :

geo_canvas_activate_center ()

void        geo_canvas_activate_center      (GeoCanvas *canvas,
                                             int button,
                                             gboolean onetime);

Activates a center point select from the cursor. When the user clicks on the canvas, the canvas will center around the cursor point without changing zoom scale. This function is also available via the center-state property.

canvas :
button : Which mouse button to use (left = 1, middle = 2, right = 3).
onetime : FALSE cause this to remain activated when the action is complete.

geo_canvas_deactivate_center ()

void        geo_canvas_deactivate_center    (GeoCanvas *canvas);

Deactivates the center select function. This function is also available via the center-state property.

canvas :

geo_canvas_new_replace ()

GeoCanvas*  geo_canvas_new_replace          (GtkWidget *window,
                                             const gchar *canvas_name);

This is a hack to destroy a regular FooCanvas object and replaces it with a GeoCanvas. It is here as a convenience to facilitate development using glade. i.e., Use glade to create the GUI with one or more FooCanvas widgets, then call this function to replace each FooCanvas widget with a GeoCanvas widget. Someday a nice Glade module would eliminate the need for this function.

If you are not using glade, then just use g_object_new to create the GeoCanvas.

window : The applications main window.
canvas_name : The name of the canvas that was specified using glade.
Returns : The newly created GeoCanvas.

Properties

The "center-button" property

  "center-button"        gint                  : Read / Write

Left button=1, middle = 2, right = 3.

Allowed values: [0,5]

Default value: 1


The "center-cursor" property

  "center-cursor"        gint                  : Read / Write

GDK Cursor to use when center is selected.

Allowed values: [0,153]

Default value: 24


The "center-state" property

  "center-state"         GeoFunctionState      : Read / Write

Activates a center point select from the cursor. When the user clicks on the canvas, the canvas will center around the cursor point without changing zoom scale. This function is also available via geo_canvas_activate_center().

Default value: GEO_INACTIVE


The "extents-level" property

  "extents-level"        gint                  : Read

This is an integer representation of the scroll region where zero represents the whole world and 4 represents a scroll area that is only 10 miles or so across. I doubt it will ever be larger than 5 or 6. Right now there are no zooming limitations.

Allowed values: [0,10]

Default value: 0


The "pan-button" property

  "pan-button"           gint                  : Read / Write

Left button=1, middle = 2, right = 3.

Allowed values: [0,5]

Default value: 2


The "pan-cursor" property

  "pan-cursor"           gint                  : Read / Write

GDK Cursor to use when pan is selected.

Allowed values: [0,153]

Default value: 56


The "pan-state" property

  "pan-state"            GeoFunctionState      : Read / Write

Activates a reference select from the cursor. When the user clicks on the canvas, that reference point will be selected. This function is also available via geo_canvas_activate_reference().

Default value: GEO_INACTIVE


The "projection" property

  "projection"           GeoProjection         : Read / Write

This property holds a reference to the GeoProjection that is currently in use by this canvas. It is feasible that an application may hold greater than one canvas, each with its own projection reference. It is also feasible that a particular canvas's projection reference could be changed dynamically.


The "reference-button" property

  "reference-button"     gint                  : Read / Write

Left button=1, middle = 2, right = 3.

Allowed values: [0,5]

Default value: 1


The "reference-cursor" property

  "reference-cursor"     gint                  : Read / Write

GDK Cursor to use when reference is selected.

Allowed values: [0,153]

Default value: 24


The "reference-state" property

  "reference-state"      GeoFunctionState      : Read / Write

Activates a reference select from the cursor. When the user clicks on the canvas, that reference point will be selected. This function is also available via geo_canvas_activate_reference().

Default value: GEO_INACTIVE


The "zoombox-button" property

  "zoombox-button"       gint                  : Read / Write

Left button=1, middle = 2, right = 3.

Allowed values: [0,5]

Default value: 2


The "zoombox-cursor" property

  "zoombox-cursor"       gint                  : Read / Write

GDK Cursor to use when zoombox is selected.

Allowed values: [0,153]

Default value: 52


The "zoombox-fill-color-rgba" property

  "zoombox-fill-color-rgba" gulong                : Read / Write

Zoombox Fill Color RGBA.


The "zoombox-outline-color-rgba" property

  "zoombox-outline-color-rgba" gulong                : Read / Write

Zoombox Outline Color RGBA.


The "zoombox-state" property

  "zoombox-state"        GeoFunctionState      : Read / Write

Activates a zoom box select from the cursor. When the user clicks and drags on the canvas, a zoom box will appear around the click center point. This function is also available via geo_canvas_activate_zoombox().

Default value: GEO_INACTIVE

Signals

The "before-update" signal

void        user_function                  (GeoCanvas *geocanvas,
                                            gpointer user_data);

This signal is emitted just prior to a canvas update. It is an idle handler on a higher priority than the canvas. This is a good time to add or remove canvas items that may be queued up.

geocanvas : the object which received the signal.
user_data : user data set when the signal handler was connected.

The "projection-changed" signal

void        user_function                  (GeoCanvas *geocanvas,
                                            gpointer user_data);

This indicates either that the canvas is using a new projection object or that some property of the existing projection object has changed. Canvas items should use this signal instead of the signal that comes directly from the projection.

geocanvas : the object which received the signal.
user_data : user data set when the signal handler was connected.

The "scroll-region-changed" signal

void        user_function                  (GeoCanvas *geocanvas,
                                            gpointer user_data);

This signal is emitted whenever the GeoCanvas automatically modifies the scrolling region. As the user zooms in, the GeoCanvas automatically shrinks the scrolling region so that it is not unreasonably large and to prevent recursion issues during the render phase of the AA canvas. As the user zooms out the GeoCanvas will increase the scrolling region.

geocanvas : the object which received the signal.
user_data : user data set when the signal handler was connected.

The "viewport-changed" signal

void        user_function                  (GeoCanvas *geocanvas,
                                            gpointer user_data);

This signal is emitted one second after the user stops manipulating the zoom, pan, horizontal, or vertical adjustments.

geocanvas : the object which received the signal.
user_data : user data set when the signal handler was connected.