casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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

Public Member Functions

 MultiPolyTool (viewer::RegionSourceFactory *rsf, PanelDisplay *pd, Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false)
 Constructor. More...
 
virtual ~MultiPolyTool ()
 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 reset (casacore::Bool skipRefresh=false)
 reset to non-existent, non-active polygon. More...
 
virtual casacore::Bool polygonDefined ()
 Is a polygon currently defined? More...
 
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.... More...
 
void revokeRegion (viewer::Region *)
 called when the user (read GUI user) indicates that a region should be deleted... More...
 
const std::set
< viewer::region::RegionTypes > & 
regionsCreated () const
 returns a set which indicates regions this creator creates... More...
 
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. More...
 
RegionToolTypes type () const
 
- Public Member Functions inherited from casa::RegionTool
 RegionTool (Display::KeySym keysym=Display::K_Pointer_Button1)
 Constructor taking the primary key to which this tool will respond. More...
 
 ~RegionTool ()
 
void otherKeyReleased (const WCPositionEvent &)
 
void enable ()
 DISPLAY_PURE_VIRTUAL(RegionTool::create,true);. 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 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...
 
- Public Member Functions inherited from casa::viewer::RegionCreator
 RegionCreator ()
 DISPLAY_PURE_VIRTUAL(RegionCreator::create,true);. More...
 
virtual ~RegionCreator ()
 

Protected Member Functions

virtual void keyPressed (const WCPositionEvent &)
 Functions called by the base class event handling operators–and normally only those. More...
 
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. More...
 
virtual void doubleInside ()
 Output callback functions–to be overridden in derived class as needed. More...
 
virtual void doubleOutside ()
 
virtual void polygonReady ()
 casacore::Function called when a polygon is ready and not being edited. More...
 
virtual void get (casacore::Vector< casacore::Int > &x, casacore::Vector< casacore::Int > &y) const
 Retrieve polygon vertices, or a single vertex, in screen pixels. More...
 
virtual void get (casacore::Int &x, casacore::Int &y, const casacore::Int pt) const
 
virtual bool checkType (viewer::region::RegionTypes t)
 
- Protected Member Functions inherited from casa::MultiWCTool
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...
 
DisplayTooloperator= (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...
 
DTVisibleoperator= (const DTVisible &other)
 (Required) copy assignment. More...
 

Private Types

enum  AdjustMode {
  Off,
  Def,
  Ready,
  Move,
  Resize
}
 state of the polyline tool More...
 
typedef std::list
< std::shared_ptr
< viewer::Polygon > > 
polygonlist
 

Private Member Functions

void start_new_polygon (WorldCanvas *, int x, int y)
 
virtual void set (const casacore::Vector< casacore::Int > &x, const casacore::Vector< casacore::Int > &y)
 Set the polygon 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 inPolygon (const casacore::Int &x, const casacore::Int &y) const
 are we inside the polygon? 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

std::shared_ptr< viewer::Polygonresizing_region
 
std::shared_ptr< viewer::Polygoncreating_region
 
casacore::Bool itsPolygonPersistent
 should the polygon remain on screen after double clicks? More...
 
MultiPolyTool::AdjustMode itsMode
 
casacore::Bool itsEmitted
 set true on double-click, if the polygon is persistent. More...
 
casacore::Int itsNPoints
 Number of points. More...
 
casacore::Vector
< casacore::Double
itsX
 Polygon 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
 
int resizing_region_handle
 may not be needed... More...
 
polygonlist moving_regions
 
double moving_linx_
 
double moving_liny_
 
std::shared_ptr< viewer::Polygonbuilding_polygon
 
viewer::RegionSourcerfactory
 
polygonlist polygons
 
PanelDisplaypd_
 

Additional Inherited Members

- Public Types inherited from casa::RegionTool
enum  RegionToolTypes {
  POLYTOOL,
  RECTTOOL,
  POINTTOOL,
  ELLIPSETOOL,
  POLYLINETOOL,
  PVLINETOOL
}
 
typedef std::map
< viewer::Region
*, viewer::region::PointInfo
region_map_type
 
- Public Types inherited from casa::viewer::RegionCreator
typedef std::list
< RegionCreator * > 
creator_list_type
 
- Static Public Member Functions inherited from casa::viewer::RegionCreator
static const creator_list_typefindCreator (region::RegionTypes type)
 
- Protected Attributes inherited from casa::MultiWCTool
WorldCanvasitsCurrentWC
 WC being (or to be) drawn on (may be 0 initially). More...
 

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::shared_ptr<viewer::Polygon> > casa::MultiPolyTool::polygonlist
private

Definition at line 179 of file MultiPolyTool.h.

Member Enumeration Documentation

state of the polyline tool

Enumerator
Off 
Def 
Ready 
Move 
Resize 

Definition at line 210 of file MultiPolyTool.h.

Constructor & Destructor Documentation

casa::MultiPolyTool::MultiPolyTool ( viewer::RegionSourceFactory rsf,
PanelDisplay pd,
Display::KeySym  keysym = Display::K_Pointer_Button1,
const casacore::Bool  persistent = false 
)

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)
inlineprotectedvirtual

Definition at line 174 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 ( )
inlineprotectedvirtual

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

