version 3.3

VRS::Canvas Class Reference

Abstract Base Class for VRS Graphics Windows. More...

#include <vrs/sg/canvas.h>

Inheritance diagram for VRS::Canvas:

VRS::Manager VRS::SharedObj VRS::Visitable VRS::GLCanvas VRS::GlutCanvas VRS::GtkCanvas VRS::OffscreenCanvasGL VRS::PBufferCanvasGL VRS::SDLCanvas

List of all members.

Public Types

enum  RenderingMode { Interactive = 1, HighQuality = 2 }

Public Member Functions

 Canvas (Clock *canvasClock=NULL, double pixelRatio=1.0, double resolutionDPI=96.0)
virtual ~Canvas ()
void append (SceneNode *sceneGraph)
void prepend (SceneNode *sceneGraph)
void insert (int atPosition, SceneNode *sceneGraph)
void remove (SceneNode *sceneGraph)
bool contains (SceneNode *sceneGraph) const
void switchOn (SceneNode *sceneGraph)
void switchOff (SceneNode *sceneGraph)
bool isSwitchedOn (SceneNode *sceneGraph) const
int sceneGraphs () const
SceneNodesceneGraph (int atPosition) const
void append (BehaviorNode *behaviorGraph)
void prepend (BehaviorNode *behaviorGraph)
void insert (int atPosition, BehaviorNode *behaviorGraph)
void remove (BehaviorNode *behaviorGraph)
bool contains (BehaviorNode *behaviorGraph) const
void reset (BehaviorNode *behaviorGraph)
void switchOn (BehaviorNode *behaviorGraph, Clock *clock=NULL)
void switchOff (BehaviorNode *behaviorGraph)
bool isSwitchedOn (BehaviorNode *behaviorGraph) const
int behaviorGraphs () const
BehaviorNodebehaviorGraph (int atPosition) const
virtual void enableRedisplay ()
 Enables the canvas for redisplaying.
virtual void disableRedisplay ()
 Disables the canvas for redisplaying (redisplay() will be ignored).
virtual bool isRedisplayEnabled () const
 Returns whether redisplaying is enabled or disabled for this canvas.
void redisplay ()
 Redraws the canvas immediately.
virtual void postForRedisplay (double delay=0.0)
virtual bool isRedisplayNeeded () const
 Returns true if the canvas is posted for redisplay, i.e., if the redraw operation is pending.
virtual VRSTime lastRedisplay () const
 Returns the moment the canvas was rendered the last time.
virtual void setSize (unsigned int width, unsigned int height)=0
 Sets width and height of the canvas. Setting the size results in a resize operation.
virtual unsigned int getWidth () const =0
 Returns the width in pixels of the canvas.
virtual unsigned int getHeight () const =0
 Returns the height in pixels of the canvas.
double pixelRatio () const
 Returns the aspect ratio of canvas pixels (width/height).
void setResolution (double dpi)
 Sets the resolution in DPI of the device the canvas is painting on.
double getResolution () const
 Returns the (horizontal) resolution in DPI of the device the canvas is painting on.
virtual void setSceneRenderer (MultiSceneRenderer *)
 Sets the MultiSceneRenderer for evaluating the scene.
virtual MultiSceneRenderergetSceneRenderer () const
 Gets the MultiSceneRenderer for evaluating the scene.
virtual Engineengine () const =0
 Returns the internal engine used to synthesize frames.
virtual TechniqueProcessorprocessor () const =0
 Returns the internal processor used to evaluate the scene graph of the canvas.
Clockclock () const
 Returns the global clock of VRS.
void pushClock (Clock *clock)
void popClock ()
void install (Engine *externalEngine)
void deinstall (Engine *externalEngine)
bool isInstalled (Engine *externalEngine) const
virtual void eval (Engine *engine, TechniqueProcessor *techniqueprocessor)
virtual bool prepareRedisplay ()
 Hook for subclasses, is called before redisplay actions.
