DSArrow.h

Classes

DSArrow -- Arrow implementation;adds a polygon to a DSLine to represent the arrow head (full description)

class DSArrow : public DSLine

Types

enum ArrowHead

Open_Triangle
Filled_Triangle
Cool_Triangle

Interface

Public Members
DSArrow()
DSArrow(const Vector<Float> &startPoint, const Vector<Float> &endPoint, DSArrow::ArrowHead style = DSArrow::Cool_Triangle, const Int arrowHeadSize = 8)
DSArrow(const DSArrow& other)
virtual ~DSArrow()
virtual void draw(PixelCanvas *pc)
virtual void move(const Float& dX, const Float& dY)
virtual void rotate(const Float& angle)
virtual void scale(const Float& scaleFactor)
virtual void setCenter(const Float& xPos, const Float& yPos)
virtual void rotateAbout(const Float& angle, const Float& aboutX, const Float& aboutY)
virtual void setStartPoint(const Vector<Float>& startPoint)
virtual void setEndPoint(const Vector<Float>& endPoint)
virtual void changePoint(const Vector<Float>&pos, const Int n)
virtual void changePoint(const Vector<Float>& pos)
virtual void setLength(const Float& pixelLength)
virtual void setAngle(const Float& angle)
virtual Record getOptions()
virtual Bool setOptions(const Record& newSettings)
Private Members
virtual void buildArrowHead()
virtual void updateArrowHead()
virtual void setDefaultOptions()
virtual void make()

Description

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..
    

Member Description

enum ArrowHead

Supported arrow head types

DSArrow()

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

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)
virtual void move(const Float& dX, const Float& dY)
virtual void rotate(const Float& angle)
virtual void scale(const Float& scaleFactor)
virtual void setCenter(const Float& xPos, const Float& yPos)

Standard Display Shape functions

virtual void rotateAbout(const Float& angle, const Float& aboutX, const Float& aboutY)

Does nothing currently

virtual void setStartPoint(const Vector<Float>& startPoint)
virtual void setEndPoint(const Vector<Float>& endPoint)
virtual void changePoint(const Vector<Float>&pos, const Int n)
virtual void changePoint(const Vector<Float>& pos)

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.

virtual void setLength(const Float& pixelLength)
virtual void setAngle(const Float& angle)

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

virtual Record getOptions()

Return an option record describing the shape

virtual Bool setOptions(const Record& newSettings)

Set options.

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