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