WCRectTool.h

Classes

WCRectTool -- Base class for WorldCanvas event-based rectangle tools (full description)

class WCRectTool : public WCTool, public DTVisible

Types

enum AdjustMode

Off
Move

Interface

Public Members
WCRectTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)
virtual ~WCRectTool()
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 rectangleReady()
virtual void rectangleNotReady()
virtual void get(Int &x1, Int &y1, Int &x2, Int &y2) const
Private Members
virtual void set(const Int &x1, const Int &y1, const Int &x2, const Int &y2)
virtual void set(const Int &x1, const Int &y1)
virtual void get(Int &x1, Int &y1) const
virtual void preserve()
virtual void restore()
virtual void draw(const Bool drawHandles = False)
virtual void reset()

Description

Review Status

Date Reviewed:
yyyy/mm/dd

  • WCTool

    Etymology

    WCRectTool stands for WorldCanvas Rectangle Tool

    Synopsis

    This class adds to its base WCTool to provide a tool for drawing, resizing and moving rectangles on a WorldCanvas. While WCRectTool is not abstract, it performs no useful function. The programmer should derive from this class, and implement the functions doubleInside and doubleOutside, which are called when the user double-clicks the key or mouse button inside or outside an existing rectangle respectively. It is up to the programmer to decide what double clicks inside and outside the rectangle correspond to, although it is recommended that a double click inside correspond to the main action of the tool, and a double click outside correspond to a secondary action of the tool, if indeed a secondary action exists.

    The rectangle is drawn by dragging the mouse from one corner to the diagonally opposite corner. Once constructed, the rectangle can be resized by dragging its corners, or relocated by dragging inside the rectangle. The rectangle 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 rectangle, and then proceeding to some action with that rectangle. A nice example is zooming.

    To Do

    Member Description

    WCRectTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = False)

    Constructor

    virtual ~WCRectTool()

    Destructor

    virtual void disable()

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

    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)

    Functions called by the local event handling operators - these handle the drawing of the rectangle. In special conditions, namely double clicking the key, they will pass control on to the doubleInside and doubleOutside functions

    virtual void doubleInside()
    virtual void doubleOutside()

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

    virtual void rectangleReady()
    virtual void rectangleNotReady()

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

    virtual void get(Int &x1, Int &y1, Int &x2, Int &y2) const

    Retrieve the rectangle corners

    enum AdjustMode

    adjustment mode

    virtual void set(const Int &x1, const Int &y1, const Int &x2, const Int &y2)

    set the coordinates of the rectangle

    virtual void set(const Int &x1, const Int &y1)
    virtual void get(Int &x1, Int &y1) const

    set/get only the anchor point

    virtual void preserve()
    virtual void restore()

    preserve/restore the world coordinates

    virtual void draw(const Bool drawHandles = False)

    draw the rubberband box on a PixelCanvas

    virtual void reset()

    reset this drawer