QCAD
Open Source 2D CAD
RBlock.h
Go to the documentation of this file.
1 
20 #ifndef RBLOCK_H
21 #define RBLOCK_H
22 
23 #include "core_global.h"
24 
25 #include <QString>
26 #include <QDebug>
27 
28 #include "RLayout.h"
29 #include "RGlobal.h"
30 #include "RObject.h"
31 #include "RVector.h"
32 #include "RPropertyTypeId.h"
33 
34 class RDocument;
35 class RTransaction;
36 
45 public:
55 
56 public:
57  RBlock();
58 
59  RBlock(RDocument* document, const QString& name, const RVector& origin);
60 
61  virtual ~RBlock();
62 
63  static void init();
64 
65  virtual RS::EntityType getType() const {
66  return RS::ObjectBlock;
67  }
68 
69  virtual RBlock* clone() const;
70 
71  QString getName() const {
72  return name;
73  }
74 
75  void setName(const QString& n);
76 
77  bool isFrozen() const {
78  return frozen;
79  }
80 
81  void setFrozen(bool on) {
82  if (QString::compare(name, modelSpaceName, Qt::CaseInsensitive)!=0) {
83  frozen = on;
84  }
85  }
86 
87  bool isAnonymous() const {
88  return anonymous;
89  }
90 
91  void setAnonymous(bool on) {
92  if (QString::compare(name, modelSpaceName, Qt::CaseInsensitive)!=0) {
93  anonymous = on;
94  }
95  }
96 
97  void setOrigin(const RVector& origin) {
98  this->origin = origin;
99  }
100 
101  RVector getOrigin() const {
102  return origin;
103  }
104 
105  bool isLayout() const {
106  return layoutId!=RLayout::INVALID_ID;
107  }
108 
109  void setLayoutId(RLayout::Id layoutId) {
110  this->layoutId = layoutId;
111  }
112 
114  return layoutId;
115  }
116 
117  QString getLayoutName() const;
118 
119  virtual QPair<QVariant, RPropertyAttributes> getProperty(RPropertyTypeId& propertyTypeId,
120  bool humanReadable = false, bool noAttributes = false);
121  virtual bool setProperty(RPropertyTypeId propertyTypeId,
122  const QVariant& value, RTransaction* transaction=NULL);
123 
124  virtual bool isSelectedForPropertyEditing();
125 
126 public:
127  static const QString modelSpaceName;
128  static const QString paperSpaceName;
129 
130 protected:
134  virtual void print(QDebug dbg) const;
135 
136 private:
137  QString name;
138  bool frozen;
139  bool anonymous;
142 };
143 
144 
145 Q_DECLARE_METATYPE(QSharedPointer<RBlock>)
146 Q_DECLARE_METATYPE(QSharedPointer<RBlock>*)
149 
150 #endif
static RPropertyTypeId PropertyOriginZ
Definition: RBlock.h:53
static RPropertyTypeId PropertyType
Definition: RBlock.h:47
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual RS::EntityType getType() const
Definition: RBlock.h:65
bool frozen
Definition: RBlock.h:138
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
static const QString modelSpaceName
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RBlock.h:127
Abstract base class for all objects.
Definition: RObject.h:48
static RPropertyTypeId PropertyLayout
Definition: RBlock.h:54
Definition: RS.h:80
Represents a block definition in a drawing.
Definition: RBlock.h:44
Copyright (c) 2011-2016 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:53
bool isLayout() const
Definition: RBlock.h:105
Transaction implementation.
Definition: RTransaction.h:74
RVector origin
Definition: RBlock.h:140
void setOrigin(const RVector &origin)
Definition: RBlock.h:97
static const QString paperSpaceName
Definition: RBlock.h:128
QString getName() const
Definition: RBlock.h:71
bool anonymous
Definition: RBlock.h:139
static const Id INVALID_ID
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RObject.h:54
static RPropertyTypeId PropertyName
Definition: RBlock.h:49
void setLayoutId(RLayout::Id layoutId)
Definition: RBlock.h:109
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
RVector getOrigin() const
Definition: RBlock.h:101
static RPropertyTypeId PropertyHandle
Definition: RBlock.h:48
bool isAnonymous() const
Definition: RBlock.h:87
QString name
Definition: RBlock.h:137
void setAnonymous(bool on)
Definition: RBlock.h:91
RLayout::Id layoutId
Definition: RBlock.h:141
static void init()
Definition: RObject.cpp:61
static RPropertyTypeId PropertyFrozen
Definition: RBlock.h:50
static RPropertyTypeId PropertyOriginY
Definition: RBlock.h:52
virtual bool isSelectedForPropertyEditing()=0
static RPropertyTypeId PropertyOriginX
Definition: RBlock.h:51
RLayout::Id getLayoutId() const
Definition: RBlock.h:113
void setFrozen(bool on)
Definition: RBlock.h:81
bool isFrozen() const
Definition: RBlock.h:77
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: RObject.cpp:512
static RPropertyTypeId PropertyCustom
Definition: RBlock.h:46
virtual RObject * clone() const =0