DisplayShapeInterface.h

Classes

DisplayShapeInterface -- Wrapper for DisplayShapes;provides easier/unified constr. of DisplayShapes (full description)

class DisplayShapeInterface

Types

enum Coord

Pixels
Relative
World

Interface

Public Members
DisplayShapeInterface(const Record& shapeInfo)
DisplayShapeInterface(const Record& shapeInfo, const PixelCanvas* pc, const Bool scale = True)
DisplayShapeInterface(const Record shapeInfo, const WorldCanvas* wc)
DisplayShapeInterface(const DisplayShapeInterface& other)
virtual ~DisplayShapeInterface()
virtual Bool inObject(const Float xPos, const Float yPos)
virtual Bool onHandles(const Float xPos, const Float yPos)
virtual Vector<Float> getCenter() const
virtual void setCenter(const Float xPos, const Float yPos)
virtual Bool whichHandle(const Float xPos, const Float yPos, Int& out)
virtual void changePoint(const Vector<Float>& newPos)
virtual void changePoint(const Vector<Float>& newPoint, const Int nPoint)
virtual void addPoint(const Vector<Float>& newPoint)
virtual void rotate(const Float angle)
virtual void scale(const Float angle)
virtual void draw(PixelCanvas* toDrawTo)
virtual void move(const Float dX, const Float dY)
virtual void addLocked(DisplayShapeInterface* toLock)
virtual void removeLocked(DisplayShapeInterface* removeLock)
virtual void setDrawHandles(const Bool& draw)
virtual Bool setOptions(const Record& newOptions)
virtual Record getOptions()
virtual Bool updatePixelPosition()
virtual Bool updateNonPixelPosition()
virtual DisplayShape* getObject()
virtual void toPolygon()
Private Members
Record toPixOpts(const Record& notPix)
Record fromPixOpts(const Record& pix)
Record pixToRelOpts(const Record& pixel)
Record relToPixOpts(const Record& relative)
Record pixToWorldOpts(const Record& pix)
Record worldToPixOpts(const Record& world)
Vector<Float> pixToRel(const Vector<Float>& pix)
Vector<Float> relToPix(const Vector<Float>& rel)
Float relToPixWidth(const Float rel)
Float relToPixHeight(const Float rel)
Float pixToRelWidth(const Float pix)
Float pixToRelHeight(const Float pix)
void makeShape(const Record& shapeInfo)

Description

class PixelCanvas; class WorldCanvas;

Prerequisite

Etymology

DisplayShapeInterface makes it easier to work with DisplayShapes.

Synopsis

DisplayShapeInterface simply contains a pointer to a DisplayShape object. It allows all DisplayShapes to be constructed via a single constructor. i.e. the DisplayShapeInterface constructor actually decides which shape to create based on the information in the Record passed to it. It makes creating new shapes look a little nice, since:
    record1.define("type", "square");
    and
    record2.define("type", "circle");
    
can both be simply made into a new DisplayShapeInterface, e.g.
    DisplayShapeInterface* myShape = new DisplayShapeInterface(record1);
    or
    DisplayShapeInterface* myShape = new DisplayShapeInterface(record2);
    
It also guarantees consistant interfaces between shapes.

Motivation

The creation of an interface to DisplayShapes makes use of the simpler.

Example

Member Description

enum Coord

DisplayShapeInterface(const Record& shapeInfo)

Constructor for a standard shape. The shape will be totally based on pixel sizes, both for it's position and sizes.

DisplayShapeInterface(const Record& shapeInfo, const PixelCanvas* pc, const Bool scale = True)

Constructor for shape based on relative screen positions. if scaled is true, relative screen positions will be used for height etc also. If not, positions only will be based on relative screen pos, heights will be based on an absolute pixel value.

DisplayShapeInterface(const Record shapeInfo, const WorldCanvas* wc)

Constructor for shape based on world co-ordinates (NYI)

DisplayShapeInterface(const DisplayShapeInterface& other)

Copy cons

virtual ~DisplayShapeInterface()

virtual Bool inObject(const Float xPos, const Float yPos)
virtual Bool onHandles(const Float xPos, const Float yPos)
virtual Vector<Float> getCenter() const
virtual void setCenter(const Float xPos, const Float yPos)
virtual Bool whichHandle(const Float xPos, const Float yPos, Int& out)
virtual void changePoint(const Vector<Float>& newPos)
virtual void changePoint(const Vector<Float>& newPoint, const Int nPoint)
virtual void addPoint(const Vector<Float>& newPoint)
virtual void rotate(const Float angle)
virtual void scale(const Float angle)
virtual void draw(PixelCanvas* toDrawTo)
virtual void move(const Float dX, const Float dY)
virtual void addLocked(DisplayShapeInterface* toLock)
virtual void removeLocked(DisplayShapeInterface* removeLock)
virtual void setDrawHandles(const Bool& draw)
virtual Bool setOptions(const Record& newOptions)
virtual Record getOptions()

DisplayShape functionality. All of these functions simply wrap those of the underlying DisplayShape (and add conversion functionality). Please see DisplayShape for a full description of these functions.

virtual Bool updatePixelPosition()

Update the pixel location of this shape, based on the stored information on its location. If the shape is being used in pixel mode this will do nothing. If being used in relative screen mode or WC mode, this will update its location. Returns false if a conversion to pixels fail.

virtual Bool updateNonPixelPosition()

If the shape is being used in absolute pixel co-ordinates, this will do nothing. If being used in relative screen or WC mode, this will update the position based on its current pixel location. Returns false if the conversion to the other co-ord type fails.

virtual DisplayShape* getObject()

Returns the pointer to the underlying object

virtual void toPolygon()

If the shape is a PolyLine, this function will change it to a polygon. This is designed for use in the creation of polygon by the user clicking out a polyline, for example.

Record toPixOpts(const Record& notPix)

Record fromPixOpts(const Record& pix)

Will return an option set with whatever the current coords method is.

Record pixToRelOpts(const Record& pixel)

Record relToPixOpts(const Record& relative)

Record pixToWorldOpts(const Record& pix)

Record worldToPixOpts(const Record& world)

Vector<Float> pixToRel(const Vector<Float>& pix)

Vector<Float> relToPix(const Vector<Float>& rel)

Float relToPixWidth(const Float rel)

Float relToPixHeight(const Float rel)

Float pixToRelWidth(const Float pix)

Float pixToRelHeight(const Float pix)

void makeShape(const Record& shapeInfo)