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 QCursor getCursor();
80  virtual void setCursor(Qt::CursorShape cursorShape);
81  virtual void setCursor(const QCursor& cursor);
82 
83  void setFocusFrameWidget(QFrame* w);
84 
85  virtual void viewportChangeEvent();
86 
87  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction);
88  virtual void emitUpdateTextLabel(const RTextLabel& textLabel);
89 
90  virtual void simulateMouseMoveEvent();
91 
92  virtual double getDevicePixelRatio() const;
93 
94 signals:
95  void drop(QDropEvent* event);
96  void dragEnter(QDragEnterEvent* event);
97 
98  void viewportChanged();
99 
100  void updateSnapInfo(QPainter* painter, RSnap* snap, RSnapRestriction* restriction);
101  void updateTextLabel(QPainter* painter, const RTextLabel& textLabel);
102 
103 
104 protected:
105  virtual QSize sizeHint() const;
106 
107  bool event(QEvent* e);
108 
109  bool gestureEvent(QGestureEvent* event);
110  //void pinchTriggered(QPinchGesture* gesture);
111  //void panTriggered(QPanGesture* gesture);
112 
113  virtual void focusInEvent(QFocusEvent* event);
114  virtual void focusOutEvent(QFocusEvent* event);
115 
116  virtual void tabletEvent(QTabletEvent *event);
117  virtual void mouseMoveEvent(QMouseEvent* event);
118  virtual void mousePressEvent(QMouseEvent* event);
119  virtual void mouseReleaseEvent(QMouseEvent* event);
120  virtual void mouseDoubleClickEvent(QMouseEvent* event);
121  virtual void wheelEvent(QWheelEvent* event);
122  virtual void paintEvent(QPaintEvent*);
123  virtual void resizeEvent(QResizeEvent* event);
124  virtual void keyPressEvent(QKeyEvent* event);
125  virtual void keyReleaseEvent(QKeyEvent* event);
126  virtual void dragEnterEvent(QDragEnterEvent* event);
127  virtual void dropEvent(QDropEvent* event);
128 
129 private:
130  QTransform previousView;
132  Qt::MouseButtons lastButtonState;
133 
134  bool showFocus;
135 
137  QCursor lastCursor;
138 
140 };
141 
143 
144 #endif
virtual void repaintView()
Triggers a paintEvent based on a buffered offscreen bitmap (very fast).
Definition: RGraphicsViewImage.cpp:102
virtual int getHeight() const
Definition: RGraphicsViewImage.cpp:1208
Abstract base class for all grid and object snap implementations.
Definition: RSnap.h:44
virtual double getDevicePixelRatio() const
Definition: RGraphicsView.h:285
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:137
virtual void emitUpdateSnapInfo(RSnap *snap, RSnapRestriction *restriction)
Definition: RGraphicsViewImage.h:247
Qt based 2d graphics scene.
Definition: RGraphicsSceneQt.h:56
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RFocusFrame.h:32
bool gesturesEnabled
Definition: RGraphicsViewQt.h:139
virtual void emitUpdateTextLabel(const RTextLabel &textLabel)
Definition: RGraphicsViewImage.h:251
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:63
virtual void giveFocus()
Definition: RGraphicsViewImage.h:208
Q_DECLARE_METATYPE(RMath *)
virtual void viewportChangeEvent()
Definition: RGraphicsView.cpp:117
Qt::MouseButtons lastButtonState
remember last mouse button state for wacom bug workaround
Definition: RGraphicsViewQt.h:132
virtual int getWidth() const
Definition: RGraphicsViewImage.cpp:1204
QWidget based 2d graphics view.
Definition: RGraphicsViewQt.h:55
Low-level mathematical representation of a line.
Definition: RLine.h:42
virtual void setCursor(Qt::CursorShape)
Definition: RGraphicsView.h:220
virtual void removeFocus()
Definition: RGraphicsViewImage.h:216
bool showFocus
Definition: RGraphicsViewQt.h:134
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
QTransform previousView
Definition: RGraphicsViewQt.h:130
void disableGestures()
Definition: RGraphicsViewQt.h:62
QFrame * focusFrameWidget
Definition: RGraphicsViewQt.h:136
virtual QCursor getCursor()
Definition: RGraphicsView.h:219
QImage based 2d graphics view.
Definition: RGraphicsViewImage.h:51