casa
$Rev:20696$
|
Arrow implementation;adds a polygon to a DSLine to represent the arrow head. More...
#include <DSArrow.h>
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 |
DSPoly * | itsArrowHead |
Vector< Float > | itsStartPoint |
Temp storage while I am being set up. | |
Vector< Float > | itsEndPoint |
Matrix< Float > | itsUnrotatedHead |
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 |
Arrow implementation;adds a polygon to a DSLine to represent the arrow head.
DSArrow is a method of managing the drawing of a line and polygon onto a PixelCanvas.
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 .
It was thought, especially in an annotations context, that an Arrow would be a usefull drawing tool.
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.\.
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.
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.
DSPoly* casa::DSArrow::itsArrowHead [private] |
Vector<Float> casa::DSArrow::itsEndPoint [private] |
DParameterRange<Int>* casa::DSArrow::itsHeadSize [private] |
Float casa::DSArrow::itsLength [private] |
Float casa::DSArrow::itsOffset [private] |
Vector<Float> casa::DSArrow::itsStartPoint [private] |
Matrix<Float> casa::DSArrow::itsUnrotatedHead [private] |
Bool casa::DSArrow::itsValidEnd [private] |
Reimplemented from casa::DSLine.
Bool casa::DSArrow::itsValidStart [private] |
Have I been supplied with valid points yet.
Reimplemented from casa::DSLine.
const int casa::DSArrow::numArrowHeads [static] |