QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 bool hasFocus();
72  virtual void removeFocus();
73 
74  virtual int getWidth() const;
75  virtual int getHeight() const;
76 
77  virtual QCursor getCursor();
78  virtual void setCursor(Qt::CursorShape cursorShape);
79  virtual void setCursor(const QCursor& cursor);
80 
81  void setFocusFrameWidget(QFrame* w);
82 
83  virtual void viewportChangeEvent();
84 
85  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction);
86  virtual void emitUpdateTextLabel(const RTextLabel& textLabel);
87 
88 signals:
89  void drop(QDropEvent* event);
90  void dragEnter(QDragEnterEvent* event);
91 
92  void viewportChanged();
93 
94  void updateSnapInfo(QPainter* painter, RSnap* snap, RSnapRestriction* restriction);
95  void updateTextLabel(QPainter* painter, const RTextLabel& textLabel);
96 
97 protected:
98  virtual QSize sizeHint() const;
99 
100  bool event(QEvent* e);
101 
102  bool gestureEvent(QGestureEvent* event);
103  //void pinchTriggered(QPinchGesture* gesture);
104  //void panTriggered(QPanGesture* gesture);
105 
106  virtual void focusInEvent(QFocusEvent* event);
107  virtual void focusOutEvent(QFocusEvent* event);
108 
109  virtual void tabletEvent(QTabletEvent *event);
110  virtual void mouseMoveEvent(QMouseEvent* event);
111  virtual void mousePressEvent(QMouseEvent* event);
112  virtual void mouseReleaseEvent(QMouseEvent* event);
113  virtual void mouseDoubleClickEvent(QMouseEvent* event);
114  virtual void wheelEvent(QWheelEvent* event);
115  virtual void paintEvent(QPaintEvent*);
116  virtual void resizeEvent(QResizeEvent* event);
117  virtual void keyPressEvent(QKeyEvent* event);
118  virtual void keyReleaseEvent(QKeyEvent* event);
119  virtual void dragEnterEvent(QDragEnterEvent* event);
120  virtual void dropEvent(QDropEvent* event);
121 
122 private:
123  QTransform previousView;
125  Qt::MouseButtons lastButtonState;
126 
127  bool showFocus;
128 
130  QCursor lastCursor;
131 
133 };
134 
136 
137 #endif