QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RGraphicsViewImage.h
Go to the documentation of this file.
1 #ifndef RGRAPHICSVIEWIMAGE_H
2 #define RGRAPHICSVIEWIMAGE_H
3 
4 #include <QtCore>
5 #include <QPinchGesture>
6 
7 #include "RGraphicsView.h"
8 #include "RPainterPath.h"
9 
10 class RAction;
11 class RDocument;
12 class RDocumentInterface;
13 class RFocusFrame;
14 class RGraphicsSceneQt;
15 class RLine;
16 class RSnap;
17 class RSnapRestriction;
18 
19 
20 
32 
33 public:
35  virtual ~RGraphicsViewImage();
36 
37  // TODO: these methods are not found in RGraphicsViewQt, due to the
38  // multiple inheritance of RGraphicsViewQt (QWidget and RGraphicsViewImage)
39  // unless they are declared here again:
40  void setNavigationAction(RAction* action) {
42  }
43 
44  RBox getBox() const {
45  return RGraphicsView::getBox();
46  }
47 
50  }
51 
52  void zoomTo(const RBox &window, int margin = 0) {
54  }
55 
56  void setGrid(RGrid* grid) {
58  }
59 
61  return RGraphicsView::getGrid();
62  }
63 
64  double getFactor(bool includeStepFactor=true) const {
65  return RGraphicsView::getFactor(includeStepFactor);
66  }
67 
68  void setFactor(double f, bool regen=true) {
69  RGraphicsView::setFactor(f, regen);
70  }
71 
72  RVector getOffset(bool includeStepOffset=true) const {
73  return RGraphicsView::getOffset(includeStepOffset);
74  }
75 
76  void setOffset(const RVector& offset, bool regen=true) {
77  RGraphicsView::setOffset(offset, regen);
78  }
79 
80  QColor getBackgroundColor() {
82  }
83 
84  void setMargin(int m) {
86  }
87 
90  }
91 
93  return RGraphicsView::getScene();
94  }
95 
98  }
99 
102  }
103 
104  void setDraftMode(bool on) {
106  }
107 
108  bool getDraftMode() const {
110  }
111 
112  void setPrinting(bool on) {
114  }
115 
116  bool isPrinting() const {
117  return RGraphicsView::isPrinting();
118  }
119 
120  void setPrintPreview(bool on) {
122  }
123 
124  bool isPrintPreview() const {
126  }
127 
128  void setPrintPointSize(const RVector& s) {
130  }
131 
132  virtual void simulateMouseMoveEvent() {
134  }
135 
136  virtual void setScene(RGraphicsSceneQt* scene, bool regen=true);
137 
138  virtual void setBackgroundColor(const QColor& col);
139 
140  virtual void regenerate(bool force=false);
141  virtual void repaintView();
142  virtual void updateImage();
143 
144  virtual bool hasFocus() {
145  return true;
146  }
147 
148  virtual void removeFocus() {
149  return;
150  }
151 
152  void saveViewport();
153  void restoreViewport();
154 
155  virtual RVector mapFromView(const RVector& v, double z=0.0) const;
156  virtual RVector mapToView(const RVector& v) const;
157  virtual double mapDistanceFromView(double d) const;
158  virtual double mapDistanceToView(double d) const;
159 
160  virtual int getWidth() const;
161  virtual int getHeight() const;
162  void resizeImage(int w, int h);
163 
164  virtual void paintGridPoint(const RVector& ucsPosition);
165  virtual void paintMetaGridLine(const RLine& ucsPosition);
166 
167  void setPaintOrigin(bool val);
168 
169  void setAntialiasing(bool val);
170  bool getAntialiasing();
171 
172  void setPanOptimization(bool on);
173  bool getPanOptimization();
174 
175  virtual void paintEntities(QPainter* painter, const RBox& queryBox);
176  virtual void paintEntity(QPainter* painter, REntity::Id id);
177 
178  QImage getBuffer() const;
179  QTransform getTransform() const;
180 
181  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction) {
182  Q_UNUSED(snap)
183  Q_UNUSED(restriction)
184  }
185  virtual void emitUpdateTextLabel(const RTextLabel& textLabel) {
186  Q_UNUSED(textLabel)
187  }
188  virtual void emitDecorateBackground(QPainter* painter) { Q_UNUSED(painter) }
189  virtual void emitDecorateForeground(QPainter* painter) { Q_UNUSED(painter) }
190 
191  void clearBackground();
192  void addToBackground(const RPainterPath& path);
193  void setBackgroundTransform(double bgFactor, const RVector& bgOffset);
194 
197  }
198 
201  }
202 
205  }
206 
209  }
210 
211 protected:
212  virtual void paintImage(QPainter* painter, RImageData& image);
213  virtual void paintOrigin(QPaintDevice& device);
214  virtual void paintErase(QPaintDevice& device, const QRect& rect = QRect());
215  virtual void paintGrid(QPaintDevice& device, const QRect& rect = QRect());
216  virtual void paintMetaGrid(QPaintDevice& device, const QRect& rect = QRect());
217  virtual void paintCursor(QPaintDevice& device);
218  virtual void paintRelativeZero(QPaintDevice& device);
219  virtual void paintDocument(const QRect& rect = QRect());
220  virtual void paintBackground(QPainter* painter, const QRect& rect = QRect());
221 
225  QPainter* initPainter(QPaintDevice& device, bool erase, bool screen = false, const QRect& rect = QRect());
226 
227  void invalidate(bool force=false);
228  void updateGraphicsBuffer();
229  void updateTransformation() const;
230 
231 protected:
234 
235 protected:
237  QMutex mutexSi;
238 
240  double currentScale;
241  QSize lastSize;
243  double lastFactor;
245  mutable QTransform transform;
246  QTransform previousView;
247 
248  QPainter* gridPainter;
251 
253  QSet<RObject::Id> selectedIds;
255 
259 
262 
263  double drawingScale;
264 
265  QList<RPainterPath> backgroundDecoration;
266  //QTransform backgroundTransform;
270 };
271 
273 
274 #endif