OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::Path2D Class Reference

The Path2D class describes a path consisting of different types of lines. More...

#include "Path2D.h"

Inheritance diagram for ot::Path2D:
ot::Serializable

Classes

struct  PathEntry
 A path entry contains the. More...
 

Public Types

enum  PathEntryType { LineType , BerzierType }
 The type of a path entry. More...
 

Public Member Functions

 Path2D ()
 Default constructor.
 
 Path2D (const Point2D &_startPos)
 Assignment constructor.
 
 Path2D (const Path2D &_other)
 Copy constructor.
 
virtual ~Path2D ()
 Destructor.
 
Path2Doperator= (const Path2D &_other)
 Assignment operator.
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ot::ConstJsonObject &_object) override
 Will set the object contents from the provided JSON object.
 
bool isClosed (void)
 Returns true if the path contains at least one entry, the entries are interconnected (end of a entry is start of another) and the start point is also the final end point.
 
void moveTo (const Point2D &_pos)
 Moves the current position. No line will be added.
 
void moveBy (const Point2D &_d)
 Moves the current position by the delta.
 
void lineTo (const Point2D &_dest)
 Adds a line from the current position to the provided destination. The current position will be set to the destination.
 
void berzierTo (const Point2D &_ct1, const Point2D &_ct2, const Point2D &_dest)
 Adds a berzier curve from the current position to the provided destination by taking the two control points into account. The current position will be set to the destination.
 
void clear (void)
 Remove all the entries from the path.
 
const std::list< PathEntry > & getEntries (void) const
 Returns the current entries.
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 

Detailed Description

The Path2D class describes a path consisting of different types of lines.

Member Enumeration Documentation

◆ PathEntryType

The type of a path entry.

Enumerator
LineType 
BerzierType 

Constructor & Destructor Documentation

◆ Path2D() [1/3]

ot::Path2D::Path2D ( )

Default constructor.

◆ Path2D() [2/3]

ot::Path2D::Path2D ( const Point2D & _startPos)

Assignment constructor.

Parameters
_startPosThe initial position of the path (same as calling moveTo())

◆ Path2D() [3/3]

ot::Path2D::Path2D ( const Path2D & _other)

Copy constructor.

◆ ~Path2D()

ot::Path2D::~Path2D ( )
virtual

Destructor.

Member Function Documentation

◆ addToJsonObject()

void ot::Path2D::addToJsonObject ( ot::JsonValue & _object,
ot::JsonAllocator & _allocator ) const
overridevirtual

Add the object contents to the provided JSON object.

Parameters
_objectJson object reference
_allocatorAllocator

Implements ot::Serializable.

◆ berzierTo()

void ot::Path2D::berzierTo ( const Point2D & _ct1,
const Point2D & _ct2,
const Point2D & _dest )

Adds a berzier curve from the current position to the provided destination by taking the two control points into account. The current position will be set to the destination.

Parameters
_ct1Control point 1.
_ct2Control point 2.
_destThe curve destination.

◆ clear()

void ot::Path2D::clear ( void )

Remove all the entries from the path.

Note
Note that the current position wont be changed.

◆ getEntries()

const std::list< PathEntry > & ot::Path2D::getEntries ( void ) const
inline

Returns the current entries.

◆ isClosed()

bool ot::Path2D::isClosed ( void )

Returns true if the path contains at least one entry, the entries are interconnected (end of a entry is start of another) and the start point is also the final end point.

◆ lineTo()

void ot::Path2D::lineTo ( const Point2D & _dest)

Adds a line from the current position to the provided destination. The current position will be set to the destination.

Parameters
_destThe line destination.

◆ moveBy()

void ot::Path2D::moveBy ( const Point2D & _d)
inline

Moves the current position by the delta.

Parameters
_dMove distance (incremental).

◆ moveTo()

void ot::Path2D::moveTo ( const Point2D & _pos)
inline

Moves the current position. No line will be added.

Parameters
_posThe position to move to (absolute).

◆ operator=()

ot::Path2D & ot::Path2D::operator= ( const Path2D & _other)

Assignment operator.

◆ setFromJsonObject()

void ot::Path2D::setFromJsonObject ( const ot::ConstJsonObject & _object)
overridevirtual

Will set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information
Exceptions
Willthrow an exception if the provided object is not valid (members missing or invalid types)

Implements ot::Serializable.


The documentation for this class was generated from the following files: