casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
casa::MultiPolyTool Class Reference

Base class for WorldCanvas event-based polygon tools. More...

#include <MultiPolyTool.h>

Inheritance diagram for casa::MultiPolyTool:
casa::RegionTool casa::DTVisible casa::viewer::RegionCreator casa::MultiWCTool casa::DisplayTool casa::WCPositionEH casa::WCMotionEH casa::WCRefreshEH casa::DisplayEH casa::MultiPolyToolImpl casa::QtPTRegion casa::QtPolyTool

List of all members.

Public Member Functions

 MultiPolyTool (viewer::RegionSourceFactory *rsf, PanelDisplay *pd, Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False)
 Constructor.
virtual ~MultiPolyTool ()
 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 reset (Bool skipRefresh=False)
 reset to non-existent, non-active polygon.
virtual Bool polygonDefined ()
 Is a polygon currently defined?
viewer::RegionSourcegetRegionSource ()
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 polygon (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 polygonReady ()
 Function called when a polygon is ready and not being edited.
virtual void get (Vector< Int > &x, Vector< Int > &y) const
 Retrieve polygon 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::Polygon > > 
polygonlist

Private Member Functions

void start_new_polygon (WorldCanvas *, int x, int y)
virtual void set (const Vector< Int > &x, const Vector< Int > &y)
 Set the polygon 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 inPolygon (const Int &x, const Int &y) const
 are we inside the polygon?
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::Polygon
resizing_region
std::tr1::shared_ptr
< viewer::Polygon
creating_region
Bool itsPolygonPersistent
 should the polygon remain on screen after double clicks?
MultiPolyTool::AdjustMode itsMode
Bool itsEmitted
 set True on double-click, if the polygon is persistent.
Int itsNPoints
 Number of points.
Vector< DoubleitsX
 Polygon points (linear).
Vector< DoubleitsY
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...
polygonlist moving_regions
double moving_linx_
double moving_liny_
std::tr1::shared_ptr
< viewer::Polygon
building_polygon
viewer::RegionSourcerfactory
polygonlist polygons
PanelDisplaypd_

Detailed Description

Base class for WorldCanvas event-based polygon tools.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

<prerequisites> (see ())WCTool </prerequisites>

Etymology

MultiPolyTool stands for Multi-WorldCanvas Polygon Tool

Synopsis

This class adds to its base MWCTool to provide a tool for drawing, reshaping and moving polygons on a WorldCanvas. While MultiPolyTool 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 again on the last or first vertex 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.

Example

Motivation

Many activities on the WorldCanvas will be based on the user drawing a polygon and using the polygon in some operation.

To Do

Definition at line 89 of file MultiPolyTool.h.


Member Typedef Documentation

typedef std::list<std::tr1::shared_ptr<viewer::Polygon> > casa::MultiPolyTool::polygonlist [private]

Definition at line 171 of file MultiPolyTool.h.


Member Enumeration Documentation

state of the polyline tool

Enumerator:
Off 
Def 
Ready 
Move 
Resize 

Definition at line 202 of file MultiPolyTool.h.


Constructor & Destructor Documentation

Constructor.

virtual casa::MultiPolyTool::~MultiPolyTool ( ) [virtual]

Destructor.


Member Function Documentation

void casa::MultiPolyTool::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::MultiPolyTool::checkType ( viewer::region::RegionTypes  t) [inline, protected, virtual]

             

Definition at line 168 of file MultiPolyTool.h.

References casa::viewer::region::PolyRegion.

bool casa::MultiPolyTool::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::MultiPolyTool::disable ( ) [virtual]

Switch the tool off - this calls the base class disable, and then erases the polygon if it's around.

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::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 polygon

Reimplemented in casa::MultiPolyToolImpl.

Definition at line 152 of file MultiPolyTool.h.

virtual void casa::MultiPolyTool::doubleOutside ( ) [inline, protected, virtual]

Definition at line 153 of file MultiPolyTool.h.

virtual void casa::MultiPolyTool::draw ( const WCRefreshEvent ,
const viewer::region::region_list_type  
) [protected, virtual]

draw the polygon (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::MultiPolyTool::get ( Vector< Int > &  x,
Vector< Int > &  y 
) const [protected, virtual]

Retrieve polygon 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::MultiPolyTool::get ( Int x,
Int y,
const Int  pt 
) const [protected, virtual]

Definition at line 112 of file MultiPolyTool.h.

References rfactory.

Bool casa::MultiPolyTool::inHandle ( const Int pt,
const Int x,
const Int y 
) const [private]

are we within the specified handle?

Bool casa::MultiPolyTool::inPolygon ( const Int x,
const Int y 
) const [private]

are we inside the polygon?

virtual void casa::MultiPolyTool::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 polygon's appearance and action. When the polygon is ready and double-click is received, the doubleInside/Outside routine is invoked.

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::keyReleased ( const WCPositionEvent ) [protected, virtual]

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::moved ( const WCMotionEvent ,
const viewer::region::region_list_type  
) [protected, virtual]

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::otherKeyPressed ( const WCPositionEvent ) [protected, virtual]

Reimplemented from casa::RegionTool.

virtual Bool casa::MultiPolyTool::polygonDefined ( ) [inline, virtual]

Is a polygon currently defined?

Definition at line 110 of file MultiPolyTool.h.

References itsMode, and Ready.

virtual void casa::MultiPolyTool::polygonReady ( ) [inline, protected, virtual]

Function called when a polygon is ready and not being edited.

(Unused so far on the glish level (12/01)).

Reimplemented in casa::QtPTRegion.

Definition at line 158 of file MultiPolyTool.h.

void casa::MultiPolyTool::popPoint ( ) [private]
void casa::MultiPolyTool::pushPoint ( Int  x1,
Int  y1 
) [private]

push/pop last vertex

returns a set which indicates regions this creator creates...

Implements casa::viewer::RegionCreator.

virtual void casa::MultiPolyTool::reset ( Bool  skipRefresh = False) [virtual]

reset to non-existent, non-active polygon.

Refreshes if necessary to erase (unless skipRefresh==True). (Does not unregister from WCs or disable future event handling).

Reimplemented from casa::MultiWCTool.

called when the user (read GUI user) indicates that a region should be deleted...

Implements casa::RegionTool.

virtual void casa::MultiPolyTool::set ( const Vector< Int > &  x,
const Vector< Int > &  y 
) [private, virtual]

Set the polygon vertices.

itsNPoints should already be set, and x and y must contain (at least) this many points.

virtual void casa::MultiPolyTool::set ( const Int  x,
const Int  y,
const Int  pt 
) [private, virtual]

replace a single vertex.

void casa::MultiPolyTool::start_new_polygon ( WorldCanvas ,
int  x,
int  y 
) [private]
RegionToolTypes casa::MultiPolyTool::type ( ) const [inline, virtual]

Implements casa::RegionTool.

Definition at line 128 of file MultiPolyTool.h.

References casa::RegionTool::POLYTOOL.


Member Data Documentation

std::tr1::shared_ptr<viewer::Polygon> casa::MultiPolyTool::building_polygon [private]

Definition at line 240 of file MultiPolyTool.h.

std::tr1::shared_ptr<viewer::Polygon> casa::MultiPolyTool::creating_region [private]

Definition at line 183 of file MultiPolyTool.h.

position that move started from

Definition at line 231 of file MultiPolyTool.h.

Definition at line 231 of file MultiPolyTool.h.

set True on double-click, if the polygon is persistent.

set False when the polygon is moved, resized or reset. If True, a click outside the polygon will erase it and begin definition of a new one.

Definition at line 214 of file MultiPolyTool.h.

size in pixels of the handles

Definition at line 225 of file MultiPolyTool.h.

Definition at line 208 of file MultiPolyTool.h.

Referenced by polygonDefined().

Number of points.

Definition at line 217 of file MultiPolyTool.h.

should the polygon remain on screen after double clicks?

Definition at line 199 of file MultiPolyTool.h.

vertex being moved

Definition at line 228 of file MultiPolyTool.h.

Polygon 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 222 of file MultiPolyTool.h.

Definition at line 222 of file MultiPolyTool.h.

Definition at line 237 of file MultiPolyTool.h.

Definition at line 238 of file MultiPolyTool.h.

Definition at line 236 of file MultiPolyTool.h.

Reimplemented in casa::QtPTRegion.

Definition at line 243 of file MultiPolyTool.h.

Definition at line 242 of file MultiPolyTool.h.

std::tr1::shared_ptr<viewer::Polygon> casa::MultiPolyTool::resizing_region [private]

Definition at line 182 of file MultiPolyTool.h.

may not be needed...

Definition at line 234 of file MultiPolyTool.h.

Definition at line 241 of file MultiPolyTool.h.

Referenced by getRegionSource().


The documentation for this class was generated from the following file: