Commit 8cc10520 authored by roangel's avatar roangel
Browse files

Merge branch 'add_checkbox_and_scale_box_CF' into pps_project

parents 970f9262 f1507545
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.2, 2017-05-12T16:06:37. -->
<!-- Written by QtCreator 4.0.2, 2017-05-18T12:14:24. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
......
......@@ -32,6 +32,8 @@ public:
std::string getName();
void setScaleCFs(double scale);
private:
// info to fill by message
......
......@@ -100,6 +100,10 @@ private slots:
#ifdef CATKIN_MAKE
void updateNewViconData(const ptrToMessage& p_msg);
#endif
void on_checkBox_vicon_crazyflies_toggled(bool checked);
void on_scaleSpinBox_valueChanged(double arg1);
private:
Ui::MainGUIWindow *ui;
......
......@@ -16,6 +16,11 @@ crazyFly::~crazyFly()
{
}
void crazyFly::setScaleCFs(double scale)
{
this->setScale(scale);
}
std::string crazyFly::getName()
{
return m_name;
......@@ -32,7 +37,7 @@ void crazyFly::updateCF(const CrazyflieData* p_crazyfly_msg)
m_yaw = p_crazyfly_msg->yaw;
m_pitch = p_crazyfly_msg->pitch;
m_roll = p_crazyfly_msg->roll;
this->setPos(m_x * FROM_MILIMETERS_TO_UNITS, -m_y * FROM_MILIMETERS_TO_UNITS); // - y because of coordinates
this->setPos(m_x * FROM_METERS_TO_UNITS, -m_y * FROM_METERS_TO_UNITS); // - y because of coordinates
this->setRotation(- m_yaw * FROM_RADIANS_TO_DEGREES); //negative beacause anti-clock wise should be positive
}
......
......@@ -66,8 +66,18 @@ void MainGUIWindow::set_tabs(int n)
void MainGUIWindow::_init()
{
// initialize checkboxes, spinboxes,....
ui->scaleSpinBox->setRange(0.1, 100);
ui->scaleSpinBox->setSingleStep(0.1);
ui->scaleSpinBox->setValue(1);
ui->checkBox_vicon_crazyflies->setChecked(false);
ui->scaleSpinBox->setEnabled(false);
ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
ui->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui->graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
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);
......@@ -113,7 +123,6 @@ void MainGUIWindow::updateNewViconData(const ptrToMessage& p_msg) //connected to
if(i >= markers_vector.size()) //some new markers coming
{
ROS_INFO_STREAM("element index: " << i << " added");
QPointF p(p_msg->markers[i].x * FROM_MILIMETERS_TO_UNITS, p_msg->markers[i].y * FROM_MILIMETERS_TO_UNITS);
Marker* tmp_p_marker = new Marker(&(p_msg->markers[i]));
markers_vector.push_back(tmp_p_marker); // what happens with the new indexes? check if this is correct
......@@ -157,7 +166,10 @@ void MainGUIWindow::updateNewViconData(const ptrToMessage& p_msg) //connected to
else
{
crazyFly* tmp_p_crazyfly = new crazyFly(&(p_msg->crazyflies[i]));
scene->addItem(tmp_p_crazyfly);
if(ui->checkBox_vicon_crazyflies->checkState() == Qt::Checked)
{
scene->addItem(tmp_p_crazyfly);
}
crazyflies_vector.push_back(tmp_p_crazyfly);
}
}
......@@ -334,45 +346,83 @@ void MainGUIWindow::on_pushButton_fitAll_clicked()
void MainGUIWindow::on_checkBox_vicon_markers_toggled(bool checked)
{
#ifdef CATKIN_MAKE
if(checked)
{
#ifdef CATKIN_MAKE
for(int i = 0; i < markers_vector.size(); i++)
{
scene->addItem(markers_vector[i]);
}
#endif
ui->checkBox_vicon_highlight_markers->setCheckable(true);
ui->checkBox_vicon_highlight_markers->setEnabled(true);
}
else
{
#ifdef CATKIN_MAKE
for(int i = 0; i < markers_vector.size(); i++)
{
scene->removeItem(markers_vector[i]);
}
#endif
ui->checkBox_vicon_highlight_markers->setChecked(false);
ui->checkBox_vicon_highlight_markers->setCheckable(false);
ui->checkBox_vicon_highlight_markers->setEnabled(false);
}
#endif
}
void MainGUIWindow::on_checkBox_vicon_highlight_markers_toggled(bool checked)
{
#ifdef CATKIN_MAKE
if(checked)
{
#ifdef CATKIN_MAKE
for(int i = 0; i < markers_vector.size(); i++)
{
markers_vector[i]->setHighlighted();
}
#endif
}
else
{
#ifdef CATKIN_MAKE
for(int i = 0; i < markers_vector.size(); i++)
{
markers_vector[i]->clearHighlighted();
}
#endif
}
}
void MainGUIWindow::on_checkBox_vicon_crazyflies_toggled(bool checked)
{
if(checked)
{
#ifdef CATKIN_MAKE
for(int i = 0; i < crazyflies_vector.size(); i++)
{
scene->addItem(crazyflies_vector[i]);
}
#endif
ui->scaleSpinBox->setEnabled(true);
}
else
{
#ifdef CATKIN_MAKE
for(int i = 0; i < crazyflies_vector.size(); i++)
{
scene->removeItem(crazyflies_vector[i]);
}
#endif
ui->scaleSpinBox->setEnabled(false);
}
}
void MainGUIWindow::on_scaleSpinBox_valueChanged(double arg1)
{
#ifdef CATKIN_MAKE
for(int i = 0; i < crazyflies_vector.size(); i++)
{
crazyflies_vector[i]->setScaleCFs(arg1);
}
#endif
}
......@@ -6,321 +6,302 @@
<rect>
<x>0</x>
<y>0</y>
<width>1479</width>
<height>1029</height>
<width>1043</width>
<height>658</height>
</rect>
</property>
<property name="windowTitle">
<string>MainGUIWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>40</x>
<y>510</y>
<width>1431</width>
<height>451</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>19</y>
<width>1391</width>
<height>401</height>
</rect>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame_drawing">
<property name="geometry">
<rect>
<x>20</x>
<y>18</y>
<width>951</width>
<height>471</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="myGraphicsView" name="graphicsView">
<property name="geometry">
<rect>
<x>10</x>
<y>9</y>
<width>741</width>
<height>401</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="removeTable">
<property name="geometry">
<rect>
<x>340</x>
<y>430</y>
<width>91</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Remove Table</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>790</x>
<y>30</y>
<width>121</width>
<height>121</height>
</rect>
</property>
<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 class="QRadioButton" name="radioButton_lock_mode">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Lock</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>230</y>
<width>131</width>
<height>131</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>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QFrame" name="frame_drawing">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_fitAll">
<property name="text">
<string>Fit All</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="removeTable">
<property name="text">
<string>Remove Table</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Creation Modes</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radioButton_table_mode">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Tables</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_crazyfly_zones_mode">
<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>
</item>
<item>
<widget class="QRadioButton" name="radioButton_lock_mode">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Lock</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="myGraphicsView" name="graphicsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>What to show</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_grid">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show Grid</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_table">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show Table</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBox_vicon_crazyflies">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show CFs</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_crazyfly_zones">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show CF Zones</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_vicon_markers">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Show Markers</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QDoubleSpinBox" name="scaleSpinBox">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>7</pointsize>
</font>
</property>
<property name="text">
<string>Scale:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="checkBox_vicon_highlight_markers">
<property name="font">
<font>
<pointsize>6</pointsize>
</font>
</property>
<property name="text">
<string>Highlight Markers</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>graphicsView</zorder>
<zorder>removeTable</zorder>
<zorder>groupBox</zorder>
<zorder>groupBox_2</zorder>
<zorder>pushButton_fitAll</zorder>