casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
casa::MultiRectTool Class Reference

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

#include <MultiRectTool.h>

Inheritance diagram for casa::MultiRectTool:
casa::RegionTool casa::DTVisible casa::viewer::RegionCreator casa::MultiWCTool casa::DisplayTool casa::WCPositionEH casa::WCMotionEH casa::WCRefreshEH casa::DisplayEH casa::MultiEllipseTool casa::MultiPointTool casa::MultiRectToolImpl casa::MultiEllipseToolImpl casa::MultiPointToolImpl casa::QtRTRegion casa::QtELRegion casa::QtPointRegion casa::QtRectTool casa::QtEllipseTool casa::QtCrossTool

List of all members.

Public Member Functions

 MultiRectTool (viewer::RegionSourceFactory *rsf, PanelDisplay *pd, Display::KeySym keysym=Display::K_Pointer_Button1, const Bool persistent=False)
 Constructor.
virtual ~MultiRectTool ()
 Destructor.
virtual void disable ()
 Switch the tool off - this erases the rectangle, if any, and calls the base class disable.
virtual void reset (Bool skipRefresh=False)
 reset to non-existent, non-active rectangle.
virtual Bool rectangleDefined ()
 Is a rectangle currently defined?
viewer::RegionSourcegetRegionSource ()
void checkPoint (WorldCanvas *wc, State &state)
 this is a non-const function because a non-const RegionTool ptr is returned in 'state' which can then be used for setting the state of the regions managed by the various tools....
void revokeRegion (viewer::Region *)
 called when the user (read GUI user) indicates that a region should be deleted...
const std::set
< viewer::region::RegionTypes > & 
regionsCreated () const
 returns a set which indicates regions this creator creates...
