diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp index 75b2326a7..be0558567 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.cpp @@ -67,8 +67,8 @@ public: public: Hidden(OSGCamera *parent) : - QObject(parent), sceneData(NULL), manipulatorMode(Default), node(NULL), - trackerMode(NodeCenterAndAzim), trackNode(NULL), + QObject(parent), sceneData(NULL), manipulatorMode(ManipulatorMode::Default), node(NULL), + trackerMode(TrackerMode::NodeCenterAndAzim), trackNode(NULL), logDepthBufferEnabled(false), logDepthBuffer(NULL), clampToTerrain(false) { fieldOfView = 90.0; @@ -107,7 +107,7 @@ public: return true; } - bool acceptManipulatorMode(ManipulatorMode mode) + bool acceptManipulatorMode(ManipulatorMode::Enum mode) { // qDebug() << "OSGCamera::acceptManipulatorMode" << mode; if (manipulatorMode == mode) { @@ -225,7 +225,7 @@ public: osgGA::CameraManipulator *cm = NULL; switch (manipulatorMode) { - case OSGCamera::Default: + case ManipulatorMode::Default: { qDebug() << "OSGCamera::attachManipulator - use TrackballManipulator"; osgGA::TrackballManipulator *tm = new osgGA::TrackballManipulator(); @@ -234,12 +234,12 @@ public: cm = tm; break; } - case OSGCamera::User: + case ManipulatorMode::User: qDebug() << "OSGCamera::attachManipulator - no camera manipulator"; // disable any installed camera manipulator cm = NULL; break; - case OSGCamera::Earth: + case ManipulatorMode::Earth: { qDebug() << "OSGCamera::attachManipulator - use EarthManipulator"; osgEarth::Util::EarthManipulator *em = new osgEarth::Util::EarthManipulator(); @@ -247,7 +247,7 @@ public: cm = em; break; } - case OSGCamera::Track: + case ManipulatorMode::Track: qDebug() << "OSGCamera::attachManipulator - use NodeTrackerManipulator"; if (trackNode && trackNode->node()) { // setup tracking camera @@ -256,13 +256,13 @@ public: osgGA::NodeTrackerManipulator *ntm = new osgGA::NodeTrackerManipulator( /*osgGA::StandardManipulator::COMPUTE_HOME_USING_BBOX | osgGA::StandardManipulator::DEFAULT_SETTINGS*/); switch (trackerMode) { - case NodeCenter: + case TrackerMode::NodeCenter: ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER); break; - case NodeCenterAndAzim: + case TrackerMode::NodeCenterAndAzim: ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM); break; - case NodeCenterAndRotation: + case TrackerMode::NodeCenterAndRotation: ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION); break; } @@ -301,7 +301,7 @@ public: void updateCamera() { updateCameraFOV(); - if (manipulatorMode == User) { + if (manipulatorMode == ManipulatorMode::User) { updateCameraPosition(); } } @@ -386,13 +386,13 @@ public: OSGNode *sceneData; - ManipulatorMode manipulatorMode; + ManipulatorMode::Enum manipulatorMode; // to compute home position OSGNode *node; // for NodeTrackerManipulator - TrackerMode trackerMode; + TrackerMode::Enum trackerMode; OSGNode *trackNode; bool logDepthBufferEnabled; @@ -473,12 +473,12 @@ void OSGCamera::setSceneData(OSGNode *node) } } -OSGCamera::ManipulatorMode OSGCamera::manipulatorMode() const +ManipulatorMode::Enum OSGCamera::manipulatorMode() const { return h->manipulatorMode; } -void OSGCamera::setManipulatorMode(ManipulatorMode mode) +void OSGCamera::setManipulatorMode(ManipulatorMode::Enum mode) { if (h->acceptManipulatorMode(mode)) { emit manipulatorModeChanged(manipulatorMode()); @@ -509,12 +509,12 @@ void OSGCamera::setTrackNode(OSGNode *node) } } -OSGCamera::TrackerMode OSGCamera::trackerMode() const +TrackerMode::Enum OSGCamera::trackerMode() const { return h->trackerMode; } -void OSGCamera::setTrackerMode(TrackerMode mode) +void OSGCamera::setTrackerMode(TrackerMode::Enum mode) { if (h->trackerMode != mode) { h->trackerMode = mode; diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.hpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.hpp index ec6c85a27..08c06518f 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.hpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGCamera.hpp @@ -40,6 +40,20 @@ class View; namespace osgQtQuick { class OSGNode; +class ManipulatorMode : public QObject { + Q_OBJECT +public: + enum Enum { Default, Earth, Track, User }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 +}; + +class TrackerMode : public QObject { + Q_OBJECT +public: + enum Enum { NodeCenter, NodeCenterAndAzim, NodeCenterAndRotation }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 +}; + // This class does too much: // - tracking a geo point and attitude // - tracking another node @@ -52,32 +66,18 @@ class OSGNode; // - provide good default distance and attitude for tracker camera class OSGQTQUICK_EXPORT OSGCamera : public QObject { Q_OBJECT Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) - Q_PROPERTY(osgQtQuick::OSGNode * sceneData READ sceneData WRITE setSceneData NOTIFY sceneDataChanged) - - Q_PROPERTY(ManipulatorMode manipulatorMode READ manipulatorMode WRITE setManipulatorMode NOTIFY manipulatorModeChanged) - + Q_PROPERTY(osgQtQuick::ManipulatorMode::Enum manipulatorMode READ manipulatorMode WRITE setManipulatorMode NOTIFY manipulatorModeChanged) Q_PROPERTY(osgQtQuick::OSGNode * node READ node WRITE setNode NOTIFY nodeChanged) - Q_PROPERTY(osgQtQuick::OSGNode * trackNode READ trackNode WRITE setTrackNode NOTIFY trackNodeChanged) - Q_PROPERTY(TrackerMode trackerMode READ trackerMode WRITE setTrackerMode NOTIFY trackerModeChanged) - + Q_PROPERTY(osgQtQuick::TrackerMode::Enum trackerMode READ trackerMode WRITE setTrackerMode NOTIFY trackerModeChanged) Q_PROPERTY(bool clampToTerrain READ clampToTerrain WRITE setClampToTerrain NOTIFY clampToTerrainChanged) Q_PROPERTY(bool intoTerrain READ intoTerrain NOTIFY intoTerrainChanged) - Q_PROPERTY(QVector3D attitude READ attitude WRITE setAttitude NOTIFY attitudeChanged) Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) - Q_PROPERTY(bool logarithmicDepthBuffer READ logarithmicDepthBuffer WRITE setLogarithmicDepthBuffer NOTIFY logarithmicDepthBufferChanged) - Q_ENUMS(ManipulatorMode) - Q_ENUMS(TrackerMode) - public: - enum ManipulatorMode { Default, Earth, Track, User }; - - enum TrackerMode { NodeCenter, NodeCenterAndAzim, NodeCenterAndRotation }; - explicit OSGCamera(QObject *parent = 0); virtual ~OSGCamera(); @@ -91,8 +91,8 @@ public: OSGNode *sceneData(); void setSceneData(OSGNode *node); - ManipulatorMode manipulatorMode() const; - void setManipulatorMode(ManipulatorMode); + ManipulatorMode::Enum manipulatorMode() const; + void setManipulatorMode(ManipulatorMode::Enum); OSGNode *node() const; void setNode(OSGNode *node); @@ -100,8 +100,8 @@ public: OSGNode *trackNode() const; void setTrackNode(OSGNode *node); - TrackerMode trackerMode() const; - void setTrackerMode(TrackerMode); + TrackerMode::Enum trackerMode() const; + void setTrackerMode(TrackerMode::Enum); bool clampToTerrain() const; void setClampToTerrain(bool arg); @@ -125,12 +125,12 @@ signals: void sceneDataChanged(OSGNode *node); - void manipulatorModeChanged(ManipulatorMode); + void manipulatorModeChanged(ManipulatorMode::Enum); void nodeChanged(OSGNode *node); void trackNodeChanged(OSGNode *node); - void trackerModeChanged(TrackerMode); + void trackerModeChanged(TrackerMode::Enum); void clampToTerrainChanged(bool arg); void intoTerrainChanged(bool arg); diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.cpp index 5e1d5ab5d..19e5ff249 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.cpp @@ -75,7 +75,7 @@ private: OSGFileNode * const self; public: - Hidden(OSGFileNode *parent) : QObject(parent), self(parent), url(), async(false), optimizeMode(None) {} + Hidden(OSGFileNode *parent) : QObject(parent), self(parent), url(), async(false), optimizeMode(OptimizeMode::None) {} bool acceptSource(QUrl url) { @@ -99,7 +99,7 @@ public: QUrl url; bool async; - OptimizeMode optimizeMode; + OptimizeMode::Enum optimizeMode; private: @@ -133,7 +133,7 @@ private: bool acceptNode(osg::Node *node) { qDebug() << "OSGFileNode::acceptNode" << node; - if (node && optimizeMode != OSGFileNode::None) { + if (node && optimizeMode != OptimizeMode::None) { // qDebug() << "OSGFileNode::acceptNode - optimize" << node << optimizeMode; osgUtil::Optimizer optimizer; optimizer.optimize(node, osgUtil::Optimizer::DEFAULT_OPTIMIZATIONS); @@ -186,12 +186,12 @@ void OSGFileNode::setAsync(const bool async) } } -OSGFileNode::OptimizeMode OSGFileNode::optimizeMode() const +OptimizeMode::Enum OSGFileNode::optimizeMode() const { return h->optimizeMode; } -void OSGFileNode::setOptimizeMode(OptimizeMode mode) +void OSGFileNode::setOptimizeMode(OptimizeMode::Enum mode) { // qDebug() << "OSGFileNode::setOptimizeMode" << mode; if (h->optimizeMode != mode) { diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.hpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.hpp index fcac16093..e170ca6d2 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.hpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGFileNode.hpp @@ -37,15 +37,20 @@ class QUrl; QT_END_NAMESPACE namespace osgQtQuick { + +class OSGQTQUICK_EXPORT OptimizeMode : public QObject { + Q_OBJECT +public: + enum Enum { None, Optimize, OptimizeAndCheck }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 +}; + class OSGQTQUICK_EXPORT OSGFileNode : public OSGNode { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(bool async READ async WRITE setAsync NOTIFY asyncChanged) - Q_PROPERTY(OptimizeMode optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged) - - Q_ENUMS(OptimizeMode) + Q_PROPERTY(osgQtQuick::OptimizeMode::Enum optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged) public: - enum OptimizeMode { None, Optimize, OptimizeAndCheck }; OSGFileNode(QObject *parent = 0); virtual ~OSGFileNode(); @@ -56,13 +61,13 @@ public: bool async() const; void setAsync(const bool async); - OptimizeMode optimizeMode() const; - void setOptimizeMode(OptimizeMode); + OptimizeMode::Enum optimizeMode() const; + void setOptimizeMode(OptimizeMode::Enum); signals: void sourceChanged(const QUrl &url); void asyncChanged(const bool async); - void optimizeModeChanged(OptimizeMode); + void optimizeModeChanged(OptimizeMode::Enum); private: struct Hidden; diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp index a40d914e0..ad1c6f52a 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.cpp @@ -86,7 +86,7 @@ public: window(NULL), sceneData(NULL), camera(NULL), - updateMode(Discrete), + updateMode(UpdateMode::Discrete), frameTimer(-1) { qDebug() << "OSGViewport::Hidden"; @@ -258,7 +258,7 @@ public: // view->getCamera()->setGraphicsContext(NULL); } - bool acceptUpdateMode(OSGViewport::UpdateMode mode) + bool acceptUpdateMode(UpdateMode::Enum mode) { // qDebug() << "OSGViewport::acceptUpdateMode" << mode; if (updateMode == mode) { @@ -289,7 +289,7 @@ public: OSGNode *sceneData; OSGCamera *camera; - OSGViewport::UpdateMode updateMode; + UpdateMode::Enum updateMode; int frameTimer; @@ -420,7 +420,7 @@ public: void start() { - if (updateMode == OSGViewport::Discrete && (frameTimer < 0)) { + if (updateMode == UpdateMode::Discrete && (frameTimer < 0)) { qDebug() << "OSGViewport::start - starting timer"; frameTimer = startTimer(33, Qt::PreciseTimer); } @@ -514,7 +514,7 @@ public: h->viewer->frame(); } - if (h->updateMode == OSGViewport::Continuous) { + if (h->updateMode == UpdateMode::Continuous) { // trigger next update update(); } @@ -559,12 +559,12 @@ OSGViewport::~OSGViewport() qDebug() << "OSGViewport::~OSGViewport"; } -OSGViewport::UpdateMode OSGViewport::updateMode() const +UpdateMode::Enum OSGViewport::updateMode() const { return h->updateMode; } -void OSGViewport::setUpdateMode(OSGViewport::UpdateMode mode) +void OSGViewport::setUpdateMode(UpdateMode::Enum mode) { if (h->acceptUpdateMode(mode)) { emit updateModeChanged(updateMode()); diff --git a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.hpp b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.hpp index 14fc85953..56901d867 100644 --- a/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.hpp +++ b/ground/gcs/src/libs/osgearth/osgQtQuick/OSGViewport.hpp @@ -41,30 +41,27 @@ class Renderer; class OSGNode; class OSGCamera; +class UpdateMode : public QObject { + Q_OBJECT +public: + enum Enum { Continuous, Discrete, OnDemand }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 +}; + class OSGQTQUICK_EXPORT OSGViewport : public QQuickFramebufferObject { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(UpdateMode updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged) + Q_PROPERTY(osgQtQuick::UpdateMode::Enum updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged) Q_PROPERTY(osgQtQuick::OSGNode * sceneData READ sceneData WRITE setSceneData NOTIFY sceneDataChanged) Q_PROPERTY(osgQtQuick::OSGCamera * camera READ camera WRITE setCamera NOTIFY cameraChanged) - Q_ENUMS(UpdateMode) - public: - friend class ViewportRenderer; - // TODO rename to UpdateMode or something better - enum UpdateMode { - Continuous, - Discrete, - OnDemand - }; - explicit OSGViewport(QQuickItem *parent = 0); virtual ~OSGViewport(); - UpdateMode updateMode() const; - void setUpdateMode(UpdateMode mode); + UpdateMode::Enum updateMode() const; + void setUpdateMode(UpdateMode::Enum mode); QColor color() const; void setColor(const QColor &color); @@ -82,7 +79,7 @@ public: virtual bool detach(osgViewer::View *view); signals: - void updateModeChanged(UpdateMode mode); + void updateModeChanged(UpdateMode::Enum mode); void colorChanged(const QColor &color); void sceneDataChanged(OSGNode *node); void cameraChanged(OSGCamera *camera); diff --git a/ground/gcs/src/libs/osgearth/osgearth.cpp b/ground/gcs/src/libs/osgearth/osgearth.cpp index 4ca9a65ee..26aa902ce 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.cpp +++ b/ground/gcs/src/libs/osgearth/osgearth.cpp @@ -72,7 +72,8 @@ void OsgEarth::registerQmlTypes() // initialize(); // Register Qml types - osgQtQuick::registerTypes("osgQtQuick"); + qDebug() << "OsgEarth::registerQmlTypes - registering Qml types..."; + osgQtQuick::registerTypes(); } void OsgEarth::initialize() diff --git a/ground/gcs/src/libs/osgearth/utility.cpp b/ground/gcs/src/libs/osgearth/utility.cpp index 96af48c4c..5ed516fab 100644 --- a/ground/gcs/src/libs/osgearth/utility.cpp +++ b/ground/gcs/src/libs/osgearth/utility.cpp @@ -499,23 +499,26 @@ QString getUsageString(osgViewer::CompositeViewer *viewer) return getUsageString(applicationUsage); } -void registerTypes(const char *uri) +void registerTypes() { - // Q_ASSERT(uri == QLatin1String("osgQtQuick")); int maj = 1, min = 0; // @uri osgQtQuick - qmlRegisterType(uri, maj, min, "OSGNode"); - qmlRegisterType(uri, maj, min, "OSGGroup"); - qmlRegisterType(uri, maj, min, "OSGFileNode"); - qmlRegisterType(uri, maj, min, "OSGTransformNode"); - qmlRegisterType(uri, maj, min, "OSGTextNode"); - qmlRegisterType(uri, maj, min, "OSGCubeNode"); - qmlRegisterType(uri, maj, min, "OSGViewport"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGGroup"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGFileNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OptimizeMode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGTransformNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGTextNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGCubeNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGViewport"); + qmlRegisterType("OsgQtQuick", maj, min, "UpdateMode"); - qmlRegisterType(uri, maj, min, "OSGModelNode"); - qmlRegisterType(uri, maj, min, "OSGSkyNode"); - qmlRegisterType(uri, maj, min, "OSGBackgroundNode"); - qmlRegisterType(uri, maj, min, "OSGCamera"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGModelNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGSkyNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGBackgroundNode"); + qmlRegisterType("OsgQtQuick", maj, min, "OSGCamera"); + qmlRegisterType("OsgQtQuick", maj, min, "ManipulatorMode"); + qmlRegisterType("OsgQtQuick", maj, min, "TrackerMode"); } } // namespace osgQtQuick diff --git a/ground/gcs/src/libs/osgearth/utility.h b/ground/gcs/src/libs/osgearth/utility.h index 8a84f70b4..5ca27268e 100644 --- a/ground/gcs/src/libs/osgearth/utility.h +++ b/ground/gcs/src/libs/osgearth/utility.h @@ -146,7 +146,7 @@ QString formatSwapBehaviorName(QSurfaceFormat::SwapBehavior swapBehavior); QString getUsageString(osgViewer::Viewer *viewer); QString getUsageString(osgViewer::CompositeViewer *viewer); -void registerTypes(const char *uri); +void registerTypes(); } // namespace osgQtQuick #endif // OSGEARTH_UTILITY_H diff --git a/ground/gcs/src/plugins/pfdqml/pfdqml.h b/ground/gcs/src/plugins/pfdqml/pfdqml.h index e3559d11c..30510e1e4 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqml.h +++ b/ground/gcs/src/plugins/pfdqml/pfdqml.h @@ -31,17 +31,29 @@ #include #include -class Pfd : public QObject { - Q_OBJECT Q_ENUMS(PositionMode) - Q_ENUMS(TimeMode) +class ModelSelectionMode : public QObject { + Q_OBJECT public: - enum ModelSelectionMode { Auto, Fixed }; - enum TimeMode { Local, PredefinedTime }; + enum Enum { Auto, Predefined }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 - static void declareQML() + static void registerQMLTypes() { - qmlRegisterType("PfdQmlEnums", 1, 0, "Pfd"); + qmlRegisterType("Pfd", 1, 0, "ModelSelectionMode"); + } +}; + +class TimeMode : public QObject { + Q_OBJECT + +public: + enum Enum { Local, Predefined }; + Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 + + static void registerQMLTypes() + { + qmlRegisterType("Pfd", 1, 0, "TimeMode"); } }; diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp index 50b6909e2..41edbcf4d 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp @@ -45,7 +45,7 @@ PfdQmlContext::PfdQmlContext(QObject *parent) : QObject(parent), m_latitude(39.657380), m_longitude(19.805158), m_altitude(100), - m_timeMode(Pfd::Local), + m_timeMode(TimeMode::Local), m_dateTime(QDateTime()), m_minAmbientLight(0.03), m_modelFile(""), @@ -172,12 +172,12 @@ void PfdQmlContext::setAltitude(double arg) } } -Pfd::TimeMode PfdQmlContext::timeMode() const +TimeMode::Enum PfdQmlContext::timeMode() const { return m_timeMode; } -void PfdQmlContext::setTimeMode(Pfd::TimeMode arg) +void PfdQmlContext::setTimeMode(TimeMode::Enum arg) { if (m_timeMode != arg) { m_timeMode = arg; diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.h b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.h index bcdf6ace9..78b426ee0 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.h +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.h @@ -47,7 +47,7 @@ class PfdQmlContext : public QObject { Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged) Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged) - Q_PROPERTY(Pfd::TimeMode timeMode READ timeMode WRITE setTimeMode NOTIFY timeModeChanged) + Q_PROPERTY(TimeMode::Enum timeMode READ timeMode WRITE setTimeMode NOTIFY timeModeChanged) Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged) Q_PROPERTY(double minimumAmbientLight READ minimumAmbientLight WRITE setMinimumAmbientLight NOTIFY minimumAmbientLightChanged) @@ -79,8 +79,8 @@ public: double altitude() const; void setAltitude(double arg); - Pfd::TimeMode timeMode() const; - void setTimeMode(Pfd::TimeMode arg); + TimeMode::Enum timeMode() const; + void setTimeMode(TimeMode::Enum arg); QDateTime dateTime() const; void setDateTime(QDateTime arg); double minimumAmbientLight() const; @@ -109,7 +109,7 @@ signals: void longitudeChanged(double arg); void altitudeChanged(double arg); - void timeModeChanged(Pfd::TimeMode arg); + void timeModeChanged(TimeMode::Enum arg); void dateTimeChanged(QDateTime arge); void minimumAmbientLightChanged(double arg); @@ -129,7 +129,7 @@ private: double m_longitude; double m_altitude; - Pfd::TimeMode m_timeMode; + TimeMode::Enum m_timeMode; QDateTime m_dateTime; double m_minAmbientLight; diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp index 134f65a27..f6df1b985 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp @@ -43,12 +43,12 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings m_latitude(0), m_longitude(0), m_altitude(0), - m_timeMode(Pfd::Local), + m_timeMode(TimeMode::Local), m_dateTime(QDateTime()), m_minAmbientLight(0), m_modelEnabled(false), m_modelFile("Unknown"), - m_modelSelectionMode(Pfd::Auto), + m_modelSelectionMode(ModelSelectionMode::Auto), m_backgroundImageFile("Unknown") { m_speedMap[1.0] = "m/s"; @@ -78,13 +78,13 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings m_altitude = qSettings->value("altitude").toDouble(); // sky - m_timeMode = static_cast(qSettings->value("timeMode").toUInt()); + m_timeMode = static_cast(qSettings->value("timeMode").toUInt()); m_dateTime = qSettings->value("dateTime").toDateTime(); m_minAmbientLight = qSettings->value("minAmbientLight").toDouble(); // model m_modelEnabled = qSettings->value("modelEnabled").toBool(); - m_modelSelectionMode = static_cast(qSettings->value("modelSelectionMode").toUInt()); + m_modelSelectionMode = static_cast(qSettings->value("modelSelectionMode").toUInt()); m_modelFile = qSettings->value("modelFile").toString(); m_modelFile = Utils::InsertDataPath(m_modelFile); diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h index bc0d23c60..9bcdc42a5 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h @@ -133,11 +133,11 @@ public: return m_cacheOnly; } - Pfd::TimeMode timeMode() const + TimeMode::Enum timeMode() const { return m_timeMode; } - void setTimeMode(Pfd::TimeMode timeMode) + void setTimeMode(TimeMode::Enum timeMode) { m_timeMode = timeMode; } @@ -178,11 +178,11 @@ public: m_modelFile = fileName; } - Pfd::ModelSelectionMode modelSelectionMode() const + ModelSelectionMode::Enum modelSelectionMode() const { return m_modelSelectionMode; } - void setModelSelectionMode(Pfd::ModelSelectionMode modelSelectionMode) + void setModelSelectionMode(ModelSelectionMode::Enum modelSelectionMode) { m_modelSelectionMode = modelSelectionMode; } @@ -223,13 +223,13 @@ private: double m_longitude; double m_altitude; - Pfd::TimeMode m_timeMode; + TimeMode::Enum m_timeMode; QDateTime m_dateTime; double m_minAmbientLight; bool m_modelEnabled; QString m_modelFile; // The name of model file - Pfd::ModelSelectionMode m_modelSelectionMode; + ModelSelectionMode::Enum m_modelSelectionMode; QString m_backgroundImageFile; diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp index 44e324daf..af7d5a7db 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp @@ -88,16 +88,16 @@ QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent) options_page->useOnlyCache->setChecked(m_config->cacheOnly()); // Sky options - options_page->useLocalTime->setChecked(m_config->timeMode() == Pfd::Local); - options_page->usePredefinedTime->setChecked(m_config->timeMode() == Pfd::PredefinedTime); + options_page->useLocalTime->setChecked(m_config->timeMode() == TimeMode::Local); + options_page->usePredefinedTime->setChecked(m_config->timeMode() == TimeMode::Predefined); options_page->dateEdit->setDate(m_config->dateTime().date()); options_page->timeEdit->setTime(m_config->dateTime().time()); options_page->minAmbientLightSpinBox->setValue(m_config->minAmbientLight()); // Model check boxes options_page->showModel->setChecked(m_config->modelEnabled()); - options_page->useAutomaticModel->setChecked(m_config->modelSelectionMode() == Pfd::Auto); - options_page->usePredefinedModel->setChecked(m_config->modelSelectionMode() == Pfd::Fixed); + options_page->useAutomaticModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Auto); + options_page->usePredefinedModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Predefined); // Model file chooser options_page->modelFile->setExpectedKind(Utils::PathChooser::File); @@ -145,9 +145,9 @@ void PfdQmlGadgetOptionsPage::apply() m_config->setCacheOnly(options_page->useOnlyCache->isChecked()); if (options_page->useLocalTime->isChecked()) { - m_config->setTimeMode(Pfd::Local); + m_config->setTimeMode(TimeMode::Local); } else { - m_config->setTimeMode(Pfd::PredefinedTime); + m_config->setTimeMode(TimeMode::Predefined); } QDateTime dateTime(options_page->dateEdit->date(), options_page->timeEdit->time()); m_config->setDateTime(dateTime); @@ -162,9 +162,9 @@ void PfdQmlGadgetOptionsPage::apply() m_config->setModelFile(options_page->modelFile->path()); if (options_page->useAutomaticModel->isChecked()) { - m_config->setModelSelectionMode(Pfd::Auto); + m_config->setModelSelectionMode(ModelSelectionMode::Auto); } else { - m_config->setModelSelectionMode(Pfd::Fixed); + m_config->setModelSelectionMode(ModelSelectionMode::Predefined); } m_config->setBackgroundImageFile(options_page->backgroundImageFile->path()); #else diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlplugin.cpp b/ground/gcs/src/plugins/pfdqml/pfdqmlplugin.cpp index 870684bd3..8530ca1c7 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlplugin.cpp +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlplugin.cpp @@ -59,7 +59,8 @@ bool PfdQmlPlugin::initialize(const QStringList & args, QString *errMsg) OsgEarth::registerQmlTypes(); #endif - Pfd::declareQML(); + ModelSelectionMode::registerQMLTypes(); + TimeMode::registerQMLTypes(); PfdQmlGadgetFactory *mf = new PfdQmlGadgetFactory(this); addAutoReleasedObject(mf); diff --git a/ground/gcs/src/share/qml/CubeView.qml b/ground/gcs/src/share/qml/CubeView.qml index d2d81fd3d..cf87387f5 100644 --- a/ground/gcs/src/share/qml/CubeView.qml +++ b/ground/gcs/src/share/qml/CubeView.qml @@ -1,5 +1,5 @@ import QtQuick 2.4 -import osgQtQuick 1.0 +import OsgQtQuick 1.0 Item { OSGViewport { diff --git a/ground/gcs/src/share/qml/EarthView.qml b/ground/gcs/src/share/qml/EarthView.qml index 271bcd07d..899ba75d3 100644 --- a/ground/gcs/src/share/qml/EarthView.qml +++ b/ground/gcs/src/share/qml/EarthView.qml @@ -1,6 +1,6 @@ import QtQuick 2.4 -import osgQtQuick 1.0 -import PfdQmlEnums 1.0 +import Pfd 1.0 +import OsgQtQuick 1.0 Item { OSGViewport { @@ -17,9 +17,9 @@ Item { function getDateTime() { switch(qmlWidget.timeMode) { - case Pfd.Local: + case TimeMode.Local: return new Date(); - case Pfd.PredefinedTime: + case TimeMode.Predefined: return qmlWidget.dateTime; } } @@ -35,7 +35,7 @@ Item { OSGCamera { id: camera fieldOfView: 90 - manipulatorMode: OSGCamera.Earth + manipulatorMode: ManipulatorMode.Earth } } diff --git a/ground/gcs/src/share/qml/model/ModelTerrainView.qml b/ground/gcs/src/share/qml/model/ModelTerrainView.qml index 2aaf6d37b..1d712a4eb 100644 --- a/ground/gcs/src/share/qml/model/ModelTerrainView.qml +++ b/ground/gcs/src/share/qml/model/ModelTerrainView.qml @@ -1,6 +1,6 @@ import QtQuick 2.4 -import osgQtQuick 1.0 -import PfdQmlEnums 1.0 +import Pfd 1.0 +import OsgQtQuick 1.0 OSGViewport { anchors.fill: parent @@ -16,9 +16,9 @@ OSGViewport { function getDateTime() { switch(qmlWidget.timeMode) { - case Pfd.Local: + case TimeMode.Local: return new Date(); - case Pfd.PredefinedTime: + case TimeMode.Predefined: return qmlWidget.dateTime; } } @@ -34,7 +34,6 @@ OSGViewport { id: terrainNode source: qmlWidget.terrainFile async: false - optimizeMode: OSGFileNode.OptimizeAndCheck } OSGModelNode { @@ -93,14 +92,14 @@ OSGViewport { id: modelFileNode source: qmlWidget.modelFile async: false - optimizeMode: OSGFileNode.OptimizeAndCheck + optimizeMode: OptimizeMode.OptimizeAndCheck } OSGCamera { id: camera fieldOfView: 90 logarithmicDepthBuffer: true - manipulatorMode: OSGCamera.Track + manipulatorMode: ManipulatorMode.Track // use model to compute camera home position node: modelTransformNode // model will be tracked diff --git a/ground/gcs/src/share/qml/model/ModelView.qml b/ground/gcs/src/share/qml/model/ModelView.qml index 4668bbb5e..6e1673e2d 100644 --- a/ground/gcs/src/share/qml/model/ModelView.qml +++ b/ground/gcs/src/share/qml/model/ModelView.qml @@ -1,6 +1,5 @@ import QtQuick 2.4 -import osgQtQuick 1.0 -import PfdQmlEnums 1.0 +import OsgQtQuick 1.0 Item { @@ -34,7 +33,7 @@ Item { id: fileNode source: qmlWidget.modelFile async: false - optimizeMode: OSGFileNode.OptimizeAndCheck + optimizeMode: OptimizeMode.OptimizeAndCheck } OSGCamera { diff --git a/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml b/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml index 0289b79a4..ab9d3961f 100644 --- a/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml +++ b/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml @@ -1,6 +1,6 @@ import QtQuick 2.4 -import osgQtQuick 1.0 -import PfdQmlEnums 1.0 +import Pfd 1.0 +import OsgQtQuick 1.0 OSGViewport { id: fullview @@ -26,9 +26,9 @@ OSGViewport { function getDateTime() { switch(qmlWidget.timeMode) { - case Pfd.Local: + case TimeMode.Local: return new Date(); - case Pfd.PredefinedTime: + case TimeMode.Predefined: return qmlWidget.dateTime; } } @@ -47,7 +47,7 @@ OSGViewport { sceneData: terrainNode logarithmicDepthBuffer: true clampToTerrain: true - manipulatorMode: OSGCamera.User + manipulatorMode: ManipulatorMode.User attitude: uavAttitude() position: uavPosition()