1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-31 16:52:10 +01:00

LP-30 global enum cleanup

This commit is contained in:
Philippe Renon 2015-11-21 15:37:39 +01:00
parent 618654b485
commit b873d37a8f
21 changed files with 159 additions and 142 deletions

View File

@ -67,8 +67,8 @@ public:
public: public:
Hidden(OSGCamera *parent) : Hidden(OSGCamera *parent) :
QObject(parent), sceneData(NULL), manipulatorMode(Default), node(NULL), QObject(parent), sceneData(NULL), manipulatorMode(ManipulatorMode::Default), node(NULL),
trackerMode(NodeCenterAndAzim), trackNode(NULL), trackerMode(TrackerMode::NodeCenterAndAzim), trackNode(NULL),
logDepthBufferEnabled(false), logDepthBuffer(NULL), clampToTerrain(false) logDepthBufferEnabled(false), logDepthBuffer(NULL), clampToTerrain(false)
{ {
fieldOfView = 90.0; fieldOfView = 90.0;
@ -107,7 +107,7 @@ public:
return true; return true;
} }
bool acceptManipulatorMode(ManipulatorMode mode) bool acceptManipulatorMode(ManipulatorMode::Enum mode)
{ {
// qDebug() << "OSGCamera::acceptManipulatorMode" << mode; // qDebug() << "OSGCamera::acceptManipulatorMode" << mode;
if (manipulatorMode == mode) { if (manipulatorMode == mode) {
@ -225,7 +225,7 @@ public:
osgGA::CameraManipulator *cm = NULL; osgGA::CameraManipulator *cm = NULL;
switch (manipulatorMode) { switch (manipulatorMode) {
case OSGCamera::Default: case ManipulatorMode::Default:
{ {
qDebug() << "OSGCamera::attachManipulator - use TrackballManipulator"; qDebug() << "OSGCamera::attachManipulator - use TrackballManipulator";
osgGA::TrackballManipulator *tm = new osgGA::TrackballManipulator(); osgGA::TrackballManipulator *tm = new osgGA::TrackballManipulator();
@ -234,12 +234,12 @@ public:
cm = tm; cm = tm;
break; break;
} }
case OSGCamera::User: case ManipulatorMode::User:
qDebug() << "OSGCamera::attachManipulator - no camera manipulator"; qDebug() << "OSGCamera::attachManipulator - no camera manipulator";
// disable any installed camera manipulator // disable any installed camera manipulator
cm = NULL; cm = NULL;
break; break;
case OSGCamera::Earth: case ManipulatorMode::Earth:
{ {
qDebug() << "OSGCamera::attachManipulator - use EarthManipulator"; qDebug() << "OSGCamera::attachManipulator - use EarthManipulator";
osgEarth::Util::EarthManipulator *em = new osgEarth::Util::EarthManipulator(); osgEarth::Util::EarthManipulator *em = new osgEarth::Util::EarthManipulator();
@ -247,7 +247,7 @@ public:
cm = em; cm = em;
break; break;
} }
case OSGCamera::Track: case ManipulatorMode::Track:
qDebug() << "OSGCamera::attachManipulator - use NodeTrackerManipulator"; qDebug() << "OSGCamera::attachManipulator - use NodeTrackerManipulator";
if (trackNode && trackNode->node()) { if (trackNode && trackNode->node()) {
// setup tracking camera // setup tracking camera
@ -256,13 +256,13 @@ public:
osgGA::NodeTrackerManipulator *ntm = new osgGA::NodeTrackerManipulator( osgGA::NodeTrackerManipulator *ntm = new osgGA::NodeTrackerManipulator(
/*osgGA::StandardManipulator::COMPUTE_HOME_USING_BBOX | osgGA::StandardManipulator::DEFAULT_SETTINGS*/); /*osgGA::StandardManipulator::COMPUTE_HOME_USING_BBOX | osgGA::StandardManipulator::DEFAULT_SETTINGS*/);
switch (trackerMode) { switch (trackerMode) {
case NodeCenter: case TrackerMode::NodeCenter:
ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER); ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER);
break; break;
case NodeCenterAndAzim: case TrackerMode::NodeCenterAndAzim:
ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM); ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM);
break; break;
case NodeCenterAndRotation: case TrackerMode::NodeCenterAndRotation:
ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION); ntm->setTrackerMode(osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION);
break; break;
} }
@ -301,7 +301,7 @@ public:
void updateCamera() void updateCamera()
{ {
updateCameraFOV(); updateCameraFOV();
if (manipulatorMode == User) { if (manipulatorMode == ManipulatorMode::User) {
updateCameraPosition(); updateCameraPosition();
} }
} }
@ -386,13 +386,13 @@ public:
OSGNode *sceneData; OSGNode *sceneData;
ManipulatorMode manipulatorMode; ManipulatorMode::Enum manipulatorMode;
// to compute home position // to compute home position
OSGNode *node; OSGNode *node;
// for NodeTrackerManipulator // for NodeTrackerManipulator
TrackerMode trackerMode; TrackerMode::Enum trackerMode;
OSGNode *trackNode; OSGNode *trackNode;
bool logDepthBufferEnabled; bool logDepthBufferEnabled;
@ -473,12 +473,12 @@ void OSGCamera::setSceneData(OSGNode *node)
} }
} }
OSGCamera::ManipulatorMode OSGCamera::manipulatorMode() const ManipulatorMode::Enum OSGCamera::manipulatorMode() const
{ {
return h->manipulatorMode; return h->manipulatorMode;
} }
void OSGCamera::setManipulatorMode(ManipulatorMode mode) void OSGCamera::setManipulatorMode(ManipulatorMode::Enum mode)
{ {
if (h->acceptManipulatorMode(mode)) { if (h->acceptManipulatorMode(mode)) {
emit manipulatorModeChanged(manipulatorMode()); 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; return h->trackerMode;
} }
void OSGCamera::setTrackerMode(TrackerMode mode) void OSGCamera::setTrackerMode(TrackerMode::Enum mode)
{ {
if (h->trackerMode != mode) { if (h->trackerMode != mode) {
h->trackerMode = mode; h->trackerMode = mode;

View File

@ -40,6 +40,20 @@ class View;
namespace osgQtQuick { namespace osgQtQuick {
class OSGNode; 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: // This class does too much:
// - tracking a geo point and attitude // - tracking a geo point and attitude
// - tracking another node // - tracking another node
@ -52,32 +66,18 @@ class OSGNode;
// - provide good default distance and attitude for tracker camera // - provide good default distance and attitude for tracker camera
class OSGQTQUICK_EXPORT OSGCamera : public QObject { class OSGQTQUICK_EXPORT OSGCamera : public QObject {
Q_OBJECT Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) 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(osgQtQuick::OSGNode * sceneData READ sceneData WRITE setSceneData NOTIFY sceneDataChanged)
Q_PROPERTY(osgQtQuick::ManipulatorMode::Enum manipulatorMode READ manipulatorMode WRITE setManipulatorMode NOTIFY manipulatorModeChanged)
Q_PROPERTY(ManipulatorMode manipulatorMode READ manipulatorMode WRITE setManipulatorMode NOTIFY manipulatorModeChanged)
Q_PROPERTY(osgQtQuick::OSGNode * node READ node WRITE setNode NOTIFY nodeChanged) Q_PROPERTY(osgQtQuick::OSGNode * node READ node WRITE setNode NOTIFY nodeChanged)
Q_PROPERTY(osgQtQuick::OSGNode * trackNode READ trackNode WRITE setTrackNode NOTIFY trackNodeChanged) 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 clampToTerrain READ clampToTerrain WRITE setClampToTerrain NOTIFY clampToTerrainChanged)
Q_PROPERTY(bool intoTerrain READ intoTerrain NOTIFY intoTerrainChanged) Q_PROPERTY(bool intoTerrain READ intoTerrain NOTIFY intoTerrainChanged)
Q_PROPERTY(QVector3D attitude READ attitude WRITE setAttitude NOTIFY attitudeChanged) Q_PROPERTY(QVector3D attitude READ attitude WRITE setAttitude NOTIFY attitudeChanged)
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged) Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(bool logarithmicDepthBuffer READ logarithmicDepthBuffer WRITE setLogarithmicDepthBuffer NOTIFY logarithmicDepthBufferChanged) Q_PROPERTY(bool logarithmicDepthBuffer READ logarithmicDepthBuffer WRITE setLogarithmicDepthBuffer NOTIFY logarithmicDepthBufferChanged)
Q_ENUMS(ManipulatorMode)
Q_ENUMS(TrackerMode)
public: public:
enum ManipulatorMode { Default, Earth, Track, User };
enum TrackerMode { NodeCenter, NodeCenterAndAzim, NodeCenterAndRotation };
explicit OSGCamera(QObject *parent = 0); explicit OSGCamera(QObject *parent = 0);
virtual ~OSGCamera(); virtual ~OSGCamera();
@ -91,8 +91,8 @@ public:
OSGNode *sceneData(); OSGNode *sceneData();
void setSceneData(OSGNode *node); void setSceneData(OSGNode *node);
ManipulatorMode manipulatorMode() const; ManipulatorMode::Enum manipulatorMode() const;
void setManipulatorMode(ManipulatorMode); void setManipulatorMode(ManipulatorMode::Enum);
OSGNode *node() const; OSGNode *node() const;
void setNode(OSGNode *node); void setNode(OSGNode *node);
@ -100,8 +100,8 @@ public:
OSGNode *trackNode() const; OSGNode *trackNode() const;
void setTrackNode(OSGNode *node); void setTrackNode(OSGNode *node);
TrackerMode trackerMode() const; TrackerMode::Enum trackerMode() const;
void setTrackerMode(TrackerMode); void setTrackerMode(TrackerMode::Enum);
bool clampToTerrain() const; bool clampToTerrain() const;
void setClampToTerrain(bool arg); void setClampToTerrain(bool arg);
@ -125,12 +125,12 @@ signals:
void sceneDataChanged(OSGNode *node); void sceneDataChanged(OSGNode *node);
void manipulatorModeChanged(ManipulatorMode); void manipulatorModeChanged(ManipulatorMode::Enum);
void nodeChanged(OSGNode *node); void nodeChanged(OSGNode *node);
void trackNodeChanged(OSGNode *node); void trackNodeChanged(OSGNode *node);
void trackerModeChanged(TrackerMode); void trackerModeChanged(TrackerMode::Enum);
void clampToTerrainChanged(bool arg); void clampToTerrainChanged(bool arg);
void intoTerrainChanged(bool arg); void intoTerrainChanged(bool arg);

View File

@ -75,7 +75,7 @@ private:
OSGFileNode * const self; OSGFileNode * const self;
public: 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) bool acceptSource(QUrl url)
{ {
@ -99,7 +99,7 @@ public:
QUrl url; QUrl url;
bool async; bool async;
OptimizeMode optimizeMode; OptimizeMode::Enum optimizeMode;
private: private:
@ -133,7 +133,7 @@ private:
bool acceptNode(osg::Node *node) bool acceptNode(osg::Node *node)
{ {
qDebug() << "OSGFileNode::acceptNode" << node; qDebug() << "OSGFileNode::acceptNode" << node;
if (node && optimizeMode != OSGFileNode::None) { if (node && optimizeMode != OptimizeMode::None) {
// qDebug() << "OSGFileNode::acceptNode - optimize" << node << optimizeMode; // qDebug() << "OSGFileNode::acceptNode - optimize" << node << optimizeMode;
osgUtil::Optimizer optimizer; osgUtil::Optimizer optimizer;
optimizer.optimize(node, osgUtil::Optimizer::DEFAULT_OPTIMIZATIONS); 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; return h->optimizeMode;
} }
void OSGFileNode::setOptimizeMode(OptimizeMode mode) void OSGFileNode::setOptimizeMode(OptimizeMode::Enum mode)
{ {
// qDebug() << "OSGFileNode::setOptimizeMode" << mode; // qDebug() << "OSGFileNode::setOptimizeMode" << mode;
if (h->optimizeMode != mode) { if (h->optimizeMode != mode) {

View File

@ -37,15 +37,20 @@ class QUrl;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace osgQtQuick { 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 { class OSGQTQUICK_EXPORT OSGFileNode : public OSGNode {
Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(bool async READ async WRITE setAsync NOTIFY asyncChanged) Q_PROPERTY(bool async READ async WRITE setAsync NOTIFY asyncChanged)
Q_PROPERTY(OptimizeMode optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged) Q_PROPERTY(osgQtQuick::OptimizeMode::Enum optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged)
Q_ENUMS(OptimizeMode)
public: public:
enum OptimizeMode { None, Optimize, OptimizeAndCheck };
OSGFileNode(QObject *parent = 0); OSGFileNode(QObject *parent = 0);
virtual ~OSGFileNode(); virtual ~OSGFileNode();
@ -56,13 +61,13 @@ public:
bool async() const; bool async() const;
void setAsync(const bool async); void setAsync(const bool async);
OptimizeMode optimizeMode() const; OptimizeMode::Enum optimizeMode() const;
void setOptimizeMode(OptimizeMode); void setOptimizeMode(OptimizeMode::Enum);
signals: signals:
void sourceChanged(const QUrl &url); void sourceChanged(const QUrl &url);
void asyncChanged(const bool async); void asyncChanged(const bool async);
void optimizeModeChanged(OptimizeMode); void optimizeModeChanged(OptimizeMode::Enum);
private: private:
struct Hidden; struct Hidden;

View File

@ -86,7 +86,7 @@ public:
window(NULL), window(NULL),
sceneData(NULL), sceneData(NULL),
camera(NULL), camera(NULL),
updateMode(Discrete), updateMode(UpdateMode::Discrete),
frameTimer(-1) frameTimer(-1)
{ {
qDebug() << "OSGViewport::Hidden"; qDebug() << "OSGViewport::Hidden";
@ -258,7 +258,7 @@ public:
// view->getCamera()->setGraphicsContext(NULL); // view->getCamera()->setGraphicsContext(NULL);
} }
bool acceptUpdateMode(OSGViewport::UpdateMode mode) bool acceptUpdateMode(UpdateMode::Enum mode)
{ {
// qDebug() << "OSGViewport::acceptUpdateMode" << mode; // qDebug() << "OSGViewport::acceptUpdateMode" << mode;
if (updateMode == mode) { if (updateMode == mode) {
@ -289,7 +289,7 @@ public:
OSGNode *sceneData; OSGNode *sceneData;
OSGCamera *camera; OSGCamera *camera;
OSGViewport::UpdateMode updateMode; UpdateMode::Enum updateMode;
int frameTimer; int frameTimer;
@ -420,7 +420,7 @@ public:
void start() void start()
{ {
if (updateMode == OSGViewport::Discrete && (frameTimer < 0)) { if (updateMode == UpdateMode::Discrete && (frameTimer < 0)) {
qDebug() << "OSGViewport::start - starting timer"; qDebug() << "OSGViewport::start - starting timer";
frameTimer = startTimer(33, Qt::PreciseTimer); frameTimer = startTimer(33, Qt::PreciseTimer);
} }
@ -514,7 +514,7 @@ public:
h->viewer->frame(); h->viewer->frame();
} }
if (h->updateMode == OSGViewport::Continuous) { if (h->updateMode == UpdateMode::Continuous) {
// trigger next update // trigger next update
update(); update();
} }
@ -559,12 +559,12 @@ OSGViewport::~OSGViewport()
qDebug() << "OSGViewport::~OSGViewport"; qDebug() << "OSGViewport::~OSGViewport";
} }
OSGViewport::UpdateMode OSGViewport::updateMode() const UpdateMode::Enum OSGViewport::updateMode() const
{ {
return h->updateMode; return h->updateMode;
} }
void OSGViewport::setUpdateMode(OSGViewport::UpdateMode mode) void OSGViewport::setUpdateMode(UpdateMode::Enum mode)
{ {
if (h->acceptUpdateMode(mode)) { if (h->acceptUpdateMode(mode)) {
emit updateModeChanged(updateMode()); emit updateModeChanged(updateMode());

View File

@ -41,30 +41,27 @@ class Renderer;
class OSGNode; class OSGNode;
class OSGCamera; 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 { class OSGQTQUICK_EXPORT OSGViewport : public QQuickFramebufferObject {
Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) 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::OSGNode * sceneData READ sceneData WRITE setSceneData NOTIFY sceneDataChanged)
Q_PROPERTY(osgQtQuick::OSGCamera * camera READ camera WRITE setCamera NOTIFY cameraChanged) Q_PROPERTY(osgQtQuick::OSGCamera * camera READ camera WRITE setCamera NOTIFY cameraChanged)
Q_ENUMS(UpdateMode)
public: public:
friend class ViewportRenderer; friend class ViewportRenderer;
// TODO rename to UpdateMode or something better
enum UpdateMode {
Continuous,
Discrete,
OnDemand
};
explicit OSGViewport(QQuickItem *parent = 0); explicit OSGViewport(QQuickItem *parent = 0);
virtual ~OSGViewport(); virtual ~OSGViewport();
UpdateMode updateMode() const; UpdateMode::Enum updateMode() const;
void setUpdateMode(UpdateMode mode); void setUpdateMode(UpdateMode::Enum mode);
QColor color() const; QColor color() const;
void setColor(const QColor &color); void setColor(const QColor &color);
@ -82,7 +79,7 @@ public:
virtual bool detach(osgViewer::View *view); virtual bool detach(osgViewer::View *view);
signals: signals:
void updateModeChanged(UpdateMode mode); void updateModeChanged(UpdateMode::Enum mode);
void colorChanged(const QColor &color); void colorChanged(const QColor &color);
void sceneDataChanged(OSGNode *node); void sceneDataChanged(OSGNode *node);
void cameraChanged(OSGCamera *camera); void cameraChanged(OSGCamera *camera);

View File

@ -72,7 +72,8 @@ void OsgEarth::registerQmlTypes()
// initialize(); // initialize();
// Register Qml types // Register Qml types
osgQtQuick::registerTypes("osgQtQuick"); qDebug() << "OsgEarth::registerQmlTypes - registering Qml types...";
osgQtQuick::registerTypes();
} }
void OsgEarth::initialize() void OsgEarth::initialize()

View File

@ -499,23 +499,26 @@ QString getUsageString(osgViewer::CompositeViewer *viewer)
return getUsageString(applicationUsage); return getUsageString(applicationUsage);
} }
void registerTypes(const char *uri) void registerTypes()
{ {
// Q_ASSERT(uri == QLatin1String("osgQtQuick"));
int maj = 1, min = 0; int maj = 1, min = 0;
// @uri osgQtQuick // @uri osgQtQuick
qmlRegisterType<osgQtQuick::OSGNode>(uri, maj, min, "OSGNode"); qmlRegisterType<osgQtQuick::OSGNode>("OsgQtQuick", maj, min, "OSGNode");
qmlRegisterType<osgQtQuick::OSGGroup>(uri, maj, min, "OSGGroup"); qmlRegisterType<osgQtQuick::OSGGroup>("OsgQtQuick", maj, min, "OSGGroup");
qmlRegisterType<osgQtQuick::OSGFileNode>(uri, maj, min, "OSGFileNode"); qmlRegisterType<osgQtQuick::OSGFileNode>("OsgQtQuick", maj, min, "OSGFileNode");
qmlRegisterType<osgQtQuick::OSGTransformNode>(uri, maj, min, "OSGTransformNode"); qmlRegisterType<osgQtQuick::OptimizeMode>("OsgQtQuick", maj, min, "OptimizeMode");
qmlRegisterType<osgQtQuick::OSGTextNode>(uri, maj, min, "OSGTextNode"); qmlRegisterType<osgQtQuick::OSGTransformNode>("OsgQtQuick", maj, min, "OSGTransformNode");
qmlRegisterType<osgQtQuick::OSGCubeNode>(uri, maj, min, "OSGCubeNode"); qmlRegisterType<osgQtQuick::OSGTextNode>("OsgQtQuick", maj, min, "OSGTextNode");
qmlRegisterType<osgQtQuick::OSGViewport>(uri, maj, min, "OSGViewport"); qmlRegisterType<osgQtQuick::OSGCubeNode>("OsgQtQuick", maj, min, "OSGCubeNode");
qmlRegisterType<osgQtQuick::OSGViewport>("OsgQtQuick", maj, min, "OSGViewport");
qmlRegisterType<osgQtQuick::UpdateMode>("OsgQtQuick", maj, min, "UpdateMode");
qmlRegisterType<osgQtQuick::OSGModelNode>(uri, maj, min, "OSGModelNode"); qmlRegisterType<osgQtQuick::OSGModelNode>("OsgQtQuick", maj, min, "OSGModelNode");
qmlRegisterType<osgQtQuick::OSGSkyNode>(uri, maj, min, "OSGSkyNode"); qmlRegisterType<osgQtQuick::OSGSkyNode>("OsgQtQuick", maj, min, "OSGSkyNode");
qmlRegisterType<osgQtQuick::OSGBackgroundNode>(uri, maj, min, "OSGBackgroundNode"); qmlRegisterType<osgQtQuick::OSGBackgroundNode>("OsgQtQuick", maj, min, "OSGBackgroundNode");
qmlRegisterType<osgQtQuick::OSGCamera>(uri, maj, min, "OSGCamera"); qmlRegisterType<osgQtQuick::OSGCamera>("OsgQtQuick", maj, min, "OSGCamera");
qmlRegisterType<osgQtQuick::ManipulatorMode>("OsgQtQuick", maj, min, "ManipulatorMode");
qmlRegisterType<osgQtQuick::TrackerMode>("OsgQtQuick", maj, min, "TrackerMode");
} }
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -146,7 +146,7 @@ QString formatSwapBehaviorName(QSurfaceFormat::SwapBehavior swapBehavior);
QString getUsageString(osgViewer::Viewer *viewer); QString getUsageString(osgViewer::Viewer *viewer);
QString getUsageString(osgViewer::CompositeViewer *viewer); QString getUsageString(osgViewer::CompositeViewer *viewer);
void registerTypes(const char *uri); void registerTypes();
} // namespace osgQtQuick } // namespace osgQtQuick
#endif // OSGEARTH_UTILITY_H #endif // OSGEARTH_UTILITY_H

View File

@ -31,17 +31,29 @@
#include <QObject> #include <QObject>
#include <QtQml> #include <QtQml>
class Pfd : public QObject { class ModelSelectionMode : public QObject {
Q_OBJECT Q_ENUMS(PositionMode) Q_OBJECT
Q_ENUMS(TimeMode)
public: public:
enum ModelSelectionMode { Auto, Fixed }; enum Enum { Auto, Predefined };
enum TimeMode { Local, PredefinedTime }; Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5
static void declareQML() static void registerQMLTypes()
{ {
qmlRegisterType<Pfd>("PfdQmlEnums", 1, 0, "Pfd"); qmlRegisterType<ModelSelectionMode>("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<TimeMode>("Pfd", 1, 0, "TimeMode");
} }
}; };

View File

@ -45,7 +45,7 @@ PfdQmlContext::PfdQmlContext(QObject *parent) : QObject(parent),
m_latitude(39.657380), m_latitude(39.657380),
m_longitude(19.805158), m_longitude(19.805158),
m_altitude(100), m_altitude(100),
m_timeMode(Pfd::Local), m_timeMode(TimeMode::Local),
m_dateTime(QDateTime()), m_dateTime(QDateTime()),
m_minAmbientLight(0.03), m_minAmbientLight(0.03),
m_modelFile(""), m_modelFile(""),
@ -172,12 +172,12 @@ void PfdQmlContext::setAltitude(double arg)
} }
} }
Pfd::TimeMode PfdQmlContext::timeMode() const TimeMode::Enum PfdQmlContext::timeMode() const
{ {
return m_timeMode; return m_timeMode;
} }
void PfdQmlContext::setTimeMode(Pfd::TimeMode arg) void PfdQmlContext::setTimeMode(TimeMode::Enum arg)
{ {
if (m_timeMode != arg) { if (m_timeMode != arg) {
m_timeMode = arg; m_timeMode = arg;

View File

@ -47,7 +47,7 @@ class PfdQmlContext : public QObject {
Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged) Q_PROPERTY(double longitude READ longitude WRITE setLongitude NOTIFY longitudeChanged)
Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged) 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(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
Q_PROPERTY(double minimumAmbientLight READ minimumAmbientLight WRITE setMinimumAmbientLight NOTIFY minimumAmbientLightChanged) Q_PROPERTY(double minimumAmbientLight READ minimumAmbientLight WRITE setMinimumAmbientLight NOTIFY minimumAmbientLightChanged)
@ -79,8 +79,8 @@ public:
double altitude() const; double altitude() const;
void setAltitude(double arg); void setAltitude(double arg);
Pfd::TimeMode timeMode() const; TimeMode::Enum timeMode() const;
void setTimeMode(Pfd::TimeMode arg); void setTimeMode(TimeMode::Enum arg);
QDateTime dateTime() const; QDateTime dateTime() const;
void setDateTime(QDateTime arg); void setDateTime(QDateTime arg);
double minimumAmbientLight() const; double minimumAmbientLight() const;
@ -109,7 +109,7 @@ signals:
void longitudeChanged(double arg); void longitudeChanged(double arg);
void altitudeChanged(double arg); void altitudeChanged(double arg);
void timeModeChanged(Pfd::TimeMode arg); void timeModeChanged(TimeMode::Enum arg);
void dateTimeChanged(QDateTime arge); void dateTimeChanged(QDateTime arge);
void minimumAmbientLightChanged(double arg); void minimumAmbientLightChanged(double arg);
@ -129,7 +129,7 @@ private:
double m_longitude; double m_longitude;
double m_altitude; double m_altitude;
Pfd::TimeMode m_timeMode; TimeMode::Enum m_timeMode;
QDateTime m_dateTime; QDateTime m_dateTime;
double m_minAmbientLight; double m_minAmbientLight;

View File

@ -43,12 +43,12 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
m_latitude(0), m_latitude(0),
m_longitude(0), m_longitude(0),
m_altitude(0), m_altitude(0),
m_timeMode(Pfd::Local), m_timeMode(TimeMode::Local),
m_dateTime(QDateTime()), m_dateTime(QDateTime()),
m_minAmbientLight(0), m_minAmbientLight(0),
m_modelEnabled(false), m_modelEnabled(false),
m_modelFile("Unknown"), m_modelFile("Unknown"),
m_modelSelectionMode(Pfd::Auto), m_modelSelectionMode(ModelSelectionMode::Auto),
m_backgroundImageFile("Unknown") m_backgroundImageFile("Unknown")
{ {
m_speedMap[1.0] = "m/s"; m_speedMap[1.0] = "m/s";
@ -78,13 +78,13 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings
m_altitude = qSettings->value("altitude").toDouble(); m_altitude = qSettings->value("altitude").toDouble();
// sky // sky
m_timeMode = static_cast<Pfd::TimeMode>(qSettings->value("timeMode").toUInt()); m_timeMode = static_cast<TimeMode::Enum>(qSettings->value("timeMode").toUInt());
m_dateTime = qSettings->value("dateTime").toDateTime(); m_dateTime = qSettings->value("dateTime").toDateTime();
m_minAmbientLight = qSettings->value("minAmbientLight").toDouble(); m_minAmbientLight = qSettings->value("minAmbientLight").toDouble();
// model // model
m_modelEnabled = qSettings->value("modelEnabled").toBool(); m_modelEnabled = qSettings->value("modelEnabled").toBool();
m_modelSelectionMode = static_cast<Pfd::ModelSelectionMode>(qSettings->value("modelSelectionMode").toUInt()); m_modelSelectionMode = static_cast<ModelSelectionMode::Enum>(qSettings->value("modelSelectionMode").toUInt());
m_modelFile = qSettings->value("modelFile").toString(); m_modelFile = qSettings->value("modelFile").toString();
m_modelFile = Utils::InsertDataPath(m_modelFile); m_modelFile = Utils::InsertDataPath(m_modelFile);

View File

@ -133,11 +133,11 @@ public:
return m_cacheOnly; return m_cacheOnly;
} }
Pfd::TimeMode timeMode() const TimeMode::Enum timeMode() const
{ {
return m_timeMode; return m_timeMode;
} }
void setTimeMode(Pfd::TimeMode timeMode) void setTimeMode(TimeMode::Enum timeMode)
{ {
m_timeMode = timeMode; m_timeMode = timeMode;
} }
@ -178,11 +178,11 @@ public:
m_modelFile = fileName; m_modelFile = fileName;
} }
Pfd::ModelSelectionMode modelSelectionMode() const ModelSelectionMode::Enum modelSelectionMode() const
{ {
return m_modelSelectionMode; return m_modelSelectionMode;
} }
void setModelSelectionMode(Pfd::ModelSelectionMode modelSelectionMode) void setModelSelectionMode(ModelSelectionMode::Enum modelSelectionMode)
{ {
m_modelSelectionMode = modelSelectionMode; m_modelSelectionMode = modelSelectionMode;
} }
@ -223,13 +223,13 @@ private:
double m_longitude; double m_longitude;
double m_altitude; double m_altitude;
Pfd::TimeMode m_timeMode; TimeMode::Enum m_timeMode;
QDateTime m_dateTime; QDateTime m_dateTime;
double m_minAmbientLight; double m_minAmbientLight;
bool m_modelEnabled; bool m_modelEnabled;
QString m_modelFile; // The name of model file QString m_modelFile; // The name of model file
Pfd::ModelSelectionMode m_modelSelectionMode; ModelSelectionMode::Enum m_modelSelectionMode;
QString m_backgroundImageFile; QString m_backgroundImageFile;

View File

@ -88,16 +88,16 @@ QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent)
options_page->useOnlyCache->setChecked(m_config->cacheOnly()); options_page->useOnlyCache->setChecked(m_config->cacheOnly());
// Sky options // Sky options
options_page->useLocalTime->setChecked(m_config->timeMode() == Pfd::Local); options_page->useLocalTime->setChecked(m_config->timeMode() == TimeMode::Local);
options_page->usePredefinedTime->setChecked(m_config->timeMode() == Pfd::PredefinedTime); options_page->usePredefinedTime->setChecked(m_config->timeMode() == TimeMode::Predefined);
options_page->dateEdit->setDate(m_config->dateTime().date()); options_page->dateEdit->setDate(m_config->dateTime().date());
options_page->timeEdit->setTime(m_config->dateTime().time()); options_page->timeEdit->setTime(m_config->dateTime().time());
options_page->minAmbientLightSpinBox->setValue(m_config->minAmbientLight()); options_page->minAmbientLightSpinBox->setValue(m_config->minAmbientLight());
// Model check boxes // Model check boxes
options_page->showModel->setChecked(m_config->modelEnabled()); options_page->showModel->setChecked(m_config->modelEnabled());
options_page->useAutomaticModel->setChecked(m_config->modelSelectionMode() == Pfd::Auto); options_page->useAutomaticModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Auto);
options_page->usePredefinedModel->setChecked(m_config->modelSelectionMode() == Pfd::Fixed); options_page->usePredefinedModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Predefined);
// Model file chooser // Model file chooser
options_page->modelFile->setExpectedKind(Utils::PathChooser::File); options_page->modelFile->setExpectedKind(Utils::PathChooser::File);
@ -145,9 +145,9 @@ void PfdQmlGadgetOptionsPage::apply()
m_config->setCacheOnly(options_page->useOnlyCache->isChecked()); m_config->setCacheOnly(options_page->useOnlyCache->isChecked());
if (options_page->useLocalTime->isChecked()) { if (options_page->useLocalTime->isChecked()) {
m_config->setTimeMode(Pfd::Local); m_config->setTimeMode(TimeMode::Local);
} else { } else {
m_config->setTimeMode(Pfd::PredefinedTime); m_config->setTimeMode(TimeMode::Predefined);
} }
QDateTime dateTime(options_page->dateEdit->date(), options_page->timeEdit->time()); QDateTime dateTime(options_page->dateEdit->date(), options_page->timeEdit->time());
m_config->setDateTime(dateTime); m_config->setDateTime(dateTime);
@ -162,9 +162,9 @@ void PfdQmlGadgetOptionsPage::apply()
m_config->setModelFile(options_page->modelFile->path()); m_config->setModelFile(options_page->modelFile->path());
if (options_page->useAutomaticModel->isChecked()) { if (options_page->useAutomaticModel->isChecked()) {
m_config->setModelSelectionMode(Pfd::Auto); m_config->setModelSelectionMode(ModelSelectionMode::Auto);
} else { } else {
m_config->setModelSelectionMode(Pfd::Fixed); m_config->setModelSelectionMode(ModelSelectionMode::Predefined);
} }
m_config->setBackgroundImageFile(options_page->backgroundImageFile->path()); m_config->setBackgroundImageFile(options_page->backgroundImageFile->path());
#else #else

View File

@ -59,7 +59,8 @@ bool PfdQmlPlugin::initialize(const QStringList & args, QString *errMsg)
OsgEarth::registerQmlTypes(); OsgEarth::registerQmlTypes();
#endif #endif
Pfd::declareQML(); ModelSelectionMode::registerQMLTypes();
TimeMode::registerQMLTypes();
PfdQmlGadgetFactory *mf = new PfdQmlGadgetFactory(this); PfdQmlGadgetFactory *mf = new PfdQmlGadgetFactory(this);
addAutoReleasedObject(mf); addAutoReleasedObject(mf);

View File

@ -1,5 +1,5 @@
import QtQuick 2.4 import QtQuick 2.4
import osgQtQuick 1.0 import OsgQtQuick 1.0
Item { Item {
OSGViewport { OSGViewport {

View File

@ -1,6 +1,6 @@
import QtQuick 2.4 import QtQuick 2.4
import osgQtQuick 1.0 import Pfd 1.0
import PfdQmlEnums 1.0 import OsgQtQuick 1.0
Item { Item {
OSGViewport { OSGViewport {
@ -17,9 +17,9 @@ Item {
function getDateTime() { function getDateTime() {
switch(qmlWidget.timeMode) { switch(qmlWidget.timeMode) {
case Pfd.Local: case TimeMode.Local:
return new Date(); return new Date();
case Pfd.PredefinedTime: case TimeMode.Predefined:
return qmlWidget.dateTime; return qmlWidget.dateTime;
} }
} }
@ -35,7 +35,7 @@ Item {
OSGCamera { OSGCamera {
id: camera id: camera
fieldOfView: 90 fieldOfView: 90
manipulatorMode: OSGCamera.Earth manipulatorMode: ManipulatorMode.Earth
} }
} }

View File

@ -1,6 +1,6 @@
import QtQuick 2.4 import QtQuick 2.4
import osgQtQuick 1.0 import Pfd 1.0
import PfdQmlEnums 1.0 import OsgQtQuick 1.0
OSGViewport { OSGViewport {
anchors.fill: parent anchors.fill: parent
@ -16,9 +16,9 @@ OSGViewport {
function getDateTime() { function getDateTime() {
switch(qmlWidget.timeMode) { switch(qmlWidget.timeMode) {
case Pfd.Local: case TimeMode.Local:
return new Date(); return new Date();
case Pfd.PredefinedTime: case TimeMode.Predefined:
return qmlWidget.dateTime; return qmlWidget.dateTime;
} }
} }
@ -34,7 +34,6 @@ OSGViewport {
id: terrainNode id: terrainNode
source: qmlWidget.terrainFile source: qmlWidget.terrainFile
async: false async: false
optimizeMode: OSGFileNode.OptimizeAndCheck
} }
OSGModelNode { OSGModelNode {
@ -93,14 +92,14 @@ OSGViewport {
id: modelFileNode id: modelFileNode
source: qmlWidget.modelFile source: qmlWidget.modelFile
async: false async: false
optimizeMode: OSGFileNode.OptimizeAndCheck optimizeMode: OptimizeMode.OptimizeAndCheck
} }
OSGCamera { OSGCamera {
id: camera id: camera
fieldOfView: 90 fieldOfView: 90
logarithmicDepthBuffer: true logarithmicDepthBuffer: true
manipulatorMode: OSGCamera.Track manipulatorMode: ManipulatorMode.Track
// use model to compute camera home position // use model to compute camera home position
node: modelTransformNode node: modelTransformNode
// model will be tracked // model will be tracked

View File

@ -1,6 +1,5 @@
import QtQuick 2.4 import QtQuick 2.4
import osgQtQuick 1.0 import OsgQtQuick 1.0
import PfdQmlEnums 1.0
Item { Item {
@ -34,7 +33,7 @@ Item {
id: fileNode id: fileNode
source: qmlWidget.modelFile source: qmlWidget.modelFile
async: false async: false
optimizeMode: OSGFileNode.OptimizeAndCheck optimizeMode: OptimizeMode.OptimizeAndCheck
} }
OSGCamera { OSGCamera {

View File

@ -1,6 +1,6 @@
import QtQuick 2.4 import QtQuick 2.4
import osgQtQuick 1.0 import Pfd 1.0
import PfdQmlEnums 1.0 import OsgQtQuick 1.0
OSGViewport { OSGViewport {
id: fullview id: fullview
@ -26,9 +26,9 @@ OSGViewport {
function getDateTime() { function getDateTime() {
switch(qmlWidget.timeMode) { switch(qmlWidget.timeMode) {
case Pfd.Local: case TimeMode.Local:
return new Date(); return new Date();
case Pfd.PredefinedTime: case TimeMode.Predefined:
return qmlWidget.dateTime; return qmlWidget.dateTime;
} }
} }
@ -47,7 +47,7 @@ OSGViewport {
sceneData: terrainNode sceneData: terrainNode
logarithmicDepthBuffer: true logarithmicDepthBuffer: true
clampToTerrain: true clampToTerrain: true
manipulatorMode: OSGCamera.User manipulatorMode: ManipulatorMode.User
attitude: uavAttitude() attitude: uavAttitude()
position: uavPosition() position: uavPosition()