Commit 6b3469bd authored by roangel's avatar roangel
Browse files

now we refresh ComboBoxes whenever we unlink

parent fd0e4e61
......@@ -57,6 +57,7 @@ set(SRC_HDRS_QOBJECT
${MY_LIB_PATH_INC}/myGraphicsView.h
${MY_LIB_PATH_INC}/mainguiwindow.h
${MY_LIB_PATH_INC}/rosNodeThread.h
${MY_LIB_PATH_INC}/CFLinker.h
)
# GUI -- wrap UI file and QOBJECT files
qt5_wrap_ui(UIS_HDRS GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui)
......
......@@ -8,9 +8,12 @@
#include "rosNodeThread.h"
#include <QObject>
class CFLinker
class CFLinker : public QObject
{
Q_OBJECT
public:
struct link {
......@@ -31,6 +34,9 @@ public:
bool isCFZoneLinked(int cf_zone_index);
bool isCFLinked(std::string cf_name);
signals:
void updateComboBoxes();
private:
// QTableWidget m_p_table;
......
......@@ -113,6 +113,8 @@ private slots:
void on_unlink_button_clicked();
void updateComboBoxes();
private:
Ui::MainGUIWindow *ui;
......@@ -126,6 +128,11 @@ private:
std::vector<crazyFly*> crazyflies_vector;
CFLinker* cf_linker;
#endif
void updateComboBoxesCFs();
void updateComboBoxesCFZones();
};
......
......@@ -3,6 +3,7 @@
#include <QHeaderView>
CFLinker::CFLinker(Ui::MainGUIWindow* ui, std::vector<crazyFly*> *crazyflies_vector, std::vector<crazyFlyZone*> *crazyfly_zones)
: QObject(0)
{
m_ui = ui;
m_crazyflies_vector = crazyflies_vector;
......@@ -157,4 +158,7 @@ void CFLinker::unlink()
// remove them graphically
m_ui->table_links->removeRow(ordered_row_indexes[i]);
}
// update combo boxes
emit updateComboBoxes();
}
......@@ -41,6 +41,7 @@ MainGUIWindow::~MainGUIWindow()
delete ui;
}
void MainGUIWindow::doNumCrazyFlyZonesChanged(int n)
{
// tabs number management, maybe do it in a different way so we dont have to remove and add everything?
......@@ -54,37 +55,7 @@ void MainGUIWindow::doNumCrazyFlyZonesChanged(int n)
connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
}
ui->comboBoxCFZones->clear();
#ifdef CATKIN_MAKE
for(int i = 0; i < scene->crazyfly_zones.size(); i++)
{
if(!cf_linker->isCFZoneLinked(scene->crazyfly_zones[i]->getIndex()))
{
QString qstr = "CrazyFlyZone ";
qstr.append(QString::number(i+1));
ui->comboBoxCFZones->addItem(qstr);
}
}
#endif
// add options to QComboBox of CFZones
// int current_count = ui->comboBoxCFZones->count();
// if(n > current_count)
// {
// for(int i = current_count; i < n; i++)
// {
// QString qstr = "CrazyFlyZone ";
// qstr.append(QString::number(i+1));
// ui->comboBoxCFZones->addItem(qstr);
// }
// }
// else if(n < current_count)
// {
// for(int i = current_count; i >= n; i--)
// {
// ui->comboBoxCFZones->removeItem(i);
// }
// }
updateComboBoxesCFZones();
}
void MainGUIWindow::_init()
......@@ -164,9 +135,47 @@ void MainGUIWindow::_init()
_rosNodeThread->init();
qRegisterMetaType<ptrToMessage>("ptrToMessage");
QObject::connect(_rosNodeThread, SIGNAL(newViconData(const ptrToMessage&)), this, SLOT(updateNewViconData(const ptrToMessage&)));
QObject::connect(cf_linker, SIGNAL(updateComboBoxes()), this, SLOT(updateComboBoxes()));
#endif
}
void MainGUIWindow::updateComboBoxes()
{
updateComboBoxesCFs();
updateComboBoxesCFZones();
}
void MainGUIWindow::updateComboBoxesCFs()
{
#ifdef CATKIN_MAKE
ui->comboBoxCFs->clear();
for(int i = 0; i < crazyflies_vector.size(); i++)
{
if(!cf_linker->isCFLinked(crazyflies_vector[i]->getName()))
{
QString qstr = QString::fromStdString(crazyflies_vector[i]->getName());
ui->comboBoxCFs->addItem(qstr);
}
}
#endif
}
void MainGUIWindow::updateComboBoxesCFZones()
{
ui->comboBoxCFZones->clear();
#ifdef CATKIN_MAKE
for(int i = 0; i < scene->crazyfly_zones.size(); i++)
{
if(!cf_linker->isCFZoneLinked(scene->crazyfly_zones[i]->getIndex()))
{
QString qstr = "CrazyFlyZone ";
qstr.append(QString::number(i+1));
ui->comboBoxCFZones->addItem(qstr);
}
}
#endif
}
#ifdef CATKIN_MAKE
void MainGUIWindow::updateNewViconData(const ptrToMessage& p_msg) //connected to newViconData, from node
{
......@@ -524,17 +533,7 @@ void MainGUIWindow::on_scaleSpinBox_valueChanged(double arg1)
void MainGUIWindow::on_refresh_cfs_button_clicked()
{
#ifdef CATKIN_MAKE
ui->comboBoxCFs->clear();
for(int i = 0; i < crazyflies_vector.size(); i++)
{
if(!cf_linker->isCFLinked(crazyflies_vector[i]->getName()))
{
QString qstr = QString::fromStdString(crazyflies_vector[i]->getName());
ui->comboBoxCFs->addItem(qstr);
}
}
#endif
updateComboBoxesCFs();
}
void MainGUIWindow::on_refresh_student_ids_button_clicked()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment