DDDObject.h

Classes

DDDObject -- Base class describing interface for objects supported by DrawingDisplayData (full description)

class DDDObject : public WCRefreshEH, public WCMotionEH, public WCPositionEH

Types

enum Mode

None
Handle
Move
Rotate

Interface

Public Members
DDDObject(const Record &description, DrawingDisplayData *owner)
virtual ~DDDObject()
virtual void draw(const Display::RefreshReason &reason, WorldCanvas *worldcanvas) = 0
virtual void showHandles(const Bool show, const Bool tellOwner = True)
virtual Bool showingHandles()
virtual Record description()
virtual void setDescription(const Record &rec)
virtual Bool storeClick(const DisplayEvent &ev)
virtual void clearClickBuffer()
Int objectID() const
virtual void operator()(const WCRefreshEvent &ev) = 0
virtual void operator()(const WCPositionEvent &ev) = 0
virtual void operator()(const WCMotionEvent &ev) = 0
Protected Members
DrawingDisplayData *owner()
String color() const
String label() const
Int lineWidth() const
Bool isEditable() const
Bool isMovable() const
Bool isFixed() const
DDDObject()
DDDObject(const DDDObject &other)
void operator=(const DDDObject &other)
void translateMatrix(Matrix<Double>& points, Double dx, Double dy)
Matrix<Double> rotateMatrix(const Matrix<Double>& points, Double angle)
Bool inPolygon(const Matrix<Double>& points, Double x, Double y)
Bool inPolygon(const Vector<Double>& xP, const Vector<Double>& yP, Double x, Double y)
void convertCoordinateSystem (CoordinateSystem& cSys, WorldCanvas* wcPtr) const
Bool onHandle(const Block<DDDHandle>& handles, Double x, Double y)

Description

Synopsis

This class defines the interface which objects that are drawable by the DrawingDisplayData class must provide.

World units of 'pix' and 'frac' are defined. 'pix' units are in screen pixel units. They are not very useful once the display has been zoomed. 'frac' units have range [0,0] -> [1,1] mapping to the display part of the pixel canvas.

Member Description

enum Mode

DDDObject(const Record &description, DrawingDisplayData *owner)

Constructor taking a Record description. Fields in the record are: color and label.

virtual ~DDDObject()

Destructor.

virtual void draw(const Display::RefreshReason &reason, WorldCanvas *worldcanvas) = 0

Draw this DrawingDisplayData object for the given reason on the provided WorldCanvas.

virtual void showHandles(const Bool show, const Bool tellOwner = True)

Indicate whether the object should show its handles or not. The parent DrawingDisplayData will control this, and either ask all DDDObjects to show their handles or not, via the user setting an option. This actually controls the state of whether this DDDObject is editable, so the parent DrawingDisplayData could also allow editing of only one DDDObject at a time.

virtual Bool showingHandles()

Query whether the object is showing its handles.

virtual Record description()

Return a record describing this object.

virtual void setDescription(const Record &rec)

Update this object based on the information in the provided Record.

virtual Bool storeClick(const DisplayEvent &ev)

Store a click in the buffer and look for a double-click event. If one is found, then call the doubleClick function in the owning DisplayData. Returns True if a double click was detected.

virtual void clearClickBuffer()

Clear the click buffer.

Int objectID() const

Return the unique id of this object.

virtual void operator()(const WCRefreshEvent &ev) = 0
virtual void operator()(const WCPositionEvent &ev) = 0
virtual void operator()(const WCMotionEvent &ev) = 0

Event handlers. The parent DrawingDisplayData will distribute events as necessary to the various DDDObjects which comprise it.

DrawingDisplayData *owner()

Return the owner of this object.

String color() const

Return the color to use to draw this object.

String label() const

Return the label of this object.

Int lineWidth() const

Return the line width of this object.

Bool isEditable() const

Bool isMovable() const

Bool isFixed() const

DDDObject()

(Required) default constructor.

DDDObject(const DDDObject &other)

(Required) copy constructor.

void operator=(const DDDObject &other)

(Required) copy assignment.

void translateMatrix(Matrix<Double>& points, Double dx, Double dy)

Translate Matrix

Matrix<Double> rotateMatrix(const Matrix<Double>& points, Double angle)

Rotate Matrix

Bool inPolygon(const Matrix<Double>& points, Double x, Double y)
Bool inPolygon(const Vector<Double>& xP, const Vector<Double>& yP, Double x, Double y)

Is point inside the polygon

void convertCoordinateSystem (CoordinateSystem& cSys, WorldCanvas* wcPtr) const

Convert CoordinateSystem to screen pixels

Bool onHandle(const Block<DDDHandle>& handles, Double x, Double y)

Is the point on a handle