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

Control class for a collection of DisplayShapeInterfaces. More...

#include <Annotations.h>

Inheritance diagram for casa::Annotations:
casa::PCPositionEH casa::PCMotionEH casa::PCRefreshEH casa::WCRefreshEH casa::DisplayEH

List of all members.

Public Types

enum  State {
  Nothing,
  Creation,
  WcCreation,
  Handle,
  OtherHandle,
  Move,
  OtherMove
}
 Used to determine the state of the class. More...
enum  CreationType {
  Normal,
  Arrow,
  Polygon,
  PolyLine,
  Marker
}
 This is used to handle the creation of shapes by mouse events. More...

Public Member Functions

 Annotations (PanelDisplay *panDisp, const Display::KeySym &keysym=Display::K_Pointer_Button1, const Bool useEH=True)
 Destructor, and constructor, taking the panelDisplay to which the Annotator will attach itself to, and which mouse button to listen to.
virtual ~Annotations ()
virtual void operator() (const PCPositionEvent &ev)
 The event handlers.
virtual void operator() (const PCMotionEvent &ev)
 Default just prints the event to cout.
virtual void operator() (const PCRefreshEvent &ev)
 Default just prints the event to cout.
virtual void operator() (const WCRefreshEvent &ev)
 original handler interface (still used for WCRefreshEvents)
virtual void draw (PixelCanvas *pc, const Bool noHandles=False)
 Redraw all the shapes.
virtual void newShape (Record &settings, const Bool &refresh=True)
 Instantly creates a shape on screen, and hence requires certain information in its record such as the center of the new object on screen.
virtual void setKey (const Display::KeySym &newKey)
 Set the key assigned to control shapes.
virtual void createShape (Record &settings)
 Create a shape, based on the information contained in the record.
virtual void enable ()
 Disable event handling (with the exception of refresh calls).
virtual void disable ()
virtual void cancelShapes ()
 Cancels creation of any pending shapes, unselects all shapes and turns off drawing of all handles.
virtual Bool deleteShape (const uInt &toDel)
 Delete the shape at the specified point in the collection of shapes The current (selected) shape can be determined by using the activeShape() function.
virtual void removeLockedFromCurrent (const uInt &removeMe)
 These allow shapes to be "locked" together.
virtual void addLockedToCurrent (const uInt &addMe)
virtual Int activeShape ()
 Return the currently selected shapes' index.
virtual Record shapesSummary ()
 Return a brief summary of all current shapes.
virtual void setShapeOptions (const uInt &whichShape, const Record &newOptions)
 Set the options for the specified shape.
virtual Record getShapeOptions (const uInt &whichShape)
 Returns a record containing the options for the specified shape.
virtual Record getAllOptions ()
 Returns a record which contains a sub record (containing options) for each shape.
virtual void setAllOptions (const Record &newSettings)
 Deletes all existing shapes, and rebuilds new shapes based on records in sub records of the supplied record.
virtual void update (PixelCanvas *pc)
 Called when a refresh is required.
virtual void annotEvent (const String &)
 Overwrite this to fire glish events.
virtual Bool revertToPix (const Int &whichOne)
 Functions for changing the co-ords system of a shape.
virtual Bool revertToFrac (const Int &whichOne)
virtual Bool lockToWC (const Int &whichOne)
virtual Record availableShapes ()
 Returns a list of shapes annotations knows about.

Private Member Functions

Bool changeCoordSys (const Int shapeIndex, const String &type, const String &currentCoords, const String &toCoords)
 Internal functions.
DisplayShapeconstructShape (const Record &settings)
void handleKeyUp ()
void handleCreation (const PCPositionEvent &ev)
void handleNormalCreation (const Vector< Float > &createPix)
void handleMarkerCreation (const Vector< Float > &createPix)
void handlePolyLineCreation (const Vector< Float > &createPix)
void handlePolygonCreation (const Vector< Float > &createPix)
void handleArrowCreation (const Vector< Float > &createPix)
void select (const Int i)
Bool determineState (const PCPositionEvent &ev)
void registerToWCs ()
Bool validateWCs ()
void changedWC ()
Bool validShape (const Record &shape)
void polyLineToPolygon (const Int whichShape)

Private Attributes

PanelDisplayitsPanelDisplay
 My private variables...
