Commit 4e08c9c9 authored by roangel's avatar roangel
Browse files

marked center of cf zone. Now we need to change the icon for a svg picture that looks better

parent 2be3fb07
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 744.09448819 1052.3622047"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="center_rect.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="299.90787"
inkscape:cy="691.68435"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<circle
style="fill:#000000;fill-opacity:1"
id="path4136"
cx="346.48233"
cy="324.04221"
r="47.477169" />
</g>
</svg>
...@@ -24,16 +24,20 @@ public: ...@@ -24,16 +24,20 @@ public:
bool isLinked(); bool isLinked();
void removeLink(); void removeLink();
void updateCenterMarker();
protected: protected:
private: private:
int _index; int _index;
QGraphicsSimpleTextItem* label; QGraphicsSimpleTextItem* label;
QGraphicsEllipseItem* m_center_marker;
// stuff for linking // stuff for linking
bool m_linked; bool m_linked;
std::string m_crazyfly_linked_name; //in the future this will be a vector of crazyFlies maybe std::string m_crazyfly_linked_name; //in the future this will be a vector of crazyFlies maybe
};
void createCenterMarker();
};
#endif #endif
...@@ -16,6 +16,7 @@ public: ...@@ -16,6 +16,7 @@ public:
void lock(); void lock();
void unlock(); void unlock();
public slots: public slots:
signals: signals:
...@@ -27,6 +28,7 @@ protected: ...@@ -27,6 +28,7 @@ protected:
virtual void rectSizeChanged() = 0; // pure virtual function, has to be overridden in derived class virtual void rectSizeChanged() = 0; // pure virtual function, has to be overridden in derived class
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
private: private:
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
crazyFlyZone::crazyFlyZone(const QRectF & rect, int index, QGraphicsItem * parent) crazyFlyZone::crazyFlyZone(const QRectF & rect, int index, QGraphicsItem * parent)
: myGraphicsRectItem(rect, parent) : myGraphicsRectItem(rect, parent)
{ {
createCenterMarker();
this->setPen(QPen(Qt::black, 0)); this->setPen(QPen(Qt::black, 0));
setIndex(index); setIndex(index);
m_linked = false; m_linked = false;
...@@ -19,6 +20,21 @@ void crazyFlyZone::updateLabel(QString string) ...@@ -19,6 +20,21 @@ void crazyFlyZone::updateLabel(QString string)
setLabelPosition(); setLabelPosition();
} }
void crazyFlyZone::createCenterMarker()
{
qreal diameter = 0.1 * FROM_METERS_TO_UNITS;
m_center_marker = new QGraphicsEllipseItem(QRectF(-diameter/2, -diameter/2, diameter, diameter), this);
updateCenterMarker();
m_center_marker->setZValue(10); //max z value, always on top of things
}
void crazyFlyZone::updateCenterMarker()
{
qreal x_offset = this->rect().width()/2;
qreal y_offset = this->rect().height()/2;
m_center_marker->setPos(this->rect().topLeft().x() + x_offset,this->rect().topLeft().y() + y_offset);
}
void crazyFlyZone::setLabel(QString string) void crazyFlyZone::setLabel(QString string)
{ {
label = new QGraphicsSimpleTextItem(string, this); label = new QGraphicsSimpleTextItem(string, this);
...@@ -49,6 +65,7 @@ void crazyFlyZone::setIndex(int index) ...@@ -49,6 +65,7 @@ void crazyFlyZone::setIndex(int index)
void crazyFlyZone::rectSizeChanged() // pure virtual coming from parent void crazyFlyZone::rectSizeChanged() // pure virtual coming from parent
{ {
setLabelPosition(); setLabelPosition();
updateCenterMarker();
} }
void crazyFlyZone::linkCF(std::string cf_name) void crazyFlyZone::linkCF(std::string cf_name)
......
...@@ -194,6 +194,7 @@ void myGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) ...@@ -194,6 +194,7 @@ void myGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
case mode_crazyfly_zones: case mode_crazyfly_zones:
{ {
tmp_crazyfly_zone_item->setRect(QRectF(*p1, mouseEvent->scenePos())); tmp_crazyfly_zone_item->setRect(QRectF(*p1, mouseEvent->scenePos()));
tmp_crazyfly_zone_item->updateCenterMarker();
qDebug("Mouse Position: %d, %d", (mouseEvent->scenePos()).toPoint().x(), (mouseEvent->scenePos()).toPoint().y()); qDebug("Mouse Position: %d, %d", (mouseEvent->scenePos()).toPoint().x(), (mouseEvent->scenePos()).toPoint().y());
qDebug("Rectangle BottomRight Position: %d, %d", tmp_crazyfly_zone_item->rect().bottomRight().x(), tmp_crazyfly_zone_item->rect().bottomRight().y()); qDebug("Rectangle BottomRight Position: %d, %d", tmp_crazyfly_zone_item->rect().bottomRight().x(), tmp_crazyfly_zone_item->rect().bottomRight().y());
break; break;
......
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