virtual void finishRedisplay ()
 Hook for subclasses, is called after redisplay actions, see also prepareRedisplay.
virtual void makeContextCurrent ()
 Hook for subclasses, should make the correct rendering context current.
virtual void releaseContext ()
 Hook for subclasses, should restore the old rendering context.
IntersectionInfopickingResult (ButtonEvent *buttonEvent, SO< Filter > filter=NULL) const
SO< Iterator< SO
< IntersectionInfo > > > 
allPickingResults (ButtonEvent *buttonEvent, SO< Filter > filter=NULL) const
int handle (Event *e)
void setWatching (int onOff)
 Turns on and off the recording of the projection and orientation transformation matrices of the internal root scene graph.
int getWatching () const
Matrix modelviewMatrix () const
Matrix projectionMatrix () const
virtual void setCursor (Cursor::Shape cursor)
 Sets the cursor displayed over the canvas immediately to one of the predefined cursor shapes.
virtual Cursor::Shape getCursor () const
 Returns the cursor currently active over the canvas.
 VRS_TYPEINFO (Canvas, Manager)
void installEngine (Engine *engine)
void deinstallEngine (Engine *engine)
void renderContents ()
 Renders the content without caring about the rendering context, prepareRedisplay or finishRedisplay, called by redisplay.
SceneThingsceneRootNode () const
 Returns the internal root node for all added scene graphs.
Viewportviewport () const
ContextData< Canvas * > * canvasHint () const
virtual RenderingMode getRenderingMode () const
virtual void setRenderingMode (RenderingMode mode)
KeyEventkeyEvent (InputEvent::Modifier modifiers, VRSTime time, unsigned long keyCode, int pressed, bool isAutoRepeat=false)
MotionEventmotionEvent (InputEvent::Modifier modifiers, VRSTime time, int x, int y, bool sameWindow)
ButtonEventbuttonEvent (InputEvent::Modifier modifiers, VRSTime time, InputEvent::Button button, InputEvent::Change pressed, int x, int y)
ResizeEventresizeEvent (unsigned int width, unsigned int height, double aspectRatio=1.0)
ConfigureEventconfigureEvent (int reason)
PointerEventpointerEvent (InputEvent::Modifier modifiers, VRSTime time, bool entered)
WheelEventwheelEvent (InputEvent::Modifier modifiers, VRSTime time, int delta, int x, int y)

Static Public Member Functions

static Iterator< Canvas * > * canvasList ()
 Returns an iterator for all currently instantiated canvas objects.
static void redisplayAll ()
 Redraws all real-time canvas immediately.
static void postAllForRedisplay (double delay=0.0)
 Posts all real-time canvases for redisplay in 'delay' seconds.

Protected Member Functions

virtual void acceptChildren (std::vector< Visitable * > &appendChildrenHere) const


Detailed Description

Abstract Base Class for VRS Graphics Windows.

Member Enumeration Documentation

Enumerator:
Interactive 
HighQuality 


Constructor & Destructor Documentation

VRS::Canvas::Canvas ( Clock canvasClock = NULL,
double  pixelRatio = 1.0,
double  resolutionDPI = 96.0 
)

virtual VRS::Canvas::~Canvas (  )  [virtual]

A canvas displays a 3D scene which is specified by the associated scene graphs. Its interactivity and its time-dependent behavior is specified by associated behavior graphs. A canvas creates internally a rendering engine, which is used to synthesize frames.


Member Function Documentation

void VRS::Canvas::append ( SceneNode sceneGraph  ) 

void VRS::Canvas::prepend ( SceneNode sceneGraph  ) 

void VRS::Canvas::insert ( int  atPosition,
SceneNode sceneGraph 
)

void VRS::Canvas::remove ( SceneNode sceneGraph  ) 

bool VRS::Canvas::contains ( SceneNode sceneGraph  )  const

void VRS::Canvas::switchOn ( SceneNode sceneGraph  ) 

void VRS::Canvas::switchOff ( SceneNode sceneGraph  ) 

