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:
53 
54 public:
55  RBlock();
56 
57  RBlock(RDocument* document, const QString& name, const RVector& origin);
58 
59  virtual ~RBlock();
60 
61  static void init();
62 
63  virtual RS::EntityType getType() const {
64  return RS::ObjectBlock;
65  }
66 
67  virtual RBlock* clone() const;
68 
69  QString getName() const {
70  return name;
71  }
72 
73  void setName(const QString& n);
74 
75  bool isFrozen() const {
76  return frozen;
77  }
78 
79  void setFrozen(bool on) {
80  if (QString::compare(name, modelSpaceName, Qt::CaseInsensitive)!=0) {
81  frozen = on;
82  }
83  }
84 
85  bool isAnonymous() const {
86  return anonymous;
87  }
88 
89  void setAnonymous(bool on) {
90  if (QString::compare(name, modelSpaceName, Qt::CaseInsensitive)!=0) {
91  anonymous = on;
92  }
93  }
94 
95  void setOrigin(const RVector& origin) {
96  this->origin = origin;
97  }
98 
99  RVector getOrigin() const {
100  return origin;
101  }
102 
103  bool isLayout() const {
104  return layoutId!=RLayout::INVALID_ID;
105  }
106 
107  void setLayoutId(RLayout::Id layoutId) {
108  this->layoutId = layoutId;
109  }
110 
112  return layoutId;
113  }
114 
115  QString getLayoutName() const;
116 
117  virtual QPair<QVariant, RPropertyAttributes> getProperty(RPropertyTypeId& propertyTypeId,
118  bool humanReadable = false, bool noAttributes = false);
119  virtual bool setProperty(RPropertyTypeId propertyTypeId,
120  const QVariant& value, RTransaction* transaction=NULL);
121 
122  virtual bool isSelectedForPropertyEditing();
123 
124 public:
125  static const QString modelSpaceName;
126  static const QString paperSpaceName;
127 
128 protected:
132  virtual void print(QDebug dbg) const;
133 
134 private:
135  QString name;
136  bool frozen;
137  bool anonymous;
140 };
141 
142 
143 Q_DECLARE_METATYPE(QSharedPointer<RBlock>)
144 Q_DECLARE_METATYPE(QSharedPointer<RBlock>*)
147 
148 #endif
static RPropertyTypeId PropertyOriginZ
Definition: RBlock.h:51
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual RS::EntityType getType() const
Definition: RBlock.h:63
bool frozen
Definition: RBlock.h:136
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:125
Abstract base class for all objects.
Definition: RObject.h:48
static RPropertyTypeId PropertyLayout
Definition: RBlock.h:52
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:103
Transaction implementation.
Definition: RTransaction.h:70
RVector origin
Definition: RBlock.h:138
void setOrigin(const RVector &origin)
Definition: RBlock.h:95
static const QString paperSpaceName
Definition: RBlock.h:126
QString getName() const
Definition: RBlock.h:69
bool anonymous
Definition: RBlock.h:137
static const Id INVALID_ID
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RObject.h:54
static RPropertyTypeId PropertyName
Definition: RBlock.h:47
void setLayoutId(RLayout::Id layoutId)
Definition: RBlock.h:107
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:99
bool isAnonymous() const
Definition: RBlock.h:85
QString name
Definition: RBlock.h:135
void setAnonymous(bool on)
Definition: RBlock.h:89
RLayout::Id layoutId
Definition: RBlock.h:139
static void init()
Definition: RObject.cpp:61
static RPropertyTypeId PropertyFrozen
Definition: RBlock.h:48
static RPropertyTypeId PropertyOriginY
Definition: RBlock.h:50
virtual bool isSelectedForPropertyEditing()=0
static RPropertyTypeId PropertyOriginX
Definition: RBlock.h:49
RLayout::Id getLayoutId() const
Definition: RBlock.h:111
void setFrozen(bool on)
Definition: RBlock.h:79
bool isFrozen() const
Definition: RBlock.h:75
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