Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
diagramwidget.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
23 #ifndef DIAGRAMWIDGET_H
24 #define DIAGRAMWIDGET_H
25 
26 
27 #include <QGraphicsView>
28 #include <QGraphicsProxyWidget>
29 #include "planargraph.h"
30 #include "diagram.h"
31 #include "latexLink.h"
32 
33 class MainWindow;
34 class QLabel;
35 namespace drawer {
36 class Graph;
37 }
38 
39 class Node;
40 class Edge;
41 
42 class Proxy;
43 class DiagramWidget : public QGraphicsView
44 {
45  Q_OBJECT
46 
47  friend class MainWindow;
48  friend class MainWidget;
49  friend class DiagramRenderer;
50 
51 public:
52  DiagramWidget(QGraphicsScene *t_scene,
53  qint32 t_X0,
54  qint32 t_Y0,
55  QWidget *parent,
56  Diagram *t_diagram);
57 
58 
59  ~DiagramWidget() override;
60 
61  void setUpScene();
62 
63  QPointF getCursorPos() const;
64 
65 public slots:
66  void zoom(double scale);
67  void zoomIn();
68  void zoomOut();
69  void centerScene();
70  void addLabel();
71 
72  void enableDiagram() { diagramEnabled = true; }
73  void disableDiagram() { diagramEnabled = false; }
74 
75 signals:
76 
77  void zoom(QWheelEvent *event);
78 
79 protected:
80  void keyPressEvent(QKeyEvent *event) override;
81  void keyReleaseEvent(QKeyEvent *event) override;
82  void mouseMoveEvent(QMouseEvent *event) override;
83  void mousePressEvent(QMouseEvent *event) override;
84  void mouseReleaseEvent(QMouseEvent *event) override;
85  void mouseDoubleClickEvent(QMouseEvent *event) override;
86  void wheelEvent(QWheelEvent *event) override;
87 
88  void scaleView(qreal scaleFactor);
89 
90 public:
91  static constexpr qint32 dx = 16;
92 private:
93 
94  QGraphicsScene *scene;
95  Diagram *diagram;
96  bool diagramEnabled;
97  qint32 X0;
98  qint32 Y0;
99  qint32 LX;
100  qint32 LY;
101 };
102 
103 
104 #endif // DIAGRAMWIDGET_H
Definition: node.h:39
Definition: drawer.h:29
Definition: edge.h:40
Definition: diagramrenderer.h:40
Definition: diagram.h:52
Definition: diagramwidget.h:43
Definition: diagram.h:243
Definition: mainwindow.h:33
Definition: mainwidget.h:34