Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
Entities.h
Go to the documentation of this file.
1#pragma once
2#include <QColor>
3#include <QList>
4#include <QMap>
5#include <QPointF>
6#include <QString>
7#include <memory>
8
9namespace sf::dxf
10{
11
15struct Entity
16{
28
30 QString _layerName;
31 QColor _color;
32
39 Entity(Type type, const QString& layer_name, const QColor& color)
40 : _type(type)
41 , _layerName(layer_name)
42 , _color(color)
43 {}
44
48 virtual ~Entity() = default;
49};
50
54struct Line : public Entity
55{
56 QPointF _startPoint;
57 QPointF _endPoint;
58
66 Line(const QPointF& start, const QPointF& end, const QString& layer_name, const QColor& color)
67 : Entity(etLine, layer_name, color)
68 , _startPoint(start)
69 , _endPoint(end)
70 {}
71};
72
80struct Polyline : public Entity
81{
82 QList<QPointF> _points;
85
93 Polyline(const QList<QPointF>& points, bool closed, const QString& layer_name, const QColor& color)
94 : Entity(etPolyline, layer_name, color)
95 , _points(points)
96 , _isClosed(closed)
97 {}
98};
99
103struct Circle : public Entity
104{
105 QPointF _center;
106 double _radius;
107
115 Circle(const QPointF& center, double radius, const QString& layer_name, const QColor& color)
116 : Entity(etCircle, layer_name, color)
117 , _center(center)
118 , _radius(radius)
119 {}
120};
121
125struct Arc : public Entity
126{
127 QPointF _center;
128 double _radius;
130 double _endAngle;
131
141 Arc(const QPointF& center, double radius, double start_angle, double end_angle, const QString& layer_name, const QColor& color)
142 : Entity(etArc, layer_name, color)
143 , _center(center)
144 , _radius(radius)
145 , _startAngle(start_angle)
146 , _endAngle(end_angle)
147 {}
148};
149
154{
156 QString _name;
160 QColor _color;
163
168 : _colorIndex(-1)
169 , _isVisible(false)
170 {}
171
179 LayerInfo(const QString& name, int color_index, const QColor& color, bool is_visible)
180 : _name(name)
181 , _colorIndex(color_index)
182 , _color(color)
183 , _isVisible(is_visible)
184 {}
185};
186
191using LayerEntities = QMap<QString, QList<std::shared_ptr<Entity>>>;
192
196using Entities = LayerEntities::mapped_type;
197
201using Layers = QMap<QString, LayerInfo>;
202
203}// namespace sf::dxf
Definition Entities.h:10
QMap< QString, QList< std::shared_ptr< Entity > > > LayerEntities
LayerEntities holds all parsed entities, organized by layer. Using std::shared_ptr for automatic memo...
Definition Entities.h:191
LayerEntities::mapped_type Entities
Entities type from the map for holding entities of a layer.
Definition Entities.h:196
QMap< QString, LayerInfo > Layers
Layers holds information for all layers in the DXF file.
Definition Entities.h:201
Represents a DXF ARC entity.
Definition Entities.h:126
double _endAngle
End-angle in degrees.
Definition Entities.h:130
double _radius
Radius in undefined units.
Definition Entities.h:128
double _startAngle
Start-angle in degrees.
Definition Entities.h:129
Arc(const QPointF &center, double radius, double start_angle, double end_angle, const QString &layer_name, const QColor &color)
Constructs an Arc entity.
Definition Entities.h:141
QPointF _center
Venter point in undefined units.
Definition Entities.h:127
Represents a DXF CIRCLE entity.
Definition Entities.h:104
Circle(const QPointF &center, double radius, const QString &layer_name, const QColor &color)
Constructs a Circle entity.
Definition Entities.h:115
double _radius
Definition Entities.h:106
QPointF _center
Definition Entities.h:105
Base class for all DXF geometric entities.
Definition Entities.h:16
Type
Enumeration of supported DXF entity types.
Definition Entities.h:21
@ etArc
Represents an ARC entity.
Definition Entities.h:25
@ etPolyline
Represents a POLYLINE entity.
Definition Entities.h:23
@ etCircle
Represents a CIRCLE entity.
Definition Entities.h:24
@ etLine
Represents a LINE entity.
Definition Entities.h:22
@ etUnknown
Represents an unknown or unsupported entity type.
Definition Entities.h:26
QString _layerName
Definition Entities.h:30
QColor _color
Color of the entity, derived from layer or entity itself.
Definition Entities.h:31
Entity(Type type, const QString &layer_name, const QColor &color)
Constructs a DxfEntity object.
Definition Entities.h:39
Type _type
Definition Entities.h:29
virtual ~Entity()=default
Virtual destructor for proper polymorphic cleanup.
LayerInfo holds properties for each layer.
Definition Entities.h:154
LayerInfo(const QString &name, int color_index, const QColor &color, bool is_visible)
Initializing constructor a LayerInfo object.
Definition Entities.h:179
bool _isVisible
Flag on the visibility of the layer.
Definition Entities.h:162
int _colorIndex
AutoCAD Color Index (ACI).
Definition Entities.h:158
QColor _color
Qt color value of the index.
Definition Entities.h:160
LayerInfo()
Default constructor.
Definition Entities.h:167
QString _name
NAme of the layer.
Definition Entities.h:156
Represents a DXF LINE entity.
Definition Entities.h:55
QPointF _endPoint
Definition Entities.h:57
QPointF _startPoint
Definition Entities.h:56
Line(const QPointF &start, const QPointF &end, const QString &layer_name, const QColor &color)
Constructs a Line entity.
Definition Entities.h:66
Represents a DXF POLYLINE entity.
Definition Entities.h:81
bool _isClosed
Whether the polyline is closed.
Definition Entities.h:84
Polyline(const QList< QPointF > &points, bool closed, const QString &layer_name, const QColor &color)
Constructs a Polyline entity.
Definition Entities.h:93
QList< QPointF > _points
Definition Entities.h:82