virtual void casa::MultiPolyTool::doubleOutside ( )
inlineprotectedvirtual

Definition at line 159 of file MultiPolyTool.h.

virtual void casa::MultiPolyTool::draw ( const WCRefreshEvent ,
const viewer::region::region_list_type  
)
protectedvirtual

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 ( casacore::Vector< casacore::Int > &  x,
casacore::Vector< casacore::Int > &  y 
) const
protectedvirtual

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 ( casacore::Int x,
casacore::Int y,
const casacore::Int  pt 
) const
protectedvirtual
viewer::RegionSource* casa::MultiPolyTool::getRegionSource ( )
inline

Definition at line 114 of file MultiPolyTool.h.

References rfactory.

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

are we within the specified handle?

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

are we inside the polygon?

virtual void casa::MultiPolyTool::keyPressed ( const WCPositionEvent )
protectedvirtual

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 )
protectedvirtual

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::moved ( const WCMotionEvent ,
const viewer::region::region_list_type  
)
protectedvirtual

Reimplemented from casa::RegionTool.

virtual void casa::MultiPolyTool::otherKeyPressed ( const WCPositionEvent )
protectedvirtual

Reimplemented from casa::RegionTool.

virtual casacore::Bool casa::MultiPolyTool::polygonDefined ( )
inlinevirtual

Is a polygon currently defined?

Definition at line 110 of file MultiPolyTool.h.

References itsMode, and Ready.

virtual void casa::MultiPolyTool::polygonReady ( )
inlineprotectedvirtual

casacore::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 164 of file MultiPolyTool.h.

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

push/pop last vertex

const std::set<viewer::region::RegionTypes>& casa::MultiPolyTool::regionsCreated ( ) const
virtual

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

Implements casa::viewer::RegionCreator.

virtual void casa::MultiPolyTool::reset ( casacore::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.

void casa::MultiPolyTool::revokeRegion ( viewer::Region )
virtual

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

Implements casa::RegionTool.

virtual void casa::MultiPolyTool::set ( const casacore::Vector< casacore::Int > &  x,
const casacore::Vector< casacore::Int > &  y 
)
privatevirtual

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 casacore::Int  x,
const casacore::Int  y,
const casacore::Int  pt 
)
privatevirtual

replace a single vertex.

void casa::MultiPolyTool::start_new_polygon ( WorldCanvas ,
int  x,
int  y 
)
private
RegionToolTypes casa::MultiPolyTool::type ( ) const
inlinevirtual

Implements casa::RegionTool.

Definition at line 132 of file MultiPolyTool.h.

References casa::RegionTool::POLYTOOL.

Member Data Documentation

std::shared_ptr<viewer::Polygon> casa::MultiPolyTool::building_polygon
private

Definition at line 249 of file MultiPolyTool.h.

std::shared_ptr<viewer::Polygon> casa::MultiPolyTool::creating_region
private

Definition at line 191 of file MultiPolyTool.h.

casacore::Int casa::MultiPolyTool::itsBaseMoveX
private

position that move started from

Definition at line 240 of file MultiPolyTool.h.

casacore::Int casa::MultiPolyTool::itsBaseMoveY
private

Definition at line 240 of file MultiPolyTool.h.

casacore::Bool casa::MultiPolyTool::itsEmitted
private

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

casacore::Int casa::MultiPolyTool::itsHandleSize
private

size in pixels of the handles

Definition at line 234 of file MultiPolyTool.h.

MultiPolyTool::AdjustMode casa::MultiPolyTool::itsMode
private

Definition at line 217 of file MultiPolyTool.h.

Referenced by polygonDefined().

casacore::Int casa::MultiPolyTool::itsNPoints
private

Number of points.

Definition at line 226 of file MultiPolyTool.h.

casacore::Bool casa::MultiPolyTool::itsPolygonPersistent
private

should the polygon remain on screen after double clicks?

Definition at line 207 of file MultiPolyTool.h.

casacore::Int casa::MultiPolyTool::itsSelectedHandle
private

vertex being moved

Definition at line 237 of file MultiPolyTool.h.

casacore::Vector<casacore::Double> casa::MultiPolyTool::itsX
private

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

casacore::Vector<casacore::Double> casa::MultiPolyTool::itsY
private

Definition at line 231 of file MultiPolyTool.h.

double casa::MultiPolyTool::moving_linx_
private

Definition at line 246 of file MultiPolyTool.h.

double casa::MultiPolyTool::moving_liny_
private

Definition at line 247 of file MultiPolyTool.h.

polygonlist casa::MultiPolyTool::moving_regions
private

Definition at line 245 of file MultiPolyTool.h.

PanelDisplay* casa::MultiPolyTool::pd_
private

Definition at line 252 of file MultiPolyTool.h.

polygonlist casa::MultiPolyTool::polygons
private

Definition at line 251 of file MultiPolyTool.h.

std::shared_ptr<viewer::Polygon> casa::MultiPolyTool::resizing_region
private

Definition at line 190 of file MultiPolyTool.h.

int casa::MultiPolyTool::resizing_region_handle
private

may not be needed...

Definition at line 243 of file MultiPolyTool.h.

viewer::RegionSource* casa::MultiPolyTool::rfactory
private

Definition at line 250 of file MultiPolyTool.h.

Referenced by getRegionSource().


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