cherish
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EventHandler Class Reference

An OpenSceneGraph events that were passed from Qt's interface - GLWidget. Event handler is where all the mouse events are processed. Examples: sketching, canvas position editing, polygon drawing, deletion of entities. The EventHandler, after the mouse info extracted, then sends according signals to the UserScene, which, in turn, register the scene changed through the undo/redo commands. Note, some of the keyboard event are processed through the GLWidget and are not passed to the event handler. However, all the mouses events are meant to be passed and processed to the EventHandler. More...

#include <EventHandler.h>

Inheritance diagram for EventHandler:

Public Member Functions

 EventHandler (GLWidget *widget, RootScene *scene, cher::MOUSE_MODE mode=cher::SELECT_ENTITY)
 
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void setMode (cher::MOUSE_MODE mode)
 
cher::MOUSE_MODE getMode () const
 

Protected Member Functions

void doEraseStroke (entity::Stroke *stroke, int first, int last, cher::EVENT event=cher::EVENT_DRAGGED)
 
void doSelectEntity (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
template<typename T1 , typename T2 >
void doSelectCanvas (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doSketch (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doSketchPolygon (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doSketchLineSegment (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doDeleteEntity (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditCanvas (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditCanvasOffset (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditCanvasRotate (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Vec3f alongAxis, osg::Vec3f rotAxis)
 
void doCanvasClone (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doCanvasSeparate (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
template<typename T1 , typename T2 >
void doEditPhotoPush (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditEntitiesMove (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditEntitiesScale (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doEditEntitiesRotate (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doIdleMouse (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doHoverWire (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doHoverPoint (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doDragPoint (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doCameraEye (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doCameraCenter (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doCameraFocal (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doPhotoScaleModelPlane (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
void doPhotoScaleBookmark (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 
entity::StrokegetStroke (const StrokeIntersector::Intersection &result)
 
template<typename EntityType >
EntityType * getEntity2D (const Entity2DIntersector< entity::Entity2D >::Intersection &result)
 
entity::CanvasgetCanvas (const osgUtil::LineSegmentIntersector::Intersection &result)
 
entity::PhotogetPhoto (const osgUtil::LineSegmentIntersector::Intersection &result)
 
entity::PolygongetPolygon (const osgUtil::LineSegmentIntersector::Intersection &result)
 
entity::DraggableWiregetDraggableWire (const PolyLineIntersector::Intersection &result)
 
entity::BookmarkToolgetBookmarkTool (const PolyLineIntersector::Intersection &result)
 
int getSelectedPoint (const PointIntersector::Intersection &result)
 
template<typename T >
cher::MOUSE_MODE getMouseModeFromName (const T &result, cher::MOUSE_MODE mode_default) const
 
cher::MOUSE_MODE getMouseModeFromEvent (cher::MOUSE_MODE mode, const osgGA::GUIEventAdapter &ea)
 
template<typename TypeIntersection , typename TypeIntersector >
bool getIntersection (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, unsigned int mask, TypeIntersection &resultIntersection)
 
bool getRaytraceCanvasIntersection (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, double &u, double &v)
 
bool getRaytraceNormalProjection (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Vec3f &XC)
 
bool getRaytracePlaneIntersection (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, const osg::Vec3f &axis, osg::Vec3f &P)
 
template<typename TResult , typename TIntersector >
bool setCanvasMouseMode (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, cher::MOUSE_MODE modeDefault, bool selected=true)
 
template<typename TResult , typename TIntersector >
std::tuple< bool, TResult > setSVMMouseMode (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, cher::MOUSE_MODE modeDefault)
 
void setDrawableColorFromMode (osg::Drawable *draw)
 
void updateWireGeometry (const PolyLineIntersector::Intersection &intersection)
 
void updatePointGeometry (const PointIntersector::Intersection &intersection)
 
void updateDragPointGeometry (const std::tuple< double, double, bool > &intersection, const osgGA::GUIEventAdapter &ea)
 
void finishAll ()
 

Protected Attributes

GLWidgetm_glWidget
 
cher::MOUSE_MODE m_mode
 
osg::observer_ptr< RootScenem_scene
 
osg::observer_ptr< entity::DraggableWirem_selection
 
osg::observer_ptr< entity::EditableWirem_selection2
 
osg::observer_ptr< entity::BookmarkToolm_tool
 

Detailed Description

An OpenSceneGraph events that were passed from Qt's interface - GLWidget. Event handler is where all the mouse events are processed. Examples: sketching, canvas position editing, polygon drawing, deletion of entities. The EventHandler, after the mouse info extracted, then sends according signals to the UserScene, which, in turn, register the scene changed through the undo/redo commands. Note, some of the keyboard event are processed through the GLWidget and are not passed to the event handler. However, all the mouses events are meant to be passed and processed to the EventHandler.

Member Function Documentation

§ doCameraCenter()

void EventHandler::doCameraCenter ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for setting up camera center position when editing entity::CamPoseData

§ doCameraEye()

void EventHandler::doCameraEye ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for setting up camera eye position when editing entity::CamPoseData

§ doCameraFocal()

void EventHandler::doCameraFocal ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for setting up camera focal size when editing entity::CamPoseData

§ doCanvasClone()

void EventHandler::doCanvasClone ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to create a new canvas by clonning operation. The clonning is done by dragging and locating the new position along a canvas normal. The cloned content does not include entity::Photo.

See also
doCanvasSeparate();.

§ doCanvasSeparate()

void EventHandler::doCanvasSeparate ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to create a new canvas which has the same rotation matrix as the original, but in contrary to the clonning operation, it does not copy any canvas content.

See also
doCanvasClone();

§ doDeleteEntity()

void EventHandler::doDeleteEntity ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to delete an entity from a current canvas by performing a drag within the entity's proximity.

§ doDragPoint()

void EventHandler::doDragPoint ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for point dragging related to entity::SVMData. VirtualPlaneIntersector is used.

§ doEditCanvas()

void EventHandler::doEditCanvas ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to perform canvas editing: offset or rotation.

§ doEditCanvasOffset()

void EventHandler::doEditCanvasOffset ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A sub-method for canvas editing to perform offset.

§ doEditEntitiesMove()

void EventHandler::doEditEntitiesMove ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to move a set of entities within a canvas.

§ doEditEntitiesRotate()

void EventHandler::doEditEntitiesRotate ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to rotate a set of entities within a canvas.

§ doEditEntitiesScale()

void EventHandler::doEditEntitiesScale ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to scale a set of entities within a canvas.

§ doEditPhotoPush()

template<typename T1 , typename T2 >
void EventHandler::doEditPhotoPush ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

This method is in developemt.

§ doEraseStroke()

void EventHandler::doEraseStroke ( entity::Stroke stroke,
int  first,
int  last,
cher::EVENT  event = cher::EVENT_DRAGGED 
)
protected

This method must not used. It is in development.

§ doHoverPoint()

void EventHandler::doHoverPoint ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for point hovering over entity::SVMData. PointIntersector is used.

§ doHoverWire()

void EventHandler::doHoverWire ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method for hover mode over entity::SVMData. PolyLineIntersector and PointIntersector are used.

§ doPhotoScaleBookmark()

void EventHandler::doPhotoScaleBookmark ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to chose a bookmark tool from 3D scene or bookmark widget.

§ doPhotoScaleModelPlane()

void EventHandler::doPhotoScaleModelPlane ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method that suggests a user to select a plane where model is located. (Photo re-scale procedure).

§ doSelectCanvas()

template<typename T1 , typename T2 >
void EventHandler::doSelectCanvas ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to perform canvas selection by using their pickables.

§ doSelectEntity()

void EventHandler::doSelectEntity ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

A method to perform a selection of an entity or a group of entities within a current canvas.

§ doSketch()

void EventHandler::doSketch ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

Method to process events for stroke sketching: left button push indicates beginning of a stroke, and left button release indicates an end of the stroke.

§ doSketchLineSegment()

void EventHandler::doSketchLineSegment ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

Method to process events for line segment drawing.

§ doSketchPolygon()

void EventHandler::doSketchPolygon ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
protected

Method to process events for polygon drawing: left mouse click indicates a new point, right mouse click or double click indicates polygon completion.

§ finishAll()

void EventHandler::finishAll ( )
protected

A method which is called whenever it is necessary to shut the current mode's operation. E.g., for sketching, it would mean forcing a mouse release imitation and completion of a current stroke. This might be necessary for various reasons. The most common one is when the raytracer cannot obtain a 3D intersection with a virtual plane because the current camera view is located too sharp towards the canvas plane where the sketching is going on. Most of the modes that rely on mouse click - drag - release, most likely use this method.

§ getBookmarkTool()

entity::BookmarkTool * EventHandler::getBookmarkTool ( const PolyLineIntersector::Intersection &  result)
protected

A method to obtain bookmark tool from intersection result.

§ getCanvas()

entity::Canvas * EventHandler::getCanvas ( const osgUtil::LineSegmentIntersector::Intersection &  result)
protected

A method to obtain entity::Canvas type from intersection result.

§ getDraggableWire()

entity::DraggableWire * EventHandler::getDraggableWire ( const PolyLineIntersector::Intersection &  result)
protected

A method to obtain entity::DraggableWire type from intersection result.

§ getIntersection()

template<typename TypeIntersection , typename TypeIntersector >
bool EventHandler::getIntersection ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
unsigned int  mask,
TypeIntersection &  resultIntersection 
)
protected

A template method to obtain intersection given an intersector type as a template.

Parameters
maskis used when only certain parts of scene graph should be taken into account by an intersector. For example, when doing a selection of geometries within a canvas, all the other canvas geometries are excluded from the intersector search.
resultIntersectionis the intersection result.
Returns
true if all the steps of intersectors passed successfully.

§ getMouseModeFromEvent()

cher::MOUSE_MODE EventHandler::getMouseModeFromEvent ( cher::MOUSE_MODE  mode,
const osgGA::GUIEventAdapter &  ea 
)
protected

A method to update a provided mouse mode based on the current mouse event. Normally, it is used to determine whether a drag event is happening or not.

Parameters
modeis the input mouse mode
Returns
the updated mouse mode (bitwise operator used to update corresponding flags).

§ getMouseModeFromName()

template<typename T >
cher::MOUSE_MODE EventHandler::getMouseModeFromName ( const T &  result,
cher::MOUSE_MODE  mode_default 
) const
protected

A method to update a mouse mode based on type of geometry caught in an intersection. This method is mainly used when we deal with a entity::SelectedGroup within a canvas. I.e., a group of geomtries that were selected by a user, and that group is now modifyable by methods of rotation within the canvas, scaling within the canvas, moving within the canvas, etc.

Parameters
resultis the intersection result, e.g. frame for scaling or geometry for rotation, etc.
mode_defaultis the default mode which is returned in case if the intersection results do not contain any known componenents, or if they are empty.
Returns
new mouse mode to set.

§ getPhoto()

entity::Photo * EventHandler::getPhoto ( const osgUtil::LineSegmentIntersector::Intersection &  result)
protected

A method to obtain entity::Photo type from intersection result.

§ getPolygon()

entity::Polygon * EventHandler::getPolygon ( const osgUtil::LineSegmentIntersector::Intersection &  result)
protected

A method to obtain entity::Polygon type from intersection result.

§ getRaytraceCanvasIntersection()

bool EventHandler::getRaytraceCanvasIntersection ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
double &  u,
double &  v 
)
protected

A convinience method to calculate intersection point between a raytrace and a current canvas virtual plane. The result intersection is returned in canvas local coordinates. As an example, this method is used for sketching on a entity::Canvas surface. The result intersection point (u, v) is passed to a entity::UserScene::addStroke() in order to draw a stroke.

Parameters
uis the result local U coordinate,
vis the result local V coordinate.

§ getRaytraceNormalProjection()

bool EventHandler::getRaytraceNormalProjection ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
osg::Vec3f &  XC 
)
protected

A convinience method to obtain a 3D point-intersection between a raytrace and a canvas' normal.

Parameters
XCis the returned 3D point
Returns
true if the point XC was found.

§ getRaytracePlaneIntersection()

bool EventHandler::getRaytracePlaneIntersection ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
const osg::Vec3f &  axis,
osg::Vec3f &  P 
)
protected

A convinience method to obtain a 3D intersection between a raycast and a plane which passes through a given axis. The center of a plane is considered to be a 3D center of a current canvas.

Parameters
axisis a vector through which the plane passes.
Pis the returned 3D location.
Returns
true if point P was found successfully.

§ getSelectedPoint()

int EventHandler::getSelectedPoint ( const PointIntersector::Intersection &  result)
protected

A method to obtain a selected point index of an entity::DraggableWire type from intersection result.

§ getStroke()

entity::Stroke * EventHandler::getStroke ( const StrokeIntersector::Intersection &  result)
protected

A method to obtain entity::Stroke type from intersection result.

§ handle()

bool EventHandler::handle ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
)
virtual

A method that handles all the events pass from GLWidget.

§ setCanvasMouseMode()

template<typename TResult , typename TIntersector >
bool EventHandler::setCanvasMouseMode ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa,
cher::MOUSE_MODE  modeDefault,
bool  selected = true 
)
protected

A method that defines the mouse mode depending on location of mouse over a canvas frame. Used in entity select, entity move, entity scale, entity rotate, etc. modes.

Returns
true if no need to exit the parent function, false otherwise

§ setDrawableColorFromMode()

void EventHandler::setDrawableColorFromMode ( osg::Drawable *  draw)
protected

A method to set colors of canvas frame drawables to:

  • gray color when mouse is not hovering anything
  • cyan color over the drawable which gets the hovering.

Member Data Documentation

§ m_glWidget

GLWidget* EventHandler::m_glWidget
protected

A pointer on a current GLWidget; used to make sure the mouse mode is set up within GUI (i.e., cursor change).

§ m_mode

cher::MOUSE_MODE EventHandler::m_mode
protected

A current mouse mode which dictates what actions are performed based on mouse events.

§ m_scene

osg::observer_ptr<RootScene> EventHandler::m_scene
protected

A pointer on a scene; ofter used to extract scene elements such as current canvas.


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