Image Component Library (ICL)
|
Special MouseHandler implementation that allows for dragging a Rectangle. More...
#include <DragRectangleMouseHandler.h>
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... | |
Lockable & | operator= (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... | |
Mutex & | getMutex () 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... | |
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.
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.
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.
icl::qt::DragRectangleMouseHandler::DragRectangleMouseHandler | ( | int | minDim = 4 | ) |
Default constructor with optionally given minimum dimension.
utils::Rect icl::qt::DragRectangleMouseHandler::getDragggedRect | ( | ) | const |
returns the currently dragged rectangle
|
inline |
returns the minimum rectangle size
utils::Rect icl::qt::DragRectangleMouseHandler::getRect | ( | ) | const |
returns the currrent rectangle
bool icl::qt::DragRectangleMouseHandler::hasDraggedRect | ( | ) | const |
returns whether the user currently defines a rectangle (using a drag gesture)
bool icl::qt::DragRectangleMouseHandler::hasRect | ( | ) | const |
returns wether a valid rectangle was defined
|
virtual |
overwritten mouse-event handler function
Reimplemented from icl::qt::MouseHandler.
|
inline |
sets the minimum rectangle size
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
|
protected |
current mouse-position while dragging
core::Color4D icl::qt::DragRectangleMouseHandler::m_edge |
edge color for the defined rectangle
core::Color4D icl::qt::DragRectangleMouseHandler::m_edgeWhileDrag |
edge color for the dragged rectangle
core::Color4D icl::qt::DragRectangleMouseHandler::m_fill |
fill color for the defined rectangle
core::Color4D icl::qt::DragRectangleMouseHandler::m_fillWhileDrag |
fill color for the dragged rectangle
|
protected |
minimum rectangle size
|
protected |
point where the drag gesture started
core::Color4D icl::qt::DragRectangleMouseHandler::m_outer |
color that is used for everything outside the rectangle
core::Color4D icl::qt::DragRectangleMouseHandler::m_outerWhileDrag |
as m_outer, but for the dragged rectangle
|
protected |
last defined rectangle