Commit d6ddbdc3 authored by Don Gagne's avatar Don Gagne

New FactSystem

Allows parameter access from QML among other things
parent 97eb82b8
......@@ -175,6 +175,7 @@ WindowsBuild {
$$DLL_DIR\\Qt5PrintSupport$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Qml$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Quick$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5QuickWidgets$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5Sensors$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5SerialPort$${DLL_QT_DEBUGCHAR}.dll \
$$DLL_DIR\\Qt5OpenGL$${DLL_QT_DEBUGCHAR}.dll \
......
import QtQuick 2.0
import QtQuick.Controls 1.2
import QGroundControl.FactSystem 1.0
TextInput {
property Fact fact
text: fact.value
font.family: "Helvetica"
font.pointSize: 24
color: "red"
focus: true
onAccepted: { fact.value = text; }
}
Module QGroundControl.FactControls
FactTextInput 1.0 FactTextInput.qml
\ No newline at end of file
......@@ -111,7 +111,8 @@ QT += network \
serialport \
sql \
printsupport \
quick
quick \
quickwidgets
!contains(DEFINES, DISABLE_GOOGLE_EARTH) {
QT += webkit webkitwidgets
......@@ -479,7 +480,8 @@ HEADERS += \
src/QGCFileDialog.h \
src/QGCMessageBox.h \
src/QGCComboBox.h \
src/QGCTemporaryFile.h
src/QGCTemporaryFile.h \
src/QGCQuickWidget.h
SOURCES += \
src/main.cc \
......@@ -618,8 +620,8 @@ SOURCES += \
src/uas/QGXPX4UAS.cc \
src/QGCFileDialog.cc \
src/QGCComboBox.cc \
src/QGCTemporaryFile.cc
src/QGCTemporaryFile.cc \
src/QGCQuickWidget.cc
#
# Unit Test specific configuration goes here
......@@ -709,7 +711,8 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/FlightModesComponent.h \
src/AutoPilotPlugins/PX4/FlightModeConfig.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \
SOURCES += \
src/VehicleSetup/SetupView.cc \
......@@ -724,4 +727,22 @@ SOURCES += \
src/AutoPilotPlugins/PX4/FlightModesComponent.cc \
src/AutoPilotPlugins/PX4/FlightModeConfig.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \
# Fact System code
INCLUDEPATH += \
src/FactSystem
HEADERS += \
src/FactSystem/FactSystem.h \
src/FactSystem/Fact.h \
src/FactSystem/FactMetaData.h \
src/FactSystem/FactValidator.h \
SOURCES += \
src/FactSystem/FactSystem.cc \
src/FactSystem/Fact.cc \
src/FactSystem/FactMetaData.cc \
src/FactSystem/FactValidator.cc \
......@@ -234,4 +234,11 @@
<qresource prefix="/QLoggingCategory">
<file alias="qtlogging.ini">files/QLoggingCategory/qtlogging.ini</file>
</qresource>
<qresource prefix="/qml">
<file alias="QGroundControlFactControls/qmldir">files/qml/qmldir</file>
<file alias="QGroundControlFactControls/FactTextInput.qml">files/qml/FactTextInput.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
<file alias="ParameterFactMetaData.xml">src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml</file>
</qresource>
</RCC>
......@@ -27,9 +27,11 @@
#include <QObject>
#include <QList>
#include <QString>
#include <QQmlContext>
#include "UASInterface.h"
#include "VehicleComponent.h"
#include "FactSystem.h"
/// @file
/// @brief The AutoPilotPlugin class is an abstract base class which represent the methods and objects
......@@ -57,6 +59,9 @@ public:
/// @brief Returns a human readable short description for the specified mode.
virtual QString getShortModeText(uint8_t baseMode, uint32_t customMode) const = 0;
/// @brief Adds the FactSystem properties associated with this AutoPilot to the Qml context.
virtual void addFactsToQmlContext(QQmlContext* context, UASInterface* uas) const = 0;
protected:
// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }
......
......@@ -85,3 +85,11 @@ QString GenericAutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t cust
return mode;
}
void GenericAutoPilotPlugin::addFactsToQmlContext(QQmlContext* context, UASInterface* uas) const
{
Q_UNUSED(context);
Q_UNUSED(uas);
// Qml not yet supported for Generic
Q_ASSERT(false);
}
......@@ -38,9 +38,11 @@ class GenericAutoPilotPlugin : public AutoPilotPlugin
public:
GenericAutoPilotPlugin(QObject* parent = NULL);
// Overrides from AutoPilotPlugin
virtual QList<VehicleComponent*> getVehicleComponents(UASInterface* uas) const ;
virtual QList<FullMode_t> getModes(void) const;
virtual QString getShortModeText(uint8_t baseMode, uint32_t customMode) const;
virtual void addFactsToQmlContext(QQmlContext* context, UASInterface* uas) const;
};
#endif
......@@ -27,6 +27,9 @@
#include "SensorsComponent.h"
#include "FlightModesComponent.h"
#include "AutoPilotPluginManager.h"
#include "UASManager.h"
#include "QGCUASParamManagerInterface.h"
#include "PX4ParameterFacts.h"
/// @file
/// @brief This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_PX4 type.
......@@ -65,7 +68,24 @@ union px4_custom_mode {
PX4AutoPilotPlugin::PX4AutoPilotPlugin(QObject* parent) :
AutoPilotPlugin(parent)
{
UASManagerInterface* uasMgr = UASManager::instance();
Q_ASSERT(uasMgr);
// We need to track uas coming and going so that we can create PX4ParameterFacts instances for each uas
connect(uasMgr, &UASManagerInterface::UASCreated, this, &PX4AutoPilotPlugin::_uasCreated);
connect(uasMgr, &UASManagerInterface::UASDeleted, this, &PX4AutoPilotPlugin::_uasDeleted);
PX4ParameterFacts::loadParameterFactMetaData();
}
PX4AutoPilotPlugin::~PX4AutoPilotPlugin()
{
PX4ParameterFacts::deleteParameterFactMetaData();
foreach(UASInterface* uas, _mapUas2ParameterFacts.keys()) {
delete _mapUas2ParameterFacts[uas];
}
_mapUas2ParameterFacts.clear();
}
QList<VehicleComponent*> PX4AutoPilotPlugin::getVehicleComponents(UASInterface* uas) const
......@@ -172,3 +192,46 @@ QString PX4AutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMo
return mode;
}
void PX4AutoPilotPlugin::addFactsToQmlContext(QQmlContext* context, UASInterface* uas) const
{
Q_ASSERT(context);
Q_ASSERT(uas);
QGCUASParamManagerInterface* paramMgr = uas->getParamManager();
Q_UNUSED(paramMgr);
Q_ASSERT(paramMgr);
Q_ASSERT(paramMgr->parametersReady());
PX4ParameterFacts* facts = _parameterFactsForUas(uas);
Q_ASSERT(facts);
context->setContextProperty("parameterFacts", facts);
}
/// @brief When a new uas is create we add a new set of parameter facts for it
void PX4AutoPilotPlugin::_uasCreated(UASInterface* uas)
{
Q_ASSERT(uas);
Q_ASSERT(!_mapUas2ParameterFacts.contains(uas));
// Each uas has it's own set of parameter facts
PX4ParameterFacts* facts = new PX4ParameterFacts(uas, this);
Q_CHECK_PTR(facts);
_mapUas2ParameterFacts[uas] = facts;
}
/// @brief When the uas is deleted we remove the parameter facts for it from the system
void PX4AutoPilotPlugin::_uasDeleted(UASInterface* uas)
{
delete _parameterFactsForUas(uas);
_mapUas2ParameterFacts.remove(uas);
}
PX4ParameterFacts* PX4AutoPilotPlugin::_parameterFactsForUas(UASInterface* uas) const
{
Q_ASSERT(uas);
Q_ASSERT(_mapUas2ParameterFacts.contains(uas));
return _mapUas2ParameterFacts[uas];
}
......@@ -25,6 +25,8 @@
#define PX4AUTOPILOT_H
#include "AutoPilotPlugin.h"
#include "UASInterface.h"
#include "PX4ParameterFacts.h"
/// @file
/// @brief This is the PX4 specific implementation of the AutoPilot class.
......@@ -36,10 +38,22 @@ class PX4AutoPilotPlugin : public AutoPilotPlugin
public:
PX4AutoPilotPlugin(QObject* parent);
~PX4AutoPilotPlugin();
// Overrides from AutoPilotPlugin
virtual QList<VehicleComponent*> getVehicleComponents(UASInterface* uas) const ;
virtual QList<FullMode_t> getModes(void) const;
virtual QString getShortModeText(uint8_t baseMode, uint32_t customMode) const;
virtual void addFactsToQmlContext(QQmlContext* context, UASInterface* uas) const;
private slots:
void _uasCreated(UASInterface* uas);
void _uasDeleted(UASInterface* uas);
private:
PX4ParameterFacts* _parameterFactsForUas(UASInterface* uas) const;
QMap<UASInterface*, PX4ParameterFacts*> _mapUas2ParameterFacts;
};
#endif
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "Fact.h"
#include <QtQml>
Fact::Fact(QObject* parent) :
QObject(parent)
{
}
void Fact::setValue(QVariant& value)
{
_value = value;
emit valueUpdated(value);
}
void Fact::updateValue(QVariant& value)
{
_value = value;
emit valueChanged(value);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef Fact_H
#define Fact_H
#include "FactMetaData.h"
#include <QObject>
#include <QString>
#include <QVariant>
/// @brief A Fact is used to hold a single value within the system.
///
/// Along with the value property is a set of meta data which further describes the Fact. This information is
/// exposed through QObject Properties such that you can bind to it from QML as well as use it within C++ code.
/// Since the meta data is common to all instances of the same Fact, it is acually stored once in a seperate object.
class Fact : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged USER true)
Q_PROPERTY(QVariant defaultValue READ defaultValue CONSTANT)
Q_PROPERTY(FactMetaData::ValueType_t type READ type CONSTANT)
Q_PROPERTY(QString shortDescription READ shortDescription CONSTANT)
Q_PROPERTY(QString longDescription READ longDescription CONSTANT)
Q_PROPERTY(QString units READ units CONSTANT)
Q_PROPERTY(QVariant min READ min CONSTANT)
Q_PROPERTY(QVariant max READ max CONSTANT)
Q_ENUMS(FactMetaData::ValueType_t)
public:
Fact(QObject* parent = NULL);
// Property system methods
/// Read accessor for value property
QVariant value(void) const { return _value; }
/// Write accessor for value property
void setValue(QVariant& value);
/// Read accesor for defaultValue property
QVariant defaultValue(void) { return _metaData->defaultValue; }
/// Read accesor for type property
FactMetaData::ValueType_t type(void) { return _metaData->type; }
/// Read accesor for shortDescription property
QString shortDescription(void) { return _metaData->shortDescription; }
/// Read accesor for longDescription property
QString longDescription(void) { return _metaData->longDescription; }
/// Read accesor for units property
QString units(void) { return _metaData->units; }
/// Read accesor for min property
QVariant min(void) { return _metaData->min; }
/// Read accesor for max property
QVariant max(void) { return _metaData->max; }
/// Used to update the value property from C++ code.
///
/// The setValue method is only for use by the QObject Property system. It should not be called directly by C++ app code.
void updateValue(QVariant& value);
/// Sets the meta data associated with the Fact.
void setMetaData(FactMetaData* metaData) { _metaData = metaData; }
signals:
/// QObject Property System signal for value property changes
///
/// This signal is only meant for use by the QT property system. It should not be connected to by client code.
void valueChanged(QVariant& value);
/// Signalled when property has been changed by a call to the property write accessor
///
/// This signal is meant for use by client code.
void valueUpdated(QVariant& value);
private:
QVariant _value; ///< Fact value
FactMetaData* _metaData; ///< FactMetaData object for Fact
};
#endif
\ No newline at end of file
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @brief Object which exposes a FactMetaData
///
/// @author Don Gagne <don@thegagnes.com>
#include "FactMetaData.h"
FactMetaData::FactMetaData(QObject* parent) :
QObject(parent)
{
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FactMetaData_H
#define FactMetaData_H
#include <QObject>
#include <QString>
#include <QVariant>
/// Holds the meta data associated with a Fact.
///
/// Holds the meta data associated with a Fact. This is kept in a seperate object from the Fact itself
/// since you may have multiple instances of the same Fact. But there is only ever one FactMetaData
/// instance or each Fact.
class FactMetaData : public QObject
{
Q_OBJECT
public:
FactMetaData(QObject* parent = NULL);
typedef enum {
valueTypeUint8,
valueTypeInt8,
valueTypeUint16,
valueTypeInt16,
valueTypeUint32,
valueTypeInt32,
valueTypeFloat,
valueTypeDouble
} ValueType_t;
QVariant defaultValue;
ValueType_t type;
QString shortDescription;
QString longDescription;
QString units;
QVariant min;
QVariant max;
};
#endif
\ No newline at end of file
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "FactSystem.h"
#include "UASManager.h"
#include <QtQml>
FactSystem* FactSystem::_instance = NULL;
QMutex FactSystem::_singletonLock;
const char* FactSystem::_factSystemQmlUri = "QGroundControl.FactSystem";
FactSystem* FactSystem::instance(void)
{
if(_instance == 0) {
_singletonLock.lock();
if (_instance == 0) {
_instance = new FactSystem(qgcApp());
Q_CHECK_PTR(_instance);
}
_singletonLock.unlock();
}
Q_ASSERT(_instance);
return _instance;
}
void FactSystem::deleteInstance(void)
{
_instance = NULL;
delete this;
}
FactSystem::FactSystem(QObject* parent, bool registerSingleton) :
QGCSingleton(parent, registerSingleton)
{
qmlRegisterType<Fact>(_factSystemQmlUri, 1, 0, "Fact");
qmlRegisterType<FactValidator>(_factSystemQmlUri, 1, 0, "FactValidator");
}
FactSystem::~FactSystem()
{
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FactSystem_h
#define FactSystem_h
#include "Fact.h"
#include "FactMetaData.h"
#include "UASInterface.h"
#include "QGCSingleton.h"
#include "FactValidator.h"
#include <QMutex>
/// FactSystem is a singleton which provides access to the Facts in the system
///
/// The components of the FactSystem are a Fact which holds an individual value. FactMetaData holds
/// additional meta data associated with a Fact such as description, min/max ranges and so forth.
/// The FactValidator object is a QML validator which validates input according to the FactMetaData
/// settings. Client code can then use this system to expose sets of Facts to QML code. An example
/// of this is the PX4ParameterFacts onbject which is part of the PX4 AutoPilot plugin. It exposes
/// the firmware parameters to QML such that you can bind QML ui elements directly to parameters.
class FactSystem : public QGCSingleton
{
Q_OBJECT
public:
/// Returns the FactSystem singleton
static FactSystem* instance(void);
/// Override from QGCSingleton
virtual void deleteInstance(void);
~FactSystem();
private:
/// All access to FactSystem is through FactSystem::instance, so constructor is private
FactSystem(QObject* parent = NULL, bool registerSingleton = true);
static QMutex _singletonLock; ///< Mutex to make calls to instance thread-safe
static FactSystem* _instance; ///< FactSystem singleton
static const char* _factSystemQmlUri; ///< URI for FactSystem QML imports
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "FactValidator.h"
FactValidator::FactValidator(QObject* parent) :
QValidator(parent)
{
}
void FactValidator::fixup(QString& input) const
{
Q_UNUSED(input);
}
FactValidator::State FactValidator::validate(QString& input, int& pos) const
{
Q_UNUSED(input);
Q_UNUSED(pos);
return Acceptable;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FactValidator_H
#define FactValidator_H
#include <QValidator>
class Fact;
/// QML Validator for Facts (Work In Progress)
///
/// The validator uses the FactMetaData to impose restrictions on the input. It is used as follows:
/// @code{.unparsed}
/// TextInput {
/// validator: FactValidator { fact: parameterFacts.RC_MAP_THROTTLE; }
/// }
/// @endcode
class FactValidator : public QValidator
{
Q_OBJECT
Q_PROPERTY(Fact* fact READ fact WRITE setFact)
public:
FactValidator(QObject* parent = NULL);
// Property system methods
/// Read accessor for fact property
Fact* fact(void) { return _fact; }
/// Write accessor for fact property
void setFact(Fact* fact) { _fact = fact; }
/// Override from QValidator
virtual void fixup(QString& input) const;
/// Override from QValidator
virtual State validate(QString& input, int& pos) const;
private:
Fact* _fact; ///< Fact that the validator is working on
};
#endif
\ No newline at end of file
......@@ -433,6 +433,11 @@ void QGCApplication::_createSingletons(void)
AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::instance();
Q_UNUSED(pluginManager);
Q_ASSERT(pluginManager);
// Must be after UASManager since FactSystem connects to UASManager
FactSystem* factSystem = FactSystem::instance();
Q_UNUSED(factSystem);
Q_ASSERT(factSystem);
}
void QGCApplication::destroySingletonsForUnitTest(void)
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "QGCQuickWidget.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h"
#include <QQmlContext>
#include <QQmlEngine>
/// @file
/// @brief Subclass of QQuickWidget which injects Facts and the Pallete object into
/// the QML context.
///
/// @author Don Gagne <don@thegagnes.com>
QGCQuickWidget::QGCQuickWidget(QWidget* parent) :
QQuickWidget(parent)
{
UASManagerInterface* uasMgr = UASManager::instance();
Q_ASSERT(uasMgr);
UASInterface* uas = uasMgr->getActiveUAS();
Q_ASSERT(uas);
AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(uas->getAutopilotType())->addFactsToQmlContext(rootContext(), uas);
rootContext()->engine()->addImportPath("qrc:/qml");
setSource(QUrl::fromLocalFile("/Users/Don/repos/qgroundcontrol/test.qml"));
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef QGCQuickWidget_H
#define QGCQuickWidget_H
#include <QQuickWidget>
#include "UASInterface.h"
/// @file
/// @brief Subclass of QQuickWidget which injects Facts and the Pallete object into
/// the QML context.
///
/// @author Don Gagne <don@thegagnes.com>
class QGCQuickWidget : public QQuickWidget {
Q_OBJECT
public:
QGCQuickWidget(QWidget* parent = NULL);
};
#endif
Markdown is supported
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