cOsgCanvas Class Reference

API: cOsgCanvas Class Reference
API
Inheritance diagram for cOsgCanvas:
[legend]

Classes

struct  EarthViewpoint
 Defines a viewpoint in 3D space with geographical coordinates, for osgEarth-style viewing. More...
struct  Viewpoint
 Defines a viewpoint in the 3D space. More...

Public Types

enum  ViewerStyle { STYLE_GENERIC , STYLE_EARTH }
 Viewer styles. More...
enum  CameraManipulatorType {
  CAM_AUTO , CAM_TERRAIN , CAM_OVERVIEW , CAM_TRACKBALL ,
  CAM_EARTH
}
 Camera manupulator types. More...

Public Member Functions

Constructors, destructor, assignment
Redefined cObject member functions.
virtual cOsgCanvasdup () const override
virtual std::string str () const override
OSG scene.
virtual void setScene (osg::Node *scene)
virtual osg::Node * getScene () const
Hints for the OSG viewer.
void setViewerStyle (ViewerStyle viewerStyle)
ViewerStyle getViewerStyle () const
void setClearColor (Color clearColor)
const ColorgetClearColor () const
void setCameraManipulatorType (CameraManipulatorType manipulator)
CameraManipulatorType getCameraManipulatorType () const
void setFieldOfViewAngle (double fieldOfViewAngle)
double getFieldOfViewAngle () const
void setZNear (double zNear)
void setZFar (double zFar)
void setZLimits (double zNear, double zFar)
void clearZLimits ()
bool hasZLimits () const
double getZNear () const
double getZFar () const
Viewer hints for the generic style.
void setGenericViewpoint (const Viewpoint &viewpoint)
const ViewpointgetGenericViewpoint () const
osgEarth-related viewer hints.
void setEarthViewpoint (const EarthViewpoint &earthViewpoint)
const EarthViewpointgetEarthViewpoint () const
Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 cOwnedObject (const char *name, bool namepooling=true)
 cOwnedObject (const cOwnedObject &obj)
virtual ~cOwnedObject ()
cOwnedObjectoperator= (const cOwnedObject &o)
virtual void parsimPack (cCommBuffer *buffer) const override
virtual void parsimUnpack (cCommBuffer *buffer) override
virtual cObjectgetOwner () const override
virtual bool isOwnedObject () const override
Public Member Functions inherited from cNamedObject
 cNamedObject ()
 cNamedObject (const char *name, bool namepooling=true)
 cNamedObject (const cNamedObject &obj)
virtual ~cNamedObject ()
cNamedObjectoperator= (const cNamedObject &o)
virtual void setName (const char *s)
virtual const char * getName () const override
virtual void setNamePooling (bool b)
virtual bool getNamePooling ()
Public Member Functions inherited from cObject
 cObject ()
 cObject (const cObject &other)=default
virtual ~cObject ()
virtual const char * getClassName () const
bool isName (const char *s) const
virtual const char * getFullName () const
virtual std::string getFullPath () const
virtual std::string getClassAndFullName () const
virtual std::string getClassAndFullPath () const
const cObjectgetThisPtr () const
virtual std::ostream & printOn (std::ostream &os) const
virtual bool isSoftOwner () const
virtual void forEachChild (cVisitor *v)
cObjectfindObject (const char *name, bool deep=true)
virtual cClassDescriptorgetDescriptor () const
void copyNotSupported () const

Additional Inherited Members

Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
static long getLiveObjectCount ()
static void resetObjectCounters ()
static cSoftOwnergetOwningContext ()
Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
virtual void drop (cOwnedObject *obj)
void dropAndDelete (cOwnedObject *obj)

Description

Wraps an OpenSceneGraph scene, allowing 3D visualization in graphical user interfaces that support it (currently Qtenv).

This class only wraps an OSG scene (as an osg::Node* pointer) and some visualization hints, other tasks like setting up a 3D viewer window are taken care of by the OMNeT++ user interface code (Qtenv). The scene graph can be assembled using the OSG API, e.g. using osgDB::readNodeFile() or creating and adding nodes directly.

Since OpenSceneGraph is not a mandatory part of OMNeT++, it is recommended that you surround your OSG code with #ifdef WITH_OSG.

