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

Arrow implementation;adds a polygon to a DSLine to represent the arrow head. More...

#include <DSArrow.h>

Inheritance diagram for casa::DSArrow:
casa::DSLine casa::DSPolyLine casa::DSBasic casa::DisplayShape casa::DSPixelArrow casa::DSScreenArrow casa::DSWorldArrow

List of all members.

Public Types

enum  ArrowHead {
  Open_Triangle,
  Filled_Triangle,
  Cool_Triangle
}
 Supported arrow head types. More...

Public Member Functions

 DSArrow ()
 Default constructor.
 DSArrow (const Vector< Float > &startPoint, const Vector< Float > &endPoint, DSArrow::ArrowHead style=DSArrow::Cool_Triangle, const Int arrowHeadSize=8)
 The start and end point are in pixel co-ordinates.
 DSArrow (const DSArrow &other)
 Copy constructor.
virtual ~DSArrow ()
 Destructor.
virtual void draw (PixelCanvas *pc)
 Standard Display Shape functions.
virtual void move (const Float &dX, const Float &dY)
virtual void rotate (const Float &angle)
 Rotate the shape about its center by a set angle (angle in degrees).
virtual void scale (const Float &scaleFactor)
 Scale the shape about its center by the scaleFactor.
virtual void setCenter (const Float &xPos, const Float &yPos)
 This does nothing, it's so arrow and other inheriting classes can take note of new centers.
virtual void rotateAbout (const Float &angle, const Float &aboutX, const Float &aboutY)
 Does nothing currently.
virtual void setStartPoint (const Vector< Float > &startPoint)
 Standard (changePoint) and specific funtions for altering the arrow.
virtual void setEndPoint (const Vector< Float > &endPoint)
virtual void changePoint (const Vector< Float > &pos, const Int n)
 Changes the nth point making up the DisplayShape ot the specified location.
virtual void changePoint (const Vector< Float > &pos)
 Point manipulation functions.
virtual void setLength (const Float &pixelLength)
 These are to enable the use of arrows more easily in vector plots.
virtual void setAngle (const Float &angle)
virtual Record getOptions ()
 Return an option record describing the shape.
virtual Bool setOptions (const Record &newSettings)
 Set options.

Static Public Attributes

static const int numArrowHeads
 For checking setoptions(arrowheadstyle = ?)

Private Member Functions

virtual void buildArrowHead ()
 Make a new arrow head (which is simply a DSPoly)
virtual void updateArrowHead ()
 Caluclate angle etc.
virtual void setDefaultOptions ()
 Set default options.
virtual void make ()
 Construct the line segment of the arrow when we have valid start / end points.

Private Attributes

Float itsLength
 If someone calls "setLength" before "setCenter", we can store our length until they DO call setLength;.
DParameterRange< Int > * itsHeadSize
DSPolyitsArrowHead
Vector< FloatitsStartPoint
 Temp storage while I am being set up.
Vector< FloatitsEndPoint
Matrix< FloatitsUnrotatedHead
 A Matrix of the unRotated arrow head.
Float itsOffset
 Offset needed to make sure the tip of the arrow is at the end of the line.
DSArrow::ArrowHead itsArrowHeadStyle
 Style of arrow head.
Bool itsValidStart
 Have I been supplied with valid points yet.
Bool itsValidEnd

Detailed Description

Arrow implementation;adds a polygon to a DSLine to represent the arrow head.

Prerequisite

Etymology

DSArrow is a method of managing the drawing of a line and polygon onto a PixelCanvas.

Synopsis

DSArrow simply extends from DSLine, and adds the management of a polygon to it. The polygon is used to represent the arrow head, and various options regarding its apppearance can be changed.

There are generally two ways to make DisplayShape(s); To create them in "one hit" by providing arguments to the constructor, or by using the default constructor and then the "setOptions" method. A simple interface for all classes inheriting from the DisplayShape class is provided by DisplayShapeInterface .

Motivation

It was thought, especially in an annotations context, that an Arrow would be a usefull drawing tool.

Example

    Vector<Float> startPoint(2); startPoint[0] = 100; startPoint[1] = 100;
    Vector<Float> endPoint(2);   endPoint[0] = 200;   endPoint[1] = 200;
   
    DSArrow* myArrow = 
    new DSArrow(startPoint, endPoint, DSArrow::Filled_Triangle, 10);
   
    myArrow->move(10,10);
   
    Vector<Float> newStart(2); newStart[0] = 50; newStart[1] = 50;
    myArrow->setStartPoint(newStart);
   
    Record newArrow;
    newArrow.define("arrowheadsize", 6);
   
    myArrow->setOptions(newArrow);
    myArrow->draw(myPixelCanvas);
    etc.\.

Definition at line 99 of file DSArrow.h.


