QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RGraphicsViewImage.h
Go to the documentation of this file.
1 
20 #ifndef RGRAPHICSVIEWIMAGE_H
21 #define RGRAPHICSVIEWIMAGE_H
22 
23 #include "gui_global.h"
24 
25 #include <QtCore>
26 #include <QPinchGesture>
27 
28 #include "RGraphicsView.h"
29 #include "RPainterPath.h"
30 
31 class RAction;
32 class RDocument;
33 class RDocumentInterface;
34 class RGraphicsSceneQt;
35 class RLine;
36 class RSnap;
37 class RSnapRestriction;
38 
39 
40 
52 
53 public:
55  virtual ~RGraphicsViewImage();
56 
57  // TODO: these methods are not found in RGraphicsViewQt, due to the
58  // multiple inheritance of RGraphicsViewQt (QWidget and RGraphicsViewImage)
59  // unless they are re-declared here again:
60  void setViewportNumber(int n) {
62  }
63 
64  int getViewportNumber() const {
66  }
67 
68  void setNavigationAction(RAction* action) {
70  }
71 
72  RBox getBox() const {
73  return RGraphicsView::getBox();
74  }
75 
76  void autoZoom(int margin = RDEFAULT_MIN1) {
78  }
79 
80  void zoomTo(const RBox &window, int margin = 0) {
81  RGraphicsView::zoomTo(window, margin);
82  }
83 
84  void zoom(const RVector& center, double factor) {
85  RGraphicsView::zoom(center, factor);
86  }
87 
88  void centerToBox(const RBox& box) {
90  }
91 
92  void centerToPoint(const RVector& point) {
94  }
95 
96  void setGrid(RGrid* grid) {
98  }
99 
101  return RGraphicsView::getGrid();
102  }
103 
104  double getFactor(bool includeStepFactor=true) const {
105  return RGraphicsView::getFactor(includeStepFactor);
106  }
107 
108  void setFactor(double f, bool regen=true) {
109  RGraphicsView::setFactor(f, regen);
110  }
111 
112  RVector getOffset(bool includeStepOffset=true) const {
113  return RGraphicsView::getOffset(includeStepOffset);
114  }
115 
116  void setOffset(const RVector& offset, bool regen=true) {
117  RGraphicsView::setOffset(offset, regen);
118  }
119 
122  }
123 
124  void setMargin(int m) {
126  }
127 
130  }
131 
133  return RGraphicsView::getScene();
134  }
135 
138  }
139 
142  }
143 
144 // void setDraftMode(bool on) {
145 // RGraphicsView::setDraftMode(on);
146 // }
147 
148 // bool getDraftMode() const {
149 // return RGraphicsView::getDraftMode();
150 // }
151 
152  void setPrinting(bool on) {
154  }
155 
156  bool isPrinting() const {
157  return RGraphicsView::isPrinting();
158  }
159 
160  void setPrintPreview(bool on) {
162  }
163 
164  bool isPrintPreview() const {
166  }
167 
168  void setPrintPointSize(const RVector& s) {
170  }
171 
172  virtual void simulateMouseMoveEvent() {
174  }
175 
178  }
179 
182  }
183 
184  bool isGridVisible() const {
186  }
187 
188  void setGridVisible(bool on) {
190  }
191 
192  virtual void setScene(RGraphicsSceneQt* scene, bool regen=true);
193 
194  virtual void setBackgroundColor(const QColor& col);
195 
196  virtual void regenerate(bool force=false);
197  virtual void repaintView();
198  virtual void updateImage();
199 
200  virtual bool hasFocus() {
201  return true;
202  }
203 
204  virtual void removeFocus() {
205  return;
206  }
207 
208  void saveViewport();
209  void restoreViewport();
210 
211  virtual RVector mapFromView(const RVector& v, double z=0.0) const;
212  virtual RVector mapToView(const RVector& v) const;
213  virtual double mapDistanceFromView(double d) const;
214  virtual double mapDistanceToView(double d) const;
215 
216  virtual int getWidth() const;
217  virtual int getHeight() const;
218  void resizeImage(int w, int h);
219 
220  virtual void paintGridPoint(const RVector& ucsPosition);
221  virtual void paintGridLine(const RLine& ucsPosition);
222  //virtual void paintCursorLine(const RLine& ucsPosition);
223 
224  void setPaintOrigin(bool val);
225 
226  void setAntialiasing(bool val);
227  bool getAntialiasing();
228 
229  void setPanOptimization(bool on);
230  bool getPanOptimization();
231 
232  virtual void paintEntities(QPainter* painter, const RBox& queryBox);
233  virtual void paintEntity(QPainter* painter, REntity::Id id);
234 
235  QImage getBuffer() const;
236  QTransform getTransform() const;
237 
238  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction) {
239  Q_UNUSED(snap)
240  Q_UNUSED(restriction)
241  }
242  virtual void emitUpdateTextLabel(const RTextLabel& textLabel) {
243  Q_UNUSED(textLabel)
244  }
245  virtual void emitDecorateBackground(QPainter* painter) { Q_UNUSED(painter) }
246  virtual void emitDecorateForeground(QPainter* painter) { Q_UNUSED(painter) }
247 
248  void clearBackground();
249  void addToBackground(const RPainterPath& path);
250  void setBackgroundTransform(double bgFactor, const RVector& bgOffset);
251 
253  colorCorrectionOverride = on;
254  }
255 
257  return colorCorrectionOverride;
258  }
259 
260 
261 protected:
262  virtual void paintImage(QPainter* painter, RImageData& image);
263  virtual void paintOrigin(QPaintDevice& device);
264  virtual void paintErase(QPaintDevice& device, const QRect& rect = QRect());
265  virtual void paintGrid(QPaintDevice& device, const QRect& rect = QRect());
266  virtual void paintMetaGrid(QPaintDevice& device, const QRect& rect = QRect());
267  virtual void paintCursor(QPaintDevice& device);
268  virtual void paintRelativeZero(QPaintDevice& device);
269  virtual void paintDocument(const QRect& rect = QRect());
270  virtual void paintBackground(QPainter* painter, const QRect& rect = QRect());
271 
275  QPainter* initPainter(QPaintDevice& device, bool erase, bool screen = false, const QRect& rect = QRect());
276 
277  void invalidate(bool force=false);
278  void updateGraphicsBuffer();
279  void updateTransformation() const;
280 
281 protected:
284 
285 protected:
287  QMutex mutexSi;
288 
290  double currentScale;
291  QSize lastSize;
293  double lastFactor;
295  mutable QTransform transform;
296  QTransform previousView;
297 
298  QPainter* gridPainter;
301 
303  QSet<RObject::Id> selectedIds;
305 
309 
310 // int textHeightThresholdOverride;
311 // int textHeightThreshold;
312 
313  double drawingScale;
314 
315  QList<RPainterPath> backgroundDecoration;
316  //QTransform backgroundTransform;
320 };
321 
323 
324 #endif