Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
mainwindow.cpp
Go to the documentation of this file.
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 
5 #include <QHBoxLayout>
6 
7 using namespace frechet;
8 using namespace view;
9 using namespace app;
13 MainWindow::MainWindow(QWidget *parent) :
14  QMainWindow(parent),
15  ui(new Ui::MainWindow)
16 {
17  ui->setupUi(this);
18  ui->actionAbout->setMenuRole(QAction::AboutRole);
19  ui->actionAbout_Qt->setMenuRole(QAction::AboutQtRole);
20 
21  splitter = new QSplitter(Qt::Horizontal);
22  QIcon wicon(":/frechet-view.svg");
23  setWindowIcon(wicon);
24 
25  overlayWindow=nullptr;
26 
27  curveView = new CurveView(this);
28  freeSpaceView = new FreeSpaceView(this);
29  freeSpaceView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
30  controlPanel = new ControlPanel(this);
31 
32  QWidget* leftPane = new QWidget(this);
33  QBoxLayout* vlayout = new QVBoxLayout(leftPane);
34  vlayout->setContentsMargins(0,0,0,0);
35  vlayout->addWidget(curveView);
36  vlayout->addWidget(controlPanel);
37  leftPane->setLayout(vlayout);
38 
39  splitter->addWidget(leftPane);
40  splitter->addWidget(freeSpaceView);
41  splitter->setStretchFactor(0,1);
42  splitter->setStretchFactor(1,4);
43 
44  QHBoxLayout *layout = new QHBoxLayout;
45  layout->addWidget(splitter);
46 
47  //setCentralWidget(new QWidget());
48  centralWidget()->setLayout(layout);
49  addToolBar(Qt::TopToolBarArea, ui->mainToolBar);
50 
51  setWindowTitle(tr("Fréchet View"));
52  //restoreSettings();
53  setUnifiedTitleAndToolBarOnMac(true);
54 
55  //ui->actionPrint_Curve->setIcon(QIcon(":/awesome/print.svg"));
56  //ui->actionPrint_Free_Space->setIcon(QIcon(":/awesome/print.svg"));
57 
58  connect( ui->actionEdit_Curve, SIGNAL(triggered(bool)),
59  FrechetViewApplication::instance(), SLOT(editInputFile()));
60 
61  connect( ui->actionSave_Curve_As, SIGNAL(triggered()),
62  curveView, SLOT(saveAs()));
63 
64  connect( ui->actionSave_Free_Space_As, SIGNAL(triggered()),
65  freeSpaceView, SLOT(saveAs()));
66 
67  connect( ui->actionPrint_Curve, SIGNAL(triggered()),
68  curveView, SLOT(print()));
69 
70  connect( ui->actionPrint_Free_Space, SIGNAL(triggered()),
71  freeSpaceView, SLOT(print()));
72 
73  connect( ui->actionShow_Bounds, SIGNAL(triggered(bool)),
74  freeSpaceView, SLOT(showBounds(bool)));
75 
76  connect( ui->actionShow_Bounds, SIGNAL(triggered(bool)),
77  controlPanel, SLOT(onShowBounds(bool)));
78 
79  connect( ui->actionFull_Screen, SIGNAL(triggered(bool)),
80  this, SLOT(enterFullScreen(bool)));
81 
82  connect( ui->actionSeparate_Curves, SIGNAL(triggered(bool)),
83  curveView, SLOT(setSeparateCurves(bool)));
84 
85  connect( ui->actionAbout, SIGNAL(triggered(bool)),
86  FrechetViewApplication::instance(), SLOT(showAboutDialog()));
87 
88  connect( ui->actionAbout_Qt, SIGNAL(triggered(bool)),
89  qApp, SLOT(aboutQt()));
90 
91  connect( ui->actionCreate_Desktop_Icon, SIGNAL(triggered(bool)),
92  FrechetViewApplication::instance(), SLOT(createDesktopEntry()));
93 
94  connect( controlPanel, SIGNAL(epsilonChanged(double)),
95  freeSpaceView, SLOT(calculateFreeSpace(double)));
96 
97  connect( controlPanel, SIGNAL(showGreedyResult()),
98  freeSpaceView, SLOT(showGreedyResult()));
99  connect( controlPanel, SIGNAL(showOptimalResult()),
100  freeSpaceView, SLOT(showOptimalResult()));
101  connect( controlPanel, SIGNAL(hideResult()),
102  freeSpaceView, SLOT(hideResult()));
103 
104  connect( freeSpaceView, SIGNAL(curveFinished(bool)),
105  controlPanel, SLOT(onCurveFinished(bool)));
106 
107  connect( curveView, SIGNAL(hiliteSegment(int,int,int)),
108  freeSpaceView, SLOT(onHiliteSegment(int,int,int)));
109  connect( freeSpaceView, SIGNAL(hiliteSegment(int,int,int)),
110  curveView, SLOT(onHiliteSegment(int,int,int)));
111 
112  connect( FrechetViewApplication::instance(), SIGNAL(fileOpened(QString)),
113  controlPanel, SLOT(updatePolyResult()));
114 
115  connect( FrechetViewApplication::instance(), SIGNAL(algorithmChanged(int)),
116  curveView, SLOT(onAlgorithmChanged(int)));
117  connect( FrechetViewApplication::instance(), SIGNAL(algorithmChanged(int)),
118  freeSpaceView, SLOT(onAlgorithmChanged(int)));
119 
120  connect( ui->actionShow_Animation, SIGNAL(triggered(bool)),
121  this, SLOT(showHideAnimation()), Qt::QueuedConnection);
122  connect( ui->actionShow_XAnimation, SIGNAL(triggered(bool)),
123  this, SLOT(showHideXAnimation()), Qt::QueuedConnection);
124  connect( ui->actionStart_Animation, SIGNAL(triggered(bool)),
125  this, SLOT(startStopAnimation()), Qt::QueuedConnection);
126  connect( ui->actionStart_FSAnimation, SIGNAL(triggered(bool)),
127  this, SLOT(startStopFSAnimation()), Qt::QueuedConnection);
128  connect( ui->actionStart_CVAnimation, SIGNAL(triggered(bool)),
129  this, SLOT(startStopCVAnimation()), Qt::QueuedConnection);
130  connect( ui->actionStart_ProjectionAnimation, SIGNAL(triggered(bool)),
131  this, SLOT(startStopProjectionAnimation()), Qt::QueuedConnection);
132 
133 }
134 
136 {
137  //no need to delete because all objects a children of this
138 }
139 
140 void MainWindow::closeEvent(QCloseEvent *event)
141 {
142  FrechetViewApplication::instance()->windowClosed(this);
143  QMainWindow::closeEvent(event);
144 }
145 
146 QAction* MainWindow::actionOpen() { return ui->actionOpen; }
147 QAction* MainWindow::actionOpenRecent() { return ui->actionOpen_Recent; }
148 QAction* MainWindow::actionQuit() { return ui->actionQuit; }
149 
150 void MainWindow::saveSettings(QSettings& settings)
151 {
152  settings.setValue("main.Window.Geometry", saveGeometry());
153  settings.setValue("main.Window.State", saveState());
154 
155  settings.setValue("main.Window.Splitter.Geometry", splitter->saveGeometry());
156  settings.setValue("main.Window.Splitter.State", splitter->saveState());
157 
158  curveView->saveSettings(settings,"view.curve");
159  freeSpaceView->saveSettings(settings,"view.freeSpace");
160  controlPanel->saveSettings(settings,"controls");
161 }
168 void MainWindow::restoreSettings(QSettings& settings)
169 {
170 
171  restoreGeometry(settings.value("main.Window.Geometry").toByteArray());
172  restoreState(settings.value("main.Window.State").toByteArray());
173 
174  splitter->restoreGeometry(settings.value("main.Window.Splitter.Geometry").toByteArray());
175  splitter->restoreState(settings.value("main.Window.Splitter.State").toByteArray());
176 
177  curveView->restoreSettings(settings,"view.curve");
178  freeSpaceView->restoreSettings(settings,"view.freeSpace");
179  controlPanel->restoreSettings(settings,"controls");
180 
183  ui->actionFull_Screen->setChecked(this->isFullScreen());
184 }
185 
187 {
188  ui->actionShow_Bounds->setChecked(on);
189 }
190 
192 {
193  ui->actionSeparate_Curves->setChecked(on);
194 }
195 
197 {
198  if (full)
199  this->showFullScreen();
200  else
201  this->showNormal();
202 }
FreeSpaceView * freeSpaceView
free-space view
Definition: mainwindow.h:110
bool separateCurves() const
Definition: curveview.h:56
global definitions for all algorithms.
(auto-generated by Qt)
The single application window.
Definition: mainwindow.h:33
Ui::MainWindow * ui
widgets (auto-generated by Qt)
Definition: mainwindow.h:105
void restoreSettings(QSettings &settings)
load settings from application preferences
Definition: mainwindow.cpp:168
void enterFullScreen(bool fullscreen)
enter/leave full-screen mode
Definition: mainwindow.cpp:196
void saveSettings(QSettings &settings)
store settings to application preferences
Definition: mainwindow.cpp:150
displays input curves P and Q.
Definition: curveview.h:22
virtual void restoreSettings(QSettings &settings, QString group)
load settings from application preferences
Definition: curveview.cpp:189
ControlPanel * controlPanel
control panel
Definition: mainwindow.h:112
CurveView * curveView
curve view
Definition: mainwindow.h:108
display the free-space diagram.
QSplitter * splitter
splitter between panels
Definition: mainwindow.h:114
virtual void saveSettings(QSettings &settings, QString group)
store settings to application preferences
Definition: curveview.cpp:180
void saveSettings(QSettings &settings, QString group)
store settings to application preferences
AnimationDialog * overlayWindow
Definition: mainwindow.h:117
void restoreSettings(QSettings &settings, QString group)
load settings from application preferences
virtual void restoreSettings(QSettings &settings, QString group)
load settings from application preferences
virtual void saveSettings(QSettings &settings, QString group)
store settings to application preferences
~MainWindow()
destructor; closes the window, releases all widgets
Definition: mainwindow.cpp:135
void setSeparateCurves(bool separate)
called when the user clicks the "Separate Curves" button
Definition: mainwindow.cpp:191
void setShowBounds(bool show)
called when the user clicks the "Show Bounds" button
Definition: mainwindow.cpp:186
void closeEvent(QCloseEvent *event)
catch window close event and quit the application
Definition: mainwindow.cpp:140
MainWindow(QWidget *parent=0)
default constructor
Definition: mainwindow.cpp:13