QCAD
Open Source 2D CAD
RViewportData.h
Go to the documentation of this file.
1 
20 #ifndef RVIEWPORTDATA_H
21 #define RVIEWPORTDATA_H
22 
23 #include "core_global.h"
24 
25 #include "RBox.h"
26 #include "RDocument.h"
27 #include "REntity.h"
28 #include "RPoint.h"
29 #include "RVector.h"
30 #include "RLine.h"
31 
40 class QCADCORE_EXPORT RViewportData: public REntityData, protected RPoint {
41 
42  friend class RViewportEntity;
43 
44 protected:
46 
47 public:
48  enum Status {
49  Off = 0x20000
50  };
51 
52 public:
53  RViewportData();
54 // RViewportData(const RVector& center, double width, double height, double scale,
55 // const RVector& viewCenter,
56 // const RVector& viewTarget);
57 
58  virtual RS::EntityType getType() const {
59  return RS::EntityViewport;
60  }
61 
62  virtual RBox getBoundingBox(bool ignoreEmpty) const;
63 
64  virtual RBox getBoundingBox() const {
65  return getBoundingBox(false);
66  }
67 
68  virtual RShape* castToShape() {
69  return this;
70  }
71 
72  int getViewportId() const {
73  return viewportId;
74  }
75 
76  void setViewportId(int id) {
77  viewportId = id;
78  }
79 
80  int getStatus() const {
81  return status;
82  }
83 
84  void setStatus(int s) {
85  status = s;
86  }
87 
88  RVector getCenter() const {
89  return position;
90  }
91 
92  void setCenter(const RVector& c) {
93  position = c;
94  }
95 
97  return viewCenter;
98  }
99 
100  void setViewCenter(const RVector& c) {
101  viewCenter = c;
102  }
103 
105  return viewTarget;
106  }
107 
108  void setViewTarget(const RVector& t) {
109  viewTarget = t;
110  }
111 
112  double getWidth() const {
113  return width;
114  }
115 
116  void setWidth(double w) {
117  width = w;
118  }
119 
120  double getHeight() const {
121  return height;
122  }
123 
124  void setHeight(double h) {
125  height = h;
126  }
127 
128  double getScale() const {
129  return scaleFactor;
130  }
131 
132  void setScale(double s) {
133  scaleFactor = s;
134  }
135 
136  double getRotation() const {
137  return rotation;
138  }
139 
140  void setRotation(double r) {
141  rotation = r;
142  }
143 
144  bool isOverall() const {
145  return overall;
146  }
147 
148  void setOverall(bool on) {
149  overall = on;
150  }
151 
152  bool isOff() const {
153  return testStatusFlag(Off);
154  }
155 
156  void setOff(bool v) {
157  setStatusFlag(Off, v);
158  }
159 
160  RVector getViewOffset() const;
161 
162  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
163 
164  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
165 
166  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
167 
168  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const;
169 
170  QList<RLine> getEdges() const;
171 
172  virtual bool scale(const RVector& scaleFactors, const RVector& center);
173 
174 protected:
175  void setStatusFlag(Status s, bool on) {
176  if (on) {
177  status |= s;
178  } else {
179  status &= ~s;
180  }
181  }
182 
183  bool testStatusFlag(Status s) const {
184  return (status & s) == s;
185  }
186 
187 private:
189  int status;
190  double width;
191  double height;
192  double scaleFactor;
193  double rotation;
194 
197 
198  bool overall;
199 };
200 
204 Q_DECLARE_METATYPE(QSharedPointer<RViewportData>)
206 
207 #endif
double getScale() const
Definition: RViewportData.h:128
double height
Definition: RViewportData.h:191
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:65
Viewport entity.
Definition: RViewportEntity.h:38
virtual RBox getBoundingBox() const
Definition: RViewportData.h:64
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
void setWidth(double w)
Definition: RViewportData.h:116
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:125
int status
Definition: RViewportData.h:189
RVector viewCenter
Definition: RViewportData.h:195
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:111
#define QCADCORE_EXPORT
Definition: core_global.h:10
void setOff(bool v)
Definition: RViewportData.h:156
int getViewportId() const
Definition: RViewportData.h:72
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:284
double getWidth() const
Definition: RViewportData.h:112
Viewport.
Definition: RS.h:172
void setStatusFlag(Status s, bool on)
Definition: RViewportData.h:175
void setHeight(double h)
Definition: RViewportData.h:124
RVector getViewOffset() const
Definition: RViewportEntity.h:189
void setViewCenter(const RVector &c)
Definition: RViewportData.h:100
RVector viewTarget
Definition: RViewportData.h:196
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:183
void setCenter(const RVector &c)
Definition: RViewportData.h:92
bool isOff() const
Definition: RViewportData.h:152
bool isOverall() const
Definition: RViewportData.h:144
void setScale(double s)
Definition: RViewportData.h:132
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:562
RVector getViewCenter() const
Definition: RViewportData.h:96
RVector getCenter() const
Definition: RViewportData.h:88
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:298
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...
Q_DECLARE_METATYPE(RMath *)
void setViewportId(int id)
Definition: RViewportData.h:76
double getHeight() const
Definition: RViewportData.h:120
void setViewTarget(const RVector &t)
Definition: RViewportData.h:108
virtual RShape * castToShape()
Definition: RViewportData.h:68
#define RMAXDOUBLE
Definition: RMath.h:63
RVector getViewTarget() const
Definition: RViewportData.h:104
double width
Definition: RViewportData.h:190
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
virtual RS::EntityType getType() const
Definition: RViewportData.h:58
bool overall
Definition: RViewportData.h:198
Definition: RS.h:184
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RViewportData.h:40
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RPoint.h:38
Status
Definition: RViewportData.h:48
double getRotation() const
Definition: RViewportData.h:136
int viewportId
Definition: RViewportData.h:188
void setOverall(bool on)
Definition: RViewportData.h:148
int getStatus() const
Definition: RViewportData.h:80
RVector position
Getter function for this property: getPosition.
Definition: RPoint.h:96
Interface for geometrical shape classes.
Definition: RShape.h:52
RViewportData data
Definition: RViewportEntity.h:205
void setRotation(double r)
Definition: RViewportData.h:140
double scaleFactor
Definition: RViewportData.h:192
double rotation
Definition: RViewportData.h:193
void setStatus(int s)
Definition: RViewportData.h:84
bool testStatusFlag(Status s) const
Definition: RViewportData.h:183
RDocument * document
Definition: RObject.h:306