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  bool showOnRequest = false);
70 
71  virtual bool setProperty(RPropertyTypeId propertyTypeId,
72  const QVariant& value, RTransaction* transaction=NULL);
73 
74  void clear();
75 
76  QSet<RPropertyTypeId> getCustomPropertyTypeIds() const;
77  void setKnownVariable(RS::KnownVariable key, const RVector& value);
78  void setKnownVariable(RS::KnownVariable key, const QVariant& value);
79  QVariant getKnownVariable(RS::KnownVariable key) const;
80  bool hasKnownVariable(RS::KnownVariable key) const;
81 
83  return currentLayerId;
84  }
85 
87  currentLayerId = id;
88  }
89 
90  RS::Unit getUnit() const {
91  return unit;
92  }
93 
94  void setUnit(RS::Unit u) {
95  QVariant v;
96  v.setValue((int)u);
97  knownVariables.insert(RS::INSUNITS, v);
98  unit = u;
99  }
100 
102  return measurement;
103  }
104 
106  if (m!=RS::Metric && m!=RS::Imperial) {
107  return;
108  }
109 
110  QVariant v;
111  v.setValue((int)m);
112  knownVariables.insert(RS::MEASUREMENT, v);
113  measurement = m;
114  }
115 
116  double getLinetypeScale() const {
117  return linetypeScale;
118  }
119 
120  void setLinetypeScale(double s) {
121  QVariant v;
122  v.setValue((double)s);
123  knownVariables.insert(RS::LTSCALE, v);
124  linetypeScale = s;
125  }
126 
127  QString getDimensionFont() const {
128  return dimensionFont;
129  }
130 
131  void setDimensionFont(const QString& f) {
132  dimensionFont = f;
133  }
134 
135  virtual void print(QDebug dbg) const;
136 
137 private:
139  // TODO:
140  //RLayer::Id currentBlockId;
141  //...
145  QString dimensionFont;
146  QHash<RS::KnownVariable, QVariant> knownVariables;
147 };
148 
150 Q_DECLARE_METATYPE(QSharedPointer<RDocumentVariables>)
151 Q_DECLARE_METATYPE(QSharedPointer<RDocumentVariables>*)
152 
153 #endif
QString dimensionFont
Definition: RDocumentVariables.h:145
void setUnit(RS::Unit u)
Definition: RDocumentVariables.h:94
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:101
Definition: RS.h:437
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: RObject.cpp:132
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
Abstract base class for all objects.
Definition: RObject.h:61
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
#define QCADCORE_EXPORT
Definition: core_global.h:10
int Id
Definition: RObject.h:66
Transaction implementation.
Definition: RTransaction.h:74
void setDimensionFont(const QString &f)
Definition: RDocumentVariables.h:131
Measurement
Enum of supported measurement systems.
Definition: RS.h:247
Definition: RS.h:86
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false, bool showOnRequest=false)
Definition: RObject.cpp:96
RS::Measurement measurement
Definition: RDocumentVariables.h:143
static RPropertyTypeId PropertyHandle
Definition: RDocumentVariables.h:40
virtual RDocumentVariables * clone() const
Definition: RDocumentVariables.h:57
Imperial.
Definition: RS.h:249
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:90
RLayer::Id getCurrentLayerId() const
Definition: RDocumentVariables.h:82
QString getDimensionFont() const
Definition: RDocumentVariables.h:127
KnownVariable
Well established document variables.
Definition: RS.h:332
void setLinetypeScale(double s)
Definition: RDocumentVariables.h:120
static RPropertyTypeId PropertyProtected
Definition: RDocumentVariables.h:41
Definition: RS.h:441
void setMeasurement(RS::Measurement m)
Definition: RDocumentVariables.h:105
Metric.
Definition: RS.h:250
double linetypeScale
Definition: RDocumentVariables.h:144
This type of object is used to store document wide variables.
Definition: RDocumentVariables.h:37
virtual QSet< RPropertyTypeId > getCustomPropertyTypeIds() const
Definition: RObject.cpp:411
RLayer::Id currentLayerId
Definition: RDocumentVariables.h:138
static RPropertyTypeId PropertyLinetypeScale
Definition: RDocumentVariables.h:44
static void init()
Definition: RObject.cpp:60
Unit
Enum of supported units (values correspond to DXF spec).
Definition: RS.h:256
double getLinetypeScale() const
Definition: RDocumentVariables.h:116
Definition: RS.h:432
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:628
QHash< RS::KnownVariable, QVariant > knownVariables
Definition: RDocumentVariables.h:146
RS::Unit unit
Definition: RDocumentVariables.h:142
void setCurrentLayerId(RLayer::Id id)
Definition: RDocumentVariables.h:86
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RDocumentVariables.h:39