casa
5.7.0-16
|
Base class for WorldCanvas event-based polyline tools. More...
#include <MWCPolylineTool.h>
Public Member Functions | |
MWCPolylineTool (Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false) | |
Constructor. More... | |
virtual | ~MWCPolylineTool () |
Destructor. More... | |
virtual void | disable () |
Switch the tool off - this calls the base class disable, and then erases the polyline if it's around. More... | |
virtual void | reset (casacore::Bool skipRefresh=false) |
reset to non-existent, non-active polyline. More... | |
Public Member Functions inherited from casa::MultiWCTool | |
MultiWCTool (const Display::KeySym &keysym=Display::K_Pointer_Button1, bool enable_events=true) | |
Constructor taking the primary key to which this tool will respond. More... | |
virtual | ~MultiWCTool () |
Destructor. More... | |
virtual void | addWorldCanvas (WorldCanvas &worldcanvas) |
Add/remove a WorldCanvas from the control of this tool. More... | |
virtual void | removeWorldCanvas (WorldCanvas &worldcanvas) |
virtual void | addWorldCanvases (PanelDisplay *pdisp) |
Add/Remove a list of WorldCanvases from PanelDisplay. More... | |
virtual void | removeWorldCanvases (PanelDisplay *pdisp) |
virtual void | enable () |
Switch the tool on/off - this simply registers or unregisters the event handlers on the WorldCanvases. More... | |
virtual void | operator() (const WCPositionEvent &ev) |
Required operators for event handling - these are called when events occur, and distribute the events to the "user-level" methods. More... | |
virtual void | operator() (const WCMotionEvent &ev) |
default sends event to cout More... | |
virtual void | operator() (const WCRefreshEvent &ev) |
original handler interface (still used for WCRefreshEvents) 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::WCPositionEH | |
WCPositionEH () | |
Default Constructor Required. More... | |
virtual | ~WCPositionEH () |
Destructor. More... | |
Public Member Functions inherited from casa::WCMotionEH | |
WCMotionEH () | |
Default Constructor Required. More... | |
virtual | ~WCMotionEH () |
Destructor. More... | |
Public Member Functions inherited from casa::WCRefreshEH | |
WCRefreshEH () | |
Default Constructor Required. More... | |
virtual | ~WCRefreshEH () |
Destructor. More... | |
Public Member Functions inherited from casa::DisplayEH | |
virtual void | handleEvent (DisplayEvent &) |
Classes that contain this interface (i.e., derive from it) can override this method to implement actions for whatever types of DisplayEvent they're interested in. More... | |
virtual | ~DisplayEH () |
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... | |
Protected Member Functions | |
virtual void | keyPressed (const WCPositionEvent &ev) |
Functions called by the base class event handling operators–and normally only those. More... | |
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. More... | |
virtual void | doubleInside () |
Output callback functions–to be overridden in derived class as needed. More... | |
virtual void | doubleOutside () |
virtual void | polylineReady () |
casacore::Function called when the polyline is ready and not being edited. More... | |
virtual void | get (casacore::Vector< casacore::Int > &x, casacore::Vector< casacore::Int > &y) const |
Retrieve polyline vertices, or a single vertex, in screen pixels. More... | |
virtual void | get (casacore::Int &x, casacore::Int &y, const casacore::Int pt) const |
void | getLinear (casacore::Vector< casacore::Float > &x, casacore::Vector< casacore::Float > &y) const |
Protected Member Functions inherited from casa::MultiWCTool | |
virtual void | otherKeyReleased (const WCPositionEvent &) |
virtual void | updateRegion () |
virtual void | clicked (casacore::Int, casacore::Int) |
virtual void | doubleClicked (casacore::Int, casacore::Int) |
virtual void | refresh () |
Copy back-to-front buffer (erasing all MWCTool drawings), then cause this (and all MWCTools on current WC's PC) to draw (or not draw) themselves, according to their current state. More... | |
virtual void | setClipToDrawArea () |
Cause subsequent drawing commands to be clipped to the current WC (or its drawing area). More... | |
virtual void | setClipToWC () |
virtual void | resetClip () |
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... | |
Private Types | |
enum | AdjustMode { Off, Def, Ready, Move, Resize } |
state of the polyline tool More... | |
Private Member Functions | |
virtual void | set (const casacore::Vector< casacore::Int > &x, const casacore::Vector< casacore::Int > &y) |
Set the polyline vertices. More... | |
virtual void | set (const casacore::Int x, const casacore::Int y, const casacore::Int pt) |
replace a single vertex. More... | |
void | pushPoint (casacore::Int x1, casacore::Int y1) |
push/pop last vertex More... | |
void | popPoint () |
casacore::Bool | inPolyline (const casacore::Int &x, const casacore::Int &y) const |
are we inside the polyline? More... | |
casacore::Bool | inHandle (const casacore::Int &pt, const casacore::Int &x, const casacore::Int &y) const |
are we within the specified handle? More... | |
Private Attributes | |
casacore::Bool | itsPolylinePersistent |
should the polyline remain on screen after double clicks? More... | |
MWCPolylineTool::AdjustMode | itsMode |
casacore::Bool | itsEmitted |
set true on double-click, if the polyline is persistent. More... | |
casacore::Int | itsNPoints |
Number of points. More... | |
casacore::Vector < casacore::Double > | itsX |
Polyline points (linear). More... | |
casacore::Vector < casacore::Double > | itsY |
casacore::Int | itsHandleSize |
size in pixels of the handles More... | |
casacore::Int | itsSelectedHandle |
vertex being moved More... | |
casacore::Int | itsBaseMoveX |
position that move started from More... | |
casacore::Int | itsBaseMoveY |
casacore::Double | itsLastPressTime |
times of the last two presses More... | |
casacore::Double | its2ndLastPressTime |
Additional Inherited Members | |
Protected Attributes inherited from casa::MultiWCTool | |
WorldCanvas * | itsCurrentWC |
WC being (or to be) drawn on (may be 0 initially). More... | |
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.
|
private |
state of the polyline tool
Enumerator | |
---|---|
Off | |
Def | |
Ready | |
Move | |
Resize |
Definition at line 172 of file MWCPolylineTool.h.
casa::MWCPolylineTool::MWCPolylineTool | ( | 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 polyline if it's around.
Reimplemented from casa::MultiWCTool.
|
inlineprotectedvirtual |
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.
|
inlineprotectedvirtual |
Definition at line 131 of file MWCPolylineTool.h.
|
protectedvirtual |
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.
|
protectedvirtual |
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.
|
protectedvirtual |
|
protected |
|
private |
are we within the specified handle?
|
private |
are we inside the polyline?
|
protectedvirtual |
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.
|
protectedvirtual |
Reimplemented from casa::MultiWCTool.
|
protectedvirtual |
Reimplemented from casa::MultiWCTool.
|
protectedvirtual |
Reimplemented from casa::MultiWCTool.
|
inlineprotectedvirtual |
casacore::Function called when the polyline is ready and not being edited.
(Useful for e.g. slicing).
Definition at line 136 of file MWCPolylineTool.h.
|
private |
|
private |
push/pop last vertex
|
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.
|
privatevirtual |
Set the polyline vertices.
itsNPoints should already be set, and x and y must contain (at least) this many points.
|
privatevirtual |
replace a single vertex.
|
private |
Definition at line 205 of file MWCPolylineTool.h.
|
private |
position that move started from
Definition at line 202 of file MWCPolylineTool.h.
|
private |
Definition at line 202 of file MWCPolylineTool.h.
|
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 185 of file MWCPolylineTool.h.
|
private |
size in pixels of the handles
Definition at line 196 of file MWCPolylineTool.h.
|
private |
times of the last two presses
Definition at line 205 of file MWCPolylineTool.h.
|
private |
Definition at line 179 of file MWCPolylineTool.h.
|
private |
Number of points.
Definition at line 188 of file MWCPolylineTool.h.
|
private |
should the polyline remain on screen after double clicks?
Definition at line 169 of file MWCPolylineTool.h.
|
private |
vertex being moved
Definition at line 199 of file MWCPolylineTool.h.
|
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 193 of file MWCPolylineTool.h.
|
private |
Definition at line 193 of file MWCPolylineTool.h.