From f49b059131083a7f3a2bfab4f9b78da5b7218cd0 Mon Sep 17 00:00:00 2001 From: "simon.fanetti" <simon.fanetti@etu.hesge.ch> Date: Wed, 3 Jun 2020 21:29:45 +0200 Subject: [PATCH] fixe overrided SubApp's functions --- app/SandboxSetup/croppingmask.cpp | 15 +++++++++----- app/SandboxSetup/croppingmask.h | 1 + app/SandboxSetup/initcamera.cpp | 1 - app/SandboxSetup/mainwindow.cpp | 1 - app/SandboxSetup/maskedit.cpp | 2 +- app/SandboxSetup/projectiongui.cpp | 4 +--- app/SandboxSetup/qtfullscreen.cpp | 33 +++++++++++++++--------------- app/SandboxSetup/qtfullscreen.h | 9 +------- app/SandboxSetup/subapp.h | 6 +++--- 9 files changed, 33 insertions(+), 39 deletions(-) diff --git a/app/SandboxSetup/croppingmask.cpp b/app/SandboxSetup/croppingmask.cpp index e2c984c..934b5dc 100644 --- a/app/SandboxSetup/croppingmask.cpp +++ b/app/SandboxSetup/croppingmask.cpp @@ -43,23 +43,28 @@ void CroppingMask::cancelRoutine(){ void CroppingMask::showEvent(QShowEvent *event){ QWidget::showEvent(event); - QTimer::singleShot(100, this, &CroppingMask::takePicture); + takePicture(); } void CroppingMask::on_btnTakePicture_clicked() -{ +{ + takePicture(); +} + +void CroppingMask::takePicture(){ + // take picture of blue screen if(!blueScreenInitilized){ blueScreenInitilized = true; projBlueScreen->setGeometry(mg->getResolution()); } + cv::Mat blueMat = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255)); projBlueScreen->imShow(blueMat); - QTimer::singleShot(1000, this, &CroppingMask::takePicture); + QTimer::singleShot(1000, this, &CroppingMask::capture); } -void CroppingMask::takePicture(){ - +void CroppingMask::capture(){ setup->getCamera()->capture(); projBlueScreen->close(); diff --git a/app/SandboxSetup/croppingmask.h b/app/SandboxSetup/croppingmask.h index d0ea80e..32391f7 100644 --- a/app/SandboxSetup/croppingmask.h +++ b/app/SandboxSetup/croppingmask.h @@ -44,6 +44,7 @@ private: bool maskValideInFrame(cv::Mat *rgb); void takePicture(); + void capture(); }; #endif // CROPPINGMASK_H diff --git a/app/SandboxSetup/initcamera.cpp b/app/SandboxSetup/initcamera.cpp index fc2caa2..410fe24 100644 --- a/app/SandboxSetup/initcamera.cpp +++ b/app/SandboxSetup/initcamera.cpp @@ -11,7 +11,6 @@ void CameraStartThread::run() { camera->start(); camera->warmUpDepthLens(); - std::cout << "camera ready" << std::endl; emit setupReady(); } diff --git a/app/SandboxSetup/mainwindow.cpp b/app/SandboxSetup/mainwindow.cpp index 6036ea7..ba4bca6 100644 --- a/app/SandboxSetup/mainwindow.cpp +++ b/app/SandboxSetup/mainwindow.cpp @@ -108,7 +108,6 @@ void MainWindow::nextApp(){ if(verifyApp()){ applist.at(step)->valideRoutine(); closeApp(); - if((uint)step < applist.size()-1){ step++; loadApp(); diff --git a/app/SandboxSetup/maskedit.cpp b/app/SandboxSetup/maskedit.cpp index 16632d3..36f4220 100644 --- a/app/SandboxSetup/maskedit.cpp +++ b/app/SandboxSetup/maskedit.cpp @@ -99,7 +99,7 @@ int MaskEdit::selectCorner(QMouseEvent* eMouse){ if(capture != nullptr && rectPoints != nullptr){ - int margin = 20; + int margin = 10; // x and y relative to the captured frame, not the UI int mouseX = (int)( (float)eMouse->x() * ratioX ); diff --git a/app/SandboxSetup/projectiongui.cpp b/app/SandboxSetup/projectiongui.cpp index c537ba1..8dda847 100644 --- a/app/SandboxSetup/projectiongui.cpp +++ b/app/SandboxSetup/projectiongui.cpp @@ -10,7 +10,7 @@ ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *par ui->setupUi(this); ui->lblFrame->setGeometry(0, 0, ui->fContainer->width(), ui->fContainer->height()); - blueScreen = new QtFullScreen(mg->getResolution(), false); + blueScreen = new QtFullScreen(mg->getResolution(), true, this); frameTimer = new QTimer(this); connect(frameTimer, &QTimer::timeout, this, &ProjectionGui::refreshFrame); @@ -44,9 +44,7 @@ void ProjectionGui::on_btnStart_clicked() cv::Mat blue = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255)); blueScreen->setGeometry(mg->getResolution()); blueScreen->imShow(blue); - cameraUsed = true; - //ui->fContainer->hide(); frameTimer->start(100); } } diff --git a/app/SandboxSetup/qtfullscreen.cpp b/app/SandboxSetup/qtfullscreen.cpp index d4e20c5..62849ea 100644 --- a/app/SandboxSetup/qtfullscreen.cpp +++ b/app/SandboxSetup/qtfullscreen.cpp @@ -1,12 +1,14 @@ #include "qtfullscreen.h" -QtFullScreen::QtFullScreen(QRect _resolution, bool _isBorderless, QWidget *parent) : QWidget(parent) +QtFullScreen::QtFullScreen(QRect reso, bool _isBorderless, QWidget *parent) : QObject() { p = parent; - win = new QDialog; - resolution = &_resolution; + resolution = new QRect(reso.left(), reso.top(), reso.width(), reso.height()); isBorderless = _isBorderless; - //win->setWindowFlags(Qt::Window); + + win = new QDialog(parent); + win->setWindowFlags(Qt::Window); + win->setFocusPolicy(Qt::NoFocus); win->setGeometry(*resolution); image = new QLabel(win); @@ -18,15 +20,7 @@ QtFullScreen::~QtFullScreen() { delete image; delete win; -} - -void QtFullScreen::showEvent(QShowEvent* event){ - - QWidget::showEvent( event ); - if(win->parent() != 0) - std::cout << "QtFullScreen showEvent : " << win->parent()->objectName().toStdString() << std::endl; - if(p != nullptr) - p->setFocus(); + delete resolution; } void QtFullScreen::setGeometry(QRect reso){ @@ -45,12 +39,17 @@ void QtFullScreen::imShow(cv::Mat frame){ QPixmap px = QPixmap::fromImage(src); image->setPixmap(px); - if(isBorderless && !win->windowState().testFlag(Qt::WindowFullScreen)){ - win->setWindowState(Qt::WindowFullScreen); + if(!win->isVisible()){ + if(isBorderless){ + win->showFullScreen(); + }else{ + win->show(); + } } - if(!win->isVisible()) - win->show(); + if(p != nullptr) + p->setFocus(); + } void QtFullScreen::close(){ diff --git a/app/SandboxSetup/qtfullscreen.h b/app/SandboxSetup/qtfullscreen.h index 0a31916..c42dd50 100644 --- a/app/SandboxSetup/qtfullscreen.h +++ b/app/SandboxSetup/qtfullscreen.h @@ -7,7 +7,7 @@ #include <QScreen> #include <QDialog> -class QtFullScreen : public QWidget +class QtFullScreen : public QObject { Q_OBJECT public: @@ -18,13 +18,6 @@ public: void setGeometry(QRect resolution); void setGeometry(int x, int y, int w, int h); -signals: - -public slots: - -protected: - void showEvent(QShowEvent* event); - private: QDialog *win; QLabel *image; diff --git a/app/SandboxSetup/subapp.h b/app/SandboxSetup/subapp.h index 1549ec8..b016f6a 100644 --- a/app/SandboxSetup/subapp.h +++ b/app/SandboxSetup/subapp.h @@ -13,9 +13,9 @@ public: bool getEndState(){ return endSuccess; }; std::string getErrorMessage(){ return error_msg; }; void setErrorMessage(std::string msg){ error_msg = msg; }; - bool checkRoutine(); - void valideRoutine(); - void cancelRoutine(); + virtual bool checkRoutine(); + virtual void valideRoutine(); + virtual void cancelRoutine(); signals: void sendNotif(); -- GitLab