MainWindow.h 3.19 KB
Newer Older
Thiago Santini's avatar
Thiago Santini committed
1 2 3 4
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QCloseEvent>
5 6
#include <QDebug>
#include <QDesktopWidget>
Thiago Santini's avatar
Thiago Santini committed
7
#include <QDir>
8 9
#include <QDirIterator>
#include <QElapsedTimer>
Thiago Santini's avatar
Thiago Santini committed
10
#include <QFileDialog>
11 12
#include <QInputDialog>
#include <QMainWindow>
Thiago Santini's avatar
Thiago Santini committed
13
#include <QMessageBox>
14
#include <QRegExp>
Thiago Santini's avatar
Thiago Santini committed
15 16
#include <QTimer>

17 18
#include "ERWidget.h"

Thiago Santini's avatar
Thiago Santini committed
19
#include "AudioRecorder.h"
20
#include "CameraWidget.h"
Thiago Santini's avatar
Thiago Santini committed
21 22 23 24 25 26 27
#include "Synchronizer.h"

#include "GazeEstimationWidget.h"
#include "NetworkStream.h"

#include "Reference.h"

Thiago Santini's avatar
Thiago Santini committed
28
#include "LogWidget.h"
29
#include "PerformanceMonitorWidget.h"
Thiago Santini's avatar
Thiago Santini committed
30

31 32
#include "post-processing/PostProcessingWidget.h"

33 34
#include "CommandManager.h"

Thiago Santini's avatar
Thiago Santini committed
35 36
#include "utils.h"

37
class MainWindowConfig {
Thiago Santini's avatar
Thiago Santini committed
38
public:
39 40 41 42
    MainWindowConfig()
        : workingDirectory("./")
    {
    }
Thiago Santini's avatar
Thiago Santini committed
43

44
    void save(QSettings* settings)
Thiago Santini's avatar
Thiago Santini committed
45 46
    {
        settings->sync();
47
        settings->setValue("workingDirectory", workingDirectory);
Thiago Santini's avatar
Thiago Santini committed
48 49
    }

50
    void load(QSettings* settings)
Thiago Santini's avatar
Thiago Santini committed
51 52 53
    {
        settings->sync();
        set(settings, "workingDirectory", workingDirectory);
54
    }
Thiago Santini's avatar
Thiago Santini committed
55

56
    QString workingDirectory;
Thiago Santini's avatar
Thiago Santini committed
57 58 59 60 61 62
};

namespace Ui {
class MainWindow;
}

63
class MainWindow : public ERWidget {
Thiago Santini's avatar
Thiago Santini committed
64 65 66
    Q_OBJECT

public:
67
    explicit MainWindow(QWidget* parent = 0);
Thiago Santini's avatar
Thiago Santini committed
68 69 70 71 72 73 74
    ~MainWindow();

signals:
    void startRecording();
    void stopRecording();

private:
75 76
    Ui::MainWindow* ui;
    QSettings* settings;
Thiago Santini's avatar
Thiago Santini committed
77 78
    MainWindowConfig cfg;

79 80 81 82 83 84 85 86 87 88 89
    CameraWidget* lEyeWidget;
    CameraWidget* rEyeWidget;
    CameraWidget* fieldWidget;
    AudioRecorder* audioRecorder;
    Synchronizer* synchronizer;
    GazeEstimationWidget* gazeEstimationWidget;
    QThread* journalThread;
    DataRecorderThread* journal;
    NetworkStream* networkStream;
    LogWidget* logWidget;
    PerformanceMonitorWidget* performanceMonitorWidget;
90
    PostProcessingWidget* postProcessingWidget;
91
    CommandManager commandManager;
Thiago Santini's avatar
Thiago Santini committed
92 93 94 95 96

    QElapsedTimer elapsedTime;
    int elapsedTimeUpdateTimer;
    QString previousPwd;

Thiago Santini's avatar
Thiago Santini committed
97 98
    QSoundEffect recStartSound, recStopSound;

Thiago Santini's avatar
Thiago Santini committed
99 100
    bool setupSubjectDirectory();
    void setSubjectName(QString newSubjectName);
101 102 103
    void widgetButtonReact(QMainWindow* window, bool checked);
    void createExtraMenus();
    void setupWidget(ERWidget* widget, QSettings* settings, QPushButton* button = nullptr);
Thiago Santini's avatar
Thiago Santini committed
104

105
    const QString metaDataFile = "meta.tsv";
Thiago Santini's avatar
Thiago Santini committed
106
    const QString metaDateFormat = "yyyy-MM-dd HH:mm:ss.zzz";
107 108
    void storeMetaDataHead();
    void storeMetaDataTail();
Thiago Santini's avatar
Thiago Santini committed
109

Thiago Santini's avatar
Thiago Santini committed
110
protected:
111
    void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
Thiago Santini's avatar
Thiago Santini committed
112 113

private slots:
114 115
    void setWorkingDirectory(QString dir);
    void restorePreviousPwd();
Thiago Santini's avatar
Thiago Santini committed
116 117 118 119 120 121 122 123 124
    void on_changePwdButton_clicked();
    void on_changeSubjectButton_clicked();
    void on_recordingToggle_clicked();
    void timerEvent(QTimerEvent* event);
    void on_leftEyeCam_clicked();
    void on_rightEyeCam_clicked();
    void on_fieldCam_clicked();
    void on_gazeEstimation_clicked();

125
    void effectiveRecordingStart();
Thiago Santini's avatar
Thiago Santini committed
126 127 128 129

    void menuOption(QAction*);
    void showReferencesDialog();
    void showAboutDialog();
Thiago Santini's avatar
Thiago Santini committed
130
    void on_log_clicked();
131
    void on_performanceMonitor_clicked();
132

133 134
    void toggleRemoteRecording();
    void freezeCameraImages();
135 136
    void unfreezeCameraImages();
    void togglePreview();
137
    void on_postProcessing_clicked();
Thiago Santini's avatar
Thiago Santini committed
138 139 140
};

#endif // MAINWINDOW_H