PosturePerfection
mainwindow.h
Go to the documentation of this file.
1 
21 #ifndef SRC_GUI_MAINWINDOW_H_
22 #define SRC_GUI_MAINWINDOW_H_
23 
24 #include <QApplication>
25 #include <QComboBox>
26 #include <QDate>
27 #include <QDialog>
28 #include <QFrame>
29 #include <QGroupBox>
30 #include <QInputDialog>
31 #include <QLabel>
32 #include <QMainWindow>
33 #include <QMenuBar>
34 #include <QPainter>
35 #include <QPushButton>
36 #include <QRect>
37 #include <QStackedWidget>
38 #include <QStandardItemModel>
39 #include <QStatusBar>
40 #include <QTableView>
41 #include <QTime>
42 #include <QTimer>
43 #include <QVBoxLayout>
44 #include <QWidget>
45 #include <QtCore/QVariant>
46 #include <opencv2/imgcodecs.hpp>
47 
48 #include "../intermediate_structures.h"
49 #include "../pipeline.h"
50 #include "../posture_estimator.h"
51 #include "opencv2/opencv.hpp"
52 
53 #define WIDGET_PADDING 5
54 
55 QT_BEGIN_NAMESPACE
56 
62 namespace GUI {
63 
69 class Button : public QPushButton {
70  Q_OBJECT
71  private:
72  QString title;
73  QString subtitle;
74  size_t padding = WIDGET_PADDING;
75 
76  void constructor(const QString &title, const QString &subtitle,
77  QWidget *parent = 0);
78 
79  public:
80  explicit Button(const QString &title, QWidget *parent = 0);
81 
82  explicit Button(const QString &title, const QString &subtitle,
83  QWidget *parent = 0);
84 
85  void setText(const QString &title);
86 
87  void setText(const QString &title, const QString &subtitle);
88 
89  void paintEvent(QPaintEvent *p);
90 };
91 
97 class Label : public QLabel {
98  Q_OBJECT
99  private:
100  QString title;
101  QString subtitle;
102  size_t padding = WIDGET_PADDING;
103 
104  void constructor(const QString &title, const QString &subtitle,
105  QWidget *parent = 0);
106 
107  public:
108  explicit Label(QWidget *parent = 0);
109 
110  explicit Label(const QString &title, QWidget *parent = 0);
111 
112  Label(const QString &title, const QString &subtitle, QWidget *parent = 0);
113 
114  void setText(const QString &title);
115 
116  void setText(const QString &title, const QString &subtitle);
117 
118  void paintEvent(QPaintEvent *p);
119 };
120 
133 class MainWindow : public QMainWindow {
134  Q_OBJECT
135 
136  public:
143  QWidget *parent = 0); // NOLINT [runtime/explicit]
144  ~MainWindow();
145 
151  void emitNewFrame(cv::Mat currentFrame);
152 
157  void createMainPage();
158 
163  void createSettingsPage();
164 
165  void createAboutPage();
166 
171  void updatePose(PostureEstimating::PoseStatus poseStatus);
172 
177  void setOutputFramerate();
178 
179  public slots:
184  void setThresholdValue(int);
185 
190  void setPoseChangeThresholdValue(int);
191 
196  void increaseVideoFramerate();
197 
202  void decreaseVideoFramerate();
203 
208  void setIdealPosture();
209 
214  void updateVideoFrame(cv::Mat currentFrame);
215 
223 
228  void openMainPage(void);
229 
234  void openSettingsPage(void);
235 
240  void openAboutPage(void);
241 
242  signals:
248  void currentFrameSignal(cv::Mat currentFrame);
249 
256 
257  private:
261  void initalFrame();
262 
263  Pipeline::Pipeline *pipelinePtr = nullptr;
264  PostureEstimating::PoseStatus currentPoseStatus;
265 
266  Label *currentFrameRate = new Label();
267  Label *postureNotification = new Label();
268  Button *idealPostureButton =
269  new Button("Set Ideal Posture", "Set current\nposture as my target");
270 
271  QGridLayout *mainLayout = new QGridLayout;
272  QWidget *central = new QWidget;
273  QStandardItemModel *model = new QStandardItemModel();
274  QLabel *frame = new QLabel();
275  QStackedWidget *stackedWidget = new QStackedWidget;
276  QComboBox *pageComboBox = new QComboBox;
277  QGroupBox *groupDateTime = new QGroupBox();
278  QVBoxLayout *dtBox = new QVBoxLayout;
279 
280  QWidget *firstPageWidget = new QWidget;
281  QGridLayout *mainPageLayout = new QGridLayout;
282 
283  QWidget *secondPageWidget = new QWidget;
284  QGridLayout *settingsPageLayout = new QGridLayout;
285 
286  QWidget *thirdPageWidget = new QWidget;
287  QGridLayout *aboutPageLayout = new QGridLayout;
288 
289  private slots:
293  void showDateTime();
294 };
295 } // namespace GUI
296 QT_END_NAMESPACE
297 #endif // SRC_GUI_MAINWINDOW_H_
Subclass of QPushButton that allows having a title and subtitle within the button.
Definition: mainwindow.h:69
void setText(const QString &title)
Definition: custom_widgets.cpp:159
void paintEvent(QPaintEvent *p)
Definition: custom_widgets.cpp:167
Button(const QString &title, QWidget *parent=0)
Definition: custom_widgets.cpp:150
Subclass of QLabel that allows having a title and subtitle within the label.
Definition: mainwindow.h:97
void paintEvent(QPaintEvent *p)
Definition: custom_widgets.cpp:115
void setText(const QString &title)
Definition: custom_widgets.cpp:107
Label(QWidget *parent=0)
Definition: custom_widgets.cpp:96
Allows for navigation around the application from the main page by letting the user navigate to the d...
Definition: mainwindow.h:133
void currentFrameSignal(cv::Mat currentFrame)
emit the newly captured frame
void createMainPage()
Creates the main page within the application.
Definition: mainwindow.cpp:138
void createAboutPage()
Definition: mainwindow.cpp:238
void openMainPage(void)
Switch to the main page with the video feed.
Definition: mainwindow.cpp:87
void setOutputFramerate()
Outputs the framerate to the GUI.
Definition: mainwindow.cpp:294
void createSettingsPage()
Creates the settings page within the application.
Definition: mainwindow.cpp:167
void updatePose(PostureEstimating::PoseStatus poseStatus)
Updates the current pose.
Definition: mainwindow.cpp:133
void openSettingsPage(void)
Switch to the settings page.
Definition: mainwindow.cpp:89
void setPoseChangeThresholdValue(int)
Updates the PostureEstimating::pose_change_threshold value.
Definition: mainwindow.cpp:306
void increaseVideoFramerate()
Increases the video frame rate.
Definition: mainwindow.cpp:289
MainWindow(Pipeline::Pipeline *Pipeline, QWidget *parent=0)
Initialises the main page.
Definition: mainwindow.cpp:30
void openAboutPage(void)
Switch to the help and about page.
Definition: mainwindow.cpp:93
void setIdealPosture()
sets the current pose to the ideal posture
Definition: mainwindow.cpp:278
void updateVideoFrame(cv::Mat currentFrame)
update the video ouput once a new frame has been captured
Definition: mainwindow.cpp:362
void currentGoodBadPosture(PostureEstimating::PostureState postureState)
emit the newly captured good posture value
void updatePostureNotification(PostureEstimating::PostureState postureState)
update the posture notification using the posture status "good" value
Definition: mainwindow.cpp:95
~MainWindow()
Definition: mainwindow.cpp:343
void emitNewFrame(cv::Mat currentFrame)
Refresh the video feed to the most recent frame.
Definition: mainwindow.cpp:358
void setThresholdValue(int)
Updates the threshold value.
Definition: mainwindow.cpp:284
void decreaseVideoFramerate()
Decreases the video frame rate.
Definition: mainwindow.cpp:301
Frame-by-frame pipeline to process video.
Definition: pipeline.h:494
#define WIDGET_PADDING
Definition: mainwindow.h:53
All code related to the graphical user interface for PosturePerfection.
Definition: custom_widgets.cpp:24
Components of the pipeline at the core of the system.
Definition: framerate_settings.cpp:22
PostureState
Potential states which the posture can be. Unset means that the ideal_pose has not been set by the us...
Definition: posture_estimator.h:90
Representation of user's pose for use by the pipeline processing.
Definition: posture_estimator.h:100