bool VRS::Canvas::isSwitchedOn ( SceneNode sceneGraph  )  const

int VRS::Canvas::sceneGraphs (  )  const

SceneNode* VRS::Canvas::sceneGraph ( int  atPosition  )  const

void VRS::Canvas::append ( BehaviorNode behaviorGraph  ) 

void VRS::Canvas::prepend ( BehaviorNode behaviorGraph  ) 

void VRS::Canvas::insert ( int  atPosition,
BehaviorNode behaviorGraph 
)

void VRS::Canvas::remove ( BehaviorNode behaviorGraph  ) 

bool VRS::Canvas::contains ( BehaviorNode behaviorGraph  )  const

void VRS::Canvas::reset ( BehaviorNode behaviorGraph  ) 

void VRS::Canvas::switchOn ( BehaviorNode behaviorGraph,
Clock clock = NULL 
)

void VRS::Canvas::switchOff ( BehaviorNode behaviorGraph  ) 

bool VRS::Canvas::isSwitchedOn ( BehaviorNode behaviorGraph  )  const

int VRS::Canvas::behaviorGraphs (  )  const

BehaviorNode* VRS::Canvas::behaviorGraph ( int  atPosition  )  const

virtual void VRS::Canvas::enableRedisplay (  )  [virtual]

Enables the canvas for redisplaying.

virtual void VRS::Canvas::disableRedisplay (  )  [virtual]

Disables the canvas for redisplaying (redisplay() will be ignored).

virtual bool VRS::Canvas::isRedisplayEnabled (  )  const [virtual]

Returns whether redisplaying is enabled or disabled for this canvas.

void VRS::Canvas::redisplay (  ) 

Redraws the canvas immediately.

Redisplay will take the common necessary actions. Before these, prepareRedisplay will be called, after it finishRedisplay. prepareRedisplay must return true in order to actually perform the redisplay. Note that, if prepareRedisplay returns false, no redisplay will take place and finishRedisplay will not be called. Calls renderContents.

virtual void VRS::Canvas::postForRedisplay ( double  delay = 0.0  )  [virtual]

Marks the canvas for redisplay in about 'delay' seconds. If 'delay' is <= 0.0 it is rendered as soon as possible.

virtual bool VRS::Canvas::isRedisplayNeeded (  )  const [virtual]

Returns true if the canvas is posted for redisplay, i.e., if the redraw operation is pending.

virtual VRSTime VRS::Canvas::lastRedisplay (  )  const [virtual]

Returns the moment the canvas was rendered the last time.

static Iterator<Canvas*>* VRS::Canvas::canvasList (  )  [static]

Returns an iterator for all currently instantiated canvas objects.

static void VRS::Canvas::redisplayAll (  )  [static]

Redraws all real-time canvas immediately.

static void VRS::Canvas::postAllForRedisplay ( double  delay = 0.0  )  [static]

Posts all real-time canvases for redisplay in 'delay' seconds.

virtual void VRS::Canvas::setSize ( unsigned int  width,
unsigned int  height 
) [pure virtual]

Sets width and height of the canvas. Setting the size results in a resize operation.

Implemented in VRS::GlutCanvas, VRS::GtkCanvas, VRS::OffscreenCanvasGL, VRS::PBufferCanvasGL, and VRS::SDLCanvas.

virtual unsigned int VRS::Canvas::getWidth (  )  const [pure virtual]

Returns the width in pixels of the canvas.

Implemented in VRS::GlutCanvas, VRS::GtkCanvas, VRS::OffscreenCanvasGL, VRS::PBufferCanvasGL, and VRS::SDLCanvas.

virtual unsigned int VRS::Canvas::getHeight (  )  const [pure virtual]

Returns the height in pixels of the canvas.

Implemented in VRS::GlutCanvas, VRS::GtkCanvas, VRS::OffscreenCanvasGL, VRS::PBufferCanvasGL, and VRS::SDLCanvas.

double VRS::Canvas::pixelRatio (  )  const

