se2ez
mainwindow.h
Go to the documentation of this file.
1 /* Author: Constantinos Chamzas, Zachary Kingston */
2 
3 #ifndef SE2EZ_GUI_MAINWINDOW_
4 #define SE2EZ_GUI_MAINWINDOW_
5 
6 #include <thread>
7 #include <mutex>
8 
9 #include <boost/date_time.hpp>
10 
11 #include <QMainWindow>
12 
14 
15 #include <se2ez/gui/renderarea.h>
16 
17 namespace Ui
18 {
19  class MainWindow;
20 }
21 
22 namespace se2ez
23 {
24  namespace gui
25  {
26  /** \cond IGNORE */
27  SE2EZ_CLASS_FORWARD(Panel)
28  SE2EZ_CLASS_FORWARD(RenderArea)
29  /** \endcond */
30 
31  /** \brief The main widget that acts a container for other widgets (canvas, panels).
32  * It also delegates the drawing functions between the panels and the canvas.
33  */
34  class MainWindow : public QMainWindow
35  {
36  Q_OBJECT
37  friend class RenderArea;
38 
39  public:
42 
43  /** \name Constructors
44  \{ */
45 
46  /** \brief Constructor. Nothing intresting for now */
47  explicit MainWindow(QWidget *parent = nullptr);
48 
49  /** \brief Destructor Nothing intresting for now.*/
50  ~MainWindow();
51 
52  /** \} */
53 
54  /** \name Panels
55  \{ */
56 
57  /** \brief Asks all the panels to draw their respective information
58  * \param[in] painter QPainter the QObject that paints/draws .
59  * \param[in] canvas RenderArea the drawing widget
60  */
61  void draw(QPainter &painter, RenderArea *canvas);
62 
63  /** \brief Asks the top panel to click at the location.
64  * \param[in] event Mouse event that was triggered.
65  * \param[in] x x coordinate in robot space
66  * \param[in] y y coordinate in robot space
67  * \param[in] sx x coordinate in screen space
68  * \param[in] sy y coordinate in screen space
69  */
70  void click(QMouseEvent *event, double x, double y, int sx, int sy);
71 
72  /** \brief Adds a panel to the main GUI
73  * \param[in] panel Pointer to the Panel.
74  */
75  void addPanel(Panel *panel);
76 
77  /** \} */
78 
79  protected:
80  void resizeEvent(QResizeEvent *e) override;
81 
82  private slots:
83  /** \brief calls the update function from canvas to draw the updated state*/
84  void updateState();
85 
86  /** \brief Slot called when the origin is updated*/
87  void updateOriginX(double x);
88 
89  /** \brief Slot called when the origin is updated*/
90  void updateOriginY(double y);
91 
92  /** \brief Slot called when the scale is updated*/
93  void updateScale(double scale);
94 
95  void record();
96  void screenshot();
97 
98  void process();
99 
100  private:
101  Ui::MainWindow *ui_; ///< UI (User Interface) pointer.
102  RenderArea *canvas_; ///< The canvas widget.
103  PanelMapPtr panels_; ///< Holds the panels.
104 
105  bool screen_{false};
106  bool record_{false};
107  std::thread *camera_{nullptr}; ///< Thread used to record the camera
108  std::string directory_; ///< Directory to save screenshots/videos
109 
110  unsigned int shotnum_; ///< Number of screenshots taken
111 
112  bool update_{true};
113  bool didUpdate_{false};
115 
116  boost::posix_time::ptime last_;
117  };
118  } // namespace gui
119 } // namespace se2ez
120 
121 #endif
The main widget that acts a container for other widgets (canvas, panels). It also delegates the drawi...
Definition: mainwindow.h:34
boost::posix_time::ptime last_
Definition: mainwindow.h:116
Definition: cspacepanel.h:22
RenderArea * canvas_
The canvas widget.
Definition: mainwindow.h:102
Ui::MainWindow * ui_
UI (User Interface) pointer.
Definition: mainwindow.h:101
unsigned int shotnum_
Number of screenshots taken.
Definition: mainwindow.h:110
The canvas widget. It contains all the drawing functions as well as all the general settings for draw...
Definition: renderarea.h:48
Main namespace.
Definition: collision.h:11
std::mutex updateMutex_
Definition: mainwindow.h:114
PanelMapPtr panels_
Holds the panels.
Definition: mainwindow.h:103
std::string directory_
Directory to save screenshots/videos.
Definition: mainwindow.h:108
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9