WCTool.h

Classes

WCToolPosEH -- WorldCanvas position event handler for WCTool. (full description)
WCToolMotEH -- WorldCanvas motion event handler for WCTool. (full description)
WCToolRefEH -- WorldCanvas refresh event handler for WCTool. (full description)
WCTool -- Base class for WorldCanvas event-based tools. (full description)

class WCToolPosEH : public WCPositionEH

Interface

Public Members
WCToolPosEH(WCTool *tool)
virtual ~WCToolPosEH()
virtual void operator()(const WCPositionEvent& ev)

Description

Synopsis

This class is a simple implementation of a WCPositionEH which passes WorldCanvas position events on to a single WCTool.

Member Description

WCToolPosEH(WCTool *tool)

virtual ~WCToolPosEH()

virtual void operator()(const WCPositionEvent& ev)


class WCToolMotEH : public WCMotionEH

Interface

WCToolMotEH(WCTool *tool)
virtual ~WCToolMotEH()
virtual void operator()(const WCMotionEvent& ev)

Description

Synopsis

This class is a simple implementation of a WCMotionEH which passes WorldCanvas motion events on to a single WCTool.

Member Description

WCToolMotEH(WCTool *tool)

virtual ~WCToolMotEH()

virtual void operator()(const WCMotionEvent& ev)


class WCToolRefEH : public WCRefreshEH

Interface

WCToolRefEH(WCTool *tool)
virtual ~WCToolRefEH()
virtual void operator()(const WCRefreshEvent& ev)

Description

Synopsis

This class is a simple implementation of a WCRefreshEH which passes WorldCanvas refresh events on to a single WCTool.

Member Description

WCToolRefEH(WCTool *tool)

virtual ~WCToolRefEH()

virtual void operator()(const WCRefreshEvent& ev)


class WCTool : public DisplayTool

Interface

WCTool(WorldCanvas *wcanvas, const Display::KeySym &keysym = Display::K_Pointer_Button1)
virtual ~WCTool()
virtual void enable()
virtual void disable()
virtual void operator()(const WCPositionEvent& ev)
virtual void operator()(const WCMotionEvent& ev)
virtual void operator()(const WCRefreshEvent& ev)
virtual void keyPressed(const WCPositionEvent &ev)
virtual void keyReleased(const WCPositionEvent &ev)
virtual void otherKeyPressed(const WCPositionEvent &ev)
virtual void otherKeyReleased(const WCPositionEvent &ev)
virtual void moved(const WCMotionEvent &ev)
virtual void refresh(const WCRefreshEvent &ev)
virtual WorldCanvas *worldCanvas() const
virtual PixelCanvas *pixelCanvas() const
Protected Members
WCTool()
WCTool(const WCTool &other)
WCTool &operator=(const WCTool &other)

Description

Review Status

Date Reviewed:
yyyy/mm/dd

  • WCPositionEH
  • WCMotionEH
  • WCRefreshEH

    Etymology

    WCTool stands for WorldCanvas Tool

    Synopsis

    This class is a base class upon which tools which respond to various events on a WorldCanvas can be built. It wraps up the position, motion and refresh events so that the programmer sees them all coming into one class, where they can be dealt with in a unified manner. WCTool is not actually abstract, so the programmer need only write handlers for the events in which they are interested.

    Example

    Motivation

    The majority of tools written for the WorldCanvas will fall into the category that this class serves: they respond to a single key or mouse button, and they potentially need to respond to position, motion and refresh events.

    To Do

    Member Description

    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.

    virtual ~WCTool()

    Destructor.

    virtual void enable()
    virtual void disable()

    Switch the tool on/off - this simply registers or unregisters the event handlers

    virtual void operator()(const WCPositionEvent& ev)
    virtual void operator()(const WCMotionEvent& ev)
    virtual void operator()(const WCRefreshEvent& ev)

    Required operators for event handling - these are called when an events occur, and distribute the events to the "user-level" methods

    virtual void keyPressed(const WCPositionEvent &ev)
    virtual void keyReleased(const WCPositionEvent &ev)
    virtual void otherKeyPressed(const WCPositionEvent &ev)
    virtual void otherKeyReleased(const WCPositionEvent &ev)
    virtual void moved(const WCMotionEvent &ev)
    virtual void refresh(const WCRefreshEvent &ev)

    Functions called by the local event handling operators - by default they do nothing, so a derived class needs only implement the events it cares about

    virtual WorldCanvas *worldCanvas() const

    Get the WorldCanvas that this Tool is attached to

    virtual PixelCanvas *pixelCanvas() const

    Get the PixelCanvas that this Tool is attached to via its WorldCanvas

    WCTool()

    (Required) default constructor.

    WCTool(const WCTool &other)

    (Required) copy constructor.

    WCTool &operator=(const WCTool &other)

    (Required) copy assignment.