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 (!isModelSpace()) {
83  frozen = on;
84  }
85  }
86 
87  bool isAnonymous() const {
88  return anonymous;
89  }
90 
91  void setAnonymous(bool on) {
92  if (!isModelSpace()) {
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 isModelSpace() const {
106  return QString::compare(name, modelSpaceName, Qt::CaseInsensitive)==0;
107  }
108 
109  bool isLayout() const {
110  return layoutId!=RLayout::INVALID_ID;
111  }
112 
113  void setLayoutId(RLayout::Id layoutId) {
114  this->layoutId = layoutId;
115  }
116 
118  return layoutId;
119  }
120 
121  QString getLayoutName() const;
122 
123  virtual QPair<QVariant, RPropertyAttributes> getProperty(RPropertyTypeId& propertyTypeId,
124  bool humanReadable = false, bool noAttributes = false);
125  virtual bool setProperty(RPropertyTypeId propertyTypeId,
126  const QVariant& value, RTransaction* transaction=NULL);
127 
128  virtual bool isSelectedForPropertyEditing();
129 
130 public:
131  static const QString modelSpaceName;
132  static const QString paperSpaceName;
133 
134 protected:
138  virtual void print(QDebug dbg) const;
139 
140 private:
141  QString name;
142  bool frozen;
143  bool anonymous;
146 };
147 
148 
149 Q_DECLARE_METATYPE(QSharedPointer<RBlock>)
150 Q_DECLARE_METATYPE(QSharedPointer<RBlock>*)
153 
154 #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:142
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-2017 by Andrew Mustun.
Definition: RBlock.h:131
Abstract base class for all objects.
Definition: RObject.h:52
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-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
bool isLayout() const
Definition: RBlock.h:109
Transaction implementation.
Definition: RTransaction.h:74
RVector origin
Definition: RBlock.h:144
void setOrigin(const RVector &origin)
Definition: RBlock.h:97
static const QString paperSpaceName
Definition: RBlock.h:132
QString getName() const
Definition: RBlock.h:71
bool anonymous
Definition: RBlock.h:143
static const Id INVALID_ID
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RObject.h:58
static RPropertyTypeId PropertyName
Definition: RBlock.h:49
void setLayoutId(RLayout::Id layoutId)
Definition: RBlock.h:113
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
bool isModelSpace() const
Definition: RBlock.h:105
static RPropertyTypeId PropertyHandle
Definition: RBlock.h:48
bool isAnonymous() const
Definition: RBlock.h:87
QString name
Definition: RBlock.h:141
void setAnonymous(bool on)
Definition: RBlock.h:91
RLayout::Id layoutId
Definition: RBlock.h:145
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:117
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:566
static RPropertyTypeId PropertyCustom
Definition: RBlock.h:46
virtual RObject * clone() const =0