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

LP-29 const correcteness

This commit is contained in:
Philippe Renon 2016-03-13 16:19:29 +01:00
parent 9ad4e57df1
commit 913d9d2cb0
19 changed files with 99 additions and 102 deletions

View File

@ -52,7 +52,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -54,14 +54,40 @@ namespace osgQtQuick {
struct OSGCamera::Hidden : public QObject {
Q_OBJECT
private:
OSGCamera * const self;
osg::ref_ptr<osg::Camera> camera;
public:
OSGNode *sceneNode;
// Camera vertical field of view in degrees
qreal fieldOfView;
ManipulatorMode::Enum manipulatorMode;
// for NodeTrackerManipulator
TrackerMode::Enum trackerMode;
OSGNode *trackNode;
bool logDepthBufferEnabled;
#ifdef USE_OSGEARTH
osgEarth::Util::LogarithmicDepthBuffer *logDepthBuffer;
#endif
bool clampToTerrain;
bool intoTerrain;
QVector3D attitude;
QVector3D position;
public:
Hidden(OSGCamera *camera) :
QObject(camera), self(camera), sceneNode(NULL),
QObject(camera), self(camera), sceneNode(NULL), fieldOfView(90),
manipulatorMode(ManipulatorMode::Default), trackerMode(TrackerMode::NodeCenterAndAzim), trackNode(NULL),
logDepthBufferEnabled(false), clampToTerrain(false), intoTerrain(false)
{
fieldOfView = 90.0;
#ifdef USE_OSGEARTH
logDepthBuffer = NULL;
#endif
@ -328,32 +354,6 @@ public:
camera->setViewMatrix(cameraMatrix);
}
OSGCamera *const self;
osg::ref_ptr<osg::Camera> camera;
// Camera vertical field of view in degrees
qreal fieldOfView;
OSGNode *sceneNode;
ManipulatorMode::Enum manipulatorMode;
// for NodeTrackerManipulator
TrackerMode::Enum trackerMode;
OSGNode *trackNode;
bool logDepthBufferEnabled;
#ifdef USE_OSGEARTH
osgEarth::Util::LogarithmicDepthBuffer *logDepthBuffer;
#endif
bool clampToTerrain;
bool intoTerrain;
QVector3D attitude;
QVector3D position;
private slots:
void onSceneNodeChanged(osg::Node *node)
{
@ -383,6 +383,18 @@ OSGCamera::~OSGCamera()
delete h;
}
OSGNode *OSGCamera::sceneNode() const
{
return h->sceneNode;
}
void OSGCamera::setSceneNode(OSGNode *node)
{
if (h->acceptSceneNode(node)) {
emit sceneNodeChanged(node);
}
}
qreal OSGCamera::fieldOfView() const
{
return h->fieldOfView;
@ -397,18 +409,6 @@ void OSGCamera::setFieldOfView(qreal arg)
}
}
OSGNode *OSGCamera::sceneNode()
{
return h->sceneNode;
}
void OSGCamera::setSceneNode(OSGNode *node)
{
if (h->acceptSceneNode(node)) {
emit sceneNodeChanged(node);
}
}
ManipulatorMode::Enum OSGCamera::manipulatorMode() const
{
return h->manipulatorMode;
@ -492,7 +492,7 @@ void OSGCamera::setPosition(QVector3D arg)
}
}
bool OSGCamera::logarithmicDepthBuffer()
bool OSGCamera::logarithmicDepthBuffer() const
{
return h->logDepthBufferEnabled;
}

View File

