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;
84
92 Polyline(const QList<QPointF>& points, bool closed, const QString& layer_name, const QColor& color)
93 : Entity(etPolyline, layer_name, color)
94 , _points(points)
95 , _isClosed(closed)
96 {}
97};
98
102struct Circle : public Entity
103{
104 QPointF _center;
105 double _radius;
106
114 Circle(const QPointF& center, double radius, const QString& layer_name, const QColor& color)
115 : Entity(etCircle, layer_name, color)
116 , _center(center)
117 , _radius(radius)
118 {}
119};
120
124struct Arc : public Entity
125{
126 QPointF _center;
127 double _radius;
129 double _endAngle;
130
140 Arc(const QPointF& center, double radius, double start_angle, double end_angle, const QString& layer_name, const QColor& color)
141 : Entity(etArc, layer_name, color)
142 , _center(center)
143 , _radius(radius)
144 , _startAngle(start_angle)
145 , _endAngle(end_angle)
146 {}
147};
148
154using EntityWrapper = std::shared_ptr<Entity>;
155using EntityList = QList<EntityWrapper>;
156using LayerEntities = QMap<QString, EntityList>;
157
162{
163 QString _name;
165 QColor _color;
167
168 // Add other layer properties as needed (e.g., linetype, lineweight).
169
171 : _colorIndex(-1)
172 , _isVisible(false)
173 {}
174
182 LayerInfo(const QString& name, int color_index, const QColor& color, bool is_visible)
183 : _name(name)
184 , _colorIndex(color_index)
185 , _color(color)
186 , _isVisible(is_visible)
187 {}
188};
189
193using Layers = QMap<QString, LayerInfo>;
194
195}// namespace sf::dxf
Definition Entities.h:10
std::shared_ptr< Entity > EntityWrapper
LayerEntities holds all parsed entities, organized by layer.
Definition Entities.h:154
QMap< QString, LayerInfo > Layers
Layers holds information for all layers in the DXF file.
Definition Entities.h:193
QList< EntityWrapper > EntityList
Definition Entities.h:155
QMap< QString, EntityList > LayerEntities
Definition Entities.h:156
Represents a DXF ARC entity.
Definition Entities.h:125
double _endAngle
End angle in degrees.
Definition Entities.h:129
double _radius
Definition Entities.h:127
double _startAngle
Start angle in degrees.
Definition Entities.h:128
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:140
QPointF _center
Definition Entities.h:126
Represents a DXF CIRCLE entity.
Definition Entities.h:103
Circle(const QPointF &center, double radius, const QString &layer_name, const QColor &color)
Constructs a Circle entity.
Definition Entities.h:114
double _radius
Definition Entities.h:105
QPointF _center
Definition Entities.h:104
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:162
LayerInfo(const QString &name, int color_index, const QColor &color, bool is_visible)
Constructs a LayerInfo object.
Definition Entities.h:182
bool _isVisible
Definition Entities.h:166
int _colorIndex
AutoCAD Color Index (ACI).
Definition Entities.h:164
QColor _color
Definition Entities.h:165
LayerInfo()
Definition Entities.h:170
QString _name
Definition Entities.h:163
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:83
Polyline(const QList< QPointF > &points, bool closed, const QString &layer_name, const QColor &color)
Constructs a Polyline entity.
Definition Entities.h:92
QList< QPointF > _points
Definition Entities.h:82