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::WCCrosshairTool Class Reference

Base class for WorldCanvas event-based crosshair tools. More...

#include <WCCrosshairTool.h>

Inheritance diagram for casa::WCCrosshairTool:
casa::WCTool casa::DTVisible casa::DisplayTool

List of all members.

Public Member Functions

 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.
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 &)
 Functions called by the local event handling operators - these handle the drawing of the crosshair.
virtual void keyReleased (const WCPositionEvent &)
virtual void otherKeyPressed (const WCPositionEvent &)
virtual void moved (const WCMotionEvent &, const viewer::region::region_list_type &)
virtual void refresh (const WCRefreshEvent &)
virtual void doubleInside ()
 Functions special to the crosshair event handling: called when there is a double click inside or outside the crosshair.
virtual void doubleOutside ()
virtual void crosshairReady ()
 Functions called when the crosshair is ready and not being editted, and when this status changes.
virtual void crosshairNotReady ()
virtual void get (Int &x1, Int &y1) const
 Retrieve the crosshair position.

Private Types

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

Private Member Functions

virtual void set (const Int &x1, const Int &y1)
 set the coordinates of the crosshair
virtual void preserve ()
 set/get only the anchor point
virtual void restore ()
virtual void draw (const Bool drawHandles=False)
 draw the crosshair on the WorldCanvas' PixelCanvas.
virtual void reset ()
 reset this drawer

Private Attributes

Bool itsCrosshairPersistent
 does the crosshair persist after double clicks?
Int itsCrosshairRadius
 what radius is the crosshair? in pixels
Bool itsOnScreen
 is the crosshair on screen?
Bool itsActive
 is some activity taking place with the crosshair?
Bool itsMoved
 has the crosshair been moved?
Bool itsCrosshairExists
 do we have a crosshair drawn yet?
WCCrosshairTool::AdjustMode itsAdjustMode
Int itsX1
 coordinates of the crosshair: pixel and world
Int itsY1
Vector< DoubleitsStoredWorldPosition
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 crosshair tools.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

<prerequisites> WCTool </prerequisites>

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.

Definition at line 88 of file WCCrosshairTool.h.


Member Enumeration Documentation

adjustment mode

Enumerator:
Off 
Move 

Definition at line 157 of file WCCrosshairTool.h.


Constructor & Destructor Documentation

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.

Destructor.


Member Function Documentation

virtual void casa::WCCrosshairTool::crosshairNotReady ( ) [inline, virtual]

Definition at line 130 of file WCCrosshairTool.h.

virtual void casa::WCCrosshairTool::crosshairReady ( ) [inline, virtual]

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

Definition at line 129 of file WCCrosshairTool.h.

virtual void casa::WCCrosshairTool::disable ( ) [virtual]

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

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::doubleInside ( ) [inline, virtual]

Functions special to the crosshair event handling: called when there is a double click inside or outside the crosshair.

Definition at line 122 of file WCCrosshairTool.h.

virtual void casa::WCCrosshairTool::doubleOutside ( ) [inline, virtual]

Definition at line 123 of file WCCrosshairTool.h.

virtual void casa::WCCrosshairTool::draw ( const Bool  drawHandles = False) [private, virtual]

draw the crosshair on the WorldCanvas' PixelCanvas.

virtual void casa::WCCrosshairTool::get ( Int x1,
Int y1 
) const [virtual]

Retrieve the crosshair position.

virtual void casa::WCCrosshairTool::keyPressed ( const WCPositionEvent ) [virtual]

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.

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::keyReleased ( const WCPositionEvent ) [virtual]

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::moved ( const WCMotionEvent ,
const viewer::region::region_list_type  
) [virtual]

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::otherKeyPressed ( const WCPositionEvent ) [virtual]

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::preserve ( ) [private, virtual]

set/get only the anchor point

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

preserve/restore the world coordinates

virtual void casa::WCCrosshairTool::refresh ( const WCRefreshEvent ) [virtual]

Reimplemented from casa::WCTool.

virtual void casa::WCCrosshairTool::reset ( ) [private, virtual]

reset this drawer

virtual void casa::WCCrosshairTool::restore ( ) [private, virtual]
virtual void casa::WCCrosshairTool::set ( const Int x1,
const Int y1 
) [private, virtual]

set the coordinates of the crosshair


Member Data Documentation

Definition at line 203 of file WCCrosshairTool.h.

Definition at line 197 of file WCCrosshairTool.h.

Definition at line 197 of file WCCrosshairTool.h.

is some activity taking place with the crosshair?

Definition at line 148 of file WCCrosshairTool.h.

Definition at line 161 of file WCCrosshairTool.h.

position that move started from

Definition at line 193 of file WCCrosshairTool.h.

Definition at line 193 of file WCCrosshairTool.h.

do we have a crosshair drawn yet?

Definition at line 154 of file WCCrosshairTool.h.

does the crosshair persist after double clicks?

Definition at line 139 of file WCCrosshairTool.h.

what radius is the crosshair? in pixels

Definition at line 142 of file WCCrosshairTool.h.

store the times of the last two presses here:

Definition at line 203 of file WCCrosshairTool.h.

position of last press event

Definition at line 196 of file WCCrosshairTool.h.

Definition at line 196 of file WCCrosshairTool.h.

position of last release event

Definition at line 200 of file WCCrosshairTool.h.

Definition at line 200 of file WCCrosshairTool.h.

has the crosshair been moved?

Definition at line 151 of file WCCrosshairTool.h.

is the crosshair on screen?

Definition at line 145 of file WCCrosshairTool.h.

Definition at line 166 of file WCCrosshairTool.h.

coordinates of the crosshair: pixel and world

Definition at line 165 of file WCCrosshairTool.h.

Definition at line 165 of file WCCrosshairTool.h.


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