mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
Add 3D map canvas handling methods to QgisInterface
This commit is contained in:
parent
2f98809d2c
commit
d8996ae33b
@ -1,11 +1,11 @@
|
|||||||
// Include auto-generated SIP files
|
// Include auto-generated SIP files
|
||||||
%Include auto_generated/processing/qgs3dalgorithms.sip
|
%Include auto_generated/processing/qgs3dalgorithms.sip
|
||||||
%Include auto_generated/qgs3d.sip
|
%Include auto_generated/qgs3d.sip
|
||||||
%Include auto_generated/qgs3dmapcanvas.sip
|
|
||||||
%Include auto_generated/qgs3dmapscene.sip
|
%Include auto_generated/qgs3dmapscene.sip
|
||||||
%Include auto_generated/qgs3dmapsettings.sip
|
%Include auto_generated/qgs3dmapsettings.sip
|
||||||
%Include auto_generated/qgs3dmaptool.sip
|
%Include auto_generated/qgs3dmaptool.sip
|
||||||
%Include auto_generated/qgs3dtypes.sip
|
%Include auto_generated/qgs3dtypes.sip
|
||||||
|
%Include auto_generated/qgs3dmapcanvas.sip
|
||||||
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
||||||
%Include auto_generated/qgscameracontroller.sip
|
%Include auto_generated/qgscameracontroller.sip
|
||||||
%Include auto_generated/qgscamerapose.sip
|
%Include auto_generated/qgscamerapose.sip
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
// Include auto-generated SIP files
|
// Include auto-generated SIP files
|
||||||
%Include auto_generated/processing/qgs3dalgorithms.sip
|
%Include auto_generated/processing/qgs3dalgorithms.sip
|
||||||
%Include auto_generated/qgs3d.sip
|
%Include auto_generated/qgs3d.sip
|
||||||
%Include auto_generated/qgs3dmapcanvas.sip
|
|
||||||
%Include auto_generated/qgs3dmapscene.sip
|
%Include auto_generated/qgs3dmapscene.sip
|
||||||
%Include auto_generated/qgs3dmapsettings.sip
|
%Include auto_generated/qgs3dmapsettings.sip
|
||||||
%Include auto_generated/qgs3dmaptool.sip
|
%Include auto_generated/qgs3dmaptool.sip
|
||||||
%Include auto_generated/qgs3dtypes.sip
|
%Include auto_generated/qgs3dtypes.sip
|
||||||
|
%Include auto_generated/qgs3dmapcanvas.sip
|
||||||
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
%Include auto_generated/qgsabstractvectorlayer3drenderer.sip
|
||||||
%Include auto_generated/qgscameracontroller.sip
|
%Include auto_generated/qgscameracontroller.sip
|
||||||
%Include auto_generated/qgscamerapose.sip
|
%Include auto_generated/qgscamerapose.sip
|
||||||
|
|||||||
@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Qgs3DMapCanvas /External/;
|
||||||
|
|
||||||
|
%ModuleHeaderCode
|
||||||
|
class Qgs3DMapCanvas;
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
class QgisInterface : QObject
|
class QgisInterface : QObject
|
||||||
@ -95,6 +100,31 @@ Closes the additional map canvas with matching ``name``.
|
|||||||
.. seealso:: :py:func:`createNewMapCanvas`
|
.. seealso:: :py:func:`createNewMapCanvas`
|
||||||
|
|
||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual QList< Qgs3DMapCanvas * > mapCanvases3D() = 0;
|
||||||
|
%Docstring
|
||||||
|
Returns a list of all 3D map canvases open in the app.
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Create a new 3D map canvas with the specified unique ``name``.
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`closeMapCanvas3D`
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual void closeMapCanvas3D( const QString &name ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Closes the additional map canvas with matching ``name``.
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`createNewMapCanvas3D`
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
||||||
|
|||||||
@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Qgs3DMapCanvas /External/;
|
||||||
|
|
||||||
|
%ModuleHeaderCode
|
||||||
|
class Qgs3DMapCanvas;
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
class QgisInterface : QObject
|
class QgisInterface : QObject
|
||||||
@ -95,6 +100,31 @@ Closes the additional map canvas with matching ``name``.
|
|||||||
.. seealso:: :py:func:`createNewMapCanvas`
|
.. seealso:: :py:func:`createNewMapCanvas`
|
||||||
|
|
||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual QList< Qgs3DMapCanvas * > mapCanvases3D() = 0;
|
||||||
|
%Docstring
|
||||||
|
Returns a list of all 3D map canvases open in the app.
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Create a new 3D map canvas with the specified unique ``name``.
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`closeMapCanvas3D`
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual void closeMapCanvas3D( const QString &name ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Closes the additional map canvas with matching ``name``.
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`createNewMapCanvas3D`
|
||||||
|
|
||||||
|
.. versionadded:: 3.36
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
||||||
|
|||||||
@ -9211,6 +9211,16 @@ void QgisApp::setupLayoutManagerConnections()
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Qgs3DMapCanvas *> QgisApp::mapCanvases3D()
|
||||||
|
{
|
||||||
|
QList<Qgs3DMapCanvas *> canvases;
|
||||||
|
#ifdef HAVE_3D
|
||||||
|
for ( Qgs3DMapCanvasWidget *w : std::as_const( mOpen3DMapViews ) )
|
||||||
|
canvases.append( w->mapCanvas3D() );
|
||||||
|
#endif
|
||||||
|
return canvases;
|
||||||
|
}
|
||||||
|
|
||||||
Qgs3DMapCanvasWidget *QgisApp::open3DMapView( const QString &viewName )
|
Qgs3DMapCanvasWidget *QgisApp::open3DMapView( const QString &viewName )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_3D
|
#ifdef HAVE_3D
|
||||||
@ -13394,6 +13404,11 @@ QgsElevationProfileWidget *QgisApp::createNewElevationProfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::new3DMapCanvas()
|
void QgisApp::new3DMapCanvas()
|
||||||
|
{
|
||||||
|
createNewMapCanvas3D( QString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Qgs3DMapCanvas *QgisApp::createNewMapCanvas3D( const QString &name )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_3D
|
#ifdef HAVE_3D
|
||||||
// initialize from project
|
// initialize from project
|
||||||
@ -13404,18 +13419,18 @@ void QgisApp::new3DMapCanvas()
|
|||||||
if ( fullExtent.isEmpty() || !fullExtent.isFinite() )
|
if ( fullExtent.isEmpty() || !fullExtent.isFinite() )
|
||||||
{
|
{
|
||||||
QMessageBox::warning( this, tr( "New 3D Map View" ), tr( "Project extent is not valid. Please add or activate a layer to render." ) );
|
QMessageBox::warning( this, tr( "New 3D Map View" ), tr( "Project extent is not valid. Please add or activate a layer to render." ) );
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
const QList< QString > usedCanvasNames = QgsProject::instance()->viewsManager()->get3DViewsNames();
|
const QList< QString > usedCanvasNames = QgsProject::instance()->viewsManager()->get3DViewsNames();
|
||||||
QString name = tr( "3D Map %1" ).arg( i );
|
QString uniqueName = name.isEmpty() ? tr( "3D Map %1" ).arg( i ) : name;
|
||||||
while ( usedCanvasNames.contains( name ) )
|
while ( usedCanvasNames.contains( uniqueName ) )
|
||||||
{
|
{
|
||||||
name = tr( "3D Map %1" ).arg( ++i );
|
uniqueName = tr( "3D Map %1" ).arg( ++i );
|
||||||
}
|
}
|
||||||
|
|
||||||
Qgs3DMapCanvasWidget *canvasWidget = createNew3DMapCanvasDock( name, false );
|
Qgs3DMapCanvasWidget *canvasWidget = createNew3DMapCanvasDock( uniqueName, false );
|
||||||
if ( canvasWidget )
|
if ( canvasWidget )
|
||||||
{
|
{
|
||||||
QgsProject *prj = QgsProject::instance();
|
QgsProject *prj = QgsProject::instance();
|
||||||
@ -13484,10 +13499,15 @@ void QgisApp::new3DMapCanvas()
|
|||||||
|
|
||||||
write3DMapViewSettings( canvasWidget, doc, elem3DMap );
|
write3DMapViewSettings( canvasWidget, doc, elem3DMap );
|
||||||
|
|
||||||
QgsProject::instance()->viewsManager()->register3DViewSettings( name, elem3DMap );
|
QgsProject::instance()->viewsManager()->register3DViewSettings( uniqueName, elem3DMap );
|
||||||
QgsProject::instance()->viewsManager()->set3DViewInitiallyVisible( name, true );
|
QgsProject::instance()->viewsManager()->set3DViewInitiallyVisible( uniqueName, true );
|
||||||
|
|
||||||
|
return canvasWidget->mapCanvas3D();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Q_UNUSED( name );
|
||||||
#endif
|
#endif
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgisApp::setExtent( const QgsRectangle &rect )
|
void QgisApp::setExtent( const QgsRectangle &rect )
|
||||||
|
|||||||
@ -160,6 +160,7 @@ class QgsAppGpsConnection;
|
|||||||
class QgsGpsToolBar;
|
class QgsGpsToolBar;
|
||||||
class QgsAppGpsSettingsMenu;
|
class QgsAppGpsSettingsMenu;
|
||||||
class Qgs3DMapScene;
|
class Qgs3DMapScene;
|
||||||
|
class Qgs3DMapCanvas;
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
@ -432,6 +433,20 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
|||||||
*/
|
*/
|
||||||
QgsLayoutDesignerDialog *openLayoutDesignerDialog( QgsMasterLayoutInterface *layout );
|
QgsLayoutDesignerDialog *openLayoutDesignerDialog( QgsMasterLayoutInterface *layout );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all 3D map canvases open in the app.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.36
|
||||||
|
*/
|
||||||
|
QList< Qgs3DMapCanvas * > mapCanvases3D();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new 3D map canvas with the specified unique \a name.
|
||||||
|
*
|
||||||
|
* \since QGIS 3.36
|
||||||
|
*/
|
||||||
|
Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a 3D view canvas for a 3D map view called \a name.
|
* Opens a 3D view canvas for a 3D map view called \a name.
|
||||||
* If the 3D view named \a name was not already created in the project, nullptr will be returned
|
* If the 3D view named \a name was not already created in the project, nullptr will be returned
|
||||||
|
|||||||
@ -391,6 +391,21 @@ void QgisAppInterface::closeMapCanvas( const QString &name )
|
|||||||
qgis->closeMapCanvas( name );
|
qgis->closeMapCanvas( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList< Qgs3DMapCanvas * > QgisAppInterface::mapCanvases3D()
|
||||||
|
{
|
||||||
|
return qgis->mapCanvases3D();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qgs3DMapCanvas *QgisAppInterface::createNewMapCanvas3D( const QString &name )
|
||||||
|
{
|
||||||
|
return qgis->createNewMapCanvas3D( name );
|
||||||
|
}
|
||||||
|
|
||||||
|
void QgisAppInterface::closeMapCanvas3D( const QString &name )
|
||||||
|
{
|
||||||
|
qgis->close3DMapView( name );
|
||||||
|
}
|
||||||
|
|
||||||
QSize QgisAppInterface::iconSize( bool dockedToolbar ) const
|
QSize QgisAppInterface::iconSize( bool dockedToolbar ) const
|
||||||
{
|
{
|
||||||
return qgis->iconSize( dockedToolbar );
|
return qgis->iconSize( dockedToolbar );
|
||||||
|
|||||||
@ -107,6 +107,9 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
|
|||||||
QList< QgsMapCanvas * > mapCanvases() override;
|
QList< QgsMapCanvas * > mapCanvases() override;
|
||||||
QgsMapCanvas *createNewMapCanvas( const QString &name ) override;
|
QgsMapCanvas *createNewMapCanvas( const QString &name ) override;
|
||||||
void closeMapCanvas( const QString &name ) override;
|
void closeMapCanvas( const QString &name ) override;
|
||||||
|
QList< Qgs3DMapCanvas * > mapCanvases3D() override;
|
||||||
|
Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name ) override;
|
||||||
|
void closeMapCanvas3D( const QString &name ) override;
|
||||||
QSize iconSize( bool dockedToolbar = false ) const override;
|
QSize iconSize( bool dockedToolbar = false ) const override;
|
||||||
QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() override;
|
QgsLayerTreeMapCanvasBridge *layerTreeCanvasBridge() override;
|
||||||
QWidget *mainWindow() override;
|
QWidget *mainWindow() override;
|
||||||
|
|||||||
@ -72,6 +72,13 @@ class QgsApplicationExitBlockerInterface;
|
|||||||
class QgsAbstractMapToolHandler;
|
class QgsAbstractMapToolHandler;
|
||||||
class QgsUserProfileManager;
|
class QgsUserProfileManager;
|
||||||
class QgsDataSourceManagerDialog;
|
class QgsDataSourceManagerDialog;
|
||||||
|
class Qgs3DMapCanvas SIP_EXTERNAL;
|
||||||
|
|
||||||
|
#ifdef SIP_RUN
|
||||||
|
% ModuleHeaderCode
|
||||||
|
class Qgs3DMapCanvas;
|
||||||
|
% End
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup gui
|
* \ingroup gui
|
||||||
@ -149,6 +156,26 @@ class GUI_EXPORT QgisInterface : public QObject
|
|||||||
*/
|
*/
|
||||||
virtual void closeMapCanvas( const QString &name ) = 0;
|
virtual void closeMapCanvas( const QString &name ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all 3D map canvases open in the app.
|
||||||
|
* \since QGIS 3.36
|
||||||
|
*/
|
||||||
|
virtual QList< Qgs3DMapCanvas * > mapCanvases3D() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new 3D map canvas with the specified unique \a name.
|
||||||
|
* \see closeMapCanvas3D()
|
||||||
|
* \since QGIS 3.36
|
||||||
|
*/
|
||||||
|
virtual Qgs3DMapCanvas *createNewMapCanvas3D( const QString &name ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the additional map canvas with matching \a name.
|
||||||
|
* \see createNewMapCanvas3D()
|
||||||
|
* \since QGIS 3.36
|
||||||
|
*/
|
||||||
|
virtual void closeMapCanvas3D( const QString &name ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the toolbar icon size. If \a dockedToolbar is TRUE, the icon size
|
* Returns the toolbar icon size. If \a dockedToolbar is TRUE, the icon size
|
||||||
* for toolbars contained within docks is returned.
|
* for toolbars contained within docks is returned.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user