1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-29 refactoring and clean ups

This commit is contained in:
Philippe Renon 2016-03-21 21:56:50 +01:00
parent a124ddd5da
commit c16fc656aa
31 changed files with 110 additions and 78 deletions

View File

@ -83,7 +83,7 @@ public:
/* class OSGBackgroundNode */ /* class OSGBackgroundNode */
OSGBackgroundNode::OSGBackgroundNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGBackgroundNode::OSGBackgroundNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGBackgroundNode::~OSGBackgroundNode() OSGBackgroundNode::~OSGBackgroundNode()
@ -108,6 +108,8 @@ void OSGBackgroundNode::setImageFile(const QUrl &url)
void OSGBackgroundNode::update() void OSGBackgroundNode::update()
{ {
Inherited::update();
if (isDirty(URL)) { if (isDirty(URL)) {
h->updateURL(); h->updateURL();
} }

View File

@ -40,6 +40,8 @@ namespace osgQtQuick {
class OSGQTQUICK_EXPORT OSGBackgroundNode : public OSGNode { class OSGQTQUICK_EXPORT OSGBackgroundNode : public OSGNode {
Q_OBJECT Q_PROPERTY(QUrl imageFile READ imageFile WRITE setImageFile NOTIFY imageFileChanged) Q_OBJECT Q_PROPERTY(QUrl imageFile READ imageFile WRITE setImageFile NOTIFY imageFileChanged)
typedef OSGNode Inherited;
public: public:
OSGBackgroundNode(QObject *parent = 0); OSGBackgroundNode(QObject *parent = 0);
virtual ~OSGBackgroundNode(); virtual ~OSGBackgroundNode();
@ -50,11 +52,12 @@ public:
signals: signals:
void imageFileChanged(const QUrl &url); void imageFileChanged(const QUrl &url);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -27,8 +27,6 @@
#include "OSGCamera.hpp" #include "OSGCamera.hpp"
#include "OSGNode.hpp"
#include <osg/Camera> #include <osg/Camera>
#include <osg/Node> #include <osg/Node>
@ -191,7 +189,7 @@ public:
/* class OSGCamera */ /* class OSGCamera */
OSGCamera::OSGCamera(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGCamera::OSGCamera(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGCamera::~OSGCamera() OSGCamera::~OSGCamera()
@ -254,6 +252,8 @@ void OSGCamera::setGraphicsContext(osg::GraphicsContext *gc)
void OSGCamera::update() void OSGCamera::update()
{ {
Inherited::update();
if (isDirty(ClearColor)) { if (isDirty(ClearColor)) {
h->updateClearColor(); h->updateClearColor();
} }

View File

@ -45,6 +45,8 @@ class OSGQTQUICK_EXPORT OSGCamera : public OSGNode {
Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged) Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged)
Q_PROPERTY(bool logarithmicDepthBuffer READ logarithmicDepthBuffer WRITE setLogarithmicDepthBuffer NOTIFY logarithmicDepthBufferChanged) Q_PROPERTY(bool logarithmicDepthBuffer READ logarithmicDepthBuffer WRITE setLogarithmicDepthBuffer NOTIFY logarithmicDepthBufferChanged)
typedef OSGNode Inherited;
friend class OSGViewport; friend class OSGViewport;
public: public:
@ -65,14 +67,15 @@ signals:
void fieldOfViewChanged(qreal arg); void fieldOfViewChanged(qreal arg);
void logarithmicDepthBufferChanged(bool enabled); void logarithmicDepthBufferChanged(bool enabled);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
osg::Camera *asCamera() const; osg::Camera *asCamera() const;
void setGraphicsContext(osg::GraphicsContext *gc); void setGraphicsContext(osg::GraphicsContext *gc);
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -146,7 +146,7 @@ private slots:
/* class OSGFileNode */ /* class OSGFileNode */
OSGFileNode::OSGFileNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGFileNode::OSGFileNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGFileNode::~OSGFileNode() OSGFileNode::~OSGFileNode()
@ -199,6 +199,8 @@ void OSGFileNode::setOptimizeMode(OptimizeMode::Enum optimizeMode)
void OSGFileNode::update() void OSGFileNode::update()
{ {
Inherited::update();
if (isDirty(Async)) { if (isDirty(Async)) {
// do nothing... // do nothing...
} }

View File

@ -39,6 +39,7 @@ QT_END_NAMESPACE
namespace osgQtQuick { namespace osgQtQuick {
class OSGQTQUICK_EXPORT OptimizeMode : public QObject { class OSGQTQUICK_EXPORT OptimizeMode : public QObject {
Q_OBJECT Q_OBJECT
public: public:
enum Enum { None, Optimize, OptimizeAndCheck }; enum Enum { None, Optimize, OptimizeAndCheck };
Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5 Q_ENUMS(Enum) // TODO switch to Q_ENUM once on Qt 5.5
@ -49,6 +50,8 @@ class OSGQTQUICK_EXPORT OSGFileNode : public OSGNode {
Q_PROPERTY(bool async READ async WRITE setAsync NOTIFY asyncChanged) Q_PROPERTY(bool async READ async WRITE setAsync NOTIFY asyncChanged)
Q_PROPERTY(osgQtQuick::OptimizeMode::Enum optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged) Q_PROPERTY(osgQtQuick::OptimizeMode::Enum optimizeMode READ optimizeMode WRITE setOptimizeMode NOTIFY optimizeModeChanged)
typedef OSGNode Inherited;
public: public:
OSGFileNode(QObject *parent = 0); OSGFileNode(QObject *parent = 0);
virtual ~OSGFileNode(); virtual ~OSGFileNode();
@ -67,11 +70,12 @@ signals:
void asyncChanged(const bool async); void asyncChanged(const bool async);
void optimizeModeChanged(OptimizeMode::Enum); void optimizeModeChanged(OptimizeMode::Enum);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -147,6 +147,7 @@ public:
// qDebug() << "OSGGeoTransformNode::updatePosition" << position; // qDebug() << "OSGGeoTransformNode::updatePosition" << position;
osgEarth::MapNode *mapNode = NULL; osgEarth::MapNode *mapNode = NULL;
if (sceneNode && sceneNode->node()) { if (sceneNode && sceneNode->node()) {
mapNode = osgEarth::MapNode::findMapNode(sceneNode->node()); mapNode = osgEarth::MapNode::findMapNode(sceneNode->node());
if (!mapNode) { if (!mapNode) {
@ -199,7 +200,7 @@ private slots:
/* class OSGGeoTransformNode */ /* class OSGGeoTransformNode */
OSGGeoTransformNode::OSGGeoTransformNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGGeoTransformNode::OSGGeoTransformNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGGeoTransformNode::~OSGGeoTransformNode() OSGGeoTransformNode::~OSGGeoTransformNode()
@ -269,6 +270,8 @@ void OSGGeoTransformNode::setPosition(QVector3D arg)
void OSGGeoTransformNode::update() void OSGGeoTransformNode::update()
{ {
Inherited::update();
if (isDirty(Child)) { if (isDirty(Child)) {
h->updateChildNode(); h->updateChildNode();
} }

View File

@ -41,12 +41,12 @@ class OSGQTQUICK_EXPORT OSGGeoTransformNode : public OSGNode {
Q_PROPERTY(osgQtQuick::OSGNode *modelData READ childNode WRITE setChildNode NOTIFY childNodeChanged) Q_PROPERTY(osgQtQuick::OSGNode *modelData READ childNode WRITE setChildNode NOTIFY childNodeChanged)
// TODO rename to earthNode // TODO rename to earthNode
Q_PROPERTY(osgQtQuick::OSGNode * sceneData READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged) Q_PROPERTY(osgQtQuick::OSGNode * sceneData READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged)
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 position READ position WRITE setPosition NOTIFY positionChanged) Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
typedef OSGNode Inherited;
public: public:
OSGGeoTransformNode(QObject *parent = 0); OSGGeoTransformNode(QObject *parent = 0);
virtual ~OSGGeoTransformNode(); virtual ~OSGGeoTransformNode();
@ -75,11 +75,12 @@ signals:
void positionChanged(QVector3D arg); void positionChanged(QVector3D arg);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -161,7 +161,7 @@ private slots:
/* class OSGGGroupNode */ /* class OSGGGroupNode */
OSGGroup::OSGGroup(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGGroup::OSGGroup(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGGroup::~OSGGroup() OSGGroup::~OSGGroup()
@ -181,6 +181,8 @@ QQmlListProperty<OSGNode> OSGGroup::children() const
void OSGGroup::update() void OSGGroup::update()
{ {
Inherited::update();
if (isDirty(Children)) { if (isDirty(Children)) {
h->updateGroupNode(); h->updateGroupNode();
} }

View File

@ -39,17 +39,20 @@ class OSGQTQUICK_EXPORT OSGGroup : public OSGNode {
Q_CLASSINFO("DefaultProperty", "children") Q_CLASSINFO("DefaultProperty", "children")
typedef OSGNode Inherited;
public: public:
explicit OSGGroup(QObject *parent = 0); explicit OSGGroup(QObject *parent = 0);
virtual ~OSGGroup(); virtual ~OSGGroup();
QQmlListProperty<OSGNode> children() const; QQmlListProperty<OSGNode> children() const;
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -129,21 +129,15 @@ void OSGNode::componentComplete()
qDebug() << "OSGNode::componentComplete" << this; qDebug() << "OSGNode::componentComplete" << this;
update(); update();
clearDirty(); clearDirty();
h->complete = h->node.valid(); h->complete = true;
if (!isComponentComplete()) { if (!h->node.valid()) {
qWarning() << "OSGNode::componentComplete - not complete !!!" << this; qWarning() << "OSGNode::componentComplete - node is not valid!" << this;
} }
} }
bool OSGNode::isComponentComplete()
{
return h->complete;
}
void OSGNode::emitNodeChanged() void OSGNode::emitNodeChanged()
{ {
if (isComponentComplete()) { if (h->complete) {
emit nodeChanged(node()); emit nodeChanged(node());
} }
} }

View File

@ -61,6 +61,9 @@ public:
osg::Node *node() const; osg::Node *node() const;
void setNode(osg::Node *node); void setNode(osg::Node *node);
signals:
void nodeChanged(osg::Node *node) const;
protected: protected:
bool isDirty(int mask = 0xFFFF) const; bool isDirty(int mask = 0xFFFF) const;
void setDirty(int mask = 0xFFFF); void setDirty(int mask = 0xFFFF);
@ -69,18 +72,13 @@ protected:
void classBegin(); void classBegin();
void componentComplete(); void componentComplete();
bool isComponentComplete();
void emitNodeChanged(); void emitNodeChanged();
signals: virtual void update();
void nodeChanged(osg::Node *node) const;
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -78,7 +78,7 @@ public:
// TODO turn into generic shape node... // TODO turn into generic shape node...
// see http://trac.openscenegraph.org/projects/osg//wiki/Support/Tutorials/TransformsAndStates // see http://trac.openscenegraph.org/projects/osg//wiki/Support/Tutorials/TransformsAndStates
OSGShapeNode::OSGShapeNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGShapeNode::OSGShapeNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{ {
setDirty(Type); setDirty(Type);
} }
@ -105,6 +105,8 @@ void OSGShapeNode::setShapeType(ShapeType::Enum type)
void OSGShapeNode::update() void OSGShapeNode::update()
{ {
Inherited::update();
if (isDirty(Type)) { if (isDirty(Type)) {
h->updateNode(); h->updateNode();
} }

View File

@ -42,6 +42,8 @@ public:
class OSGQTQUICK_EXPORT OSGShapeNode : public OSGNode { class OSGQTQUICK_EXPORT OSGShapeNode : public OSGNode {
Q_OBJECT Q_PROPERTY(osgQtQuick::ShapeType::Enum shapeType READ shapeType WRITE setShapeType NOTIFY shapeTypeChanged) Q_OBJECT Q_PROPERTY(osgQtQuick::ShapeType::Enum shapeType READ shapeType WRITE setShapeType NOTIFY shapeTypeChanged)
typedef OSGNode Inherited;
public: public:
OSGShapeNode(QObject *parent = 0); OSGShapeNode(QObject *parent = 0);
virtual ~OSGShapeNode(); virtual ~OSGShapeNode();
@ -52,11 +54,12 @@ public:
signals: signals:
void shapeTypeChanged(ShapeType::Enum); void shapeTypeChanged(ShapeType::Enum);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -223,7 +223,7 @@ private slots:
/* class OSGSkyNode */ /* class OSGSkyNode */
OSGSkyNode::OSGSkyNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGSkyNode::OSGSkyNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{ {
setDirty(DateTime | Light); setDirty(DateTime | Light);
} }
@ -305,6 +305,8 @@ void OSGSkyNode::setMinimumAmbientLight(double ambient)
void OSGSkyNode::update() void OSGSkyNode::update()
{ {
Inherited::update();
if (isDirty(Scene)) { if (isDirty(Scene)) {
h->updateSkyNode(); h->updateSkyNode();
} }

View File

@ -49,11 +49,12 @@ class OSGQTQUICK_EXPORT OSGSkyNode : public OSGNode {
// TODO rename to sceneNode // TODO rename to sceneNode
Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *sceneData READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged) Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *sceneData READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged)
Q_PROPERTY(osgQtQuick::OSGViewport * viewport READ viewport WRITE setViewport NOTIFY viewportChanged) Q_PROPERTY(osgQtQuick::OSGViewport * viewport READ viewport WRITE setViewport NOTIFY viewportChanged)
Q_PROPERTY(bool sunLightEnabled READ sunLightEnabled WRITE setSunLightEnabled NOTIFY sunLightEnabledChanged) Q_PROPERTY(bool sunLightEnabled READ sunLightEnabled WRITE setSunLightEnabled NOTIFY sunLightEnabledChanged)
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)
typedef OSGNode Inherited;
public: public:
OSGSkyNode(QObject *parent = 0); OSGSkyNode(QObject *parent = 0);
virtual ~OSGSkyNode(); virtual ~OSGSkyNode();
@ -81,11 +82,12 @@ signals:
void dateTimeChanged(QDateTime arg); void dateTimeChanged(QDateTime arg);
void minimumAmbientLightChanged(double arg); void minimumAmbientLightChanged(double arg);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -90,7 +90,7 @@ public:
/* class OSGTextNode */ /* class OSGTextNode */
OSGTextNode::OSGTextNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGTextNode::OSGTextNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{ {
setDirty(Text | Color); setDirty(Text | Color);
} }
@ -130,6 +130,8 @@ void OSGTextNode::setColor(const QColor &color)
void OSGTextNode::update() void OSGTextNode::update()
{ {
Inherited::update();
if (isDirty(Text)) { if (isDirty(Text)) {
h->updateText(); h->updateText();
} }

View File

@ -38,6 +38,8 @@ class OSGQTQUICK_EXPORT OSGTextNode : public OSGNode {
Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_OBJECT Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
typedef OSGNode Inherited;
public: public:
explicit OSGTextNode(QObject *parent = 0); explicit OSGTextNode(QObject *parent = 0);
virtual ~OSGTextNode(); virtual ~OSGTextNode();
@ -52,11 +54,12 @@ signals:
void textChanged(const QString &text); void textChanged(const QString &text);
void colorChanged(const QColor &color); void colorChanged(const QColor &color);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -138,7 +138,7 @@ private slots:
/* class OSGTransformNode */ /* class OSGTransformNode */
OSGTransformNode::OSGTransformNode(QObject *parent) : OSGNode(parent), h(new Hidden(this)) OSGTransformNode::OSGTransformNode(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGTransformNode::~OSGTransformNode() OSGTransformNode::~OSGTransformNode()
@ -204,6 +204,8 @@ void OSGTransformNode::setPosition(QVector3D arg)
void OSGTransformNode::update() void OSGTransformNode::update()
{ {
Inherited::update();
if (isDirty(Child)) { if (isDirty(Child)) {
h->updateChildNode(); h->updateChildNode();
} }

View File

@ -39,11 +39,12 @@ class OSGQTQUICK_EXPORT OSGTransformNode : public OSGNode {
Q_OBJECT Q_OBJECT
// TODO rename to childNode // TODO rename to childNode
Q_PROPERTY(osgQtQuick::OSGNode *modelData READ childNode WRITE setChildNode NOTIFY childNodeChanged) Q_PROPERTY(osgQtQuick::OSGNode *modelData READ childNode WRITE setChildNode NOTIFY childNodeChanged)
Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QVector3D scale READ scale WRITE setScale NOTIFY scaleChanged)
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)
typedef OSGNode Inherited;
public: public:
OSGTransformNode(QObject *parent = 0); OSGTransformNode(QObject *parent = 0);
virtual ~OSGTransformNode(); virtual ~OSGTransformNode();
@ -67,11 +68,12 @@ signals:
void attitudeChanged(QVector3D arg); void attitudeChanged(QVector3D arg);
void positionChanged(QVector3D arg); void positionChanged(QVector3D arg);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -72,7 +72,7 @@
which will separate the clip plane calculations of the helicopter from those of the earth. * which will separate the clip plane calculations of the helicopter from those of the earth. *
TODO : add OSGView to handle multiple views for a given OSGViewport TODO : add OSGView to handle multiple views for a given OSGViewport
*/ */
/* /*
that's a typical error when working with high-resolution (retina) that's a typical error when working with high-resolution (retina)
@ -95,7 +95,7 @@
I think osgQt already handles this correctly, so you shouldn't have to I think osgQt already handles this correctly, so you shouldn't have to
worry about this if you use the classes provided by osgQt ... worry about this if you use the classes provided by osgQt ...
*/ */
namespace osgQtQuick { namespace osgQtQuick {
enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1 }; enum DirtyFlag { Scene = 1 << 0, Camera = 1 << 1 };

View File

@ -149,7 +149,8 @@ void OSGCameraManipulator::classBegin()
void OSGCameraManipulator::componentComplete() void OSGCameraManipulator::componentComplete()
{ {
qDebug() << "OSGCameraManipulator::componentComplete" << this; qDebug() << "OSGCameraManipulator::componentComplete" << this;
h->updateSceneNode(); update();
clearDirty();
} }
osgGA::CameraManipulator *OSGCameraManipulator::manipulator() const osgGA::CameraManipulator *OSGCameraManipulator::manipulator() const
@ -168,7 +169,9 @@ osgGA::CameraManipulator *OSGCameraManipulator::asCameraManipulator() const
} }
void OSGCameraManipulator::update() void OSGCameraManipulator::update()
{} {
h->updateSceneNode();
}
} // namespace osgQtQuick } // namespace osgQtQuick
#include "OSGCameraManipulator.moc" #include "OSGCameraManipulator.moc"

View File

@ -69,11 +69,12 @@ protected:
osgGA::CameraManipulator *manipulator() const; osgGA::CameraManipulator *manipulator() const;
void setManipulator(osgGA::CameraManipulator *manipulator); void setManipulator(osgGA::CameraManipulator *manipulator);
protected:
virtual void update();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -57,7 +57,7 @@ public:
/* class OSGEarthManipulator */ /* class OSGEarthManipulator */
OSGEarthManipulator::OSGEarthManipulator(QObject *parent) : OSGCameraManipulator(parent), h(new Hidden(this)) OSGEarthManipulator::OSGEarthManipulator(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGEarthManipulator::~OSGEarthManipulator() OSGEarthManipulator::~OSGEarthManipulator()

View File

@ -37,6 +37,8 @@ namespace osgQtQuick {
class OSGQTQUICK_EXPORT OSGEarthManipulator : public OSGCameraManipulator { class OSGQTQUICK_EXPORT OSGEarthManipulator : public OSGCameraManipulator {
Q_OBJECT Q_OBJECT
typedef OSGCameraManipulator Inherited;
public: public:
explicit OSGEarthManipulator(QObject *parent = 0); explicit OSGEarthManipulator(QObject *parent = 0);
virtual ~OSGEarthManipulator(); virtual ~OSGEarthManipulator();

View File

@ -203,7 +203,7 @@ void MyManipulator::updateCamera(osg::Camera & camera)
/* class OSGGeoTransformManipulator */ /* class OSGGeoTransformManipulator */
OSGGeoTransformManipulator::OSGGeoTransformManipulator(QObject *parent) : OSGCameraManipulator(parent), h(new Hidden(this)) OSGGeoTransformManipulator::OSGGeoTransformManipulator(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGGeoTransformManipulator::~OSGGeoTransformManipulator() OSGGeoTransformManipulator::~OSGGeoTransformManipulator()
@ -258,18 +258,10 @@ void OSGGeoTransformManipulator::setPosition(QVector3D arg)
} }
} }
// TODO factorize up
void OSGGeoTransformManipulator::componentComplete()
{
OSGCameraManipulator::componentComplete();
qDebug() << "OSGGeoTransformManipulator::componentComplete" << this;
update();
clearDirty();
}
void OSGGeoTransformManipulator::update() void OSGGeoTransformManipulator::update()
{ {
Inherited::update();
h->updatePosition(); h->updatePosition();
h->updateAttitude(); h->updateAttitude();
h->updateManipulator(); h->updateManipulator();

View File

@ -41,6 +41,8 @@ class OSGQTQUICK_EXPORT OSGGeoTransformManipulator : public OSGCameraManipulator
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)
typedef OSGCameraManipulator Inherited;
public: public:
explicit OSGGeoTransformManipulator(QObject *parent = 0); explicit OSGGeoTransformManipulator(QObject *parent = 0);
virtual ~OSGGeoTransformManipulator(); virtual ~OSGGeoTransformManipulator();
@ -62,9 +64,6 @@ signals:
void clampToTerrainChanged(bool arg); void clampToTerrainChanged(bool arg);
void intoTerrainChanged(bool arg); void intoTerrainChanged(bool arg);
protected:
void componentComplete();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;

View File

@ -122,7 +122,7 @@ private slots:
/* class OSGNodeTrackerManipulator */ /* class OSGNodeTrackerManipulator */
OSGNodeTrackerManipulator::OSGNodeTrackerManipulator(QObject *parent) : OSGCameraManipulator(parent), h(new Hidden(this)) OSGNodeTrackerManipulator::OSGNodeTrackerManipulator(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGNodeTrackerManipulator::~OSGNodeTrackerManipulator() OSGNodeTrackerManipulator::~OSGNodeTrackerManipulator()
@ -156,11 +156,10 @@ void OSGNodeTrackerManipulator::setTrackerMode(TrackerMode::Enum mode)
} }
} }
void OSGNodeTrackerManipulator::componentComplete() void OSGNodeTrackerManipulator::update()
{ {
OSGCameraManipulator::componentComplete(); Inherited::update();
qDebug() << "OSGNodeTrackerManipulator::componentComplete" << this;
h->updateTrackerMode(); h->updateTrackerMode();
h->updateTrackNode(); h->updateTrackNode();
} }

View File

@ -45,6 +45,8 @@ class OSGQTQUICK_EXPORT OSGNodeTrackerManipulator : public OSGCameraManipulator
Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *trackNode READ trackNode WRITE setTrackNode NOTIFY trackNodeChanged) Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *trackNode READ trackNode WRITE setTrackNode NOTIFY trackNodeChanged)
Q_PROPERTY(osgQtQuick::TrackerMode::Enum trackerMode READ trackerMode WRITE setTrackerMode NOTIFY trackerModeChanged) Q_PROPERTY(osgQtQuick::TrackerMode::Enum trackerMode READ trackerMode WRITE setTrackerMode NOTIFY trackerModeChanged)
typedef OSGCameraManipulator Inherited;
public: public:
explicit OSGNodeTrackerManipulator(QObject *parent = 0); explicit OSGNodeTrackerManipulator(QObject *parent = 0);
virtual ~OSGNodeTrackerManipulator(); virtual ~OSGNodeTrackerManipulator();
@ -59,12 +61,11 @@ signals:
void trackNodeChanged(OSGNode *node); void trackNodeChanged(OSGNode *node);
void trackerModeChanged(TrackerMode::Enum); void trackerModeChanged(TrackerMode::Enum);
protected:
void componentComplete();
private: private:
struct Hidden; struct Hidden;
Hidden *const h; Hidden *const h;
virtual void update();
}; };
} // namespace osgQtQuick } // namespace osgQtQuick

View File

@ -57,7 +57,7 @@ public:
/* class OSGTrackballManipulator */ /* class OSGTrackballManipulator */
OSGTrackballManipulator::OSGTrackballManipulator(QObject *parent) : OSGCameraManipulator(parent), h(new Hidden(this)) OSGTrackballManipulator::OSGTrackballManipulator(QObject *parent) : Inherited(parent), h(new Hidden(this))
{} {}
OSGTrackballManipulator::~OSGTrackballManipulator() OSGTrackballManipulator::~OSGTrackballManipulator()

View File

@ -37,6 +37,8 @@ namespace osgQtQuick {
class OSGQTQUICK_EXPORT OSGTrackballManipulator : public OSGCameraManipulator { class OSGQTQUICK_EXPORT OSGTrackballManipulator : public OSGCameraManipulator {
Q_OBJECT Q_OBJECT
typedef OSGCameraManipulator Inherited;
public: public:
explicit OSGTrackballManipulator(QObject *parent = 0); explicit OSGTrackballManipulator(QObject *parent = 0);
virtual ~OSGTrackballManipulator(); virtual ~OSGTrackballManipulator();