casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
casa::WCPolyTool Class Reference

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

#include <WCPolyTool.h>

Inheritance diagram for casa::WCPolyTool:
casa::WCTool casa::DTVisible casa::DisplayTool casa::WCPTRegion

Public Member Functions

 WCPolyTool (WorldCanvas *wcanvas, Display::KeySym keysym=Display::K_Pointer_Button1, const casacore::Bool persistent=false)
 Constructor. More...
 
virtual ~WCPolyTool ()
 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 keyPressed (const WCPositionEvent &ev)
 Functions called by the local event handling operators - these handle the drawing of the polygon. More...
 
virtual void keyReleased (const WCPositionEvent &ev)
 
virtual void otherKeyPressed (const WCPositionEvent &ev)
 
virtual void moved (const WCMotionEvent &ev, const viewer::region::region_list_type &)
 
virtual void refresh (const WCRefreshEvent &ev)
 
virtual void doubleInside ()
 Functions special to the polygon event handling - called when there is a double click inside/outside the polygon. More...
 
virtual void doubleOutside ()
 
virtual void polygonReady ()
 Functions called when a polygon is ready and not being editted, and when this status changes. More...
 
virtual void polygonNotReady ()
 
virtual void get (casacore::Vector< casacore::Int > &x, casacore::Vector< casacore::Int > &y)
 Retrive the polygon vertices. More...
 
- Public Member Functions inherited from casa::WCTool
 WCTool (WorldCanvas *wcanvas, const Display::KeySym &keysym=Display::K_Pointer_Button1)
 Constructor taking a pointer to a WorldCanvas to which this tool will attach, and a primary key to respond to. More...
 
virtual ~WCTool ()
 Destructor. More...
 
virtual void enable ()
 Switch the tool on/off - this simply registers or unregisters the event handlers. More...
 
virtual void operator() (const WCPositionEvent &ev)
 Required operators for event handling - these are called when an events occur, and distribute the events to the "user-level" methods. More...
 
virtual void operator() (const WCMotionEvent &ev)
 
virtual void operator() (const WCRefreshEvent &ev)
 
virtual void otherKeyReleased (const WCPositionEvent &)
 
virtual WorldCanvasworldCanvas () const
 Get the WorldCanvas that this Tool is attached to. More...
 
virtual PixelCanvaspixelCanvas () const
 Get the PixelCanvas that this Tool is attached to via its WorldCanvas. 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::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...
 

Private Types

enum  AdjustMode {
  Off,
  Move,
  Handle
}
 adjustment mode More...
 

Private Member Functions

void pushPoint (casacore::uInt x1, casacore::uInt y1)
 Point operations. More...
 
void popPoint ()
 
void preserve ()
 preserve/restore the world coordinates More...
 
void restore ()
 
void draw (casacore::Bool drawHandles=false)
 draw the polygon on a PixelCanvas More...
 
void reset ()
 reset this drawer More...
 
casacore::Bool inHandle (const casacore::uInt &pt, const casacore::uInt &x, const casacore::uInt &y) const
 are we within the specified handle? More...
 
casacore::Bool inPolygon (const casacore::uInt &x, const casacore::uInt &y) const
 are we inside the polygon? More...
 

Private Attributes

casacore::Bool itsPolygonPersistent
 do the polygons persist after double clicks? More...
 
casacore::Bool itsOnScreen
 is the polygon on screen? More...
 
casacore::Bool itsActive
 are we actively drawing? More...
 
casacore::Bool itsMoved
 have we moved? More...
 
casacore::Bool itsPolygonExists
 do we have a polygon yet? More...
 
WCPolyTool::AdjustMode itsAdjustMode
 
casacore::uInt itsNPoints
 Number of points. More...
 
casacore::Vector< casacore::IntitsX
 
Polygon points

... More...

 
casacore::Vector< casacore::IntitsY
 
casacore::Vector
< casacore::Double
itsStoredWorldX
 ... More...
 
casacore::Vector
< casacore::Double
itsStoredWorldY
 
casacore::uInt itsHandleSize
 size in pixels of the handles More...
 
casacore::uInt itsSelectedHandle
 which handle to modify? More...
 
casacore::Int itsBaseMoveX
 position that move started from More...
 
casacore::Int itsBaseMoveY
 
casacore::Int itsLastPressX
 position of last press event More...
 
casacore::Int itsLastPressY
 
casacore::Int its2ndLastPressX
 
casacore::Int its2ndLastPressY
 
casacore::Int itsLastReleaseX
 position of last release event More...
 
casacore::Int itsLastReleaseY
 
casacore::Double itsLastPressTime
 store the times of the last two presses here: More...
 
casacore::Double its2ndLastPressTime
 

Additional Inherited Members

- Protected Member Functions inherited from casa::WCTool
 WCTool ()
 (Required) default constructor. More...
 
 WCTool (const WCTool &other)
 (Required) copy constructor. More...
 
WCTooloperator= (const WCTool &other)
 (Required) copy assignment. More...
 
- 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...
 

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

WCPolyTool stands for WorldCanvas Polygon Tool

Synopsis

This class adds to its base WCTool to provide a tool for drawing, reshaping and moving polygons on a WorldCanvas. While WCPolyTool 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 on the last or first vertices 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 88 of file WCPolyTool.h.

Member Enumeration Documentation

adjustment mode

Enumerator
Off 
Move 
Handle 

Definition at line 152 of file WCPolyTool.h.

Constructor & Destructor Documentation

casa::WCPolyTool::WCPolyTool ( WorldCanvas wcanvas,
Display::KeySym  keysym = Display::K_Pointer_Button1,
const casacore::Bool  persistent = false 
)

