QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RToleranceData.h
Go to the documentation of this file.
1
20#ifndef RTOLERANCEDATA_H
21#define RTOLERANCEDATA_H
22
23#include "entity_global.h"
24
25#include "REntityData.h"
26#include "RVector.h"
27
28class RDocument;
29class RLine;
30class RRefPoint;
31class RPolyline;
32class RTextData;
33
34#ifndef RDEFAULT_MIN1
35#define RDEFAULT_MIN1 -1
36#endif
37
46 friend class RToleranceEntity;
47
48protected:
49 RToleranceData(RDocument* document, const RToleranceData& data);
50
51public:
53
54 virtual RS::EntityType getType() const {
56 }
57 virtual RShape* castToShape() {
58 return NULL;
59 }
60
62 return location;
63 }
64
65 void setLocation(const RVector& l) {
66 location = l;
67 update();
68 }
69
71 return direction;
72 }
73
74 void setDirection(const RVector& d) {
75 direction = d;
76 update();
77 }
78
79 QList<QStringList> getFields() const;
80
81 QString getText() const {
82 return text;
83 }
84 void setText(const QString& t) {
85 text = t;
86 update();
87 }
88// void addField(const QString& t) {
89// text += "%%v" + t;
90// }
91// void addLineBreak() {
92// text += "^J";
93// }
94
95 double getDimtxt(bool scale = true) const;
96 void setDimtxt(double f);
97
98 double getDimscale() const;
99 void setDimscale(double f);
100
101 //double getDimscale(bool fromDocument=true) const;
102 //void setDimScaleOverride(double v);
103
104
105 virtual void scaleVisualProperties(double scaleFactor);
106
107// void setPolyline(const RPolyline& polyline) {
108// *((RPolyline*)this) = polyline;
109// }
110
111 QList<RVector> getCorners() const;
112 QList<RVector> getMiddels() const;
113
114 virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
115
116 virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
117
118 virtual bool move(const RVector& offset);
119 virtual bool rotate(double rotation, const RVector& center);
120 virtual bool scale(const RVector& scaleFactors, const RVector& center);
121 virtual bool mirror(const RLine& axis);
122 virtual bool flipHorizontal();
123 virtual bool flipVertical();
124
125 QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
126 //return RPolyline::getExploded(segments);
127 return QList<QSharedPointer<RShape> >();
128 }
129
130 //virtual bool scale(const RVector& scaleFactors, const RVector& center);
131 //virtual bool stretch(const RPolyline& area, const RVector& offset);
132
133 virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false, QList<RObject::Id>* entityIds = NULL) const;
134
135 virtual void update() const;
136
137 QList<RTextData> getTextLabels() const;
138 QList<RLine> getFrame() const;
139 int getRows() const {
140 return divisions.length();
141 }
142
144
145 virtual RVector getVectorTo(const RVector& point, bool limited=true, double strictRange = RMAXDOUBLE) const;
146
148 dimscale = -1.0;
149 dimtxt = -1.0;
150 update();
151 }
152
153// bool hasOverrides() const {
154// return overrides.isValid();
155// }
156
157// bool hasOverride(RS::KnownVariable key) const {
158// return overrides.hasOverride(key);
159// }
160
161// RDimStyleData getOverrides() const {
162// return overrides;
163// }
164
165private:
169 QString text;
171 //double dimScaleOverride;
174
175 double dimscale;
176 double dimtxt;
177
178 // TODO: add alignment (top, bottom, left, right)
179 // keep tolerance aligned when text, scale, etc. changes
180 // store alignement in DXF/DWG as custom property
181
182 mutable QList<QList<double> > divisions;
183 mutable bool joinFirstField;
184};
185
189Q_DECLARE_METATYPE(QSharedPointer<RToleranceData>)
190
191#endif
#define RDEFAULT_RBOX
Definition RBox.h:35
#define RDEFAULT_MIN1
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RExplodable.h:30
Q_DECLARE_METATYPE(RMath *)
#define RMAXDOUBLE
Definition RMath.h:66
Represents a box e.g.
Definition RBox.h:46
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
Base class for all entity data classes.
Definition REntityData.h:65
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition REntityData.cpp:675
virtual bool flipHorizontal()
Definition REntityData.cpp:729
virtual RVector getPointOnEntity() const
Definition REntityData.cpp:372
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint, Qt::KeyboardModifiers modifiers=Qt::NoModifier)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
virtual void scaleVisualProperties(double scaleFactor)
Definition REntityData.cpp:709
virtual bool flipVertical()
Definition REntityData.cpp:733
virtual bool mirror(const RLine &axis)
Definition REntityData.cpp:715
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition REntityData.cpp:685
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty).
Definition REntityData.h:415
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition REntityData.cpp:695
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false, QList< RObject::Id > *entityIds=NULL) const
Definition REntityData.h:111
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
Definition REntityData.cpp:551
Low-level mathematical representation of a line.
Definition RLine.h:41
int Id
Definition RObject.h:69
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition RPolyline.h:50
Represents a reference point of an entity.
Definition RRefPoint.h:18
EntityType
Entity types used for property handling / filtering.
Definition RS.h:227
@ EntityTolerance
Tolerance.
Definition RS.h:278
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition RS.h:293
@ RenderTop
Definition RS.h:294
Interface for geometrical shape classes.
Definition RShape.h:72
Text entity data class.
Definition RTextData.h:38
Tolerance entity data class.
Definition RToleranceData.h:45
int getRows() const
Definition RToleranceData.h:139
RVector getDirection() const
Definition RToleranceData.h:70
RVector location
Definition RToleranceData.h:166
RVector direction
Definition RToleranceData.h:167
void setText(const QString &t)
Definition RToleranceData.h:84
virtual RShape * castToShape()
Definition RToleranceData.h:57
QString text
Text code, e.g.
Definition RToleranceData.h:169
virtual RS::EntityType getType() const
Definition RToleranceData.h:54
QString getText() const
Definition RToleranceData.h:81
double dimtxt
Definition RToleranceData.h:176
double dimscale
Definition RToleranceData.h:175
void setLocation(const RVector &l)
Definition RToleranceData.h:65
void setDirection(const RVector &d)
Definition RToleranceData.h:74
QList< QList< double > > divisions
Definition RToleranceData.h:182
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition RToleranceData.h:125
bool joinFirstField
Definition RToleranceData.h:183
RVector getLocation() const
Definition RToleranceData.h:61
RObject::Id dimToleranceBlockId
Dimension scale.
Definition RToleranceData.h:173
void clearStyleOverrides()
Definition RToleranceData.h:147
Tolerance entity class.
Definition RToleranceEntity.h:53
Represents a 3d vector (x/y/z).
Definition RVector.h:47
#define QCADENTITY_EXPORT
Definition entity_global.h:10
void scale(void e, void factor, void focusPoint)
Scales the given entity or shape by the given factor with the given focus point.
Definition simple_modify.js:15
#define NULL
Definition opennurbs_system.h:256