diff --git a/app/SandboxSetup/SandboxSetup.pro b/app/SandboxSetup/SandboxSetup.pro index 3f86910a6f30b239aa152891445650b79b04a223..7d0de55a286cca2e28caf0dd80076cffd0522bd4 100644 --- a/app/SandboxSetup/SandboxSetup.pro +++ b/app/SandboxSetup/SandboxSetup.pro @@ -33,7 +33,8 @@ SOURCES += \ projectiongui.cpp \ qtfullscreen.cpp \ beamerlocationgui.cpp \ - mainwindow.cpp + mainwindow.cpp \ + subapp.cpp HEADERS += \ monitorgui.h \ @@ -43,7 +44,8 @@ HEADERS += \ projectiongui.h \ qtfullscreen.h \ beamerlocationgui.h \ - mainwindow.h + mainwindow.h \ + subapp.h FORMS += \ monitorgui.ui \ diff --git a/app/SandboxSetup/beamerlocationgui.cpp b/app/SandboxSetup/beamerlocationgui.cpp index 328275b512e23b9b5b11d364963c267bac594a91..0b40bc9b623132b69e37572c8bd11974a5787f76 100644 --- a/app/SandboxSetup/beamerlocationgui.cpp +++ b/app/SandboxSetup/beamerlocationgui.cpp @@ -2,7 +2,7 @@ #include "ui_beamerlocationgui.h" BeamerLocationGui::BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *parent) : - QDialog(parent), + SubApp(parent), ui(new Ui::BeamerLocationGui) { setup = _setup; @@ -23,9 +23,35 @@ BeamerLocationGui::~BeamerLocationGui() delete ui; } -void BeamerLocationGui::closeEvent (QCloseEvent *e){ - QWidget::closeEvent(e); +void BeamerLocationGui::valideRoutine(){ + + if(timer->isActive()) + timer->stop(); + + beamer->setPosition( (cv::Point3f)beamer->approximatePosition(&bases, &directions) ); + winFullScreen->close(); + endSuccess = true; +} + +void BeamerLocationGui::cancelRoutine(){ + if(timer->isActive()) + timer->stop(); + winFullScreen->close(); + endSuccess = false; +} + +void BeamerLocationGui::showEvent(QShowEvent *event){ + QWidget::showEvent(event); + + if(!isFullScreenInit){ + winFullScreen->setGeometry(mg->getResolution()); + } + startRoutine(); +} + +void BeamerLocationGui::closeEvent(QCloseEvent *e){ endRoutine(); + QWidget::closeEvent(e); } void BeamerLocationGui::keyPressEvent(QKeyEvent *e) @@ -101,20 +127,11 @@ void BeamerLocationGui::endRoutine(){ if(timer->isActive()) timer->stop(); - endSuccessfully = (bases.size() == beamer->MAX_LINEAR_LINE_POINTS && directions.size() == beamer->MAX_LINEAR_LINE_POINTS); - - if(endSuccessfully) - beamer->setPosition( (cv::Point3f)beamer->approximatePosition(&bases, &directions) ); + endSuccess = (bases.size() == beamer->MAX_LINEAR_LINE_POINTS && directions.size() == beamer->MAX_LINEAR_LINE_POINTS); + if(endSuccess){ + // send to parent ReadyToValide + } winFullScreen->close(); } - -void BeamerLocationGui::on_btnStart_clicked() -{ - if(!isFullScreenInit){ - winFullScreen->setGeometry(mg->getResolution()); - } - startRoutine(); - -} diff --git a/app/SandboxSetup/beamerlocationgui.h b/app/SandboxSetup/beamerlocationgui.h index 86e5f576e61f2e7fc5b337998ad7c995db331067..14774a41d138c1574bd6a38ea69e3085c6b2d48b 100644 --- a/app/SandboxSetup/beamerlocationgui.h +++ b/app/SandboxSetup/beamerlocationgui.h @@ -7,26 +7,29 @@ #include "qtfullscreen.h" #include "monitorgui.h" #include "sandboxSetup.h" +#include "subapp.h" namespace Ui { class BeamerLocationGui; } -class BeamerLocationGui : public QDialog +class BeamerLocationGui : public SubApp { Q_OBJECT public: explicit BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *parent = 0); - bool endedSuccessfully(){ return endSuccessfully; }; ~BeamerLocationGui(); + void valideRoutine(); + void cancelRoutine(); protected: void keyPressEvent(QKeyEvent *e); void closeEvent (QCloseEvent *event); + void showEvent(QShowEvent *event); private slots: - void on_btnStart_clicked(); + private: Ui::BeamerLocationGui *ui; @@ -36,7 +39,6 @@ private: Camera *camera; FrameProcessProfil *profil; MonitorGui *mg; - bool endSuccessfully = false; int keypressed = -1; bool isFullScreenInit = false; bool isWaiting = true; diff --git a/app/SandboxSetup/beamerlocationgui.ui b/app/SandboxSetup/beamerlocationgui.ui index 10a18168312a78a55b66c02dffe9a724eb2efd34..98b3e9d65e4370fce3d2fad4a0056dc78ff716c8 100644 --- a/app/SandboxSetup/beamerlocationgui.ui +++ b/app/SandboxSetup/beamerlocationgui.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>BeamerLocationGui</class> - <widget class="QDialog" name="BeamerLocationGui"> + <widget class="QWidget" name="BeamerLocationGui"> <property name="geometry"> <rect> <x>0</x> @@ -13,19 +13,6 @@ <property name="windowTitle"> <string>Dialog</string> </property> - <widget class="QPushButton" name="btnStart"> - <property name="geometry"> - <rect> - <x>210</x> - <y>210</y> - <width>89</width> - <height>25</height> - </rect> - </property> - <property name="text"> - <string>Start</string> - </property> - </widget> </widget> <resources/> <connections/> diff --git a/app/SandboxSetup/camerafocus.cpp b/app/SandboxSetup/camerafocus.cpp index 91b07880369497ad1d5b4276a7d2a12fa3069551..dc46d65a7dbff5cb30f32d54271efdd1d814164b 100644 --- a/app/SandboxSetup/camerafocus.cpp +++ b/app/SandboxSetup/camerafocus.cpp @@ -2,7 +2,7 @@ #include "ui_camerafocus.h" CameraFocus::CameraFocus(SandboxSetup *sandbox, QWidget *parent) : - QDialog(parent), + SubApp(parent), ui(new Ui::CameraFocus) { ui->setupUi(this); @@ -22,15 +22,18 @@ CameraFocus::~CameraFocus() delete ui; } -void CameraFocus::on_btnbxValidate_clicked(QAbstractButton *button) -{ - (void)button; +// TODO : override "checkRoutine" to ensure that the profil makes sense + +void CameraFocus::valideRoutine(){ + + endSuccess = true; frameTimer->stop(); } -void CameraFocus::on_btnbxValidate_accepted() -{ - state = true; +void CameraFocus::cancelRoutine(){ + + endSuccess = false; + frameTimer->stop(); } void CameraFocus::refreshFrame(){ diff --git a/app/SandboxSetup/camerafocus.h b/app/SandboxSetup/camerafocus.h index b0fb84e60c8666fb92dd8bcba836f267108f5211..86750ad92cec0d2a9832d045316635c264fa6499 100644 --- a/app/SandboxSetup/camerafocus.h +++ b/app/SandboxSetup/camerafocus.h @@ -6,24 +6,25 @@ #include <QAbstractButton> #include <sandboxSetup.h> +#include "subapp.h" + namespace Ui { class CameraFocus; } -class CameraFocus : public QDialog +class CameraFocus : public SubApp { Q_OBJECT public: explicit CameraFocus(SandboxSetup *sandbox, QWidget *parent = 0); ~CameraFocus(); - bool isOk(){ return state; }; -private slots: - void on_btnbxValidate_clicked(QAbstractButton *button); + void valideRoutine(); + void cancelRoutine(); - void on_btnbxValidate_accepted(); +private slots: void on_dbsbxContrast_valueChanged(double arg1); void on_sbxBrightness_valueChanged(int arg1); @@ -41,7 +42,6 @@ private slots: private: Ui::CameraFocus *ui; SandboxSetup *setup; - bool state = false; QTimer *frameTimer; FrameProcessProfil defaultProfil; bool displayConstrasts = false; diff --git a/app/SandboxSetup/camerafocus.ui b/app/SandboxSetup/camerafocus.ui index d3babc19024bcb94c3b007645ed6ef705bd38b9c..954c84b365b990b193deaa9da1a244bebcb4b16f 100644 --- a/app/SandboxSetup/camerafocus.ui +++ b/app/SandboxSetup/camerafocus.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>CameraFocus</class> - <widget class="QDialog" name="CameraFocus"> + <widget class="QWidget" name="CameraFocus"> <property name="geometry"> <rect> <x>0</x> @@ -13,22 +13,6 @@ <property name="windowTitle"> <string>Focus</string> </property> - <widget class="QDialogButtonBox" name="btnbxValidate"> - <property name="geometry"> - <rect> - <x>270</x> - <y>560</y> - <width>341</width> - <height>32</height> - </rect> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> <widget class="QWidget" name="formLayoutWidget"> <property name="geometry"> <rect> @@ -175,38 +159,5 @@ </widget> </widget> <resources/> - <connections> - <connection> - <sender>btnbxValidate</sender> - <signal>accepted()</signal> - <receiver>CameraFocus</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>btnbxValidate</sender> - <signal>rejected()</signal> - <receiver>CameraFocus</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> diff --git a/app/SandboxSetup/croppingmask.cpp b/app/SandboxSetup/croppingmask.cpp index fd3124fd9e33d3dce64cf9b2536a765599c17cd8..51ff4a9a2bb53ab61a58d579e8e24f8dc1d62c11 100644 --- a/app/SandboxSetup/croppingmask.cpp +++ b/app/SandboxSetup/croppingmask.cpp @@ -2,7 +2,7 @@ #include "ui_croppingmask.h" CroppingMask::CroppingMask(SandboxSetup *sandbox, MonitorGui *_mg, QWidget *parent) : - QDialog(parent), + SubApp(parent), ui(new Ui::CroppingMask) { @@ -23,6 +23,25 @@ CroppingMask::~CroppingMask() delete ui; } +void CroppingMask::valideRoutine(){ + + if(maskUpdated){ + cv::Size s = setup->getCamera()->getDepthFrame().size(); + cv::Point center(s.width / 2, s.height / 2); + std::vector<cv::Point> rectPoints = getRectPoints(); + + setup->setupAdjustMatrix(rectPoints, center); + setup->setupCroppingMask(rectPoints); + } + + endSuccess = true; +} + +void CroppingMask::cancelRoutine(){ + + endSuccess = false; +} + void CroppingMask::on_btnTakePicture_clicked() { // take picture of blue screen @@ -69,7 +88,3 @@ bool CroppingMask::maskValideInFrame(cv::Mat *rgb){ return true; } -void CroppingMask::on_btnbxEnd_accepted() -{ - state = true; -} diff --git a/app/SandboxSetup/croppingmask.h b/app/SandboxSetup/croppingmask.h index e5fa0f56620f81182137732aa9b05e0fc381c39c..e810b4135de8fee045482220cfc9017c97817934 100644 --- a/app/SandboxSetup/croppingmask.h +++ b/app/SandboxSetup/croppingmask.h @@ -8,12 +8,13 @@ #include "qtfullscreen.h" #include "maskedit.h" #include "monitorgui.h" +#include "subapp.h" namespace Ui { class CroppingMask; } -class CroppingMask : public QDialog +class CroppingMask : public SubApp { Q_OBJECT @@ -21,18 +22,16 @@ public: explicit CroppingMask(SandboxSetup *sandbox, MonitorGui *_mg, QWidget *parent = 0); ~CroppingMask(); std::vector<cv::Point> getRectPoints(){ return rectPoints; }; - bool updated(){ return maskUpdated; }; - bool isOk(){ return state; }; + void valideRoutine(); + void cancelRoutine(); private slots: void on_btnTakePicture_clicked(); - void on_btnbxEnd_accepted(); private: Ui::CroppingMask *ui; SandboxSetup *setup; std::vector<cv::Point> rectPoints; - bool state = false; cv::Mat cameraRGBFrame; MaskEdit *maskEdit; MonitorGui *mg; diff --git a/app/SandboxSetup/croppingmask.ui b/app/SandboxSetup/croppingmask.ui index c1fa63cda4c8d0d5dc709fc8d30a7f57b27f4e87..51433397930d765661268c0153b0bfcec77ea784 100644 --- a/app/SandboxSetup/croppingmask.ui +++ b/app/SandboxSetup/croppingmask.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>CroppingMask</class> - <widget class="QDialog" name="CroppingMask"> + <widget class="QWidget" name="CroppingMask"> <property name="geometry"> <rect> <x>0</x> @@ -13,25 +13,6 @@ <property name="windowTitle"> <string>Crop</string> </property> - <widget class="QDialogButtonBox" name="btnbxEnd"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="geometry"> - <rect> - <x>270</x> - <y>380</y> - <width>341</width> - <height>32</height> - </rect> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> <widget class="QPushButton" name="btnTakePicture"> <property name="geometry"> <rect> @@ -93,43 +74,9 @@ </property> </widget> <zorder>frame</zorder> - <zorder>btnbxEnd</zorder> <zorder>btnTakePicture</zorder> <zorder>label</zorder> </widget> <resources/> - <connections> - <connection> - <sender>btnbxEnd</sender> - <signal>accepted()</signal> - <receiver>CroppingMask</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>btnbxEnd</sender> - <signal>rejected()</signal> - <receiver>CroppingMask</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> diff --git a/app/SandboxSetup/main.cpp b/app/SandboxSetup/main.cpp index 067b1649fa51679fdcb2cfc2d72ae6339aade790..42fece4605f638c045ec40de73360a466e56aec1 100644 --- a/app/SandboxSetup/main.cpp +++ b/app/SandboxSetup/main.cpp @@ -1,5 +1,5 @@ -/* + #include <QApplication> #include "mainwindow.h" @@ -10,7 +10,8 @@ int main(int argc, char *argv[]) main.show(); return app.exec(); } -*/ + +/* #include <QApplication> #include "monitorgui.h" @@ -96,3 +97,4 @@ int main(int argc, char *argv[]) } +*/ diff --git a/app/SandboxSetup/mainwindow.cpp b/app/SandboxSetup/mainwindow.cpp index 49f9a781dca7dd1b9d703d4518072d4e9c286f62..dd551fd4ddc501b73487b9ca013d9de20be0560c 100644 --- a/app/SandboxSetup/mainwindow.cpp +++ b/app/SandboxSetup/mainwindow.cpp @@ -11,24 +11,18 @@ MainWindow::MainWindow(QWidget *parent) : ui->btnNext->setEnabled(false); setup = new SandboxSetup; - mg = new MonitorGui(this); - pg = new ProjectionGui(setup, mg, this); - cf = new CameraFocus(setup, this); - cm = new CroppingMask(setup, mg, this); - bl = new BeamerLocationGui(setup, mg, this); + mg = new MonitorGui(setup); + pg = new ProjectionGui(setup, mg); + cf = new CameraFocus(setup); + cm = new CroppingMask(setup, mg); + bl = new BeamerLocationGui(setup, mg); applist.push_back(mg); applist.push_back(pg); applist.push_back(cf); applist.push_back(cm); applist.push_back(bl); -/* - checkapplist.push_back(checkResolution); - checkapplist.push_back(checkProj); - checkapplist.push_back(checkProcessProfil); - checkapplist.push_back(checkCroppingMask); - checkapplist.push_back(checkBeamerLocation); - */ + } MainWindow::~MainWindow() @@ -41,6 +35,13 @@ void MainWindow::showEvent(QShowEvent *event){ QTimer::singleShot(0, this, &MainWindow::initCamera); } +void MainWindow::closeEvent(QCloseEvent *event){ + closeApp(); + QWidget::closeEvent(event); + if(!verifyApp()) + exit_msg("Failed setup at step " + std::to_string(step) + " : " + applist.at(step)->getErrorMessage()); +} + void MainWindow::exit_msg(std::string msg){ setup->getCamera()->stop(); std::cout << msg << std::endl; @@ -65,21 +66,24 @@ void MainWindow::loadApp(){ } bool MainWindow::verifyApp(){ - return true;//checkapplist.at(step)(); + return applist.at(step)->checkRoutine(); } void MainWindow::nextApp(){ if(verifyApp()){ + applist.at(step)->valideRoutine(); closeApp(); - step++; - loadApp(); - }else{ - exit_msg("Failed setup at step : " + step); + + if((uint)step < applist.size()-1){ + step++; + loadApp(); + } } } void MainWindow::prevApp(){ if(step > 0){ + applist.at(step)->cancelRoutine(); closeApp(); step--; loadApp(); @@ -104,49 +108,6 @@ void MainWindow::finishConfig(){ setup->getCamera()->stop(); } -bool MainWindow::checkResolution(){ - if(!mg->isOk()){ - //exit_msg("Cancel resolution"); - return false; - } - setup->getBeamer()->setResolution(cv::Size(mg->getWidth(), mg->getHeight())); - return true; -} - -bool MainWindow::checkProj(){ return true; } - -bool MainWindow::checkProcessProfil(){ - if(!cf->isOk()){ - //exit_msg("Cancel camera parameters"); - return false; - } - return true; -} - -bool MainWindow::checkCroppingMask(){ - if(!cm->isOk()){ - //exit_msg("Cancel drop"); - return false; - } - if(cm->updated()){ - cv::Size s = setup->getCamera()->getDepthFrame().size(); - cv::Point center(s.width / 2, s.height / 2); - std::vector<cv::Point> rectPoints = cm->getRectPoints(); - - setup->setupAdjustMatrix(rectPoints, center); - setup->setupCroppingMask(rectPoints); - } - return true; -} - -bool MainWindow::checkBeamerLocation(){ - if(!bl->endedSuccessfully()){ - //exit_msg("Cancel beamer position"); - return false; - } - return true; -} - void MainWindow::on_btnNext_clicked() { diff --git a/app/SandboxSetup/mainwindow.h b/app/SandboxSetup/mainwindow.h index a8a78e790b33bef9c89969846488541cd748fcbe..fed42c7f723cb4643ad10203948d496e1b128b09 100644 --- a/app/SandboxSetup/mainwindow.h +++ b/app/SandboxSetup/mainwindow.h @@ -9,6 +9,7 @@ #include "qtfullscreen.h" #include "beamerlocationgui.h" #include <sandboxSetup.h> +#include "subapp.h" #include <QTimer> @@ -31,6 +32,7 @@ private slots: protected: void showEvent(QShowEvent *event); + void closeEvent(QCloseEvent *event); private: Ui::MainWindow *ui; @@ -41,8 +43,7 @@ private: CroppingMask *cm; BeamerLocationGui *bl; int step = 0; - std::vector<QWidget*> applist; - std::vector<bool(MainWindow::*)()> checkapplist; + std::vector<SubApp*> applist; void loadApp(); void closeApp(); diff --git a/app/SandboxSetup/mainwindow.ui b/app/SandboxSetup/mainwindow.ui index 295c9f5a36f0b2f44b9ca4627bf2b6f86ed94ded..1f127d06041ea222ab1a428a9ae02fb0064bd648 100644 --- a/app/SandboxSetup/mainwindow.ui +++ b/app/SandboxSetup/mainwindow.ui @@ -22,8 +22,8 @@ <rect> <x>0</x> <y>0</y> - <width>160</width> - <height>80</height> + <width>801</width> + <height>511</height> </rect> </property> <layout class="QVBoxLayout" name="apps"/> diff --git a/app/SandboxSetup/monitorgui.cpp b/app/SandboxSetup/monitorgui.cpp index aa28da2499bfd7809f35a4942d28f6f4fabca2c1..594ac117fd921c4610a50efa069de0f45a71bd9e 100644 --- a/app/SandboxSetup/monitorgui.cpp +++ b/app/SandboxSetup/monitorgui.cpp @@ -1,12 +1,14 @@ #include "monitorgui.h" #include "ui_monitorgui.h" -MonitorGui::MonitorGui(QWidget *parent) : - QDialog(parent), +MonitorGui::MonitorGui(SandboxSetup *_setup, QWidget *parent) : + SubApp(parent), ui(new Ui::MonitorGui) { + setup = _setup; ui->setupUi(this); resolution = new QRect; + setErrorMessage("Cancel resolution"); std::string path = ".monitors.tmp"; monitors = std::map<std::string, std::vector<std::string>>(); @@ -28,6 +30,29 @@ MonitorGui::~MonitorGui() delete ui; } +void MonitorGui::valideRoutine(){ + + QString selectedRes = ui->cbxResolutions->currentText(); + outputName = ui->cbxOutputs->currentText(); + std::vector<std::string> res = splitResolution(selectedRes.toStdString()); + width = std::stoi(res[0]); + height = std::stoi(res[1]); + + QScreen *sc = getMonitor(); + resolution->setX(sc->geometry().x()); + resolution->setY(sc->geometry().y()); + resolution->setWidth(width); + resolution->setHeight(height); + + endSuccess = true; + setup->getBeamer()->setResolution(cv::Size(getWidth(), getHeight())); +} + +void MonitorGui::cancelRoutine(){ + + endSuccess = false; +} + QScreen* MonitorGui::getMonitor(){ QScreen *sc = QApplication::screens().at(0); @@ -51,23 +76,6 @@ void MonitorGui::on_cbxOutputs_currentIndexChanged(int index) loadResolutionsOf(screens[index]); } -void MonitorGui::on_btnbxMonitors_accepted() -{ - valideState = true; - QString selectedRes = ui->cbxResolutions->currentText(); - outputName = ui->cbxOutputs->currentText(); - std::vector<std::string> res = splitResolution(selectedRes.toStdString()); - width = std::stoi(res[0]); - height = std::stoi(res[1]); - - QScreen *sc = getMonitor(); - resolution->setX(sc->geometry().x()); - resolution->setY(sc->geometry().y()); - resolution->setWidth(width); - resolution->setHeight(height); -} - - void MonitorGui::initMonitorMapWithFile(std::string path){ diff --git a/app/SandboxSetup/monitorgui.h b/app/SandboxSetup/monitorgui.h index 7eedcdf6aedc5fa7afa677f55b558a3a29caf5de..b26d82f2121752f4ebb3f500b10c4fdd9a3fcfca 100644 --- a/app/SandboxSetup/monitorgui.h +++ b/app/SandboxSetup/monitorgui.h @@ -11,16 +11,19 @@ #include <iostream> #include <QScreen> +#include "subapp.h" +#include <sandboxSetup.h> + namespace Ui { class MonitorGui; } -class MonitorGui : public QDialog +class MonitorGui : public SubApp { Q_OBJECT public: - explicit MonitorGui(QWidget *parent = 0); + explicit MonitorGui(SandboxSetup *_setup, QWidget *parent = 0); ~MonitorGui(); int getHeight(){ return height; }; @@ -28,21 +31,21 @@ public: std::string getOutput(){ return outputName.toStdString(); }; QRect getResolution(){ return *resolution; } - bool isOk(){ return valideState; }; + void valideRoutine(); + void cancelRoutine(); private slots: void on_cbxOutputs_currentIndexChanged(int index); - void on_btnbxMonitors_accepted(); private: Ui::MonitorGui *ui; - bool valideState = false; std::map<std::string, std::vector<std::string>> monitors; int height = 0; int width = 0; QString outputName = ""; QRect *resolution; + SandboxSetup *setup; QScreen* getMonitor(); void loadResolutionsOf(QScreen* screen); diff --git a/app/SandboxSetup/monitorgui.ui b/app/SandboxSetup/monitorgui.ui index 2fc38fc4f7bde70b7d111fe994716e3900d2df0e..c2ee6eb3b5853166adb42de0698b9c2bcf4a3436 100644 --- a/app/SandboxSetup/monitorgui.ui +++ b/app/SandboxSetup/monitorgui.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MonitorGui</class> - <widget class="QDialog" name="MonitorGui"> + <widget class="QWidget" name="MonitorGui"> <property name="geometry"> <rect> <x>0</x> @@ -13,22 +13,6 @@ <property name="windowTitle"> <string>Screen</string> </property> - <widget class="QDialogButtonBox" name="btnbxMonitors"> - <property name="geometry"> - <rect> - <x>30</x> - <y>240</y> - <width>341</width> - <height>32</height> - </rect> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> @@ -77,38 +61,5 @@ </widget> </widget> <resources/> - <connections> - <connection> - <sender>btnbxMonitors</sender> - <signal>accepted()</signal> - <receiver>MonitorGui</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>btnbxMonitors</sender> - <signal>rejected()</signal> - <receiver>MonitorGui</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> + <connections/> </ui> diff --git a/app/SandboxSetup/projectiongui.cpp b/app/SandboxSetup/projectiongui.cpp index d8730873b0eda2890ccfb402f7dd5af8f4ebfd46..fa3447b8b54cc11f6e37e6299728b2ef6d08afba 100644 --- a/app/SandboxSetup/projectiongui.cpp +++ b/app/SandboxSetup/projectiongui.cpp @@ -2,7 +2,7 @@ #include "ui_projectiongui.h" ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *parent) : - QDialog(parent), + SubApp(parent), ui(new Ui::ProjectionGui) { setup = _setup; @@ -18,13 +18,20 @@ ProjectionGui::~ProjectionGui() delete ui; } -void ProjectionGui::on_btnSkip_clicked() -{ +void ProjectionGui::valideRoutine(){ + if(cameraUsed){ + frameTimer->stop(); + blueScreen->close(); + } + cameraUsed = true; +} + +void ProjectionGui::cancelRoutine(){ if(cameraUsed){ frameTimer->stop(); blueScreen->close(); } - close(); + cameraUsed = false; } // Note : Screens should be in extented mode, not mirror (to avoid loop noise from the capture of the screen) diff --git a/app/SandboxSetup/projectiongui.h b/app/SandboxSetup/projectiongui.h index de29078f3c8ea62e9dd7f19ee0952fdadb7060eb..0ee46631cbea04e718f52800bfb5399fa6784ca9 100644 --- a/app/SandboxSetup/projectiongui.h +++ b/app/SandboxSetup/projectiongui.h @@ -10,17 +10,17 @@ namespace Ui { class ProjectionGui; } -class ProjectionGui : public QDialog +class ProjectionGui : public SubApp { Q_OBJECT public: explicit ProjectionGui(SandboxSetup *setup, MonitorGui *mg, QWidget *parent = 0); ~ProjectionGui(); + void valideRoutine(); + void cancelRoutine(); private slots: - void on_btnSkip_clicked(); - void on_btnStart_clicked(); private: diff --git a/app/SandboxSetup/projectiongui.ui b/app/SandboxSetup/projectiongui.ui index 402799dfff15c4a269bc5a96b596b668036f55a2..07e3099494d878ff13bb77e67ee35125469279e7 100644 --- a/app/SandboxSetup/projectiongui.ui +++ b/app/SandboxSetup/projectiongui.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ProjectionGui</class> - <widget class="QDialog" name="ProjectionGui"> + <widget class="QWidget" name="ProjectionGui"> <property name="geometry"> <rect> <x>0</x> @@ -64,19 +64,6 @@ </property> </widget> </widget> - <widget class="QPushButton" name="btnSkip"> - <property name="geometry"> - <rect> - <x>390</x> - <y>350</y> - <width>89</width> - <height>25</height> - </rect> - </property> - <property name="text"> - <string>Next</string> - </property> - </widget> <widget class="QLabel" name="lblFrame"> <property name="geometry"> <rect> @@ -114,7 +101,6 @@ </widget> <zorder>lblFrame</zorder> <zorder>fContainer</zorder> - <zorder>btnSkip</zorder> <zorder>label_2</zorder> </widget> <resources/> diff --git a/app/SandboxSetup/subapp.cpp b/app/SandboxSetup/subapp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..069a876e05c8685b7dc7387595fea852b5dd9947 --- /dev/null +++ b/app/SandboxSetup/subapp.cpp @@ -0,0 +1,20 @@ +#include "subapp.h" + +SubApp::SubApp(QWidget *parent) : QWidget(parent) +{ + error_msg = "Error"; +} + +SubApp::~SubApp() +{ + +} + +bool SubApp::checkRoutine(){ + return true; +} + +void SubApp::valideRoutine(){ } + +void SubApp::cancelRoutine(){ } + diff --git a/app/SandboxSetup/subapp.h b/app/SandboxSetup/subapp.h new file mode 100644 index 0000000000000000000000000000000000000000..4edc4f0a1b8a3eeef4b20165fbfcec48e94a5cde --- /dev/null +++ b/app/SandboxSetup/subapp.h @@ -0,0 +1,25 @@ +#ifndef SUBAPP_H +#define SUBAPP_H + +#include <QWidget> + +class SubApp : public QWidget +{ + Q_OBJECT + +public: + explicit SubApp(QWidget *parent = 0); + ~SubApp(); + bool getEndState(){ return endSuccess; }; + std::string getErrorMessage(){ return error_msg; }; + void setErrorMessage(std::string msg){ error_msg = msg; }; + bool checkRoutine(); + void valideRoutine(); + void cancelRoutine(); + +protected: + bool endSuccess = false; + std::string error_msg; +}; + +#endif // SUBAPP_H