QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
39 
40 friend class RBlockReferenceEntity;
41 friend class RViewportEntity;
42 
43 protected:
45 
46 public:
48  RBlockReferenceData(RBlock::Id referencedBlockId,
49  const RVector& position, const RVector& scaleFactors, double angle);
50 
51  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
52 
53  virtual QList<RVector> getInternalReferencePoints(
55  virtual QList<RVector> getReferencePoints(
57  virtual RVector getVectorTo(const RVector& point,
58  bool limited = true, double strictRange = RMAXDOUBLE) const;
59  virtual double getDistanceTo(const RVector& point,
60  bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
61 
62  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
63 
64  //virtual void setSelected(bool on);
65 
66  virtual bool moveReferencePoint(const RVector& referencePoint,
67  const RVector& targetPoint);
68  virtual bool move(const RVector& offset);
69  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
70  virtual bool mirror(const RLine& axis);
71  virtual bool scale(const RVector& scaleFactors,
72  const RVector& center = RDEFAULT_RVECTOR);
73 
74  void setReferencedBlockId(RBlock::Id blockId);
75 
76  void groundReferencedBlockId() const {
77  referencedBlockId = RBlock::INVALID_ID;
78  }
79 
81  return referencedBlockId;
82  }
83 
84  void setReferencedBlockName(const QString& blockName);
85  QString getReferencedBlockName() const;
86 
87  RVector getPosition() const {
88  return position;
89  }
90  void setPosition(const RVector& p);
91 
93  return scaleFactors;
94  }
95  void setScaleFactors(const RVector& sf);
96 
97  double getRotation() const {
98  return rotation;
99  }
100  void setRotation(double r);
101 
102  virtual void update() const;
103  virtual void update(RObject::Id entityId) const;
104 
105  QSharedPointer<REntity> queryEntity(REntity::Id entityId) const;
106  bool applyTransformationTo(REntity& entity) const;
107  RVector mapToBlock(const RVector& v) const;
108 
109 private:
113  double rotation;
114  mutable RBox boundingBox;
115  mutable QMap<REntity::Id, QSharedPointer<REntity> > cache;
116 };
117 
121 
122 #endif