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, bool ignoreEmpty=false) {
77  RGraphicsView::autoZoom(margin, ignoreEmpty);
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 
132  void setHairlineMode(bool on) {
134  }
135 
138  }
139 
140  void setAntialiasing(bool on) {
142  }
143 
144  bool getAntialiasing() const {
146  }
147 
149  return RGraphicsView::getScene();
150  }
151 
154  }
155 
158  }
159 
160  void setPrinting(bool on) {
162  }
163 
164  bool isPrinting() const {
165  return RGraphicsView::isPrinting();
166  }
167 
168  void setPrintPreview(bool on) {
170  }
171 
172  bool isPrintPreview() const {
174  }
175 
176  void setPrintPointSize(const RVector& s) {
178  }
179 
180  virtual void simulateMouseMoveEvent() {
182  }
183 
186  }
187 
190  }
191 
192  bool isGridVisible() const {
194  }
195 
196  void setGridVisible(bool on) {
198  }
199 
200  virtual void setScene(RGraphicsSceneQt* scene, bool regen=true);
201 
202  virtual void setBackgroundColor(const QColor& col);
203 
204  virtual void regenerate(bool force=false);
205  virtual void repaintView();
206  virtual void updateImage();
207 
208  virtual void giveFocus() {
209  return;
210  }
211 
212  virtual bool hasFocus() {
213  return true;
214  }
215 
216  virtual void removeFocus() {
217  return;
218  }
219 
220  void saveViewport();
221  void restoreViewport();
222 
223  virtual RVector mapFromView(const RVector& v, double z=0.0) const;
224  virtual RVector mapToView(const RVector& v) const;
225  virtual double mapDistanceFromView(double d) const;
226  virtual double mapDistanceToView(double d) const;
227 
228  virtual int getWidth() const;
229  virtual int getHeight() const;
230  void resizeImage(int w, int h);
231 
232  virtual void paintGridPoint(const RVector& ucsPosition);
233  virtual void paintGridLine(const RLine& ucsPosition);
234  //virtual void paintCursorLine(const RLine& ucsPosition);
235 
236  void setPaintOrigin(bool val);
237 
238  void setPanOptimization(bool on);
239  bool getPanOptimization();
240 
241  virtual void paintEntities(QPainter* painter, const RBox& queryBox);
242  virtual void paintEntity(QPainter* painter, REntity::Id id);
243 
244  QImage getBuffer() const;
245  QTransform getTransform() const;
246 
247  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction) {
248  Q_UNUSED(snap)
249  Q_UNUSED(restriction)
250  }
251  virtual void emitUpdateTextLabel(const RTextLabel& textLabel) {
252  Q_UNUSED(textLabel)
253  }
254  virtual void emitDecorateBackground(QPainter* painter) { Q_UNUSED(painter) }
255  virtual void emitDecorateForeground(QPainter* painter) { Q_UNUSED(painter) }
256 
257  void clearBackground();
258  void addToBackground(const RPainterPath& path);
259  void setBackgroundTransform(double bgFactor, const RVector& bgOffset);
260 
262  colorCorrectionOverride = on;
263  }
264 
266  return colorCorrectionOverride;
267  }
268 
269 
270 protected:
271  double getPointSize(double pSize);
272  virtual void drawDot(QPainter* painter, QPointF pt);
273  virtual void drawPlus(QPainter* painter, QPointF pt, double pSize);
274  virtual void drawEx(QPainter* painter, QPointF pt, double pSize);
275  virtual void drawVBar(QPainter* painter, QPointF pt, double pSize);
276  virtual void drawCircle(QPainter* painter, QPointF pt, double pSize);
277  virtual void drawSquare(QPainter* painter, QPointF pt, double pSize);
278 
279  virtual void paintImage(QPainter* painter, RImageData& image);
280  virtual void paintOrigin(QPaintDevice& device);
281  virtual void paintReferencePoint(QPainter& painter, const RVector& pos, bool highlight);
282  virtual void paintErase(QPaintDevice& device, const QRect& rect = QRect());
283  virtual void paintGrid(QPaintDevice& device, const QRect& rect = QRect());
284  virtual void paintMetaGrid(QPaintDevice& device, const QRect& rect = QRect());
285  virtual void paintCursor(QPaintDevice& device);
286  virtual void paintRelativeZero(QPaintDevice& device);
287  virtual void paintDocument(const QRect& rect = QRect());
288  virtual void paintBackground(QPainter* painter, const QRect& rect = QRect());
289 
293  QPainter* initPainter(QPaintDevice& device, bool erase, bool screen = false, const QRect& rect = QRect());
294 
295  void invalidate(bool force=false);
296  void updateGraphicsBuffer();
297  void updateTransformation() const;
298 
299 protected:
302 
303 protected:
305  QMutex mutexSi;
306 
308  double currentScale;
309  QSize lastSize;
311  double lastFactor;
313  mutable QTransform transform;
314  QTransform previousView;
315 
316  QPainter* gridPainter;
318 
320  QSet<RObject::Id> selectedIds;
322 
326 
327 // int textHeightThresholdOverride;
328 // int textHeightThreshold;
329 
330  double drawingScale;
331 
332  QList<RPainterPath> backgroundDecoration;
333  //QTransform backgroundTransform;
337 };
338 
340 
341 #endif