Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3d] Add general 3d options tab, with settings for default camera
projection types and movement options These settings are inherited by all new 3d views
- Loading branch information
1 parent
a630ef4
commit 553c747
Showing
10 changed files
with
335 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*************************************************************************** | ||
qgs3doptions.cpp | ||
------------------------- | ||
begin : January 2021 | ||
copyright : (C) 2021 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* 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 "qgs3doptions.h" | ||
#include "qgsapplication.h" | ||
#include "qgssettings.h" | ||
#include "qgis.h" | ||
#include "qgsgui.h" | ||
#include "qgscameracontroller.h" | ||
#include <Qt3DRender/QCamera> | ||
|
||
// | ||
// QgsCodeEditorOptionsWidget | ||
// | ||
|
||
Qgs3DOptionsWidget::Qgs3DOptionsWidget( QWidget *parent ) | ||
: QgsOptionsPageWidget( parent ) | ||
{ | ||
setupUi( this ); | ||
|
||
layout()->setContentsMargins( 0, 0, 0, 0 ); | ||
|
||
mCameraNavigationModeCombo->addItem( tr( "Terrain Based" ), QgsCameraController::TerrainBasedNavigation ); | ||
mCameraNavigationModeCombo->addItem( tr( "Walk Mode (First Person)" ), QgsCameraController::WalkNavigation ); | ||
|
||
cboCameraProjectionType->addItem( tr( "Perspective Projection" ), Qt3DRender::QCameraLens::PerspectiveProjection ); | ||
cboCameraProjectionType->addItem( tr( "Orthogonal Projection" ), Qt3DRender::QCameraLens::OrthographicProjection ); | ||
|
||
mCameraMovementSpeed->setClearValue( 4 ); | ||
spinCameraFieldOfView->setClearValue( 45.0 ); | ||
|
||
QgsSettings settings; | ||
const QgsCameraController::NavigationMode defaultNavMode = settings.enumValue( QStringLiteral( "map3d/defaultNavigation" ), QgsCameraController::TerrainBasedNavigation, QgsSettings::App ); | ||
mCameraNavigationModeCombo->setCurrentIndex( mCameraNavigationModeCombo->findData( static_cast< int >( defaultNavMode ) ) ); | ||
|
||
const Qt3DRender::QCameraLens::ProjectionType defaultProjection = settings.enumValue( QStringLiteral( "map3d/defaultProjection" ), Qt3DRender::QCameraLens::PerspectiveProjection, QgsSettings::App ); | ||
cboCameraProjectionType->setCurrentIndex( cboCameraProjectionType->findData( static_cast< int >( defaultProjection ) ) ); | ||
|
||
mCameraMovementSpeed->setValue( settings.value( QStringLiteral( "map3d/defaultMovementSpeed" ), 5, QgsSettings::App ).toDouble() ); | ||
spinCameraFieldOfView->setValue( settings.value( QStringLiteral( "map3d/defaultFieldOfView" ), 45, QgsSettings::App ).toInt() ); | ||
} | ||
|
||
void Qgs3DOptionsWidget::apply() | ||
{ | ||
QgsSettings settings; | ||
settings.setValue( QStringLiteral( "map3d/defaultNavigation" ), static_cast< QgsCameraController::NavigationMode >( mCameraNavigationModeCombo->currentData().toInt() ), QgsSettings::App ); | ||
settings.setValue( QStringLiteral( "map3d/defaultProjection" ), static_cast< Qt3DRender::QCameraLens::ProjectionType >( cboCameraProjectionType->currentData().toInt() ), QgsSettings::App ); | ||
settings.setValue( QStringLiteral( "map3d/defaultMovementSpeed" ), mCameraMovementSpeed->value(), QgsSettings::App ); | ||
settings.setValue( QStringLiteral( "map3d/defaultFieldOfView" ), spinCameraFieldOfView->value(), QgsSettings::App ); | ||
} | ||
|
||
|
||
// | ||
// Qgs3DOptionsFactory | ||
// | ||
Qgs3DOptionsFactory::Qgs3DOptionsFactory() | ||
: QgsOptionsWidgetFactory( tr( "3D" ), QIcon() ) | ||
{ | ||
|
||
} | ||
|
||
QIcon Qgs3DOptionsFactory::icon() const | ||
{ | ||
return QgsApplication::getThemeIcon( QStringLiteral( "/3d.svg" ) ); | ||
} | ||
|
||
QgsOptionsPageWidget *Qgs3DOptionsFactory::createWidget( QWidget *parent ) const | ||
{ | ||
return new Qgs3DOptionsWidget( parent ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*************************************************************************** | ||
qgs3doptions.h | ||
------------------------- | ||
begin : January 2021 | ||
copyright : (C) 2021 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* 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 QGS3DOPTIONS_H | ||
#define QGS3DOPTIONS_H | ||
|
||
#include "ui_qgs3doptionsbase.h" | ||
#include "qgsoptionswidgetfactory.h" | ||
#include "qgscodeeditor.h" | ||
|
||
/** | ||
* \ingroup app | ||
* \class Qgs3DOptionsWidget | ||
* \brief An options widget showing 3D settings. | ||
* | ||
* \since QGIS 3.18 | ||
*/ | ||
class Qgs3DOptionsWidget : public QgsOptionsPageWidget, private Ui::Qgs3DOptionsBase | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for Qgs3DOptionsWidget with the specified \a parent widget. | ||
*/ | ||
Qgs3DOptionsWidget( QWidget *parent ); | ||
|
||
void apply() override; | ||
|
||
}; | ||
|
||
|
||
class Qgs3DOptionsFactory : public QgsOptionsWidgetFactory | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
Qgs3DOptionsFactory(); | ||
|
||
QIcon icon() const override; | ||
QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override; | ||
|
||
}; | ||
|
||
|
||
#endif // QGS3DOPTIONS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.