OpenWalnut  1.5.0dev
Public Member Functions | Static Public Attributes | Protected Member Functions | 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:
+ Collaboration diagram for WPickHandler:

Public Member Functions

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

Static Public Attributes

static const std::string unpickString = "unpick"
 The string indicating picking has stopped. More...
 

Protected Member Functions

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

Private Member Functions

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

Private Attributes

boost::signals2::signal< void(WPickInfo) > m_pickSignal
 One can register to this signal to receive pick events. More...
 
WPickInfo m_hitResult
 Textual representation of the result of a pick. More...
 
WPickInfo m_startPick
 indicates what was first picked. Should be "" after unpick. More...
 
bool m_shift
 is shift pressed? More...
 
bool m_ctrl
 is ctrl pressed? More...
 
std::string m_viewerName
 which viewer sends the signal More...
 
bool m_paintMode
 the paint mode More...
 
WPickInfo::WMouseButton m_mouseButton
 stores mouse button that initiated the pick More...
 
bool m_inPickMode
 if true, the pick handler currently is in pick mode. More...
 
int32_t m_scrollWheel
 the virtual value of the scrollwheel More...
 

Detailed Description

Class to handle events with a pick.

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

Definition at line 43 of file WPickHandler.h.

Constructor & Destructor Documentation

◆ WPickHandler() [1/2]

WPickHandler::WPickHandler ( )

Constructor that initalizes members with sensible defaults.

Definition at line 32 of file WPickHandler.cpp.

◆ WPickHandler() [2/2]

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 45 of file WPickHandler.cpp.

◆ ~WPickHandler()

WPickHandler::~WPickHandler ( )
protectedvirtual

Virtual destructor needed because of virtual function.

This desctructor is protected to avoid accidentally deleting an 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 58 of file WPickHandler.cpp.

Member Function Documentation

◆ getHitResult()

WPickInfo WPickHandler::getHitResult ( )

Gives information about the picked object.

Returns
info object for this hit

Definition at line 62 of file WPickHandler.cpp.

References m_hitResult.

Referenced by pick(), and unpick().

+ Here is the caller graph for this function:

◆ getPickSignal()

boost::signals2::signal< void(WPickInfo) > * WPickHandler::getPickSignal ( )
Returns
the m_pickSignal to for registering to it.

Definition at line 67 of file WPickHandler.cpp.

References m_pickSignal.

◆ handle()

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 72 of file WPickHandler.cpp.

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

+ Here is the call graph for this function:

◆ pick()

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 221 of file WPickHandler.cpp.

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

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPaintMode() [1/2]

void WPickHandler::setPaintMode ( bool  paintMode)

Set in paint mode.

Parameters
paintModeShould we switch to paint mode?

Definition at line 388 of file WPickHandler.cpp.

References m_paintMode.

◆ setPaintMode() [2/2]

void WPickHandler::setPaintMode ( int  mode)

setter for paint mode

Deprecated:
use variant taking bool instead.
Parameters
modethe paint mode

Definition at line 393 of file WPickHandler.cpp.

References m_paintMode.

◆ unpick()

void WPickHandler::unpick ( )
virtual

Send a pick signal with the unpickString.

Definition at line 182 of file WPickHandler.cpp.

References getHitResult(), m_hitResult, m_inPickMode, m_pickSignal, m_scrollWheel, m_startPick, m_viewerName, and unpickString.

Referenced by handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updatePickInfoModifierKeys()

void WPickHandler::updatePickInfoModifierKeys ( WPickInfo pickInfo)
private

Sets the current modifiers to the provided pickInfo.

Parameters
pickInfoThis pickInfo will be updated.

Definition at line 208 of file WPickHandler.cpp.

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

Referenced by pick().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ctrl

bool WPickHandler::m_ctrl
private

is ctrl pressed?

Definition at line 131 of file WPickHandler.h.

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

◆ m_hitResult

WPickInfo WPickHandler::m_hitResult
private

Textual representation of the result of a pick.

Definition at line 128 of file WPickHandler.h.

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

◆ m_inPickMode

bool WPickHandler::m_inPickMode
private

if true, the pick handler currently is in pick mode.

Definition at line 136 of file WPickHandler.h.

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

◆ m_mouseButton

WPickInfo::WMouseButton WPickHandler::m_mouseButton
private

stores mouse button that initiated the pick

Definition at line 134 of file WPickHandler.h.

Referenced by handle(), and pick().

◆ m_paintMode

bool WPickHandler::m_paintMode
private

the paint mode

Definition at line 133 of file WPickHandler.h.

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

◆ m_pickSignal

boost::signals2::signal< void( WPickInfo ) > WPickHandler::m_pickSignal
private

One can register to this signal to receive pick events.

Definition at line 126 of file WPickHandler.h.

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

◆ m_scrollWheel

int32_t WPickHandler::m_scrollWheel
private

the virtual value of the scrollwheel

Definition at line 138 of file WPickHandler.h.

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

◆ m_shift

bool WPickHandler::m_shift
private

is shift pressed?

Definition at line 130 of file WPickHandler.h.

Referenced by handle(), and updatePickInfoModifierKeys().

◆ m_startPick

WPickInfo WPickHandler::m_startPick
private

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

Definition at line 129 of file WPickHandler.h.

Referenced by pick(), and unpick().

◆ m_viewerName

std::string WPickHandler::m_viewerName
private

which viewer sends the signal

Definition at line 132 of file WPickHandler.h.

Referenced by pick(), and unpick().

◆ unpickString

const std::string WPickHandler::unpickString = "unpick"
static

The string indicating picking has stopped.

Definition at line 104 of file WPickHandler.h.

Referenced by pick(), WMPickingDVR::pickHandler(), WMPaintTexture::queuePaint(), unpick(), WROIBox::updateGFX(), and WROISphere::updateGFX().


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