MNE-CPP  beta 1.0
mainwindow.cpp
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
44 
45 //GUI
46 #include "mainwindow.h"
47 #include "runwidget.h"
48 #include "startupwidget.h"
49 #include "plugingui.h"
50 
51 
52 //*************************************************************************************************************
53 //=============================================================================================================
54 // QT INCLUDES
55 //=============================================================================================================
56 
57 #include <QtWidgets>
58 #include <QDebug>
59 #include <QTimer>
60 #include <QTime>
61 #include <QFile>
62 #include <QFileDialog>
63 #include <QFileInfo>
64 #include <QStandardPaths>
65 
66 #include <iostream>
67 
68 
69 //*************************************************************************************************************
70 //=============================================================================================================
71 // USED NAMESPACES
72 //=============================================================================================================
73 
74 using namespace MNEX;
75 
76 
77 //*************************************************************************************************************
78 //=============================================================================================================
79 // CONST
80 //=============================================================================================================
81 
82 const char* pluginDir = "/mne_x_plugins";
85 //*************************************************************************************************************
86 //=============================================================================================================
87 // DEFINE MEMBER METHODS
88 //=============================================================================================================
89 
90 MainWindow::MainWindow(QWidget *parent)
91 : QMainWindow(parent)
92 , m_pStartUpWidget(new StartUpWidget(this))
93 , m_pRunWidget(NULL)
94 , m_pDisplayManager(new DisplayManager(this))
95 , m_bDisplayMax(false)
96 , m_bIsRunning(false)
97 , m_pToolBar(NULL)
98 , m_pDynamicPluginToolBar(NULL)
99 , m_pDynamicDisplayToolBar(NULL)
100 , m_pLabelTime(NULL)
101 , m_pTimer(NULL)
102 , m_pTime(new QTime(0, 0))
103 , m_iTimeoutMSec(1000)
104 , m_pPluginGui(NULL)
105 , m_pPluginManager(new PluginManager(this))
106 , m_pPluginSceneManager(new PluginSceneManager(this))
107 , m_eLogLevelCurrent(_LogLvMax)
108 {
109  qDebug() << "MNE-X - Version" << CInfo::AppVersion();
110 
111  setCentralWidget(m_pStartUpWidget);
112 
113  setWindowTitle(CInfo::AppNameShort());
114  setMinimumSize(400, 400);
115  resize(1280, 800);
116 
117  setUnifiedTitleAndToolBarOnMac(true);
118 
119  m_pPluginManager->loadPlugins(qApp->applicationDirPath()+pluginDir);
120 
121  createActions();
122  createMenus();
123  createToolBars();
124  createPluginDockWindow();
125  createLogDockWindow();
126 
127 // //ToDo Debug Startup
128 // writeToLog(tr("Test normal message, Max"), _LogKndMessage, _LogLvMax);
129 // writeToLog(tr("Test warning message, Normal"), _LogKndWarning, _LogLvNormal);
130 // writeToLog(tr("Test error message, Min"), _LogKndError, _LogLvMin);
131 
132  initStatusBar();
133 }
134 
135 
136 //*************************************************************************************************************
137 
139 {
140  clear();
141 
142  //clean
143  if(m_pToolBar)
144  {
145  if(m_pLabelTime)
146  delete m_pLabelTime;
147  m_pLabelTime = NULL;
148  delete m_pToolBar;
149  }
150 
151  if(m_pDynamicPluginToolBar)
152  delete m_pDynamicPluginToolBar;
153 
154  if(m_pDynamicDisplayToolBar)
155  delete m_pDynamicDisplayToolBar;
156 }
157 
158 
159 //*************************************************************************************************************
160 
162 {
163  if(m_bIsRunning)
164  this->stopMeasurement();
165 }
166 
167 
168 //*************************************************************************************************************
169 
170 void MainWindow::closeEvent(QCloseEvent *event)
171 {
172  QMainWindow::closeEvent(event);
173 }
174 
175 
176 
177 //*************************************************************************************************************
178 //File QMenu
179 void MainWindow::newConfiguration()
180 {
181  writeToLog(tr("Invoked <b>File|NewConfiguration</b>"), _LogKndMessage, _LogLvMin);
182  m_pPluginGui->clearScene();
183 }
184 
185 
186 //*************************************************************************************************************
187 
188 void MainWindow::openConfiguration()
189 {
190  writeToLog(tr("Invoked <b>File|OpenConfiguration</b>"), _LogKndMessage, _LogLvMin);
191 
192  QString path = QFileDialog::getOpenFileName(this,
193  "Open MNE-X Configuration File",
194  QStandardPaths::writableLocation(QStandardPaths::DataLocation),
195  tr("Configuration file (*.xml)"));
196 
197  QFileInfo qFileInfo(path);
198  m_pPluginGui->loadConfig(qFileInfo.path(), qFileInfo.fileName());
199 }
200 
201 
202 //*************************************************************************************************************
203 
204 void MainWindow::saveConfiguration()
205 {
206  writeToLog(tr("Invoked <b>File|SaveConfiguration</b>"), _LogKndMessage, _LogLvMin);
207 
208  QString path = QFileDialog::getSaveFileName(
209  this,
210  "Save MNE-X Configuration File",
211  QStandardPaths::writableLocation(QStandardPaths::DataLocation),
212  tr("Configuration file (*.xml)"));
213 
214  QFileInfo qFileInfo(path);
215  m_pPluginGui->saveConfig(qFileInfo.path(), qFileInfo.fileName());
216 }
217 
218 
219 //*************************************************************************************************************
220 //Help QMenu
221 void MainWindow::helpContents()
222 {
223  writeToLog(tr("Invoked <b>Help|HelpContents</b>"), _LogKndMessage, _LogLvMin);
224 }
225 
226 
227 //*************************************************************************************************************
228 
229 void MainWindow::about()
230 {
231  writeToLog(tr("Invoked <b>Help|About</b>"), _LogKndMessage, _LogLvMin);
232  QMessageBox::about(this, CInfo::AppNameShort()+ ", "+tr("Version ")+CInfo::AppVersion(),
233  tr("Copyright (C) 2013 Christoph Dinh, Martin Luessi, Limin Sun, Jens Haueisen, Matti Hamalainen. All rights reserved.\n\n"
234  "Redistribution and use in source and binary forms, with or without modification, are permitted provided that"
235  " the following conditions are met:\n"
236  "\t* Redistributions of source code must retain the above copyright notice, this list of conditions and the"
237  " following disclaimer.\n"
238  "\t* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and"
239  " the following disclaimer in the documentation and/or other materials provided with the distribution.\n"
240  "\t* Neither the name of MNE-CPP authors nor the names of its contributors may be used"
241  " to endorse or promote products derived from this software without specific prior written permission.\n\n"
242  "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED"
243  " WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A"
244  " PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,"
245  " INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,"
246  " PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)"
247  " HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING"
248  " NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE"
249  " POSSIBILITY OF SUCH DAMAGE."));
250 }
251 
252 
253 //*************************************************************************************************************
254 
255 void MainWindow::setMinLogLevel()
256 {
257  writeToLog(tr("minimal log level set"), _LogKndMessage, _LogLvMin);
258  m_eLogLevelCurrent = _LogLvMin;
259 }
260 
261 
262 //*************************************************************************************************************
263 
264 void MainWindow::setNormalLogLevel()
265 {
266  writeToLog(tr("normal log level set"), _LogKndMessage, _LogLvMin);
267  m_eLogLevelCurrent = _LogLvNormal;
268 }
269 
270 
271 //*************************************************************************************************************
272 
273 void MainWindow::setMaxLogLevel()
274 {
275  writeToLog(tr("maximal log level set"), _LogKndMessage, _LogLvMin);
276  m_eLogLevelCurrent = _LogLvMax;
277 }
278 
279 //*************************************************************************************************************
280 
281 void MainWindow::createActions()
282 {
283  //File QMenu
284  m_pActionNewConfig = new QAction(QIcon(":/images/new.png"), tr("&New configuration"), this);
285  m_pActionNewConfig->setShortcuts(QKeySequence::New);
286  m_pActionNewConfig->setStatusTip(tr("Create a new configuration"));
287  connect(m_pActionNewConfig, &QAction::triggered, this, &MainWindow::newConfiguration);
288 
289  m_pActionOpenConfig = new QAction(tr("&Open configuration..."), this);
290  m_pActionOpenConfig->setShortcuts(QKeySequence::Open);
291  m_pActionOpenConfig->setStatusTip(tr("Open an existing configuration"));
292  connect(m_pActionOpenConfig, &QAction::triggered, this, &MainWindow::openConfiguration);
293 
294  m_pActionSaveConfig = new QAction(QIcon(":/images/save.png"), tr("&Save configuration..."), this);
295  m_pActionSaveConfig->setShortcuts(QKeySequence::Save);
296  m_pActionSaveConfig->setStatusTip(tr("Save the current configuration"));
297  connect(m_pActionSaveConfig, &QAction::triggered, this, &MainWindow::saveConfiguration);
298 
299  m_pActionExit = new QAction(tr("E&xit"), this);
300  m_pActionExit->setShortcuts(QKeySequence::Quit);
301  m_pActionExit->setStatusTip(tr("Exit the application"));
302  connect(m_pActionExit, &QAction::triggered, this, &MainWindow::close);
303 
304  //View QMenu
305  m_pActionMinLgLv = new QAction(tr("&Minimal"), this);
306  m_pActionMinLgLv->setCheckable(true);
307  m_pActionMinLgLv->setShortcut(tr("Ctrl+1"));
308  m_pActionMinLgLv->setStatusTip(tr("Open an existing file"));
309  connect(m_pActionMinLgLv, &QAction::triggered, this, &MainWindow::setMinLogLevel);
310 
311  m_pActionNormLgLv = new QAction(tr("&Normal"), this);
312  m_pActionNormLgLv->setCheckable(true);
313  m_pActionNormLgLv->setShortcut(tr("Ctrl+2"));
314  m_pActionNormLgLv->setStatusTip(tr("Save the document to disk"));
315  connect(m_pActionNormLgLv, &QAction::triggered, this, &MainWindow::setNormalLogLevel);
316 
317  m_pActionMaxLgLv = new QAction(tr("Maximal"), this);
318  m_pActionMaxLgLv->setCheckable(true);
319  m_pActionMaxLgLv->setShortcut(tr("Ctrl+3"));
320  m_pActionMaxLgLv->setStatusTip(tr("Exit the application"));
321  connect(m_pActionMaxLgLv, &QAction::triggered, this, &MainWindow::setMaxLogLevel);
322 
323  m_pActionGroupLgLv = new QActionGroup(this);
324  m_pActionGroupLgLv->addAction(m_pActionMinLgLv);
325  m_pActionGroupLgLv->addAction(m_pActionNormLgLv);
326  m_pActionGroupLgLv->addAction(m_pActionMaxLgLv);
327  if (m_eLogLevelCurrent == _LogLvMin){
328  m_pActionMinLgLv->setChecked(true);}
329  else if (m_eLogLevelCurrent == _LogLvNormal){
330  m_pActionNormLgLv->setChecked(true);}
331  else {
332  m_pActionMaxLgLv->setChecked(true);}
333 
334  //Help QMenu
335  m_pActionHelpContents = new QAction(tr("Help &Contents"), this);
336  m_pActionHelpContents->setShortcuts(QKeySequence::HelpContents);
337  m_pActionHelpContents->setStatusTip(tr("Show the help contents"));
338  connect(m_pActionHelpContents, &QAction::triggered, this, &MainWindow::helpContents);
339 
340  m_pActionAbout = new QAction(tr("&About"), this);
341  m_pActionAbout->setStatusTip(tr("Show the application's About box"));
342  connect(m_pActionAbout, &QAction::triggered, this, &MainWindow::about);
343 
344  //QToolbar
345  m_pActionRun = new QAction(QIcon(":/images/run.png"), tr("Run (F5)"), this);
346  m_pActionRun->setShortcut(tr("F5"));
347  m_pActionRun->setStatusTip(tr("Runs (F5) ")+CInfo::AppNameShort());
348  connect(m_pActionRun, &QAction::triggered, this, &MainWindow::startMeasurement);
349 
350  m_pActionStop = new QAction(QIcon(":/images/stop.png"), tr("Stop (F6)"), this);
351  m_pActionStop->setShortcut(tr("F6"));
352  m_pActionStop->setStatusTip(tr("Stops (F6) ")+CInfo::AppNameShort());
353  connect(m_pActionStop, &QAction::triggered, this, &MainWindow::stopMeasurement);
354 
355  m_pActionZoomStd = new QAction(QIcon(":/images/zoomStd.png"), tr("Standard Zoom (Ctrl+0)"), this);
356  m_pActionZoomStd->setShortcut(tr("Ctrl+0"));
357  m_pActionZoomStd->setStatusTip(tr("Sets the standard Zoom (Ctrl+0)"));
358  connect(m_pActionZoomStd, &QAction::triggered, this, &MainWindow::zoomStd);
359 
360  m_pActionZoomIn = new QAction(QIcon(":/images/zoomIn.png"), tr("Zoom In ")+QKeySequence(QKeySequence::ZoomIn).toString(), this);
361  m_pActionZoomIn->setShortcuts(QKeySequence::ZoomIn);
362  m_pActionZoomIn->setStatusTip(tr("Zooms in the magnitude ")+QKeySequence(QKeySequence::ZoomIn).toString());
363  connect(m_pActionZoomIn, &QAction::triggered, this, &MainWindow::zoomIn);
364 
365  m_pActionZoomOut = new QAction(QIcon(":/images/zoomOut.png"), tr("Zoom Out ")+QKeySequence(QKeySequence::ZoomOut).toString(), this);
366  m_pActionZoomOut->setShortcuts(QKeySequence::ZoomOut);
367  m_pActionZoomOut->setStatusTip(tr("Zooms out the magnitude ")+QKeySequence(QKeySequence::ZoomOut).toString());
368  connect(m_pActionZoomOut, &QAction::triggered, this, &MainWindow::zoomOut);
369 
370  m_pActionDisplayMax = new QAction(QIcon(":/images/displayMax.png"), tr("Maximize current Display (F11)"), this);
371  m_pActionDisplayMax->setShortcut(tr("F11"));
372  m_pActionDisplayMax->setStatusTip(tr("Maximizes the current display (F11)"));
373  connect(m_pActionDisplayMax, &QAction::triggered, this, &MainWindow::toggleDisplayMax);
374 }
375 
376 
377 //*************************************************************************************************************
378 
379 void MainWindow::createMenus()
380 {
381  m_pMenuFile = menuBar()->addMenu(tr("&File"));
382  m_pMenuFile->addAction(m_pActionNewConfig);
383  m_pMenuFile->addAction(m_pActionOpenConfig);
384  m_pMenuFile->addAction(m_pActionSaveConfig);
385  m_pMenuFile->addSeparator();
386  m_pMenuFile->addAction(m_pActionExit);
387 
388  m_pMenuView = menuBar()->addMenu(tr("&View"));
389  m_pMenuLgLv = m_pMenuView->addMenu(tr("&Log Level"));
390  m_pMenuLgLv->addAction(m_pActionMinLgLv);
391  m_pMenuLgLv->addAction(m_pActionNormLgLv);
392  m_pMenuLgLv->addAction(m_pActionMaxLgLv);
393  m_pMenuView->addSeparator();
394 
395  menuBar()->addSeparator();
396 
397  m_pMenuHelp = menuBar()->addMenu(tr("&Help"));
398  m_pMenuHelp->addAction(m_pActionHelpContents);
399  m_pMenuHelp->addSeparator();
400  m_pMenuHelp->addAction(m_pActionAbout);
401 
402 }
403 
404 
405 //*************************************************************************************************************
406 
407 void MainWindow::createToolBars()
408 {
409  //Control
410  if(!m_pToolBar)
411  {
412  m_pToolBar = addToolBar(tr("Control"));
413  m_pToolBar->addAction(m_pActionRun);
414  m_pToolBar->addAction(m_pActionStop);
415  m_pActionStop->setEnabled(false);
416 
417  m_pToolBar->addSeparator();
418 
419  m_pToolBar->addAction(m_pActionZoomStd);
420  m_pToolBar->addAction(m_pActionZoomIn);
421  m_pToolBar->addAction(m_pActionZoomOut);
422  m_pToolBar->addAction(m_pActionDisplayMax);
423  m_pActionZoomStd->setEnabled(false);
424  m_pActionZoomIn->setEnabled(false);
425  m_pActionZoomOut->setEnabled(false);
426  m_pActionDisplayMax->setEnabled(false);
427 
428  m_pToolBar->addSeparator();
429 
430  m_pLabelTime = new QLabel(this);
431  m_pToolBar->addWidget(m_pLabelTime);
432  m_pLabelTime->setText(QTime(0, 0).toString());
433  }
434 
435  //Plugin
436  if(m_pDynamicPluginToolBar)
437  {
438  removeToolBar(m_pDynamicPluginToolBar);
439  delete m_pDynamicPluginToolBar;
440  m_pDynamicPluginToolBar = NULL;
441  }
442  if(m_qListDynamicPluginActions.size() > 0)
443  {
444  m_pDynamicPluginToolBar = addToolBar(m_sCurPluginName + tr("Control"));
445  for(qint32 i = 0; i < m_qListDynamicPluginActions.size(); ++i)
446  m_pDynamicPluginToolBar->addAction(m_qListDynamicPluginActions[i]);
447  }
448 
449  //Display
450  if(m_pDynamicDisplayToolBar)
451  {
452  removeToolBar(m_pDynamicDisplayToolBar);
453  delete m_pDynamicDisplayToolBar;
454  m_pDynamicDisplayToolBar = NULL;
455  }
456  if(m_qListDynamicDisplayActions.size() > 0 || m_qListDynamicDisplayWidgets.size() > 0)
457  {
458  m_pDynamicDisplayToolBar = addToolBar(tr("Display"));
459  for(qint32 i = 0; i < m_qListDynamicDisplayActions.size(); ++i)
460  m_pDynamicDisplayToolBar->addAction(m_qListDynamicDisplayActions[i]);
461  for(qint32 i = 0; i < m_qListDynamicDisplayWidgets.size(); ++i)
462  m_pDynamicDisplayToolBar->addWidget(m_qListDynamicDisplayWidgets[i]);
463  }
464 
465 }
466 
467 
468 //*************************************************************************************************************
469 
470 void MainWindow::initStatusBar()
471 {
472  statusBar()->showMessage(tr("Ready"));
473 }
474 
475 
476 //*************************************************************************************************************
477 
478 void MainWindow::createPluginDockWindow()
479 {
480  m_pPluginGuiDockWidget = new QDockWidget(tr("Plugins"), this);
481  m_pPluginGuiDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
482 
483  m_pPluginGui = new PluginGui(m_pPluginManager.data(), m_pPluginSceneManager.data());
484  m_pPluginGui->setParent(m_pPluginGuiDockWidget);
485  m_pPluginGuiDockWidget->setWidget(m_pPluginGui);
486 
487  addDockWidget(Qt::LeftDockWidgetArea, m_pPluginGuiDockWidget);
488 
489  connect(m_pPluginGui, &PluginGui::selectedPluginChanged,
490  this, &MainWindow::updatePluginWidget);
491 
492  connect(m_pPluginGui, &PluginGui::selectedConnectionChanged,
493  this, &MainWindow::updateConnectionWidget);
494 }
495 
496 
497 //*************************************************************************************************************
498 
499 void MainWindow::createLogDockWindow()
500 {
501  //Log TextBrowser
502  m_pDockWidget_Log = new QDockWidget(tr("Log"), this);
503 
504  m_pTextBrowser_Log = new QTextBrowser(m_pDockWidget_Log);
505 
506  m_pDockWidget_Log->setWidget(m_pTextBrowser_Log);
507 
508  m_pDockWidget_Log->setAllowedAreas(Qt::BottomDockWidgetArea);
509  addDockWidget(Qt::BottomDockWidgetArea, m_pDockWidget_Log);
510 
511  //dock->setVisible(false);
512 
513  m_pMenuView->addAction(m_pDockWidget_Log->toggleViewAction());
514 
515 }
516 
517 
518 //*************************************************************************************************************
519 //Plugin stuff
520 void MainWindow::updatePluginWidget(IPlugin::SPtr pPlugin)
521 {
522  m_qListDynamicPluginActions.clear();
523  m_qListDynamicDisplayActions.clear();
524  m_qListDynamicDisplayWidgets.clear();
525 
526  if(!pPlugin.isNull())
527  {
528  // Add Dynamic Plugin Actions
529  m_qListDynamicPluginActions.append(pPlugin->getPluginActions());
530 
531  m_sCurPluginName = pPlugin->getName();
532 
533  //Garbage collecting
534  if(m_pRunWidget)
535  {
536  delete m_pRunWidget;
537  m_pRunWidget = NULL;
538  }
539 
540  if(pPlugin.isNull())
541  {
542  QWidget* pWidget = new QWidget;
543  setCentralWidget(pWidget);
544  }
545  else
546  {
547  if(!m_bIsRunning)
548  setCentralWidget(pPlugin->setupWidget());
549  else
550  {
551  m_pRunWidget = new RunWidget( m_pDisplayManager->show(pPlugin->getOutputConnectors(), m_pTime, m_qListDynamicDisplayActions, m_qListDynamicDisplayWidgets));
552 
553  m_pRunWidget->show();
554 
555  if(m_bDisplayMax)//ToDo send events to main window
556  {
557  m_pRunWidget->showFullScreen();
558  connect(m_pRunWidget, &RunWidget::displayClosed, this, &MainWindow::toggleDisplayMax);
559  m_pRunWidgetClose = new QShortcut(QKeySequence(Qt::Key_Escape), m_pRunWidget, SLOT(close()));
560  }
561  else
562  setCentralWidget(m_pRunWidget);
563  }
564  }
565  }
566  else
567  {
568  QWidget* t_pWidgetEmpty = new QWidget;
569  setCentralWidget(t_pWidgetEmpty);
570  }
571 
572  this->createToolBars();
573 }
574 
575 
576 //*************************************************************************************************************
577 
578 void MainWindow::updateConnectionWidget(PluginConnectorConnection::SPtr pConnection)
579 {
580  QWidget* pWidget = pConnection->setupWidget();
581  setCentralWidget(pWidget);
582 }
583 
584 
585 //*************************************************************************************************************
586 
587 void MainWindow::writeToLog(const QString& logMsg, LogKind lgknd, LogLevel lglvl)
588 {
589  if(lglvl<=m_eLogLevelCurrent)
590  {
591  if(lgknd == _LogKndError)
592  {
593  m_pTextBrowser_Log->insertHtml("<font color=red><b>Error:</b> "+logMsg+"</font>");
594 
595  }
596  else if(lgknd == _LogKndWarning)
597  {
598  m_pTextBrowser_Log->insertHtml("<font color=blue><b>Warning:</b> "+logMsg+"</font>");
599  }
600  else
601  {
602  m_pTextBrowser_Log->insertHtml(logMsg);
603  }
604  m_pTextBrowser_Log->insertPlainText("\n"); // new line
605  //scroll down to the newest entry
606  QTextCursor c = m_pTextBrowser_Log->textCursor();
607  c.movePosition(QTextCursor::End);
608  m_pTextBrowser_Log->setTextCursor(c);
609 
610  m_pTextBrowser_Log->verticalScrollBar()->setValue(m_pTextBrowser_Log->verticalScrollBar()->maximum());
611  }
612 }
613 
614 
615 //*************************************************************************************************************
616 
617 void MainWindow::startMeasurement()
618 {
619  writeToLog(tr("Starting real-time measurement..."), _LogKndMessage, _LogLvMin);
620 
621  if(!m_pPluginSceneManager->startPlugins())
622  {
623  QMessageBox::information(0, tr("MNE X - Start"), QString(QObject::tr("Not able to start at least one sensor plugin!")), QMessageBox::Ok);
624  return;
625  }
626 
627  m_pPluginGui->uiSetupRunningState(true);
628  uiSetupRunningState(true);
629  startTimer(m_iTimeoutMSec);
630 
631  updatePluginWidget(m_pPluginGui->getCurrentPlugin());
632 
633 // CentralWidgetShowPlugin();
634 
635 
636 // //OLD
637 // qDebug() << "MainCSART::startMeasurement()";
638 
639 // //MeasurementManager::clean();
640 // //DisplayManager::clean();
641 
642 // if(!PluginManager::startPlugins())
643 // {
644 // QMessageBox::information(0, QObject::tr("CSA RT - Start plugins"), QString(QObject::tr("No Sensor plugin is active")), QMessageBox::Ok);
645 // return;
646 // }
647 
648 // m_pPluginDockWidget->setTogglingEnabled(false);
649 
650 // //OLD
651 }
652 
653 
654 //*************************************************************************************************************
655 
656 void MainWindow::stopMeasurement()
657 {
658  writeToLog(tr("Stopping real-time measurement..."), _LogKndMessage, _LogLvMin);
659 
660  m_pPluginSceneManager->stopPlugins();
661  m_pDisplayManager->clean();
662 
663 
664  m_pPluginGui->uiSetupRunningState(false);
665  uiSetupRunningState(false);
666  stopTimer();
667 
668  updatePluginWidget(m_pPluginGui->getCurrentPlugin());
669 
670 
671 
672 // PluginManager::stopPlugins();
673 
674 // Connector::disconnectMeasurementWidgets(m_pListCurrentDisplayPlugins);//was before stopPlugins();
675 
676 // qDebug() << "set stopped UI";
677 
678 // m_pPluginDockWidget->setTogglingEnabled(true);
679 }
680 
681 
682 //*************************************************************************************************************
683 
684 void MainWindow::zoomStd()
685 {
686  if(m_pRunWidget)
687  {
688  m_pRunWidget->setStandardZoom();
689  m_pActionZoomStd->setEnabled(false);
690  }
691 }
692 
693 
694 //*************************************************************************************************************
695 
696 void MainWindow::zoomIn()
697 {
698  if(m_pRunWidget)
699  {
700  m_pRunWidget->zoomVert(2);
701  m_pActionZoomStd->setEnabled(true);
702  }
703 }
704 
705 
706 //*************************************************************************************************************
707 
708 void MainWindow::zoomOut()
709 {
710  if(m_pRunWidget)
711  {
712  m_pRunWidget->zoomVert(0.5);
713  m_pActionZoomStd->setEnabled(true);
714  }
715 
716 }
717 
718 
719 //*************************************************************************************************************
720 
721 void MainWindow::toggleDisplayMax()
722 {
723 
724  m_bDisplayMax = !m_bDisplayMax;
725 
726  m_pActionDisplayMax->setEnabled(!m_bDisplayMax);
727 
728  updatePluginWidget(m_pPluginGui->getCurrentPlugin());
729 }
730 
731 
732 //*************************************************************************************************************
733 
734 void MainWindow::uiSetupRunningState(bool state)
735 {
736  m_pActionRun->setEnabled(!state);
737  m_pActionStop->setEnabled(state);
738 
739  if(state)
740  {
741  m_pActionZoomStd->setEnabled(!state);
742  m_pActionZoomIn->setEnabled(state);
743  m_pActionZoomOut->setEnabled(state);
744  m_pActionDisplayMax->setEnabled(state);
745  }
746  else
747  {
748  m_pActionZoomStd->setEnabled(state);
749  m_pActionZoomIn->setEnabled(state);
750  m_pActionZoomOut->setEnabled(state);
751  m_pActionDisplayMax->setEnabled(state);
752  }
753 
754  m_bIsRunning = state;
755 }
756 
757 
758 
759 //*************************************************************************************************************
760 
762 {
763  m_pTimer = QSharedPointer<QTimer>(new QTimer(this));
764  connect(m_pTimer.data(), &QTimer::timeout, this, &MainWindow::updateTime);
765  m_pTimer->start(msec);
766  m_pTime->setHMS(0,0,0);
767  QString strTime = m_pTime->toString();
768  m_pLabelTime->setText(strTime);
769 }
770 
771 
772 //*************************************************************************************************************
773 
775 {
776  disconnect(m_pTimer.data(), &QTimer::timeout, this, &MainWindow::updateTime);
777 }
778 
779 
780 //*************************************************************************************************************
781 
782 void MainWindow::updateTime()
783 {
784  *m_pTime = m_pTime->addMSecs(m_iTimeoutMSec);
785  QString strTime = m_pTime->toString();
786  m_pLabelTime->setText(strTime);
787 }
Contains declaration of PluginSceneManager class.
Contains declaration of StartUpWidget class.
virtual ~MainWindow()
Definition: mainwindow.cpp:138
QSharedPointer< PluginConnectorConnection > SPtr
Contains the declaration of the PluginManager class.
The RunWidget class provides the central widget for the run mode.
Definition: runwidget.h:78
static const QString AppNameShort()
Definition: info.h:103
void setStandardZoom()
Definition: runwidget.cpp:109
Contains declaration of RunWidget class.
PluginGui class declaration.
The PluginManager class provides a dynamic plugin loader. As well as the handling of the loaded plugi...
Definition: pluginmanager.h:82
Declaration of the DisplayManager Class.
static const QString AppVersion()
Definition: info.h:169
void loadConfig(const QString &sPath, const QString &sFileName)
Definition: plugingui.cpp:182
QSharedPointer< IPlugin > SPtr
Definition: IPlugin.h:108
void zoomVert(float factor)
Definition: runwidget.cpp:117
void startTimer(int msec)
Definition: mainwindow.cpp:761
Definition: arrow.h:75
The PluginSceneManager class manages plugins and connections of a set of plugins. ...
void displayClosed()
The DisplayManager class handles current displayed widgets.
void writeToLog(const QString &logMsg, LogKind lgknd=_LogKndMessage, LogLevel lglvl=_LogLvNormal)
Definition: mainwindow.cpp:587
void saveConfig(const QString &sPath, const QString &sFileName)
Definition: plugingui.cpp:297
MainWindow(QWidget *parent=0)
Definition: mainwindow.cpp:90
void closeEvent(QCloseEvent *event)
Definition: mainwindow.cpp:170
The StartUpWidget class provides the widget which is shown at start up in the central widget of the m...
Definition: startupwidget.h:78