OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
WOnscreenSelection Class Reference

Manages different types of selection. More...

#include <WOnscreenSelection.h>

+ Collaboration diagram for WOnscreenSelection:

Public Types

enum class  WSelectionType { BRUSH , LINELOOP , BOX }
 The different types of selection. More...
 
typedef boost::function< void(enum WSelectionType, float, float) > CallbackType
 A typedef for the type of the callbacks. More...
 

Public Member Functions

 WOnscreenSelection ()
 Not only creates the Object but also sets up the drawing context. More...
 
 ~WOnscreenSelection ()
 Cleans up all the now unneeded drawing context stuff. More...
 
void start (float x, float y)
 Starts the selection. More...
 
void end (float x, float y)
 Ends the selection. More...
 
void move (float x, float y)
 Handles mouse move while selecting. More...
 
enum WSelectionType getSelectionType ()
 Gets the current selection type. More...
 
void clear ()
 Clears the current selection. More...
 
bool isSelected (float x, float y, float z)
 Whether a point is selected or not. More...
 
std::vector< WPositionisSelected (std::vector< WPosition > positions)
 Checks if the positions are selected and only returns those that are. More...
 
void setSelectionType (enum WSelectionType selectionType)
 Sets the current selection type. More...
 
void setOnstart (CallbackType onstart)
 Sets the callback for the onstart function. More...
 
void setOnend (CallbackType onend)
 Sets the callback for the onend function. More...
 
void setOnmove (CallbackType onmove)
 Sets the callback for the onmove function. More...
 
bool isSelecting ()
 Returns whether this manager is currently creating a selection. More...
 
bool boxCheck (float x, float y)
 Check for the box selection. More...
 
bool brushCheck (float x, float y)
 Check for the brush selection. More...
 
bool lineloopCheck (float x, float y)
 Check for the lineloop selection. More...
 
int crossingNumberProduct (float x, float y, WPosition b, WPosition c)
 Calculates the crossing number product. More...
 
void setClickType (bool clickType)
 Sets the click type. More...
 
bool getClickType ()
 Gets the click type. More...
 
bool hasMoved ()
 

Private Member Functions

void updateDisplay ()
 Updates the current rendered data. More...
 

Private Attributes

osg::ref_ptr< osg::Projection > m_projection
 The Projection to draw on. More...
 
enum WSelectionType m_selectionType
 The current selection type. More...
 
osg::ref_ptr< WOnscreenSelectionHandlerm_selectionHandler
 The SelectionHandler for this object. More...
 
std::vector< WPositionm_line
 The points that are used for the selection. More...
 
bool m_isSelecting
 Whether a selection has been started or not. More...
 
osg::ref_ptr< WGEShaderm_shader
 The shader for the selection. More...
 
float m_thickness
 The thickness of the brush. More...
 
bool m_clickType
 Whether this is a left click or not. More...
 
bool m_moved
 Whether the mouse has been moved. More...
 
CallbackType m_onstart
 The Callback for the start function. More...
 
CallbackType m_onend
 The Callback for the end function. More...
 
CallbackType m_onmove
 The Callback for the move function. More...
 

Detailed Description

Manages different types of selection.

Definition at line 50 of file WOnscreenSelection.h.

Member Typedef Documentation

◆ CallbackType

typedef boost::function< void ( enum WSelectionType, float, float ) > WOnscreenSelection::CallbackType

A typedef for the type of the callbacks.

Definition at line 64 of file WOnscreenSelection.h.

Member Enumeration Documentation

◆ WSelectionType

The different types of selection.

Definition at line 56 of file WOnscreenSelection.h.

Constructor & Destructor Documentation

◆ WOnscreenSelection()

WOnscreenSelection::WOnscreenSelection ( )

Not only creates the Object but also sets up the drawing context.

Definition at line 29 of file WOnscreenSelection.cpp.

References WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), and m_selectionHandler.

+ Here is the call graph for this function:

◆ ~WOnscreenSelection()

WOnscreenSelection::~WOnscreenSelection ( )

Cleans up all the now unneeded drawing context stuff.

Definition at line 41 of file WOnscreenSelection.cpp.

References WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), m_projection, and m_selectionHandler.

+ Here is the call graph for this function:

Member Function Documentation

◆ boxCheck()

bool WOnscreenSelection::boxCheck ( float  x,
float  y 
)

Check for the box selection.

Parameters
xThe x position of the point.
yThe y position of the point.
Returns
true The point is inside of the box.
false The point is not inside of the box

Definition at line 316 of file WOnscreenSelection.cpp.

References m_line.

Referenced by isSelected().

+ Here is the caller graph for this function:

◆ brushCheck()