Member Function Documentation

◆ dup()

virtual cOsgCanvas * dup ( ) const
inlineoverridevirtual

Should be redefined in subclasses to create an exact copy of this object. The default implementation just throws an error, to indicate that the method was not redefined.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Returns a brief, one-line description of the object. The returned string does (should) NOT include the object's name and class. This method is used to display object information at several places in the Qtenv GUI, among others.

Reimplemented from cObject.

◆ setScene()

virtual void setScene ( osg::Node * scene)
virtual

Set the 3D scene to be displayed. Note that osg::Node implements reference counting, and setScene() increments the reference count.

◆ getScene()

virtual osg::Node * getScene ( ) const
inlinevirtual

Return the 3D scene to be displayed.

◆ setViewerStyle()

void setViewerStyle ( ViewerStyle viewerStyle)
inline

Sets the viewer style. This hint affects the defaults for several other hints, for example the camera maniplator hint. Currently there are two styles, STYLE_GENERIC for generic OSG (non-osgEarth), and STYLE_EARTH for osgEarth models.

◆ getViewerStyle()

ViewerStyle getViewerStyle ( ) const
inline

Return the viewer style hint.

◆ setClearColor()

void setClearColor ( Color clearColor)
inline

Set the color hint for the background behind the scene. Note that this hint will be ignored by osgEarth models, because osgEarth uses sky models for the same purpose.

◆ getClearColor()

const Color & getClearColor ( ) const
inline

Return the color hint for background behind the scene.

◆ setCameraManipulatorType()

void setCameraManipulatorType ( CameraManipulatorType manipulator)
inline

Set the camera manipulator type hint. The camera manipulator determines how the camera reacts to mouse/keyboard actions. CAM_TERRAIN, CAM_OVERVIEW, and CAM_TRACKBALL are useful when viewing generic OSG scenes, and CAM_EARTH is useful for osgEarth scenes.

◆ getCameraManipulatorType()

CameraManipulatorType getCameraManipulatorType ( ) const
inline

Return the camera manipulator type hint.

◆ setFieldOfViewAngle()

void setFieldOfViewAngle ( double fieldOfViewAngle)
inline

Set the field of view angle hint, in degrees, in the y direction.

◆ getFieldOfViewAngle()

double getFieldOfViewAngle ( ) const
inline

Return the field of view angle hint, in degrees, in the y direction.

◆ setZNear()

void setZNear ( double zNear)
inline

Set the distance hint from the viewer to the near clipping plane (always positive).

See also
setZLimits()

◆ setZFar()

void setZFar ( double zFar)
inline

Set the distance hint from the viewer to the far clipping plane (always positive).

See also
setZLimits()

◆ setZLimits()

void setZLimits ( double zNear,
double zFar )
inline

Set the distance from the viewer to the near and far clipping planes (always positive) as viewer hint. When not set, the corresponding limits are computed automatically by the viewer.

See also
clearZLimits()

◆ clearZLimits()

void clearZLimits ( )

Unset the zNear/zFar values set via setZLimits().

◆ hasZLimits()

bool hasZLimits ( ) const

Returns true if the zNear/zFar values are set manually.

See also
setZLimits(), clearZLimits()

◆ getZNear()

double getZNear ( ) const
inline

Return the distance hint from the viewer to the near clipping plane. Returns NaN when not set (e.g. after clearZLimits()).

◆ getZFar()

double getZFar ( ) const
inline

Return the distance from the viewer to the far clipping plane. Returns NaN when not set (e.g. after clearZLimits()).

◆ setGenericViewpoint()

void setGenericViewpoint ( const Viewpoint & viewpoint)

Sets the initial genericViewpoint hint.

◆ getGenericViewpoint()

const Viewpoint & getGenericViewpoint ( ) const
inline

Returns the initial genericViewpoint hint.

◆ setEarthViewpoint()

void setEarthViewpoint ( const EarthViewpoint & earthViewpoint)

Sets the initial earthViewpoint hint.

◆ getEarthViewpoint()

const EarthViewpoint & getEarthViewpoint ( ) const
inline

Returns the initial earthViewpoint hint.