QCAD
Open Source 2D CAD
RGraphicsViewQt.h
Go to the documentation of this file.
1 
20 #ifndef RGRAPHICSVIEWQT_H
21 #define RGRAPHICSVIEWQT_H
22 
23 #include "gui_global.h"
24 
25 #include <QtCore>
26 #include <QFrame>
27 #include <QFocusFrame>
28 #include <QWidget>
29 #include <QPinchGesture>
30 
31 #include "RGraphicsViewImage.h"
32 #include "RPainterPath.h"
33 
34 class RAction;
35 class RDocument;
36 class RDocumentInterface;
37 class RFocusFrame;
38 class RGraphicsSceneQt;
39 class RLine;
40 class RSnap;
41 class RSnapRestriction;
42 
43 
44 
55 class QCADGUI_EXPORT RGraphicsViewQt : public QWidget, public RGraphicsViewImage {
56  Q_OBJECT
57 
58 public:
59  RGraphicsViewQt(QWidget* parent=NULL, bool showFocus=true);
60  virtual ~RGraphicsViewQt();
61 
62  void disableGestures() {
63  gesturesEnabled = false;
64  ungrabGesture(Qt::PanGesture);
65  ungrabGesture(Qt::PinchGesture);
66  }
67 
68  virtual void repaintView();
69  virtual void repaintNow();
70 
71  virtual void giveFocus();
72  virtual bool hasFocus();
73  virtual void removeFocus();
74 
75  virtual int getWidth() const;
76  virtual int getHeight() const;
77  virtual QRect getRect() const;
78 
79  virtual bool getSignalsBlocked() const;
80  virtual void setSignalsBlocked(bool on);
81 
82  virtual QCursor getCursor();
83  virtual void setCursor(Qt::CursorShape cursorShape);
84  virtual void setCursor(const QCursor& cursor);
85 
86  void setFocusFrameWidget(QFrame* w);
87 
88  virtual void viewportChangeEvent();
89 
90  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction);
91  virtual void emitUpdateTextLabel(const RTextLabel& textLabel);
92 
93  virtual void simulateMouseMoveEvent();
94 
95  virtual double getDevicePixelRatio() const;
96 
97  virtual bool registerForFocus() const {
98  return true;
99  }
100 
101 signals:
102  void drop(QDropEvent* event);
103  void dragEnter(QDragEnterEvent* event);
104 
105  void viewportChanged();
106 
107  void updateSnapInfo(QPainter* painter, RSnap* snap, RSnapRestriction* restriction);
108  void updateTextLabel(QPainter* painter, const RTextLabel& textLabel);
109 
110 protected:
111  virtual QSize sizeHint() const;
112 
113  bool event(QEvent* e);
114 
115  bool gestureEvent(QGestureEvent* event);
116 
117  virtual void focusInEvent(QFocusEvent* event);
118  virtual void focusOutEvent(QFocusEvent* event);
119 
120  virtual void tabletEvent(QTabletEvent *event);
121  virtual void mouseMoveEvent(QMouseEvent* event);
122  virtual void mousePressEvent(QMouseEvent* event);
123  virtual void mouseReleaseEvent(QMouseEvent* event);
124  virtual void mouseDoubleClickEvent(QMouseEvent* event);
125  virtual void wheelEvent(QWheelEvent* event);
126  virtual void paintEvent(QPaintEvent*);
127  virtual void resizeEvent(QResizeEvent* event);
128  virtual void keyPressEvent(QKeyEvent* event);
129  virtual void keyReleaseEvent(QKeyEvent* event);
130  virtual void dragEnterEvent(QDragEnterEvent* event);
131  virtual void dropEvent(QDropEvent* event);
132 
133 private:
134  QTransform previousView;
136  Qt::MouseButtons lastButtonState;
137 
138  bool showFocus;
139 
141  QCursor lastCursor;
142 
147 };
148 
150 
151 #endif
virtual void repaintView()
Triggers a paintEvent based on a buffered offscreen bitmap (very fast).
Definition: RGraphicsViewImage.cpp:114
virtual int getHeight() const
Definition: RGraphicsViewImage.cpp:1508
Abstract base class for all grid and object snap implementations.
Definition: RSnap.h:44
virtual void setSignalsBlocked(bool on)
Definition: RGraphicsView.h:208
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual double getDevicePixelRatio() const
Definition: RGraphicsView.h:307
Text label.
Definition: RTextLabel.h:42
virtual bool hasFocus()
Definition: RGraphicsViewImage.h:214
#define QCADGUI_EXPORT
Definition: gui_global.h:10
Abstract base class for all snap restriction implementations.
Definition: RSnapRestriction.h:37
QCursor lastCursor
Definition: RGraphicsViewQt.h:141
virtual void emitUpdateSnapInfo(RSnap *snap, RSnapRestriction *restriction)
Definition: RGraphicsViewImage.h:249
RVector mousePressModelPosition
Definition: RGraphicsViewQt.h:146
Qt based 2d graphics scene.
Definition: RGraphicsSceneQt.h:62
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RFocusFrame.h:32
bool gesturesEnabled
Definition: RGraphicsViewQt.h:143
virtual void emitUpdateTextLabel(const RTextLabel &textLabel)
Definition: RGraphicsViewImage.h:253
RVector mousePressScreenPosition
Definition: RGraphicsViewQt.h:145
virtual void simulateMouseMoveEvent()
Definition: RGraphicsViewImage.h:182
Abstract base class for all action classes.
Definition: RAction.h:62
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
virtual void giveFocus()
Definition: RGraphicsViewImage.h:210
Q_DECLARE_METATYPE(RMath *)
virtual void viewportChangeEvent()
Definition: RGraphicsView.cpp:117
virtual bool getSignalsBlocked() const
Definition: RGraphicsView.h:205
Qt::MouseButtons lastButtonState
remember last mouse button state for wacom bug workaround
Definition: RGraphicsViewQt.h:136
virtual int getWidth() const
Definition: RGraphicsViewImage.cpp:1504
QWidget based 2d graphics view.
Definition: RGraphicsViewQt.h:55
Low-level mathematical representation of a line.
Definition: RLine.h:41
virtual void setCursor(Qt::CursorShape)
Definition: RGraphicsView.h:242
QTime mouseClickTimer
Definition: RGraphicsViewQt.h:144
virtual void removeFocus()
Definition: RGraphicsViewImage.h:218
virtual bool registerForFocus() const
Reimplementations may return true to register this view and allow it to be returned by RDocumentInter...
Definition: RGraphicsViewQt.h:97
bool showFocus
Definition: RGraphicsViewQt.h:138
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:84
QTransform previousView
Definition: RGraphicsViewQt.h:134
void disableGestures()
Definition: RGraphicsViewQt.h:62
QFrame * focusFrameWidget
Definition: RGraphicsViewQt.h:140
virtual QCursor getCursor()
Definition: RGraphicsView.h:241
QImage based 2d graphics view.
Definition: RGraphicsViewImage.h:51