CEDRIC  Revision_backup-2009-02
Public Types | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
MyCameraWidget Class Reference

Viewer based on MyCamera providing Trackball rotation, Rubberband zoom and Picking. More...

#include <MyCameraWidget.h>

Inheritance diagram for MyCameraWidget:
OsgViewerWidget OsgAdapterWidget EventCameraWidget

Public Types

enum  MouseMode { ROTATE, RUBBERBAND, SELECT }
 Different action modes for mouse. More...
 

Public Slots

void setProjection (int proj)
 
void setMouseMode (int mode)
 Set mouse action mode (see enum MouseMode for a list of supported action modes) More...
 
- Public Slots inherited from OsgViewerWidget
virtual void idle (double simulationTime=USE_REFERENCE_TIME)
 Do event and update traversal. More...
 
void triggerRedraw ()
 Trigger a redraw in 1/60 sec. More...
 
void toggleContinuousUpdate (bool activate)
 Toggle continous redraw (usefull for animation) More...
 
void forceContinuousUpdate (bool force)
 Forces continous redraw (i.e. continuous redraw cannot be disabled via toggleContinousUpdate(false)) More...
 

Signals

void positionChanged (float x, float y, float z)
 Unprojected mouse position. More...
 
void focusChanged (bool)
 On focusInEvent/focusOutEvent this signal is emitted respectively with true/false as parameter. More...
 
void doubleClicked (Selectable *selectable)
 Emitted when in SELECTION mode currently highlighted Selectable is double-clicked. More...
 
- Signals inherited from OsgAdapterWidget
void processEvents ()
 

Public Member Functions

 MyCameraWidget (QWidget *parent=0)
 
virtual ~MyCameraWidget ()
 
int getProjection () const
 Get projection setting of MyCamera member (see MyCamera::Projection for supported projections) More...
 
int getMouseMode () const
 Get current mouse action mode. More...
 
MyCamera * getMyCamera ()
 Access to MyCamera class (e.g. for switching between orthographic and perspective projection) More...
 
virtual void setSceneData (osg::Node *node)
 Override to append own HUD. More...
 
- Public Member Functions inherited from OsgViewerWidget
 OsgViewerWidget (QWidget *parent=0)
 
virtual ~OsgViewerWidget ()
 
virtual bool paintGL2PS (const char *filename, int format)
 Render scene to postscript using GL2PS library. More...
 
bool isContinuousUpdateForced () const
 Returns true if continous update was forced (i.e. continuous redraw cannot be disable via toggleContinousUpdate(false)) More...
 
virtual void frame (double simulationTime=USE_REFERENCE_TIME)
 
virtual void requestRedraw ()
 
virtual void requestContinuousUpdate (bool needed=true)
 
virtual void requestWarpPointer (float x, float y)
 
- Public Member Functions inherited from OsgAdapterWidget
 OsgAdapterWidget (QWidget *parent=0)
 
virtual ~OsgAdapterWidget ()
 
osgViewer::GraphicsWindow * getGraphicsWindow ()
 
const osgViewer::GraphicsWindow * getGraphicsWindow () const
 

Protected Slots

void mouseOverNode (osg::Node *node)
 Corresponding signal from PickingHandler is connected here. More...
 
virtual void focusInEvent (QFocusEvent *)
 Override QWidget::focusInEvent() to notice that we received focus. More...
 
virtual void focusOutEvent (QFocusEvent *)
 Override QWidget::focusOutEvent() to notice that we lost focus. More...
 
void myCameraChanged ()
 

Protected Member Functions

virtual void paintGL ()
 Override OsgViewerWidget::paintGL() for overpainting via OpenGL. More...
 
virtual void resizeGL (int width, int height)
 Override OsgAdapterWidget::resizeGL() for changing HUD aspect ratio also. More...
 
osg::Node * createHUD (osgText::Text *text)
 Helper function which creates a simple heads-up-display which is later used to show name of highlighted Pickable. More...
 
osg::Node * createAxesView ()
 Helper function which creates a little 3d view in the lower left of fixed size showing the 3d coordinate axes. More...
 
virtual void mouseMoveEvent (QMouseEvent *event)
 Override Qt mouse events to allow different mouse modes. More...
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from OsgAdapterWidget
void init ()
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
osgGA::GUIEventAdapter * makeEventAdapter (QMouseEvent *event, osgGA::GUIEventAdapter::EventType type)
 

Protected Attributes

MyCamera * m_myCamera
 
int m_mouseMode
 
bool m_rubberbandActive
 
ClipRect m_rubberbandRect
 
osg::ref_ptr< osg::Node > m_hud
 
osg::ref_ptr< PickingHandler > m_pickingHandler
 

heads-up-display, should be an osg::Camera to make aspect ratio adjustion in resizeGL work

More...
 
osg::ref_ptr
< osg::MatrixTransform > 
m_axes
 
osg::ref_ptr< osg::Node > m_axesView
 
- Protected Attributes inherited from OsgAdapterWidget
osg::ref_ptr
< osgViewer::GraphicsWindowEmbedded > 
_gw
 

Additional Inherited Members

- Public Attributes inherited from OsgViewerWidget
unsigned long idleCount
 

Detailed Description

Viewer based on MyCamera providing Trackball rotation, Rubberband zoom and Picking.

Author
Max Hermann <mhermann[at]mail.cern.ch>

Member Enumeration Documentation

Different action modes for mouse.