bool WOnscreenSelection::brushCheck ( float  x,
float  y 
)

Check for the brush selection.

Parameters
xThe x position of the point.
yThe y position of the point.
Returns
true The point is on the brush.
false The point is not on the brush

Definition at line 329 of file WOnscreenSelection.cpp.

References WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), m_line, and m_thickness.

Referenced by isSelected().

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

◆ clear()

void WOnscreenSelection::clear ( )

Clears the current selection.

Definition at line 260 of file WOnscreenSelection.cpp.

References m_line, and updateDisplay().

Referenced by WOnscreenSelectionHandler::handle(), and start().

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

◆ crossingNumberProduct()

int WOnscreenSelection::crossingNumberProduct ( float  x,
float  y,
WPosition  b,
WPosition  c 
)

Calculates the crossing number product.

Parameters
xThe x position of the point.
yThe y position of the point.
bThe start of the line.
cThe end of the line.
Returns
int Either -1, 0 or 1.

Definition at line 388 of file WOnscreenSelection.cpp.

Referenced by lineloopCheck().

+ Here is the caller graph for this function:

◆ end()

void WOnscreenSelection::end ( float  x,
float  y 
)

Ends the selection.

Parameters
xThe normalized x position of the mouse.
yThe normalized y position of the mouse.

Definition at line 73 of file WOnscreenSelection.cpp.

References m_isSelecting, m_line, m_onend, m_selectionType, and updateDisplay().

Referenced by WOnscreenSelectionHandler::handle().

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

◆ getClickType()

bool WOnscreenSelection::getClickType ( )

Gets the click type.

Returns
true left click.
false right click.

Definition at line 426 of file WOnscreenSelection.cpp.

References m_clickType.

◆ getSelectionType()

enum WOnscreenSelection::WSelectionType WOnscreenSelection::getSelectionType ( )

Gets the current selection type.

Returns
enum WSelectionType The current selection type.

Definition at line 101 of file WOnscreenSelection.cpp.

References m_isSelecting, m_line, m_moved, m_onmove, m_selectionType, and updateDisplay().

+ Here is the call graph for this function:

◆ hasMoved()

bool WOnscreenSelection::hasMoved ( )
Returns
true The mouse has been moved.
false The mouse has not been moved.

Definition at line 431 of file WOnscreenSelection.cpp.

References m_moved.

◆ isSelected() [1/2]

bool WOnscreenSelection::isSelected ( float  x,
float  y,
float  z 
)

Whether a point is selected or not.

Parameters
xThe x position.
yThe y position.
zThe z position.
Returns
true The point is selected.
false The point is not selected.

Definition at line 266 of file WOnscreenSelection.cpp.

References boxCheck(), brushCheck(), WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), lineloopCheck(), m_line, and m_selectionType.

Referenced by isSelected().

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

◆ isSelected() [2/2]

std::vector< WPosition > WOnscreenSelection::isSelected ( std::vector< WPosition positions)

Checks if the positions are selected and only returns those that are.

Parameters
positionsThe positions to check
Returns
std::vector< WPosition > A vector of selected positions

Definition at line 300 of file WOnscreenSelection.cpp.

References isSelected().

+ Here is the call graph for this function:

◆ isSelecting()

bool WOnscreenSelection::isSelecting ( )

Returns whether this manager is currently creating a selection.

Returns
true It is creating a selection.
false It is not creating a selection.

Definition at line 255 of file WOnscreenSelection.cpp.

References m_isSelecting.

◆ lineloopCheck()

bool WOnscreenSelection::lineloopCheck ( float  x,
float  y 
)

Check for the lineloop selection.

Parameters
xThe x position of the point.
yThe y position of the point.
Returns
true The point is inside of the lineloop.
false The point is inside of the lineloop

Definition at line 371 of file WOnscreenSelection.cpp.

References crossingNumberProduct(), and m_line.

Referenced by isSelected().

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

◆ move()

void WOnscreenSelection::move ( float  x,
float  y 
)

Handles mouse move while selecting.

Parameters
xThe normalized x position of the mouse.
yThe normalized y position of the mouse.

Definition at line 101 of file WOnscreenSelection.cpp.

Referenced by WOnscreenSelectionHandler::handle().

+ Here is the caller graph for this function:

◆ setClickType()

void WOnscreenSelection::setClickType ( bool  clickType)

Sets the click type.

Parameters
clickTypetrue for left click, false for right click.

Definition at line 421 of file WOnscreenSelection.cpp.

References m_clickType.

Referenced by WOnscreenSelectionHandler::handle().

+ Here is the caller graph for this function:

◆ setOnend()

void WOnscreenSelection::setOnend ( CallbackType  onend)

Sets the callback for the onend function.

