OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WPickHandler Class Reference

Class to handle events with a pick. More...

#include <WPickHandler.h>

+ Inheritance diagram for WPickHandler:

Public Member Functions

 WPickHandler ()
 Constructor that initalizes members with sensible defaults.
 WPickHandler (std::string viewerName)
 Constructor that initalizes members with sensible defaults and sets the name of the viewer.
bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
 Deals with the events found by the osg.
virtual void pick (osgViewer::View *view, const osgGA::GUIEventAdapter &ea)
 Send a pick signal with the pick information as string.
virtual void unpick ()
 Send a pick signal with the string "unpick".
WPickInfo getHitResult ()
 Gives information about the picked object.
boost::signals2::signal1< void,
WPickInfo > * 
getPickSignal ()
 returns the m_pickSignal to for registering to it.
void setPaintMode (int mode)
 setter for paint mode

Protected Member Functions

virtual ~WPickHandler ()
 Virtual destructor needed because of virtual function.

Protected Attributes

WPickInfo m_hitResult
 Textual representation of the result of a pick.
WPickInfo m_startPick
 indicates what was first picked. Should be "" after unpick.
bool m_shift
 is shift pressed?
bool m_ctrl
 is ctrl pressed?
std::string m_viewerName
 which viewer sends the signal
int m_paintMode
 the paint mode
WPickInfo::WMouseButton m_mouseButton
 stores mouse button that initiated the pick

Private Member Functions

void updatePickInfoModifierKeys (WPickInfo *pickInfo)
 Sets the current modifiers to the provided pickInfo.

Private Attributes

boost::signals2::signal1< void,
WPickInfo
m_pickSignal
 One can register to this signal to receive pick events.

Detailed Description

Class to handle events with a pick.

The handler ignores any geometry whose name starts with an underscore ("_").

Definition at line 57 of file WPickHandler.h.

Constructor & Destructor Documentation

WPickHandler::WPickHandler ( )

Constructor that initalizes members with sensible defaults.

Definition at line 35 of file WPickHandler.cpp.

WPickHandler::WPickHandler ( std::string  viewerName)
explicit

Constructor that initalizes members with sensible defaults and sets the name of the viewer.

Parameters
viewerNamename of the viewer

Definition at line 46 of file WPickHandler.cpp.

WPickHandler::~WPickHandler ( )
protectedvirtual

Virtual destructor needed because of virtual function.

This desctructor is protected to avoid accidentally deleting a instance of WPickHandler. This follows the philosophy of OSG to avoid problems in multithreaded environments, since these pointers are used deep in the OSG where a deletion could cause a segfault.

Definition at line 57 of file WPickHandler.cpp.

Member Function Documentation

WPickInfo WPickHandler::getHitResult ( )

Gives information about the picked object.

Returns
info object for this hit

Definition at line 61 of file WPickHandler.cpp.

References m_hitResult.

Referenced by pick(), and unpick().

boost::signals2::signal1< void, WPickInfo > * WPickHandler::getPickSignal ( )

returns the m_pickSignal to for registering to it.

Definition at line 66 of file WPickHandler.cpp.

References m_pickSignal.

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

Deals with the events found by the osg.

Parameters
eaEvent class for storing Keyboard, mouse and window events.
aaInterface by which GUIEventHandlers may request actions of the GUI system
Returns
true if the event was handled.

Definition at line 71 of file WPickHandler.cpp.

References m_ctrl, m_mouseButton, m_paintMode, m_shift, pick(), and unpick().

void WPickHandler::pick ( osgViewer::View *  view,
const osgGA::GUIEventAdapter &  ea 
)
virtual

Send a pick signal with the pick information as string.

Parameters
viewthe view in which we pick.
eaEvent class for storing Keyboard, mouse and window events.

Definition at line 180 of file WPickHandler.cpp.

References getHitResult(), WPickInfo::getModifierKey(), WPickInfo::getName(), WPickInfo::getPickNormal(), WPickInfo::getPickPosition(), m_ctrl, m_hitResult, m_mouseButton, m_paintMode, m_pickSignal, m_startPick, m_viewerName, and updatePickInfoModifierKeys().

Referenced by handle().

void WPickHandler::setPaintMode ( int  mode)

setter for paint mode

Parameters
modethe paint mode

Definition at line 311 of file WPickHandler.cpp.

References m_paintMode.

void WPickHandler::unpick ( )
virtual

Send a pick signal with the string "unpick".

Definition at line 143 of file WPickHandler.cpp.

References getHitResult(), m_hitResult, m_pickSignal, m_startPick, and m_viewerName.

Referenced by handle().

void WPickHandler::updatePickInfoModifierKeys ( WPickInfo pickInfo)
private

Sets the current modifiers to the provided pickInfo.

Parameters
pickInfoThis pickInfo will be updated.

Definition at line 167 of file WPickHandler.cpp.

References m_ctrl, m_shift, and WPickInfo::setModifierKey().

Referenced by pick().

Member Data Documentation

bool WPickHandler::m_ctrl
protected

is ctrl pressed?

Definition at line 127 of file WPickHandler.h.

Referenced by handle(), pick(), and updatePickInfoModifierKeys().

WPickInfo WPickHandler::m_hitResult
protected

Textual representation of the result of a pick.

Definition at line 124 of file WPickHandler.h.

Referenced by getHitResult(), pick(), and unpick().

WPickInfo::WMouseButton WPickHandler::m_mouseButton
protected

stores mouse button that initiated the pick

Definition at line 130 of file WPickHandler.h.

Referenced by handle(), and pick().

int WPickHandler::m_paintMode
protected

the paint mode

Definition at line 129 of file WPickHandler.h.

Referenced by handle(), pick(), and setPaintMode().

boost::signals2::signal1< void, WPickInfo > WPickHandler::m_pickSignal
private

One can register to this signal to receive pick events.

Definition at line 141 of file WPickHandler.h.

Referenced by getPickSignal(), pick(), and unpick().

bool WPickHandler::m_shift
protected

is shift pressed?

Definition at line 126 of file WPickHandler.h.

Referenced by handle(), and updatePickInfoModifierKeys().

WPickInfo WPickHandler::m_startPick
protected

indicates what was first picked. Should be "" after unpick.

Definition at line 125 of file WPickHandler.h.

Referenced by pick(), and unpick().

std::string WPickHandler::m_viewerName
protected

which viewer sends the signal

Definition at line 128 of file WPickHandler.h.

Referenced by pick(), and unpick().


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