Skip to content
Permalink
Browse files

[3d] Change options button in 3d canvas dock from directly opening

the settings dialog to instead show a menu with quick toggles
for enabling shadows and eye dome lighting, along with a Configure
option for the full map configuration
  • Loading branch information
nyalldawson committed Nov 9, 2020
1 parent 68ceaf2 commit b567a7c55bbd192c16215d013cf572a9d4f9678b
Showing with 46 additions and 2 deletions.
  1. +42 −2 src/app/3d/qgs3dmapcanvasdockwidget.cpp
  2. +4 −0 src/app/3d/qgs3dmapcanvasdockwidget.h
@@ -121,8 +121,42 @@ Qgs3DMapCanvasDockWidget::Qgs3DMapCanvasDockWidget( QWidget *parent )

toolBar->addWidget( mBtnMapThemes );

toolBar->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ),
tr( "Configure…" ), this, &Qgs3DMapCanvasDockWidget::configure );
// Options Menu
mOptionsMenu = new QMenu( this );

mBtnOptions = new QToolButton();
mBtnOptions->setAutoRaise( true );
mBtnOptions->setToolTip( tr( "Options" ) );
mBtnOptions->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ) );
mBtnOptions->setPopupMode( QToolButton::InstantPopup );
mBtnOptions->setMenu( mOptionsMenu );

toolBar->addWidget( mBtnOptions );

mActionEnableShadows = new QAction( tr( "Show Shadows" ), this );
mActionEnableShadows->setCheckable( true );
connect( mActionEnableShadows, &QAction::toggled, this, [ = ]( bool enabled )
{
QgsShadowSettings settings = mCanvas->map()->shadowSettings();
settings.setRenderShadows( enabled );
mCanvas->map()->setShadowSettings( settings );
} );
mOptionsMenu->addAction( mActionEnableShadows );

mActionEnableEyeDome = new QAction( tr( "Show Eye Dome Lighting" ), this );
mActionEnableEyeDome->setCheckable( true );
connect( mActionEnableEyeDome, &QAction::triggered, this, [ = ]( bool enabled )
{
mCanvas->map()->setEyeDomeLightingEnabled( enabled );
} );
mOptionsMenu->addAction( mActionEnableEyeDome );

mOptionsMenu->addSeparator();

QAction *configureAction = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ),
tr( "Configure…" ), this );
connect( configureAction, &QAction::triggered, this, &Qgs3DMapCanvasDockWidget::configure );
mOptionsMenu->addAction( configureAction );

mCanvas = new Qgs3DMapCanvas( contentsWidget );
mCanvas->setMinimumSize( QSize( 200, 200 ) );
@@ -226,6 +260,9 @@ void Qgs3DMapCanvasDockWidget::toggleNavigationWidget( bool visibility )

void Qgs3DMapCanvasDockWidget::setMapSettings( Qgs3DMapSettings *map )
{
whileBlocking( mActionEnableShadows )->setChecked( map->shadowSettings().renderShadows() );
whileBlocking( mActionEnableEyeDome )->setChecked( map->eyeDomeLightingEnabled() );

mCanvas->setMap( map );

connect( mCanvas->scene(), &Qgs3DMapScene::totalPendingJobsCountChanged, this, &Qgs3DMapCanvasDockWidget::onTotalPendingJobsCountChanged );
@@ -310,6 +347,9 @@ void Qgs3DMapCanvasDockWidget::configure()
if ( !dlg.exec() )
return;
applyConfig();

whileBlocking( mActionEnableShadows )->setChecked( map->shadowSettings().renderShadows() );
whileBlocking( mActionEnableEyeDome )->setChecked( map->eyeDomeLightingEnabled() );
}

void Qgs3DMapCanvasDockWidget::exportScene()
@@ -78,8 +78,12 @@ class APP_EXPORT Qgs3DMapCanvasDockWidget : public QgsDockWidget
Qgs3DMapToolIdentify *mMapToolIdentify = nullptr;
Qgs3DMapToolMeasureLine *mMapToolMeasureLine = nullptr;
QMenu *mMapThemeMenu = nullptr;
QMenu *mOptionsMenu = nullptr;
QList<QAction *> mMapThemeMenuPresetActions;
QToolButton *mBtnMapThemes = nullptr;
QAction *mActionEnableShadows = nullptr;
QAction *mActionEnableEyeDome = nullptr;
QToolButton *mBtnOptions = nullptr;
};

#endif // QGS3DMAPCANVASDOCKWIDGET_H

0 comments on commit b567a7c

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