Member Enumeration Documentation

Supported arrow head types.

Enumerator:
Open_Triangle 
Filled_Triangle 
Cool_Triangle 

Definition at line 104 of file DSArrow.h.


Constructor & Destructor Documentation

Default constructor.

In order to make the arrow "valid", it must be supplied with a valid start and end point.

casa::DSArrow::DSArrow ( const Vector< Float > &  startPoint,
const Vector< Float > &  endPoint,
DSArrow::ArrowHead  style = DSArrow::Cool_Triangle,
const Int  arrowHeadSize = 8 
)

The start and end point are in pixel co-ordinates.

casa::DSArrow::DSArrow ( const DSArrow other)

Copy constructor.

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

Destructor.


Member Function Documentation

virtual void casa::DSArrow::buildArrowHead ( ) [private, virtual]

Make a new arrow head (which is simply a DSPoly)

virtual void casa::DSArrow::changePoint ( const Vector< Float > &  newPoint,
const Int  nPoint 
) [virtual]

Changes the nth point making up the DisplayShape ot the specified location.

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::changePoint ( const Vector< Float > &  pos) [virtual]

Point manipulation functions.

The changePoint with only one argument moves the closest point to the location specified.

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::draw ( PixelCanvas pc) [virtual]

Standard Display Shape functions.

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSWorldArrow.

virtual Record casa::DSArrow::getOptions ( ) [virtual]

Return an option record describing the shape.

Reimplemented from casa::DSLine.

Reimplemented in casa::DSScreenArrow, casa::DSWorldArrow, and casa::DSPixelArrow.

virtual void casa::DSArrow::make ( ) [private, virtual]

Construct the line segment of the arrow when we have valid start / end points.

Reimplemented from casa::DSLine.

virtual void casa::DSArrow::move ( const Float dX,
const Float dY 
) [virtual]

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::rotate ( const Float angle) [virtual]

Rotate the shape about its center by a set angle (angle in degrees).

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::rotateAbout ( const Float angle,
const Float aboutX,
const Float aboutY 
) [virtual]

Does nothing currently.

Reimplemented from casa::DSPolyLine.

virtual void casa::DSArrow::scale ( const Float scaleFactor) [virtual]

Scale the shape about its center by the scaleFactor.

Reimplemented from casa::DSPolyLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::setAngle ( const Float angle) [virtual]
virtual void casa::DSArrow::setCenter ( const Float xPos,
const Float yPos 
) [virtual]

This does nothing, it's so arrow and other inheriting classes can take note of new centers.

Reimplemented from casa::DSLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::setDefaultOptions ( ) [private, virtual]

Set default options.

Reimplemented from casa::DSPolyLine.

virtual void casa::DSArrow::setEndPoint ( const Vector< Float > &  endPoint) [virtual]

Reimplemented from casa::DSLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::setLength ( const Float pixelLength) [virtual]

These are to enable the use of arrows more easily in vector plots.

virtual Bool casa::DSArrow::setOptions ( const Record newSettings) [virtual]

Set options.

Reimplemented from casa::DSLine.

Reimplemented in casa::DSScreenArrow, casa::DSWorldArrow, and casa::DSPixelArrow.

virtual void casa::DSArrow::setStartPoint ( const Vector< Float > &  startPoint) [virtual]

Standard (changePoint) and specific funtions for altering the arrow.

the changePoint method with only one argument will move the closest point to the specified new point. When speciffyin 'n', in this case only 0 or 1 are valid. The 'startpoint' is the one with the arrow head on it.

Reimplemented from casa::DSLine.

Reimplemented in casa::DSScreenArrow, and casa::DSWorldArrow.

virtual void casa::DSArrow::updateArrowHead ( ) [private, virtual]

Caluclate angle etc.


Member Data Documentation

Definition at line 183 of file DSArrow.h.

Style of arrow head.

Definition at line 199 of file DSArrow.h.

Definition at line 188 of file DSArrow.h.

Definition at line 181 of file DSArrow.h.

If someone calls "setLength" before "setCenter", we can store our length until they DO call setLength;.

Definition at line 166 of file DSArrow.h.

Offset needed to make sure the tip of the arrow is at the end of the line.

Definition at line 196 of file DSArrow.h.

Temp storage while I am being set up.

Definition at line 187 of file DSArrow.h.

A Matrix of the unRotated arrow head.

Definition at line 192 of file DSArrow.h.

Reimplemented from casa::DSLine.

Definition at line 202 of file DSArrow.h.

Have I been supplied with valid points yet.

Reimplemented from casa::DSLine.

Definition at line 202 of file DSArrow.h.

const int casa::DSArrow::numArrowHeads [static]

For checking setoptions(arrowheadstyle = ?)

Definition at line 107 of file DSArrow.h.


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