PixelCanvasitsPC
ListIter< WorldCanvas * > * itsWCLI
 My copy of the list of Worldcanvases.
List< WorldCanvas * > itsWCs
PtrBlock< DisplayShape * > itsShapes
 List of shapes.
Display::KeySym itsKey
 Some overall settings.
Bool itsUseEH
Annotations::State itsState
 Stuff to remember my current state:
Annotations::CreationType itsCreation
Bool itsShapeMoved
Int itsActiveShape
Int itsActiveHandle
uInt itsX
uInt itsY
Bool itsEnabled
Bool itsRefreshedYet

Detailed Description

Control class for a collection of DisplayShapeInterfaces.

Prerequisite

Etymology

Annotations is a method by which a collection of shapes can be managed on a pixel canvas.

Synopsis

Annotations registers itself as an event handler on whichever pixelcanvas it is supplied. It can then add, delete or modify shapes based on function calls and user mouse input.

The class is essentially a PtrBlock of DisplayShapeInterfaces, with pixelcanvas event handling to control them.

Motivation

To allow a collection of shapes to be displayed and cotrolled by one class.

Example

Definition at line 84 of file Annotations.h.


Member Enumeration Documentation

This is used to handle the creation of shapes by mouse events.

Some types of shapes require special treatment when constructed with the mouse.

Enumerator:
Normal 
Arrow 
Polygon 
PolyLine 
Marker 

Definition at line 98 of file Annotations.h.

Used to determine the state of the class.

The state may change due to mouse events, or function calls.

Enumerator:
Nothing 
Creation 
WcCreation 
Handle 
OtherHandle 
Move 
OtherMove 

Definition at line 92 of file Annotations.h.


Constructor & Destructor Documentation

casa::Annotations::Annotations ( PanelDisplay panDisp,
const Display::KeySym keysym = Display::K_Pointer_Button1,
const Bool  useEH = True 
)

Destructor, and constructor, taking the panelDisplay to which the Annotator will attach itself to, and which mouse button to listen to.

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

Member Function Documentation

virtual Int casa::Annotations::activeShape ( ) [virtual]

Return the currently selected shapes' index.

virtual void casa::Annotations::addLockedToCurrent ( const uInt addMe) [virtual]
virtual void casa::Annotations::annotEvent ( const String ) [inline, virtual]

Overwrite this to fire glish events.

Definition at line 201 of file Annotations.h.

Returns a list of shapes annotations knows about.

virtual void casa::Annotations::cancelShapes ( ) [virtual]

Cancels creation of any pending shapes, unselects all shapes and turns off drawing of all handles.

Bool casa::Annotations::changeCoordSys ( const Int  shapeIndex,
const String type,
const String currentCoords,
const String toCoords 
) [private]

Internal functions.

void casa::Annotations::changedWC ( ) [private]
DisplayShape* casa::Annotations::constructShape ( const Record settings) [private]
virtual void casa::Annotations::createShape ( Record settings) [virtual]

Create a shape, based on the information contained in the record.

This function does not require the center to be specified, as once createShape is called, the user can "drag" out the shape required. If createShape is called, and the shape is no longer required, the function 'cancelShapes' can be used to reset the state of the annotator.

virtual Bool casa::Annotations::deleteShape ( const uInt toDel) [virtual]

Delete the shape at the specified point in the collection of shapes The current (selected) shape can be determined by using the activeShape() function.

virtual void casa::Annotations::disable ( ) [virtual]
virtual void casa::Annotations::draw ( PixelCanvas pc,
const Bool  noHandles = False 
) [virtual]

Redraw all the shapes.

Turns all handles off if noHandles is True

virtual void casa::Annotations::enable ( ) [virtual]

Disable event handling (with the exception of refresh calls).

This stops the user from moving shapes etc via the mouse motion / position event handlers. These do not recognize nested calls (e.g. two disables, followed by an enable will enable the handlers).

Returns a record which contains a sub record (containing options) for each shape.

e.g. To obtain options for the first shape:

      Record all = myAnnotator.getAllOptions();
      Record shape = all.subRecord(0);
virtual Record casa::Annotations::getShapeOptions ( const uInt whichShape) [virtual]

Returns a record containing the options for the specified shape.

