From 95b4d3bb086d0d4c3bf6f05581f78e7a47fc621b Mon Sep 17 00:00:00 2001 From: Angel <roangel@student.ethz.ch> Date: Wed, 27 Sep 2017 14:52:47 +0200 Subject: [PATCH] now figure center comes from svg. Need to beautify it with inkscape --- pps_ws/src/d_fall_pps/CMakeLists.txt | 1 + .../GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc | 1 + .../GUI_Qt/CrazyFlyGUI/images/center_rect.svg | 25 ++++++++++------- .../GUI_Qt/CrazyFlyGUI/include/centerMarker.h | 27 +++++++++++++++++++ .../GUI_Qt/CrazyFlyGUI/include/crazyFly.h | 1 - .../GUI_Qt/CrazyFlyGUI/include/crazyFlyZone.h | 4 +-- .../GUI_Qt/CrazyFlyGUI/src/centerMarker.cpp | 25 +++++++++++++++++ .../GUI_Qt/CrazyFlyGUI/src/crazyFlyZone.cpp | 3 ++- pps_ws/src/d_fall_pps/param/Crazyflie.db | 2 +- 9 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/centerMarker.h create mode 100644 pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/centerMarker.cpp diff --git a/pps_ws/src/d_fall_pps/CMakeLists.txt b/pps_ws/src/d_fall_pps/CMakeLists.txt index 58a69ae5..e57ee183 100755 --- a/pps_ws/src/d_fall_pps/CMakeLists.txt +++ b/pps_ws/src/d_fall_pps/CMakeLists.txt @@ -260,6 +260,7 @@ set(MY_CPP_SOURCES_GUI # compilation of sources ${MY_GUI_LIB_PATH_SRC}/crazyFly.cpp ${MY_GUI_LIB_PATH_SRC}/CFLinker.cpp ${MY_GUI_LIB_PATH_SRC}/channelLUT.cpp + ${MY_GUI_LIB_PATH_SRC}/centerMarker.cpp ) # StudentGUI -- Add sources here diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc index ff5d1cbb..55f60357 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.qrc @@ -12,5 +12,6 @@ <file>images/drone_fixed_07.svg</file> <file>images/drone_fixed_08.svg</file> <file>images/drone_fixed_09.svg</file> + <file>images/center_rect.svg</file> </qresource> </RCC> diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/images/center_rect.svg b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/images/center_rect.svg index 53d15a13..0c9eb7a8 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/images/center_rect.svg +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/images/center_rect.svg @@ -9,9 +9,9 @@ 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" + width="151.66655mm" + height="151.66655mm" + viewBox="0 0 537.40116 537.40116" id="svg2" version="1.1" inkscape:version="0.91 r13725" @@ -26,8 +26,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.98994949" - inkscape:cx="299.90787" - inkscape:cy="691.68435" + inkscape:cx="149.39514" + inkscape:cy="309.84671" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -35,7 +35,11 @@ inkscape:window-height="1056" inkscape:window-x="65" inkscape:window-y="24" - inkscape:window-maximized="1" /> + inkscape:window-maximized="1" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" /> <metadata id="metadata7"> <rdf:RDF> @@ -51,12 +55,13 @@ <g inkscape:label="Layer 1" inkscape:groupmode="layer" - id="layer1"> + id="layer1" + transform="translate(0,-133.12338)"> <circle style="fill:#000000;fill-opacity:1" id="path4136" - cx="346.48233" - cy="324.04221" - r="47.477169" /> + cx="268.70059" + cy="401.82397" + r="268.70059" /> </g> </svg> diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/centerMarker.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/centerMarker.h new file mode 100644 index 00000000..32f513f7 --- /dev/null +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/centerMarker.h @@ -0,0 +1,27 @@ +#ifndef CENTER_MARKER_H +#define CENTER_MARKER_H + +#include "globalDefinitions.h" + +#include <QGraphicsSvgItem> +#include <QSvgRenderer> + +#define DIAMETER 100 * FROM_MILIMETERS_TO_UNITS + +class centerMarker : public QGraphicsSvgItem +{ +public: + explicit centerMarker(QString filename, QGraphicsItem * parent = 0); + ~centerMarker(); + QRectF boundingRect() const; + + void paint(QPainter * painter, + const QStyleOptionGraphicsItem * option, + QWidget * widget); + +private: + qreal m_diameter; +}; + + +#endif diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFly.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFly.h index 6671a1f3..d1ac3d4f 100644 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFly.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFly.h @@ -68,5 +68,4 @@ private: int m_assigned_cf_zone_index; }; - #endif diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFlyZone.h b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFlyZone.h index 0d5c433f..0ae5dbc9 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFlyZone.h +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/include/crazyFlyZone.h @@ -3,8 +3,8 @@ #include <QGraphicsSimpleTextItem> - #include "myGraphicsRectItem.h" +#include "centerMarker.h" class crazyFlyZone : public myGraphicsRectItem { @@ -31,7 +31,7 @@ protected: private: int _index; QGraphicsSimpleTextItem* label; - QGraphicsEllipseItem* m_center_marker; + centerMarker* m_center_marker; // stuff for linking bool m_linked; diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/centerMarker.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/centerMarker.cpp new file mode 100644 index 00000000..4f412d2a --- /dev/null +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/centerMarker.cpp @@ -0,0 +1,25 @@ +#include "centerMarker.h" + +#include <QPen> +#include <QBrush> + + +centerMarker::centerMarker(QString filename, QGraphicsItem * parent) + : QGraphicsSvgItem(filename, parent) +{ + m_diameter = DIAMETER; +} + +centerMarker::~centerMarker() +{ +} + +QRectF centerMarker::boundingRect() const +{ + return QRectF(-m_diameter/2, -m_diameter/2, m_diameter, m_diameter); +} + +void centerMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + this->renderer()->render(painter,this->boundingRect()); +} diff --git a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/crazyFlyZone.cpp b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/crazyFlyZone.cpp index 49d0e43b..3b68c898 100755 --- a/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/crazyFlyZone.cpp +++ b/pps_ws/src/d_fall_pps/GUI_Qt/CrazyFlyGUI/src/crazyFlyZone.cpp @@ -23,7 +23,8 @@ void crazyFlyZone::updateLabel(QString string) void crazyFlyZone::createCenterMarker() { qreal diameter = 0.1 * FROM_METERS_TO_UNITS; - m_center_marker = new QGraphicsEllipseItem(QRectF(-diameter/2, -diameter/2, diameter, diameter), this); + // m_center_marker = new QGraphicsEllipseItem(QRectF(-diameter/2, -diameter/2, diameter, diameter), this); + m_center_marker = new centerMarker(":/images/center_rect.svg", this); updateCenterMarker(); m_center_marker->setZValue(10); //max z value, always on top of things } diff --git a/pps_ws/src/d_fall_pps/param/Crazyflie.db b/pps_ws/src/d_fall_pps/param/Crazyflie.db index 92f7e458..5fdd872a 100644 --- a/pps_ws/src/d_fall_pps/param/Crazyflie.db +++ b/pps_ws/src/d_fall_pps/param/Crazyflie.db @@ -1 +1 @@ -5,cfTwo,0/69/2M,0,-0.251699,-1.96387,-0.2,0.0792386,-1.54593,2 +5,PPS_CF04,0/24/2M,0,-0.885221,-0.268794,-0.2,0.379322,0.827822,2 -- GitLab