diff --git a/src/app/3d/qgs3ddebugwidget.cpp b/src/app/3d/qgs3ddebugwidget.cpp new file mode 100644 index 00000000000..8e54c7ffb2b --- /dev/null +++ b/src/app/3d/qgs3ddebugwidget.cpp @@ -0,0 +1,145 @@ +/*************************************************************************** + qgs3ddebugwidget.cpp + -------------------------------------- + Date : November 2024 + Copyright : (C) 2024 by Matej Bagar + Email : matej dot bagar at lutraconsulting dot co dot uk + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "qgis.h" + +#include "moc_qgs3ddebugwidget.cpp" +#include "qgs3ddebugwidget.h" +#include "qgs3dmapcanvas.h" +#include "qgscameracontroller.h" + +Qgs3DDebugWidget::Qgs3DDebugWidget( Qgs3DMapCanvas *canvas, QWidget *parent ) : QWidget( parent ), m3DMapCanvas( canvas ) +{ + // set up the widget defined in ui file + setupUi( this ); + + // set up the fixed width of debug widget + mCameraInfoGroupBox->setMinimumWidth( mCameraInfoGroupBox->sizeHint().width() ); + mCameraInfoGroupBox->adjustSize(); + scrollAreaWidgetContents->setMinimumWidth( scrollAreaWidgetContents->sizeHint().width() ); + scrollAreaWidgetContents->adjustSize(); + scrollArea->setMinimumWidth( scrollArea->sizeHint().width() ); + scrollArea->adjustSize(); + this->adjustSize(); + + // set up the shadow map block + mDebugShadowMapCornerComboBox->addItem( tr( "Top Left" ) ); + mDebugShadowMapCornerComboBox->addItem( tr( "Top Right" ) ); + mDebugShadowMapCornerComboBox->addItem( tr( "Bottom Left" ) ); + mDebugShadowMapCornerComboBox->addItem( tr( "Bottom Right" ) ); + mDebugShadowMapSizeSpinBox->setClearValue( 0.1 ); + + // set up the depth map block + mDebugDepthMapCornerComboBox->addItem( tr( "Top Left" ) ); + mDebugDepthMapCornerComboBox->addItem( tr( "Top Right" ) ); + mDebugDepthMapCornerComboBox->addItem( tr( "Bottom Left" ) ); + mDebugDepthMapCornerComboBox->addItem( tr( "Bottom Right" ) ); + mDebugDepthMapSizeSpinBox->setClearValue( 0.1 ); + + // set up the camera info block + mNearPlane->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mFarPlane->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mCameraX->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mCameraY->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mCameraZ->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mLookingX->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mLookingY->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + mLookingZ->setRange( std::numeric_limits::lowest(), std::numeric_limits::max() ); + + // hide camera info on first render + for ( QWidget *childWidget : mCameraInfoGroupBox->findChildren() ) + { + childWidget->setVisible( false ); + } + + // hide or show camera info on toggle + connect( mCameraInfoGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled ) + { + for ( QWidget *childWidget : mCameraInfoGroupBox->findChildren() ) + { + childWidget->setVisible( enabled ); + } + } ); +} + +/** + * Sets up the interactive elements with values from Qgs3DMapSettings + */ +void Qgs3DDebugWidget::setMapSettings( Qgs3DMapSettings *mapSettings ) +{ + mMap = mapSettings; + chkShowTileInfo->setChecked( mMap->showTerrainTilesInfo() ); + chkShowBoundingBoxes->setChecked( mMap->showTerrainBoundingBoxes() ); + chkShowCameraViewCenter->setChecked( mMap->showCameraViewCenter() ); + chkShowCameraRotationCenter->setChecked( mMap->showCameraRotationCenter() ); + chkShowLightSourceOrigins->setChecked( mMap->showLightSourceOrigins() ); + chkStopUpdates->setChecked( mMap->stopUpdates() ); + chkDebugOverlay->setChecked( mMap->isDebugOverlayEnabled() ); + connect( chkShowTileInfo, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowTerrainTilesInfo( enabled ); } ); + connect( chkShowBoundingBoxes, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowTerrainBoundingBoxes( enabled ); } ); + connect( chkShowCameraViewCenter, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowCameraViewCenter( enabled ); } ); + connect( chkShowCameraRotationCenter, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowCameraRotationCenter( enabled ); } ); + connect( chkShowLightSourceOrigins, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setShowLightSourceOrigins( enabled ); } ); + connect( chkStopUpdates, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setStopUpdates( enabled ); } ); + connect( chkDebugOverlay, &QCheckBox::toggled, this, [ = ]( const bool enabled ) {mMap->setIsDebugOverlayEnabled( enabled ); } ); + + mDebugShadowMapGroupBox->setChecked( mMap->debugShadowMapEnabled() ); + mDebugShadowMapCornerComboBox->setCurrentIndex( mMap->debugShadowMapCorner() ); + mDebugShadowMapSizeSpinBox->setValue( mMap->debugShadowMapSize() ); + // Do not display the shadow debug map if the shadow effect is not enabled. + connect( mDebugShadowMapGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled ) + { + mMap->setDebugShadowMapSettings( enabled && mMap->shadowSettings().renderShadows(), static_cast( mDebugShadowMapCornerComboBox->currentIndex() ), mDebugShadowMapSizeSpinBox->value() ); + } ); + connect( mDebugShadowMapCornerComboBox, QOverload::of( &QComboBox::currentIndexChanged ), this, [ = ]( const int index ) + { + mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast( index ), mDebugShadowMapSizeSpinBox->value() ); + } ); + connect( mDebugShadowMapSizeSpinBox, QOverload::of( &QDoubleSpinBox::valueChanged ), this, [ = ]( const int value ) + { + mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast( mDebugShadowMapCornerComboBox->currentIndex() ), value ); + } ); + + mDebugDepthMapGroupBox->setChecked( mMap->debugDepthMapEnabled() ); + mDebugDepthMapCornerComboBox->setCurrentIndex( mMap->debugDepthMapCorner() ); + mDebugDepthMapSizeSpinBox->setValue( mMap->debugDepthMapSize() ); + connect( mDebugDepthMapGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled ) + { + mMap->setDebugDepthMapSettings( enabled, static_cast( mDebugDepthMapCornerComboBox->currentIndex() ), mDebugDepthMapSizeSpinBox->value() ); + } ); + connect( mDebugDepthMapCornerComboBox, QOverload::of( &QComboBox::currentIndexChanged ), this, [ = ]( const int index ) + { + mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast( index ), mDebugDepthMapSizeSpinBox->value() ); + } ); + connect( mDebugShadowMapSizeSpinBox, QOverload::of( &QDoubleSpinBox::valueChanged ), this, [ = ]( const int value ) + { + mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast( mDebugDepthMapCornerComboBox->currentIndex() ), value ); + } ); +} + +/** + * Update the state of navigation widget from camera's state + */ +void Qgs3DDebugWidget::updateFromCamera() const +{ + mNearPlane->setValue( m3DMapCanvas->cameraController()->camera()->nearPlane() ); + mFarPlane->setValue( m3DMapCanvas->cameraController()->camera()->farPlane() ); + mCameraX->setValue( m3DMapCanvas->cameraController()->camera()->position().x() ); + mCameraY->setValue( m3DMapCanvas->cameraController()->camera()->position().y() ); + mCameraZ->setValue( m3DMapCanvas->cameraController()->camera()->position().z() ); + mLookingX->setValue( m3DMapCanvas->cameraController()->lookingAtPoint().x() ); + mLookingY->setValue( m3DMapCanvas->cameraController()->lookingAtPoint().y() ); + mLookingZ->setValue( m3DMapCanvas->cameraController()->lookingAtPoint().z() ); +} diff --git a/src/app/3d/qgs3ddebugwidget.h b/src/app/3d/qgs3ddebugwidget.h new file mode 100644 index 00000000000..68ce309ccbd --- /dev/null +++ b/src/app/3d/qgs3ddebugwidget.h @@ -0,0 +1,41 @@ +/*************************************************************************** + qgs3ddebugwidget.h + -------------------------------------- + Date : November 2024 + Copyright : (C) 2024 by Matej Bagar + Email : matej dot bagar at lutraconsulting dot co dot uk + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef QGS3DDEBUGWIDGET_H +#define QGS3DDEBUGWIDGET_H + +class QStandardItemModel; +class Qgs3DMapCanvas; + +#include +#include "qgs3dmapsettings.h" + +class Qgs3DDebugWidget : public QWidget, Ui::Q3DDebugWidget +{ + Q_OBJECT + public: + explicit Qgs3DDebugWidget( Qgs3DMapCanvas *canvas, QWidget *parent = nullptr ); + + void setMapSettings( Qgs3DMapSettings *mapSettings ); + + public slots: + void updateFromCamera() const; + + private: + Qgs3DMapSettings *mMap = nullptr; + Qgs3DMapCanvas *m3DMapCanvas = nullptr; +}; + +#endif // QGS3DDEBUGWIDGET_H diff --git a/src/app/3d/qgs3dmapcanvaswidget.cpp b/src/app/3d/qgs3dmapcanvaswidget.cpp index 4740fe03ad3..4555a8af65e 100644 --- a/src/app/3d/qgs3dmapcanvaswidget.cpp +++ b/src/app/3d/qgs3dmapcanvaswidget.cpp @@ -46,6 +46,7 @@ #include "qgs3dmaptoolidentify.h" #include "qgs3dmaptoolmeasureline.h" #include "qgs3dnavigationwidget.h" +#include "qgs3ddebugwidget.h" #include "qgs3dutils.h" #include "qgswindow3dengine.h" @@ -288,11 +289,13 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) mContainer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); mNavigationWidget = new Qgs3DNavigationWidget( mCanvas ); mNavigationWidget->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); + mDebugWidget = new Qgs3DDebugWidget( mCanvas ); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setContentsMargins( 0, 0, 0, 0 ); hLayout->addWidget( mContainer ); hLayout->addWidget( mNavigationWidget ); + hLayout->addWidget( mDebugWidget ); toggleNavigationWidget( setting.value( QStringLiteral( "/3D/navigationWidget/visibility" ), false, QgsSettings::Gui ).toBool() @@ -318,6 +321,19 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked ) { QgisApp::instance()->close3DMapView( canvasName() ); } ); + + QAction *toggleDebugPanel = toolBar->addAction( + QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/general.svg" ) ), + tr( "Toggle On-Screen Debug Information" ) ); + + toggleDebugPanel->setCheckable( true ); + toggleDebugPanel->setChecked( + setting.value( QStringLiteral( "/3D/debugWidget/visibility" ), false, QgsSettings::Gui ).toBool() + ); + toggleDebugWidget( + setting.value( QStringLiteral( "/3D/debugWidget/visibility" ), false, QgsSettings::Gui ).toBool() + ); + connect( toggleDebugPanel, &QAction::toggled, this, &Qgs3DMapCanvasWidget::toggleDebugWidget ); } Qgs3DMapCanvasWidget::~Qgs3DMapCanvasWidget() @@ -396,6 +412,13 @@ void Qgs3DMapCanvasWidget::toggleFpsCounter( bool visibility ) mLabelFpsCounter->setVisible( visibility ); } +void Qgs3DMapCanvasWidget::toggleDebugWidget( const bool visibility ) const +{ + mDebugWidget->setVisible( visibility ); + QgsSettings setting; + setting.setValue( QStringLiteral( "/3D/debugWidget/visibility" ), visibility, QgsSettings::Gui ); +} + void Qgs3DMapCanvasWidget::setMapSettings( Qgs3DMapSettings *map ) { whileBlocking( mActionEnableShadows )->setChecked( map->shadowSettings().renderShadows() ); @@ -407,14 +430,14 @@ void Qgs3DMapCanvasWidget::setMapSettings( Qgs3DMapSettings *map ) mCanvas->setMapSettings( map ); - // Connect the camera to the navigation widget. - connect( mCanvas->cameraController(), &QgsCameraController::cameraChanged, mNavigationWidget, &Qgs3DNavigationWidget::updateFromCamera ); connect( mCanvas->scene(), &Qgs3DMapScene::totalPendingJobsCountChanged, this, &Qgs3DMapCanvasWidget::onTotalPendingJobsCountChanged ); connect( mCanvas->scene(), &Qgs3DMapScene::gpuMemoryLimitReached, this, &Qgs3DMapCanvasWidget::onGpuMemoryLimitReached ); - // update the navigation widget when the near/far planes have been updated by the map scene - connect( mCanvas->cameraController()->camera(), &Qt3DRender::QCamera::nearPlaneChanged, mNavigationWidget, &Qgs3DNavigationWidget::updateFromCamera ); - connect( mCanvas->cameraController()->camera(), &Qt3DRender::QCamera::farPlaneChanged, mNavigationWidget, &Qgs3DNavigationWidget::updateFromCamera ); + // Connect the camera to the debug widget. + connect( mCanvas->cameraController(), &QgsCameraController::cameraChanged, mDebugWidget, &Qgs3DDebugWidget::updateFromCamera ); + // update the debug widget when the near/far planes have been updated by the map scene + connect( mCanvas->cameraController()->camera(), &Qt3DRender::QCamera::nearPlaneChanged, mDebugWidget, &Qgs3DDebugWidget::updateFromCamera ); + connect( mCanvas->cameraController()->camera(), &Qt3DRender::QCamera::farPlaneChanged, mDebugWidget, &Qgs3DDebugWidget::updateFromCamera ); mAnimationWidget->setCameraController( mCanvas->cameraController() ); mAnimationWidget->setMap( map ); diff --git a/src/app/3d/qgs3dmapcanvaswidget.h b/src/app/3d/qgs3dmapcanvaswidget.h index 17b460abaff..97064c52df3 100644 --- a/src/app/3d/qgs3dmapcanvaswidget.h +++ b/src/app/3d/qgs3dmapcanvaswidget.h @@ -36,6 +36,7 @@ class Qgs3DMapSettings; class Qgs3DMapToolIdentify; class Qgs3DMapToolMeasureLine; class Qgs3DNavigationWidget; +class Qgs3DDebugWidget; class QgsMapTool; class QgsMapToolExtent; class QgsMapCanvas; @@ -79,6 +80,7 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget void exportScene(); void toggleNavigationWidget( bool visibility ); void toggleFpsCounter( bool visibility ); + void toggleDebugWidget( bool visibility ) const; void setSceneExtentOn2DCanvas(); void setSceneExtent( const QgsRectangle &extent ); @@ -139,7 +141,8 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget QWidget *mContainer = nullptr; //! On-Screen Navigation widget. Qgs3DNavigationWidget *mNavigationWidget = nullptr; - + //! On-screen Debug widget + Qgs3DDebugWidget *mDebugWidget = nullptr; }; #endif // QGS3DMAPCANVASWIDGET_H diff --git a/src/app/3d/qgs3dmapconfigwidget.cpp b/src/app/3d/qgs3dmapconfigwidget.cpp index 7a0fc28dd1e..c9e29f5dda0 100644 --- a/src/app/3d/qgs3dmapconfigwidget.cpp +++ b/src/app/3d/qgs3dmapconfigwidget.cpp @@ -92,8 +92,6 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas terrainElevationOffsetSpinBox->setClearValue( 0.0 ); edlStrengthSpinBox->setClearValue( 1000 ); edlDistanceSpinBox->setClearValue( 1 ); - mDebugShadowMapSizeSpinBox->setClearValue( 0.1 ); - mDebugDepthMapSizeSpinBox->setClearValue( 0.1 ); cboTerrainLayer->setAllowEmptyLayer( true ); cboTerrainLayer->setFilters( Qgis::LayerFilter::RasterLayer ); @@ -158,16 +156,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas spinGroundError->setValue( mMap->maxTerrainGroundError() ); terrainElevationOffsetSpinBox->setValue( mMap->terrainElevationOffset() ); chkShowLabels->setChecked( mMap->showLabels() ); - chkShowTileInfo->setChecked( mMap->showTerrainTilesInfo() ); - chkShowBoundingBoxes->setChecked( mMap->showTerrainBoundingBoxes() ); - chkShowCameraViewCenter->setChecked( mMap->showCameraViewCenter() ); - chkShowCameraRotationCenter->setChecked( mMap->showCameraRotationCenter() ); - chkShowLightSourceOrigins->setChecked( mMap->showLightSourceOrigins() ); mFpsCounterCheckBox->setChecked( mMap->isFpsCounterEnabled() ); - chkStopUpdates->setChecked( mMap->stopUpdates() ); - - mDebugOverlayCheckBox->setChecked( mMap->isDebugOverlayEnabled() ); - mDebugOverlayCheckBox->setVisible( true ); groupTerrainShading->setChecked( mMap->isTerrainShadingEnabled() ); widgetTerrainMaterial->setTechnique( QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture ); @@ -232,25 +221,6 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas edlStrengthSpinBox->setValue( map->eyeDomeLightingStrength() ); edlDistanceSpinBox->setValue( map->eyeDomeLightingDistance() ); - mDebugShadowMapCornerComboBox->addItem( tr( "Top Left" ) ); - mDebugShadowMapCornerComboBox->addItem( tr( "Top Right" ) ); - mDebugShadowMapCornerComboBox->addItem( tr( "Bottom Left" ) ); - mDebugShadowMapCornerComboBox->addItem( tr( "Bottom Right" ) ); - - mDebugDepthMapCornerComboBox->addItem( tr( "Top Left" ) ); - mDebugDepthMapCornerComboBox->addItem( tr( "Top Right" ) ); - mDebugDepthMapCornerComboBox->addItem( tr( "Bottom Left" ) ); - mDebugDepthMapCornerComboBox->addItem( tr( "Bottom Right" ) ); - - mDebugShadowMapGroupBox->setChecked( map->debugShadowMapEnabled() ); - - mDebugShadowMapCornerComboBox->setCurrentIndex( static_cast( map->debugShadowMapCorner() ) ); - mDebugShadowMapSizeSpinBox->setValue( map->debugShadowMapSize() ); - - mDebugDepthMapGroupBox->setChecked( map->debugDepthMapEnabled() ); - mDebugDepthMapCornerComboBox->setCurrentIndex( static_cast( map->debugDepthMapCorner() ) ); - mDebugDepthMapSizeSpinBox->setValue( map->debugDepthMapSize() ); - // Ambient occlusion mAmbientOcclusionSettingsWidget->setAmbientOcclusionSettings( map->ambientOcclusionSettings() ); @@ -373,15 +343,8 @@ void Qgs3DMapConfigWidget::apply() mMap->setMaxTerrainGroundError( spinGroundError->value() ); mMap->setTerrainElevationOffset( terrainElevationOffsetSpinBox->value() ); mMap->setShowLabels( chkShowLabels->isChecked() ); - mMap->setShowTerrainTilesInfo( chkShowTileInfo->isChecked() ); - mMap->setShowTerrainBoundingBoxes( chkShowBoundingBoxes->isChecked() ); - mMap->setShowCameraViewCenter( chkShowCameraViewCenter->isChecked() ); - mMap->setShowCameraRotationCenter( chkShowCameraRotationCenter->isChecked() ); - mMap->setShowLightSourceOrigins( chkShowLightSourceOrigins->isChecked() ); mMap->setIsFpsCounterEnabled( mFpsCounterCheckBox->isChecked() ); - mMap->setStopUpdates( chkStopUpdates->isChecked() ); mMap->setTerrainShadingEnabled( groupTerrainShading->isChecked() ); - mMap->setIsDebugOverlayEnabled( mDebugOverlayCheckBox->isChecked() ); const std::unique_ptr< QgsAbstractMaterialSettings > terrainMaterial( widgetTerrainMaterial->settings() ); if ( QgsPhongMaterialSettings *phongMaterial = dynamic_cast< QgsPhongMaterialSettings * >( terrainMaterial.get() ) ) @@ -405,11 +368,6 @@ void Qgs3DMapConfigWidget::apply() viewSyncMode.setFlag( Qgis::ViewSyncModeFlag::Sync3DTo2D, mSync3DTo2DCheckbox->isChecked() ); mMap->setViewSyncMode( viewSyncMode ); mMap->setViewFrustumVisualizationEnabled( mVisualizeExtentCheckBox->isChecked() ); - - mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast( mDebugDepthMapCornerComboBox->currentIndex() ), mDebugDepthMapSizeSpinBox->value() ); - - // Do not display the shadow debug map if the shadow effect is not enabled. - mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && groupShadowRendering->isChecked(), static_cast( mDebugShadowMapCornerComboBox->currentIndex() ), mDebugShadowMapSizeSpinBox->value() ); } void Qgs3DMapConfigWidget::onTerrainTypeChanged() diff --git a/src/app/3d/qgs3dnavigationwidget.cpp b/src/app/3d/qgs3dnavigationwidget.cpp index 634f9190e55..4d72d3a2a49 100644 --- a/src/app/3d/qgs3dnavigationwidget.cpp +++ b/src/app/3d/qgs3dnavigationwidget.cpp @@ -138,37 +138,4 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p m3DMapCanvas->cameraController()->moveView( -1, 0 ); } ); - - mCameraInfoItemModel = new QStandardItemModel( this ); - - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Near plane" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Far plane" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Camera X pos" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Camera Y pos" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Camera Z pos" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Looking at X" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Looking at Y" ) ), new QStandardItem } ); - mCameraInfoItemModel->appendRow( QList { new QStandardItem( QStringLiteral( "Looking at Z" ) ), new QStandardItem } ); - - mCameraInfo->setModel( mCameraInfoItemModel ); - mCameraInfo->verticalHeader()->hide(); - mCameraInfo->horizontalHeader()->hide(); - mCameraInfo->horizontalHeader()->setSectionResizeMode( QHeaderView::ResizeMode::Stretch ); - - QObject::connect( mCameraInfoCheckBox, &QCheckBox::clicked, m3DMapCanvas, [ = ]( bool enabled ) { mCameraInfo->setVisible( enabled ); } ); -} - -void Qgs3DNavigationWidget::updateFromCamera() -{ - // Make sure the angle is between 0 - 359 - whileBlocking( mCompass )->setValue( fmod( m3DMapCanvas->cameraController()->yaw() + 360, 360 ) ); - - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 0, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->camera()->nearPlane() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 1, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->camera()->farPlane() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 2, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->camera()->position().x() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 3, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->camera()->position().y() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 4, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->camera()->position().z() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 5, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->lookingAtPoint().x() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 6, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->lookingAtPoint().y() ) ); - mCameraInfoItemModel->setData( mCameraInfoItemModel->index( 7, 1 ), QStringLiteral( "%1" ).arg( m3DMapCanvas->cameraController()->lookingAtPoint().z() ) ); } diff --git a/src/app/3d/qgs3dnavigationwidget.h b/src/app/3d/qgs3dnavigationwidget.h index 49266632d1d..a393e9a82a1 100644 --- a/src/app/3d/qgs3dnavigationwidget.h +++ b/src/app/3d/qgs3dnavigationwidget.h @@ -29,16 +29,8 @@ class Qgs3DNavigationWidget : public QWidget, private Ui::Q3DNavigationWidget public: Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *parent = nullptr ); - public slots: - - /** - * Update the state of navigation widget from camera's state - */ - void updateFromCamera(); - private: Qgs3DMapCanvas *m3DMapCanvas = nullptr; - QStandardItemModel *mCameraInfoItemModel = nullptr; }; #endif // QGS3DNAVIGATIONWIDGET_H diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 10105ca8fd6..1fd7c2278cf 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -379,6 +379,7 @@ if (WITH_3D) 3d/qgspointcloudlayer3drendererwidget.cpp 3d/qgs3dmapcanvaswidget.cpp 3d/qgs3dviewsmanagerdialog.cpp + 3d/qgs3ddebugwidget.cpp ) endif() diff --git a/src/ui/3d/3ddebugwidget.ui b/src/ui/3d/3ddebugwidget.ui new file mode 100644 index 00000000000..3be9f3886fe --- /dev/null +++ b/src/ui/3d/3ddebugwidget.ui @@ -0,0 +1,362 @@ + + + Q3DDebugWidget + + + + 0 + 0 + 283 + 452 + + + + + 0 + 0 + + + + Form + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + Qt::ScrollBarAsNeeded + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + 0 + 0 + 250 + 792 + + + + + 0 + 0 + + + + + QLayout::SetDefaultConstraint + + + 6 + + + + + + + Show map tile info + + + + + + + Show bounding boxes + + + + + + + Show camera's view center + + + + + + + Show camera's rotation center + + + + + + + Show light sources + + + + + + + Stop scene updates + + + + + + + true + + + Show debug overlay + + + + + + + + + Debug Shadow Map + + + true + + + false + + + + + + + + + Corner + + + + + + + Size + + + + + + + 1.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + + + + Debug Depth Map + + + true + + + false + + + + + + + + + Size + + + + + + + Corner + + + + + + + 1.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + + + + Show camera info + + + true + + + false + + + + QLayout::SetDefaultConstraint + + + + + 6 + + + + + + + Looking at X + + + + + + + Looking at Y + + + + + + + QAbstractSpinBox::UpDownArrows + + + 6 + + + + + + + QAbstractSpinBox::UpDownArrows + + + 6 + + + + + + + Camera X pos + + + + + + + Camera Y pos + + + + + + + 6 + + + + + + + Far plane + + + + + + + Camera Z pos + + + + + + + Near plane + + + + + + + 6 + + + + + + + Looking at Z + + + + + + + 6 + + + + + + + 6 + + + + + + + 6 + + + + + + + + + + + + + + + QgsDoubleSpinBox + QDoubleSpinBox +
qgsdoublespinbox.h
+
+
+ + +
diff --git a/src/ui/3d/3dnavigationwidget.ui b/src/ui/3d/3dnavigationwidget.ui index 688911104b4..ea3eba58bcc 100644 --- a/src/ui/3d/3dnavigationwidget.ui +++ b/src/ui/3d/3dnavigationwidget.ui @@ -26,9 +26,6 @@ 2 - - Qt::AlignTop - @@ -36,11 +33,15 @@ + + Move up + - - Move up + + + :/images/themes/default/mActionArrowUp.svg:/images/themes/default/mActionArrowUp.svg true @@ -48,22 +49,19 @@ true - - - :/images/themes/default/mActionArrowUp.svg:/images/themes/default/mActionArrowUp.svg - - + Zoom In - - Zoom In + + + :/images/themes/default/mActionZoomIn.svg:/images/themes/default/mActionZoomIn.svg true @@ -71,19 +69,19 @@ true - - - :/images/themes/default/mActionZoomIn.svg:/images/themes/default/mActionZoomIn.svg - + + Tilt up + - - Tilt up + + + :/images/themes/default/mActionTiltUp.svg:/images/themes/default/mActionTiltUp.svg true @@ -91,19 +89,19 @@ true - - - :/images/themes/default/mActionTiltUp.svg:/images/themes/default/mActionTiltUp.svg - + + Move left + - - Move left + + + :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg true @@ -111,10 +109,6 @@ true - - - :/images/themes/default/mActionArrowLeft.svg:/images/themes/default/mActionArrowLeft.svg - @@ -132,11 +126,15 @@ + + Move right + - - Move right + + + :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg true @@ -144,19 +142,19 @@ true - - - :/images/themes/default/mActionArrowRight.svg:/images/themes/default/mActionArrowRight.svg - + + Zoom Out + - - Zoom Out + + + :/images/themes/default/mActionZoomOut.svg:/images/themes/default/mActionZoomOut.svg true @@ -164,19 +162,19 @@ true - - - :/images/themes/default/mActionZoomOut.svg:/images/themes/default/mActionZoomOut.svg - + + Move down + - - Move down + + + :/images/themes/default/mActionArrowDown.svg:/images/themes/default/mActionArrowDown.svg true @@ -184,19 +182,19 @@ true - - - :/images/themes/default/mActionArrowDown.svg:/images/themes/default/mActionArrowDown.svg - + + Tilt down + - - Tilt down + + + :/images/themes/default/mActionTiltDown.svg:/images/themes/default/mActionTiltDown.svg true @@ -204,43 +202,22 @@ true - - - :/images/themes/default/mActionTiltDown.svg:/images/themes/default/mActionTiltDown.svg - - - - 0 + + + Qt::Vertical - - 0 + + + 20 + 40 + - - - - Show camera info (for debugging) - - - false - - - - - - - false - - - QAbstractItemView::NoEditTriggers - - - - + diff --git a/src/ui/3d/map3dconfigwidget.ui b/src/ui/3d/map3dconfigwidget.ui index f1305337f5f..549f491d4b0 100644 --- a/src/ui/3d/map3dconfigwidget.ui +++ b/src/ui/3d/map3dconfigwidget.ui @@ -217,8 +217,8 @@ 0 0 - 818 - 649 + 100 + 30 @@ -963,53 +963,46 @@ Advanced Settings - - - - Debug Depth Map - - - true - - - false - - - - - - - - - Size - - - - - - - Corner - - - - - - - 1.000000000000000 - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - + + + + Max. screen error + + + + + + + Max. ground error + + + + + + + px + + + 4096 + + + + + + + Show frames per second (FPS) + + + + + + + Show labels + + + @@ -1029,13 +1022,6 @@ - - - - Show bounding boxes - - - @@ -1043,89 +1029,6 @@ - - - - Map tile resolution - - - - - - - Show camera's rotation center - - - - - - - px - - - 4096 - - - - - - - Max. screen error - - - - - - - Show frames per second (FPS) - - - - - - - Zoom levels - - - - - - - Show labels - - - - - - - Show camera's view center - - - - - - - Show map tile info - - - - - - - false - - - Show debug overlay - - - - - - - Show light sources - - - @@ -1136,68 +1039,23 @@ - - + + - Max. ground error + Map tile resolution - - + + - Stop scene updates + Zoom levels - - - Debug Shadow Map - - - true - - - false - - - - - - - - - Corner - - - - - - - Size - - - - - - - 1.000000000000000 - - - 0.100000000000000 - - - 0.100000000000000 - - - - - - - Qt::Vertical @@ -1304,20 +1162,10 @@ spinScreenError spinGroundError chkShowLabels - chkShowTileInfo - chkShowBoundingBoxes - chkShowCameraViewCenter - chkShowLightSourceOrigins mFpsCounterCheckBox edlGroupBox edlStrengthSpinBox edlDistanceSpinBox - mDebugShadowMapGroupBox - mDebugShadowMapCornerComboBox - mDebugShadowMapSizeSpinBox - mDebugDepthMapGroupBox - mDebugDepthMapCornerComboBox - mDebugDepthMapSizeSpinBox