mainguiwindow.h 4.62 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
#include <std_msgs/Int32.h>
37
#include <std_msgs/Int32MultiArray.h>
38

39

40
#define CMD_CRAZYFLY_MOTORS_OFF   5
41
using namespace d_fall_pps;
42

43
#endif
44

45

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

50
51
52
53
54
55

namespace Ui {
class MainGUIWindow;
}


56
#ifdef CATKIN_MAKE
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
91
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:
92
93
    explicit MainGUIWindow(int argc, char **argv, QWidget *parent = 0);

94
95
96
    ~MainGUIWindow();

public slots:
97

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

roangel's avatar
roangel committed
102
    void doNumCrazyFlyZonesChanged(int n);
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
    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();

125
126
127
128
    void on_checkBox_vicon_markers_toggled(bool checked);

    void on_checkBox_vicon_highlight_markers_toggled(bool checked);

129
130
131
132
    void on_save_in_DB_button_clicked();

    void on_load_from_DB_button_clicked();

133
134
    void on_checkBox_enable_UWB_toggled(bool checked);

tiagos's avatar
tiagos committed
135
136
    void on_reloadAnchors_button_pressed();

roangel's avatar
roangel committed
137
    #ifdef CATKIN_MAKE
138
    void updateNewViconData(const ptrToMessage& p_msg);
139
140
141
142

    void updateStudentIDs(const std_msgs::Int32MultiArray& ids);

    void updateCFPositions(const CrazyfliePositionData& data);
roangel's avatar
roangel committed
143
    #endif
144
145
146
    void on_checkBox_vicon_crazyflies_toggled(bool checked);

    void on_scaleSpinBox_valueChanged(double arg1);
147
148
149
    void on_refresh_cfs_button_clicked();

    void on_refresh_student_ids_button_clicked();
150

151
152
    void on_link_button_clicked();

153
154
    void on_unlink_button_clicked();

155
156
    void updateComboBoxes();

157
158
159
    void setTabIndex(int index);
    void doTabClosed(int tab_index);

160
161
    void on_comboBoxCFs_currentTextChanged(const QString &arg1);

162
163
    void on_all_motors_off_button_clicked();

164
165
166
167
168
169
private:

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

170

171
    #ifdef CATKIN_MAKE
172
    rosNodeThread* _rosNodeThread;
173
174
    std::vector<Marker*> markers_vector;
    std::vector<crazyFly*> crazyflies_vector;
175
    std::vector<crazyFly*> cf_positionsVector;
176
    CFLinker* cf_linker;
177
178

    ros::Publisher DBChangedPublisher;
179
    ros::Publisher emergencyStopPublisher;
180
181

    ros::Publisher refreshStudents_publisher;
tiagos's avatar
tiagos committed
182
    ros::Publisher UWBSettings_publisher;
183
    
184
    #endif
185
186
187
188
189

    void updateComboBoxesCFs();

    void updateComboBoxesCFZones();

190
191
    int getTabIndexFromName(QString name);

192
    CrazyflieDB m_data_base;
193
194
195
196
197
198
199
200
201
202
203

    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);

204
205
206
207
208
};



#endif // MAINGUIWINDOW_H