The user selected shape can be determined by calling the 'activeShape' method. To see a list of the options returned by shapes / objects, see their individual documentation.

void casa::Annotations::handleArrowCreation ( const Vector< Float > &  createPix) [private]
void casa::Annotations::handleCreation ( const PCPositionEvent ev) [private]
void casa::Annotations::handleKeyUp ( ) [private]
void casa::Annotations::handleMarkerCreation ( const Vector< Float > &  createPix) [private]
void casa::Annotations::handleNormalCreation ( const Vector< Float > &  createPix) [private]
void casa::Annotations::handlePolygonCreation ( const Vector< Float > &  createPix) [private]
void casa::Annotations::handlePolyLineCreation ( const Vector< Float > &  createPix) [private]
virtual Bool casa::Annotations::lockToWC ( const Int whichOne) [virtual]
virtual void casa::Annotations::newShape ( Record settings,
const Bool refresh = True 
) [virtual]

Instantly creates a shape on screen, and hence requires certain information in its record such as the center of the new object on screen.

Refresh == False can be used to surpress a refresh.

virtual void casa::Annotations::operator() ( const PCPositionEvent ev) [virtual]

The event handlers.

Reimplemented from casa::PCPositionEH.

virtual void casa::Annotations::operator() ( const PCMotionEvent eh) [virtual]

Default just prints the event to cout.

Reimplemented from casa::PCMotionEH.

virtual void casa::Annotations::operator() ( const PCRefreshEvent eh) [virtual]

Default just prints the event to cout.

Reimplemented from casa::PCRefreshEH.

virtual void casa::Annotations::operator() ( const WCRefreshEvent ev) [virtual]

original handler interface (still used for WCRefreshEvents)

Implements casa::WCRefreshEH.

void casa::Annotations::polyLineToPolygon ( const Int  whichShape) [private]
virtual void casa::Annotations::removeLockedFromCurrent ( const uInt removeMe) [virtual]

These allow shapes to be "locked" together.

Adding a locked shape to the current shape means that whenever the current shape moves, so too will the specified shape. removeLockedFromCurrent can be used to remove this effect.

virtual Bool casa::Annotations::revertToFrac ( const Int whichOne) [virtual]
virtual Bool casa::Annotations::revertToPix ( const Int whichOne) [virtual]

Functions for changing the co-ords system of a shape.

void casa::Annotations::select ( const Int  i) [private]
virtual void casa::Annotations::setAllOptions ( const Record newSettings) [virtual]

Deletes all existing shapes, and rebuilds new shapes based on records in sub records of the supplied record.

A record returned from getAllOptions() can therefore be used to copy a set of shapes.

virtual void casa::Annotations::setKey ( const Display::KeySym newKey) [virtual]

Set the key assigned to control shapes.

virtual void casa::Annotations::setShapeOptions ( const uInt whichShape,
const Record newOptions 
) [virtual]

Set the options for the specified shape.

The user selected shape can be determined by call the 'activeShape' method. To see a list of available options for different types of shapes / objects, see their individual documentation.

Return a brief summary of all current shapes.

virtual void casa::Annotations::update ( PixelCanvas pc) [virtual]

Called when a refresh is required.

It copies back to front buffer, then causes a refresh with reason = backCopiedToFront.

Bool casa::Annotations::validShape ( const Record shape) [private]

Member Data Documentation

Definition at line 247 of file Annotations.h.

Definition at line 246 of file Annotations.h.

Definition at line 244 of file Annotations.h.

Definition at line 249 of file Annotations.h.

Some overall settings.

Definition at line 237 of file Annotations.h.

My private variables...

The PanelDisplay I was given on construction and some stuff I got out of it

Definition at line 223 of file Annotations.h.

Definition at line 224 of file Annotations.h.

Definition at line 250 of file Annotations.h.

Definition at line 245 of file Annotations.h.

List of shapes.

Definition at line 233 of file Annotations.h.

Stuff to remember my current state:

Definition at line 243 of file Annotations.h.

Definition at line 238 of file Annotations.h.

My copy of the list of Worldcanvases.

I can check this against itsPanelDisplay to see if anything has changed.

Definition at line 229 of file Annotations.h.

Definition at line 230 of file Annotations.h.

Definition at line 248 of file Annotations.h.

Definition at line 248 of file Annotations.h.


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