Image Component Library (ICL)
Public Member Functions | Public Attributes | Protected Attributes | List of all members
icl::qt::DragRectangleMouseHandler Class Reference

Special MouseHandler implementation that allows for dragging a Rectangle. More...

#include <DragRectangleMouseHandler.h>

Inheritance diagram for icl::qt::DragRectangleMouseHandler:
icl::qt::MouseHandler icl::utils::Lockable

Public Member Functions

 DragRectangleMouseHandler (int minDim=4)
 Default constructor with optionally given minimum dimension. More...
 
virtual void process (const MouseEvent &e)
 overwritten mouse-event handler function More...
 
void visualize (ICLDrawWidget &w)
 visualization method that can be used to visualized the MouseHandlers current state More...
 
bool hasRect () const
 returns wether a valid rectangle was defined More...
 
utils::Rect getRect () const
 returns the currrent rectangle More...
 
bool hasDraggedRect () const
 returns whether the user currently defines a rectangle (using a drag gesture) More...
 
utils::Rect getDragggedRect () const
 returns the currently dragged rectangle More...
 
void setMinDim (int minDim)
 sets the minimum rectangle size More...
 
int getMinDim () const
 returns the minimum rectangle size More...
 
- Public Member Functions inherited from icl::qt::MouseHandler
 MouseHandler (mouse_handler handler)
 Create a mouse handler with given callback function. More...
 
- Public Member Functions inherited from icl::utils::Lockable
 Lockable (bool recursive=false)
 Default constructor. More...
 
 Lockable (const Lockable &l)
 copy constructor (does not copy the source mutex) More...
 
Lockableoperator= (const Lockable &l)
 assignment operator (does not copy the source mutex) More...
 
 ~Lockable ()
 Destructor. More...
 
void lock () const
 lock object More...
 
void unlock () const
 unlock object More...
 
MutexgetMutex () const
 returns mutex of this object More...
 

Public Attributes

core::Color4D m_edge
 edge color for the defined rectangle More...
 
core::Color4D m_fill
 fill color for the defined rectangle More...
 
core::Color4D m_outer
 color that is used for everything outside the rectangle More...
 
core::Color4D m_edgeWhileDrag
 edge color for the dragged rectangle More...
 
core::Color4D m_fillWhileDrag
 fill color for the dragged rectangle More...
 
core::Color4D m_outerWhileDrag
 as m_outer, but for the dragged rectangle More...
 

Protected Attributes

utils::Point m_origin
 point where the drag gesture started More...
 
utils::Point m_curr
 current mouse-position while dragging More...
 
int m_minDim
 minimum rectangle size More...
 
utils::Rect m_rect
 last defined rectangle More...
 

Additional Inherited Members

- Public Types inherited from icl::qt::MouseHandler
typedef void(* mouse_handler) (const MouseEvent &event)
 mouse_handler function type More...
 
- Public Slots inherited from icl::qt::MouseHandler
void handleEvent (const MouseEvent &event)
 connected to the ICLWidget's signal mouseEventOccured More...
 
- Protected Member Functions inherited from icl::qt::MouseHandler
 MouseHandler ()
 This constructor can be called from derived classes. More...
 

Detailed Description

Special MouseHandler implementation that allows for dragging a Rectangle.

This mousehandler can be installed on an instance of ICLWidget. This widget then enables the user to use a mouse-based drag gesture to define a rectangle on top of the current image. The DragRectangleMouseHandler's visualize-method can be used to show the current result. The rectangle can be defined by holding the left mouse button. The right mouse button deletes the currently define rectangle. There are two Rectangles, that can be accessed from outside: the 'dragged-rect' is the rectangle, that is currently dragged. It can be accessed with hasDraggedRect and getDraggedRect. Once a rectangle is defined, it can be accessed with hasRect and hasDraggedRect.

Colors

For each of these two rectangles, three different colors can be set. The edge color of the rectangle, the fill color of the rectangle and the color that is used to fill everything else then the rectangle. Each of these colors can have an alpha component of zero; in this case, the component is not drawn. Since setting these colors is not crucial for threading, public access to the color memerber is granted.

Minimal Rectangle Dimension

In order to avoid to capture simple mouse-clicks, that lead to very small or even zero-sized rectangles, a minimum rectangle dimension can be given in the constructor. The minimum rectangle dimension is only used for the 'real' rectangle, not for the dragged one.

Constructor & Destructor Documentation

◆ DragRectangleMouseHandler()

icl::qt::DragRectangleMouseHandler::DragRectangleMouseHandler ( int  minDim = 4)

Default constructor with optionally given minimum dimension.

See also
Minimal Rectangle Dimension

Member Function Documentation

◆ getDragggedRect()

utils::Rect icl::qt::DragRectangleMouseHandler::getDragggedRect ( ) const

returns the currently dragged rectangle

◆ getMinDim()

int icl::qt::DragRectangleMouseHandler::getMinDim ( ) const
inline

returns the minimum rectangle size

◆ getRect()

utils::Rect icl::qt::DragRectangleMouseHandler::getRect ( ) const

returns the currrent rectangle

◆ hasDraggedRect()

bool icl::qt::DragRectangleMouseHandler::hasDraggedRect ( ) const

returns whether the user currently defines a rectangle (using a drag gesture)

◆ hasRect()

bool icl::qt::DragRectangleMouseHandler::hasRect ( ) const

returns wether a valid rectangle was defined

◆ process()

virtual void icl::qt::DragRectangleMouseHandler::process ( const MouseEvent e)
virtual

overwritten mouse-event handler function

Reimplemented from icl::qt::MouseHandler.

◆ setMinDim()

void icl::qt::DragRectangleMouseHandler::setMinDim ( int  minDim)
inline

sets the minimum rectangle size

◆ visualize()

void icl::qt::DragRectangleMouseHandler::visualize ( ICLDrawWidget w)

visualization method that can be used to visualized the MouseHandlers current state

This method needs an already locked instance of ICLDrawWidget

Member Data Documentation

◆ m_curr

utils::Point icl::qt::DragRectangleMouseHandler::m_curr
protected

current mouse-position while dragging

◆ m_edge

core::Color4D icl::qt::DragRectangleMouseHandler::m_edge

edge color for the defined rectangle

◆ m_edgeWhileDrag

core::Color4D icl::qt::DragRectangleMouseHandler::m_edgeWhileDrag

edge color for the dragged rectangle

◆ m_fill

core::Color4D icl::qt::DragRectangleMouseHandler::m_fill

fill color for the defined rectangle

◆ m_fillWhileDrag

core::Color4D icl::qt::DragRectangleMouseHandler::m_fillWhileDrag

fill color for the dragged rectangle

◆ m_minDim

int icl::qt::DragRectangleMouseHandler::m_minDim
protected

minimum rectangle size

◆ m_origin

utils::Point icl::qt::DragRectangleMouseHandler::m_origin
protected

point where the drag gesture started

◆ m_outer

core::Color4D icl::qt::DragRectangleMouseHandler::m_outer

color that is used for everything outside the rectangle

◆ m_outerWhileDrag

core::Color4D icl::qt::DragRectangleMouseHandler::m_outerWhileDrag

as m_outer, but for the dragged rectangle

◆ m_rect

utils::Rect icl::qt::DragRectangleMouseHandler::m_rect
protected

last defined rectangle


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