bool create (viewer::region::RegionTypes, WorldCanvas *, const std::vector< std::pair< double, double > > &, const std::string &, viewer::region::TextPosition, const std::vector< int > &, const std::string &, int, int, const std::string &, const std::string &, viewer::region::LineStyle, unsigned int, bool, VOID *)
 create regions of various types (e.g.
RegionToolTypes type () const

Protected Member Functions

virtual void keyPressed (const WCPositionEvent &ev)
 Functions called by the base class event handling operators--and normally only those.
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 draw (const WCRefreshEvent &, const viewer::region::region_list_type &)
 draw the rectangle (if any) on the object's currently active WC.
virtual void doubleInside ()
 Output callback functions--to be overridden in derived class.
virtual void doubleOutside ()
virtual void rectangleReady ()
 Called when a rectangle is ready and not being edited.
virtual void get (Int &x1, Int &y1, Int &x2, Int &y2) const
 Retrieve the rectangle coordinates, in screen pixels.
virtual bool checkType (viewer::region::RegionTypes t)
virtual std::tr1::shared_ptr
< viewer::Rectangle
allocate_region (WorldCanvas *wc, double x1, double y1, double x2, double y2, VOID *region_specific_state) const

Protected Attributes

viewer::RegionSourcerfactory

Private Types

typedef std::list
< std::tr1::shared_ptr
< viewer::Rectangle > > 
rectanglelist

Private Member Functions

void update_stats (const WCMotionEvent &ev)
void start_new_rectangle (WorldCanvas *, int x, int y)
virtual void set (const Int &x1, const Int &y1, const Int &x2, const Int &y2)
 set the pixel coordinates of the rectangle
virtual void get (Int &x1, Int &y1) const
 get only the anchor point

Private Attributes

Bool itsRectanglePersistent
 does the rectangle persist after double clicks (until a new one is started)?
Bool itsrectangleexists
 do we have a rectangle yet? (if True, itsCurrentWC, itsEmitted, P1, and P2 are valid)
Bool itsActive
 was the button pressed in the rectangle (or, if none, in an active WC) and not yet released/reset?
std::tr1::shared_ptr
< viewer::Rectangle
resizing_region
 itsActive is being replaced by resizing_region
std::tr1::shared_ptr
< viewer::Rectangle
creating_region
int resizing_region_handle
Bool itsMoving
 (valid only if itsActive==True): True = being moved False = being resized
rectanglelist moving_regions
 itsMoving is being replaced by moving_regions
double moving_linx_
double moving_liny_
Bool itsEmitted
 (valid only if itsrectangleexists==True) Has doubleInside/Outside been called for this rectangle? If so, a key press outside the rectangle will start a new rectangle, as if itsrectangleexists were False.
Vector< DoubleitsP1
 (Linear) coordinates of the rectangle (invariant over zooms, but not coordinate system changes.
Vector< DoubleitsP2
Vector< IntitsHX
 storage of the handle (pixel) coordinates
Vector< IntitsHY
Int itsBaseMoveX
 position that move started from
Int itsBaseMoveY
Double itsLastPressTime
 store the times of the last two presses here:
Double its2ndLastPressTime
rectanglelist rectangles
PanelDisplaypd_

Detailed Description

Base class for MultiWorldCanvas event-based rectangle tools.

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

<prerequisites> WCTool </prerequisites>

Etymology

MultiRectTool stands for MultiWorldCanvas Rectangle Tool

Synopsis

This class adds to its base WCTool to provide a tool for drawing, resizing and moving rectangles on a WorldCanvas. While MultiRectTool 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.

Definition at line 92 of file MultiRectTool.h.


Member Typedef Documentation

typedef std::list<std::tr1::shared_ptr<viewer::Rectangle> > casa::MultiRectTool::rectanglelist [private]

Definition at line 177 of file MultiRectTool.h.


Constructor & Destructor Documentation

Constructor.

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

Destructor.


Member Function Documentation

virtual std::tr1::shared_ptr<viewer::Rectangle> casa::MultiRectTool::allocate_region ( WorldCanvas wc,
double  x1,
double  y1,
double  x2,
double  y2,
VOID region_specific_state 
) const [protected, virtual]
void casa::MultiRectTool::checkPoint ( WorldCanvas wc,
State state 
) [virtual]

this is a non-const function because a non-const RegionTool ptr is returned in 'state' which can then be used for setting the state of the regions managed by the various tools....

Implements casa::RegionTool.

virtual bool casa::MultiRectTool::checkType ( viewer::region::RegionTypes  t) [inline, protected, virtual]

Reimplemented in casa::MultiEllipseTool, and casa::MultiPointTool.

Definition at line 170 of file MultiRectTool.h.

References casa::viewer::region::RectRegion.

bool casa::MultiRectTool::create ( viewer::region::RegionTypes  ,
WorldCanvas ,
const std::vector< std::pair< double, double > > &  ,
const std::string &  ,
viewer::region::TextPosition  ,
const std::vector< int > &  ,
const std::string &  ,
int  ,
int  ,
const std::string &  ,
const std::string &  ,
viewer::region::LineStyle  ,
unsigned  int,
bool  ,
VOID  
) [virtual]

create regions of various types (e.g.

point, rect, poly, etc.). For use when loading casa region files...

Implements casa::RegionTool.

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

Switch the tool off - this erases the rectangle, if any, and calls the base class disable.

Reimplemented from casa::RegionTool.

virtual void casa::MultiRectTool::doubleInside ( ) [inline, protected, virtual]

Output callback functions--to be overridden in derived class.

Called when there is a double click inside/outside the rectangle

Reimplemented in casa::MultiEllipseToolImpl, casa::MultiPointToolImpl, and casa::MultiRectToolImpl.

Definition at line 156 of file MultiRectTool.h.

virtual void casa::MultiRectTool::doubleOutside ( ) [inline, protected, virtual]

Definition at line 157 of file MultiRectTool.h.

virtual void casa::MultiRectTool::draw ( const WCRefreshEvent ,
const viewer::region::region_list_type  
) [protected, virtual]

draw the rectangle (if any) on the object's currently active WC.

Only to be called by the base class refresh event handler. Derived objects should use refresh() if they need to redraw, but even that is normally handled automatically.

Reimplemented from casa::RegionTool.

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

Retrieve the rectangle coordinates, in screen pixels.

Anchor (if applicable) is (x1,y1). Valid during the output callbacks; to be used by them, as well as internally.

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

get only the anchor point

Definition at line 116 of file MultiRectTool.h.

References rfactory.

virtual void casa::MultiRectTool::keyPressed ( const WCPositionEvent ev) [protected, virtual]

Functions called by the base class event handling operators--and normally only those.

This is the input that controls the rectangle's appearance and action. When the rectangle is ready and double-click is received, the doubleInside/Outside routine will be invoked.

Reimplemented from casa::RegionTool.

virtual void casa::MultiRectTool::keyReleased ( const WCPositionEvent ev) [protected, virtual]

Reimplemented from casa::RegionTool.

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

Reimplemented from casa::RegionTool.

virtual void casa::MultiRectTool::otherKeyPressed ( const WCPositionEvent ev) [protected, virtual]

Reimplemented from casa::RegionTool.

virtual Bool casa::MultiRectTool::rectangleDefined ( ) [inline, virtual]

Is a rectangle currently defined?

Definition at line 114 of file MultiRectTool.h.

References itsrectangleexists.

virtual void casa::MultiRectTool::rectangleReady ( ) [inline, protected, virtual]

Called when a rectangle is ready and not being edited.

(Unused so far on the glish level (12/01)).

Definition at line 162 of file MultiRectTool.h.

returns a set which indicates regions this creator creates...

Implements casa::viewer::RegionCreator.

Reimplemented in casa::MultiEllipseTool, and casa::MultiPointTool.

virtual void casa::MultiRectTool::reset ( Bool  skipRefresh = False) [virtual]

reset to non-existent, non-active rectangle.

Refreshes if necessary to erase (unless skipRefresh==True In that case, the caller should do the refresh itself). (Does not unregister from WCs or disable future event handling).

Reimplemented from casa::MultiWCTool.

called when the user (read GUI user) indicates that a region should be deleted...

Implements casa::RegionTool.

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

set the pixel coordinates of the rectangle

void casa::MultiRectTool::start_new_rectangle ( WorldCanvas ,
int  x,
int  y 
) [private]
RegionToolTypes casa::MultiRectTool::type ( ) const [inline, virtual]

Implements casa::RegionTool.

Reimplemented in casa::MultiEllipseTool, and casa::MultiPointTool.

Definition at line 132 of file MultiRectTool.h.

References casa::RegionTool::RECTTOOL.

void casa::MultiRectTool::update_stats ( const WCMotionEvent ev) [private]

Member Data Documentation

Definition at line 200 of file MultiRectTool.h.

Definition at line 232 of file MultiRectTool.h.

was the button pressed in the rectangle (or, if none, in an active WC) and not yet released/reset?

Definition at line 197 of file MultiRectTool.h.

position that move started from

Definition at line 229 of file MultiRectTool.h.

Definition at line 229 of file MultiRectTool.h.

(valid only if itsrectangleexists==True) Has doubleInside/Outside been called for this rectangle? If so, a key press outside the rectangle will start a new rectangle, as if itsrectangleexists were False.

However, a key press inside the rectangle will reset itsEmitted to False, allowing the rectangle to be reused (possibly moved or resized, and emitted again).

Definition at line 218 of file MultiRectTool.h.

storage of the handle (pixel) coordinates

Definition at line 226 of file MultiRectTool.h.

Definition at line 226 of file MultiRectTool.h.

store the times of the last two presses here:

Definition at line 232 of file MultiRectTool.h.

(valid only if itsActive==True): True = being moved False = being resized

Definition at line 205 of file MultiRectTool.h.

(Linear) coordinates of the rectangle (invariant over zooms, but not coordinate system changes.

To do: support the WorldCoordinateChange refresh reason, and reset this tool when it occurs).

Definition at line 223 of file MultiRectTool.h.

Definition at line 223 of file MultiRectTool.h.

do we have a rectangle yet? (if True, itsCurrentWC, itsEmitted, P1, and P2 are valid)

Definition at line 193 of file MultiRectTool.h.

Referenced by rectangleDefined().

does the rectangle persist after double clicks (until a new one is started)?

Definition at line 190 of file MultiRectTool.h.

Definition at line 208 of file MultiRectTool.h.

Definition at line 209 of file MultiRectTool.h.

itsMoving is being replaced by moving_regions

Definition at line 207 of file MultiRectTool.h.

Reimplemented in casa::QtELRegion, casa::QtPointRegion, and casa::QtRTRegion.

Definition at line 235 of file MultiRectTool.h.

Definition at line 234 of file MultiRectTool.h.

itsActive is being replaced by resizing_region

Definition at line 199 of file MultiRectTool.h.

Definition at line 201 of file MultiRectTool.h.

Definition at line 174 of file MultiRectTool.h.

Referenced by getRegionSource().


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