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 scale;
130  }
131 
132  void setScale(double s) {
133  scale = 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  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
161 
162  virtual bool moveReferencePoint(const RVector& referencePoint,
163  const RVector& targetPoint);
164 
165  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const;
166 
167 protected:
168  void setStatusFlag(Status s, bool on) {
169  if (on) {
170  status |= s;
171  } else {
172  status &= ~s;
173  }
174  }
175 
176  bool testStatusFlag(Status s) const {
177  return (status & s) == s;
178  }
179 
180 private:
182  int status;
183  double width;
184  double height;
185  double scale;
186  double rotation;
187 
190 
191  bool overall;
192 };
193 
197 Q_DECLARE_METATYPE(QSharedPointer<RViewportData>)
199 
200 #endif
double getScale() const
Definition: RViewportData.h:128
double height
Definition: RViewportData.h:184
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:76
int status
Definition: RViewportData.h:182
RVector viewCenter
Definition: RViewportData.h:188
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:104
#define QCADCORE_EXPORT
Definition: core_global.h:10
void setOff(bool v)
Definition: RViewportData.h:156
int getViewportId() const
Definition: RViewportData.h:72
double getWidth() const
Definition: RViewportData.h:112
Viewport.
Definition: RS.h:120
void setStatusFlag(Status s, bool on)
Definition: RViewportData.h:168
void setHeight(double h)
Definition: RViewportData.h:124
void setViewCenter(const RVector &c)
Definition: RViewportData.h:100
RVector viewTarget
Definition: RViewportData.h:189
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
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:527
RVector getViewCenter() const
Definition: RViewportData.h:96
RVector getCenter() const
Definition: RViewportData.h:88
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:275
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
void scale(void e, void factor, void focusPoint)
Scales the given entity or shape by the given factor with the given focus point.
Definition: simple_modify.js:71
RVector getViewTarget() const
Definition: RViewportData.h:104
double width
Definition: RViewportData.h:183
double scale
Definition: RViewportData.h:185
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:191
Definition: RS.h:132
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RViewportData.h:40
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPoint.h:38
Status
Definition: RViewportData.h:48
double getRotation() const
Definition: RViewportData.h:136
int viewportId
Definition: RViewportData.h:181
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:193
void setRotation(double r)
Definition: RViewportData.h:140
double rotation
Definition: RViewportData.h:186
void setStatus(int s)
Definition: RViewportData.h:84
bool testStatusFlag(Status s) const
Definition: RViewportData.h:176
RDocument * document
Definition: RObject.h:271