OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
GraphicsPolygonItemCfg.h
Go to the documentation of this file.
1
5// ###########################################################################################################################################################################################################################################################################################################################
6
7#pragma once
8
9// OpenTwin header
10#include "OTCore/Point2D.h"
11#include "OTGui/Outline.h"
14
15// std header
16#include <list>
17
18#define OT_FactoryKey_GraphicsPolygonItem "OT_GIPoly"
19
20namespace ot {
21
22 class Painter2D;
23
26 public:
29
31 virtual GraphicsItemCfg* createCopy(void) const override;
32
36 virtual void addToJsonObject(JsonValue& _object, JsonAllocator& _allocator) const override;
37
41 virtual void setFromJsonObject(const ConstJsonObject& _object) override;
42
44 virtual std::string getFactoryKey(void) const override { return std::string(OT_FactoryKey_GraphicsPolygonItem); };
45
46 // ###########################################################################################################################################################################################################################################################################################################################
47
48 // Setter / Getter
49
52 void addPoint(const Point2DD& _pt) { m_points.push_back(_pt); };
53
56 void setPoints(const std::list<Point2DD>& _points) { m_points = _points; };
57
59 std::list<Point2DD>& getPoints(void) { return m_points; };
60
62 const std::list<Point2DD>& getPoints(void) const { return m_points; };
63
67 void setBackgroundPainter(Painter2D* _painter);
68
70 const Painter2D* getBackgroundPainter(void) const { return m_backgroundPainter; };
71
74 Painter2D* takeBackgroundPainter(void);
75
78 void setOutline(const OutlineF& _outline) { m_outline = _outline; };
79
81 const OutlineF& getOutline(void) const { return m_outline; };
82
85 void setOutlinePainter(Painter2D* _painter) { m_outline.setPainter(_painter); };
86
88 const Painter2D* getOutlinePainter(void) const { return m_outline.painter(); };
89
92 void setOutlineWidth(double _w) { m_outline.setWidth(_w); };
93
95 double getOutlineWidth(void) const { return m_outline.width(); };
96
99 void setFillPolygon(bool _fill) { m_fillPolygon = _fill; };
100
102 bool getFillPolygon(void) const { return m_fillPolygon; };
103
104 private:
105 bool m_fillPolygon;
106 std::list<Point2DD> m_points;
107 Painter2D* m_backgroundPainter;
108 OutlineF m_outline;
109 };
110}
#define OT_FactoryKey_GraphicsPolygonItem
Definition GraphicsPolygonItemCfg.h:18
This file contains defines that may be used simplyfy class creation.
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The GraphicsItemCfg is the base class for all graphics item configurations.
Definition GraphicsItemCfg.h:33
Definition GraphicsPolygonItemCfg.h:24
bool getFillPolygon(void) const
If fill polygon is enabled the polygon will be filled, otherwise only the outline will be drawn.
Definition GraphicsPolygonItemCfg.h:102
double getOutlineWidth(void) const
Outline width.
Definition GraphicsPolygonItemCfg.h:95
void setOutlinePainter(Painter2D *_painter)
Set the outline painter. The item takes ownership of the painter.
Definition GraphicsPolygonItemCfg.h:85
const OutlineF & getOutline(void) const
Outlin.
Definition GraphicsPolygonItemCfg.h:81
void setPoints(const std::list< Point2DD > &_points)
Set the outline points.
Definition GraphicsPolygonItemCfg.h:56
const std::list< Point2DD > & getPoints(void) const
Outline points const reference.
Definition GraphicsPolygonItemCfg.h:62
const Painter2D * getOutlinePainter(void) const
Outline painter.
Definition GraphicsPolygonItemCfg.h:88
const Painter2D * getBackgroundPainter(void) const
Background painter.
Definition GraphicsPolygonItemCfg.h:70
void setFillPolygon(bool _fill)
Set the fill property.
Definition GraphicsPolygonItemCfg.h:99
void setOutline(const OutlineF &_outline)
Set the outline.
Definition GraphicsPolygonItemCfg.h:78
virtual std::string getFactoryKey(void) const override
Returns the key that is used to create an instance of this class in the simple factory.
Definition GraphicsPolygonItemCfg.h:44
std::list< Point2DD > & getPoints(void)
Outline points reference.
Definition GraphicsPolygonItemCfg.h:59
void addPoint(const Point2DD &_pt)
Will append the provided point to the point list.
Definition GraphicsPolygonItemCfg.h:52
void setOutlineWidth(double _w)
Set the outline width.
Definition GraphicsPolygonItemCfg.h:92
The OutlineF class is used to describe how a outline should look like.
Definition Outline.h:161
Definition Painter2D.h:17
2D Point with double values
Definition Point2D.h:144
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30