Use NULL to reset.

Parameters
onendThe Callback or NULL.

Definition at line 245 of file WOnscreenSelection.cpp.

References m_onend.

◆ setOnmove()

void WOnscreenSelection::setOnmove ( CallbackType  onmove)

Sets the callback for the onmove function.

Use NULL to reset.

Parameters
onmoveThe Callback or NULL.

Definition at line 250 of file WOnscreenSelection.cpp.

References m_onmove.

◆ setOnstart()

void WOnscreenSelection::setOnstart ( CallbackType  onstart)

Sets the callback for the onstart function.

Use NULL to reset.

Parameters
onstartThe Callback or NULL.

Definition at line 240 of file WOnscreenSelection.cpp.

References m_onstart.

◆ setSelectionType()

void WOnscreenSelection::setSelectionType ( enum WSelectionType  selectionType)

Sets the current selection type.

Parameters
selectionTypeThe selection type to set.

Definition at line 135 of file WOnscreenSelection.cpp.

References m_selectionType.

◆ start()

void WOnscreenSelection::start ( float  x,
float  y 
)

Starts the selection.

Parameters
xThe normalized x position of the mouse.
yThe normalized y position of the mouse.

Definition at line 47 of file WOnscreenSelection.cpp.

References clear(), m_isSelecting, m_line, m_moved, m_onstart, m_selectionType, and updateDisplay().

Referenced by WOnscreenSelectionHandler::handle().

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

◆ updateDisplay()

void WOnscreenSelection::updateDisplay ( )
private

Updates the current rendered data.

Definition at line 140 of file WOnscreenSelection.cpp.

References WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), m_clickType, m_line, m_projection, m_selectionType, m_shader, and m_thickness.

Referenced by clear(), end(), getSelectionType(), and start().

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

Member Data Documentation

◆ m_clickType

bool WOnscreenSelection::m_clickType
private

Whether this is a left click or not.

Definition at line 242 of file WOnscreenSelection.h.

Referenced by getClickType(), setClickType(), and updateDisplay().

◆ m_isSelecting

bool WOnscreenSelection::m_isSelecting
private

Whether a selection has been started or not.

Definition at line 236 of file WOnscreenSelection.h.

Referenced by end(), getSelectionType(), isSelecting(), and start().

◆ m_line

std::vector< WPosition > WOnscreenSelection::m_line
private

The points that are used for the selection.

Definition at line 234 of file WOnscreenSelection.h.

Referenced by boxCheck(), brushCheck(), clear(), end(), getSelectionType(), isSelected(), lineloopCheck(), start(), and updateDisplay().

◆ m_moved

bool WOnscreenSelection::m_moved
private

Whether the mouse has been moved.

Definition at line 244 of file WOnscreenSelection.h.

Referenced by getSelectionType(), hasMoved(), and start().

◆ m_onend

CallbackType WOnscreenSelection::m_onend
private

The Callback for the end function.

Definition at line 248 of file WOnscreenSelection.h.

Referenced by end(), and setOnend().

◆ m_onmove

CallbackType WOnscreenSelection::m_onmove
private

The Callback for the move function.

Definition at line 250 of file WOnscreenSelection.h.

Referenced by getSelectionType(), and setOnmove().

◆ m_onstart

CallbackType WOnscreenSelection::m_onstart
private

The Callback for the start function.

Definition at line 246 of file WOnscreenSelection.h.

Referenced by setOnstart(), and start().

◆ m_projection

osg::ref_ptr< osg::Projection > WOnscreenSelection::m_projection
private

The Projection to draw on.

Definition at line 228 of file WOnscreenSelection.h.

Referenced by updateDisplay(), and ~WOnscreenSelection().

◆ m_selectionHandler

osg::ref_ptr< WOnscreenSelectionHandler > WOnscreenSelection::m_selectionHandler
private

The SelectionHandler for this object.

Definition at line 232 of file WOnscreenSelection.h.

Referenced by WOnscreenSelection(), and ~WOnscreenSelection().

◆ m_selectionType

enum WSelectionType WOnscreenSelection::m_selectionType
private

The current selection type.

Definition at line 228 of file WOnscreenSelection.h.

Referenced by end(), getSelectionType(), isSelected(), setSelectionType(), start(), and updateDisplay().

◆ m_shader

osg::ref_ptr< WGEShader > WOnscreenSelection::m_shader
private

The shader for the selection.

Definition at line 238 of file WOnscreenSelection.h.

Referenced by updateDisplay().

◆ m_thickness

float WOnscreenSelection::m_thickness
private

The thickness of the brush.

Definition at line 240 of file WOnscreenSelection.h.

Referenced by brushCheck(), and updateDisplay().


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