QCAD
Open Source 2D CAD
RDocumentVariables.h
Go to the documentation of this file.
1 
20 #ifndef RDOCUMENTVARIABLES_H
21 #define RDOCUMENTVARIABLES_H
22 
23 #include "core_global.h"
24 
25 #include "RLayer.h"
26 #include "RObject.h"
27 
28 class RDocument;
29 
38 public:
46 
47 public:
48  RDocumentVariables(RDocument* document);
49  virtual ~RDocumentVariables();
50 
51  static void init();
52 
53  virtual RS::EntityType getType() const {
55  }
56 
57  virtual RDocumentVariables* clone() const {
58  return new RDocumentVariables(*this);
59  }
60 
62  return false;
63  }
64 
65  virtual QPair<QVariant, RPropertyAttributes>
66  getProperty(RPropertyTypeId& propertyTypeId,
67  bool humanReadable = false,
68  bool noAttributes = false);
69 
70  virtual bool setProperty(RPropertyTypeId propertyTypeId,
71  const QVariant& value, RTransaction* transaction=NULL);
72 
73  void clear();
74 
75  QSet<RPropertyTypeId> getCustomPropertyTypeIds() const;
76  void setKnownVariable(RS::KnownVariable key, const RVector& value);
77  void setKnownVariable(RS::KnownVariable key, const QVariant& value);
78  QVariant getKnownVariable(RS::KnownVariable key) const;
79  bool hasKnownVariable(RS::KnownVariable key) const;
80 
82  return currentLayerId;
83  }
84 
86  currentLayerId = id;
87  }
88 
89  RS::Unit getUnit() const {
90  return unit;
91  }
92 
93  void setUnit(RS::Unit u) {
94  QVariant v;
95  v.setValue((int)u);
96  knownVariables.insert(RS::INSUNITS, v);
97  unit = u;
98  }
99 
101  return measurement;
102  }
103 
105  if (m!=RS::Metric && m!=RS::Imperial) {
106  return;
107  }
108 
109  QVariant v;
110  v.setValue((int)m);
111  knownVariables.insert(RS::MEASUREMENT, v);
112  measurement = m;
113  }
114 
115  double getLinetypeScale() const {
116  return linetypeScale;
117  }
118 
119  void setLinetypeScale(double s) {
120  QVariant v;
121  v.setValue((double)s);
122  knownVariables.insert(RS::LTSCALE, v);
123  linetypeScale = s;
124  }
125 
126  QString getDimensionFont() const {
127  return dimensionFont;
128  }
129 
130  void setDimensionFont(const QString& f) {
131  dimensionFont = f;
132  }
133 
134  virtual void print(QDebug dbg) const;
135 
136 private:
138  // TODO:
139  //RLayer::Id currentBlockId;
140  //...
144  QString dimensionFont;
145  QHash<RS::KnownVariable, QVariant> knownVariables;
146 };
147 
149 Q_DECLARE_METATYPE(QSharedPointer<RDocumentVariables>)
150 Q_DECLARE_METATYPE(QSharedPointer<RDocumentVariables>*)
151 
152 #endif
QString dimensionFont
Definition: RDocumentVariables.h:144
void setUnit(RS::Unit u)
Definition: RDocumentVariables.h:93
virtual bool isSelectedForPropertyEditing()
Definition: RDocumentVariables.h:61
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
RS::Measurement getMeasurement() const
Definition: RDocumentVariables.h:100
Definition: RS.h:434
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: RObject.cpp:129
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
Abstract base class for all objects.
Definition: RObject.h:52
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
#define QCADCORE_EXPORT
Definition: core_global.h:10
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: RObject.cpp:94
int Id
Definition: RObject.h:57
Transaction implementation.
Definition: RTransaction.h:74
void setDimensionFont(const QString &f)
Definition: RDocumentVariables.h:130
Measurement
Enum of supported measurement systems.
Definition: RS.h:244
Definition: RS.h:86
RS::Measurement measurement
Definition: RDocumentVariables.h:142
static RPropertyTypeId PropertyHandle
Definition: RDocumentVariables.h:40
virtual RDocumentVariables * clone() const
Definition: RDocumentVariables.h:57
Imperial.
Definition: RS.h:246
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
static RPropertyTypeId PropertyUnit
Definition: RDocumentVariables.h:43
RS::Unit getUnit() const
Definition: RDocumentVariables.h:89
RLayer::Id getCurrentLayerId() const
Definition: RDocumentVariables.h:81
QString getDimensionFont() const
Definition: RDocumentVariables.h:126
KnownVariable
Well established document variables.
Definition: RS.h:329
void setLinetypeScale(double s)
Definition: RDocumentVariables.h:119
static RPropertyTypeId PropertyProtected
Definition: RDocumentVariables.h:41
Definition: RS.h:438
void setMeasurement(RS::Measurement m)
Definition: RDocumentVariables.h:104
Metric.
Definition: RS.h:247
double linetypeScale
Definition: RDocumentVariables.h:143
This type of object is used to store document wide variables.
Definition: RDocumentVariables.h:37
virtual QSet< RPropertyTypeId > getCustomPropertyTypeIds() const
Definition: RObject.cpp:397
RLayer::Id currentLayerId
Definition: RDocumentVariables.h:137
static RPropertyTypeId PropertyLinetypeScale
Definition: RDocumentVariables.h:44
static void init()
Definition: RObject.cpp:61
Unit
Enum of supported units (values correspond to DXF spec).
Definition: RS.h:253
double getLinetypeScale() const
Definition: RDocumentVariables.h:115
Definition: RS.h:429
virtual RS::EntityType getType() const
Definition: RDocumentVariables.h:53
static RPropertyTypeId PropertyCurrentLayerId
Definition: RDocumentVariables.h:42
static RPropertyTypeId PropertyDimensionFont
Definition: RDocumentVariables.h:45
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: RObject.cpp:566
QHash< RS::KnownVariable, QVariant > knownVariables
Definition: RDocumentVariables.h:145
RS::Unit unit
Definition: RDocumentVariables.h:141
void setCurrentLayerId(RLayer::Id id)
Definition: RDocumentVariables.h:85
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RDocumentVariables.h:39