Commit bca51c27 authored by roangel's avatar roangel
Browse files

Added buttons in a different layout. Need now to wire check and uncheck buttons

parent 47b093f9
......@@ -56,17 +56,21 @@ void MainGUIWindow::_init()
{
scene = new myGraphicsScene(ui->frame_drawing);
//scene->setSceneRect(QRectF(QPointF(-100, 100), QSizeF(200, 200)));
scene->setSceneRect(QRectF(QPointF(-1400, 1400), QSizeF(1400, 1400)));
ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
ui->graphicsView->setScene(scene);
// ui->radioButton_crazyfly_zones_mode->setCheckable(false);
// ui->radioButton_crazyfly_zones_mode->setEnabled(false);
QObject::connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), scene, SLOT(removeCrazyFlyZone(int)));
QObject::connect(scene, SIGNAL(numCrazyFlyZonesChanged(int)), this, SLOT(set_tabs(int)));
QObject::connect(ui->tabWidget, SIGNAL(currentChanged(int)), scene, SLOT(setSelectedCrazyFlyZone(int)));
QObject::connect(scene, SIGNAL(crazyFlyZoneSelected(int)), ui->tabWidget, SLOT(setCurrentIndex(int)));
QObject::connect(scene, SIGNAL(modeChanged(int)), this, SLOT(transitionToMode(int)));
QObject::connect(scene, SIGNAL(numTablePiecesChanged(int)), this, SLOT(handleTablePiecesNumChanged(int)));
}
#ifndef DEBUG_GUI
......@@ -945,46 +949,80 @@ void CSetpointQueue::print()
#endif // DEBUG_GUI
void MainGUIWindow::on_drawingModeButton_clicked()
void MainGUIWindow::on_removeTable_clicked()
{
switch(scene->getMode())
if(scene->getMode() == myGraphicsScene::mode_table)
{
scene->removeTable();
}
}
void MainGUIWindow::transitionToMode(int mode)
{
switch(mode)
{
case myGraphicsScene::mode_table:
{
scene->setMode(myGraphicsScene::mode_crazyfly_zones);
ui->drawingModeButton->setText("CreateCFZonesMode");
ui->removeTable->setDisabled(false);
break;
}
case myGraphicsScene::mode_crazyfly_zones:
{
scene->setMode(myGraphicsScene::mode_table);
ui->drawingModeButton->setText("CreateTableMode");
ui->removeTable->setDisabled(true);
break;
}
}
}
void MainGUIWindow::on_removeTable_clicked()
void MainGUIWindow::on_radioButton_table_mode_toggled(bool checked)
{
if(scene->getMode() == myGraphicsScene::mode_table)
switch(scene->getMode())
{
scene->removeTable();
case myGraphicsScene::mode_table:
{
// already in the mode we want, do nothing
break;
}
case myGraphicsScene::mode_crazyfly_zones:
{
scene->setMode(myGraphicsScene::mode_table);
ui->radioButton_crazyfly_zones_mode->setChecked(false);
break;
}
}
}
void MainGUIWindow::transitionToMode(int mode)
void MainGUIWindow::on_radioButton_crazyfly_zones_mode_toggled(bool checked)
{
switch(mode)
switch(scene->getMode())
{
case myGraphicsScene::mode_table:
{
ui->removeTable->setDisabled(false);
scene->setMode(myGraphicsScene::mode_crazyfly_zones);
ui->radioButton_table_mode->setChecked(false);
break;
}
case myGraphicsScene::mode_crazyfly_zones:
{
ui->removeTable->setDisabled(true);
// already in the mode we want, do nothing
break;
}
}
}
void MainGUIWindow::handleTablePiecesNumChanged(int newNum)
{
// if(newNum == 0)
// {
// ui->radioButton_crazyfly_zones_mode->setCheckable(false);
// ui->radioButton_crazyfly_zones_mode->setEnabled(false);
// }
// else
// {
// ui->radioButton_crazyfly_zones_mode->setCheckable(true);
// ui->radioButton_crazyfly_zones_mode->setEnabled(true);
// }
}
......@@ -131,9 +131,13 @@ private slots:
void set_tabs(int n);
void transitionToMode(int mode);
void on_drawingModeButton_clicked();
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);
private:
Ui::MainGUIWindow *ui;
......
......@@ -19,7 +19,7 @@
<rect>
<x>40</x>
<y>510</y>
<width>1171</width>
<width>1431</width>
<height>451</height>
</rect>
</property>
......@@ -34,7 +34,7 @@
<rect>
<x>20</x>
<y>19</y>
<width>1131</width>
<width>1391</width>
<height>401</height>
</rect>
</property>
......@@ -53,9 +53,9 @@
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>641</width>
<height>469</height>
<y>18</y>
<width>951</width>
<height>471</height>
</rect>
</property>
<property name="frameShape">
......@@ -69,7 +69,7 @@
<rect>
<x>10</x>
<y>9</y>
<width>571</width>
<width>741</width>
<height>401</height>
</rect>
</property>
......@@ -77,39 +77,130 @@
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="drawingModeButton">
<widget class="QPushButton" name="removeTable">
<property name="geometry">
<rect>
<x>20</x>
<x>340</x>
<y>430</y>
<width>141</width>
<width>91</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>CreateTableMode</string>
<string>Remove Table</string>
</property>
</widget>
<widget class="QPushButton" name="removeTable">
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>200</x>
<y>430</y>
<width>91</width>
<height>21</height>
<x>790</x>
<y>30</y>
<width>121</width>
<height>80</height>
</rect>
</property>
<property name="text">
<string>Remove Table</string>
<property name="title">
<string>Creation Modes</string>
</property>
<widget class="QRadioButton" name="radioButton_table_mode">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>61</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Tables</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="radioButton_crazyfly_zones_mode">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>CrazyFly Zones</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>790</x>
<y>130</y>
<width>120</width>
<height>241</height>
</rect>
</property>
<property name="title">
<string>What to show</string>
</property>
<widget class="QCheckBox" name="checkBox_crazyfly_zones">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show CF Zones</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_vicon_markers">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show Markers</string>
</property>
</widget>
</widget>
</widget>
<widget class="QFrame" name="frame_3">
<property name="geometry">
<rect>
<x>669</x>
<y>21</y>
<width>541</width>
<x>990</x>
<y>20</y>
<width>481</width>
<height>469</height>
</rect>
</property>
......
......@@ -19,8 +19,8 @@
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_MainGUIWindow_t {
QByteArrayData data[8];
char stringdata0[100];
QByteArrayData data[12];
char stringdata0[191];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -35,13 +35,19 @@ QT_MOC_LITERAL(2, 23, 0), // ""
QT_MOC_LITERAL(3, 24, 1), // "n"
QT_MOC_LITERAL(4, 26, 16), // "transitionToMode"
QT_MOC_LITERAL(5, 43, 4), // "mode"
QT_MOC_LITERAL(6, 48, 28), // "on_drawingModeButton_clicked"
QT_MOC_LITERAL(7, 77, 22) // "on_removeTable_clicked"
QT_MOC_LITERAL(6, 48, 22), // "on_removeTable_clicked"
QT_MOC_LITERAL(7, 71, 33), // "on_radioButton_table_mode_tog..."
QT_MOC_LITERAL(8, 105, 7), // "checked"
QT_MOC_LITERAL(9, 113, 42), // "on_radioButton_crazyfly_zones..."
QT_MOC_LITERAL(10, 156, 27), // "handleTablePiecesNumChanged"
QT_MOC_LITERAL(11, 184, 6) // "newNum"
},
"MainGUIWindow\0set_tabs\0\0n\0transitionToMode\0"
"mode\0on_drawingModeButton_clicked\0"
"on_removeTable_clicked"
"mode\0on_removeTable_clicked\0"
"on_radioButton_table_mode_toggled\0"
"checked\0on_radioButton_crazyfly_zones_mode_toggled\0"
"handleTablePiecesNumChanged\0newNum"
};
#undef QT_MOC_LITERAL
......@@ -51,7 +57,7 @@ static const uint qt_meta_data_MainGUIWindow[] = {
7, // revision
0, // classname
0, 0, // classinfo
4, 14, // methods
6, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
......@@ -59,16 +65,20 @@ static const uint qt_meta_data_MainGUIWindow[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 1, 34, 2, 0x08 /* Private */,
4, 1, 37, 2, 0x08 /* Private */,
6, 0, 40, 2, 0x08 /* Private */,
7, 0, 41, 2, 0x08 /* Private */,
1, 1, 44, 2, 0x08 /* Private */,
4, 1, 47, 2, 0x08 /* Private */,
6, 0, 50, 2, 0x08 /* Private */,
7, 1, 51, 2, 0x08 /* Private */,
9, 1, 54, 2, 0x08 /* Private */,
10, 1, 57, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void, QMetaType::Int, 3,
QMetaType::Void, QMetaType::Int, 5,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void, QMetaType::Bool, 8,
QMetaType::Void, QMetaType::Bool, 8,
QMetaType::Void, QMetaType::Int, 11,
0 // eod
};
......@@ -81,8 +91,10 @@ void MainGUIWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _i
switch (_id) {
case 0: _t->set_tabs((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: _t->transitionToMode((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: _t->on_drawingModeButton_clicked(); break;
case 3: _t->on_removeTable_clicked(); break;
case 2: _t->on_removeTable_clicked(); break;
case 3: _t->on_radioButton_table_mode_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 4: _t->on_radioButton_crazyfly_zones_mode_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 5: _t->handleTablePiecesNumChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
}
......@@ -113,13 +125,13 @@ int MainGUIWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 4)
if (_id < 6)
qt_static_metacall(this, _c, _id, _a);
_id -= 4;
_id -= 6;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 4)
if (_id < 6)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 4;
_id -= 6;
}
return _id;
}
......
......@@ -19,8 +19,8 @@
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_myGraphicsScene_t {
QByteArrayData data[12];
char stringdata0[158];
QByteArrayData data[13];
char stringdata0[180];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
......@@ -37,17 +37,18 @@ QT_MOC_LITERAL(4, 48, 20), // "crazyFlyZoneSelected"
QT_MOC_LITERAL(5, 69, 5), // "index"
QT_MOC_LITERAL(6, 75, 11), // "modeChanged"
QT_MOC_LITERAL(7, 87, 4), // "mode"
QT_MOC_LITERAL(8, 92, 18), // "removeCrazyFlyZone"
QT_MOC_LITERAL(9, 111, 23), // "setSelectedCrazyFlyZone"
QT_MOC_LITERAL(10, 135, 12), // "changeModeTo"
QT_MOC_LITERAL(11, 148, 9) // "next_mode"
QT_MOC_LITERAL(8, 92, 21), // "numTablePiecesChanged"
QT_MOC_LITERAL(9, 114, 18), // "removeCrazyFlyZone"
QT_MOC_LITERAL(10, 133, 23), // "setSelectedCrazyFlyZone"
QT_MOC_LITERAL(11, 157, 12), // "changeModeTo"
QT_MOC_LITERAL(12, 170, 9) // "next_mode"
},
"myGraphicsScene\0numCrazyFlyZonesChanged\0"
"\0newNum\0crazyFlyZoneSelected\0index\0"
"modeChanged\0mode\0removeCrazyFlyZone\0"
"setSelectedCrazyFlyZone\0changeModeTo\0"
"next_mode"
"modeChanged\0mode\0numTablePiecesChanged\0"
"removeCrazyFlyZone\0setSelectedCrazyFlyZone\0"
"changeModeTo\0next_mode"
};
#undef QT_MOC_LITERAL
......@@ -57,32 +58,34 @@ static const uint qt_meta_data_myGraphicsScene[] = {
7, // revision
0, // classname
0, 0, // classinfo
6, 14, // methods
7, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
3, // signalCount
4, // signalCount
// signals: name, argc, parameters, tag, flags
1, 1, 44, 2, 0x06 /* Public */,
4, 1, 47, 2, 0x06 /* Public */,
6, 1, 50, 2, 0x06 /* Public */,
1, 1, 49, 2, 0x06 /* Public */,
4, 1, 52, 2, 0x06 /* Public */,
6, 1, 55, 2, 0x06 /* Public */,
8, 1, 58, 2, 0x06 /* Public */,
// slots: name, argc, parameters, tag, flags
8, 1, 53, 2, 0x0a /* Public */,
9, 1, 56, 2, 0x0a /* Public */,
10, 1, 59, 2, 0x0a /* Public */,
9, 1, 61, 2, 0x0a /* Public */,
10, 1, 64, 2, 0x0a /* Public */,
11, 1, 67, 2, 0x0a /* Public */,
// signals: parameters
QMetaType::Void, QMetaType::Int, 3,
QMetaType::Void, QMetaType::Int, 5,
QMetaType::Void, QMetaType::Int, 7,
QMetaType::Void, QMetaType::Int, 3,
// slots: parameters
QMetaType::Void, QMetaType::Int, 5,
QMetaType::Void, QMetaType::Int, 5,
QMetaType::Void, QMetaType::Int, 11,
QMetaType::Void, QMetaType::Int, 12,
0 // eod
};
......@@ -96,9 +99,10 @@ void myGraphicsScene::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
case 0: _t->numCrazyFlyZonesChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 1: _t->crazyFlyZoneSelected((*reinterpret_cast< int(*)>(_a[1]))); break;
case 2: _t->modeChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 3: _t->removeCrazyFlyZone((*reinterpret_cast< int(*)>(_a[1]))); break;
case 4: _t->setSelectedCrazyFlyZone((*reinterpret_cast< int(*)>(_a[1]))); break;
case 5: _t->changeModeTo((*reinterpret_cast< int(*)>(_a[1]))); break;
case 3: _t->numTablePiecesChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
case 4: _t->removeCrazyFlyZone((*reinterpret_cast< int(*)>(_a[1]))); break;
case 5: _t->setSelectedCrazyFlyZone((*reinterpret_cast< int(*)>(_a[1]))); break;
case 6: _t->changeModeTo((*reinterpret_cast< int(*)>(_a[1]))); break;
default: ;
}
} else if (_c == QMetaObject::IndexOfMethod) {
......@@ -125,6 +129,13 @@ void myGraphicsScene::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
return;
}
}
{
typedef void (myGraphicsScene::*_t)(int );
if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&myGraphicsScene::numTablePiecesChanged)) {
*result = 3;
return;
}
}
}
}
......@@ -153,13 +164,13 @@ int myGraphicsScene::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 6)
if (_id < 7)
qt_static_metacall(this, _c, _id, _a);
_id -= 6;
_id -= 7;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 6)
if (_id < 7)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 6;
_id -= 7;
}
return _id;
}
......@@ -184,4 +195,11 @@ void myGraphicsScene::modeChanged(int _t1)
void *_a[] = { Q_NULLPTR, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 2, _a);
}
// SIGNAL 3
void myGraphicsScene::numTablePiecesChanged(int _t1)
{
void *_a[] = { Q_NULLPTR, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 3, _a);
}
QT_END_MOC_NAMESPACE
......@@ -152,6 +152,7 @@ void myGraphicsScene::addCrazyFlyZoneToVector(crazyFlyZone* rect)
void myGraphicsScene::addTablePieceToVector(tablePiece* rect)
{
table_pieces.push_back(rect);
emit numTablePiecesChanged(table_pieces.size());
}
void myGraphicsScene::updateIndexesAndLabelsCrazyFlyZones()
......@@ -247,6 +248,7 @@ void myGraphicsScene::removeTable()
this->removeItem(table_pieces[i]);
}
table_pieces.clear();
emit numTablePiecesChanged(table_pieces.size());
}
void myGraphicsScene::removeTablePiece(int index)
......@@ -254,6 +256,7 @@ void myGraphicsScene::removeTablePiece(int index)
this->removeItem(table_pieces[index]);
table_pieces.erase(table_pieces.begin() + index);
qDebug("removed TabledPiece %d", index);
emit numTablePiecesChanged(table_pieces.size());
}
void myGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
......
......@@ -38,6 +38,7 @@ signals:
void numCrazyFlyZonesChanged(int newNum);
void crazyFlyZoneSelected(int index);