#include <vhdOSGViewerServiceBody.h>
Inheritance diagram for vhdOSGViewerServiceBody:
Public Member Functions | |
vhdOSGViewerServiceBody (const std::string &serviceClassName, const std::string &serviceName) | |
virtual | ~vhdOSGViewerServiceBody () |
int | nbProperty (void) const |
vhdPropertyRef | getProperty (const int id) const |
vhdPropertyRef | getProperty (const std::string &pname) const |
bool | toggleMovieGrabber (int fps=10) |
bool | registerDefaultKeys (void) |
bool | unregisterDefaultKeys (void) |
virtual osgNodeRef | getSceneGraphRoot (void) |
virtual osgProducerViewerRef | getViewer (void) |
virtual CameraManipulatorRef | getCameraManipulator (void) |
void | setViewMatrix (osg::Matrixd &vMat) |
void | setVHDViewMatrix (const vhdMatrix4 vMat) |
osg::Matrixd | getViewMatrix (void) |
vhdMatrix4 | getVHDViewMatrix (void) |
void | getViewMatrixAsLookAt (osg::Vec3 &eye, osg::Vec3 ¢er, osg::Vec3 &up, float lookDistance=1.0f) |
void | getVHDViewMatrixAsLookAt (vhdVector3 &eye, vhdVector3 ¢er, vhdVector3 &up, float lookDistance=1.0f) |
void | setViewMatrixAsLookAt (osg::Vec3 &eye, osg::Vec3 ¢er, osg::Vec3 &up) |
void | setVHDViewMatrixAsLookAt (const vhdVector3 &eye, const vhdVector3 ¢er, const vhdVector3 &up) |
void | setProjMatrixPerspective (double fovx, double fovy, double aspectRatio, double nearClip, double farClip) |
void | setLensOrtho (double left, double right, double bottom, double top, double nearClip, double farClip) |
bool | getIntersectionsWithScene (float x, float y, HitList &hits, unsigned int camera=0) |
void | setCursorPosition (float x, float y, unsigned int camera=0) |
void | startRecordingCameraPath () |
void | stopRecordingCameraPath (const std::string &pathfilename="saved_animation.path", bool autoStart=false) |
void | playRecordedCameraPath (const std::string &pathfilename="saved_animation.path") |
void | setHUDText (const std::string &textToSet) |
void | setHUDText (const std::string &textToSet, const std::string &encoding) |
void | setHUDTextPosition (vhdVector2 &position) |
void | setHUDTextSize (int size) |
void | setHUDTextFont (const std::string &font) |
void | setHUDTextColor (vhdVector4 &color) |
HWND | getOSGWindowHandle (void) |
bool | getIsViewerRealizedAtRun (void) |
void | setIsViewerRealizedAtRun (bool realizeAtRun) |
Static Public Member Functions | |
static vhdOSGViewerServiceBody * | cast (vhdServiceBody *body) |
Protected Member Functions | |
bool | getMovieGrabberState (void) const |
bool | setMovieGrabberState (bool start, int fps=10) |
virtual vhtSize32 | _getServiceBodyVersionImplem () |
virtual void | _declareCollaborationsImplem () |
virtual vhtBool | _initImplem (vhdServiceContextRef serviceContext) |
virtual vhtBool | _initPropertyScanImplem (vhdPropertyRef property) |
virtual bool | _runImplem () |
virtual vhtBool | _terminateImplem () |
virtual vhtBool | _updateImplem () |
virtual void | _handleWarpClockExchangeImplem (const std::string &warpClockName, vhdWarpClockRef warpClock) |
virtual void | _handleAddServiceImplem (vhdServiceHandleRef serviceHandle) |
virtual void | _handleRemoveServiceImplem (vhdServiceHandleRef serviceHandle) |
virtual void | _handleServiceStateChangeImplem (vhdServiceHandleRef serviceHandle) |
virtual vhtBool | _handleAddPropertyScanImplem (vhdPropertyRef property) |
virtual vhtBool | _handleRemovePropertyScanImplem (vhdPropertyRef property) |
virtual void | _handlePropertyChangeImplem (vhdPropertyRef property) |
virtual vhtBool | _filterEventImplem (vhdEventRef event) |
virtual vhtBool | _handleEventImplem (vhdEventRef event) |
Static Protected Member Functions | |
static bool | defaultCBHandler (void *self, int key, int value) |
Private Attributes | |
vhdCLASS_TYPE | |
_Impl * | _impl |
Classes | |
class | _Impl |
vhdOSGViewerServiceBody::vhdOSGViewerServiceBody | ( | const std::string & | serviceClassName, | |
const std::string & | serviceName | |||
) |
Constructor.
vhdOSGViewerServiceBody::~vhdOSGViewerServiceBody | ( | ) | [virtual] |
Destructor.
static vhdOSGViewerServiceBody* vhdOSGViewerServiceBody::cast | ( | vhdServiceBody * | body | ) | [inline, static] |
int vhdOSGViewerServiceBody::nbProperty | ( | void | ) | const |
Get the number of OSGViewerService registered vhdProperty (either vhdGeometryProperty or vhdHANIMProperty)
vhdPropertyRef vhdOSGViewerServiceBody::getProperty | ( | const int | id | ) | const |
Get one OSGViewerService registered vhdProperty by index [in the internal propertyController table] (either vhdGeometryProperty or vhdHANIMProperty) Return NULL if index out of bound.
vhdPropertyRef vhdOSGViewerServiceBody::getProperty | ( | const std::string & | pname | ) | const |
Get one OSGViewerService registered vhdProperty by name (either vhdGeometryProperty or vhdHANIMProperty) Return NULL if no registered property found for the given 'pname'.
bool vhdOSGViewerServiceBody::toggleMovieGrabber | ( | int | fps = 10 |
) |
Start/Stop the MovieGrabber engine. (This is currently a Windows only feature).
bool vhdOSGViewerServiceBody::registerDefaultKeys | ( | void | ) |
Register the default set of keyboard behaviour.
bool vhdOSGViewerServiceBody::unregisterDefaultKeys | ( | void | ) |
Unregister the default set of keyboard behaviour.
bool vhdOSGViewerServiceBody::defaultCBHandler | ( | void * | self, | |
int | key, | |||
int | value | |||
) | [static, protected] |
Callback implementing the default set of keyboard behaviour.
bool vhdOSGViewerServiceBody::getMovieGrabberState | ( | void | ) | const [protected] |
Return the status of the MovieGrabber engine. (This is currently a Windows only feature).
bool vhdOSGViewerServiceBody::setMovieGrabberState | ( | bool | start, | |
int | fps = 10 | |||
) | [protected] |
Triggers the MovieGrabber engine on/off. (This is currently a Windows only feature).
virtual vhtSize32 vhdOSGViewerServiceBody::_getServiceBodyVersionImplem | ( | ) | [inline, protected, virtual] |
___IMPLEMENT IT___
Imeplement it as a simple inline method returning version number of your ServiceBody implementation. Example: virtual vhtSize32 _getServiceVersion() { return 27; }
virtual void vhdOSGViewerServiceBody::_declareCollaborationsImplem | ( | ) | [inline, protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
vhtBool vhdOSGViewerServiceBody::_initImplem | ( | vhdServiceContextRef | serviceContext | ) | [protected, virtual] |
___IMPLEMENT IT___
Called by vhdServiceHandle to notify ServiceBody that it should initialize itself. It is assured that the non-NULL cnotext is passed thanks to the thread safe interface
vhtBool vhdOSGViewerServiceBody::_initPropertyScanImplem | ( | vhdPropertyRef | property | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
Right after _initImplem() the kernel will make the vhdProperty tree scan for you using vhdPropertyTreeIterator and it will feed you with all vhdProperties found using this method. Note that the service is initialized after the scan which means that within this method you may be adding new properties to the tree and still your _handleAddPropertyImplem() will not be called since notifications are forwrded onyl to the initialized services.
You may stop the scan at any moment by returning FALSE. Othewise return TRUE to continue the scan.
Return TRUE for each property that your vhdService will operate on (FALSE means that you are not interested in a property)
Normally for properties that you would like to use add them to your vhdPropertyController (for READ/WRITE) or vhdPropertyObserver (for READ ONLY)
Example of implementation that filters proeprties that can be of interest for you. void postInitPropertyScanImplem( vhdPropertyRef property) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdGeometryProperty, property)) { vhdGeometryPropertyRef geomProp = vhdREF_DYNAMIC_CAST( vhdGeometryProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); } else if ( vhdREF_IS_OF_CLASS( vhdCameraProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); } else if ( vhdREF_IS_OF_CLASS( vhdProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... getServiceContext()->getPropertyController/Observer()->addProperty(property); }
return TRUE; // to tell the kernel to continue the scan }
vhtBool vhdOSGViewerServiceBody::_runImplem | ( | ) | [protected, virtual] |
Called by ServiceHead to notify ServiceBody that service will be running which means that ServiceBody will receive calls to _udate() from now on.
vhtBool vhdOSGViewerServiceBody::_terminateImplem | ( | ) | [protected, virtual] |
Called by vhdServiceHandle to notify ServiceBody that it should terminate.
vhtBool vhdOSGViewerServiceBody::_updateImplem | ( | ) | [protected, virtual] |
Called by ServiceHead to notify ServiceBody that is should update itself. It is called only when serive is initialized and running.
void vhdOSGViewerServiceBody::_handleWarpClockExchangeImplem | ( | const std::string & | warpClockName, | |
vhdWarpClockRef | warpClock | |||
) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
By implementing this method you may react to the changes of the vhdWarpClock stored for you in the vhdServiceContext. Through this methdo you receive new warpClockName and warpClock or empty string and NULL which means that from now on getWarpClockCurrentTime() will be returnign time readings from the SIM clock.
void vhdOSGViewerServiceBody::_handleAddServiceImplem | ( | vhdServiceHandleRef | serviceHandle | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
Each time new vhdProperty is added ot the property tree kept by vhdPropertyManager then vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about new properties. If you return TRUE then the property will be added automatically to the private vhdPropertyController of the vhdServiceBody.
This method is called right after the vhdPropery has been added
property | just added to the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.) |
void vhdOSGViewerServiceBody::_handleRemoveServiceImplem | ( | vhdServiceHandleRef | serviceHandle | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
This method is called just before any vhdProperty is going to be removed. You may return FALSE to block the removal of the property.
property | just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.) |
void vhdOSGViewerServiceBody::_handleServiceStateChangeImplem | ( | vhdServiceHandleRef | serviceHandle | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
This method is called just after the state of the service changed
property | just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.) |
vhtBool vhdOSGViewerServiceBody::_handleAddPropertyScanImplem | ( | vhdPropertyRef | property | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
Each time a new vhdProperty is added ot the property tree kept by vhdPropertyManager the vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about a new property and its subtree using this method.
If you are just interested in the just added property and you do not care about its subproeprty tree then return FALSE which will tell the kernel to stop the scan.
Normally you should check the propery type and if you are interested in controlling or observing it you should add it respectively to your vhdPropertyController or vhdPropertyObserver.
This method is called right after the vhdPropery has been added.
property | just added to the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.) |
Appliquer le brouillard a OSG
vhtBool vhdOSGViewerServiceBody::_handleRemovePropertyScanImplem | ( | vhdPropertyRef | property | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
Each time new vhdProperty is about to be removed from the property tree kept by vhdPropertyManager the vhdPropertyManager goes to the vhdServiceManager and notifies each vhdServiceBody about a property that is about to be removed and its subtree using this method.
If you are just interested in the proeprty to be removed and you do not care about its subproeprty tree then return FALSE which will tell the kernel to stop the scan.
Normally here you should check the propery type and have a look into your vhdPropertyController or/and vhdPropertyObserver to find out if you were controlling or/and observing a property. This is your decision here then to remove it or still keep the property in vhdPropertyController or/and vhdPropertyObserver.
This method is called just before any vhdProperty is going to be removed.
property | just about to be removed from the property tree kept by vhdPropertyManager (so you can inspect the parent, etc.) |
remove fog in OSG
void vhdOSGViewerServiceBody::_handlePropertyChangeImplem | ( | vhdPropertyRef | property | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
In vhdServiceContext of your service you will find access to your own vhdPropertyObserver. vhdPropertyObserver of your service should store all vhdProperies that you are interested to monitor/inspect during the service runtime.
HOW IT WORKS: If you modify any property you may wish to notify all vhdPropertyObservers interested in observing of that property. In order to notify observers you call property->notifyPropertyObservers(). notifyPropertyObservers() will go over all connected vhdPropertyObservers and call on each one propertyObserver->observeProperty(property), and this one in turn will be forwarded to this method below that by default is registerd to the default vhdProperyObserver of your service. As the notification propagation is synchronous you should better react fast.
Please not that once you get the property you do not know what type it is. You may perform powerful hierarchical filtering here. See the example below: void _observePropertyImplem( vhdPropertyRef property) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdGeometryProperty, property)) { vhdGeometryPropertyRef geomProp = vhdREF_DYNAMIC_CAST( vhdGeometryProperty, property); ... } else if ( vhdREF_IS_OF_CLASS( vhdCameraProperty, property)) { vhdCameraPropertyRef camProp = vhdREF_DYNAMIC_CAST( vhdCameraProperty, property); ... } else if ( vhdREF_IS_OF_CLASS( vhdProperty, property)) { ... } else { vhdDIAG_WARNING("::unknown property"); } }
property | that has changed (or somebody wants just to draw your attention to it) |
set the fog up in OSG
vhtBool vhdOSGViewerServiceBody::_filterEventImplem | ( | vhdEventRef | event | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
Allows for filtering of the events arriving to the vhdEventReceiver of this vhdServiceBody. You filter out event by returnign TRUE. By returning FALSE you let the event go to the _handleEventImplem() method.
SYNC EVENT DISPATCH FORBIDDEN: It is forbidden to call dispatchEvent() (SYNC) opertations from inside of this method. Calling such operations will cause vhdEventDispatcherException. On the other hand you may use postEvent() (ASYNC) opertations. This is to avoid recurrent dispatch opertations where initial dispatch causes handler to trigger another dispatch, etc. which may easily lead to deadlocks and long event handling chains prohibitive for RT simulation.
Hierarchical catching of events is similar to catching of exceptions in C++. You should always catch the root class at the end of the statement. vhtBool _filterEventImplem( vhdEventRef event) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdMySimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSystemEvent, event)) { ... return TRUE; }
return FALSE; }
event | to be checked. |
vhtBool vhdOSGViewerServiceBody::_handleEventImplem | ( | vhdEventRef | event | ) | [protected, virtual] |
___OPTIONALLY_IMPLEMENT IT___
If the event passed the filtering step defined by _filterEventImpl() then it is passed to this method for handling. By implementing this method you define an IMMEDIATE REACTION of your service to the events it receives. If you return TRUE it means you handled the event. IF you return FALSE it menas that event should be added to getServiceContext()->getEventReceiver() that is buffering unhandled events for you so that you can process them during _updateImplem().
SYNC EVENT DISPATCH FORBIDDEN: It is forbidden to call dispatchEvent() (SYNC) opertations from inside of this method. Calling such operations will cause vhdEventDispatcherException. On the other hand you may use postEvent() (ASYNC) opertations. This is to avoid recurrent dispatch opertations where initial dispatch causes handler to trigger another dispatch, etc. which may easily lead to deadlocks and long event handling chains prohibitive for RT simulation.
Hierarchical catching of events is similar to catching of exceptions in C++. You should always catch the root class at the end of the statement. vhtBool _filterEventImplem( vhdEventRef event) { if (false) else if ( vhdREF_IS_OF_CLASS( vhdMySimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSimulationEvent, event)) { ... return TRUE; } else if ( vhdREF_IS_OF_CLASS( vhdSystemEvent, event)) { ... return TRUE; }
return FALSE; }
event | to handle. |
osgNodeRef vhdOSGViewerServiceBody::getSceneGraphRoot | ( | void | ) | [virtual] |
osgProducerViewerRef vhdOSGViewerServiceBody::getViewer | ( | void | ) | [virtual] |
CameraManipulatorRef vhdOSGViewerServiceBody::getCameraManipulator | ( | void | ) | [virtual] |
void vhdOSGViewerServiceBody::setViewMatrix | ( | osg::Matrixd & | vMat | ) |
void vhdOSGViewerServiceBody::setVHDViewMatrix | ( | const vhdMatrix4 | vMat | ) |
osg::Matrixd vhdOSGViewerServiceBody::getViewMatrix | ( | void | ) |
vhdMatrix4 vhdOSGViewerServiceBody::getVHDViewMatrix | ( | void | ) |
void vhdOSGViewerServiceBody::getViewMatrixAsLookAt | ( | osg::Vec3 & | eye, | |
osg::Vec3 & | center, | |||
osg::Vec3 & | up, | |||
float | lookDistance = 1.0f | |||
) |
void vhdOSGViewerServiceBody::getVHDViewMatrixAsLookAt | ( | vhdVector3 & | eye, | |
vhdVector3 & | center, | |||
vhdVector3 & | up, | |||
float | lookDistance = 1.0f | |||
) |
void vhdOSGViewerServiceBody::setViewMatrixAsLookAt | ( | osg::Vec3 & | eye, | |
osg::Vec3 & | center, | |||
osg::Vec3 & | up | |||
) |
void vhdOSGViewerServiceBody::setVHDViewMatrixAsLookAt | ( | const vhdVector3 & | eye, | |
const vhdVector3 & | center, | |||
const vhdVector3 & | up | |||
) |
void vhdOSGViewerServiceBody::setProjMatrixPerspective | ( | double | fovx, | |
double | fovy, | |||
double | aspectRatio, | |||
double | nearClip, | |||
double | farClip | |||
) |
void vhdOSGViewerServiceBody::setLensOrtho | ( | double | left, | |
double | right, | |||
double | bottom, | |||
double | top, | |||
double | nearClip, | |||
double | farClip | |||
) |
Convenience method for setting the lens Orthographic projection See Camera::Lens::setOrtho()
bool vhdOSGViewerServiceBody::getIntersectionsWithScene | ( | float | x, | |
float | y, | |||
HitList & | hits, | |||
unsigned int | camera = 0 | |||
) |
void vhdOSGViewerServiceBody::setCursorPosition | ( | float | x, | |
float | y, | |||
unsigned int | camera = 0 | |||
) |
void vhdOSGViewerServiceBody::startRecordingCameraPath | ( | ) |
void vhdOSGViewerServiceBody::stopRecordingCameraPath | ( | const std::string & | pathfilename = "saved_animation.path" , |
|
bool | autoStart = false | |||
) |
void vhdOSGViewerServiceBody::playRecordedCameraPath | ( | const std::string & | pathfilename = "saved_animation.path" |
) |
void vhdOSGViewerServiceBody::setHUDText | ( | const std::string & | textToSet | ) |
void vhdOSGViewerServiceBody::setHUDText | ( | const std::string & | textToSet, | |
const std::string & | encoding | |||
) |
void vhdOSGViewerServiceBody::setHUDTextPosition | ( | vhdVector2 & | position | ) |
void vhdOSGViewerServiceBody::setHUDTextSize | ( | int | size | ) |
void vhdOSGViewerServiceBody::setHUDTextFont | ( | const std::string & | font | ) |
void vhdOSGViewerServiceBody::setHUDTextColor | ( | vhdVector4 & | color | ) |
HWND vhdOSGViewerServiceBody::getOSGWindowHandle | ( | void | ) |
bool vhdOSGViewerServiceBody::getIsViewerRealizedAtRun | ( | void | ) |
void vhdOSGViewerServiceBody::setIsViewerRealizedAtRun | ( | bool | realizeAtRun | ) |
vhdOSGViewerServiceBody::vhdCLASS_TYPE [private] |
_Impl* vhdOSGViewerServiceBody::_impl [private] |