QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RGraphicsViewQt.h
Go to the documentation of this file.
1 #ifndef RGRAPHICSVIEWQT_H
2 #define RGRAPHICSVIEWQT_H
3 
4 #include <QtCore>
5 #include <QFrame>
6 #include <QFocusFrame>
7 #include <QWidget>
8 #include <QPinchGesture>
9 
10 #include "RGraphicsViewImage.h"
11 #include "RPainterPath.h"
12 
13 class RAction;
14 class RDocument;
15 class RDocumentInterface;
16 class RFocusFrame;
17 class RGraphicsSceneQt;
18 class RLine;
19 class RSnap;
20 class RSnapRestriction;
21 
22 
23 
34 class RGraphicsViewQt : public QWidget, public RGraphicsViewImage {
35  Q_OBJECT
36 
37 public:
38  RGraphicsViewQt(QWidget* parent=NULL, bool showFocus=true);
39  virtual ~RGraphicsViewQt();
40 
41  void disableGestures() {
42  gesturesEnabled = false;
43  ungrabGesture(Qt::PanGesture);
44  ungrabGesture(Qt::PinchGesture);
45  }
46 
47  virtual void repaintView();
48  virtual void repaintNow();
49 
50  virtual bool hasFocus();
51  virtual void removeFocus();
52 
53  virtual int getWidth() const;
54  virtual int getHeight() const;
55 
56  virtual QCursor getCursor();
57  virtual void setCursor(Qt::CursorShape cursorShape);
58  virtual void setCursor(const QCursor& cursor);
59 
60  void setFocusFrameWidget(QFrame* w);
61 
62  virtual void viewportChangeEvent();
63 
64  virtual void emitUpdateSnapInfo(RSnap* snap, RSnapRestriction* restriction);
65  virtual void emitUpdateTextLabel(const RTextLabel& textLabel);
66 
67 signals:
68  void drop(QDropEvent* event);
69  void dragEnter(QDragEnterEvent* event);
70 
71  void viewportChanged();
72 
73  void updateSnapInfo(QPainter* painter, RSnap* snap, RSnapRestriction* restriction);
74  void updateTextLabel(QPainter* painter, const RTextLabel& textLabel);
75 
76 protected:
77  virtual QSize sizeHint() const;
78 
79  bool event(QEvent* e);
80 
81  bool gestureEvent(QGestureEvent* event);
82  //void pinchTriggered(QPinchGesture* gesture);
83  //void panTriggered(QPanGesture* gesture);
84 
85  virtual void focusInEvent(QFocusEvent* event);
86  virtual void focusOutEvent(QFocusEvent* event);
87 
88  virtual void mouseMoveEvent(QMouseEvent* event);
89  virtual void mousePressEvent(QMouseEvent* event);
90  virtual void mouseReleaseEvent(QMouseEvent* event);
91  virtual void mouseDoubleClickEvent(QMouseEvent* event);
92  virtual void wheelEvent(QWheelEvent* event);
93  virtual void paintEvent(QPaintEvent*);
94  virtual void resizeEvent(QResizeEvent* event);
95  virtual void keyPressEvent(QKeyEvent* event);
96  virtual void keyReleaseEvent(QKeyEvent* event);
97  virtual void dragEnterEvent(QDragEnterEvent* event);
98  virtual void dropEvent(QDropEvent* event);
99 
100 private:
101  QTransform previousView;
103  Qt::MouseButtons lastButtonState;
104 
105  bool showFocus;
106 
108  QCursor lastCursor;
109 
111 };
112 
114 
115 #endif