Skip to content
Snippets Groups Projects
Commit 4e08c9c9 authored by Angel's avatar Angel
Browse files

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

parent 2be3fb07
No related branches found
No related tags found
No related merge requests found
<?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:
bool isLinked();
void removeLink();
void updateCenterMarker();
protected:
private:
int _index;
QGraphicsSimpleTextItem* label;
QGraphicsEllipseItem* m_center_marker;
// stuff for linking
bool m_linked;
std::string m_crazyfly_linked_name; //in the future this will be a vector of crazyFlies maybe
};
void createCenterMarker();
};
#endif
......@@ -16,6 +16,7 @@ public:
void lock();
void unlock();
public slots:
signals:
......@@ -27,6 +28,7 @@ protected:
virtual void rectSizeChanged() = 0; // pure virtual function, has to be overridden in derived class
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
private:
......
......@@ -4,6 +4,7 @@
crazyFlyZone::crazyFlyZone(const QRectF & rect, int index, QGraphicsItem * parent)
: myGraphicsRectItem(rect, parent)
{
createCenterMarker();
this->setPen(QPen(Qt::black, 0));
setIndex(index);
m_linked = false;
......@@ -19,6 +20,21 @@ void crazyFlyZone::updateLabel(QString string)
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)
{
label = new QGraphicsSimpleTextItem(string, this);
......@@ -49,6 +65,7 @@ void crazyFlyZone::setIndex(int index)
void crazyFlyZone::rectSizeChanged() // pure virtual coming from parent
{
setLabelPosition();
updateCenterMarker();
}
void crazyFlyZone::linkCF(std::string cf_name)
......
......@@ -194,6 +194,7 @@ void myGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
case mode_crazyfly_zones:
{
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("Rectangle BottomRight Position: %d, %d", tmp_crazyfly_zone_item->rect().bottomRight().x(), tmp_crazyfly_zone_item->rect().bottomRight().y());
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment