Skip to content
Snippets Groups Projects
Commit 367d2a95 authored by simon.fanetti's avatar simon.fanetti
Browse files

add Qt full screen class

parent 8645118a
No related branches found
No related tags found
No related merge requests found
...@@ -30,14 +30,16 @@ SOURCES += \ ...@@ -30,14 +30,16 @@ SOURCES += \
camerafocus.cpp \ camerafocus.cpp \
croppingmask.cpp \ croppingmask.cpp \
maskedit.cpp \ maskedit.cpp \
projectiongui.cpp projectiongui.cpp \
qtfullscreen.cpp
HEADERS += \ HEADERS += \
monitorgui.h \ monitorgui.h \
camerafocus.h \ camerafocus.h \
croppingmask.h \ croppingmask.h \
maskedit.h \ maskedit.h \
projectiongui.h projectiongui.h \
qtfullscreen.h
FORMS += \ FORMS += \
monitorgui.ui \ monitorgui.ui \
......
...@@ -27,6 +27,23 @@ MonitorGui::~MonitorGui() ...@@ -27,6 +27,23 @@ MonitorGui::~MonitorGui()
delete ui; delete ui;
} }
QScreen* MonitorGui::getScreen(){
QScreen *sc = QApplication::screens().at(0);
QList<QScreen *> lst = sc->virtualSiblings();
for(int i=0; i<lst.size(); i++){
std::string name = lst[i]->name().toStdString();
if(name == outputName.toStdString()){
sc = lst.at(i);
break;
}
}
return sc;
}
void MonitorGui::on_cbxOutputs_currentIndexChanged(int index) void MonitorGui::on_cbxOutputs_currentIndexChanged(int index)
{ {
QList<QScreen*> screens = QApplication::screens(); QList<QScreen*> screens = QApplication::screens();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <fstream> #include <fstream>
#include <map> #include <map>
#include <iostream> #include <iostream>
#include <QScreen>
namespace Ui { namespace Ui {
class MonitorGui; class MonitorGui;
...@@ -25,6 +26,8 @@ public: ...@@ -25,6 +26,8 @@ public:
int getHeight(){ return height; }; int getHeight(){ return height; };
int getWidth(){ return width; }; int getWidth(){ return width; };
std::string getOutput(){ return outputName.toStdString(); }; std::string getOutput(){ return outputName.toStdString(); };
QScreen* getScreen();
bool isOk(){ return valideState; }; bool isOk(){ return valideState; };
private slots: private slots:
...@@ -33,11 +36,14 @@ private slots: ...@@ -33,11 +36,14 @@ private slots:
private: private:
Ui::MonitorGui *ui; Ui::MonitorGui *ui;
bool valideState = false;
std::map<std::string, std::vector<std::string>> monitors;
int height = 0; int height = 0;
int width = 0; int width = 0;
QString outputName = ""; QString outputName = "";
bool valideState = false;
std::map<std::string, std::vector<std::string>> monitors;
void loadResolutionsOf(QScreen* screen); void loadResolutionsOf(QScreen* screen);
std::vector<std::string> splitResolution(std::string s); std::vector<std::string> splitResolution(std::string s);
bool isResolution(std::string s); bool isResolution(std::string s);
......
...@@ -5,7 +5,6 @@ ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *par ...@@ -5,7 +5,6 @@ ProjectionGui::ProjectionGui(SandboxSetup *_setup, MonitorGui *_mg, QWidget *par
QDialog(parent), QDialog(parent),
ui(new Ui::ProjectionGui) ui(new Ui::ProjectionGui)
{ {
blueScreen = new QDialog;
setup = _setup; setup = _setup;
mg = _mg; mg = _mg;
ui->setupUi(this); ui->setupUi(this);
...@@ -31,25 +30,15 @@ void ProjectionGui::on_btnSkip_clicked() ...@@ -31,25 +30,15 @@ void ProjectionGui::on_btnSkip_clicked()
// Note : Screens should be in extented mode, not mirror (to avoid loop noise from the capture of the screen) // Note : Screens should be in extented mode, not mirror (to avoid loop noise from the capture of the screen)
void ProjectionGui::on_btnStart_clicked() void ProjectionGui::on_btnStart_clicked()
{ {
QScreen *sc = QApplication::screens().at(0); QScreen *sc = mg->getScreen();
QList<QScreen *> lst = sc->virtualSiblings();
for(int i=0; i<lst.size(); i++){
std::string name = lst[i]->name().toStdString();
if(name == mg->getOutput()){
sc = lst[i];
break;
}
}
// open blue screen on the selected output // open blue screen on the selected output
blueScreen->setGeometry(sc->geometry()); cv::Mat blue = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255));
blueScreen->setStyleSheet("background-color:blue;"); blueScreen = new QtFullScreen(sc);
blueScreen->show(); blueScreen->imShow(blue);
cameraUsed = true;
ui->fContainer->hide(); ui->fContainer->hide();
frameTimer->start(100); frameTimer->start(100);
cameraUsed = true;
} }
void ProjectionGui::refreshFrame(){ void ProjectionGui::refreshFrame(){
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QDialog> #include <QDialog>
#include <sandboxSetup.h> #include <sandboxSetup.h>
#include "monitorgui.h" #include "monitorgui.h"
#include "qtfullscreen.h"
namespace Ui { namespace Ui {
class ProjectionGui; class ProjectionGui;
...@@ -27,7 +28,7 @@ private: ...@@ -27,7 +28,7 @@ private:
SandboxSetup *setup; SandboxSetup *setup;
MonitorGui *mg; MonitorGui *mg;
QTimer *frameTimer; QTimer *frameTimer;
QDialog *blueScreen; QtFullScreen *blueScreen;
bool cameraUsed = false; bool cameraUsed = false;
void refreshFrame(); void refreshFrame();
......
#include "qtfullscreen.h"
QtFullScreen::QtFullScreen(QScreen *_sc, QWidget *parent) : QWidget(parent)
{
win = new QDialog;
screen = _sc;
win->setGeometry(screen->geometry());
image = new QLabel(win);
image->setGeometry(0, 0 , win->geometry().width(), win->geometry().height());
image->setScaledContents(true);
}
void QtFullScreen::imShow(cv::Mat frame){
QImage src = QImage((uchar *)frame.data, (int)frame.cols, (int)frame.rows, static_cast<int>(frame.step.buf[0]), QImage::Format_RGB888);
QPixmap px = QPixmap::fromImage(src);
image->setPixmap(px);
if(!win->isVisible())
win->show();
}
void QtFullScreen::close(){
if(win->isVisible())
win->close();
}
#ifndef QTFULLSCREEN_H
#define QTFULLSCREEN_H
#include <opencv2/opencv.hpp>
#include <QWidget>
#include <QLabel>
#include <QScreen>
#include <QDialog>
class QtFullScreen : public QWidget
{
Q_OBJECT
public:
explicit QtFullScreen(QScreen *sc, QWidget *parent = nullptr);
void imShow(cv::Mat frame);
void close();
signals:
public slots:
private:
QDialog *win;
QLabel *image;
QScreen *screen;
};
#endif // QTFULLSCREEN_H
...@@ -102,7 +102,7 @@ int SandboxSetup::setupProjection(){ ...@@ -102,7 +102,7 @@ int SandboxSetup::setupProjection(){
void SandboxSetup::captureBlueScreen(int delay){ void SandboxSetup::captureBlueScreen(int delay){
// Blue screen // Blue screen
char windowName[] = "border"; char windowName[] = "BlueScreen";
initWindowsFullScreen(windowName); initWindowsFullScreen(windowName);
cv::Mat frameBeamer(cv::Size(beamer.getWidth(), beamer.getHeight()), CV_8UC3, cv::Scalar(255, 0, 0)); cv::Mat frameBeamer(cv::Size(beamer.getWidth(), beamer.getHeight()), CV_8UC3, cv::Scalar(255, 0, 0));
cv::imshow(windowName, frameBeamer); cv::imshow(windowName, frameBeamer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment