Commit 431c9769 authored by Thiago Santini's avatar Thiago Santini

Adds config for widget visibility

Also adds some extra text for the performance monitor ui
parent be8dcf19
......@@ -23,7 +23,7 @@
</font>
</property>
<property name="toolTip">
<string>Log messages</string>
<string>Log messages; use the text box below to add custom messages to the log file.</string>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
......
#include "MainWindow.h"
#include "ui_MainWindow.h"
// TODO: refactor MainWindow into a config aware class that can be shared by the
// widgets
void MainWindow::createExtraMenus()
{
ui->menuBar->addAction("References");
......@@ -25,8 +28,7 @@ MainWindow::MainWindow(QWidget *parent) :
setWindowTitle(QString("EyeRecToo v%1").arg(GIT_VERSION));
setWindowIcon(QIcon(":/icons/EyeRecToo.png"));
move(cfg.mainWindowPos);
resize(cfg.mainWindowSize);
setupWidget(this, cfg.mainWindowPos, cfg.mainWindowSize, true);
if (!cfg.workingDirectory.isEmpty())
setWorkingDirectory(cfg.workingDirectory);
......@@ -35,9 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->blinker->hide();
logWidget = new LogWidget();
logWidget->show();
logWidget->move(cfg.logWidgetPos);
logWidget->resize(cfg.logWidgetSize);
setupWidget(logWidget, cfg.logWidgetPos, cfg.logWidgetSize, cfg.logWidgetVisible, ui->log);
gLogWidget = logWidget;
/*
......@@ -53,21 +53,15 @@ MainWindow::MainWindow(QWidget *parent) :
*/
lEyeWidget = new CameraWidget("LeftEye", ImageProcessor::Eye);
lEyeWidget->setWindowIcon(QIcon(":/icons/lEyeWidget.png"));
lEyeWidget->move(cfg.leftEyeWidgetPos);
lEyeWidget->resize(cfg.leftEyeWidgetSize);
lEyeWidget->show();
setupWidget(lEyeWidget, cfg.leftEyeWidgetPos, cfg.leftEyeWidgetSize, cfg.leftEyeWidgetVisible, ui->leftEyeCam);
QThread::msleep(200);
rEyeWidget = new CameraWidget("RightEye", ImageProcessor::Eye);
rEyeWidget->setWindowIcon(QIcon(":/icons/rEyeWidget.png"));
rEyeWidget->move(cfg.rightEyeWidgetPos);
rEyeWidget->resize(cfg.rightEyeWidgetSize);
rEyeWidget->show();
setupWidget(rEyeWidget, cfg.rightEyeWidgetPos, cfg.rightEyeWidgetSize, cfg.rightEyeWidgetVisible, ui->rightEyeCam);
QThread::msleep(200);
fieldWidget = new CameraWidget("Field", ImageProcessor::Field);
fieldWidget->setWindowIcon(QIcon(":/icons/fieldWidget.png"));
fieldWidget->move(cfg.fieldWidgetPos);
fieldWidget->resize(cfg.fieldWidgetSize);
fieldWidget->show();
setupWidget(fieldWidget, cfg.fieldWidgetPos, cfg.fieldWidgetSize, cfg.fieldWidgetVisible, ui->fieldCam);
/*
* Synchronizer
......@@ -84,9 +78,7 @@ MainWindow::MainWindow(QWidget *parent) :
* Synchronous elements
*/
gazeEstimationWidget = new GazeEstimationWidget();
gazeEstimationWidget->move(cfg.gazeEstimationWidgetPos);
gazeEstimationWidget->resize(cfg.gazeEstimationWidgetSize);
gazeEstimationWidget->show();
setupWidget(gazeEstimationWidget, cfg.gazeEstimationWidgetPos, cfg.gazeEstimationWidgetSize, cfg.gazeEstimationWidgetVisible, ui->gazeEstimation);
connect(synchronizer, SIGNAL(newData(DataTuple)),
gazeEstimationWidget, SIGNAL(inDataTuple(DataTuple)) );
connect(fieldWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)),
......@@ -109,9 +101,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(gazeEstimationWidget, SIGNAL(outDataTuple(DataTuple)), networkStream, SLOT(push(DataTuple)) );
performanceMonitorWidget = new PerformanceMonitorWidget();
performanceMonitorWidget->show();
performanceMonitorWidget->move(cfg.performanceMonitorWidgetPos);
performanceMonitorWidget->resize(cfg.performanceMonitorWidgetSize);
setupWidget(performanceMonitorWidget, cfg.performanceMonitorWidgetPos, cfg.performanceMonitorWidgetSize, cfg.performanceMonitorWidgetVisible, ui->performanceMonitor);
// GUI to Widgets signals
connect(this, SIGNAL(startRecording()),
......@@ -154,16 +144,22 @@ void MainWindow::closeEvent(QCloseEvent *event)
cfg.mainWindowSize = size();
cfg.logWidgetPos = logWidget->pos();
cfg.logWidgetSize = logWidget->size();
cfg.logWidgetVisible = logWidget->isVisible();
cfg.leftEyeWidgetPos = lEyeWidget->pos();
cfg.leftEyeWidgetSize = lEyeWidget->size();
cfg.leftEyeWidgetVisible = lEyeWidget->isVisible();
cfg.rightEyeWidgetPos = rEyeWidget->pos();
cfg.rightEyeWidgetSize = rEyeWidget->size();
cfg.rightEyeWidgetVisible = rEyeWidget->isVisible();
cfg.fieldWidgetPos = fieldWidget->pos();
cfg.fieldWidgetSize = fieldWidget->size();
cfg.fieldWidgetVisible = fieldWidget->isVisible();
cfg.gazeEstimationWidgetPos = gazeEstimationWidget->pos();
cfg.gazeEstimationWidgetSize = gazeEstimationWidget->size();
cfg.gazeEstimationWidgetVisible = gazeEstimationWidget->isVisible();
cfg.performanceMonitorWidgetPos = performanceMonitorWidget->pos();
cfg.performanceMonitorWidgetSize = performanceMonitorWidget->size();
cfg.performanceMonitorWidgetVisible = performanceMonitorWidget->isVisible();
cfg.workingDirectory = QDir::currentPath();
if (settings)
cfg.save(settings);
......@@ -530,3 +526,23 @@ void MainWindow::showAboutDialog()
msg.append("Copyright &copy; 2017 University of Tübingen");
QMessageBox::about(this, "About", msg);
}
void MainWindow::setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible, QPushButton *button)
{
// Sanitize position first
bool inScreen = false;
for (int i = 0; i < QApplication::desktop()->screenCount(); i++)
inScreen |= QApplication::desktop()->screenGeometry(i).contains(position, true);
if (!inScreen)
position = QApplication::desktop()->screenGeometry().topLeft();
window->move(position);
window->resize(size);
if (visible)
window->show();
if (button)
button->setChecked(visible);
}
......@@ -11,6 +11,7 @@
#include <QElapsedTimer>
#include <QTimer>
#include <QDirIterator>
#include <QDesktopWidget>
#include <QDebug>
#include "CameraWidget.h"
......@@ -34,36 +35,46 @@ public:
mainWindowSize( QSize(100, 100)),
logWidgetPos( QPoint(0,0) ),
logWidgetSize( QSize(640, 240)),
logWidgetVisible(true),
leftEyeWidgetPos( QPoint(0,0) ),
leftEyeWidgetSize( QSize(320,240) ),
leftEyeWidgetVisible(true),
rightEyeWidgetPos( QPoint(0,0) ),
rightEyeWidgetSize( QSize(320, 240) ),
rightEyeWidgetVisible(true),
fieldWidgetPos( QPoint(0,0) ),
fieldWidgetSize( QSize(320,240) ),
fieldWidgetVisible(true),
gazeEstimationWidgetPos( QPoint(0,0) ),
gazeEstimationWidgetSize( QSize(100, 100) ),
gazeEstimationWidgetVisible(true),
performanceMonitorWidgetPos( QPoint(0,0) ),
performanceMonitorWidgetSize( QSize(640, 240)),
workingDirectory("./"),
showOpenH264Info(true)
performanceMonitorWidgetVisible(true),
workingDirectory("./")
{}
QPoint mainWindowPos;
QSize mainWindowSize;
QPoint logWidgetPos;
QSize logWidgetSize;
bool logWidgetVisible;
QPoint leftEyeWidgetPos;
QSize leftEyeWidgetSize;
bool leftEyeWidgetVisible;
QPoint rightEyeWidgetPos;
QSize rightEyeWidgetSize;
bool rightEyeWidgetVisible;
QPoint fieldWidgetPos;
QSize fieldWidgetSize;
bool fieldWidgetVisible;
QPoint gazeEstimationWidgetPos;
QSize gazeEstimationWidgetSize;
bool gazeEstimationWidgetVisible;
QPoint performanceMonitorWidgetPos;
QSize performanceMonitorWidgetSize;
bool performanceMonitorWidgetVisible;
QString workingDirectory;
bool showOpenH264Info;
void save(QSettings *settings)
{
......@@ -72,18 +83,23 @@ public:
settings->setValue("mainWindowSize", mainWindowSize);
settings->setValue("logWidgetPos", logWidgetPos);
settings->setValue("logWidgetSize", logWidgetSize);
settings->setValue("logWidgetVisible", logWidgetVisible);
settings->setValue("leftEyeWidgetPos", leftEyeWidgetPos);
settings->setValue("leftEyeWidgetSize", leftEyeWidgetSize);
settings->setValue("leftEyeWidgetVisible", leftEyeWidgetVisible);
settings->setValue("rightEyeWidgetPos", rightEyeWidgetPos);
settings->setValue("rightEyeWidgetSize", rightEyeWidgetSize);
settings->setValue("rightEyeWidgetVisible", rightEyeWidgetVisible);
settings->setValue("fieldWidgetPos", fieldWidgetPos);
settings->setValue("fieldWidgetSize", fieldWidgetSize);
settings->setValue("fieldWidgetVisible", fieldWidgetVisible);
settings->setValue("gazeEstimationWidgetPos", gazeEstimationWidgetPos);
settings->setValue("gazeEstimationWidgetSize", gazeEstimationWidgetSize);
settings->setValue("gazeEstimationWidgetVisible", gazeEstimationWidgetVisible);
settings->setValue("performanceMonitorWidgetPos", performanceMonitorWidgetPos);
settings->setValue("performanceMonitorWidgetSize", performanceMonitorWidgetSize);
settings->setValue("performanceMonitorWidgetVisible", performanceMonitorWidgetVisible);
settings->setValue("workingDirectory", workingDirectory);
settings->setValue("showOpenH264Info", showOpenH264Info);
}
void load(QSettings *settings)
......@@ -93,18 +109,23 @@ public:
set(settings, "mainWindowSize", mainWindowSize);
set(settings, "logWidgetPos", logWidgetPos);
set(settings, "logWidgetSize", logWidgetSize);
set(settings, "logWidgetVisible", logWidgetVisible);
set(settings, "leftEyeWidgetPos", leftEyeWidgetPos);
set(settings, "leftEyeWidgetSize", leftEyeWidgetSize);
set(settings, "leftEyeWidgetVisible", leftEyeWidgetVisible);
set(settings, "rightEyeWidgetPos", rightEyeWidgetPos);
set(settings, "rightEyeWidgetSize", rightEyeWidgetSize);
set(settings, "rightEyeWidgetVisible", rightEyeWidgetVisible);
set(settings, "fieldWidgetPos", fieldWidgetPos);
set(settings, "fieldWidgetSize", fieldWidgetSize);
set(settings, "fieldWidgetVisible", fieldWidgetVisible);
set(settings, "gazeEstimationWidgetPos", gazeEstimationWidgetPos);
set(settings, "gazeEstimationWidgetSize", gazeEstimationWidgetSize);
set(settings, "gazeEstimationWidgetVisible", gazeEstimationWidgetVisible);
set(settings, "performanceMonitorWidgetPos", performanceMonitorWidgetPos);
set(settings, "performanceMonitorWidgetSize", performanceMonitorWidgetSize);
set(settings, "performanceMonitorWidgetVisible", performanceMonitorWidgetVisible);
set(settings, "workingDirectory", workingDirectory);
set(settings, "showOpenH264Info", showOpenH264Info);
}
};
......@@ -149,8 +170,8 @@ private:
void setSubjectName(QString newSubjectName);
void setWorkingDirectory(QString dir);
void widgetButtonReact(QMainWindow *window, bool checked);
void checkForOpenH264();
void createExtraMenus();
void setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible=true, QPushButton *button=NULL);
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
......
......@@ -17,6 +17,9 @@
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QGroupBox" name="droppedFramesBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Counts the number of frames dropped by different sources at the beginning of different stages.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stages:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;1) Frame Grabber: &lt;/span&gt;received an invalid frame from the camera.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;2) Image Processor:&lt;/span&gt; probably the device can't handle the current camera settings.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;3) Data Recorder:&lt;/span&gt; probably the device can't write the data fast enough to the disk.&lt;br/&gt;&lt;/p&gt;&lt;p&gt;To reduce frame dropping from stages 2 and 3, try:&lt;/p&gt;&lt;p&gt;- Reducing the camera fps and resolution (In Widget-&amp;gt;Options-&amp;gt;Device-&amp;gt;Format)&lt;/p&gt;&lt;p&gt;- Downscaling the image before processing (In Widget-&amp;gt;Options-&amp;gt;Image Processor-&amp;gt;Downscaling Factor)&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note: This is from the point of view of EyeRecToo so frames dropped by the driver or hardware are not accounted.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="title">
<string>Dropped Frames</string>
</property>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment