casa
5.7.0-16
|
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 casacore::Bool persistent=false) | |
Constructor. More... | |
virtual | ~WCPolyTool () |
Destructor. More... | |
virtual void | disable () |
Switch the tool off - this calls the base class disable, and then erases the polygon if it's around. More... | |
virtual void | keyPressed (const WCPositionEvent &ev) |
Functions called by the local event handling operators - these handle the drawing of the polygon. More... | |
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. More... | |
virtual void | doubleOutside () |
virtual void | polygonReady () |
Functions called when a polygon is ready and not being editted, and when this status changes. More... | |
virtual void | polygonNotReady () |
virtual void | get (casacore::Vector< casacore::Int > &x, casacore::Vector< casacore::Int > &y) |
Retrive the polygon vertices. More... | |
Public Member Functions inherited from casa::WCTool | |
WCTool (WorldCanvas *wcanvas, const Display::KeySym &keysym=Display::K_Pointer_Button1) | |
Constructor taking a pointer to a WorldCanvas to which this tool will attach, and a primary key to respond to. More... | |
virtual | ~WCTool () |
Destructor. More... | |
virtual void | enable () |
Switch the tool on/off - this simply registers or unregisters the event handlers. More... | |
virtual void | operator() (const WCPositionEvent &ev) |
Required operators for event handling - these are called when an events occur, and distribute the events to the "user-level" methods. More... | |
virtual void | operator() (const WCMotionEvent &ev) |
virtual void | operator() (const WCRefreshEvent &ev) |
virtual void | otherKeyReleased (const WCPositionEvent &) |
virtual WorldCanvas * | worldCanvas () const |
Get the WorldCanvas that this Tool is attached to. More... | |
virtual PixelCanvas * | pixelCanvas () const |
Get the PixelCanvas that this Tool is attached to via its WorldCanvas. More... | |
Public Member Functions inherited from casa::DisplayTool | |
virtual | ~DisplayTool () |
Destructor. More... | |
virtual void | setKey (const Display::KeySym &keysym) |
Set/get which key to catch. More... | |
virtual Display::KeySym | getKey () const |
Public Member Functions inherited from casa::DTVisible | |
DTVisible () | |
Default constructor. More... | |
virtual | ~DTVisible () |
Destructor. More... | |
virtual casacore::String | drawColor () const |
Return the color to use. More... | |
virtual casacore::Int | lineWidth () const |
Return the line width to use. More... | |
virtual casacore::Double | doubleClickInterval () const |
Return the double click interval (in seconds). More... | |
Private Types | |
enum | AdjustMode { Off, Move, Handle } |
adjustment mode More... | |
Private Member Functions | |
void | pushPoint (casacore::uInt x1, casacore::uInt y1) |
Point operations. More... | |
void | popPoint () |
void | preserve () |
preserve/restore the world coordinates More... | |
void | restore () |
void | draw (casacore::Bool drawHandles=false) |
draw the polygon on a PixelCanvas More... | |
void | reset () |
reset this drawer More... | |
casacore::Bool | inHandle (const casacore::uInt &pt, const casacore::uInt &x, const casacore::uInt &y) const |
are we within the specified handle? More... | |
casacore::Bool | inPolygon (const casacore::uInt &x, const casacore::uInt &y) const |
are we inside the polygon? More... | |
Additional Inherited Members | |
Protected Member Functions inherited from casa::WCTool | |
WCTool () | |
(Required) default constructor. More... | |
WCTool (const WCTool &other) | |
(Required) copy constructor. More... | |
WCTool & | operator= (const WCTool &other) |
(Required) copy assignment. More... | |
Protected Member Functions inherited from casa::DisplayTool | |
DisplayTool (const Display::KeySym &keysym=Display::K_Pointer_Button1) | |
Constructor taking a key to which this tool will initially be attached, typically one of the pointer buttons. More... | |
DisplayTool (const DisplayTool &other) | |
Copy constructor - construct a new DisplayTool from other , using copy semantics. More... | |
DisplayTool & | operator= (const DisplayTool &other) |
Copy assignment using copy semantics. More... | |
Display::KeyModifier | keyModifiers () |
Return the modifier mask. More... | |
Protected Member Functions inherited from casa::DTVisible | |
DTVisible (const DTVisible &other) | |
(Required) copy constructor. More... | |
DTVisible & | operator= (const DTVisible &other) |
(Required) copy assignment. More... | |
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.
|
private |
casa::WCPolyTool::WCPolyTool | ( | WorldCanvas * | wcanvas, |
Display::KeySym | keysym = Display::K_Pointer_Button1 , |
||
const casacore::Bool | persistent = false |
||
) |
Constructor.
|
virtual |
Destructor.
|
virtual |
Switch the tool off - this calls the base class disable, and then erases the polygon if it's around.
Reimplemented from casa::WCTool.
|
inlinevirtual |
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.
|
inlinevirtual |
Definition at line 121 of file WCPolyTool.h.
|
private |
draw the polygon on a PixelCanvas
|
virtual |
Retrive the polygon vertices.
|
private |
are we within the specified handle?
|
private |
are we inside the polygon?
|
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 |
Reimplemented from casa::WCTool.
|
virtual |
Reimplemented from casa::WCTool.
|
virtual |
Reimplemented from casa::WCTool.
|
inlinevirtual |
Definition at line 128 of file WCPolyTool.h.
|
inlinevirtual |
Functions called when a polygon is ready and not being editted, and when this status changes.
Definition at line 127 of file WCPolyTool.h.
|
private |
|
private |
preserve/restore the world coordinates
|
private |
Point operations.
|
virtual |
Reimplemented from casa::WCTool.
|
private |
reset this drawer
|
private |
|
private |
Definition at line 209 of file WCPolyTool.h.
|
private |
Definition at line 203 of file WCPolyTool.h.
|
private |
Definition at line 203 of file WCPolyTool.h.
|
private |
are we actively drawing?
Definition at line 143 of file WCPolyTool.h.
|
private |
Definition at line 157 of file WCPolyTool.h.
|
private |
position that move started from
Definition at line 199 of file WCPolyTool.h.
|
private |
Definition at line 199 of file WCPolyTool.h.
|
private |
size in pixels of the handles
Definition at line 187 of file WCPolyTool.h.
|
private |
store the times of the last two presses here:
Definition at line 209 of file WCPolyTool.h.
|
private |
position of last press event
Definition at line 202 of file WCPolyTool.h.
|
private |
Definition at line 202 of file WCPolyTool.h.
|
private |
position of last release event
Definition at line 206 of file WCPolyTool.h.
|
private |
Definition at line 206 of file WCPolyTool.h.
|
private |
have we moved?
Definition at line 146 of file WCPolyTool.h.
|
private |
Number of points.
Definition at line 160 of file WCPolyTool.h.
|
private |
is the polygon on screen?
Definition at line 140 of file WCPolyTool.h.
|
private |
do we have a polygon yet?
Definition at line 149 of file WCPolyTool.h.
|
private |
do the polygons persist after double clicks?
Definition at line 137 of file WCPolyTool.h.
|
private |
which handle to modify?
Definition at line 193 of file WCPolyTool.h.
|
private |
|
private |
Definition at line 166 of file WCPolyTool.h.
|
private |
|
private |
Definition at line 164 of file WCPolyTool.h.