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 signals:
98  void drop(QDropEvent* event);
99  void dragEnter(QDragEnterEvent* event);
100 
101  void viewportChanged();
102 
103  void updateSnapInfo(QPainter* painter, RSnap* snap, RSnapRestriction* restriction);
104  void updateTextLabel(QPainter* painter, const RTextLabel& textLabel);
105 
106 
107 protected:
108  virtual QSize sizeHint() const;
109 
110  bool event(QEvent* e);
111 
112  bool gestureEvent(QGestureEvent* event);
113  //void pinchTriggered(QPinchGesture* gesture);
114  //void panTriggered(QPanGesture* gesture);
115 
116  virtual void focusInEvent(QFocusEvent* event);
117  virtual void focusOutEvent(QFocusEvent* event);
118 
119  virtual void tabletEvent(QTabletEvent *event);
120  virtual void mouseMoveEvent(QMouseEvent* event);
121  virtual void mousePressEvent(QMouseEvent* event);
122  virtual void mouseReleaseEvent(QMouseEvent* event);
123  virtual void mouseDoubleClickEvent(QMouseEvent* event);
124  virtual void wheelEvent(QWheelEvent* event);
125  virtual void paintEvent(QPaintEvent*);
126  virtual void resizeEvent(QResizeEvent* event);
127  virtual void keyPressEvent(QKeyEvent* event);
128  virtual void keyReleaseEvent(QKeyEvent* event);
129  virtual void dragEnterEvent(QDragEnterEvent* event);
130  virtual void dropEvent(QDropEvent* event);
131 
132 private:
133  QTransform previousView;
135  Qt::MouseButtons lastButtonState;
136 
137  bool showFocus;
138 
140  QCursor lastCursor;
141 
146 };
147 
149 
150 #endif
virtual void repaintView()
Triggers a paintEvent based on a buffered offscreen bitmap (very fast).
Definition: RGraphicsViewImage.cpp:106
virtual int getHeight() const
Definition: RGraphicsViewImage.cpp:1488
Abstract base class for all grid and object snap implementations.
Definition: RSnap.h:44
virtual void setSignalsBlocked(bool on)
Definition: RGraphicsView.h:199
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual double getDevicePixelRatio() const
Definition: RGraphicsView.h:298
Text label.
Definition: RTextLabel.h:42
virtual bool hasFocus()
Definition: RGraphicsViewImage.h:212
#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:140
virtual void emitUpdateSnapInfo(RSnap *snap, RSnapRestriction *restriction)
Definition: RGraphicsViewImage.h:247
RVector mousePressModelPosition
Definition: RGraphicsViewQt.h:145
Qt based 2d graphics scene.
Definition: RGraphicsSceneQt.h:62
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RFocusFrame.h:32
bool gesturesEnabled
Definition: RGraphicsViewQt.h:142
virtual void emitUpdateTextLabel(const RTextLabel &textLabel)
Definition: RGraphicsViewImage.h:251
RVector mousePressScreenPosition
Definition: RGraphicsViewQt.h:144
virtual void simulateMouseMoveEvent()
Definition: RGraphicsViewImage.h:180
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:208
Q_DECLARE_METATYPE(RMath *)
virtual void viewportChangeEvent()
Definition: RGraphicsView.cpp:117
virtual bool getSignalsBlocked() const
Definition: RGraphicsView.h:196
Qt::MouseButtons lastButtonState
remember last mouse button state for wacom bug workaround
Definition: RGraphicsViewQt.h:135
virtual int getWidth() const
Definition: RGraphicsViewImage.cpp:1484
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:233
QTime mouseClickTimer
Definition: RGraphicsViewQt.h:143
virtual void removeFocus()
Definition: RGraphicsViewImage.h:216
bool showFocus
Definition: RGraphicsViewQt.h:137
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
QTransform previousView
Definition: RGraphicsViewQt.h:133
void disableGestures()
Definition: RGraphicsViewQt.h:62
QFrame * focusFrameWidget
Definition: RGraphicsViewQt.h:139
virtual QCursor getCursor()
Definition: RGraphicsView.h:232
QImage based 2d graphics view.
Definition: RGraphicsViewImage.h:51