mainguiwindow.h 4.22 KB
Newer Older
roangel's avatar
roangel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//    Teacher's GUI main window header.
//    Copyright (C) 2017  Angel Romero
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

17
18
19
#ifndef MAINGUIWINDOW_H
#define MAINGUIWINDOW_H

20
// The #define CATKIN_MAKE comes from cmake file
21
22
23
24
25
#include <QMainWindow>
#include <QTimer>
#include <QGridLayout>
#include <QGraphicsRectItem>

26

27
#ifdef CATKIN_MAKE
28
#include "rosNodeThread.h"
29
30
#include "marker.h"
#include "crazyFly.h"
31
#include "CFLinker.h"
32
33

#include "d_fall_pps/CrazyflieDB.h"
34
#include "d_fall_pps/CrazyflieEntry.h"
35

36
37
#include <std_msgs/Int32.h>

38

39
#define CMD_CRAZYFLY_MOTORS_OFF   5
40
using namespace d_fall_pps;
41

42
#endif
43

44

45
46
#include "ui_mainguiwindow.h"
#include "myGraphicsScene.h"
47
48
#include "globalDefinitions.h"

49
50
51
52
53
54

namespace Ui {
class MainGUIWindow;
}


55
#ifdef CATKIN_MAKE
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
struct setpoint
{
    double x;
    double y;
    double z;
    double yaw;
};

class CSetpointQueue
{
public:
    CSetpointQueue();
    void insert(setpoint newElem);
    setpoint getNext();
    void print();

private:
    struct QueueElem
    {
        QueueElem(setpoint newElem) {elem.x=newElem.x; elem.y=newElem.y; elem.z=newElem.z; elem.yaw=newElem.yaw; next=NULL;}
        setpoint elem;
        QueueElem* next;
    };

    QueueElem* startElem;
    QueueElem* currElem;
    QueueElem* lastElem;
};
#endif

class MainGUIWindow : public QMainWindow
{
    Q_OBJECT

public:
91
92
    explicit MainGUIWindow(int argc, char **argv, QWidget *parent = 0);

93
94
95
    ~MainGUIWindow();

public slots:
96

97
private slots:
98
    #ifdef CATKIN_MAKE
99
    #endif
100

roangel's avatar
roangel committed
101
    void doNumCrazyFlyZonesChanged(int n);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
    void transitionToMode(int mode);
    void on_removeTable_clicked();

    void on_radioButton_table_mode_toggled(bool checked);

    void on_radioButton_crazyfly_zones_mode_toggled(bool checked);
    void handleTablePiecesNumChanged(int newNum);

    void on_radioButton_lock_mode_toggled(bool checked);

    void on_checkBox_grid_toggled(bool checked);

    void on_checkBox_table_toggled(bool checked);

    void on_checkBox_crazyfly_zones_toggled(bool checked);

    void on_tabWidget_currentChanged(int index);

    void centerViewIndex(int index);

    void on_pushButton_fitAll_clicked();

124
125
126
127
    void on_checkBox_vicon_markers_toggled(bool checked);

    void on_checkBox_vicon_highlight_markers_toggled(bool checked);

128
129
130
131
    void on_save_in_DB_button_clicked();

    void on_load_from_DB_button_clicked();

roangel's avatar
roangel committed
132
    #ifdef CATKIN_MAKE
133
    void updateNewViconData(const ptrToMessage& p_msg);
roangel's avatar
roangel committed
134
    #endif
135
136
137
    void on_checkBox_vicon_crazyflies_toggled(bool checked);

    void on_scaleSpinBox_valueChanged(double arg1);
138
139
140
    void on_refresh_cfs_button_clicked();

    void on_refresh_student_ids_button_clicked();
141

142
143
    void on_link_button_clicked();

144
145
    void on_unlink_button_clicked();

146
147
    void updateComboBoxes();

148
149
150
    void setTabIndex(int index);
    void doTabClosed(int tab_index);

151
152
    void on_comboBoxCFs_currentTextChanged(const QString &arg1);

153
154
    void on_all_motors_off_button_clicked();

155
156
157
158
159
160
private:

    Ui::MainGUIWindow *ui;
    myGraphicsScene* scene;
    void _init();

161

162
    #ifdef CATKIN_MAKE
163
    rosNodeThread* _rosNodeThread;
164
165
    std::vector<Marker*> markers_vector;
    std::vector<crazyFly*> crazyflies_vector;
166
    CFLinker* cf_linker;
167
168

    ros::Publisher DBChangedPublisher;
169
    ros::Publisher emergencyStopPublisher;
170
    #endif
171
172
173
174
175

    void updateComboBoxesCFs();

    void updateComboBoxesCFZones();

176
177
    int getTabIndexFromName(QString name);

178
    CrazyflieDB m_data_base;
179
180
181
182
183
184
185
186
187
188
189

    void clear_database_file();

    void fill_database_file();

    int read_database_from_file(CrazyflieDB &read_db);

    void save_database_file();

    void insert_or_update_entry_database(CrazyflieEntry entry);

190
191
192
193
194
};



#endif // MAINGUIWINDOW_H