casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Types | Private Member Functions | Private Attributes
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

List of all members.

Public Member Functions

 WCPolyTool (WorldCanvas *wcanvas, Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False)
 Constructor.
virtual ~WCPolyTool ()
 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 keyPressed (const WCPositionEvent &ev)
 Functions called by the local event handling operators - these handle the drawing of the polygon.
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.
virtual void doubleOutside ()
virtual void polygonReady ()
 Functions called when a polygon is ready and not being editted, and when this status changes.
virtual void polygonNotReady ()
virtual void get (Vector< Int > &x, Vector< Int > &y)
 Retrive the polygon vertices.

Private Types

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

Private Member Functions

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

Private Attributes

Bool itsPolygonPersistent
 do the polygons persist after double clicks?
Bool itsOnScreen
 is the polygon on screen?
Bool itsActive
 are we actively drawing?
Bool itsMoved
 have we moved?
Bool itsPolygonExists
 do we have a polygon yet?
WCPolyTool::AdjustMode itsAdjustMode
uInt itsNPoints
 Number of points.
Vector< IntitsX
 Polygon points ...
Vector< IntitsY
Vector< DoubleitsStoredWorldX
 ...
Vector< DoubleitsStoredWorldY
uInt itsHandleSize
 size in pixels of the handles
uInt itsSelectedHandle
 which handle to modify?
Int itsBaseMoveX
 position that move started from
Int itsBaseMoveY
Int itsLastPressX
 position of last press event
Int itsLastPressY
Int its2ndLastPressX
Int its2ndLastPressY
Int itsLastReleaseX
 position of last release event
Int itsLastReleaseY
Double itsLastPressTime
 store the times of the last two presses here:
Double its2ndLastPressTime

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

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 ( ) [inline, virtual]

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 ( ) [inline, virtual]

Definition at line 121 of file WCPolyTool.h.

void casa::WCPolyTool::draw ( Bool  drawHandles = False) [private]

draw the polygon on a PixelCanvas

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

Retrive the polygon vertices.

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

are we within the specified handle?

Bool casa::WCPolyTool::inPolygon ( const uInt x,
const 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 ( ) [inline, virtual]

Definition at line 128 of file WCPolyTool.h.

virtual void casa::WCPolyTool::polygonReady ( ) [inline, virtual]

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 ( uInt  x1,
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

Definition at line 209 of file WCPolyTool.h.

Definition at line 203 of file WCPolyTool.h.

Definition at line 203 of file WCPolyTool.h.

are we actively drawing?

Definition at line 143 of file WCPolyTool.h.

Definition at line 157 of file WCPolyTool.h.

position that move started from

Definition at line 199 of file WCPolyTool.h.

Definition at line 199 of file WCPolyTool.h.

size in pixels of the handles

Definition at line 187 of file WCPolyTool.h.

store the times of the last two presses here:

Definition at line 209 of file WCPolyTool.h.

position of last press event

Definition at line 202 of file WCPolyTool.h.

Definition at line 202 of file WCPolyTool.h.

position of last release event

Definition at line 206 of file WCPolyTool.h.

Definition at line 206 of file WCPolyTool.h.

have we moved?

Definition at line 146 of file WCPolyTool.h.

Number of points.

Definition at line 160 of file WCPolyTool.h.

is the polygon on screen?

Definition at line 140 of file WCPolyTool.h.

do we have a polygon yet?

Definition at line 149 of file WCPolyTool.h.

do the polygons persist after double clicks?

Definition at line 137 of file WCPolyTool.h.

which handle to modify?

Definition at line 193 of file WCPolyTool.h.

...

world

Definition at line 166 of file WCPolyTool.h.

Definition at line 166 of file WCPolyTool.h.

Polygon points ...

pixels

Definition at line 164 of file WCPolyTool.h.

Definition at line 164 of file WCPolyTool.h.


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