Constructor.

virtual casa::WCPolyTool::~WCPolyTool ( )
virtual

Destructor.

Member Function Documentation

virtual void casa::WCPolyTool::disable ( )
virtual

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

Reimplemented from casa::WCTool.

virtual void casa::WCPolyTool::doubleInside ( )
inlinevirtual

Functions special to the polygon event handling - called when there is a double click inside/outside the polygon.

Reimplemented in casa::WCPTRegion.

Definition at line 120 of file WCPolyTool.h.

virtual void casa::WCPolyTool::doubleOutside ( )
inlinevirtual

Definition at line 121 of file WCPolyTool.h.

void casa::WCPolyTool::draw ( casacore::Bool  drawHandles = false)
private

draw the polygon on a PixelCanvas

virtual void casa::WCPolyTool::get ( casacore::Vector< casacore::Int > &  x,
casacore::Vector< casacore::Int > &  y 
)
virtual

Retrive the polygon vertices.

casacore::Bool casa::WCPolyTool::inHandle ( const casacore::uInt pt,
const casacore::uInt x,
const casacore::uInt y 
) const
private

are we within the specified handle?

casacore::Bool casa::WCPolyTool::inPolygon ( const casacore::uInt x,
const casacore::uInt y 
) const
private

are we inside the polygon?

virtual void casa::WCPolyTool::keyPressed ( const WCPositionEvent ev)
virtual

Functions called by the local event handling operators - these handle the drawing of the polygon.

In special conditions, namely double clicking the key, they will pass control on to the doubleInside and doubleOutside functions

Reimplemented from casa::WCTool.

virtual void casa::WCPolyTool::keyReleased ( const WCPositionEvent ev)
virtual

Reimplemented from casa::WCTool.

virtual void casa::WCPolyTool::moved ( const WCMotionEvent ev,
const viewer::region::region_list_type  
)
virtual

Reimplemented from casa::WCTool.

virtual void casa::WCPolyTool::otherKeyPressed ( const WCPositionEvent ev)
virtual

Reimplemented from casa::WCTool.

virtual void casa::WCPolyTool::polygonNotReady ( )
inlinevirtual

Definition at line 128 of file WCPolyTool.h.

virtual void casa::WCPolyTool::polygonReady ( )
inlinevirtual

Functions called when a polygon is ready and not being editted, and when this status changes.

Definition at line 127 of file WCPolyTool.h.

void casa::WCPolyTool::popPoint ( )
private
void casa::WCPolyTool::preserve ( )
private

preserve/restore the world coordinates

void casa::WCPolyTool::pushPoint ( casacore::uInt  x1,
casacore::uInt  y1 
)
private

Point operations.

virtual void casa::WCPolyTool::refresh ( const WCRefreshEvent ev)
virtual

Reimplemented from casa::WCTool.

void casa::WCPolyTool::reset ( )
private

reset this drawer

void casa::WCPolyTool::restore ( )
private

Member Data Documentation

casacore::Double casa::WCPolyTool::its2ndLastPressTime
private

Definition at line 209 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::its2ndLastPressX
private

Definition at line 203 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::its2ndLastPressY
private

Definition at line 203 of file WCPolyTool.h.

casacore::Bool casa::WCPolyTool::itsActive
private

are we actively drawing?

Definition at line 143 of file WCPolyTool.h.

WCPolyTool::AdjustMode casa::WCPolyTool::itsAdjustMode
private

Definition at line 157 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsBaseMoveX
private

position that move started from

Definition at line 199 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsBaseMoveY
private

Definition at line 199 of file WCPolyTool.h.

casacore::uInt casa::WCPolyTool::itsHandleSize
private

size in pixels of the handles

Definition at line 187 of file WCPolyTool.h.

casacore::Double casa::WCPolyTool::itsLastPressTime
private

store the times of the last two presses here:

Definition at line 209 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsLastPressX
private

position of last press event

Definition at line 202 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsLastPressY
private

Definition at line 202 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsLastReleaseX
private

position of last release event

Definition at line 206 of file WCPolyTool.h.

casacore::Int casa::WCPolyTool::itsLastReleaseY
private

Definition at line 206 of file WCPolyTool.h.

casacore::Bool casa::WCPolyTool::itsMoved
private

have we moved?

Definition at line 146 of file WCPolyTool.h.

casacore::uInt casa::WCPolyTool::itsNPoints
private

Number of points.

Definition at line 160 of file WCPolyTool.h.

casacore::Bool casa::WCPolyTool::itsOnScreen
private

is the polygon on screen?

Definition at line 140 of file WCPolyTool.h.

casacore::Bool casa::WCPolyTool::itsPolygonExists
private

do we have a polygon yet?

Definition at line 149 of file WCPolyTool.h.

casacore::Bool casa::WCPolyTool::itsPolygonPersistent
private

do the polygons persist after double clicks?

Definition at line 137 of file WCPolyTool.h.

casacore::uInt casa::WCPolyTool::itsSelectedHandle
private

which handle to modify?

Definition at line 193 of file WCPolyTool.h.

casacore::Vector<casacore::Double> casa::WCPolyTool::itsStoredWorldX
private

...

world

Definition at line 166 of file WCPolyTool.h.

casacore::Vector<casacore::Double> casa::WCPolyTool::itsStoredWorldY
private

Definition at line 166 of file WCPolyTool.h.

casacore::Vector<casacore::Int> casa::WCPolyTool::itsX
private

Polygon points

...

pixels

Definition at line 164 of file WCPolyTool.h.

casacore::Vector<casacore::Int> casa::WCPolyTool::itsY
private

Definition at line 164 of file WCPolyTool.h.


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