casa
$Rev:20696$
|
Base class for WorldCanvas event-based polyline tools. More...
#include <MultiPolylineTool.h>
Public Member Functions | |
MultiPolylineTool (viewer::RegionSourceFactory *rsf, PanelDisplay *pd, Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False) | |
Constructor. | |
virtual | ~MultiPolylineTool () |
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. | |
virtual Bool | polylineDefined () |
Is a polyline currently defined? | |
viewer::RegionSource * | getRegionSource () |
void | checkPoint (WorldCanvas *wc, State &state) |
this is a non-const function because a non-const RegionTool ptr is returned in 'state' which can then be used for setting the state of the regions managed by the various tools.... | |
void | revokeRegion (viewer::Region *) |
called when the user (read GUI user) indicates that a region should be deleted... | |
const std::set < viewer::region::RegionTypes > & | regionsCreated () const |
returns a set which indicates regions this creator creates... | |
bool | create (viewer::region::RegionTypes, WorldCanvas *, const std::vector< std::pair< double, double > > &, const std::string &, viewer::region::TextPosition, const std::vector< int > &, const std::string &, int, int, const std::string &, const std::string &, viewer::region::LineStyle, unsigned int, bool, VOID *) |
create regions of various types (e.g. | |
RegionToolTypes | type () const |
Protected Member Functions | |
virtual void | keyPressed (const WCPositionEvent &) |
Functions called by the base class event handling operators--and normally only those. | |
virtual void | moved (const WCMotionEvent &, const viewer::region::region_list_type &) |
virtual void | keyReleased (const WCPositionEvent &) |
virtual void | otherKeyPressed (const WCPositionEvent &) |
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 a 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 |
virtual bool | checkType (viewer::region::RegionTypes t) |
Private Types | |
enum | AdjustMode { Off, Def, Ready, Move, Resize } |
state of the polyline tool More... | |
typedef std::list < std::tr1::shared_ptr < viewer::Polyline > > | polylinelist |
Private Member Functions | |
void | start_new_polyline (WorldCanvas *, int x, int y) |
virtual void | set (const Vector< Int > &x, const Vector< Int > &y) |
Set the polyline vertices. | |
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 | |
std::tr1::shared_ptr < viewer::Polyline > | resizing_region |
std::tr1::shared_ptr < viewer::Polyline > | creating_region |
Bool | itsPolylinePersistent |
should the polyline remain on screen after double clicks? | |
MultiPolylineTool::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 | itsX1 |
pixel coordinates of the pan vector. | |
Int | itsY1 |
Int | itsX2 |
Int | itsY2 |
Int | itsX3 |
Int | itsY3 |
Int | itsHandleSize |
size in pixels of the handles | |
Int | itsSelectedHandle |
vertex being moved | |
Int | itsBaseMoveX |
position that move started from | |
Int | itsBaseMoveY |
int | resizing_region_handle |
may not be needed... | |
polylinelist | moving_regions |
double | moving_linx_ |
double | moving_liny_ |
std::tr1::shared_ptr < viewer::Polyline > | building_polyline |
viewer::RegionSource * | rfactory |
polylinelist | polylines |
PanelDisplay * | pd_ |
Base class for WorldCanvas event-based polyline tools.
Public interface
<prerequisites> (see ())WCTool </prerequisites>
MultiPolylineTool 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 MultiPolylineTool 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 or first vertex 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.
Definition at line 82 of file MultiPolylineTool.h.
typedef std::list<std::tr1::shared_ptr<viewer::Polyline> > casa::MultiPolylineTool::polylinelist [private] |
Definition at line 164 of file MultiPolylineTool.h.
enum casa::MultiPolylineTool::AdjustMode [private] |
state of the polyline tool
Definition at line 194 of file MultiPolylineTool.h.
casa::MultiPolylineTool::MultiPolylineTool | ( | viewer::RegionSourceFactory * | rsf, |
PanelDisplay * | pd, | ||
Display::KeySym | keysym = Display::K_Pointer_Button1 , |
||
const Bool | persistent = False |
||
) |
Constructor.
virtual casa::MultiPolylineTool::~MultiPolylineTool | ( | ) | [virtual] |
Destructor.
void casa::MultiPolylineTool::checkPoint | ( | WorldCanvas * | wc, |
State & | state | ||
) | [virtual] |
this is a non-const function because a non-const RegionTool ptr is returned in 'state' which can then be used for setting the state of the regions managed by the various tools....
Implements casa::RegionTool.
virtual bool casa::MultiPolylineTool::checkType | ( | viewer::region::RegionTypes | t | ) | [inline, protected, virtual] |
Definition at line 161 of file MultiPolylineTool.h.
References casa::viewer::region::PolylineRegion.
bool casa::MultiPolylineTool::create | ( | viewer::region::RegionTypes | , |
WorldCanvas * | , | ||
const std::vector< std::pair< double, double > > & | , | ||
const std::string & | , | ||
viewer::region::TextPosition | , | ||
const std::vector< int > & | , | ||
const std::string & | , | ||
int | , | ||
int | , | ||
const std::string & | , | ||
const std::string & | , | ||
viewer::region::LineStyle | , | ||
unsigned | int, | ||
bool | , | ||
VOID * | |||
) | [virtual] |
create regions of various types (e.g.
point, rect, poly, etc.). For use when loading casa region files...
Implements casa::RegionTool.
virtual void casa::MultiPolylineTool::disable | ( | ) | [virtual] |
Switch the tool off - this calls the base class disable, and then erases the polyline if it's around.
Reimplemented from casa::RegionTool.
virtual void casa::MultiPolylineTool::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
Reimplemented in casa::MultiPolylineToolImpl.
Definition at line 145 of file MultiPolylineTool.h.
virtual void casa::MultiPolylineTool::doubleOutside | ( | ) | [inline, protected, virtual] |
Definition at line 146 of file MultiPolylineTool.h.
virtual void casa::MultiPolylineTool::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::RegionTool.
virtual void casa::MultiPolylineTool::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::MultiPolylineTool::get | ( | Int & | x, |
Int & | y, | ||
const Int | pt | ||
) | const [protected, virtual] |
viewer::RegionSource* casa::MultiPolylineTool::getRegionSource | ( | ) | [inline] |
Definition at line 105 of file MultiPolylineTool.h.
References rfactory.
Bool casa::MultiPolylineTool::inHandle | ( | const Int & | pt, |
const Int & | x, | ||
const Int & | y | ||
) | const [private] |
are we within the specified handle?
Bool casa::MultiPolylineTool::inPolyline | ( | const Int & | x, |
const Int & | y | ||
) | const [private] |
are we inside the polyline?
virtual void casa::MultiPolylineTool::keyPressed | ( | const WCPositionEvent & | ) | [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::RegionTool.
virtual void casa::MultiPolylineTool::keyReleased | ( | const WCPositionEvent & | ) | [protected, virtual] |
Reimplemented from casa::RegionTool.
virtual void casa::MultiPolylineTool::moved | ( | const WCMotionEvent & | , |
const viewer::region::region_list_type & | |||
) | [protected, virtual] |
Reimplemented from casa::RegionTool.
virtual void casa::MultiPolylineTool::otherKeyPressed | ( | const WCPositionEvent & | ) | [protected, virtual] |
Reimplemented from casa::RegionTool.
virtual Bool casa::MultiPolylineTool::polylineDefined | ( | ) | [inline, virtual] |
Is a polyline currently defined?
Definition at line 103 of file MultiPolylineTool.h.
virtual void casa::MultiPolylineTool::polylineReady | ( | ) | [inline, protected, virtual] |
Function called when a polyline is ready and not being edited.
(Unused so far on the glish level (12/01)).
Reimplemented in casa::QtPolylineToolRegion.
Definition at line 151 of file MultiPolylineTool.h.
void casa::MultiPolylineTool::popPoint | ( | ) | [private] |
void casa::MultiPolylineTool::pushPoint | ( | Int | x1, |
Int | y1 | ||
) | [private] |
push/pop last vertex
const std::set<viewer::region::RegionTypes>& casa::MultiPolylineTool::regionsCreated | ( | ) | const [virtual] |
returns a set which indicates regions this creator creates...
Implements casa::viewer::RegionCreator.
virtual void casa::MultiPolylineTool::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.
void casa::MultiPolylineTool::revokeRegion | ( | viewer::Region * | ) | [virtual] |
called when the user (read GUI user) indicates that a region should be deleted...
Implements casa::RegionTool.
virtual void casa::MultiPolylineTool::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::MultiPolylineTool::set | ( | const Int | x, |
const Int | y, | ||
const Int | pt | ||
) | [private, virtual] |
replace a single vertex.
void casa::MultiPolylineTool::start_new_polyline | ( | WorldCanvas * | , |
int | x, | ||
int | y | ||
) | [private] |
RegionToolTypes casa::MultiPolylineTool::type | ( | ) | const [inline, virtual] |
Implements casa::RegionTool.
Definition at line 121 of file MultiPolylineTool.h.
References casa::RegionTool::POLYLINETOOL.
std::tr1::shared_ptr<viewer::Polyline> casa::MultiPolylineTool::building_polyline [private] |
Definition at line 235 of file MultiPolylineTool.h.
std::tr1::shared_ptr<viewer::Polyline> casa::MultiPolylineTool::creating_region [private] |
Definition at line 175 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsBaseMoveX [private] |
position that move started from
Definition at line 226 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsBaseMoveY [private] |
Definition at line 226 of file MultiPolylineTool.h.
Bool casa::MultiPolylineTool::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 206 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsHandleSize [private] |
size in pixels of the handles
Definition at line 220 of file MultiPolylineTool.h.
Definition at line 200 of file MultiPolylineTool.h.
Referenced by polylineDefined().
Int casa::MultiPolylineTool::itsNPoints [private] |
Number of points.
Definition at line 209 of file MultiPolylineTool.h.
should the polyline remain on screen after double clicks?
Definition at line 191 of file MultiPolylineTool.h.
vertex being moved
Definition at line 223 of file MultiPolylineTool.h.
Vector<Double> casa::MultiPolylineTool::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 214 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsX1 [private] |
pixel coordinates of the pan vector.
1 = anchor, 2 = new position.
Definition at line 216 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsX2 [private] |
Definition at line 216 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsX3 [private] |
Definition at line 216 of file MultiPolylineTool.h.
Vector<Double> casa::MultiPolylineTool::itsY [private] |
Definition at line 214 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsY1 [private] |
Definition at line 216 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsY2 [private] |
Definition at line 216 of file MultiPolylineTool.h.
Int casa::MultiPolylineTool::itsY3 [private] |
Definition at line 216 of file MultiPolylineTool.h.
double casa::MultiPolylineTool::moving_linx_ [private] |
Definition at line 232 of file MultiPolylineTool.h.
double casa::MultiPolylineTool::moving_liny_ [private] |
Definition at line 233 of file MultiPolylineTool.h.
Definition at line 231 of file MultiPolylineTool.h.
PanelDisplay* casa::MultiPolylineTool::pd_ [private] |
Reimplemented in casa::QtPolylineToolRegion.
Definition at line 238 of file MultiPolylineTool.h.
Definition at line 237 of file MultiPolylineTool.h.
std::tr1::shared_ptr<viewer::Polyline> casa::MultiPolylineTool::resizing_region [private] |
Definition at line 174 of file MultiPolylineTool.h.
int casa::MultiPolylineTool::resizing_region_handle [private] |
may not be needed...
Definition at line 229 of file MultiPolylineTool.h.
Definition at line 236 of file MultiPolylineTool.h.
Referenced by getRegionSource().