Commit fdd49102 authored by Thiago Santini's avatar Thiago Santini

Starts Log Widget

parent 3d3367c7
...@@ -33,7 +33,8 @@ SOURCES +=\ ...@@ -33,7 +33,8 @@ SOURCES +=\
$${TOP}/src/gaze-estimation/Homography.cpp \ $${TOP}/src/gaze-estimation/Homography.cpp \
$${TOP}/src/DataRecorder.cpp \ $${TOP}/src/DataRecorder.cpp \
$${TOP}/src/NetworkStream.cpp \ $${TOP}/src/NetworkStream.cpp \
$${TOP}/src/Reference.cpp $${TOP}/src/Reference.cpp \
$${TOP}/src/LogWidget.cpp
HEADERS += \ HEADERS += \
$${TOP}/src/MainWindow.h\ $${TOP}/src/MainWindow.h\
...@@ -56,12 +57,14 @@ HEADERS += \ ...@@ -56,12 +57,14 @@ HEADERS += \
$${TOP}/src/gaze-estimation/Homography.h \ $${TOP}/src/gaze-estimation/Homography.h \
$${TOP}/src/DataRecorder.h \ $${TOP}/src/DataRecorder.h \
$${TOP}/src/NetworkStream.h \ $${TOP}/src/NetworkStream.h \
$${TOP}/src/Reference.h $${TOP}/src/Reference.h \
$${TOP}/src/LogWidget.h
FORMS += \ FORMS += \
$${TOP}/src/MainWindow.ui \ $${TOP}/src/MainWindow.ui \
$${TOP}/src/CameraWidget.ui \ $${TOP}/src/CameraWidget.ui \
$${TOP}/src/GazeEstimationWidget.ui $${TOP}/src/GazeEstimationWidget.ui \
src/LogWidget.ui
RESOURCES += \ RESOURCES += \
$${TOP}/resources.qrc $${TOP}/resources.qrc
......
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
<file>icons/fieldWidget.png</file> <file>icons/fieldWidget.png</file>
<file>icons/EyeRecToo.png</file> <file>icons/EyeRecToo.png</file>
<file>icons/gazeEstimationWidget.png</file> <file>icons/gazeEstimationWidget.png</file>
<file>icons/logWidget.png</file>
</qresource> </qresource>
</RCC> </RCC>
#include "LogWidget.h"
#include "ui_LogWidget.h"
LogWidget::LogWidget(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::LogWidget)
{
ui->setupUi(this);
setWindowTitle("Log Widget");
setWindowIcon(QIcon(":/icons/logWidget.png"));
}
LogWidget::~LogWidget()
{
delete ui;
}
void LogWidget::appendMessage(const QString &msg)
{
ui->log->appendPlainText(msg.trimmed());
}
#ifndef LOGWIDGET_H
#define LOGWIDGET_H
#include <QMainWindow>
namespace Ui {
class LogWidget;
}
class LogWidget : public QMainWindow
{
Q_OBJECT
public:
explicit LogWidget(QWidget *parent = 0);
~LogWidget();
public slots:
void appendMessage(const QString &msg);
private:
Ui::LogWidget *ui;
};
#endif // LOGWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LogWidget</class>
<widget class="QMainWindow" name="LogWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>240</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="log">
<property name="font">
<font>
<family>Courier New</family>
</font>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
...@@ -34,6 +34,12 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -34,6 +34,12 @@ MainWindow::MainWindow(QWidget *parent) :
ui->blinker->hide(); ui->blinker->hide();
logWidget = new LogWidget();
logWidget->show();
logWidget->move(cfg.logWidgetPos);
logWidget->resize(cfg.logWidgetSize);
gLogWidget = logWidget;
/* /*
* WARNING: DO NOT REMOVE THIS CALL to QCameraInfo::availableCameras() * WARNING: DO NOT REMOVE THIS CALL to QCameraInfo::availableCameras()
* Logically, its meaningless, but it guarantees that DirectShow will work * Logically, its meaningless, but it guarantees that DirectShow will work
...@@ -138,6 +144,8 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -138,6 +144,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
cfg.mainWindowPos = pos(); cfg.mainWindowPos = pos();
cfg.mainWindowSize = size(); cfg.mainWindowSize = size();
cfg.logWidgetPos = logWidget->pos();
cfg.logWidgetSize = logWidget->size();
cfg.leftEyeWidgetPos = lEyeWidget->pos(); cfg.leftEyeWidgetPos = lEyeWidget->pos();
cfg.leftEyeWidgetSize = lEyeWidget->size(); cfg.leftEyeWidgetSize = lEyeWidget->size();
cfg.rightEyeWidgetPos = rEyeWidget->pos(); cfg.rightEyeWidgetPos = rEyeWidget->pos();
...@@ -182,6 +190,11 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -182,6 +190,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
if (networkStream) if (networkStream)
networkStream->deleteLater(); networkStream->deleteLater();
if (logWidget) {
gLogWidget = NULL;
logWidget->deleteLater();
}
if (settings) if (settings)
settings->deleteLater(); settings->deleteLater();
...@@ -375,6 +388,11 @@ void MainWindow::on_gazeEstimation_clicked() ...@@ -375,6 +388,11 @@ void MainWindow::on_gazeEstimation_clicked()
widgetButtonReact(gazeEstimationWidget, ui->gazeEstimation->isChecked()); widgetButtonReact(gazeEstimationWidget, ui->gazeEstimation->isChecked());
} }
void MainWindow::on_log_clicked()
{
widgetButtonReact(logWidget, ui->log->isChecked());
}
void MainWindow::keyPressEvent(QKeyEvent *event) void MainWindow::keyPressEvent(QKeyEvent *event)
{ {
if (event->isAutoRepeat()) if (event->isAutoRepeat())
...@@ -524,3 +542,4 @@ void MainWindow::checkForOpenH264() ...@@ -524,3 +542,4 @@ void MainWindow::checkForOpenH264()
qInfo() << "Video encoder:" << (gHasOpenH264 ? "OpenH264" : "DivX"); qInfo() << "Video encoder:" << (gHasOpenH264 ? "OpenH264" : "DivX");
} }
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "Reference.h" #include "Reference.h"
#include "LogWidget.h"
#include "utils.h" #include "utils.h"
class MainWindowConfig class MainWindowConfig
...@@ -29,6 +31,8 @@ public: ...@@ -29,6 +31,8 @@ public:
MainWindowConfig() : MainWindowConfig() :
mainWindowPos( QPoint(0,0) ), mainWindowPos( QPoint(0,0) ),
mainWindowSize( QSize(100, 100)), mainWindowSize( QSize(100, 100)),
logWidgetPos( QPoint(0,0) ),
logWidgetSize( QSize(640, 240)),
leftEyeWidgetPos( QPoint(0,0) ), leftEyeWidgetPos( QPoint(0,0) ),
leftEyeWidgetSize( QSize(320,240) ), leftEyeWidgetSize( QSize(320,240) ),
rightEyeWidgetPos( QPoint(0,0) ), rightEyeWidgetPos( QPoint(0,0) ),
...@@ -43,6 +47,8 @@ public: ...@@ -43,6 +47,8 @@ public:
QPoint mainWindowPos; QPoint mainWindowPos;
QSize mainWindowSize; QSize mainWindowSize;
QPoint logWidgetPos;
QSize logWidgetSize;
QPoint leftEyeWidgetPos; QPoint leftEyeWidgetPos;
QSize leftEyeWidgetSize; QSize leftEyeWidgetSize;
QPoint rightEyeWidgetPos; QPoint rightEyeWidgetPos;
...@@ -59,6 +65,8 @@ public: ...@@ -59,6 +65,8 @@ public:
settings->sync(); settings->sync();
settings->setValue("mainWindowPos", mainWindowPos); settings->setValue("mainWindowPos", mainWindowPos);
settings->setValue("mainWindowSize", mainWindowSize); settings->setValue("mainWindowSize", mainWindowSize);
settings->setValue("logWidgetPos", logWidgetPos);
settings->setValue("logWidgetSize", logWidgetSize);
settings->setValue("leftEyeWidgetPos", leftEyeWidgetPos); settings->setValue("leftEyeWidgetPos", leftEyeWidgetPos);
settings->setValue("leftEyeWidgetSize", leftEyeWidgetSize); settings->setValue("leftEyeWidgetSize", leftEyeWidgetSize);
settings->setValue("rightEyeWidgetPos", rightEyeWidgetPos); settings->setValue("rightEyeWidgetPos", rightEyeWidgetPos);
...@@ -76,6 +84,8 @@ public: ...@@ -76,6 +84,8 @@ public:
settings->sync(); settings->sync();
set(settings, "mainWindowPos", mainWindowPos); set(settings, "mainWindowPos", mainWindowPos);
set(settings, "mainWindowSize", mainWindowSize); set(settings, "mainWindowSize", mainWindowSize);
set(settings, "logWidgetPos", logWidgetPos);
set(settings, "logWidgetSize", logWidgetSize);
set(settings, "leftEyeWidgetPos", leftEyeWidgetPos); set(settings, "leftEyeWidgetPos", leftEyeWidgetPos);
set(settings, "leftEyeWidgetSize", leftEyeWidgetSize); set(settings, "leftEyeWidgetSize", leftEyeWidgetSize);
set(settings, "rightEyeWidgetPos", rightEyeWidgetPos); set(settings, "rightEyeWidgetPos", rightEyeWidgetPos);
...@@ -119,6 +129,7 @@ private: ...@@ -119,6 +129,7 @@ private:
QThread *journalThread; QThread *journalThread;
DataRecorderThread *journal; DataRecorderThread *journal;
NetworkStream * networkStream; NetworkStream * networkStream;
LogWidget *logWidget;
QElapsedTimer elapsedTime; QElapsedTimer elapsedTime;
int elapsedTimeUpdateTimer; int elapsedTimeUpdateTimer;
...@@ -151,6 +162,7 @@ private slots: ...@@ -151,6 +162,7 @@ private slots:
void menuOption(QAction*); void menuOption(QAction*);
void showReferencesDialog(); void showReferencesDialog();
void showAboutDialog(); void showAboutDialog();
void on_log_clicked();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>252</width> <width>319</width>
<height>371</height> <height>371</height>
</rect> </rect>
</property> </property>
...@@ -393,6 +393,56 @@ ...@@ -393,6 +393,56 @@
<string>Widgets</string> <string>Widgets</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="QPushButton" name="rightEyeCam">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="toolTip">
<string>Toggle Right Eye Cam Widget</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/icons/rEyeWidget.png</normaloff>:/icons/rEyeWidget.png</iconset>
</property>
<property name="iconSize">
<size>
<width>33</width>
<height>33</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="leftEyeCam"> <widget class="QPushButton" name="leftEyeCam">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -452,8 +502,8 @@ ...@@ -452,8 +502,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="2">
<widget class="QPushButton" name="rightEyeCam"> <widget class="QPushButton" name="fieldCam">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -473,7 +523,7 @@ ...@@ -473,7 +523,7 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Toggle Right Eye Cam Widget</string> <string>Toggle Field Cam Widget</string>
</property> </property>
<property name="statusTip"> <property name="statusTip">
<string/> <string/>
...@@ -486,7 +536,7 @@ ...@@ -486,7 +536,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../resources.qrc">
<normaloff>:/icons/rEyeWidget.png</normaloff>:/icons/rEyeWidget.png</iconset> <normaloff>:/icons/fieldWidget.png</normaloff>:/icons/fieldWidget.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
...@@ -502,8 +552,8 @@ ...@@ -502,8 +552,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="3">
<widget class="QPushButton" name="fieldCam"> <widget class="QPushButton" name="gazeEstimation">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -523,7 +573,7 @@ ...@@ -523,7 +573,7 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Toggle Field Cam Widget</string> <string>Toggle Gaze Estimation Widget</string>
</property> </property>
<property name="statusTip"> <property name="statusTip">
<string/> <string/>
...@@ -536,7 +586,7 @@ ...@@ -536,7 +586,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../resources.qrc">
<normaloff>:/icons/fieldWidget.png</normaloff>:/icons/fieldWidget.png</iconset> <normaloff>:/icons/gazeEstimationWidget.png</normaloff>:/icons/gazeEstimationWidget.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
...@@ -552,8 +602,11 @@ ...@@ -552,8 +602,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="4">
<widget class="QPushButton" name="gazeEstimation"> <widget class="QPushButton" name="log">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
...@@ -573,20 +626,14 @@ ...@@ -573,20 +626,14 @@
</size> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Toggle Gaze Estimation Widget</string> <string>Toggle Log Widget</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../resources.qrc">
<normaloff>:/icons/gazeEstimationWidget.png</normaloff>:/icons/gazeEstimationWidget.png</iconset> <normaloff>:/icons/logWidget.png</normaloff>:/icons/logWidget.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
...@@ -614,7 +661,7 @@ ...@@ -614,7 +661,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>252</width> <width>319</width>
<height>20</height> <height>20</height>
</rect> </rect>
</property> </property>
......
...@@ -20,6 +20,9 @@ QTextStream gLogStream; ...@@ -20,6 +20,9 @@ QTextStream gLogStream;
std::atomic<bool> gRecording(false); std::atomic<bool> gRecording(false);
bool gHasOpenH264 = false; bool gHasOpenH264 = false;
LogWidget *gLogWidget = NULL;
std::vector<QString> gLogBuffer;
/* /*
* Utility functions * Utility functions
*/ */
...@@ -88,6 +91,16 @@ void logMessages(QtMsgType type, const QMessageLogContext &context, const QStrin ...@@ -88,6 +91,16 @@ void logMessages(QtMsgType type, const QMessageLogContext &context, const QStrin
if (gLogStream.status() == QTextStream::Ok) if (gLogStream.status() == QTextStream::Ok)
gLogStream << str.c_str(); gLogStream << str.c_str();
if (gLogWidget) {
if (gLogBuffer.size() > 0) {
for (auto s=gLogBuffer.begin(); s!=gLogBuffer.end(); s++)
QMetaObject::invokeMethod( gLogWidget, "appendMessage", Q_ARG( const QString&, *s ) );
gLogBuffer.clear();
}
QMetaObject::invokeMethod( gLogWidget, "appendMessage", Q_ARG( const QString&, QString(str.c_str())) );
} else
gLogBuffer.push_back( QString(str.c_str()) );
std::cout.flush(); std::cout.flush();
gLogStream.flush(); gLogStream.flush();
} }
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <opencv2/imgproc.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp> #include <opencv2/calib3d.hpp>
#include "LogWidget.h"
/* /*
* Global variables * Global variables
*/ */
...@@ -96,4 +98,7 @@ template<typename T> void set(const QSettings *settings, const QString key, T &v ...@@ -96,4 +98,7 @@ template<typename T> void set(const QSettings *settings, const QString key, T &v
void loadSoundEffect(QSoundEffect &effect, QString fileName); void loadSoundEffect(QSoundEffect &effect, QString fileName);
extern LogWidget *gLogWidget;
extern std::vector<QString> gLogBuffer;
#endif // UTILS_H #endif // UTILS_H
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