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