QCAD
Open Source 2D CAD
RBlockReferenceData.h
Go to the documentation of this file.
1 
20 #ifndef RBLOCKREFERENCEDATA_H
21 #define RBLOCKREFERENCEDATA_H
22 
23 #include "core_global.h"
24 
25 #include "RBox.h"
26 #include "REntity.h"
27 #include "RVector.h"
28 #include "RBlock.h"
29 
30 class RDocument;
31 
40 
41 friend class RBlockReferenceEntity;
42 friend class RViewportEntity;
43 
44 protected:
46 
47 public:
49  RBlockReferenceData(RBlock::Id referencedBlockId,
50  const RVector& position, const RVector& scaleFactors,
51  double angle,
52  int columnCount=1, int rowCount=1,
53  double columnSpacing=0, double rowSpacing=0);
54 
55  virtual RS::EntityType getType() const {
56  return RS::EntityBlockRef;
57  }
58 
59  virtual QList<RBox> getBoundingBoxes(bool ignoreEmpty=false) const;
60  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
61 
62  virtual QList<RRefPoint> getInternalReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
63  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
64  virtual RVector getVectorTo(const RVector& point, bool limited = true, double strictRange = RMAXDOUBLE) const;
65  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0,
66  bool draft = false, double strictRange = RMAXDOUBLE) const;
67 
68  RBox getQueryBoxInBlockCoordinates(const RBox& box) const;
69  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const;
70 
71  //virtual void setSelected(bool on);
72 
73  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
74  virtual bool move(const RVector& offset);
75  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
76  virtual bool mirror(const RLine& axis);
77  virtual bool scale(const RVector& scaleFactors,
78  const RVector& center = RDEFAULT_RVECTOR);
79 
80  void setReferencedBlockId(RBlock::Id blockId);
81 
82  void groundReferencedBlockId() const;
83 
85  return referencedBlockId;
86  }
87 
88  void setReferencedBlockName(const QString& blockName);
89  QString getReferencedBlockName() const;
90 
91  RVector getPosition() const {
92  return position;
93  }
94  void setPosition(const RVector& p);
95 
97  return scaleFactors;
98  }
99  void setScaleFactors(const RVector& sf);
100 
101  double getRotation() const {
102  return rotation;
103  }
104  void setRotation(double r);
105 
106  int getColumnCount() const {
107  return columnCount;
108  }
109  void setColumnCount(int c) {
110  columnCount = c;
111  }
112 
113  int getRowCount() const {
114  return rowCount;
115  }
116  void setRowCount(int c) {
117  rowCount = c;
118  }
119 
120  double getColumnSpacing() const {
121  return columnSpacing;
122  }
123  void setColumnSpacing(double s) {
124  columnSpacing = s;
125  }
126 
127  double getRowSpacing() const {
128  return rowSpacing;
129  }
130  void setRowSpacing(double s) {
131  rowSpacing = s;
132  }
133 
134  virtual void update() const;
135  virtual void update(RObject::Id entityId) const;
136 
137  QSharedPointer<REntity> queryEntity(REntity::Id entityId) const;
138  bool applyTransformationTo(REntity& entity) const;
139  RVector getColumnRowOffset(int col, int row) const;
140  void applyColumnRowOffsetTo(REntity& entity, int col, int row) const;
141  RVector mapToBlock(const RVector& v) const;
142 
143 
144 private:
148  double rotation;
150  int rowCount;
152  double rowSpacing;
153  mutable QList<RBox> boundingBoxes;
154  mutable QList<RBox> boundingBoxesIgnoreEmpty;
155  mutable QMap<REntity::Id, QSharedPointer<REntity> > cache;
156 };
157 
162 
163 #endif
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:65
void setRowSpacing(double s)
Definition: RBlockReferenceData.h:130
Viewport entity.
Definition: RViewportEntity.h:38
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
virtual bool mirror(const RLine &axis)
Definition: REntityData.cpp:547
QMap< REntity::Id, QSharedPointer< REntity > > cache
Definition: RBlockReferenceData.h:155
void setColumnCount(int c)
Definition: RBlockReferenceData.h:109
RVector scaleFactors
Definition: RBlockReferenceData.h:147
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
double getColumnSpacing() const
Definition: RBlockReferenceData.h:120
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:104
RBlock::Id getReferencedBlockId() const
Definition: RBlockReferenceData.h:84
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:507
void setRotation(double r)
Definition: RViewportEntity.h:169
#define QCADCORE_EXPORT
Definition: core_global.h:10
int Id
Definition: RObject.h:57
virtual QList< RBox > getBoundingBoxes(bool ignoreEmpty=false) const
Definition: REntityData.h:140
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:261
int getColumnCount() const
Definition: RBlockReferenceData.h:106
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
RBlock::Id referencedBlockId
Definition: RBlockReferenceData.h:145
double columnSpacing
Definition: RBlockReferenceData.h:151
void setColumnSpacing(double s)
Definition: RBlockReferenceData.h:123
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:527
void setRowCount(int c)
Definition: RBlockReferenceData.h:116
int getRowCount() const
Definition: RBlockReferenceData.h:113
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:275
Base class for all entity classes.
Definition: REntity.h:64
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
RVector position
Definition: RBlockReferenceData.h:146
Q_DECLARE_METATYPE(RMath *)
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:517
double rowSpacing
Definition: RBlockReferenceData.h:152
#define RMAXDOUBLE
Definition: RMath.h:63
Defines the geometry and appearance of a block reference entity.
Definition: RBlockReferenceData.h:39
double rotation
Definition: RBlockReferenceData.h:148
int rowCount
Definition: RBlockReferenceData.h:150
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
Low-level mathematical representation of a line.
Definition: RLine.h:41
double getRotation() const
Definition: RBlockReferenceData.h:101
Block reference.
Definition: RS.h:92
Definition: RS.h:132
RVector getPosition() const
Definition: RBlockReferenceData.h:91
virtual RS::EntityType getType() const
Definition: RBlockReferenceData.h:55
virtual QList< RRefPoint > getInternalReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const
Can be overwritten to return internal, resolved reference points.
Definition: REntityData.h:294
QList< RBox > boundingBoxesIgnoreEmpty
Definition: RBlockReferenceData.h:154
int columnCount
Definition: RBlockReferenceData.h:149
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:408
double getRowSpacing() const
Definition: RBlockReferenceData.h:127
Block reference entity.
Definition: RBlockReferenceEntity.h:38
RViewportData data
Definition: RViewportEntity.h:193
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:371
QList< RBox > boundingBoxes
Definition: RBlockReferenceData.h:153
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
RDocument * document
Definition: RObject.h:271
RVector getScaleFactors() const
Definition: RBlockReferenceData.h:96