-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCGTeaMainWindow.cpp
More file actions
executable file
·102 lines (87 loc) · 4.08 KB
/
Copy pathCGTeaMainWindow.cpp
File metadata and controls
executable file
·102 lines (87 loc) · 4.08 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
#include "CGTeaMainWindow.h"
#include <QtWidgets>
CGTeaMainWindow::CGTeaMainWindow()
{
widget = new ThemeWidget();
setCentralWidget(widget);
createMenus();
QString message = tr("A context menu is available by right-clicking");
statusBar()->showMessage(message);
}
void CGTeaMainWindow::createMenus()
{
auto generateMenu = menuBar()->addMenu(tr("&Generate"));
for(auto& g : widget->graphRelatedGatherer.availableGenerators) {
auto newAct = new QAction(tr((string("&")+g->name()).c_str()), this);
newAct->setData(QString::fromStdString(g->name()));
// newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr(g->description().c_str()));
generateMenu->addAction(newAct);
}
connect(generateMenu, &QMenu::triggered, this, &CGTeaMainWindow::generate);
auto reportMenu = menuBar()->addMenu(tr("&Report"));
for(auto& g : widget->graphRelatedGatherer.availableReports) {
auto newAct = new QAction(tr((string("&")+g->name()).c_str()), this);
newAct->setData(QString::fromStdString(g->name()));
// newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr(g->description().c_str()));
reportMenu->addAction(newAct);
}
connect(reportMenu, &QMenu::triggered, this, &CGTeaMainWindow::report);
auto actionMenu = menuBar()->addMenu(tr("&Action"));
for(auto& g : widget->graphRelatedGatherer.availableActions) {
auto newAct = new QAction(tr((string("&")+g->name()).c_str()), this);
newAct->setData(QString::fromStdString(g->name()));
// newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr(g->description().c_str()));
actionMenu->addAction(newAct);
// connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
}
connect(actionMenu, &QMenu::triggered, this, &CGTeaMainWindow::action);
auto binaryOperationMenu = menuBar()->addMenu(tr("&Binary Operations"));
for(auto& g : widget->graphRelatedGatherer.availableBinaryOperations) {
auto newAct = new QAction(tr((string("&")+g->name()).c_str()), this);
newAct->setData(QString::fromStdString(g->name()));
// newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr(g->description().c_str()));
binaryOperationMenu->addAction(newAct);
// connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
}
connect(binaryOperationMenu, &QMenu::triggered, this, &CGTeaMainWindow::binaryOperation);
}
void CGTeaMainWindow::generate(QAction* act) {
// themeComboBox
// widget->m_ui->
auto& rs = widget->graphRelatedGatherer.availableGenerators;
auto name = act->data().toString().toStdString();
auto el = std::find_if(rs.begin(), rs.end(),[&name](const auto& x) {return x->name().compare(name)==0;});
if(el != rs.end()) {
if(widget->whichGraphIsSelected() == "G1")
widget->updateG1View( (*el)->generate_with_positions(10, 2, cgtea_geometry::Point(100,100), cgtea_geometry::Point(200,200)));
else
widget->updateG2View( (*el)->generate_with_positions(10, 2, cgtea_geometry::Point(100,100), cgtea_geometry::Point(200,200)));
}
}
void CGTeaMainWindow::report(QAction* act) {
auto& rs = widget->graphRelatedGatherer.availableReports;
auto name = act->data().toString().toStdString();
auto el = std::find_if(rs.begin(), rs.end(),[&name](const auto& x) {return x->name().compare(name)==0;});
if(el != rs.end()) {
// auto res = (*el)->report(widget->currentGraph);
}
}
void CGTeaMainWindow::action(QAction* act) {
auto& rs = widget->graphRelatedGatherer.availableReports;
auto name = act->data().toString().toStdString();
auto el = std::find_if(rs.begin(), rs.end(),[&name](const auto& x) {return x->name().compare(name)==0;});
if(el != rs.end()) {
}
}
void CGTeaMainWindow::binaryOperation(QAction* act) {
auto& rs = widget->graphRelatedGatherer.availableBinaryOperations;
auto name = act->data().toString().toStdString();
auto el = std::find_if(rs.begin(), rs.end(),[&name](const auto& x) {return x->name().compare(name)==0;});
if(el != rs.end()) {
widget->updateG1View((*el)->operate(widget->getG1(), widget->getG2()));
}
}