Commit b6e7ebba authored by roangel's avatar roangel
Browse files

Now checkbox is connected to show/hide markers

parent f5dd84b3
......@@ -93,12 +93,18 @@ private slots:
void on_pushButton_fitAll_clicked();
void on_checkBox_vicon_markers_toggled(bool checked);
void on_checkBox_vicon_highlight_markers_toggled(bool checked);
private:
Ui::MainGUIWindow *ui;
myGraphicsScene* scene;
void _init();
Marker* marker;
#ifdef CATKIN_MAKE
#endif
......
......@@ -15,6 +15,7 @@ class Marker : public QGraphicsEllipseItem
public:
explicit Marker(qreal x, qreal y, QGraphicsItem *parent = 0);
~Marker();
void setHighlighted(void);
......
......@@ -8,7 +8,6 @@
#include "crazyFlyZone.h"
#include "tablePiece.h"
#include "marker.h"
class QGraphicsSceneMouseEvent;
class QPointF;
......@@ -84,7 +83,6 @@ private:
QPointF* p1;
QPointF* p2;
Marker* marker;
bool startedRect;
int mode;
......
......@@ -219,3 +219,33 @@ void MainGUIWindow::on_pushButton_fitAll_clicked()
ui->graphicsView->fitInView(scene->itemsBoundingRect(), Qt::KeepAspectRatio);
ui->graphicsView->scale(0.95, 0.95); // A bit back zoom, so we can see everything better
}
void MainGUIWindow::on_checkBox_vicon_markers_toggled(bool checked)
{
// This is temporal, just to see effect. In the end the marker will be created with data from vicon
if(checked)
{
marker = new Marker(0, 0);
scene->addItem(marker);
ui->checkBox_vicon_highlight_markers->setCheckable(true);
}
else
{
marker->setParentItem(NULL);
delete marker;
ui->checkBox_vicon_highlight_markers->setChecked(false);
ui->checkBox_vicon_highlight_markers->setCheckable(false);
}
}
void MainGUIWindow::on_checkBox_vicon_highlight_markers_toggled(bool checked)
{
if(checked)
{
marker->setHighlighted();
}
else
{
marker->clearHighlighted();
}
}
......@@ -171,8 +171,8 @@
<rect>
<x>790</x>
<y>230</y>
<width>120</width>
<height>141</height>
<width>131</width>
<height>131</height>
</rect>
</property>
<property name="title">
......@@ -216,12 +216,15 @@
<property name="text">
<string>Show Markers</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_grid">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<y>80</y>
<width>101</width>
<height>20</height>
</rect>
......@@ -242,7 +245,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<y>100</y>
<width>101</width>
<height>20</height>
</rect>
......@@ -259,6 +262,27 @@
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_vicon_highlight_markers">
<property name="geometry">
<rect>
<x>30</x>
<y>60</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<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>
</widget>
<widget class="QPushButton" name="pushButton_fitAll">
<property name="geometry">
......
......@@ -19,25 +19,31 @@ Marker::Marker(qreal x, qreal y, QGraphicsItem * parent)
this->setPen(Qt::NoPen);
this->setBrush(QColor(255, 0, 0));
this->setZValue(10); // max z value, should always be seen
setHighlighted();
}
void Marker::setHighlighted(void)
{
prepareGeometryChange();
_highlight_circle = new QGraphicsEllipseItem();
_highlight_circle->setRect(QRectF(_x_highlight, _y_highlight, _highlight_diameter, _highlight_diameter));
_highlight_circle->setPen(QPen(QBrush(Qt::black), HIGHLIGHT_WIDTH));
_highlight_circle->setParentItem(this);
_highlight_circle->setFlag(QGraphicsItem::ItemIgnoresTransformations);
_highlighted = true;
if(!_highlighted)
{
prepareGeometryChange();
_highlight_circle = new QGraphicsEllipseItem();
_highlight_circle->setRect(QRectF(_x_highlight, _y_highlight, _highlight_diameter, _highlight_diameter));
_highlight_circle->setPen(QPen(QBrush(Qt::black), HIGHLIGHT_WIDTH));
_highlight_circle->setParentItem(this);
_highlight_circle->setFlag(QGraphicsItem::ItemIgnoresTransformations);
_highlighted = true;
}
}
void Marker::clearHighlighted(void)
{
prepareGeometryChange();
_highlighted = false;
if(_highlighted)
{
prepareGeometryChange();
_highlight_circle->setParentItem(NULL);
delete _highlight_circle;
_highlighted = false;
}
}
......@@ -46,5 +52,10 @@ bool Marker::getHighlighted(void)
return _highlighted;
}
Marker::~Marker()
{
clearHighlighted();
}
......@@ -15,9 +15,6 @@ myGraphicsScene::myGraphicsScene(QObject *parent)
tmp_rect = 0;
startedRect = false;
setGrid(true);
marker = new Marker(0, 0);
this->addItem(marker);
}
......
Markdown is supported
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