Revision: 7274
http://playerstage.svn.sourceforge.net/playerstage/?rev=7274&view=rev
Author: alexcb
Date: 2009-01-15 23:15:17 +0000 (Thu, 15 Jan 2009)
Log Message:
-----------
added framework for user supplied custom visializations
Modified Paths:
--------------
code/stage/trunk/libstage/model.cc
code/stage/trunk/libstage/model.hh
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2009-01-15 23:13:38 UTC (rev 7273)
+++ code/stage/trunk/libstage/model.cc 2009-01-15 23:15:17 UTC (rev 7274)
@@ -137,6 +137,7 @@
data_fresh(false),
disabled(false),
flag_list(NULL),
+ custom_visual_list( NULL ),
geom(),
has_default_block( true ),
id( Model::count++ ),
@@ -896,6 +897,19 @@
glPopMatrix();
}
+void Model::AddCustomVisualizer( CustomVisualizer* custom_visual )
+{
+ if( custom_visual )
+ custom_visual_list = g_list_append(custom_visual_list,
custom_visual );
+}
+
+void Model::RemoveCustomVisualizer( CustomVisualizer* custom_visual )
+{
+ if( custom_visual )
+ custom_visual_list = g_list_remove(custom_visual_list,
custom_visual );
+}
+
+
void Model::DrawStatusTree( Camera* cam )
{
PushLocalCoords();
@@ -1143,6 +1157,11 @@
PushLocalCoords();
DataVisualize( cam ); // virtual function overridden by most model types
+ for( GList* item = custom_visual_list; item; item = item->next ) {
+ static_cast< CustomVisualizer* >( item->data )->DataVisualize( cam );
+ }
+
+
// and draw the children
LISTMETHODARG( children, Model*, DataVisualizeTree, cam );
Modified: code/stage/trunk/libstage/model.hh
===================================================================
--- code/stage/trunk/libstage/model.hh 2009-01-15 23:13:38 UTC (rev 7273)
+++ code/stage/trunk/libstage/model.hh 2009-01-15 23:15:17 UTC (rev 7274)
@@ -34,7 +34,15 @@
}
};
+/** Abstract class for adding visualizations to models. DataVisualize must be
overloaded, and is then called in the models local coord system */
+class CustomVisualizer {
+public:
+ //TODO allow user to specify name - which will show up in display filter
+ virtual ~CustomVisualizer( void ) { }
+ virtual void DataVisualize( Camera* cam ) = 0;
+};
+
/* Hooks for attaching special callback functions (not used as
variables - we just need unique addresses for them.) */
class CallbackHooks
@@ -116,6 +124,7 @@
instead of adding a data callback. */
bool data_fresh;
stg_bool_t disabled; //< if non-zero, the model is disabled
+ GList* custom_visual_list;
GList* flag_list;
Geom geom;
Pose global_pose;
@@ -343,6 +352,11 @@
virtual ~Model();
void Say( const char* str );
+ /** Attach a user supplied visualization to a model */
+ void AddCustomVisualizer( CustomVisualizer* custom_visual );
+ /** remove user supplied visualization to a model - supply the same ptr
passed to AddCustomVisualizer */
+ void RemoveCustomVisualizer( CustomVisualizer* custom_visual );
+
void Load( Worldfile* wf, int wf_entity )
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit