mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Ground/MagicWaypoint: Now displays the current position and desired position (icons could do with work)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1763 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6fe9a12358
commit
6d66060730
@ -134,8 +134,8 @@
|
||||
style="stroke-width:2.1899786;stroke-miterlimit:4;stroke-dasharray:none" />
|
||||
</g>
|
||||
<a
|
||||
id="a3867"
|
||||
transform="translate(10,-10)">
|
||||
id="desiredPositionObj"
|
||||
transform="translate(-5.3432485,-16.199292)">
|
||||
<path
|
||||
transform="matrix(0.88823427,0,0,0.88823427,0.65875236,4.0999609)"
|
||||
inkscape:label="#path3034"
|
||||
@ -144,8 +144,25 @@
|
||||
sodipodi:rx="1.0136986"
|
||||
sodipodi:cy="28.684931"
|
||||
sodipodi:cx="25.013699"
|
||||
id="joystickEnd"
|
||||
id="desiredPosition"
|
||||
style="fill:#ff201d;fill-opacity:1;stroke:#ef7d7d;stroke-width:0.39996386;stroke-miterlimit:4;stroke-opacity:0.59336093;stroke-dasharray:none"
|
||||
sodipodi:type="arc" />
|
||||
</a>
|
||||
<use
|
||||
x="0"
|
||||
y="0"
|
||||
xlink:href="#a3867"
|
||||
id="use3944"
|
||||
transform="translate(-7.1291862,13.018514)"
|
||||
width="64"
|
||||
height="64" />
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:#998ad7;stroke-width:0;stroke-miterlimit:4;stroke-opacity:0.59336093;stroke-dasharray:none"
|
||||
id="actualPosition"
|
||||
sodipodi:cx="14.490846"
|
||||
sodipodi:cy="23.162163"
|
||||
sodipodi:rx="0.85240269"
|
||||
sodipodi:ry="0.85240269"
|
||||
d="m 15.343248,23.162163 a 0.85240269,0.85240269 0 1 1 -1.704805,0 0.85240269,0.85240269 0 1 1 1.704805,0 z" />
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 5.4 KiB |
@ -28,6 +28,7 @@
|
||||
#include "ui_magicwaypoint.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
@ -47,10 +48,14 @@ MagicWaypointGadgetWidget::MagicWaypointGadgetWidget(QWidget *parent) : QLabel(p
|
||||
m_magicwaypoint->setupUi(this);
|
||||
|
||||
// Connect object updated event from UAVObject to also update check boxes
|
||||
connect(getPositionDesired(), SIGNAL(objectUpdated(UAVObject*)), this, SLOT(positionDesiredObjectChanged(UAVObject*)));
|
||||
connect(getPositionDesired(), SIGNAL(objectUpdated(UAVObject*)), this, SLOT(positionObjectChanged(UAVObject*)));
|
||||
connect(getPositionActual(), SIGNAL(objectUpdated(UAVObject*)), this, SLOT(positionObjectChanged(UAVObject*)));
|
||||
|
||||
// Connect updates from the position widget to this widget
|
||||
connect(m_magicwaypoint->widgetPosition, SIGNAL(positionClicked(double,double)), this, SLOT(positionSelected(double,double)));
|
||||
connect(this, SIGNAL(positionObjectChanged(double,double)), m_magicwaypoint->widgetPosition, SLOT(updateIndicator(double,double)));
|
||||
connect(this, SIGNAL(positionActualObjectChanged(double,double)), m_magicwaypoint->widgetPosition, SLOT(updateActualIndicator(double,double)));
|
||||
connect(this, SIGNAL(positionDesiredObjectChanged(double,double)), m_magicwaypoint->widgetPosition, SLOT(updateDesiredIndicator(double,double)));
|
||||
|
||||
// Catch changes in scale for visualization
|
||||
connect(m_magicwaypoint->horizontalSliderScale, SIGNAL(valueChanged(int)), this, SLOT(scaleChanged(double)));
|
||||
}
|
||||
@ -61,7 +66,7 @@ MagicWaypointGadgetWidget::~MagicWaypointGadgetWidget()
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the ManualControlCommand UAVObject
|
||||
\brief Returns the @ref PositionDesired UAVObject
|
||||
*/
|
||||
PositionDesired* MagicWaypointGadgetWidget::getPositionDesired()
|
||||
{
|
||||
@ -71,24 +76,41 @@ PositionDesired* MagicWaypointGadgetWidget::getPositionDesired()
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the @ref PositionActual UAVObject
|
||||
*/
|
||||
PositionActual* MagicWaypointGadgetWidget::getPositionActual()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
PositionActual* obj = dynamic_cast<PositionActual*>( objManager->getObject(QString("PositionActual")) );
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect changes in scale and update visualization (does not change position)
|
||||
*/
|
||||
void MagicWaypointGadgetWidget::scaleChanged(int scale) {
|
||||
Q_UNUSED(scale);
|
||||
positionDesiredObjectChanged(getPositionDesired());
|
||||
positionObjectChanged(getPositionDesired());
|
||||
positionObjectChanged(getPositionActual());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update displayed position when @ref PositionDesired object is changed
|
||||
* Emit a position changed signal when @ref PositionDesired or @ref PositionActual object is changed
|
||||
*/
|
||||
void MagicWaypointGadgetWidget::positionDesiredObjectChanged(UAVObject* obj)
|
||||
void MagicWaypointGadgetWidget::positionObjectChanged(UAVObject* obj)
|
||||
{
|
||||
double north = obj->getField("North")->getDouble();
|
||||
double east = obj->getField("East")->getDouble();
|
||||
double scale = m_magicwaypoint->horizontalSliderScale->value();
|
||||
double north = obj->getField("North")->getDouble() / scale;
|
||||
double east = obj->getField("East")->getDouble() / scale;
|
||||
|
||||
if(obj->getName().compare("PositionDesired")) {
|
||||
emit positionDesiredObjectChanged(north,east);
|
||||
} else {
|
||||
emit positionActualObjectChanged(north,east);
|
||||
}
|
||||
|
||||
emit positionObjectChanged(north/scale,east/scale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include "uavobjects/positiondesired.h"
|
||||
#include "uavobjects/positionactual.h"
|
||||
|
||||
class Ui_MagicWaypoint;
|
||||
|
||||
@ -42,15 +43,17 @@ public:
|
||||
~MagicWaypointGadgetWidget();
|
||||
|
||||
signals:
|
||||
void positionObjectChanged(double north, double east);
|
||||
void positionActualObjectChanged(double north, double east);
|
||||
void positionDesiredObjectChanged(double north, double east);
|
||||
|
||||
protected slots:
|
||||
void scaleChanged(int scale);
|
||||
void positionDesiredObjectChanged(UAVObject *);
|
||||
void positionObjectChanged(UAVObject *);
|
||||
void positionSelected(double north, double east);
|
||||
|
||||
private:
|
||||
PositionDesired * getPositionDesired();
|
||||
PositionActual * getPositionActual();
|
||||
Ui_MagicWaypoint * m_magicwaypoint;
|
||||
};
|
||||
|
||||
|
@ -55,15 +55,21 @@ PositionField::PositionField(QWidget *parent) :
|
||||
m_background->setSharedRenderer(m_renderer);
|
||||
m_background->setElementId(QString("background"));
|
||||
|
||||
m_position = new QGraphicsSvgItem();
|
||||
m_position->setSharedRenderer(m_renderer);
|
||||
m_position->setElementId(QString("joystickEnd"));
|
||||
m_position->setPos(0,0);
|
||||
m_positiondesired = new QGraphicsSvgItem();
|
||||
m_positiondesired->setSharedRenderer(m_renderer);
|
||||
m_positiondesired->setElementId(QString("desiredPosition"));
|
||||
m_positiondesired->setPos(0,0);
|
||||
|
||||
m_positionactual = new QGraphicsSvgItem();
|
||||
m_positionactual->setSharedRenderer(m_renderer);
|
||||
m_positionactual->setElementId(QString("actualPosition"));
|
||||
m_positionactual->setPos(0,0);
|
||||
|
||||
QGraphicsScene *l_scene = scene();
|
||||
l_scene->clear(); // This also deletes all items contained in the scene.
|
||||
l_scene->addItem(m_background);
|
||||
l_scene->addItem(m_position);
|
||||
l_scene->addItem(m_positiondesired);
|
||||
l_scene->addItem(m_positionactual);
|
||||
l_scene->setSceneRect(m_background->boundingRect());
|
||||
}
|
||||
|
||||
@ -75,13 +81,19 @@ PositionField::~PositionField()
|
||||
/**
|
||||
* @brief Update aircraft position on image (values go from -1 to 1)
|
||||
*/
|
||||
void PositionField::updateIndicator(double north, double east)
|
||||
void PositionField::updateDesiredIndicator(double north, double east)
|
||||
{
|
||||
QRectF sceneSize = scene()->sceneRect();
|
||||
|
||||
m_position->setPos((east+1)/2*sceneSize.width(),(-north+1)/2*sceneSize.height());
|
||||
m_positiondesired->setPos((east+1)/2*sceneSize.width(),(-north+1)/2*sceneSize.height());
|
||||
}
|
||||
|
||||
void PositionField::updateActualIndicator(double north, double east)
|
||||
{
|
||||
QRectF sceneSize = scene()->sceneRect();
|
||||
|
||||
m_positionactual->setPos((east+1)/2*sceneSize.width(),(-north+1)/2*sceneSize.height());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Redirect mouse move events to control position
|
||||
|
@ -57,12 +57,14 @@ signals:
|
||||
void positionClicked(double north, double east);
|
||||
|
||||
public slots:
|
||||
void updateIndicator(double north, double east);
|
||||
void updateDesiredIndicator(double north, double east);
|
||||
void updateActualIndicator(double north, double east);
|
||||
|
||||
private:
|
||||
QSvgRenderer *m_renderer;
|
||||
QGraphicsSvgItem *m_background;
|
||||
QGraphicsSvgItem *m_position;
|
||||
QGraphicsSvgItem *m_positiondesired;
|
||||
QGraphicsSvgItem *m_positionactual;
|
||||
};
|
||||
|
||||
#endif // POSITIONFIELD_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user