@ -64,8 +64,8 @@ public:
// - expose track mode
// - provide good default distance and attitude for tracker camera
class OSGQTQUICK_EXPORT OSGCamera : public OSGNode {
Q_OBJECT Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged)
Q_PROPERTY(osgQtQuick::OSGNode * sceneNode READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged)
Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *sceneNode READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged)
Q_PROPERTY(qreal fieldOfView READ fieldOfView WRITE setFieldOfView NOTIFY fieldOfViewChanged)
Q_PROPERTY(osgQtQuick::ManipulatorMode::Enum manipulatorMode READ manipulatorMode WRITE setManipulatorMode NOTIFY manipulatorModeChanged)
Q_PROPERTY(osgQtQuick::OSGNode * trackNode READ trackNode WRITE setTrackNode NOTIFY trackNodeChanged)
Q_PROPERTY(osgQtQuick::TrackerMode::Enum trackerMode READ trackerMode WRITE setTrackerMode NOTIFY trackerModeChanged)
@ -81,6 +81,9 @@ public:
explicit OSGCamera(QObject *parent = 0);
virtual ~OSGCamera();
OSGNode *sceneNode() const;
void setSceneNode(OSGNode *node);
// fov depends on the scenery space (probaby distance)
// here are some value: 75°, 60°, 45° many gamers use
// x-plane uses 45° for 4:3 and 60° for 16:9/16:10
@ -88,9 +91,6 @@ public:
qreal fieldOfView() const;
void setFieldOfView(qreal arg);
OSGNode *sceneNode();
void setSceneNode(OSGNode *node);
ManipulatorMode::Enum manipulatorMode() const;
void setManipulatorMode(ManipulatorMode::Enum);
@ -111,14 +111,14 @@ public:
QVector3D position() const;
void setPosition(QVector3D arg);
bool logarithmicDepthBuffer();
bool logarithmicDepthBuffer() const;
void setLogarithmicDepthBuffer(bool enabled);
signals:
void fieldOfViewChanged(qreal arg);
void sceneNodeChanged(OSGNode *node);
void fieldOfViewChanged(qreal arg);
void manipulatorModeChanged(ManipulatorMode::Enum);
void trackNodeChanged(OSGNode *node);
@ -134,7 +134,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -69,7 +69,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -201,7 +201,7 @@ OSGGeoTransformNode::~OSGGeoTransformNode()
delete h;
}
OSGNode *OSGGeoTransformNode::childNode()
OSGNode *OSGGeoTransformNode::childNode() const
{
return h->childNode;
}
@ -214,7 +214,7 @@ void OSGGeoTransformNode::setChildNode(OSGNode *node)
}
}
OSGNode *OSGGeoTransformNode::sceneNode()
OSGNode *OSGGeoTransformNode::sceneNode() const
{
return h->sceneNode;
}

View File

@ -51,10 +51,10 @@ public:
OSGGeoTransformNode(QObject *parent = 0);
virtual ~OSGGeoTransformNode();
OSGNode *childNode();
OSGNode *childNode() const;
void setChildNode(OSGNode *node);
OSGNode *sceneNode();
OSGNode *sceneNode() const;
void setSceneNode(OSGNode *node);
bool clampToTerrain() const;
@ -77,7 +77,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -39,7 +39,7 @@ struct OSGGroup::Hidden : public QObject {
Q_OBJECT
private:
OSGGroup * self;
OSGGroup * const self;
osg::ref_ptr<osg::Group> group;
@ -171,7 +171,7 @@ OSGGroup::~OSGGroup()
delete h;
}
QQmlListProperty<OSGNode> OSGGroup::children()
QQmlListProperty<OSGNode> OSGGroup::children() const
{
return QQmlListProperty<OSGNode>(h, 0,
&Hidden::append_child,

View File

@ -43,11 +43,11 @@ public:
explicit OSGGroup(QObject *parent = 0);
virtual ~OSGGroup();
QQmlListProperty<OSGNode> children();
QQmlListProperty<OSGNode> children() const;
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -51,11 +51,20 @@ struct OSGNode::Hidden : public QObject {
friend class OSGNode;
private:
OSGNode *const self;
osg::ref_ptr<osg::Node> node;
osg::ref_ptr<osg::NodeCallback> nodeUpdateCallback;
int dirty;
public:
Hidden(OSGNode *node) : QObject(node), self(node), dirty(0)
{}
bool isDirty(int mask)
bool isDirty(int mask) const
{
return (dirty && mask) != 0;
}
@ -121,15 +130,6 @@ public:
}
return true;
}
private:
OSGNode *const self;
osg::ref_ptr<osg::Node> node;
osg::ref_ptr<osg::NodeCallback> nodeUpdateCallback;
int dirty;
};
void NodeUpdateCallback::operator()(osg::Node *node, osg::NodeVisitor *nv)
@ -159,12 +159,12 @@ void OSGNode::setNode(osg::Node *node)
}
}
bool OSGNode::isDirty()
bool OSGNode::isDirty() const
{
return h->isDirty(0xFFFFFFFF);
}
bool OSGNode::isDirty(int mask)
bool OSGNode::isDirty(int mask) const
{
return h->isDirty(mask);
}

View File

@ -67,8 +67,8 @@ public:
void setNode(osg::Node *node);
protected:
bool isDirty();
bool isDirty(int mask);
bool isDirty() const;
bool isDirty(int mask) const;
void setDirty(int mask);
void clearDirty();
@ -85,7 +85,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void attach(osgViewer::View *view);
virtual void detach(osgViewer::View *view);

