mainguiwindow.h 3.48 KB
Newer Older
1
2
3
#ifndef MAINGUIWINDOW_H
#define MAINGUIWINDOW_H

4
// The #define CATKIN_MAKE comes from cmake file
5
6
7
8
9
#include <QMainWindow>
#include <QTimer>
#include <QGridLayout>
#include <QGraphicsRectItem>

10

11
#ifdef CATKIN_MAKE
12
#include "rosNodeThread.h"
13
14
#include "marker.h"
#include "crazyFly.h"
15
#include "CFLinker.h"
16
17

#include "d_fall_pps/CrazyflieDB.h"
18
#include "d_fall_pps/CrazyflieEntry.h"
19

20
21
#include <std_msgs/Int32.h>

22

23
#define CMD_CRAZYFLY_MOTORS_OFF   5
24
using namespace d_fall_pps;
25

26
#endif
27

28

29
30
#include "ui_mainguiwindow.h"
#include "myGraphicsScene.h"
31
32
#include "globalDefinitions.h"

33
34
35
36
37
38

namespace Ui {
class MainGUIWindow;
}


39
#ifdef CATKIN_MAKE
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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:
75
76
    explicit MainGUIWindow(int argc, char **argv, QWidget *parent = 0);

77
78
79
    ~MainGUIWindow();

public slots:
80

81
private slots:
82
    #ifdef CATKIN_MAKE
83
    #endif
84

roangel's avatar
roangel committed
85
    void doNumCrazyFlyZonesChanged(int n);
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
    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();

108
109
110
111
    void on_checkBox_vicon_markers_toggled(bool checked);

    void on_checkBox_vicon_highlight_markers_toggled(bool checked);

112
113
114
115
    void on_save_in_DB_button_clicked();

    void on_load_from_DB_button_clicked();

roangel's avatar
roangel committed
116
    #ifdef CATKIN_MAKE
117
    void updateNewViconData(const ptrToMessage& p_msg);
roangel's avatar
roangel committed
118
    #endif
119
120
121
    void on_checkBox_vicon_crazyflies_toggled(bool checked);

    void on_scaleSpinBox_valueChanged(double arg1);
122
123
124
    void on_refresh_cfs_button_clicked();

    void on_refresh_student_ids_button_clicked();
125

126
127
    void on_link_button_clicked();

128
129
    void on_unlink_button_clicked();

130
131
    void updateComboBoxes();

132
133
134
    void setTabIndex(int index);
    void doTabClosed(int tab_index);

135
136
    void on_comboBoxCFs_currentTextChanged(const QString &arg1);

137
138
    void on_all_motors_off_button_clicked();

139
140
141
142
143
144
private:

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

145

146
    #ifdef CATKIN_MAKE
147
    rosNodeThread* _rosNodeThread;
148
149
    std::vector<Marker*> markers_vector;
    std::vector<crazyFly*> crazyflies_vector;
150
    CFLinker* cf_linker;
151
152

    ros::Publisher DBChangedPublisher;
153
    ros::Publisher emergencyStopPublisher;
154
    #endif
155
156
157
158
159

    void updateComboBoxesCFs();

    void updateComboBoxesCFZones();

160
161
    int getTabIndexFromName(QString name);

162
    CrazyflieDB m_data_base;
163
164
165
166
167
168
169
170
171
172
173

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

174
175
176
177
178
};



#endif // MAINGUIWINDOW_H