Skip to content
Permalink
Browse files

Better initialization of 3d framework, usable outside of app

  • Loading branch information
nyalldawson committed Jul 22, 2020
1 parent a34eabd commit c7b6a115df1b25d1fc623dd3d7a15e2ceb3428a9
Showing with 36 additions and 9 deletions.
  1. +5 −0 python/3d/auto_generated/qgs3d.sip.in
  2. +21 −0 src/3d/qgs3d.cpp
  3. +7 −0 src/3d/qgs3d.h
  4. +3 −9 src/app/qgisapp.cpp
@@ -32,6 +32,11 @@ Returns a pointer to the singleton instance.

~Qgs3D();

static void initialize();
%Docstring
Initializes the 3D framework.
%End

private:
Qgs3D( const Qgs3D &other );
};
@@ -17,6 +17,15 @@

#include "qgs3d.h"

#include "qgsapplication.h"
#include "qgs3drendererregistry.h"

#include "qgsabstract3drenderer.h"
#include "qgs3drendererregistry.h"
#include "qgsrulebased3drenderer.h"
#include "qgsvectorlayer3drenderer.h"
#include "qgsmeshlayer3drenderer.h"

Qgs3D *Qgs3D::instance()
{
static Qgs3D *sInstance( new Qgs3D() );
@@ -27,6 +36,18 @@ Qgs3D::~Qgs3D()
{
}

void Qgs3D::initialize()
{
if ( instance()->mInitialized )
return;

instance()->mInitialized = true;

QgsApplication::renderer3DRegistry()->addRenderer( new QgsVectorLayer3DRendererMetadata );
QgsApplication::renderer3DRegistry()->addRenderer( new QgsRuleBased3DRendererMetadata );
QgsApplication::renderer3DRegistry()->addRenderer( new QgsMeshLayer3DRendererMetadata );
}

Qgs3D::Qgs3D()
{
}
@@ -45,6 +45,11 @@ class _3D_EXPORT Qgs3D

~Qgs3D();

/**
* Initializes the 3D framework.
*/
static void initialize();

private:

Qgs3D();
@@ -53,6 +58,8 @@ class _3D_EXPORT Qgs3D
Qgs3D( const Qgs3D &other );
#endif

bool mInitialized = false;

};

#endif // QGS3D_H
@@ -97,19 +97,15 @@
#include "qgsgeometrycheckregistry.h"

#ifdef HAVE_3D
#include "qgsabstract3drenderer.h"
#include "qgs3d.h"
#include "qgs3danimationsettings.h"
#include "qgs3danimationwidget.h"
#include "qgs3dmapcanvasdockwidget.h"
#include "qgs3drendererregistry.h"
#include "qgs3dmapcanvas.h"
#include "qgs3dmapsettings.h"
#include "qgscameracontroller.h"
#include "qgsflatterraingenerator.h"
#include "qgslayoutitem3dmap.h"
#include "qgsrulebased3drenderer.h"
#include "qgsvectorlayer3drenderer.h"
#include "qgsmeshlayer3drenderer.h"
#include "processing/qgs3dalgorithms.h"
#include "qgs3dmaptoolmeasureline.h"
#include "layout/qgslayout3dmapwidget.h"
@@ -12655,10 +12651,8 @@ void QgisApp::newMapCanvas()
void QgisApp::init3D()
{
#ifdef HAVE_3D
// register 3D renderers
QgsApplication::instance()->renderer3DRegistry()->addRenderer( new QgsVectorLayer3DRendererMetadata );
QgsApplication::instance()->renderer3DRegistry()->addRenderer( new QgsRuleBased3DRendererMetadata );
QgsApplication::instance()->renderer3DRegistry()->addRenderer( new QgsMeshLayer3DRendererMetadata );
// initialize 3D registries
Qgs3D::initialize();
#else
mActionNew3DMapCanvas->setVisible( false );
#endif

0 comments on commit c7b6a11

Please sign in to comment.
You can’t perform that action at this time.