DisplayShape.h
Classes
- DisplayShape -- The abstract base class for all "DisplayShapes". (full description)
Types
- Filled_Square = 0
-
- Open_Square
-
- Filled_Circle
-
- Open_Circle
-
- Filled_Triangle
-
- Open_Triangle
-
Interface
- Public Members
- DisplayShape()
- DisplayShape(const DisplayShape& other)
- virtual ~DisplayShape()
- virtual void draw(PixelCanvas* pc)
- virtual void rotateAbout(const Float& relAngle, const Float& aboutX, const Float& aboutY)
- virtual void move(const Float& dX, const Float& dY)
- virtual Matrix<Float> rotatePolygon(const Matrix<Float>& toRotate, const Float& angle, const Float& aboutX, const Float& aboutY)
- virtual Vector<Float> rotatePoint(const Vector<Float>& toRotate, const Float& angle, const Float& aboutX, const Float& aboutY)
- virtual Matrix<Float> translateMatrix(const Matrix<Float>& points, const Float& dx, const Float& dy)
- virtual Bool inPolygon(const Matrix<Float>& points, const Float& xPos, const Float& yPos)
- virtual Bool closestLine(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& firstVert, Int& secondVert, const Bool& closedPoly = True)
- virtual Bool closestPoint(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& out)
- virtual Bool closestPoints(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& outClosest, Int& outSecond)
- virtual Bool inObject(const Float& xPos, const Float& yPos) = 0
- virtual Float toRadians(const Float& degrees)
- virtual Float toDegrees(const Float& radians)
- virtual void setCenter(const Float& xPos, const Float& yPos) = 0
- virtual Vector<Float> getCenter() = 0
- virtual void changePoint(const Vector<Float>& newPos) = 0
- virtual void changePoint(const Vector<Float>& newPoint, const Int nPoint) = 0
- virtual void addPoint(const Vector<Float>& newPoint)
- virtual void rotate(const Float& angle) = 0
- virtual void scale(const Float& scaleFactor) = 0
- virtual void addLocked(DisplayShape* toLock)
- virtual void removeLocked(DisplayShape* removeLock)
- virtual void buildHandles(const Matrix<Float>& startPoints)
- virtual Matrix<Float> getHandleLocations()
- virtual void setHandlePositions(const Matrix<Float>& newPoints)
- virtual DSClosed* makeHandle(const Vector<Float>& newHandlePos)
- virtual void addHandle(const Vector<Float>& newHandlePos, const Bool& atEnd = True , const Int position = 0)
- virtual Bool removeHandle(const Vector<Float>& getRidOf)
- virtual Bool removeHandle(const Int nHandle)
- virtual Bool onHandles(const Float& xPos, const Float& yPos)
- virtual Bool whichHandle(const Float& xPos, const Float& yPos, Int& out)
- virtual void setDrawHandles(const Bool& shouldIDraw)
- virtual Bool drawingHandles()
- virtual void setHasHandles(const Bool& hasHandles)
- virtual void setHandleShape(const DisplayShape::HandleShape& shape)
- virtual void setHandleSize(const Int pixelSize)
- virtual void setHandleColor(const String& handleColor)
- virtual uInt nHandles()
- virtual void setColor(const String& newColor)
- virtual String getColor()
- virtual Record getOptions()
- virtual Bool setOptions(const Record& settings)
- virtual void recalculateScreenPosition()
- Private Members
- virtual void setDefaultOptions()
Prerequisite
Etymology
DisplayShape is a way of providing a consistant interface to a large number
of different shapes.
Synopsis
DisplayShape provides a framework from which a large number of different
shapes can be made, all with the same interface. Any new DisplayShape
should inherit from this class, or higher level classes
(see DSPoly etc).
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
A common interface to a large number of shapes was desired.
Example
Member Description
Handle style
Default constructor. Creates shape with default options set
DisplayShape(const DisplayShape& other)
Copy constructor
Destructor
virtual void draw(PixelCanvas* pc)
virtual void rotateAbout(const Float& relAngle, const Float& aboutX, const Float& aboutY)
virtual void move(const Float& dX, const Float& dY)
These functions contol behaviour of handles during a call
to the display shape object.
(These calls should be propogated up through the class tree).
virtual Matrix<Float> rotatePolygon(const Matrix<Float>& toRotate, const Float& angle, const Float& aboutX, const Float& aboutY)
Rotate the supplied polygon (column 1 - x values, column 2 - y values)
about the supplied point by the supplied angle. NB Angle in radians
virtual Vector<Float> rotatePoint(const Vector<Float>& toRotate, const Float& angle, const Float& aboutX, const Float& aboutY)
Rotates a point around the point specified. NB Angle in radians.
virtual Matrix<Float> translateMatrix(const Matrix<Float>& points, const Float& dx, const Float& dy)
Translate an entire matrix by the specified dx / dy amounts.
virtual Bool inPolygon(const Matrix<Float>& points, const Float& xPos, const Float& yPos)
Is xPos, YPos inside the supplied points (column 1 - x values,
clolumn 2 - y values)
virtual Bool closestLine(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& firstVert, Int& secondVert, const Bool& closedPoly = True)
Determine the two vertices (firstVert, secondVert) which join the line
closest to the xPos, yPos point supplied. If closedPoly is left as
true, the points supplied are treated as a polygon, if not as a poly
line.
virtual Bool closestPoint(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& out)
For a specified set of points, find the closest to xPos,YPos. out
relates the matrix index (row number) of the closest point.
virtual Bool closestPoints(const Matrix<Float>& points, const Float& xPos, const Float& yPos, Int& outClosest, Int& outSecond)
Find the closest two Points from a Matrix to the specified point.
virtual Bool inObject(const Float& xPos, const Float& yPos) = 0
Is the supplied point within the DisplayShape?
virtual Float toRadians(const Float& degrees)
Convert degrees to radians
virtual Float toDegrees(const Float& radians)
Conver radians to degree
virtual void setCenter(const Float& xPos, const Float& yPos) = 0
Sets the center of the DisplayShape
Returns the center of the DisplayShape (x,y).
virtual void changePoint(const Vector<Float>& newPos) = 0
Changes the closest point to the supplied location to that location
virtual void changePoint(const Vector<Float>& newPoint, const Int nPoint) = 0
Changes the nth point making up the DisplayShape ot the specified
location.
virtual void addPoint(const Vector<Float>& newPoint)
If applicable, this function will add a point to the shape in the
most meaningful location.
virtual void rotate(const Float& angle) = 0
Rotate the shape about its center by a set angle (angle in degrees).
virtual void scale(const Float& scaleFactor) = 0
Scale the shape about its center by the scaleFactor
virtual void addLocked(DisplayShape* toLock)
Allow locking of other shapes onto this one. When a shape is locked,
if the current shape is moved, so to will the locked shape.
virtual void removeLocked(DisplayShape* removeLock)
Removes a lock from the specified shape.
virtual void buildHandles(const Matrix<Float>& startPoints)
virtual Matrix<Float> getHandleLocations()
virtual void setHandlePositions(const Matrix<Float>& newPoints)
virtual DSClosed* makeHandle(const Vector<Float>& newHandlePos)
virtual void addHandle(const Vector<Float>& newHandlePos, const Bool& atEnd = True , const Int position = 0)
virtual Bool removeHandle(const Vector<Float>& getRidOf)
virtual Bool removeHandle(const Int nHandle)
virtual Bool onHandles(const Float& xPos, const Float& yPos)
virtual Bool whichHandle(const Float& xPos, const Float& yPos, Int& out)
virtual void setDrawHandles(const Bool& shouldIDraw)
virtual Bool drawingHandles()
virtual void setHasHandles(const Bool& hasHandles)
virtual void setHandleShape(const DisplayShape::HandleShape& shape)
virtual void setHandleSize(const Int pixelSize)
virtual void setHandleColor(const String& handleColor)
virtual uInt nHandles()
Handle management.
Manage the color of object. (Does not include handles)
Settings
Set default options