WCCrosshairTool.h

Classes

WCCrosshairTool -- Base class for WorldCanvas event-based crosshair tools. (full description)

class WCCrosshairTool : public WCTool, public DTVisible

Types

enum AdjustMode

Off
Move

Interface

Public Members
WCCrosshairTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = True)
virtual ~WCCrosshairTool()
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 crosshairReady()
virtual void crosshairNotReady()
virtual void get(Int &x1, Int &y1) const
Private Members
virtual void set(const Int &x1, const Int &y1)
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

    WCCrosshairTool stands for WorldCanvas Crosshair Tool.

    Synopsis

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

    The crosshair is drawn by simply clicking at the location the crosshair should be placed. Once constructed, the crosshair can be relocated by dragging inside the crosshair. The crosshair is removed from the display when the Esc key is pressed.

    Example

    Motivation

    Many activities on the WorldCanvas will be based on the user placing a crosshair, and then proceeding to some action with that crosshair. A nice example is emitting positions to be caught by some external controlling process.

    To Do

    Member Description

    WCCrosshairTool(WorldCanvas *wcanvas, Display::KeySym keysym = Display::K_Pointer_Button1, const Bool persistent = True)

    Constructor requires a WorldCanvas to operate on, and optional specifications of the key to respond to, and whether the crosshair should be persistent. A persistent crosshair will "stick around" after a double click action.

    virtual ~WCCrosshairTool()

    Destructor.

    virtual void disable()

    Switch the tool off: this calls the base class disable, and then erases the crosshair if necessary.

    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 crosshair. 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 crosshair event handling: called when there is a double click inside or outside the crosshair.

    virtual void crosshairReady()
    virtual void crosshairNotReady()

    Functions called when the crosshair is ready and not being editted, and when this status changes.

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

    Retrieve the crosshair position.

    enum AdjustMode

    adjustment mode

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

    set/get only the anchor point

    virtual void preserve()
    virtual void restore()

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

    preserve/restore the world coordinates

    virtual void draw(const Bool drawHandles = False)

    draw the crosshair on the WorldCanvas' PixelCanvas.

    virtual void reset()

    reset this drawer