casa
$Rev:20696$
|
Base class for WorldCanvas event-based polygon tools. More...
#include <WCPolyTool.h>
Public Member Functions | |
WCPolyTool (WorldCanvas *wcanvas, Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False) | |
Constructor. | |
virtual | ~WCPolyTool () |
Destructor. | |
virtual void | disable () |
Switch the tool off - this calls the base class disable, and then erases the polygon if it's around. | |
virtual void | keyPressed (const WCPositionEvent &ev) |
Functions called by the local event handling operators - these handle the drawing of the polygon. | |
virtual void | keyReleased (const WCPositionEvent &ev) |
virtual void | otherKeyPressed (const WCPositionEvent &ev) |
virtual void | moved (const WCMotionEvent &ev, const viewer::region::region_list_type &) |
virtual void | refresh (const WCRefreshEvent &ev) |
virtual void | doubleInside () |
Functions special to the polygon event handling - called when there is a double click inside/outside the polygon. | |
virtual void | doubleOutside () |
virtual void | polygonReady () |
Functions called when a polygon is ready and not being editted, and when this status changes. | |
virtual void | polygonNotReady () |
virtual void | get (Vector< Int > &x, Vector< Int > &y) |
Retrive the polygon vertices. | |
Private Types | |
enum | AdjustMode { Off, Move, Handle } |
adjustment mode More... | |
Private Member Functions | |
void | pushPoint (uInt x1, uInt y1) |
Point operations. | |
void | popPoint () |
void | preserve () |
preserve/restore the world coordinates | |
void | restore () |
void | draw (Bool drawHandles=False) |
draw the polygon on a PixelCanvas | |
void | reset () |
reset this drawer | |
Bool | inHandle (const uInt &pt, const uInt &x, const uInt &y) const |
are we within the specified handle? | |
Bool | inPolygon (const uInt &x, const uInt &y) const |
are we inside the polygon? | |
Private Attributes | |
Bool | itsPolygonPersistent |
do the polygons persist after double clicks? | |
Bool | itsOnScreen |
is the polygon on screen? | |
Bool | itsActive |
are we actively drawing? | |
Bool | itsMoved |
have we moved? | |
Bool | itsPolygonExists |
do we have a polygon yet? | |
WCPolyTool::AdjustMode | itsAdjustMode |
uInt | itsNPoints |
Number of points. | |
Vector< Int > | itsX |
Polygon points ... | |
Vector< Int > | itsY |
Vector< Double > | itsStoredWorldX |
... | |
Vector< Double > | itsStoredWorldY |
uInt | itsHandleSize |
size in pixels of the handles | |
uInt | itsSelectedHandle |
which handle to modify? | |
Int | itsBaseMoveX |
position that move started from | |
Int | itsBaseMoveY |
Int | itsLastPressX |
position of last press event | |
Int | itsLastPressY |
Int | its2ndLastPressX |
Int | its2ndLastPressY |
Int | itsLastReleaseX |
position of last release event | |
Int | itsLastReleaseY |
Double | itsLastPressTime |
store the times of the last two presses here: | |
Double | its2ndLastPressTime |
Base class for WorldCanvas event-based polygon tools.
Public interface
<prerequisites> (see ())WCTool </prerequisites>
WCPolyTool stands for WorldCanvas Polygon Tool
This class adds to its base WCTool to provide a tool for drawing, reshaping and moving polygons on a WorldCanvas. While WCPolyTool is not abstract, it performs no useful function. The programmer should derive from this class and override the functions doubleInside and doubleOutside at the very least. These are called when the user double-clicks a particular key or mouse button inside or outside an existing polygon respectively. It is up to the programmer to decide what these events mean, but it is recommended that an internal double- click correspond to the main action of the tool, eg. emitting the polygon vertices to the application, and that an external double-click correspond to a secondary action of the tool, if indeed there are additional actions suitable to the tool.
The polygon is drawn by clicking at each of the vertices, and clicking on the last or first vertices to complete the polygon. Once drawn, the vertices can be moved by dragging their handles, and the entire polygon relocated by dragging inside the polygon. The polygon is removed from the display when the Esc key is pressed.
Many activities on the WorldCanvas will be based on the user drawing a polygon and using the polygon in some operation.
Definition at line 88 of file WCPolyTool.h.
enum casa::WCPolyTool::AdjustMode [private] |
casa::WCPolyTool::WCPolyTool | ( | WorldCanvas * | wcanvas, |
Display::KeySym | keysym = Display::K_Pointer_Button1 , |
||
const Bool | persistent = False |
||
) |
Constructor.
virtual casa::WCPolyTool::~WCPolyTool | ( | ) | [virtual] |
Destructor.
virtual void casa::WCPolyTool::disable | ( | ) | [virtual] |
Switch the tool off - this calls the base class disable, and then erases the polygon if it's around.
Reimplemented from casa::WCTool.
virtual void casa::WCPolyTool::doubleInside | ( | ) | [inline, virtual] |
Functions special to the polygon event handling - called when there is a double click inside/outside the polygon.
Reimplemented in casa::WCPTRegion.
Definition at line 120 of file WCPolyTool.h.
virtual void casa::WCPolyTool::doubleOutside | ( | ) | [inline, virtual] |
Definition at line 121 of file WCPolyTool.h.
void casa::WCPolyTool::draw | ( | Bool | drawHandles = False | ) | [private] |
draw the polygon on a PixelCanvas
virtual void casa::WCPolyTool::get | ( | Vector< Int > & | x, |
Vector< Int > & | y | ||
) | [virtual] |
Retrive the polygon vertices.
Bool casa::WCPolyTool::inHandle | ( | const uInt & | pt, |
const uInt & | x, | ||
const uInt & | y | ||
) | const [private] |
are we within the specified handle?
Bool casa::WCPolyTool::inPolygon | ( | const uInt & | x, |
const uInt & | y | ||
) | const [private] |
are we inside the polygon?
virtual void casa::WCPolyTool::keyPressed | ( | const WCPositionEvent & | ev | ) | [virtual] |
Functions called by the local event handling operators - these handle the drawing of the polygon.
In special conditions, namely double clicking the key, they will pass control on to the doubleInside and doubleOutside functions
Reimplemented from casa::WCTool.
virtual void casa::WCPolyTool::keyReleased | ( | const WCPositionEvent & | ev | ) | [virtual] |
Reimplemented from casa::WCTool.
virtual void casa::WCPolyTool::moved | ( | const WCMotionEvent & | ev, |
const viewer::region::region_list_type & | |||
) | [virtual] |
Reimplemented from casa::WCTool.
virtual void casa::WCPolyTool::otherKeyPressed | ( | const WCPositionEvent & | ev | ) | [virtual] |
Reimplemented from casa::WCTool.
virtual void casa::WCPolyTool::polygonNotReady | ( | ) | [inline, virtual] |
Definition at line 128 of file WCPolyTool.h.
virtual void casa::WCPolyTool::polygonReady | ( | ) | [inline, virtual] |
Functions called when a polygon is ready and not being editted, and when this status changes.
Definition at line 127 of file WCPolyTool.h.
void casa::WCPolyTool::popPoint | ( | ) | [private] |
void casa::WCPolyTool::preserve | ( | ) | [private] |
preserve/restore the world coordinates
void casa::WCPolyTool::pushPoint | ( | uInt | x1, |
uInt | y1 | ||
) | [private] |
Point operations.
virtual void casa::WCPolyTool::refresh | ( | const WCRefreshEvent & | ev | ) | [virtual] |
Reimplemented from casa::WCTool.
void casa::WCPolyTool::reset | ( | ) | [private] |
reset this drawer
void casa::WCPolyTool::restore | ( | ) | [private] |
Double casa::WCPolyTool::its2ndLastPressTime [private] |
Definition at line 209 of file WCPolyTool.h.
Int casa::WCPolyTool::its2ndLastPressX [private] |
Definition at line 203 of file WCPolyTool.h.
Int casa::WCPolyTool::its2ndLastPressY [private] |
Definition at line 203 of file WCPolyTool.h.
Bool casa::WCPolyTool::itsActive [private] |
are we actively drawing?
Definition at line 143 of file WCPolyTool.h.
Definition at line 157 of file WCPolyTool.h.
Int casa::WCPolyTool::itsBaseMoveX [private] |
position that move started from
Definition at line 199 of file WCPolyTool.h.
Int casa::WCPolyTool::itsBaseMoveY [private] |
Definition at line 199 of file WCPolyTool.h.
uInt casa::WCPolyTool::itsHandleSize [private] |
size in pixels of the handles
Definition at line 187 of file WCPolyTool.h.
Double casa::WCPolyTool::itsLastPressTime [private] |
store the times of the last two presses here:
Definition at line 209 of file WCPolyTool.h.
Int casa::WCPolyTool::itsLastPressX [private] |
position of last press event
Definition at line 202 of file WCPolyTool.h.
Int casa::WCPolyTool::itsLastPressY [private] |
Definition at line 202 of file WCPolyTool.h.
Int casa::WCPolyTool::itsLastReleaseX [private] |
position of last release event
Definition at line 206 of file WCPolyTool.h.
Int casa::WCPolyTool::itsLastReleaseY [private] |
Definition at line 206 of file WCPolyTool.h.
Bool casa::WCPolyTool::itsMoved [private] |
have we moved?
Definition at line 146 of file WCPolyTool.h.
uInt casa::WCPolyTool::itsNPoints [private] |
Number of points.
Definition at line 160 of file WCPolyTool.h.
Bool casa::WCPolyTool::itsOnScreen [private] |
is the polygon on screen?
Definition at line 140 of file WCPolyTool.h.
Bool casa::WCPolyTool::itsPolygonExists [private] |
do we have a polygon yet?
Definition at line 149 of file WCPolyTool.h.
Bool casa::WCPolyTool::itsPolygonPersistent [private] |
do the polygons persist after double clicks?
Definition at line 137 of file WCPolyTool.h.
uInt casa::WCPolyTool::itsSelectedHandle [private] |
which handle to modify?
Definition at line 193 of file WCPolyTool.h.
Vector<Double> casa::WCPolyTool::itsStoredWorldX [private] |
Vector<Double> casa::WCPolyTool::itsStoredWorldY [private] |
Definition at line 166 of file WCPolyTool.h.
Vector<Int> casa::WCPolyTool::itsX [private] |
Vector<Int> casa::WCPolyTool::itsY [private] |
Definition at line 164 of file WCPolyTool.h.