Enumerator
ROTATE 

Trackball rotation on left mouse button.

RUBBERBAND 

Rubberband zoom on left mouse button.

SELECT 

Picking/Selection on left mouse button.

Constructor & Destructor Documentation

MyCameraWidget::MyCameraWidget ( QWidget *  parent = 0)
virtual MyCameraWidget::~MyCameraWidget ( )
inlinevirtual

Member Function Documentation

osg::Node * MyCameraWidget::createAxesView ( )
protected

Helper function which creates a little 3d view in the lower left of fixed size showing the 3d coordinate axes.

References m_axes.

Referenced by MyCameraWidget().

osg::Node * MyCameraWidget::createHUD ( osgText::Text *  text)
protected

Helper function which creates a simple heads-up-display which is later used to show name of highlighted Pickable.

Referenced by MyCameraWidget().

void MyCameraWidget::doubleClicked ( Selectable *  selectable)
signal

Emitted when in SELECTION mode currently highlighted Selectable is double-clicked.

Referenced by mouseDoubleClickEvent().

void MyCameraWidget::focusChanged ( bool  )
signal

On focusInEvent/focusOutEvent this signal is emitted respectively with true/false as parameter.

Referenced by focusInEvent(), and focusOutEvent().

virtual void MyCameraWidget::focusInEvent ( QFocusEvent *  )
inlineprotectedvirtualslot

Override QWidget::focusInEvent() to notice that we received focus.

References focusChanged().

virtual void MyCameraWidget::focusOutEvent ( QFocusEvent *  )
inlineprotectedvirtualslot

Override QWidget::focusOutEvent() to notice that we lost focus.

References focusChanged().

int MyCameraWidget::getMouseMode ( ) const
inline

Get current mouse action mode.

References m_mouseMode.

MyCamera* MyCameraWidget::getMyCamera ( )
inline
int MyCameraWidget::getProjection ( ) const
inline

Get projection setting of MyCamera member (see MyCamera::Projection for supported projections)

References MyCamera::getProjection(), and m_myCamera.

void MyCameraWidget::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual
void MyCameraWidget::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Override Qt mouse events to allow different mouse modes.

Reimplemented from OsgAdapterWidget.

Reimplemented in EventCameraWidget.

References ClipRect::bottom, m_myCamera, m_rubberbandActive, m_rubberbandRect, OsgAdapterWidget::mouseMoveEvent(), positionChanged(), ClipRect::right, and MyCamera::unproject().

Referenced by EventCameraWidget::mouseMoveEvent().

void MyCameraWidget::mouseOverNode ( osg::Node *  node)
protectedslot

Corresponding signal from PickingHandler is connected here.

void MyCameraWidget::mousePressEvent ( QMouseEvent *  event)
protectedvirtual
void MyCameraWidget::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual
void MyCameraWidget::myCameraChanged ( )
protectedslot

References m_axes, m_myCamera, and MyCamera::rotation().

Referenced by MyCameraWidget().

void MyCameraWidget::paintGL ( )
protectedvirtual
void MyCameraWidget::positionChanged ( float  x,
float  y,
float  z 
)
signal

Unprojected mouse position.

Referenced by mouseMoveEvent().

void MyCameraWidget::resizeGL ( int  width,
int  height 
)
protectedvirtual

Override OsgAdapterWidget::resizeGL() for changing HUD aspect ratio also.

Reimplemented from OsgAdapterWidget.

References m_hud, and OsgAdapterWidget::resizeGL().

void MyCameraWidget::setMouseMode ( int  mode)
slot

Set mouse action mode (see enum MouseMode for a list of supported action modes)

References m_mouseMode, m_pickingHandler, SELECT, and OsgViewerWidget::toggleContinuousUpdate().

void MyCameraWidget::setProjection ( int  proj)
inlineslot

Set projection setting of MyCamera member (see MyCamera::Projection for supported projections) Pass thru is needed because MyCamera is no Q_OBJECT

References m_myCamera, and MyCamera::setProjection().

Referenced by EventViewerWidget::setViewMode().

void MyCameraWidget::setSceneData ( osg::Node *  node)
virtual

Override to append own HUD.

Reimplemented in EventCameraWidget.

References m_axesView, m_hud, and OsgLighting::setupDefaultLighting().

Referenced by EventCameraWidget::setSceneData().

void MyCameraWidget::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Reimplemented from OsgAdapterWidget.

Reimplemented in EventCameraWidget.

References OsgAdapterWidget::wheelEvent().

Referenced by EventCameraWidget::wheelEvent().

Member Data Documentation

osg::ref_ptr<osg::MatrixTransform> MyCameraWidget::m_axes
protected

Referenced by createAxesView(), and myCameraChanged().

osg::ref_ptr<osg::Node> MyCameraWidget::m_axesView
protected

Referenced by MyCameraWidget(), and setSceneData().

osg::ref_ptr<osg::Node> MyCameraWidget::m_hud
protected
int MyCameraWidget::m_mouseMode
protected
MyCamera* MyCameraWidget::m_myCamera
protected
osg::ref_ptr<PickingHandler> MyCameraWidget::m_pickingHandler
protected

heads-up-display, should be an osg::Camera to make aspect ratio adjustion in resizeGL work

Referenced by MyCameraWidget(), and setMouseMode().

bool MyCameraWidget::m_rubberbandActive
protected
ClipRect MyCameraWidget::m_rubberbandRect
protected