WCPolyTool.h
Classes
- WCPolyTool -- Base class for WorldCanvas event-based polygon tools (full description)
Types
- Off
-
- Move
-
- Handle
-
Interface
- Public Members
- WCPolyTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)
- virtual ~WCPolyTool()
- virtual void disable()
- virtual void keyPressed(const WCPositionEvent &ev)
- virtual void keyReleased(const WCPositionEvent &ev)
- virtual void otherKeyPressed(const WCPositionEvent &ev)
- virtual void moved(const WCMotionEvent &ev)
- virtual void refresh(const WCRefreshEvent &ev)
- virtual void doubleInside()
- virtual void doubleOutside()
- virtual void polygonReady()
- virtual void polygonNotReady()
- virtual void get(Vector<Int> &x, Vector<Int> &y)
- Private Members
- void pushPoint(uInt x1, uInt y1)
- void popPoint()
- void preserve()
- void restore()
- void draw(Bool drawHandles = False)
- void reset()
- Bool inHandle(const uInt &pt, const uInt &x, const uInt &y) const
- Bool inPolygon(const uInt &x, const uInt &y) const
Review Status
- Date Reviewed:
- yyyy/mm/dd
WCTool
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
- Add time constraint to double click detection
Member Description
WCPolyTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)
Constructor
Destructor
virtual void disable()
Switch the tool off - this calls the base class disable,
and then erases the polygon if it's around
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
Functions special to the polygon event handling - called when
there is a double click inside/outside the polygon
Functions called when a polygon is ready and not being
editted, and when this status changes
virtual void get(Vector<Int> &x, Vector<Int> &y)
Retrive the polygon vertices
adjustment mode
Point operations
preserve/restore the world coordinates
void draw(Bool drawHandles = False)
draw the polygon on a PixelCanvas
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?