-
-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathmainwindow.h
More file actions
213 lines (132 loc) · 4.88 KB
/
mainwindow.h
File metadata and controls
213 lines (132 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <nodes/Node>
#include <QTreeWidgetItem>
#include <QShortcut>
#include <QTimer>
#include <deque>
#include <thread>
#include <mutex>
#include <nodes/DataModelRegistry>
#include "graphic_container.h"
#include "XML_utilities.hpp"
#include "sidepanel_editor.h"
#include "sidepanel_replay.h"
#include "models/SubtreeNodeModel.hpp"
#ifdef ZMQ_FOUND
#include "sidepanel_monitor.h"
#endif
namespace Ui {
class MainWindow;
}
namespace QtNodes{
class FlowView;
class FlowScene;
class Node;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
enum SubtreeExpandOption{ SUBTREE_EXPAND,
SUBTREE_COLLAPSE,
SUBTREE_CHANGE,
SUBTREE_REFRESH};
public:
explicit MainWindow(GraphicMode initial_mode, QWidget *parent = nullptr);
~MainWindow() override;
void loadFromXML(const QString &xml_text);
QString saveToXML() const ;
GraphicContainer* currentTabInfo();
GraphicContainer *getTabByName(const QString& name);
void clearTreeModels();
const NodeModels ®isteredModels() const;
void resetTreeStyle(AbsBehaviorTree &tree);
GraphicMode getGraphicMode(void) const;
public slots:
void onAutoArrange();
void onSceneChanged();
void onPushUndo();
void onUndoInvoked();
void onRedoInvoked();
void onConnectionUpdate(bool connected);
void onRequestSubTreeExpand(GraphicContainer& container,
QtNodes::Node& node);
void onAddToModelRegistry(const NodeModel& model);
void onDestroySubTree(const QString &ID);
void onModelRemoveRequested(QString ID);
virtual void closeEvent(QCloseEvent *event) override;
void on_actionLoad_triggered();
void on_actionSave_triggered();
void on_splitter_splitterMoved(int pos = 0, int index = 0);
void on_toolButtonReorder_pressed();
void on_toolButtonCenterView_pressed();
void onCreateAbsBehaviorTree(const AbsBehaviorTree &tree,
const QString &bt_name,
bool secondary_tabs = true);
void onChangeNodesStatus(const QString& bt_name, const std::vector<std::pair<int, NodeStatus>>& node_status);
void on_toolButtonLayout_clicked();
void on_actionEditor_mode_triggered();
void on_actionMonitor_mode_triggered();
void on_actionReplay_mode_triggered();
void on_tabWidget_currentChanged(int index);
void onActionClearTriggered(bool create_new);
void on_actionClear_triggered();
void onTreeNodeEdited(QString prev_ID, QString new_ID);
void onTabCustomContextMenuRequested(const QPoint &pos);
void onTabRenameRequested(int tab_index, QString new_name = QString());
void onTabSetMainTree(int tab_index);
signals:
void updateGraphic();
private slots:
void on_actionAbout_triggered();
void on_actionReportIssue_triggered();
public:
void lockEditing(const bool locked);
private:
void updateCurrentMode();
bool eventFilter(QObject *obj, QEvent *event) override;
void resizeEvent(QResizeEvent *) override;
GraphicContainer* createTab(const QString &name);
void refreshNodesLayout(QtNodes::PortLayout new_layout);
void refreshExpandedSubtrees();
void streamElementAttributes(QXmlStreamWriter &stream, const QDomElement &element) const;
QString xmlDocumentToString(const QDomDocument &document) const;
void recursivelySaveNodeCanonically(QXmlStreamWriter &stream, const QDomNode &parent_node) const;
struct SavedState
{
QString main_tree;
QString current_tab_name;
QTransform view_transform;
QRectF view_area;
std::map<QString, QByteArray> json_states;
bool operator ==( const SavedState& other) const;
bool operator !=( const SavedState& other) const { return !( *this == other); }
};
void loadSavedStateFromJson(SavedState state);
QtNodes::Node *subTreeExpand(GraphicContainer& container,
QtNodes::Node &node,
SubtreeExpandOption option);
Ui::MainWindow *ui;
GraphicMode _current_mode;
std::shared_ptr<QtNodes::DataModelRegistry> _model_registry;
std::map<QString, GraphicContainer*> _tab_info;
// 1st string is ros_pkg (empty if ros isn't used), 2nd is path
std::vector<std::array<std::string, 2>> _includes;
std::mutex _mutex;
std::deque<SavedState> _undo_stack;
std::deque<SavedState> _redo_stack;
SavedState _current_state;
QtNodes::PortLayout _current_layout;
NodeModels _treenode_models;
QString _main_tree;
SidepanelEditor* _editor_widget;
SidepanelReplay* _replay_widget;
#ifdef ZMQ_FOUND
SidepanelMonitor* _monitor_widget;
#endif
MainWindow::SavedState saveCurrentState();
void clearUndoStacks();
};
#endif // MAINWINDOW_H