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

LP-29 renaming and other minor cleanups

This commit is contained in:
Philippe Renon 2016-03-12 20:33:24 +01:00
parent c89d8f4ff4
commit 9ad4e57df1
2 changed files with 29 additions and 44 deletions

View File

@ -87,6 +87,7 @@ struct OSGViewport::Hidden : public QObject {
friend ViewportRenderer;
private:
OSGViewport *self;
QQuickWindow *window;
@ -94,7 +95,7 @@ struct OSGViewport::Hidden : public QObject {
int frameTimer;
public:
OSGNode *sceneData;
OSGNode *sceneNode;
OSGCamera *camera;
osg::ref_ptr<osgViewer::CompositeViewer> viewer;
@ -112,7 +113,7 @@ public:
self(viewport),
window(NULL),
frameTimer(-1),
sceneData(NULL),
sceneNode(NULL),
camera(NULL),
updateMode(UpdateMode::OnDemand),
busy(false)
@ -151,40 +152,34 @@ public slots:
public:
bool acceptSceneData(OSGNode *node)
bool acceptSceneNode(OSGNode *node)
{
qDebug() << "OSGViewport::acceptSceneData" << node;
if (sceneData == node) {
qDebug() << "OSGViewport::acceptSceneNode" << node;
if (sceneNode == node) {
return true;
}
if (sceneData) {
disconnect(sceneData);
if (sceneNode) {
disconnect(sceneNode);
}
sceneData = node;
sceneNode = node;
if (sceneData) {
acceptNode(sceneData->node());
connect(sceneData, &OSGNode::nodeChanged, this, &Hidden::onNodeChanged);
if (sceneNode) {
connect(sceneNode, &OSGNode::nodeChanged, this, &Hidden::onNodeChanged);
}
return true;
}
bool acceptNode(osg::Node *node)
{
return true;
}
void attach(osgViewer::View *view)
{
if (!sceneData) {
if (!sceneNode) {
qWarning() << "OSGViewport::attach - invalid scene!";
return;
}
// attach scene
attach(view, sceneData->node());
attach(view, sceneNode->node());
// attach camera
if (camera) {
camera->attach(view);
@ -276,17 +271,6 @@ public:
// view->getCamera()->setGraphicsContext(NULL);
}
bool acceptUpdateMode(UpdateMode::Enum mode)
{
if (updateMode == mode) {
return true;
}
updateMode = mode;
return true;
}
bool acceptCamera(OSGCamera *camera)
{
qDebug() << "OSGViewport::acceptCamera" << camera;
@ -612,15 +596,15 @@ OSGViewport::~OSGViewport()
delete h;
}
OSGNode *OSGViewport::sceneData()
OSGNode *OSGViewport::sceneNode()
{
return h->sceneData;
return h->sceneNode;
}
void OSGViewport::setSceneData(OSGNode *node)
void OSGViewport::setSceneNode(OSGNode *node)
{
if (h->acceptSceneData(node)) {
emit sceneDataChanged(node);
if (h->acceptSceneNode(node)) {
emit sceneNodeChanged(node);
}
}
@ -643,8 +627,9 @@ UpdateMode::Enum OSGViewport::updateMode() const
void OSGViewport::setUpdateMode(UpdateMode::Enum mode)
{
if (h->acceptUpdateMode(mode)) {
emit updateModeChanged(updateMode());
if (h->updateMode != mode) {
h->updateMode = mode;
emit updateModeChanged(mode);
}
}
@ -688,8 +673,8 @@ QQuickFramebufferObject::Renderer *OSGViewport::createRenderer() const
void OSGViewport::attach(osgViewer::View *view)
{
// qDebug() << "OSGViewport::attach" << view;
if (h->sceneData) {
h->sceneData->attach(view);
if (h->sceneNode) {
h->sceneNode->attach(view);
}
h->attach(view);
}
@ -698,8 +683,8 @@ void OSGViewport::detach(osgViewer::View *view)
{
qDebug() << "OSGViewport::detach" << view;
h->detach(view);
if (h->sceneData) {
h->sceneData->detach(view);
if (h->sceneNode) {
h->sceneNode->detach(view);
}
}

View File

@ -49,7 +49,7 @@ public:
};
class OSGQTQUICK_EXPORT OSGViewport : public QQuickFramebufferObject {
Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *sceneData READ sceneData WRITE setSceneData NOTIFY sceneDataChanged)
Q_OBJECT Q_PROPERTY(osgQtQuick::OSGNode *sceneData READ sceneNode WRITE setSceneNode NOTIFY sceneNodeChanged)
Q_PROPERTY(osgQtQuick::OSGCamera * camera READ camera WRITE setCamera NOTIFY cameraChanged)
Q_PROPERTY(osgQtQuick::UpdateMode::Enum updateMode READ updateMode WRITE setUpdateMode NOTIFY updateModeChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
@ -61,8 +61,8 @@ public:
explicit OSGViewport(QQuickItem *parent = 0);
virtual ~OSGViewport();
OSGNode *sceneData();
void setSceneData(OSGNode *node);
OSGNode *sceneNode();
void setSceneNode(OSGNode *node);
OSGCamera *camera();
void setCamera(OSGCamera *camera);
@ -80,7 +80,7 @@ public:
void releaseResources();
signals:
void sceneDataChanged(OSGNode *node);
void sceneNodeChanged(OSGNode *node);
void cameraChanged(OSGCamera *camera);
void updateModeChanged(UpdateMode::Enum mode);
void busyChanged(bool busy);