Returns the aspect ratio of canvas pixels (width/height).

void VRS::Canvas::setResolution ( double  dpi  ) 

Sets the resolution in DPI of the device the canvas is painting on.

This can be used by shapes in order to create objects with a fixed size. The given resolution is always considered the horizontal resolution in DPI. The vertical resolution can be calculated using the pixel ratio. The default value is 96 DPI.

double VRS::Canvas::getResolution (  )  const

Returns the (horizontal) resolution in DPI of the device the canvas is painting on.

virtual void VRS::Canvas::setSceneRenderer ( MultiSceneRenderer  )  [virtual]

Sets the MultiSceneRenderer for evaluating the scene.

virtual MultiSceneRenderer* VRS::Canvas::getSceneRenderer (  )  const [virtual]

Gets the MultiSceneRenderer for evaluating the scene.

virtual Engine* VRS::Canvas::engine (  )  const [pure virtual]

Returns the internal engine used to synthesize frames.

Implemented in VRS::GLCanvas.

virtual TechniqueProcessor* VRS::Canvas::processor (  )  const [pure virtual]

Returns the internal processor used to evaluate the scene graph of the canvas.

Implemented in VRS::GLCanvas.

Clock* VRS::Canvas::clock (  )  const

Returns the global clock of VRS.

void VRS::Canvas::pushClock ( Clock clock  ) 

void VRS::Canvas::popClock (  ) 

void VRS::Canvas::install ( Engine externalEngine  ) 

void VRS::Canvas::deinstall ( Engine externalEngine  ) 

bool VRS::Canvas::isInstalled ( Engine externalEngine  )  const

virtual void VRS::Canvas::eval ( Engine engine,
TechniqueProcessor techniqueprocessor 
) [virtual]

virtual bool VRS::Canvas::prepareRedisplay (  )  [virtual]

Hook for subclasses, is called before redisplay actions.

Subclasses take the necessary actions to prepare the redisplay here. Expecially the rendering context should be handled here and there must be a valid engine after prepareRedisplay. Note that there is another hook, makeContextCurrent, where the correct rendering context should be made current. The standard implementation of prepareRedisplay will call makeContextCurrent, so if preparing the rendering context is the only action necessary, only makeContextCurrent should be overwritten. The first action of an overriding method should be to call the inherited prepareRedisplay. If false is returned, the redisplay is cancelled and finishRedisplay is not called.

Reimplemented in VRS::GLCanvas, VRS::OffscreenCanvasGL, and VRS::PBufferCanvasGL.

virtual void VRS::Canvas::finishRedisplay (  )  [virtual]

Hook for subclasses, is called after redisplay actions, see also prepareRedisplay.

The standard implementation calls releaseContext.

Reimplemented in VRS::GlutCanvas, VRS::GtkCanvas, VRS::GLCanvas, VRS::OffscreenCanvasGL, VRS::PBufferCanvasGL, and VRS::SDLCanvas.

virtual void VRS::Canvas::makeContextCurrent (  )  [virtual]

Hook for subclasses, should make the correct rendering context current.

Since makeContextCurrent should be the first action in order to prepare a redisplay, it should use as least ressources as possible (e.g. the engine). The creation of the engine (and other ressources) can not be forced by this abstract base class, so there may be no engine when makeContextCurrent is called.

Reimplemented in VRS::GlutCanvas, VRS::GtkCanvas, VRS::OffscreenCanvasGL, and VRS::PBufferCanvasGL.

virtual void VRS::Canvas::releaseContext (  )  [virtual]

Hook for subclasses, should restore the old rendering context.

Reimplemented in VRS::OffscreenCanvasGL, and VRS::PBufferCanvasGL.

IntersectionInfo* VRS::Canvas::pickingResult ( ButtonEvent buttonEvent,
SO< Filter filter = NULL 
) const

Returns the top-most result of a ray query with the given mouse position of the ButtonEvent. If no shape is hit, NULL is returned.

