![]() |
![]() |
![]() |
Grits Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Signals |
#define GRITS_LEVEL_BACKGROUND #define GRITS_LEVEL_WORLD #define GRITS_LEVEL_OVERLAY #define GRITS_LEVEL_HUD struct GritsViewer; struct GritsViewerClass; gdouble (*GritsHeightFunc) (gdouble lat
,gdouble lon
,gpointer user_data
); void grits_viewer_setup (GritsViewer *viewer
,GritsPlugins *plugins
,GritsPrefs *prefs
); void grits_viewer_set_time (GritsViewer *viewer
,time_t time
); time_t grits_viewer_get_time (GritsViewer *viewer
); void grits_viewer_set_location (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
); void grits_viewer_get_location (GritsViewer *viewer
,gdouble *lat
,gdouble *lon
,gdouble *elev
); void grits_viewer_pan (GritsViewer *viewer
,gdouble forward
,gdouble right
,gdouble up
); void grits_viewer_zoom (GritsViewer *viewer
,gdouble scale
); void grits_viewer_set_rotation (GritsViewer *viewer
,gdouble x
,gdouble y
,gdouble z
); void grits_viewer_get_rotation (GritsViewer *viewer
,gdouble *x
,gdouble *y
,gdouble *z
); void grits_viewer_rotate (GritsViewer *viewer
,gdouble x
,gdouble y
,gdouble z
); void grits_viewer_refresh (GritsViewer *viewer
); void grits_viewer_set_offline (GritsViewer *viewer
,gboolean offline
); gboolean grits_viewer_get_offline (GritsViewer *viewer
); void grits_viewer_center_position (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
); void grits_viewer_project (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
,gdouble *px
,gdouble *py
,gdouble *pz
); void grits_viewer_clear_height_func (GritsViewer *viewer
); void grits_viewer_set_height_func (GritsViewer *viewer
,GritsBounds *bounds
,GritsHeightFunc height_func
,gpointer user_data
,gboolean update
); gpointer grits_viewer_add (GritsViewer *viewer
,GritsObject *object
,gint level
,gboolean sort
); GritsObject * grits_viewer_remove (GritsViewer *viewer
,gpointer ref
);
GObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkDrawingArea +----GritsViewer +----GritsOpenGL
"location-changed" :Run Last
"offline" :Run Last
"refresh" :Run Last
"rotation-changed" :Run Last
"time-changed" :Run Last
GritsViewer is the base class for the virtual globe widget. It handles everything not directly related to drawing the globe. Plugins and applications using the viewer should normally talk to the viewer and not care how it is implemented.
#define GRITS_LEVEL_BACKGROUND -100
The level used to draw background objects (stars, atmosphere, etc).
#define GRITS_LEVEL_WORLD 0
The level used to draw world objects. This is for both surface data as well
as things in the air or underground. Most objects should use
GRITS_LEVEL_WORLD
;
#define GRITS_LEVEL_OVERLAY 100
The level used to draw screen overlays. These will be drawn in front of most
of ther objects. Text and markers should use GRITS_LEVEL_OVERLAY
.
#define GRITS_LEVEL_HUD 200
The level used to draw the Heads Up Display. This is for things that are not anchored at all the the world. They should be drawn in front of everything else.
struct GritsViewerClass { GtkDrawingAreaClass parent_class; /* class members */ void (*center_position) (GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev); void (*project) (GritsViewer *viewer, gdouble lat, gdouble lon, gdouble elev, gdouble *px, gdouble *py, gdouble *pz); void (*clear_height_func)(GritsViewer *viewer); void (*set_height_func) (GritsViewer *viewer, GritsBounds *bounds, GritsHeightFunc height_func, gpointer user_data, gboolean update); gpointer (*add) (GritsViewer *viewer, GritsObject *object, gint level, gboolean sort); GritsObject *(*remove) (GritsViewer *viewer, gpointer ref); };
gdouble (*GritsHeightFunc) (gdouble lat
,gdouble lon
,gpointer user_data
);
Determine the surface elevation (ground level) at a given point.
|
the target latitude |
|
the target longitude |
|
user data passed to the function |
Returns : |
the elevation in meters above sea level |
void grits_viewer_setup (GritsViewer *viewer
,GritsPlugins *plugins
,GritsPrefs *prefs
);
This should be called by objects which implement GritsViewer somewhere in their constructor.
|
the viewer |
|
a plugins store |
|
a prefs store |
void grits_viewer_set_time (GritsViewer *viewer
,time_t time
);
Set the current time for the view
|
the viewer |
|
the time to set the view to |
time_t grits_viewer_get_time (GritsViewer *viewer
);
Get the time that is being viewed
|
the viewer |
Returns : |
the current time |
void grits_viewer_set_location (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
);
Set the location for the camera
|
the viewer |
|
the new latitude |
|
the new longitude |
|
the new elevation |
void grits_viewer_get_location (GritsViewer *viewer
,gdouble *lat
,gdouble *lon
,gdouble *elev
);
Get the location of the camera
|
the viewer |
|
the location to store the latitude |
|
the location to store the longitude |
|
the location to store the elevation |
void grits_viewer_pan (GritsViewer *viewer
,gdouble forward
,gdouble right
,gdouble up
);
Pan the location by a number of meters long the surface.
Bugs: the distances are not in meters Bugs: panning does not move in strait lines
|
the viewer |
|
distance to move forward in meters |
|
distance to move right in meters |
|
distance to move up in meters |
void grits_viewer_zoom (GritsViewer *viewer
,gdouble scale
);
Multiple the elevation by a scale.
|
the viewer |
|
the scale to multiple the elevation by |
void grits_viewer_set_rotation (GritsViewer *viewer
,gdouble x
,gdouble y
,gdouble z
);
Set the rotations in degrees around the x, y, and z axes.
|
the viewer |
|
rotation new around the x axes |
|
rotation new around the y axes |
|
rotation new around the z axes |
void grits_viewer_get_rotation (GritsViewer *viewer
,gdouble *x
,gdouble *y
,gdouble *z
);
Get the rotations in degrees around the x, y, and z axes.
|
the viewer |
|
rotation around the x axes |
|
rotation around the y axes |
|
rotation around the z axes |
void grits_viewer_rotate (GritsViewer *viewer
,gdouble x
,gdouble y
,gdouble z
);
Add to the rotation around the x, y, and z axes.
|
the viewer |
|
rotation around the x axes |
|
rotation around the y axes |
|
rotation around the z axes |
void grits_viewer_refresh (GritsViewer *viewer
);
Trigger the refresh signal. This will cause any remote data to be checked for updates.
|
the viewer |
void grits_viewer_set_offline (GritsViewer *viewer
,gboolean offline
);
Set the offline mode. If offline
is TRUE
, only locally cached data will be
used.
|
the viewer |
|
TRUE to enter offline mode |
gboolean grits_viewer_get_offline (GritsViewer *viewer
);
Check if the viewer is in offline mode.
|
the viewer |
Returns : |
TRUE if the viewer is in offline mode. |
void grits_viewer_center_position (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
);
Center the viewer on a point. This can be used before drawing operations to center the items a particular location.
|
the viewer |
|
the latitude |
|
the longitude |
|
the elevation |
void grits_viewer_project (GritsViewer *viewer
,gdouble lat
,gdouble lon
,gdouble elev
,gdouble *px
,gdouble *py
,gdouble *pz
);
Project a latitude, longitude, elevation point to to x, y, and z coordinates in screen space. Useful for drawing orthographic data over a particular point in space. E.g. GritsMarker.
|
the viewer |
|
the latitude |
|
the latitude |
|
the latitude |
|
the project x coordinate |
|
the project y coordinate |
|
the project z coordinate |
void grits_viewer_clear_height_func (GritsViewer *viewer
);
Clears the height function for the entire viewer. Useful when an elevation plugin is unloaded.
|
the viewer |
void grits_viewer_set_height_func (GritsViewer *viewer
,GritsBounds *bounds
,GritsHeightFunc height_func
,gpointer user_data
,gboolean update
);
Set the height function to be used for a given part of the surface..
|
the viewer |
|
the area to set the height function for |
|
the height function |
|
user data to pass to the height function |
|
TRUE if the heights inside the bounds should be updated. |
gpointer grits_viewer_add (GritsViewer *viewer
,GritsObject *object
,gint level
,gboolean sort
);
Objects which are added to the viewer will be drawn on subsequent renderings if their level of details is adequate.
The level
represents the order the object should be drawn in, this is
unrelated to the objects actual position in the world.
Semi-transparent objects should set sort
to TRUE
so that they are rendered
correctly when they overlap other semi-transparent objects.
The viewer steals the objects reference. Call g_object_ref if you plan on holding a reference as well.
|
the viewer |
|
the object to add |
|
the level to add the object to |
|
TRUE if the object should be depth-sorted prior to being drawn |
Returns : |
a handle to be pass to grits_viewer_remove()
|
GritsObject * grits_viewer_remove (GritsViewer *viewer
,gpointer ref
);
Remove an object from the viewer. The objects reference count is decremented prior to being removed.
|
the viewer |
|
the handle obtained from grits_viewer_add()
|
Returns : |
the GritsObject referenced by the handle |
"location-changed"
signalvoid user_function (GritsViewer *viewer,
gdouble lat,
gdouble lon,
gdouble elev,
gpointer user_data) : Run Last
The ::location-changed signal is emitted when the viewers camera location changes.
|
the viewer. |
|
the new latitude. |
|
the new longitude. |
|
the new elevation. |
|
user data set when the signal handler was connected. |
"offline"
signalvoid user_function (GritsViewer *viewer,
gboolean offline,
gpointer user_data) : Run Last
The ::offline signal is emitted when the viewers offline mode changes.
|
the viewer. |
|
TRUE if the viewer going offline. |
|
user data set when the signal handler was connected. |
"refresh"
signalvoid user_function (GritsViewer *viewer,
gpointer user_data) : Run Last
The ::refresh signal is emitted when a refresh is needed. If you are using real-time data from a remote server, you should connect to the refresh signal and update the data when necessary.
|
the viewer. |
|
user data set when the signal handler was connected. |
"rotation-changed"
signalvoid user_function (GritsViewer *viewer,
gdouble x,
gdouble y,
gdouble z,
gpointer user_data) : Run Last
The ::rotation-changed signal is emitted when the viewers cameras rotation changes.
|
the viewer. |
|
rotation new around the x axes. |
|
rotation new around the y axes. |
|
rotation new around the z axes. |
|
user data set when the signal handler was connected. |
"time-changed"
signalvoid user_function (GritsViewer *viewer,
glong time,
gpointer user_data) : Run Last
The ::time-changed signal is emitted when the viewers current time changers.
|
the viewer. |
|
the new time. |
|
user data set when the signal handler was connected. |