casa
$Rev:20696$
|
Base class for WorldCanvas event-based polyline tools. More...
#include <MWCPolylineTool.h>
Public Member Functions | |
MWCPolylineTool (Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False) | |
Constructor. | |
virtual | ~MWCPolylineTool () |
Destructor. | |
virtual void | disable () |
Switch the tool off - this calls the base class disable, and then erases the polyline if it's around. | |
virtual void | reset (Bool skipRefresh=False) |
reset to non-existent, non-active polyline. | |
Protected Member Functions | |
virtual void | keyPressed (const WCPositionEvent &ev) |
Functions called by the base class event handling operators--and normally only those. | |
virtual void | moved (const WCMotionEvent &ev, const viewer::region::region_list_type &) |
virtual void | keyReleased (const WCPositionEvent &ev) |
virtual void | otherKeyPressed (const WCPositionEvent &ev) |
virtual void | draw (const WCRefreshEvent &, const viewer::region::region_list_type &) |
draw the polyline (if any) on the object's currently active WC. | |
virtual void | doubleInside () |
Output callback functions--to be overridden in derived class as needed. | |
virtual void | doubleOutside () |
virtual void | polylineReady () |
Function called when the polyline is ready and not being edited. | |
virtual void | get (Vector< Int > &x, Vector< Int > &y) const |
Retrieve polyline vertices, or a single vertex, in screen pixels. | |
virtual void | get (Int &x, Int &y, const Int pt) const |
void | getLinear (Vector< Float > &x, Vector< Float > &y) const |
Private Types | |
enum | AdjustMode { Off, Def, Ready, Move, Resize } |
state of the polyline tool More... | |
Private Member Functions | |
virtual void | set (const Vector< Int > &x, const Vector< Int > &y) |
virtual void | set (const Int x, const Int y, const Int pt) |
replace a single vertex. | |
void | pushPoint (Int x1, Int y1) |
push/pop last vertex | |
void | popPoint () |
Bool | inPolyline (const Int &x, const Int &y) const |
are we inside the polyline? | |
Bool | inHandle (const Int &pt, const Int &x, const Int &y) const |
are we within the specified handle? | |
Private Attributes | |
Bool | itsPolylinePersistent |
should the polyline remain on screen after double clicks? | |
MWCPolylineTool::AdjustMode | itsMode |
Bool | itsEmitted |
set True on double-click, if the polyline is persistent. | |
Int | itsNPoints |
Number of points. | |
Vector< Double > | itsX |
Polyline points (linear). | |
Vector< Double > | itsY |
Int | itsHandleSize |
size in pixels of the handles | |
Int | itsSelectedHandle |
vertex being moved | |
Int | itsBaseMoveX |
position that move started from | |
Int | itsBaseMoveY |
Double | itsLastPressTime |
times of the last two presses | |
Double | its2ndLastPressTime |
Base class for WorldCanvas event-based polyline tools.
Public interface
<prerequisites> (see ())WCTool </prerequisites>
MWCPolylineTool stands for Multi-WorldCanvas Polyline Tool
This class adds to its base MWCTool to provide a tool for drawing, reshaping and moving polylines on a WorldCanvas. While MWCPolylineTool 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 polyline 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 polyline 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 polyline is drawn by clicking at each of the vertices, and clicking again on the last to complete the polyline. Once drawn, the vertices can be moved by dragging their handles, and the entire polyline relocated by dragging inside the polyline. The polyline is removed from the display when the Esc key is pressed.
Many activities on the WorldCanvas will be based on the user drawing a polyline and using the polyline in some operation.
Definition at line 88 of file MWCPolylineTool.h.
enum casa::MWCPolylineTool::AdjustMode [private] |
state of the polyline tool
Definition at line 172 of file MWCPolylineTool.h.
casa::MWCPolylineTool::MWCPolylineTool | ( | Display::KeySym | keysym = Display::K_Pointer_Button1 , |
const Bool | persistent = False |
||
) |
Constructor.
virtual casa::MWCPolylineTool::~MWCPolylineTool | ( | ) | [virtual] |
Destructor.
virtual void casa::MWCPolylineTool::disable | ( | ) | [virtual] |
Switch the tool off - this calls the base class disable, and then erases the polyline if it's around.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::doubleInside | ( | ) | [inline, protected, virtual] |
Output callback functions--to be overridden in derived class as needed.
Called when there is a double click inside/outside the polyline
Definition at line 130 of file MWCPolylineTool.h.
virtual void casa::MWCPolylineTool::doubleOutside | ( | ) | [inline, protected, virtual] |
Definition at line 131 of file MWCPolylineTool.h.
virtual void casa::MWCPolylineTool::draw | ( | const WCRefreshEvent & | , |
const viewer::region::region_list_type & | |||
) | [protected, virtual] |
draw the polyline (if any) on the object's currently active WC.
Only to be called by the base class refresh event handler. Derived objects should use refresh() if they need to redraw, but even that is normally handled automatically by this class.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::get | ( | Vector< Int > & | x, |
Vector< Int > & | y | ||
) | const [protected, virtual] |
Retrieve polyline vertices, or a single vertex, in screen pixels.
Valid results during the callback functions; to be used by them, as well as internally.
virtual void casa::MWCPolylineTool::get | ( | Int & | x, |
Int & | y, | ||
const Int | pt | ||
) | const [protected, virtual] |
void casa::MWCPolylineTool::getLinear | ( | Vector< Float > & | x, |
Vector< Float > & | y | ||
) | const [protected] |
Bool casa::MWCPolylineTool::inHandle | ( | const Int & | pt, |
const Int & | x, | ||
const Int & | y | ||
) | const [private] |
are we within the specified handle?
Bool casa::MWCPolylineTool::inPolyline | ( | const Int & | x, |
const Int & | y | ||
) | const [private] |
are we inside the polyline?
virtual void casa::MWCPolylineTool::keyPressed | ( | const WCPositionEvent & | ev | ) | [protected, virtual] |
Functions called by the base class event handling operators--and normally only those.
This is the input that controls the polyline's appearance and action. When the polyline is ready and double-click is received, the doubleInside/Outside routine is invoked.
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::keyReleased | ( | const WCPositionEvent & | ev | ) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::moved | ( | const WCMotionEvent & | ev, |
const viewer::region::region_list_type & | |||
) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::otherKeyPressed | ( | const WCPositionEvent & | ev | ) | [protected, virtual] |
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::polylineReady | ( | ) | [inline, protected, virtual] |
Function called when the polyline is ready and not being edited.
(Useful for e.g. slicing).
Definition at line 136 of file MWCPolylineTool.h.
void casa::MWCPolylineTool::popPoint | ( | ) | [private] |
void casa::MWCPolylineTool::pushPoint | ( | Int | x1, |
Int | y1 | ||
) | [private] |
push/pop last vertex
virtual void casa::MWCPolylineTool::reset | ( | Bool | skipRefresh = False | ) | [virtual] |
reset to non-existent, non-active polyline.
Refreshes if necessary to erase (unless skipRefresh==True). (Does not unregister from WCs or disable future event handling).
Reimplemented from casa::MultiWCTool.
virtual void casa::MWCPolylineTool::set | ( | const Vector< Int > & | x, |
const Vector< Int > & | y | ||
) | [private, virtual] |
Set the polyline vertices. itsNPoints should already be set, and x and y must contain (at least) this many points.
virtual void casa::MWCPolylineTool::set | ( | const Int | x, |
const Int | y, | ||
const Int | pt | ||
) | [private, virtual] |
replace a single vertex.
Definition at line 204 of file MWCPolylineTool.h.
Int casa::MWCPolylineTool::itsBaseMoveX [private] |
position that move started from
Definition at line 201 of file MWCPolylineTool.h.
Int casa::MWCPolylineTool::itsBaseMoveY [private] |
Definition at line 201 of file MWCPolylineTool.h.
Bool casa::MWCPolylineTool::itsEmitted [private] |
set True on double-click, if the polyline is persistent.
set False when the polyline is moved, resized or reset. If True, a click outside the polyline will erase it and begin definition of a new one.
Definition at line 184 of file MWCPolylineTool.h.
Int casa::MWCPolylineTool::itsHandleSize [private] |
size in pixels of the handles
Definition at line 195 of file MWCPolylineTool.h.
times of the last two presses
Definition at line 204 of file MWCPolylineTool.h.
Definition at line 178 of file MWCPolylineTool.h.
Int casa::MWCPolylineTool::itsNPoints [private] |
Number of points.
Definition at line 187 of file MWCPolylineTool.h.
should the polyline remain on screen after double clicks?
Definition at line 169 of file MWCPolylineTool.h.
Int casa::MWCPolylineTool::itsSelectedHandle [private] |
vertex being moved
Definition at line 198 of file MWCPolylineTool.h.
Vector<Double> casa::MWCPolylineTool::itsX [private] |
Polyline points (linear).
Not to be used directly. use get, set, push, pop instead, which take pixel coordinate arguments. It's done this way so that zooms work on the figures.
Definition at line 192 of file MWCPolylineTool.h.
Vector<Double> casa::MWCPolylineTool::itsY [private] |
Definition at line 192 of file MWCPolylineTool.h.