-
Notifications
You must be signed in to change notification settings - Fork 948
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (61 loc) · 1.72 KB
/
main.cpp
File metadata and controls
81 lines (61 loc) · 1.72 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
#include "state_node_model.h"
#include <nodes/FlowScene>
#include <nodes/FlowView>
#include <nodes/ConnectionStyle>
#include <QApplication>
#include <QMenuBar>
#include <QBoxLayout>
using QtNodes::FlowScene;
using QtNodes::FlowView;
using QtNodes::DataModelRegistry;
using QtNodes::ConnectionStyle;
std::shared_ptr<DataModelRegistry> registerDataModels()
{
std::shared_ptr<DataModelRegistry> registry(new DataModelRegistry());
registry->registerModel<StateNodeModel>();
return registry;
}
static
void
setStyle()
{
ConnectionStyle::setConnectionStyle(
R"(
{
"ConnectionStyle": {
"ConstructionColor": "gray",
"NormalColor": "black",
"SelectedColor": "gray",
"SelectedHaloColor": "deepskyblue",
"HoveredColor": "deepskyblue",
"LineWidth": 3.0,
"ConstructionLineWidth": 2.0,
"PointDiameter": 10.0,
"UseDataDefinedColors": true
}
}
)");
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
setStyle();
QWidget mainWidget;
auto menuBar = new QMenuBar();
auto saveAction = menuBar->addAction("Save..");
auto loadAction = menuBar->addAction("Load..");
QVBoxLayout *l = new QVBoxLayout(&mainWidget);
l->addWidget(menuBar);
auto scene = new FlowScene(registerDataModels(), &mainWidget);
l->addWidget(new FlowView(scene));
l->setContentsMargins(0, 0, 0, 0);
l->setSpacing(0);
QObject::connect(saveAction, &QAction::triggered,
scene, &FlowScene::save);
QObject::connect(loadAction, &QAction::triggered,
scene, &FlowScene::load);
mainWidget.setWindowTitle("Simplest state editor");
mainWidget.resize(800, 600);
mainWidget.showNormal();
return app.exec();
}