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. | |
virtual void | process (const MouseEvent &e) |
overwritten mouse-event handler function | |
void | visualize (ICLDrawWidget &w) |
visualization method that can be used to visualized the MouseHandlers current state | |
bool | hasRect () const |
returns wether a valid rectangle was defined | |
utils::Rect | getRect () const |
returns the currrent rectangle | |
bool | hasDraggedRect () const |
returns whether the user currently defines a rectangle (using a drag gesture) | |
utils::Rect | getDragggedRect () const |
returns the currently dragged rectangle | |
void | setMinDim (int minDim) |
sets the minimum rectangle size | |
int | getMinDim () const |
returns the minimum rectangle size | |
Public Attributes | |
core::Color4D | m_edge |
edge color for the defined rectangle | |
core::Color4D | m_fill |
fill color for the defined rectangle | |
core::Color4D | m_outer |
color that is used for everything outside the rectangle | |
core::Color4D | m_edgeWhileDrag |
edge color for the dragged rectangle | |
core::Color4D | m_fillWhileDrag |
fill color for the dragged rectangle | |
core::Color4D | m_outerWhileDrag |
as m_outer, but for the dragged rectangle | |
Protected Attributes | |
utils::Point | m_origin |
point where the drag gesture started | |
utils::Point | m_curr |
current mouse-position while dragging | |
int | m_minDim |
minimum rectangle size | |
utils::Rect | m_rect |
last defined rectangle |
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.
returns the currently dragged rectangle
int icl::qt::DragRectangleMouseHandler::getMinDim | ( | ) | const [inline] |
returns the minimum rectangle size
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 void icl::qt::DragRectangleMouseHandler::process | ( | const MouseEvent & | e | ) | [virtual] |
overwritten mouse-event handler function
Reimplemented from icl::qt::MouseHandler.
void icl::qt::DragRectangleMouseHandler::setMinDim | ( | int | minDim | ) | [inline] |
sets the minimum rectangle size
visualization method that can be used to visualized the MouseHandlers current state
This method needs an already locked instance of ICLDrawWidget
current mouse-position while dragging
edge color for the defined rectangle
edge color for the dragged rectangle
fill color for the defined rectangle
fill color for the dragged rectangle
int icl::qt::DragRectangleMouseHandler::m_minDim [protected] |
minimum rectangle size
point where the drag gesture started
color that is used for everything outside the rectangle
as m_outer, but for the dragged rectangle
last defined rectangle