Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
diagramrenderer.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 DIAGRAMRENDERER_H
24 #define DIAGRAMRENDERER_H
25 
26 #include <QScrollArea>
27 #include <QList>
28 #include <QGridLayout>
29 #include <QTableWidget>
30 #include "diagramwidget.h"
31 #include "diagram.h"
32 #include "grid.h"
33 
34 namespace Ui {
35 class DiagramRenderer;
36 }
37 
38 class EdgeForm;
39 class NodeForm;
40 class DiagramRenderer : public QWidget
41 {
42  Q_OBJECT
43 
44  friend class MainWidget;
45 
46  enum Mode {
47  DiagramMode,
48  SessionMode
49  };
50 
51 public:
52 
53  static inline qint32 maxNDiagrams = 100;
54 
55 private:
56  explicit DiagramRenderer(QWidget *parent = nullptr);
57 public:
58  explicit DiagramRenderer(
59  QString const &nameFile,
60  QWidget *parent = nullptr);
61  ~DiagramRenderer() override;
62 
63 public slots:
64 
65  void clear();
66  void init();
67 
68  latexcompiler *getLatexCompiler() const {
69  return compiler;
70  }
71 
72  void toggle();
73  void updateGrid(int factor = 0);
74  void displayGrid(bool display);
75  void forceNodesOnGrid(bool);
76 
77  void centerDiagram();
78  void updateZoom(int zoom);
79  void rotateDiagram(int rotation);
80  bool setDiagramMode();
81  void setSessionMode();
82  void setTable();
83  bool setDiagram(qint32 i = -1);
84  void cellPressed(int i, int j);
85  void resetSelection();
86 
87  // Function not ready to be used
88  void setDiagramSet(qint32 first, qint32 last);
89 
90  bool hasEdgeForm() {
91  return edgeForm;
92  }
93  bool hasNodeForm() {
94  return nodeForm;
95  }
96  void closeEdgeForm();
97  void openEdgeForm(Edge *edge);
98 
99  void closeNodeForm();
100  void openNodeForm(Node *node);
101 
102  void keyPressEvent(QKeyEvent *event) override;
103  void mousePressEvent(QMouseEvent *event) override;
104  void readFile(QString const &nameFile);
105  void addDiagram();
106 
107  void diagramDoubleClicked(qint32, qint32);
108 
109  void add();
110  void select();
111  void erase();
112  void save(QString const &fileName);
113  void copy();
114  void paste();
115  void paste(qint32 pos);
116  void refresh(qint32 pos);
117 
118  void modificationDone();
119 
120 signals:
121 
122 
123  void diagramMode();
124  void sessionMode();
125 
126  void nonEmptySelection(bool);
127 
128  void modif();
129 
130 protected:
131 
132  std::pair<Diagram*, DiagramWidget*>
133  generateDiagram(qint32 iRow, qint32 iCol);
134  std::pair<Diagram*, DiagramWidget*> newDiagram();
135 
136 private:
137 
138  Ui::DiagramRenderer *m_ui;
139  QHBoxLayout *hlayout;
140  Mode mode;
141  qint32 nColumns;
142  qint32 minWidth;
143  qint32 minHeight;
144  qint32 firstDiag;
145  qint32 lastDiag;
146  std::vector<drawer::LatexLinker> links;
147  QList<Diagram*> allDiagrams;
148  QList<Diagram*> diagrams;
149  QList<std::pair<int, int>> selectedDiagrams;
150  qint32 indexDiagram;
151  QList<qint32> clipBoardDiagram;
152  latexcompiler *compiler;
153  DiagramWidget *diag;
154  QTableWidget *table;
155  QGraphicsScene *scene;
156  EdgeForm *edgeForm;
157  NodeForm *nodeForm;
158  qreal zoomValue;
159  Grid grid;
160  bool displayGridValue;
161 };
162 
163 #endif // DIAGRAMRENDERER_H
Definition: node.h:39
Definition: diagramrenderer.h:34
Definition: edgeform.h:34
Definition: grid.h:30
Definition: edge.h:40
Definition: latexcompiler.h:25
void readFile(std::string const &fileName)
Load a .lha file for built-in values in MARTY, in particular SM and MSSM inputs.
Definition: lhaBuiltIn.cpp:27
Definition: diagramrenderer.h:40
Definition: diagramwidget.h:43
Definition: nodeform.h:35
Definition: mainwidget.h:34