Skip to content

Commit

Permalink
remove 3D views from view->panels and make checkable in view->3d views
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 12, 2022
1 parent 05824dc commit b43d0a4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
36 changes: 30 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -1745,6 +1745,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers

setupLayoutManagerConnections();

#ifdef HAVE_3D
connect( QgsProject::instance()->views3DManager(), &Qgs3DViewsManager::viewsListChanged, this, &QgisApp::views3DMenuAboutToShow );
#endif

setupDuplicateFeaturesAction();

// support for project storage
Expand Down Expand Up @@ -9909,6 +9913,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::open3DMapView( const QString &mapName )
return nullptr;

read3DMapViewSettings( mapCanvasDock3D, elem3DMap );
mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );

QgsProject::instance()->views3DManager()->viewOpened( mapName );

Expand Down Expand Up @@ -9973,6 +9978,8 @@ Qgs3DMapCanvasDockWidget *QgisApp::duplicate3DMapView( const QString &existingVi
QgsProject::instance()->views3DManager()->register3DViewSettings( newViewName, elem3DMap );
QgsProject::instance()->views3DManager()->viewOpened( newViewName );

mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );

return mapCanvasDock3D;
#else
Q_UNUSED( existingViewName )
Expand Down Expand Up @@ -10072,14 +10079,28 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
#ifdef HAVE_3D
menu->clear();
QList<QAction *> acts;
const QList< QString > views = QgsProject::instance()->views3DManager()->get3DViewsNames();
QList< QDomElement > views = QgsProject::instance()->views3DManager()->get3DViews();
acts.reserve( views.size() );
for ( QString viewName : views )
for ( const QDomElement &viewConfig : views )
{
QString viewName = viewConfig.attribute( QStringLiteral( "name" ) );
bool isOpen = viewConfig.attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
QAction *a = new QAction( viewName, menu );
connect( a, &QAction::triggered, this, [this, viewName]
a->setCheckable( true );
a->setChecked( isOpen );
connect( a, &QAction::triggered, this, [viewName]( bool isChecked )
{
open3DMapView( viewName );
if ( isChecked )
{
QgisApp::instance()->open3DMapView( viewName );
}
else
{
if ( Qgs3DMapCanvasDockWidget *w = QgisApp::instance()->findChild<Qgs3DMapCanvasDockWidget *>( viewName + QStringLiteral( "ViewObject" ) ) )
{
w->close();
}
}
} );
acts << a;
}
Expand All @@ -10097,6 +10118,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )

void QgisApp::views3DMenuAboutToShow()
{
qDebug() << __PRETTY_FUNCTION__;
populate3DMapviewsMenu( m3DMapViewsMenu );
}

Expand Down Expand Up @@ -14059,6 +14081,8 @@ void QgisApp::new3DMapCanvas()
{
QgsProject::instance()->views3DManager()->viewClosed( name );
} );

mPanelMenu->removeAction( dock->toggleViewAction() );
}
#endif
}
Expand Down Expand Up @@ -16761,8 +16785,6 @@ void QgisApp::writeProject( QDomDocument &doc )
write3DMapViewSettings( widget, doc, elem3DMap );
QgsProject::instance()->views3DManager()->register3DViewSettings( viewName, elem3DMap );
}
// QDomElement elem3DMaps = QgsProject::instance()->views3DManager()->writeXml( doc );
// qgisNode.appendChild( elem3DMaps );
#endif
projectChanged( doc );
}
Expand Down Expand Up @@ -16885,6 +16907,8 @@ void QgisApp::readProject( const QDomDocument &doc )
{
QgsProject::instance()->views3DManager()->viewClosed( viewName );
} );

mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
}
#endif

Expand Down
1 change: 1 addition & 0 deletions src/core/3d/qgs3dviewsmanager.cpp
Expand Up @@ -92,6 +92,7 @@ void Qgs3DViewsManager::rename3DView( const QString &oldTitle, const QString &ne
QDomElement elem = m3DMapViewsDom.value( oldTitle );
m3DMapViewsDom.remove( oldTitle );
m3DMapViewsDom[ newTitle ] = elem;
m3DMapViewsDom[ newTitle ].setAttribute( QStringLiteral( "name" ), newTitle );
emit viewsListChanged();
}

Expand Down

0 comments on commit b43d0a4

Please sign in to comment.