1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Connected Dials plugin to UAVObjects. Does not actually update yet but we're getting there.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@641 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-05-19 16:07:11 +00:00 committed by edouard
parent d02a3325d9
commit 195f5b8a75
5 changed files with 42 additions and 4 deletions

View File

@ -6,5 +6,6 @@
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
<dependency name="UAVObjects" version="0.0.1"/>
</dependencyList>
</plugin>

View File

@ -3,7 +3,7 @@ TARGET = AirspeedGadget
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/qwt/qwt.pri)
include(airspeed_dependencies.pri)
HEADERS += airspeedplugin.h
HEADERS += airspeedgadget.h
HEADERS += airspeedgadgetwidget.h

View File

@ -0,0 +1 @@
include(../../plugins/uavobjects/uavobjects.pri)

View File

@ -26,9 +26,9 @@
*/
#include "airspeedgadgetwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include <iostream>
#include <QtGui/QFileDialog>
#include <QDebug>
AirspeedGadgetWidget::AirspeedGadgetWidget(QWidget *parent) : QGraphicsView(parent)
@ -64,8 +64,43 @@ AirspeedGadgetWidget::~AirspeedGadgetWidget()
// Do nothing
}
/*!
\brief Connects the widget to the relevant UAVObjects
*/
void AirspeedGadgetWidget::connectNeedles(QString object1, QString field1, QString object2, QString field2 ) {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
// Check validity of arguments first, reject empty args and unknown fields.
if (!(object1.isEmpty() || field1.isEmpty())) {
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(object1) );
if (obj != NULL ) {
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateNeedles(UAVObject*)));
} else {
std::cout << "Error: Object is unknown (" << object1.toStdString() << ")." << std::endl;
}
}
// And do the same for the second needle.
if (!(object2.isEmpty() || field2.isEmpty())) {
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(object2) );
if (obj != NULL ) {
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(updateNeedles(UAVObject*)));
} else {
std::cout << "Error: Object is unknown (" << object2.toStdString() << ")." << std::endl;
}
}
}
/*!
\brief Called by the systemalarms UAVObject
*/
void AirspeedGadgetWidget::updateNeedles(UAVObject *systemObject) {
// UAVObjectField* field = obj->getField(QString("Field1"));
}

View File

@ -29,12 +29,12 @@
#define AIRSPEEDGADGETWIDGET_H_
#include "airspeedgadgetconfiguration.h"
#include "uavobjects/uavobject.h"
#include <QGraphicsView>
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QGraphicsSvgItem>
#include <QFile>
// Used for test purposes
#include <QTimer>
class AirspeedGadgetWidget : public QGraphicsView
@ -67,6 +67,7 @@ private:
private slots:
// Test function
void testRotate();
void updateNeedles(UAVObject *systemAlarm); // Called by the systemalarms UAVObject
void rotateNeedles();
private: