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 QList<RBox> getBoundingBoxes(bool ignoreEmpty=false) const;
56  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
57 
58  virtual QList<RVector> getInternalReferencePoints(
60  virtual QList<RVector> getReferencePoints(
62  virtual RVector getVectorTo(const RVector& point,
63  bool limited = true, double strictRange = RMAXDOUBLE) const;
64  virtual double getDistanceTo(const RVector& point,
65  bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
66 
67  RBox getQueryBoxInBlockCoordinates(const RBox& box) const;
68  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
69 
70  //virtual void setSelected(bool on);
71 
72  virtual bool moveReferencePoint(const RVector& referencePoint,
73  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  referencedBlockId = RBlock::INVALID_ID;
84  }
85 
87  return referencedBlockId;
88  }
89 
90  void setReferencedBlockName(const QString& blockName);
91  QString getReferencedBlockName() const;
92 
93  RVector getPosition() const {
94  return position;
95  }
96  void setPosition(const RVector& p);
97 
99  return scaleFactors;
100  }
101  void setScaleFactors(const RVector& sf);
102 
103  double getRotation() const {
104  return rotation;
105  }
106  void setRotation(double r);
107 
108  int getColumnCount() const {
109  return columnCount;
110  }
111  void setColumnCount(int c) {
112  columnCount = c;
113  }
114 
115  int getRowCount() const {
116  return rowCount;
117  }
118  void setRowCount(int c) {
119  rowCount = c;
120  }
121 
122  double getColumnSpacing() const {
123  return columnSpacing;
124  }
125  void setColumnSpacing(double s) {
126  columnSpacing = s;
127  }
128 
129  double getRowSpacing() const {
130  return rowSpacing;
131  }
132  void setRowSpacing(double s) {
133  rowSpacing = s;
134  }
135 
136  virtual void update() const;
137  virtual void update(RObject::Id entityId) const;
138 
139  QSharedPointer<REntity> queryEntity(REntity::Id entityId) const;
140  bool applyTransformationTo(REntity& entity) const;
141  RVector getColumnRowOffset(int col, int row) const;
142  void applyColumnRowOffsetTo(REntity& entity, int col, int row) const;
143  RVector mapToBlock(const RVector& v) const;
144 
145 
146 private:
150  double rotation;
152  int rowCount;
154  double rowSpacing;
155  mutable QList<RBox> boundingBoxes;
156  mutable QList<RBox> boundingBoxesIgnoreEmpty;
157  mutable QMap<REntity::Id, QSharedPointer<REntity> > cache;
158 };
159 
164 
165 #endif
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:64
void setRowSpacing(double s)
Definition: RBlockReferenceData.h:132
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:523
QMap< REntity::Id, QSharedPointer< REntity > > cache
Definition: RBlockReferenceData.h:157
void setColumnCount(int c)
Definition: RBlockReferenceData.h:111
RVector scaleFactors
Definition: RBlockReferenceData.h:149
double getColumnSpacing() const
Definition: RBlockReferenceData.h:122
RBlock::Id getReferencedBlockId() const
Definition: RBlockReferenceData.h:86
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:483
#define QCADCORE_EXPORT
Definition: core_global.h:10
int Id
Definition: RObject.h:53
virtual QList< RBox > getBoundingBoxes(bool ignoreEmpty=false) const
Definition: REntityData.h:121
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:247
virtual QList< RVector > getInternalReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const
Can be overwritten to return internal, resolved reference points.
Definition: REntityData.h:268
static const Id INVALID_ID
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RObject.h:54
int getColumnCount() const
Definition: RBlockReferenceData.h:108
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:128
RBlock::Id referencedBlockId
Definition: RBlockReferenceData.h:147
double columnSpacing
Definition: RBlockReferenceData.h:153
void setColumnSpacing(double s)
Definition: RBlockReferenceData.h:125
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:503
void setRowCount(int c)
Definition: RBlockReferenceData.h:118
int getRowCount() const
Definition: RBlockReferenceData.h:115
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:261
Base class for all entity classes.
Definition: REntity.h:64
virtual QList< RVector > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
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:148
Q_DECLARE_METATYPE(RMath *)
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:493
double rowSpacing
Definition: RBlockReferenceData.h:154
#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:150
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: REntityData.h:88
void groundReferencedBlockId() const
Definition: RBlockReferenceData.h:82
int rowCount
Definition: RBlockReferenceData.h:152
Low-level mathematical representation of a line.
Definition: RLine.h:42
double getRotation() const
Definition: RBlockReferenceData.h:103
Definition: RS.h:129
RVector getPosition() const
Definition: RBlockReferenceData.h:93
QList< RBox > boundingBoxesIgnoreEmpty
Definition: RBlockReferenceData.h:156
int columnCount
Definition: RBlockReferenceData.h:151
virtual RVector getVectorTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:391
double getRowSpacing() const
Definition: RBlockReferenceData.h:129
Block reference entity.
Definition: RBlockReferenceEntity.h:38
RViewportData data
Definition: RViewportEntity.h:180
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:350
QList< RBox > boundingBoxes
Definition: RBlockReferenceData.h:155
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
RDocument * document
Definition: RObject.h:263
RVector getScaleFactors() const
Definition: RBlockReferenceData.h:98