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

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

#include <WCRectTool.h>

Inheritance diagram for casa::WCRectTool:
casa::WCTool casa::DTVisible casa::DisplayTool casa::WCRTRegion casa::WCRTZoomer

List of all members.

Public Member Functions

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

Private Types

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

Private Member Functions

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)
 set/get only the anchor point
virtual void get (Int &x1, Int &y1) const
virtual void preserve ()
 preserve/restore the world coordinates
virtual void restore ()
virtual void draw (const Bool drawHandles=False)
 draw the rubberband box on a PixelCanvas
virtual void reset ()
 reset this drawer

Private Attributes

Bool itsRectanglePersistent
 do the rectangles persist after double clicks?
Bool itsOnScreen
 is the rectangle on screen?
Bool itsActive
 are we actively zooming?
Bool itsMoved
 have we moved?
Bool itsRectangleExists
 do we have a rectangle drawn yet?
WCRectTool::AdjustMode itsAdjustMode
Int itsX1
 coordinates of the rectangle: pixel and world
Int itsY1
Int itsX2
Int itsY2
Vector< DoubleitsStoredWorldBlc
Vector< DoubleitsStoredWorldTrc
Vector< IntitsHX
 storage of the handle coordinates
Vector< IntitsHY
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 rectangle tools.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

<prerequisites> WCTool </prerequisites>

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

Definition at line 88 of file WCRectTool.h.


Member Enumeration Documentation

adjustment mode

Enumerator:
Off 
Move 

Definition at line 152 of file WCRectTool.h.


Constructor & Destructor Documentation

Constructor.

virtual casa::WCRectTool::~WCRectTool ( ) [virtual]

Destructor.


Member Function Documentation

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

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

Reimplemented from casa::WCTool.

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

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

Reimplemented in casa::WCRTRegion, and casa::WCRTZoomer.

Definition at line 120 of file WCRectTool.h.

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

Reimplemented in casa::WCRTZoomer.

Definition at line 121 of file WCRectTool.h.

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

draw the rubberband box on a PixelCanvas

virtual void casa::WCRectTool::get ( Int x1,
Int y1,
Int x2,
Int y2 
) const [virtual]

Retrieve the rectangle corners.

virtual void casa::WCRectTool::get ( Int x1,
Int y1 
) const [private, virtual]
virtual void casa::WCRectTool::keyPressed ( const WCPositionEvent ev) [virtual]

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

Reimplemented from casa::WCTool.

virtual void casa::WCRectTool::keyReleased ( const WCPositionEvent ev) [virtual]

Reimplemented from casa::WCTool.

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

Reimplemented from casa::WCTool.

virtual void casa::WCRectTool::otherKeyPressed ( const WCPositionEvent ev) [virtual]

Reimplemented from casa::WCTool.

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

preserve/restore the world coordinates

virtual void casa::WCRectTool::rectangleNotReady ( ) [inline, virtual]

Definition at line 128 of file WCRectTool.h.

virtual void casa::WCRectTool::rectangleReady ( ) [inline, virtual]

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

Definition at line 127 of file WCRectTool.h.

virtual void casa::WCRectTool::refresh ( const WCRefreshEvent ev) [virtual]

Reimplemented from casa::WCTool.

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

reset this drawer

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

set the coordinates of the rectangle

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

set/get only the anchor point


Member Data Documentation

Definition at line 201 of file WCRectTool.h.

Definition at line 195 of file WCRectTool.h.

Definition at line 195 of file WCRectTool.h.

are we actively zooming?

Definition at line 143 of file WCRectTool.h.

Definition at line 156 of file WCRectTool.h.

position that move started from

Definition at line 191 of file WCRectTool.h.

Definition at line 191 of file WCRectTool.h.

storage of the handle coordinates

Definition at line 188 of file WCRectTool.h.

Definition at line 188 of file WCRectTool.h.

store the times of the last two presses here:

Definition at line 201 of file WCRectTool.h.

position of last press event

Definition at line 194 of file WCRectTool.h.

Definition at line 194 of file WCRectTool.h.

position of last release event

Definition at line 198 of file WCRectTool.h.

Definition at line 198 of file WCRectTool.h.

have we moved?

Definition at line 146 of file WCRectTool.h.

is the rectangle on screen?

Definition at line 140 of file WCRectTool.h.

do we have a rectangle drawn yet?

Definition at line 149 of file WCRectTool.h.

do the rectangles persist after double clicks?

Definition at line 137 of file WCRectTool.h.

Definition at line 161 of file WCRectTool.h.

Definition at line 161 of file WCRectTool.h.

coordinates of the rectangle: pixel and world

Definition at line 160 of file WCRectTool.h.

Definition at line 160 of file WCRectTool.h.

Definition at line 160 of file WCRectTool.h.

Definition at line 160 of file WCRectTool.h.


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