Commit b05f63e7 authored by roangel's avatar roangel
Browse files

Added table. Need to take care of everything else, like unlink, impossible to...

Added table. Need to take care of everything else, like unlink, impossible to add same student id twice, remove added elements from choices....
parent 87663399
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.2, 2017-05-18T17:53:08. -->
<!-- Written by QtCreator 4.0.2, 2017-05-23T19:29:03. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
......@@ -4,13 +4,15 @@
#include "globalDefinitions.h"
#include "crazyFly.h"
#include "crazyFlyZone.h"
#include "ui_mainguiwindow.h"
#include "rosNodeThread.h"
#include <QTableWidget>
class CFLinker
{
public:
explicit CFLinker(QTableWidget* p_table);
explicit CFLinker(Ui::MainGUIWindow* ui);
~CFLinker();
void link(int student_id, crazyFly* crazyfly, crazyFlyZone* crazyfly_zone);
......@@ -26,8 +28,9 @@ private:
std::vector<struct link> links;
// table
QTableWidget* m_p_table;
// QTableWidget m_p_table;
Ui::MainGUIWindow* m_ui;
};
......
......@@ -109,6 +109,8 @@ private slots:
void on_refresh_student_ids_button_clicked();
void on_link_button_clicked();
private:
Ui::MainGUIWindow *ui;
......@@ -120,7 +122,7 @@ private:
rosNodeThread* _rosNodeThread;
std::vector<Marker*> markers_vector;
std::vector<crazyFly*> crazyflies_vector;
CFLinker cf_linker;
CFLinker* cf_linker;
#endif
};
......
#include "CFLinker.h"
CFLinker::CFLinker(QTableWidget* p_table)
CFLinker::CFLinker(Ui::MainGUIWindow* ui)
{
m_p_table = p_table;
m_ui = ui;
}
CFLinker::~CFLinker()
......@@ -20,13 +20,16 @@ void CFLinker::link(int student_id, crazyFly* crazyfly, crazyFlyZone* crazyfly_z
crazyfly_zone->linkCF(tmp_link.cf_name);
crazyfly->assignCFZone(tmp_link.cf_zone_index);
m_p_table->insertRow(m_p_table->rowCount());
ROS_INFO("tmp_link.cf_name = %s", tmp_link.cf_name.c_str());
int row_count = m_ui->table_links->rowCount();
ROS_INFO("row_count %d", row_count);
m_ui->table_links->insertRow(row_count);
QString str_id = QString::number(student_id);
m_p_table->insertItem(m_p_table->rowCount() - 1, 0, new QTableWidgetItem(str_id));
m_ui->table_links->setItem(m_ui->table_links->rowCount() - 1, 0, new QTableWidgetItem(str_id));
QString str_cf_name = QString::fromStdString(crazyfly->getName());
m_p_table->insertItem(m_p_table->rowCount() - 1, 1, new QTableWidgetItem(str_cf_name));
QString str_cf_zone_index = QString::number(crazyfly_zone->getIndex());
m_p_table->insertItem(m_p_table->rowCount() - 1, 2, new QTableWidgetItem(str_cf_zone_index));
m_ui->table_links->setItem(m_ui->table_links->rowCount() - 1, 1, new QTableWidgetItem(str_cf_name));
QString str_cf_zone_index = QString("CrazyFlyZone ").append(QString::number(crazyfly_zone->getIndex() + 1));
m_ui->table_links->setItem(m_ui->table_links->rowCount() - 1, 2, new QTableWidgetItem(str_cf_zone_index));
links.push_back(tmp_link);
}
......
......@@ -27,12 +27,10 @@ using namespace d_fall_pps;
MainGUIWindow::MainGUIWindow(int argc, char **argv, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainGUIWindow)
#ifdef CATKIN_MAKE
,cf_linker(ui->table_links)
#endif
{
#ifdef CATKIN_MAKE
_rosNodeThread = new rosNodeThread(argc, argv, "/ViconDataPublisher/ViconData");
cf_linker = new CFLinker(ui);
#endif
ui->setupUi(this);
_init();
......@@ -94,7 +92,6 @@ void MainGUIWindow::_init()
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// initialize table_links
ui->table_links->setColumnCount(3);
QStringList horizontal_header;
horizontal_header << "Student ID" << "CrazyFly" << "CrazyFly Zone";
......@@ -104,7 +101,7 @@ void MainGUIWindow::_init()
ui->table_links->horizontalHeader()->setFont(fnt);
ui->table_links->horizontalHeader()->setDefaultSectionSize(90);
ui->table_links->verticalHeader()->setDefaultSectionSize(90);
ui->table_links->verticalHeader()->setDefaultSectionSize(20);
const int rowCount = ui->table_links->rowCount();
const int columnCount = ui->table_links->columnCount();
......@@ -117,7 +114,6 @@ void MainGUIWindow::_init()
}
}
// scene
scene = new myGraphicsScene(ui->frame_drawing);
scene->setSceneRect(-100 * FROM_METERS_TO_UNITS, -100 * FROM_METERS_TO_UNITS, 200 * FROM_METERS_TO_UNITS, 200 * FROM_METERS_TO_UNITS);
......@@ -543,3 +539,27 @@ void MainGUIWindow::on_refresh_student_ids_button_clicked()
}
#endif
}
void MainGUIWindow::on_link_button_clicked()
{
#ifdef CATKIN_MAKE
QString cfzone_str = ui->comboBoxCFZones->currentText();
crazyFly* p_tmp_cf;
for(int i = 0; i < crazyflies_vector.size(); i++)
{
if(ui->comboBoxCFs->currentText().toStdString() == crazyflies_vector[i]->getName())
{
ROS_INFO("crazyfly to link found!--------------------------");
p_tmp_cf = crazyflies_vector[i];
}
}
int cf_zone_index = cfzone_str.split(" ")[1].toInt() - 1;
crazyFlyZone* p_tmp_cf_zone = scene->crazyfly_zones[cf_zone_index];
ROS_INFO("cf_zone_index: %d", cf_zone_index);
cf_linker->link(ui->spinBox_student_ids->value(), p_tmp_cf, p_tmp_cf_zone);
#endif
}
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