View File

@ -41,7 +41,7 @@ struct OSGShapeNode::Hidden : public QObject {
Q_OBJECT
private:
OSGShapeNode * self;
OSGShapeNode * const self;
public:
ShapeType::Enum shapeType;

View File

@ -54,7 +54,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -214,7 +214,7 @@ OSGSkyNode::~OSGSkyNode()
delete h;
}
OSGNode *OSGSkyNode::sceneNode()
OSGNode *OSGSkyNode::sceneNode() const
{
return h->sceneNode;
}
@ -227,7 +227,7 @@ void OSGSkyNode::setSceneNode(OSGNode *node)
}
}
bool OSGSkyNode::sunLightEnabled()
bool OSGSkyNode::sunLightEnabled() const
{
return h->sunLightEnabled;
}
@ -241,7 +241,7 @@ void OSGSkyNode::setSunLightEnabled(bool enabled)
}
}
QDateTime OSGSkyNode::dateTime()
QDateTime OSGSkyNode::dateTime() const
{
return h->dateTime;
}
@ -255,7 +255,7 @@ void OSGSkyNode::setDateTime(QDateTime dateTime)
}
}
double OSGSkyNode::minimumAmbientLight()
double OSGSkyNode::minimumAmbientLight() const
{
return h->minimumAmbientLight;
}

View File

@ -55,16 +55,16 @@ public:
OSGSkyNode(QObject *parent = 0);
virtual ~OSGSkyNode();
OSGNode *sceneNode();
OSGNode *sceneNode() const;
void setSceneNode(OSGNode *node);
bool sunLightEnabled();
bool sunLightEnabled() const;
void setSunLightEnabled(bool arg);
QDateTime dateTime();
QDateTime dateTime() const;
void setDateTime(QDateTime arg);
double minimumAmbientLight();
double minimumAmbientLight() const;
void setMinimumAmbientLight(double arg);
signals:
@ -76,7 +76,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -54,7 +54,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -151,7 +151,7 @@ OSGTransformNode::~OSGTransformNode()
delete h;
}
OSGNode *OSGTransformNode::childNode()
OSGNode *OSGTransformNode::childNode() const
{
return h->childNode;
}

View File

@ -48,7 +48,7 @@ public:
OSGTransformNode(QObject *parent = 0);
virtual ~OSGTransformNode();
OSGNode *childNode();
OSGNode *childNode() const;
void setChildNode(OSGNode *node);
QVector3D scale() const;
@ -69,7 +69,7 @@ signals:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
virtual void update();

View File

@ -88,7 +88,7 @@ struct OSGViewport::Hidden : public QObject {
friend ViewportRenderer;
private:
OSGViewport *self;
OSGViewport *const self;
QQuickWindow *window;
@ -107,8 +107,6 @@ public:
static QtKeyboardMap keyMap;
public:
Hidden(OSGViewport *viewport) : QObject(viewport),
self(viewport),
window(NULL),
@ -151,7 +149,6 @@ public slots:
}
public:
bool acceptSceneNode(OSGNode *node)
{
qDebug() << "OSGViewport::acceptSceneNode" << node;
@ -571,7 +568,7 @@ public:
}
private:
OSGViewport::Hidden *h;
OSGViewport::Hidden *const h;
bool firstFrame;
bool needToDoFrame;
@ -596,7 +593,7 @@ OSGViewport::~OSGViewport()
delete h;
}
OSGNode *OSGViewport::sceneNode()
OSGNode *OSGViewport::sceneNode() const
{
return h->sceneNode;
}
@ -608,7 +605,7 @@ void OSGViewport::setSceneNode(OSGNode *node)
}
}
OSGCamera *OSGViewport::camera()
OSGCamera *OSGViewport::camera() const
{
return h->camera;
}

View File

@ -61,10 +61,10 @@ public:
explicit OSGViewport(QQuickItem *parent = 0);
virtual ~OSGViewport();
OSGNode *sceneNode();
OSGNode *sceneNode() const;
void setSceneNode(OSGNode *node);
OSGCamera *camera();
OSGCamera *camera() const;
void setCamera(OSGCamera *camera);
UpdateMode::Enum updateMode() const;
@ -104,7 +104,7 @@ protected:
private:
struct Hidden;
Hidden *h;
Hidden *const h;
};
} // namespace osgQtQuick