SO<Iterator<SO<IntersectionInfo> > > VRS::Canvas::allPickingResults ( ButtonEvent buttonEvent,
SO< Filter filter = NULL 
) const

Returns the complete result of a ray query with the given mouse position of the ButtonEvent.

int VRS::Canvas::handle ( Event e  )  [virtual]

only for internal use.

Implements VRS::Manager.

void VRS::Canvas::setWatching ( int  onOff  ) 

Turns on and off the recording of the projection and orientation transformation matrices of the internal root scene graph.

'onOff' is a bitwise combination of the flags defined in scenething.h

int VRS::Canvas::getWatching (  )  const

Matrix VRS::Canvas::modelviewMatrix (  )  const

Matrix VRS::Canvas::projectionMatrix (  )  const

virtual void VRS::Canvas::setCursor ( Cursor::Shape  cursor  )  [virtual]

Sets the cursor displayed over the canvas immediately to one of the predefined cursor shapes.

This should be overriden in a subclass for the specific GUI toolkit.

Reimplemented in VRS::GlutCanvas, and VRS::SDLCanvas.

virtual Cursor::Shape VRS::Canvas::getCursor (  )  const [virtual]

Returns the cursor currently active over the canvas.

This should be overriden in a subclass for the specific GUI toolkit.

VRS::Canvas::VRS_TYPEINFO ( Canvas  ,
Manager   
)

void VRS::Canvas::installEngine ( Engine engine  ) 

void VRS::Canvas::deinstallEngine ( Engine engine  ) 

void VRS::Canvas::renderContents (  ) 

Renders the content without caring about the rendering context, prepareRedisplay or finishRedisplay, called by redisplay.

This method can be used by specialized canvases, which need rendering without the other mentioned stuff. largeScaleSnapshot from the GLCanvas is an example for this.

SceneThing* VRS::Canvas::sceneRootNode (  )  const

Returns the internal root node for all added scene graphs.

Viewport* VRS::Canvas::viewport (  )  const

Returns the viewport attribute maintained by the canvas. The viewport is updated whenever the window gets resized.

ContextData<Canvas*>* VRS::Canvas::canvasHint (  )  const

Returns the canvasHint_ hint that is maintained by the canvas.

virtual RenderingMode VRS::Canvas::getRenderingMode (  )  const [virtual]

virtual void VRS::Canvas::setRenderingMode ( RenderingMode  mode  )  [virtual]

KeyEvent* VRS::Canvas::keyEvent ( InputEvent::Modifier  modifiers,
VRSTime  time,
unsigned long  keyCode,
int  pressed,
bool  isAutoRepeat = false 
)

MotionEvent* VRS::Canvas::motionEvent ( InputEvent::Modifier  modifiers,
VRSTime  time,
int  x,
int  y,
bool  sameWindow 
)

ButtonEvent* VRS::Canvas::buttonEvent ( InputEvent::Modifier  modifiers,
VRSTime  time,
InputEvent::Button  button,
InputEvent::Change  pressed,
int  x,
int  y 
)

ResizeEvent* VRS::Canvas::resizeEvent ( unsigned int  width,
unsigned int  height,
double  aspectRatio = 1.0 
)

ConfigureEvent* VRS::Canvas::configureEvent ( int  reason  ) 

PointerEvent* VRS::Canvas::pointerEvent ( InputEvent::Modifier  modifiers,
VRSTime  time,
bool  entered 
)

WheelEvent* VRS::Canvas::wheelEvent ( InputEvent::Modifier  modifiers,
VRSTime  time,
int  delta,
int  x,
int  y 
)

virtual void VRS::Canvas::acceptChildren ( std::vector< Visitable * > &  appendChildrenHere  )  const [protected, virtual]

Reimplemented from VRS::Visitable.


The documentation for this class was generated from the following file:

Generated on Sat May 18 06:00:31 2013 by Doxygen 1.5.6
© 2001-2010 Hasso-Plattner-Institut | Impressum | Contact