Model — Shapes

Geometric shape nodes that can be drawn in a document.

DocraftRectangle

Rectangle with background and border styling, often used as a container.

class DocraftRectangle : public docraft::model::DocraftChildrenContainerNode, public docraft::model::IDocraftClonable

Rectangle node with background and border styling.

Often used as a container to draw a box behind its children.

Subclassed by docraft::model::DocraftSection

Public Functions

virtual void draw(const std::shared_ptr<DocraftDocumentContext> &context) override

Draws the rectangle using the provided context.

Parameters:

context – Document context.

virtual std::shared_ptr<DocraftNode> clone() const override

Clones the rectangle node and its children.

Returns:

Shared pointer to the cloned node.

void set_background_color(const DocraftColor &color)

Sets the background color.

Parameters:

color – Background color.

void set_border_color(const DocraftColor &color)

Sets the border color.

Parameters:

color – Border color.

void set_border_width(float width)

Sets the border width in points.

Parameters:

width – Border width in points.

const DocraftColor &background_color() const

Returns the background color.

Returns:

Background color.

const DocraftColor &border_color() const

Returns the border color.

Returns:

Border color.

float border_width() const

Returns the border width in points.

Returns:

Border width in points.

void set_background_color_template_expression(const std::string &expression)

Sets the template expression for background color if it’s a template.

Parameters:

expression – Template expression string.

void set_border_color_template_expression(const std::string &expression)

Sets the template expression for border color if it’s a template.

Parameters:

expression – Template expression string.

const std::string &background_color_template_expression() const

Returns the template expression for background color.

Returns:

Template expression string.

const std::string &border_color_template_expression() const

Returns the template expression for border color.

Returns:

Template expression string.

DocraftChildrenContainerNode(const DocraftChildrenContainerNode &node) = default
explicit DocraftChildrenContainerNode(DocraftChildrenContainerNode *node)

Constructs from an existing node pointer (copy).

DocraftCircle

Circle node with background and border styling.

class DocraftCircle : public docraft::model::DocraftNode, public docraft::model::IDocraftClonable

Circle node with background and border styling.

Public Functions

virtual void draw(const std::shared_ptr<DocraftDocumentContext> &context) override

Draws the circle using the provided context.

Parameters:

context – Document context.

virtual std::shared_ptr<DocraftNode> clone() const override

Clones the circle node.

Returns:

Shared pointer to the cloned node.

void set_background_color(const DocraftColor &color)

Sets the background color.

Parameters:

color – Background color.

void set_border_color(const DocraftColor &color)

Sets the border color.

Parameters:

color – Border color.

void set_border_width(float width)

Sets the border width in points.

Parameters:

width – Border width.

const DocraftColor &background_color() const

Returns the background color.

Returns:

Background color.

const DocraftColor &border_color() const

Returns the border color.

Returns:

Border color.

float border_width() const

Returns the border width in points.

Returns:

Border width.

explicit DocraftNode()

Creates a node with a unique id.

DocraftNode(const DocraftNode &node)

Copy-constructs a node.

explicit DocraftNode(const DocraftNode *node)

Constructs a node from an existing pointer (copy).

DocraftTriangle

Triangle node defined by three points.

class DocraftTriangle : public docraft::model::DocraftNode, public docraft::model::IDocraftClonable

Triangle node defined by three points.

Public Functions

virtual void draw(const std::shared_ptr<DocraftDocumentContext> &context) override

Draws the triangle using the provided context.

Parameters:

context – Document context.

virtual std::shared_ptr<DocraftNode> clone() const override

Clones the triangle node.

Returns:

Shared pointer to the cloned node.

void set_points(const std::vector<DocraftPoint> &points)

Sets the triangle points (local coordinates).

Parameters:

points – Points vector (size must be 3).

const std::vector<DocraftPoint> &points() const

Returns the triangle points.

Returns:

Points vector.

void set_background_color(const DocraftColor &color)

Sets the background color.

Parameters:

color – Background color.

void set_border_color(const DocraftColor &color)

Sets the border color.

Parameters:

color – Border color.

void set_border_width(float width)

Sets the border width in points.

Parameters:

width – Border width.

const DocraftColor &background_color() const

Returns the background color.

Returns:

Background color.

const DocraftColor &border_color() const

Returns the border color.

Returns:

Border color.

float border_width() const

Returns the border width in points.

Returns:

Border width.

explicit DocraftNode()

Creates a node with a unique id.

DocraftNode(const DocraftNode &node)

Copy-constructs a node.

explicit DocraftNode(const DocraftNode *node)

Constructs a node from an existing pointer (copy).

DocraftLine

Line node defined by start and end points.

class DocraftLine : public docraft::model::DocraftNode, public docraft::model::IDocraftClonable

Line node defined by start and end points.

Public Functions

virtual void draw(const std::shared_ptr<DocraftDocumentContext> &context) override

Draws the line using the provided context.

Parameters:

context – Document context.

virtual std::shared_ptr<DocraftNode> clone() const override

Clones the line node.

Returns:

Shared pointer to the cloned node.

void set_start(const DocraftPoint &point)

Sets the line start point (local coordinates).

Parameters:

point – Start point.

void set_end(const DocraftPoint &point)

Sets the line end point (local coordinates).

Parameters:

point – End point.

void set_border_color(const DocraftColor &color)

Sets the stroke color.

Parameters:

color – Stroke color.

void set_border_width(float width)

Sets the stroke width.

Parameters:

width – Stroke width in points.

const DocraftPoint &start() const

Returns the start point.

Returns:

Start point.

const DocraftPoint &end() const

Returns the end point.

Returns:

End point.

const DocraftColor &border_color() const

Returns the stroke color.

Returns:

Stroke color.

float border_width() const

Returns the stroke width in points.

Returns:

Stroke width.

explicit DocraftNode()

Creates a node with a unique id.

DocraftNode(const DocraftNode &node)

Copy-constructs a node.

explicit DocraftNode(const DocraftNode *node)

Constructs a node from an existing pointer (copy).

DocraftPolygon

Polygon node defined by a list of points.

class DocraftPolygon : public docraft::model::DocraftNode, public docraft::model::IDocraftClonable

Polygon node defined by a list of points.

Public Functions

virtual void draw(const std::shared_ptr<DocraftDocumentContext> &context) override

Draws the polygon using the provided context.

Parameters:

context – Document context.

virtual std::shared_ptr<DocraftNode> clone() const override

Clones the polygon node.

Returns:

Shared pointer to the cloned node.

void set_points(const std::vector<DocraftPoint> &points)

Sets the polygon points (local coordinates).

Parameters:

points – Points vector.

const std::vector<DocraftPoint> &points() const

Returns the polygon points.

Returns:

Points vector.

void set_background_color(const DocraftColor &color)

Sets the background color.

Parameters:

color – Background color.

void set_border_color(const DocraftColor &color)

Sets the border color.

Parameters:

color – Border color.

void set_border_width(float width)

Sets the border width in points.

Parameters:

width – Border width.

const DocraftColor &background_color() const

Returns the background color.

Returns:

Background color.

const DocraftColor &border_color() const

Returns the border color.

Returns:

Border color.

float border_width() const

Returns the border width in points.

Returns:

Border width.

explicit DocraftNode()

Creates a node with a unique id.

DocraftNode(const DocraftNode &node)

Copy-constructs a node.

explicit DocraftNode(const DocraftNode *node)

Constructs a node from an existing pointer (copy).