1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-19 04:52:12 +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:
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;

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

@ -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());

View File

@ -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);

View File

@ -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()

View File

@ -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<osgQtQuick::OSGNode>(uri, maj, min, "OSGNode");
qmlRegisterType<osgQtQuick::OSGGroup>(uri, maj, min, "OSGGroup");
qmlRegisterType<osgQtQuick::OSGFileNode>(uri, maj, min, "OSGFileNode");
qmlRegisterType<osgQtQuick::OSGTransformNode>(uri, maj, min, "OSGTransformNode");
qmlRegisterType<osgQtQuick::OSGTextNode>(uri, maj, min, "OSGTextNode");
qmlRegisterType<osgQtQuick::OSGCubeNode>(uri, maj, min, "OSGCubeNode");
qmlRegisterType<osgQtQuick::OSGViewport>(uri, maj, min, "OSGViewport");
qmlRegisterType<osgQtQuick::OSGNode>("OsgQtQuick", maj, min, "OSGNode");
qmlRegisterType<osgQtQuick::OSGGroup>("OsgQtQuick", maj, min, "OSGGroup");
qmlRegisterType<osgQtQuick::OSGFileNode>("OsgQtQuick", maj, min, "OSGFileNode");
qmlRegisterType<osgQtQuick::OptimizeMode>("OsgQtQuick", maj, min, "OptimizeMode");
qmlRegisterType<osgQtQuick::OSGTransformNode>("OsgQtQuick", maj, min, "OSGTransformNode");
qmlRegisterType<osgQtQuick::OSGTextNode>("OsgQtQuick", maj, min, "OSGTextNode");
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::OSGSkyNode>(uri, maj, min, "OSGSkyNode");
qmlRegisterType<osgQtQuick::OSGBackgroundNode>(uri, maj, min, "OSGBackgroundNode");
qmlRegisterType<osgQtQuick::OSGCamera>(uri, maj, min, "OSGCamera");
qmlRegisterType<osgQtQuick::OSGModelNode>("OsgQtQuick", maj, min, "OSGModelNode");
qmlRegisterType<osgQtQuick::OSGSkyNode>("OsgQtQuick", maj, min, "OSGSkyNode");
qmlRegisterType<osgQtQuick::OSGBackgroundNode>("OsgQtQuick", maj, min, "OSGBackgroundNode");
qmlRegisterType<osgQtQuick::OSGCamera>("OsgQtQuick", maj, min, "OSGCamera");
qmlRegisterType<osgQtQuick::ManipulatorMode>("OsgQtQuick", maj, min, "ManipulatorMode");
qmlRegisterType<osgQtQuick::TrackerMode>("OsgQtQuick", maj, min, "TrackerMode");
}
} // namespace osgQtQuick

View File

@ -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

View File

@ -31,17 +31,29 @@
#include <QObject>
#include <QtQml>
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<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_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;

View File

@ -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;

View File

@ -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<Pfd::TimeMode>(qSettings->value("timeMode").toUInt());
m_timeMode = static_cast<TimeMode::Enum>(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<Pfd::ModelSelectionMode>(qSettings->value("modelSelectionMode").toUInt());
m_modelSelectionMode = static_cast<ModelSelectionMode::Enum>(qSettings->value("modelSelectionMode").toUInt());
m_modelFile = qSettings->value("modelFile").toString();
m_modelFile = Utils::InsertDataPath(m_modelFile);

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

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

View File

@ -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
}
}

View File

@ -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

View File

@ -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 {

View File

@ -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()