mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
run pre-commit
This commit is contained in:
parent
5b60c23a49
commit
33ea41a100
@ -23,39 +23,38 @@
|
||||
#include <QObject>
|
||||
#include <qgsapplication.h>
|
||||
|
||||
class %{CN}: public QObject
|
||||
class % { CN } : public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase(); // will be called before the first testfunction is executed.
|
||||
void initTestCase(); // will be called before the first testfunction is executed.
|
||||
void cleanupTestCase(); // will be called after the last testfunction was executed.
|
||||
void init(); // will be called before each testfunction is executed.
|
||||
void cleanup(); // will be called after every testfunction.
|
||||
void init(); // will be called before each testfunction is executed.
|
||||
void cleanup(); // will be called after every testfunction.
|
||||
|
||||
// Add your test methods here
|
||||
};
|
||||
|
||||
void %{CN}::initTestCase()
|
||||
void % { CN }
|
||||
::initTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void %{CN}::cleanupTestCase()
|
||||
void % { CN }
|
||||
::cleanupTestCase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void %{CN}::init()
|
||||
void % { CN }
|
||||
::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void %{CN}::cleanup()
|
||||
void % { CN }
|
||||
::cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( %{CN} )
|
||||
QGSTEST_MAIN( % { CN } )
|
||||
#include "%{JS: Cpp.classToFileName('%{Class}', '.moc')}"
|
||||
|
||||
@ -25,7 +25,8 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr )
|
||||
Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog()
|
||||
: QDialog( nullptr )
|
||||
{
|
||||
setupUi( this );
|
||||
mFpsSpinBox->setClearValue( 30 );
|
||||
@ -33,16 +34,13 @@ Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr )
|
||||
mHeightSpinBox->setClearValue( 600 );
|
||||
const QgsSettings settings;
|
||||
|
||||
const QString templateText = settings.value( QStringLiteral( "Export3DAnimation/fileNameTemplate" ),
|
||||
QStringLiteral( "%1####.jpg" ).arg( QgsProject::instance()->baseName() )
|
||||
, QgsSettings::App ).toString();
|
||||
const QString templateText = settings.value( QStringLiteral( "Export3DAnimation/fileNameTemplate" ), QStringLiteral( "%1####.jpg" ).arg( QgsProject::instance()->baseName() ), QgsSettings::App ).toString();
|
||||
mTemplateLineEdit->setText( templateText );
|
||||
const thread_local QRegularExpression rx( QStringLiteral( "^\\w+#+\\.{1}\\w+$" ) ); //e.g. anyprefix#####.png
|
||||
QValidator *validator = new QRegularExpressionValidator( rx, this );
|
||||
mTemplateLineEdit->setValidator( validator );
|
||||
|
||||
connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [ = ]
|
||||
{
|
||||
connect( mTemplateLineEdit, &QLineEdit::textChanged, this, [=] {
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Export3DAnimation/fileNameTemplate" ), mTemplateLineEdit->text() );
|
||||
} );
|
||||
@ -53,35 +51,30 @@ Qgs3DAnimationExportDialog::Qgs3DAnimationExportDialog(): QDialog( nullptr )
|
||||
mOutputDirFileWidget->setDefaultRoot( settings.value( QStringLiteral( "Export3DAnimation/lastDir" ), QString(), QgsSettings::App ).toString() );
|
||||
mOutputDirFileWidget->setFilePath( settings.value( QStringLiteral( "Export3DAnimation/lastDir" ), QString(), QgsSettings::App ).toString() );
|
||||
|
||||
connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [ = ]
|
||||
{
|
||||
connect( mOutputDirFileWidget, &QgsFileWidget::fileChanged, this, [=] {
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Export3DAnimation/lastDir" ), mOutputDirFileWidget->filePath(), QgsSettings::App );
|
||||
} );
|
||||
|
||||
mFpsSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/fps" ), 30 ).toInt() );
|
||||
connect( mFpsSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( mFpsSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QgsSpinBox::valueChanged ), this, [=] {
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Export3DAnimation/fps" ), mFpsSpinBox->value() );
|
||||
} );
|
||||
|
||||
mWidthSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/width" ), 800 ).toInt() );
|
||||
connect( mWidthSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( mWidthSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QgsSpinBox::valueChanged ), this, [=] {
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Export3DAnimation/width" ), mWidthSpinBox->value() );
|
||||
} );
|
||||
|
||||
mHeightSpinBox->setValue( settings.value( QStringLiteral( "Export3DAnimation/height" ), 600 ).toInt() );
|
||||
connect( mHeightSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QgsSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( mHeightSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QgsSpinBox::valueChanged ), this, [=] {
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "Export3DAnimation/height" ), mHeightSpinBox->value() );
|
||||
} );
|
||||
|
||||
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [ = ]
|
||||
{
|
||||
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [=] {
|
||||
QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html#create-animation" ) );
|
||||
} );
|
||||
|
||||
|
||||
@ -36,10 +36,10 @@ class Qgs3DAnimationExportDialog : public QDialog, private Ui::AnimationExport3D
|
||||
~Qgs3DAnimationExportDialog() override;
|
||||
|
||||
//! Returns output directory for frames
|
||||
QString outputDirectory( ) const;
|
||||
QString outputDirectory() const;
|
||||
|
||||
//! Returns filename template for frames
|
||||
QString fileNameExpression( ) const;
|
||||
QString fileNameExpression() const;
|
||||
|
||||
//! Returns frames per second
|
||||
int fps() const;
|
||||
|
||||
@ -191,15 +191,13 @@ void Qgs3DAnimationWidget::onExportAnimation()
|
||||
if ( dialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
QgsFeedback progressFeedback;
|
||||
std::unique_ptr< QgsScopedProxyProgressTask > progressTask = std::make_unique< QgsScopedProxyProgressTask >( tr( "Exporting animation" ) );
|
||||
std::unique_ptr<QgsScopedProxyProgressTask> progressTask = std::make_unique<QgsScopedProxyProgressTask>( tr( "Exporting animation" ) );
|
||||
|
||||
QProgressDialog progressDialog( tr( "Exporting frames..." ), tr( "Abort" ), 0, 100, this );
|
||||
progressDialog.setWindowModality( Qt::WindowModal );
|
||||
QString error;
|
||||
|
||||
connect( &progressFeedback, &QgsFeedback::progressChanged, this,
|
||||
[&progressDialog, &progressTask]( double progress )
|
||||
{
|
||||
connect( &progressFeedback, &QgsFeedback::progressChanged, this, [&progressDialog, &progressTask]( double progress ) {
|
||||
progressDialog.setValue( static_cast<int>( progress ) );
|
||||
progressTask->setProgress( progress );
|
||||
QCoreApplication::processEvents();
|
||||
@ -208,14 +206,15 @@ void Qgs3DAnimationWidget::onExportAnimation()
|
||||
connect( &progressDialog, &QProgressDialog::canceled, &progressFeedback, &QgsFeedback::cancel );
|
||||
|
||||
const bool success = Qgs3DUtils::exportAnimation(
|
||||
animation(),
|
||||
*mMap,
|
||||
dialog.fps(),
|
||||
dialog.outputDirectory(),
|
||||
dialog.fileNameExpression(),
|
||||
dialog.frameSize(),
|
||||
error,
|
||||
&progressFeedback );
|
||||
animation(),
|
||||
*mMap,
|
||||
dialog.fps(),
|
||||
dialog.outputDirectory(),
|
||||
dialog.fileNameExpression(),
|
||||
dialog.frameSize(),
|
||||
error,
|
||||
&progressFeedback
|
||||
);
|
||||
|
||||
progressTask.reset();
|
||||
|
||||
|
||||
@ -31,16 +31,16 @@
|
||||
|
||||
void Qgs3DAppUtils::initialize()
|
||||
{
|
||||
qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "point" ) ) )->setWidgetFunction( QgsPoint3DSymbolWidget::create );
|
||||
qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "line" ) ) )->setWidgetFunction( QgsLine3DSymbolWidget::create );
|
||||
qgis::down_cast< Qgs3DSymbolMetadata * >( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "polygon" ) ) )->setWidgetFunction( QgsPolygon3DSymbolWidget::create );
|
||||
qgis::down_cast<Qgs3DSymbolMetadata *>( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "point" ) ) )->setWidgetFunction( QgsPoint3DSymbolWidget::create );
|
||||
qgis::down_cast<Qgs3DSymbolMetadata *>( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "line" ) ) )->setWidgetFunction( QgsLine3DSymbolWidget::create );
|
||||
qgis::down_cast<Qgs3DSymbolMetadata *>( QgsApplication::symbol3DRegistry()->symbolMetadata( QStringLiteral( "polygon" ) ) )->setWidgetFunction( QgsPolygon3DSymbolWidget::create );
|
||||
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "null" ) ) )->setWidgetFunction( QgsNullMaterialWidget::create );
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phong" ) ) )->setWidgetFunction( QgsPhongMaterialWidget::create );
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phongtextured" ) ) )->setWidgetFunction( QgsPhongTexturedMaterialWidget::create );
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "gooch" ) ) )->setWidgetFunction( QgsGoochMaterialWidget::create );
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "simpleline" ) ) )->setWidgetFunction( QgsSimpleLineMaterialWidget::create );
|
||||
qgis::down_cast< QgsMaterialSettingsMetadata * >( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "metalrough" ) ) )->setWidgetFunction( QgsMetalRoughMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "null" ) ) )->setWidgetFunction( QgsNullMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phong" ) ) )->setWidgetFunction( QgsPhongMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "phongtextured" ) ) )->setWidgetFunction( QgsPhongTexturedMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "gooch" ) ) )->setWidgetFunction( QgsGoochMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "simpleline" ) ) )->setWidgetFunction( QgsSimpleLineMaterialWidget::create );
|
||||
qgis::down_cast<QgsMaterialSettingsMetadata *>( Qgs3D::materialRegistry()->materialSettingsMetadata( QStringLiteral( "metalrough" ) ) )->setWidgetFunction( QgsMetalRoughMaterialWidget::create );
|
||||
|
||||
QgsStyleModel::setIconGenerator( new Qgs3DIconGenerator( QgsApplication::defaultStyleModel() ) );
|
||||
}
|
||||
|
||||
@ -21,12 +21,10 @@
|
||||
class Qgs3DAppUtils
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Initializes 3D components belonging to the app library.
|
||||
*/
|
||||
static void initialize();
|
||||
|
||||
};
|
||||
|
||||
#endif // QGS3DAPPUTILS_H
|
||||
|
||||
@ -73,29 +73,26 @@ void Qgs3DDebugWidget::setMapSettings( Qgs3DMapSettings *mapSettings )
|
||||
whileBlocking( chkShowLightSourceOrigins )->setChecked( mMap->showLightSourceOrigins() );
|
||||
whileBlocking( chkStopUpdates )->setChecked( mMap->stopUpdates() );
|
||||
whileBlocking( 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 ); } );
|
||||
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 ); } );
|
||||
|
||||
// set up the shadow map block
|
||||
whileBlocking( mDebugShadowMapGroupBox )->setChecked( mMap->debugShadowMapEnabled() );
|
||||
whileBlocking( mDebugShadowMapCornerComboBox )->setCurrentIndex( mMap->debugShadowMapCorner() );
|
||||
whileBlocking( 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 )
|
||||
{
|
||||
connect( mDebugShadowMapGroupBox, &QGroupBox::toggled, this, [=]( const bool enabled ) {
|
||||
mMap->setDebugShadowMapSettings( enabled && mMap->shadowSettings().renderShadows(), static_cast<Qt::Corner>( mDebugShadowMapCornerComboBox->currentIndex() ), mDebugShadowMapSizeSpinBox->value() );
|
||||
} );
|
||||
connect( mDebugShadowMapCornerComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( const int index )
|
||||
{
|
||||
connect( mDebugShadowMapCornerComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( const int index ) {
|
||||
mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast<Qt::Corner>( index ), mDebugShadowMapSizeSpinBox->value() );
|
||||
} );
|
||||
connect( mDebugShadowMapSizeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mDebugShadowMapSizeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
mMap->setDebugShadowMapSettings( mDebugShadowMapGroupBox->isChecked() && mMap->shadowSettings().renderShadows(), static_cast<Qt::Corner>( mDebugShadowMapCornerComboBox->currentIndex() ), value );
|
||||
} );
|
||||
|
||||
@ -103,75 +100,67 @@ void Qgs3DDebugWidget::setMapSettings( Qgs3DMapSettings *mapSettings )
|
||||
whileBlocking( mDebugDepthMapGroupBox )->setChecked( mMap->debugDepthMapEnabled() );
|
||||
whileBlocking( mDebugDepthMapCornerComboBox )->setCurrentIndex( mMap->debugDepthMapCorner() );
|
||||
whileBlocking( mDebugDepthMapSizeSpinBox )->setValue( mMap->debugDepthMapSize() );
|
||||
connect( mDebugDepthMapGroupBox, &QGroupBox::toggled, this, [ = ]( const bool enabled )
|
||||
{
|
||||
connect( mDebugDepthMapGroupBox, &QGroupBox::toggled, this, [=]( const bool enabled ) {
|
||||
mMap->setDebugDepthMapSettings( enabled, static_cast<Qt::Corner>( mDebugDepthMapCornerComboBox->currentIndex() ), mDebugDepthMapSizeSpinBox->value() );
|
||||
} );
|
||||
connect( mDebugDepthMapCornerComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( const int index )
|
||||
{
|
||||
connect( mDebugDepthMapCornerComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( const int index ) {
|
||||
mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast<Qt::Corner>( index ), mDebugDepthMapSizeSpinBox->value() );
|
||||
} );
|
||||
connect( mDebugDepthMapSizeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mDebugDepthMapSizeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
mMap->setDebugDepthMapSettings( mDebugDepthMapGroupBox->isChecked(), static_cast<Qt::Corner>( mDebugDepthMapCornerComboBox->currentIndex() ), value );
|
||||
} );
|
||||
|
||||
// connect the camera info spin boxes with changing functions
|
||||
connect( mNearPlane, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mNearPlane, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
m3DMapCanvas->cameraController()->camera()->setNearPlane( static_cast<float>( value ) );
|
||||
} );
|
||||
connect( mFarPlane, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mFarPlane, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
m3DMapCanvas->cameraController()->camera()->setFarPlane( static_cast<float>( value ) );
|
||||
} );
|
||||
connect( mCameraX, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
connect( mCameraX, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
newPosition.setX( static_cast<float>( value ) );
|
||||
m3DMapCanvas->cameraController()->camera()->setPosition( newPosition );
|
||||
} );
|
||||
connect( mCameraY, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
connect( mCameraY, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
newPosition.setY( static_cast<float>( value ) );
|
||||
m3DMapCanvas->cameraController()->camera()->setPosition( newPosition );
|
||||
} );
|
||||
connect( mCameraZ, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
connect( mCameraZ, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QVector3D newPosition = m3DMapCanvas->cameraController()->camera()->position();
|
||||
newPosition.setZ( static_cast<float>( value ) );
|
||||
m3DMapCanvas->cameraController()->camera()->setPosition( newPosition );
|
||||
} );
|
||||
connect( mLookingX, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mLookingX, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint();
|
||||
newLookingAt.setX( value );
|
||||
m3DMapCanvas->cameraController()->setLookingAtPoint(
|
||||
newLookingAt,
|
||||
m3DMapCanvas->cameraController()->distance(),
|
||||
m3DMapCanvas->cameraController()->pitch(),
|
||||
m3DMapCanvas->cameraController()->yaw() );
|
||||
m3DMapCanvas->cameraController()->yaw()
|
||||
);
|
||||
} );
|
||||
connect( mLookingY, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mLookingY, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint();
|
||||
newLookingAt.setY( value );
|
||||
m3DMapCanvas->cameraController()->setLookingAtPoint(
|
||||
newLookingAt,
|
||||
m3DMapCanvas->cameraController()->distance(),
|
||||
m3DMapCanvas->cameraController()->pitch(),
|
||||
m3DMapCanvas->cameraController()->yaw() );
|
||||
m3DMapCanvas->cameraController()->yaw()
|
||||
);
|
||||
} );
|
||||
connect( mLookingZ, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( const double value )
|
||||
{
|
||||
connect( mLookingZ, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( const double value ) {
|
||||
QgsVector3D newLookingAt = m3DMapCanvas->cameraController()->lookingAtPoint();
|
||||
newLookingAt.setZ( value );
|
||||
m3DMapCanvas->cameraController()->setLookingAtPoint(
|
||||
newLookingAt,
|
||||
m3DMapCanvas->cameraController()->distance(),
|
||||
m3DMapCanvas->cameraController()->pitch(),
|
||||
m3DMapCanvas->cameraController()->yaw() );
|
||||
m3DMapCanvas->cameraController()->yaw()
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@ -21,13 +21,12 @@
|
||||
Qgs3DIconGenerator::Qgs3DIconGenerator( QObject *parent )
|
||||
: QgsAbstractStyleEntityIconGenerator( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Qgs3DIconGenerator::generateIcon( QgsStyle *, QgsStyle::StyleEntity type, const QString &name )
|
||||
{
|
||||
QIcon icon;
|
||||
const QList< QSize > sizes = iconSizes();
|
||||
const QList<QSize> sizes = iconSizes();
|
||||
if ( sizes.isEmpty() )
|
||||
icon.addFile( QgsApplication::defaultThemePath() + QDir::separator() + QStringLiteral( "3d.svg" ), QSize( 24, 24 ) );
|
||||
for ( const QSize &s : sizes )
|
||||
|
||||
@ -25,7 +25,6 @@ class Qgs3DIconGenerator : public QgsAbstractStyleEntityIconGenerator
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Qgs3DIconGenerator( QObject *parent );
|
||||
|
||||
void generateIcon( QgsStyle *style, QgsStyle::StyleEntity type, const QString &name ) override;
|
||||
|
||||
@ -68,16 +68,15 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
QToolBar *toolBar = new QToolBar( this );
|
||||
toolBar->setIconSize( QgisApp::instance()->iconSize( isDocked ) );
|
||||
|
||||
QAction *actionCameraControl = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionPan.svg" ) ),
|
||||
tr( "Camera Control" ), this, &Qgs3DMapCanvasWidget::cameraControl );
|
||||
QAction *actionCameraControl = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionPan.svg" ) ), tr( "Camera Control" ), this, &Qgs3DMapCanvasWidget::cameraControl );
|
||||
actionCameraControl->setCheckable( true );
|
||||
|
||||
toolBar->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionZoomFullExtent.svg" ) ),
|
||||
tr( "Zoom Full" ), this, &Qgs3DMapCanvasWidget::resetView );
|
||||
toolBar->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionZoomFullExtent.svg" ) ), tr( "Zoom Full" ), this, &Qgs3DMapCanvasWidget::resetView );
|
||||
|
||||
QAction *toggleOnScreenNavigation = toolBar->addAction(
|
||||
QgsApplication::getThemeIcon( QStringLiteral( "mAction3DNavigation.svg" ) ),
|
||||
tr( "Toggle On-Screen Navigation" ) );
|
||||
QgsApplication::getThemeIcon( QStringLiteral( "mAction3DNavigation.svg" ) ),
|
||||
tr( "Toggle On-Screen Navigation" )
|
||||
);
|
||||
|
||||
toggleOnScreenNavigation->setCheckable( true );
|
||||
toggleOnScreenNavigation->setChecked(
|
||||
@ -87,12 +86,10 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
toolBar->addSeparator();
|
||||
|
||||
QAction *actionIdentify = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionIdentify.svg" ) ),
|
||||
tr( "Identify" ), this, &Qgs3DMapCanvasWidget::identify );
|
||||
QAction *actionIdentify = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionIdentify.svg" ) ), tr( "Identify" ), this, &Qgs3DMapCanvasWidget::identify );
|
||||
actionIdentify->setCheckable( true );
|
||||
|
||||
QAction *actionMeasurementTool = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionMeasure.svg" ) ),
|
||||
tr( "Measurement Line" ), this, &Qgs3DMapCanvasWidget::measureLine );
|
||||
QAction *actionMeasurementTool = toolBar->addAction( QIcon( QgsApplication::iconPath( "mActionMeasure.svg" ) ), tr( "Measurement Line" ), this, &Qgs3DMapCanvasWidget::measureLine );
|
||||
actionMeasurementTool->setCheckable( true );
|
||||
|
||||
// Create action group to make the action exclusive
|
||||
@ -103,8 +100,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
actionGroup->setExclusive( true );
|
||||
actionCameraControl->setChecked( true );
|
||||
|
||||
mActionAnim = toolBar->addAction( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ),
|
||||
tr( "Animations" ), this, &Qgs3DMapCanvasWidget::toggleAnimations );
|
||||
mActionAnim = toolBar->addAction( QIcon( QgsApplication::iconPath( "mTaskRunning.svg" ) ), tr( "Animations" ), this, &Qgs3DMapCanvasWidget::toggleAnimations );
|
||||
mActionAnim->setCheckable( true );
|
||||
|
||||
// Export Menu
|
||||
@ -116,11 +112,9 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
QToolButton *exportButton = qobject_cast<QToolButton *>( toolBar->widgetForAction( mActionExport ) );
|
||||
exportButton->setPopupMode( QToolButton::ToolButtonPopupMode::InstantPopup );
|
||||
|
||||
mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionSaveMapAsImage.svg" ) ),
|
||||
tr( "Save as Image…" ), this, &Qgs3DMapCanvasWidget::saveAsImage );
|
||||
mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionSaveMapAsImage.svg" ) ), tr( "Save as Image…" ), this, &Qgs3DMapCanvasWidget::saveAsImage );
|
||||
|
||||
mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "3d.svg" ) ),
|
||||
tr( "Export 3D Scene" ), this, &Qgs3DMapCanvasWidget::exportScene );
|
||||
mExportMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "3d.svg" ) ), tr( "Export 3D Scene" ), this, &Qgs3DMapCanvasWidget::exportScene );
|
||||
|
||||
toolBar->addSeparator();
|
||||
|
||||
@ -150,8 +144,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mActionSync2DNavTo3D = new QAction( tr( "2D Map View Follows 3D Camera" ), this );
|
||||
mActionSync2DNavTo3D->setCheckable( true );
|
||||
connect( mActionSync2DNavTo3D, &QAction::triggered, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionSync2DNavTo3D, &QAction::triggered, this, [=]( bool enabled ) {
|
||||
Qgis::ViewSyncModeFlags syncMode = mCanvas->mapSettings()->viewSyncMode();
|
||||
syncMode.setFlag( Qgis::ViewSyncModeFlag::Sync2DTo3D, enabled );
|
||||
mCanvas->mapSettings()->setViewSyncMode( syncMode );
|
||||
@ -160,8 +153,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mActionSync3DNavTo2D = new QAction( tr( "3D Camera Follows 2D Map View" ), this );
|
||||
mActionSync3DNavTo2D->setCheckable( true );
|
||||
connect( mActionSync3DNavTo2D, &QAction::triggered, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionSync3DNavTo2D, &QAction::triggered, this, [=]( bool enabled ) {
|
||||
Qgis::ViewSyncModeFlags syncMode = mCanvas->mapSettings()->viewSyncMode();
|
||||
syncMode.setFlag( Qgis::ViewSyncModeFlag::Sync3DTo2D, enabled );
|
||||
mCanvas->mapSettings()->setViewSyncMode( syncMode );
|
||||
@ -170,17 +162,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mShowFrustumPolyogon = new QAction( tr( "Show Visible Camera Area in 2D Map View" ), this );
|
||||
mShowFrustumPolyogon->setCheckable( true );
|
||||
connect( mShowFrustumPolyogon, &QAction::triggered, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mShowFrustumPolyogon, &QAction::triggered, this, [=]( bool enabled ) {
|
||||
mCanvas->mapSettings()->setViewFrustumVisualizationEnabled( enabled );
|
||||
} );
|
||||
mCameraMenu->addAction( mShowFrustumPolyogon );
|
||||
|
||||
mActionSetSceneExtent = mCameraMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "extents.svg" ) ),
|
||||
tr( "Set 3D Scene Extent on 2D Map View" ), this, &Qgs3DMapCanvasWidget::setSceneExtentOn2DCanvas );
|
||||
mActionSetSceneExtent = mCameraMenu->addAction( QgsApplication::getThemeIcon( QStringLiteral( "extents.svg" ) ), tr( "Set 3D Scene Extent on 2D Map View" ), this, &Qgs3DMapCanvasWidget::setSceneExtentOn2DCanvas );
|
||||
mActionSetSceneExtent->setCheckable( true );
|
||||
auto createShortcuts = [ = ]( const QString & objectName, void ( Qgs3DMapCanvasWidget::* slot )() )
|
||||
{
|
||||
auto createShortcuts = [=]( const QString &objectName, void ( Qgs3DMapCanvasWidget::*slot )() ) {
|
||||
if ( QShortcut *sc = QgsGui::shortcutsManager()->shortcutByName( objectName ) )
|
||||
connect( sc, &QShortcut::activated, this, slot );
|
||||
};
|
||||
@ -197,8 +186,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mActionEnableShadows = new QAction( tr( "Show Shadows" ), this );
|
||||
mActionEnableShadows->setCheckable( true );
|
||||
connect( mActionEnableShadows, &QAction::toggled, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionEnableShadows, &QAction::toggled, this, [=]( bool enabled ) {
|
||||
QgsShadowSettings settings = mCanvas->mapSettings()->shadowSettings();
|
||||
settings.setRenderShadows( enabled );
|
||||
mCanvas->mapSettings()->setShadowSettings( settings );
|
||||
@ -207,16 +195,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mActionEnableEyeDome = new QAction( tr( "Show Eye Dome Lighting" ), this );
|
||||
mActionEnableEyeDome->setCheckable( true );
|
||||
connect( mActionEnableEyeDome, &QAction::triggered, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionEnableEyeDome, &QAction::triggered, this, [=]( bool enabled ) {
|
||||
mCanvas->mapSettings()->setEyeDomeLightingEnabled( enabled );
|
||||
} );
|
||||
mEffectsMenu->addAction( mActionEnableEyeDome );
|
||||
|
||||
mActionEnableAmbientOcclusion = new QAction( tr( "Show Ambient Occlusion" ), this );
|
||||
mActionEnableAmbientOcclusion->setCheckable( true );
|
||||
connect( mActionEnableAmbientOcclusion, &QAction::triggered, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionEnableAmbientOcclusion, &QAction::triggered, this, [=]( bool enabled ) {
|
||||
QgsAmbientOcclusionSettings ambientOcclusionSettings = mCanvas->mapSettings()->ambientOcclusionSettings();
|
||||
ambientOcclusionSettings.setEnabled( enabled );
|
||||
mCanvas->mapSettings()->setAmbientOcclusionSettings( ambientOcclusionSettings );
|
||||
@ -224,16 +210,14 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
mEffectsMenu->addAction( mActionEnableAmbientOcclusion );
|
||||
|
||||
// Options Menu
|
||||
QAction *configureAction = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ),
|
||||
tr( "Configure…" ), this );
|
||||
QAction *configureAction = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mActionOptions.svg" ) ), tr( "Configure…" ), this );
|
||||
connect( configureAction, &QAction::triggered, this, &Qgs3DMapCanvasWidget::configure );
|
||||
toolBar->addAction( configureAction );
|
||||
|
||||
mCanvas = new Qgs3DMapCanvas;
|
||||
mCanvas->setMinimumSize( QSize( 200, 200 ) );
|
||||
|
||||
connect( mCanvas, &Qgs3DMapCanvas::savedAsImage, this, [ = ]( const QString & fileName )
|
||||
{
|
||||
connect( mCanvas, &Qgs3DMapCanvas::savedAsImage, this, [=]( const QString &fileName ) {
|
||||
QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as Image" ), tr( "Successfully saved the 3D map to <a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) );
|
||||
} );
|
||||
|
||||
@ -271,8 +255,7 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
|
||||
mLabelNavSpeedHideTimeout = new QTimer( this );
|
||||
mLabelNavSpeedHideTimeout->setInterval( 1000 );
|
||||
connect( mLabelNavSpeedHideTimeout, &QTimer::timeout, this, [ = ]
|
||||
{
|
||||
connect( mLabelNavSpeedHideTimeout, &QTimer::timeout, this, [=] {
|
||||
mLabelNavigationSpeed->hide();
|
||||
mLabelNavSpeedHideTimeout->stop();
|
||||
} );
|
||||
@ -321,12 +304,10 @@ Qgs3DMapCanvasWidget::Qgs3DMapCanvasWidget( const QString &name, bool isDocked )
|
||||
}
|
||||
QAction *dockAction = mDockableWidgetHelper->createDockUndockAction( tr( "Dock 3D Map View" ), this );
|
||||
toolBar->addAction( dockAction );
|
||||
connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [ = ]()
|
||||
{
|
||||
connect( mDockableWidgetHelper, &QgsDockableWidgetHelper::closed, this, [=]() {
|
||||
QgisApp::instance()->close3DMapView( canvasName() );
|
||||
} );
|
||||
connect( dockAction, &QAction::toggled, this, [ = ]( const bool isSmallSize )
|
||||
{
|
||||
connect( dockAction, &QAction::toggled, this, [=]( const bool isSmallSize ) {
|
||||
toolBar->setIconSize( QgisApp::instance()->iconSize( isSmallSize ) );
|
||||
} );
|
||||
}
|
||||
@ -338,7 +319,7 @@ Qgs3DMapCanvasWidget::~Qgs3DMapCanvasWidget()
|
||||
|
||||
void Qgs3DMapCanvasWidget::saveAsImage()
|
||||
{
|
||||
const QPair< QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( this, tr( "Choose a file name to save the 3D map canvas to an image" ) );
|
||||
const QPair<QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( this, tr( "Choose a file name to save the 3D map canvas to an image" ) );
|
||||
if ( !fileNameAndFilter.first.isEmpty() )
|
||||
{
|
||||
mCanvas->saveAsImage( fileNameAndFilter.first, fileNameAndFilter.second );
|
||||
@ -447,9 +428,7 @@ void Qgs3DMapCanvasWidget::setMapSettings( Qgs3DMapSettings *map )
|
||||
mAnimationWidget->setMap( map );
|
||||
|
||||
// Disable button for switching the map theme if the terrain generator is a mesh, or if there is no terrain
|
||||
mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled()
|
||||
|| !mCanvas->mapSettings()->terrainGenerator()
|
||||
|| mCanvas->mapSettings()->terrainGenerator()->type() == QgsTerrainGenerator::Mesh );
|
||||
mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() || !mCanvas->mapSettings()->terrainGenerator() || mCanvas->mapSettings()->terrainGenerator()->type() == QgsTerrainGenerator::Mesh );
|
||||
mLabelFpsCounter->setVisible( map->isFpsCounterEnabled() );
|
||||
|
||||
connect( map, &Qgs3DMapSettings::viewFrustumVisualizationEnabledChanged, this, &Qgs3DMapCanvasWidget::onViewFrustumVisualizationEnabledChanged );
|
||||
@ -462,7 +441,7 @@ void Qgs3DMapCanvasWidget::setMainCanvas( QgsMapCanvas *canvas )
|
||||
{
|
||||
mMainCanvas = canvas;
|
||||
|
||||
mMapToolExtent = std::make_unique< QgsMapToolExtent >( canvas );
|
||||
mMapToolExtent = std::make_unique<QgsMapToolExtent>( canvas );
|
||||
mMapToolExtent->setAction( mActionSetSceneExtent );
|
||||
connect( mMapToolExtent.get(), &QgsMapToolExtent::extentChanged, this, &Qgs3DMapCanvasWidget::setSceneExtent );
|
||||
|
||||
@ -507,8 +486,7 @@ void Qgs3DMapCanvasWidget::configure()
|
||||
Qgs3DMapConfigWidget *w = new Qgs3DMapConfigWidget( map, mMainCanvas, mCanvas, mConfigureDialog );
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, mConfigureDialog );
|
||||
|
||||
auto applyConfig = [ = ]()
|
||||
{
|
||||
auto applyConfig = [=]() {
|
||||
const QgsVector3D oldOrigin = map->origin();
|
||||
const QgsCoordinateReferenceSystem oldCrs = map->crs();
|
||||
const QgsCameraPose oldCameraPose = mCanvas->cameraController()->cameraPose();
|
||||
@ -518,9 +496,10 @@ void Qgs3DMapCanvasWidget::configure()
|
||||
w->apply();
|
||||
|
||||
const QgsVector3D p = Qgs3DUtils::transformWorldCoordinates(
|
||||
oldLookingAt,
|
||||
oldOrigin, oldCrs,
|
||||
map->origin(), map->crs(), QgsProject::instance()->transformContext() );
|
||||
oldLookingAt,
|
||||
oldOrigin, oldCrs,
|
||||
map->origin(), map->crs(), QgsProject::instance()->transformContext()
|
||||
);
|
||||
|
||||
if ( p != oldLookingAt )
|
||||
{
|
||||
@ -531,14 +510,11 @@ void Qgs3DMapCanvasWidget::configure()
|
||||
}
|
||||
|
||||
// Disable map theme button if the terrain generator is a mesh, or if there is no terrain
|
||||
mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled()
|
||||
|| !mCanvas->mapSettings()->terrainGenerator()
|
||||
|| map->terrainGenerator()->type() == QgsTerrainGenerator::Mesh );
|
||||
mActionMapThemes->setDisabled( !mCanvas->mapSettings()->terrainRenderingEnabled() || !mCanvas->mapSettings()->terrainGenerator() || map->terrainGenerator()->type() == QgsTerrainGenerator::Mesh );
|
||||
};
|
||||
|
||||
connect( buttons, &QDialogButtonBox::rejected, mConfigureDialog, &QDialog::reject );
|
||||
connect( buttons, &QDialogButtonBox::clicked, mConfigureDialog, [ = ]( QAbstractButton * button )
|
||||
{
|
||||
connect( buttons, &QDialogButtonBox::clicked, mConfigureDialog, [=]( QAbstractButton *button ) {
|
||||
if ( button == buttons->button( QDialogButtonBox::Apply ) || button == buttons->button( QDialogButtonBox::Ok ) )
|
||||
applyConfig();
|
||||
if ( button == buttons->button( QDialogButtonBox::Ok ) )
|
||||
@ -546,8 +522,7 @@ void Qgs3DMapCanvasWidget::configure()
|
||||
} );
|
||||
connect( buttons, &QDialogButtonBox::helpRequested, w, []() { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html#scene-configuration" ) ); } );
|
||||
|
||||
connect( w, &Qgs3DMapConfigWidget::isValidChanged, this, [ = ]( bool valid )
|
||||
{
|
||||
connect( w, &Qgs3DMapConfigWidget::isValidChanged, this, [=]( bool valid ) {
|
||||
buttons->button( QDialogButtonBox::Apply )->setEnabled( valid );
|
||||
buttons->button( QDialogButtonBox::Ok )->setEnabled( valid );
|
||||
} );
|
||||
@ -568,7 +543,6 @@ void Qgs3DMapCanvasWidget::configure()
|
||||
|
||||
void Qgs3DMapCanvasWidget::exportScene()
|
||||
{
|
||||
|
||||
QDialog dlg;
|
||||
dlg.setWindowTitle( tr( "Export 3D Scene" ) );
|
||||
dlg.setObjectName( QStringLiteral( "3DSceneExportDialog" ) );
|
||||
@ -581,7 +555,7 @@ void Qgs3DMapCanvasWidget::exportScene()
|
||||
|
||||
connect( buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
|
||||
connect( buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
|
||||
connect( buttons, &QDialogButtonBox::helpRequested, &dlg, [ = ] { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html" ) ); } );
|
||||
connect( buttons, &QDialogButtonBox::helpRequested, &dlg, [=] { QgsHelp::openHelp( QStringLiteral( "map_views/3d_map_view.html" ) ); } );
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout( &dlg );
|
||||
layout->addWidget( &w, 1 );
|
||||
@ -634,8 +608,7 @@ void Qgs3DMapCanvasWidget::mapThemeMenuAboutToShow()
|
||||
{
|
||||
actionFollowMain->setChecked( true );
|
||||
}
|
||||
connect( actionFollowMain, &QAction::triggered, this, [ = ]
|
||||
{
|
||||
connect( actionFollowMain, &QAction::triggered, this, [=] {
|
||||
mCanvas->mapSettings()->setTerrainMapTheme( QString() );
|
||||
} );
|
||||
mMapThemeMenuPresetActions.append( actionFollowMain );
|
||||
@ -649,8 +622,7 @@ void Qgs3DMapCanvasWidget::mapThemeMenuAboutToShow()
|
||||
{
|
||||
a->setChecked( true );
|
||||
}
|
||||
connect( a, &QAction::triggered, this, [a, this]
|
||||
{
|
||||
connect( a, &QAction::triggered, this, [a, this] {
|
||||
mCanvas->mapSettings()->setTerrainMapTheme( a->text() );
|
||||
} );
|
||||
mMapThemeMenuPresetActions.append( a );
|
||||
@ -739,7 +711,8 @@ void Qgs3DMapCanvasWidget::onGpuMemoryLimitReached()
|
||||
double memLimit = settings.value( QStringLiteral( "map3d/gpuMemoryLimit" ), 500.0, QgsSettings::App ).toDouble();
|
||||
mMessageBar->pushMessage( tr( "A map layer has used all graphics memory allowed (%1 MB). "
|
||||
"You may want to lower the amount of detail in the scene, or increase the limit in the options." )
|
||||
.arg( memLimit ), Qgis::MessageLevel::Warning );
|
||||
.arg( memLimit ),
|
||||
Qgis::MessageLevel::Warning );
|
||||
mGpuMemoryLimitReachedReported = true;
|
||||
}
|
||||
|
||||
|
||||
@ -132,8 +132,8 @@ class APP_EXPORT Qgs3DMapCanvasWidget : public QWidget
|
||||
QAction *mActionEffects = nullptr;
|
||||
QAction *mActionSetSceneExtent = nullptr;
|
||||
QgsDockableWidgetHelper *mDockableWidgetHelper = nullptr;
|
||||
QObjectUniquePtr< QgsRubberBand > mViewFrustumHighlight;
|
||||
QObjectUniquePtr< QgsRubberBand > mViewExtentHighlight;
|
||||
QObjectUniquePtr<QgsRubberBand> mViewFrustumHighlight;
|
||||
QObjectUniquePtr<QgsRubberBand> mViewExtentHighlight;
|
||||
QPointer<QDialog> mConfigureDialog;
|
||||
QgsMessageBar *mMessageBar = nullptr;
|
||||
bool mGpuMemoryLimitReachedReported = false;
|
||||
|
||||
@ -50,7 +50,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas
|
||||
const QgsSettings settings;
|
||||
|
||||
const int iconSize = QgsGuiUtils::scaleIconSize( 20 );
|
||||
m3DOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) ) ;
|
||||
m3DOptionsListWidget->setIconSize( QSize( iconSize, iconSize ) );
|
||||
|
||||
mCameraNavigationModeCombo->addItem( tr( "Terrain Based" ), QVariant::fromValue( Qgis::NavigationMode::TerrainBased ) );
|
||||
mCameraNavigationModeCombo->addItem( tr( "Walk Mode (First Person)" ), QVariant::fromValue( Qgis::NavigationMode::Walk ) );
|
||||
@ -58,7 +58,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas
|
||||
// get rid of annoying outer focus rect on Mac
|
||||
m3DOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false );
|
||||
m3DOptionsListWidget->setCurrentRow( settings.value( QStringLiteral( "Windows/3DMapConfig/Tab" ), 0 ).toInt() );
|
||||
connect( m3DOptionsListWidget, &QListWidget::currentRowChanged, this, [ = ]( int index ) { m3DOptionsStackedWidget->setCurrentIndex( index ); } );
|
||||
connect( m3DOptionsListWidget, &QListWidget::currentRowChanged, this, [=]( int index ) { m3DOptionsStackedWidget->setCurrentIndex( index ); } );
|
||||
m3DOptionsStackedWidget->setCurrentIndex( m3DOptionsListWidget->currentRow() );
|
||||
|
||||
if ( !settings.contains( QStringLiteral( "Windows/3DMapConfig/OptionsSplitState" ) ) )
|
||||
@ -75,8 +75,7 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas
|
||||
|
||||
cboCameraProjectionType->addItem( tr( "Perspective Projection" ), Qt3DRender::QCameraLens::PerspectiveProjection );
|
||||
cboCameraProjectionType->addItem( tr( "Orthogonal Projection" ), Qt3DRender::QCameraLens::OrthographicProjection );
|
||||
connect( cboCameraProjectionType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]()
|
||||
{
|
||||
connect( cboCameraProjectionType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=]() {
|
||||
spinCameraFieldOfView->setEnabled( cboCameraProjectionType->currentIndex() == cboCameraProjectionType->findData( Qt3DRender::QCameraLens::PerspectiveProjection ) );
|
||||
} );
|
||||
|
||||
@ -194,16 +193,16 @@ Qgs3DMapConfigWidget::Qgs3DMapConfigWidget( Qgs3DMapSettings *map, QgsMapCanvas
|
||||
|
||||
// ==================
|
||||
// Page: 3D axis
|
||||
mCbo3dAxisType->addItem( tr( "Coordinate Reference System" ), static_cast< int >( Qgs3DAxisSettings::Mode::Crs ) );
|
||||
mCbo3dAxisType->addItem( tr( "Cube" ), static_cast< int >( Qgs3DAxisSettings::Mode::Cube ) );
|
||||
mCbo3dAxisType->addItem( tr( "Coordinate Reference System" ), static_cast<int>( Qgs3DAxisSettings::Mode::Crs ) );
|
||||
mCbo3dAxisType->addItem( tr( "Cube" ), static_cast<int>( Qgs3DAxisSettings::Mode::Cube ) );
|
||||
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Left" ), static_cast< int >( Qt::AnchorPoint::AnchorLeft ) );
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Center" ), static_cast< int >( Qt::AnchorPoint::AnchorHorizontalCenter ) );
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Right" ), static_cast< int >( Qt::AnchorPoint::AnchorRight ) );
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Left" ), static_cast<int>( Qt::AnchorPoint::AnchorLeft ) );
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Center" ), static_cast<int>( Qt::AnchorPoint::AnchorHorizontalCenter ) );
|
||||
mCbo3dAxisHorizPos->addItem( tr( "Right" ), static_cast<int>( Qt::AnchorPoint::AnchorRight ) );
|
||||
|
||||
mCbo3dAxisVertPos->addItem( tr( "Top" ), static_cast< int >( Qt::AnchorPoint::AnchorTop ) );
|
||||
mCbo3dAxisVertPos->addItem( tr( "Middle" ), static_cast< int >( Qt::AnchorPoint::AnchorVerticalCenter ) );
|
||||
mCbo3dAxisVertPos->addItem( tr( "Bottom" ), static_cast< int >( Qt::AnchorPoint::AnchorBottom ) );
|
||||
mCbo3dAxisVertPos->addItem( tr( "Top" ), static_cast<int>( Qt::AnchorPoint::AnchorTop ) );
|
||||
mCbo3dAxisVertPos->addItem( tr( "Middle" ), static_cast<int>( Qt::AnchorPoint::AnchorVerticalCenter ) );
|
||||
mCbo3dAxisVertPos->addItem( tr( "Bottom" ), static_cast<int>( Qt::AnchorPoint::AnchorBottom ) );
|
||||
|
||||
init3DAxisPage();
|
||||
|
||||
@ -276,9 +275,7 @@ void Qgs3DMapConfigWidget::apply()
|
||||
{
|
||||
// if we already have a DEM terrain generator, check whether there was actually any change
|
||||
QgsDemTerrainGenerator *oldDemTerrainGen = static_cast<QgsDemTerrainGenerator *>( mMap->terrainGenerator() );
|
||||
if ( oldDemTerrainGen->layer() == demLayer &&
|
||||
oldDemTerrainGen->resolution() == spinTerrainResolution->value() &&
|
||||
oldDemTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() )
|
||||
if ( oldDemTerrainGen->layer() == demLayer && oldDemTerrainGen->resolution() == spinTerrainResolution->value() && oldDemTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() )
|
||||
tGenNeedsUpdate = false;
|
||||
}
|
||||
|
||||
@ -299,8 +296,7 @@ void Qgs3DMapConfigWidget::apply()
|
||||
if ( mMap->terrainGenerator()->type() == QgsTerrainGenerator::Online )
|
||||
{
|
||||
QgsOnlineTerrainGenerator *oldOnlineTerrainGen = static_cast<QgsOnlineTerrainGenerator *>( mMap->terrainGenerator() );
|
||||
if ( oldOnlineTerrainGen->resolution() == spinTerrainResolution->value() &&
|
||||
oldOnlineTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() )
|
||||
if ( oldOnlineTerrainGen->resolution() == spinTerrainResolution->value() && oldOnlineTerrainGen->skirtHeight() == spinTerrainSkirtHeight->value() )
|
||||
tGenNeedsUpdate = false;
|
||||
}
|
||||
|
||||
@ -320,7 +316,7 @@ void Qgs3DMapConfigWidget::apply()
|
||||
QgsMeshTerrainGenerator *newTerrainGenerator = new QgsMeshTerrainGenerator;
|
||||
newTerrainGenerator->setCrs( mMap->crs(), QgsProject::instance()->transformContext() );
|
||||
newTerrainGenerator->setLayer( meshLayer );
|
||||
std::unique_ptr< QgsMesh3DSymbol > symbol = mMeshSymbolWidget->symbol();
|
||||
std::unique_ptr<QgsMesh3DSymbol> symbol = mMeshSymbolWidget->symbol();
|
||||
symbol->setVerticalScale( spinTerrainScale->value() );
|
||||
newTerrainGenerator->setSymbol( symbol.release() );
|
||||
mMap->setTerrainGenerator( newTerrainGenerator );
|
||||
@ -337,8 +333,8 @@ void Qgs3DMapConfigWidget::apply()
|
||||
}
|
||||
|
||||
mMap->setFieldOfView( spinCameraFieldOfView->value() );
|
||||
mMap->setProjectionType( cboCameraProjectionType->currentData().value< Qt3DRender::QCameraLens::ProjectionType >() );
|
||||
mMap->setCameraNavigationMode( mCameraNavigationModeCombo->currentData().value< Qgis::NavigationMode>() );
|
||||
mMap->setProjectionType( cboCameraProjectionType->currentData().value<Qt3DRender::QCameraLens::ProjectionType>() );
|
||||
mMap->setCameraNavigationMode( mCameraNavigationModeCombo->currentData().value<Qgis::NavigationMode>() );
|
||||
mMap->setCameraMovementSpeed( mCameraMovementSpeed->value() );
|
||||
mMap->setTerrainVerticalScale( spinTerrainScale->value() );
|
||||
mMap->setMapTileResolution( spinMapResolution->value() );
|
||||
@ -350,8 +346,8 @@ void Qgs3DMapConfigWidget::apply()
|
||||
mMap->setShowDebugPanel( chkShowDebugPanel->isChecked() );
|
||||
mMap->setTerrainShadingEnabled( groupTerrainShading->isChecked() );
|
||||
|
||||
const std::unique_ptr< QgsAbstractMaterialSettings > terrainMaterial( widgetTerrainMaterial->settings() );
|
||||
if ( QgsPhongMaterialSettings *phongMaterial = dynamic_cast< QgsPhongMaterialSettings * >( terrainMaterial.get() ) )
|
||||
const std::unique_ptr<QgsAbstractMaterialSettings> terrainMaterial( widgetTerrainMaterial->settings() );
|
||||
if ( QgsPhongMaterialSettings *phongMaterial = dynamic_cast<QgsPhongMaterialSettings *>( terrainMaterial.get() ) )
|
||||
mMap->setTerrainShadingMaterial( *phongMaterial );
|
||||
|
||||
mMap->setLightSources( widgetLights->lightSources() );
|
||||
@ -448,7 +444,7 @@ void Qgs3DMapConfigWidget::validate()
|
||||
switch ( static_cast<QgsTerrainGenerator::Type>( cboTerrainType->currentData().toInt() ) )
|
||||
{
|
||||
case QgsTerrainGenerator::Dem:
|
||||
if ( ! cboTerrainLayer->currentLayer() )
|
||||
if ( !cboTerrainLayer->currentLayer() )
|
||||
{
|
||||
valid = false;
|
||||
mMessageBar->pushMessage( tr( "An elevation layer must be selected for a DEM terrain" ), Qgis::MessageLevel::Critical );
|
||||
@ -456,7 +452,7 @@ void Qgs3DMapConfigWidget::validate()
|
||||
break;
|
||||
|
||||
case QgsTerrainGenerator::Mesh:
|
||||
if ( ! cboTerrainLayer->currentLayer() )
|
||||
if ( !cboTerrainLayer->currentLayer() )
|
||||
{
|
||||
valid = false;
|
||||
mMessageBar->pushMessage( tr( "An elevation layer must be selected for a mesh terrain" ), Qgis::MessageLevel::Critical );
|
||||
@ -464,7 +460,7 @@ void Qgs3DMapConfigWidget::validate()
|
||||
break;
|
||||
|
||||
case QgsTerrainGenerator::QuantizedMesh:
|
||||
if ( ! cboTerrainLayer->currentLayer() )
|
||||
if ( !cboTerrainLayer->currentLayer() )
|
||||
{
|
||||
valid = false;
|
||||
mMessageBar->pushMessage( tr( "An elevation layer must be selected for a quantized mesh terrain" ), Qgis::MessageLevel::Critical );
|
||||
@ -498,11 +494,11 @@ void Qgs3DMapConfigWidget::init3DAxisPage()
|
||||
else
|
||||
{
|
||||
mGroupBox3dAxis->setChecked( true );
|
||||
mCbo3dAxisType->setCurrentIndex( mCbo3dAxisType->findData( static_cast< int >( s.mode() ) ) );
|
||||
mCbo3dAxisType->setCurrentIndex( mCbo3dAxisType->findData( static_cast<int>( s.mode() ) ) );
|
||||
}
|
||||
|
||||
mCbo3dAxisHorizPos->setCurrentIndex( mCbo3dAxisHorizPos->findData( static_cast< int >( s.horizontalPosition() ) ) );
|
||||
mCbo3dAxisVertPos->setCurrentIndex( mCbo3dAxisVertPos->findData( static_cast< int >( s.verticalPosition() ) ) );
|
||||
mCbo3dAxisHorizPos->setCurrentIndex( mCbo3dAxisHorizPos->findData( static_cast<int>( s.horizontalPosition() ) ) );
|
||||
mCbo3dAxisVertPos->setCurrentIndex( mCbo3dAxisVertPos->findData( static_cast<int>( s.verticalPosition() ) ) );
|
||||
}
|
||||
|
||||
void Qgs3DMapConfigWidget::on3DAxisChanged()
|
||||
@ -511,7 +507,7 @@ void Qgs3DMapConfigWidget::on3DAxisChanged()
|
||||
Qgs3DAxisSettings::Mode m;
|
||||
|
||||
if ( mGroupBox3dAxis->isChecked() )
|
||||
m = static_cast< Qgs3DAxisSettings::Mode >( mCbo3dAxisType->currentData().toInt() );
|
||||
m = static_cast<Qgs3DAxisSettings::Mode>( mCbo3dAxisType->currentData().toInt() );
|
||||
else
|
||||
m = Qgs3DAxisSettings::Mode::Off;
|
||||
|
||||
@ -521,8 +517,8 @@ void Qgs3DMapConfigWidget::on3DAxisChanged()
|
||||
}
|
||||
else
|
||||
{
|
||||
const Qt::AnchorPoint hPos = static_cast< Qt::AnchorPoint >( mCbo3dAxisHorizPos->currentData().toInt() );
|
||||
const Qt::AnchorPoint vPos = static_cast< Qt::AnchorPoint >( mCbo3dAxisVertPos->currentData().toInt() );
|
||||
const Qt::AnchorPoint hPos = static_cast<Qt::AnchorPoint>( mCbo3dAxisHorizPos->currentData().toInt() );
|
||||
const Qt::AnchorPoint vPos = static_cast<Qt::AnchorPoint>( mCbo3dAxisVertPos->currentData().toInt() );
|
||||
|
||||
if ( s.horizontalPosition() != hPos || s.verticalPosition() != vPos )
|
||||
{
|
||||
|
||||
@ -50,8 +50,7 @@ void Qgs3DMapToolIdentify::mousePressEvent( QMouseEvent *event )
|
||||
|
||||
void Qgs3DMapToolIdentify::mouseMoveEvent( QMouseEvent *event )
|
||||
{
|
||||
if ( !mMouseHasMoved &&
|
||||
( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() )
|
||||
if ( !mMouseHasMoved && ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() )
|
||||
{
|
||||
mMouseHasMoved = true;
|
||||
}
|
||||
@ -78,7 +77,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
|
||||
for ( auto it = allHits.constKeyValueBegin(); it != allHits.constKeyValueEnd(); ++it )
|
||||
{
|
||||
// We can directly show vector layer results
|
||||
if ( QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer * >( it->first ) )
|
||||
if ( QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it->first ) )
|
||||
{
|
||||
const QgsRayCastingUtils::RayHit hit = it->second.first();
|
||||
const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( hit.pos, mCanvas->mapSettings()->origin() );
|
||||
@ -98,7 +97,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
|
||||
showTerrainResults = false;
|
||||
}
|
||||
// We need to restructure point cloud layer results to display them later. We may have multiple hits for each layer.
|
||||
else if ( QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer * >( it->first ) )
|
||||
else if ( QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer *>( it->first ) )
|
||||
{
|
||||
QVector<QVariantMap> pointCloudResults;
|
||||
for ( const QgsRayCastingUtils::RayHit &hit : it->second )
|
||||
@ -114,7 +113,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
|
||||
const QgsRayCastingUtils::RayHit hit = it->second.first();
|
||||
const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( hit.pos, mCanvas->mapSettings()->origin() );
|
||||
|
||||
QMap< QString, QString > derivedAttributes;
|
||||
QMap<QString, QString> derivedAttributes;
|
||||
QString x;
|
||||
QString y;
|
||||
QgsCoordinateUtils::formatCoordinatePartsForProject(
|
||||
@ -133,7 +132,7 @@ void Qgs3DMapToolIdentify::mouseReleaseEvent( QMouseEvent *event )
|
||||
{
|
||||
derivedAttributes[key] = hit.attributes[key].toString();
|
||||
}
|
||||
QString nodeId = derivedAttributes[ QStringLiteral( "node_id" ) ];
|
||||
QString nodeId = derivedAttributes[QStringLiteral( "node_id" )];
|
||||
// only derived attributes are supported for now, so attributes is empty
|
||||
QgsMapToolIdentify::IdentifyResult res( it->first, nodeId, {}, derivedAttributes );
|
||||
tiledSceneIdentifyResults.append( res );
|
||||
|
||||
@ -32,7 +32,7 @@ Qgs3DMapToolMeasureLine::Qgs3DMapToolMeasureLine( Qgs3DMapCanvas *canvas )
|
||||
: Qgs3DMapTool( canvas )
|
||||
{
|
||||
// Dialog
|
||||
mDialog = std::make_unique< Qgs3DMeasureDialog >( this );
|
||||
mDialog = std::make_unique<Qgs3DMeasureDialog>( this );
|
||||
mDialog->setWindowFlags( mDialog->windowFlags() | Qt::Tool );
|
||||
mDialog->restorePosition();
|
||||
}
|
||||
@ -97,10 +97,7 @@ void Qgs3DMapToolMeasureLine::handleClick( const QPoint &screenPos )
|
||||
if ( minDist < 0 || resDist < minDist )
|
||||
{
|
||||
minDist = resDist;
|
||||
worldIntersection = QgsVector3D( result.pos.x(),
|
||||
result.pos.y(),
|
||||
result.pos.z()
|
||||
);
|
||||
worldIntersection = QgsVector3D( result.pos.x(), result.pos.y(), result.pos.z() );
|
||||
}
|
||||
}
|
||||
const QgsVector3D mapCoords = Qgs3DUtils::worldToMapCoordinates( worldIntersection, mCanvas->mapSettings()->origin() );
|
||||
@ -189,8 +186,7 @@ void Qgs3DMapToolMeasureLine::mousePressEvent( QMouseEvent *event )
|
||||
|
||||
void Qgs3DMapToolMeasureLine::mouseMoveEvent( QMouseEvent *event )
|
||||
{
|
||||
if ( !mMouseHasMoved &&
|
||||
( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() )
|
||||
if ( !mMouseHasMoved && ( event->pos() - mMouseClickPos ).manhattanLength() >= QApplication::startDragDistance() )
|
||||
{
|
||||
mMouseHasMoved = true;
|
||||
}
|
||||
@ -228,8 +224,7 @@ void Qgs3DMapToolMeasureLine::mouseReleaseEvent( QMouseEvent *event )
|
||||
|
||||
void Qgs3DMapToolMeasureLine::keyPressEvent( QKeyEvent *event )
|
||||
{
|
||||
if ( event->key() == Qt::Key_Backspace ||
|
||||
event->key() == Qt::Key_Delete )
|
||||
if ( event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete )
|
||||
{
|
||||
undo();
|
||||
}
|
||||
|
||||
@ -122,17 +122,17 @@ double Qgs3DMeasureDialog::lastHorizontalDistance()
|
||||
|
||||
void Qgs3DMeasureDialog::repopulateComboBoxUnits()
|
||||
{
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Meters ), static_cast< int >( Qgis::DistanceUnit::Meters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Kilometers ), static_cast< int >( Qgis::DistanceUnit::Kilometers ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Feet ), static_cast< int >( Qgis::DistanceUnit::Feet ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Yards ), static_cast< int >( Qgis::DistanceUnit::Yards ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Miles ), static_cast< int >( Qgis::DistanceUnit::Miles ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::NauticalMiles ), static_cast< int >( Qgis::DistanceUnit::NauticalMiles ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Centimeters ), static_cast< int >( Qgis::DistanceUnit::Centimeters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Millimeters ), static_cast< int >( Qgis::DistanceUnit::Millimeters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Inches ), static_cast< int >( Qgis::DistanceUnit::Inches ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Degrees ), static_cast< int >( Qgis::DistanceUnit::Degrees ) );
|
||||
mUnitsCombo->addItem( tr( "map units" ), static_cast< int >( Qgis::DistanceUnit::Unknown ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Meters ), static_cast<int>( Qgis::DistanceUnit::Meters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Kilometers ), static_cast<int>( Qgis::DistanceUnit::Kilometers ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Feet ), static_cast<int>( Qgis::DistanceUnit::Feet ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Yards ), static_cast<int>( Qgis::DistanceUnit::Yards ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Miles ), static_cast<int>( Qgis::DistanceUnit::Miles ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::NauticalMiles ), static_cast<int>( Qgis::DistanceUnit::NauticalMiles ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Centimeters ), static_cast<int>( Qgis::DistanceUnit::Centimeters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Millimeters ), static_cast<int>( Qgis::DistanceUnit::Millimeters ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Inches ), static_cast<int>( Qgis::DistanceUnit::Inches ) );
|
||||
mUnitsCombo->addItem( QgsUnitTypes::toString( Qgis::DistanceUnit::Degrees ), static_cast<int>( Qgis::DistanceUnit::Degrees ) );
|
||||
mUnitsCombo->addItem( tr( "map units" ), static_cast<int>( Qgis::DistanceUnit::Unknown ) );
|
||||
}
|
||||
|
||||
void Qgs3DMeasureDialog::removeLastPoint()
|
||||
@ -176,15 +176,15 @@ void Qgs3DMeasureDialog::updateSettings()
|
||||
mDecimalPlaces = settings.value( QStringLiteral( "qgis/measure/decimalplaces" ), "3" ).toInt();
|
||||
mMapDistanceUnit = mTool->canvas()->mapSettings()->crs().mapUnits();
|
||||
mDisplayedDistanceUnit = QgsUnitTypes::decodeDistanceUnit(
|
||||
settings.value( QStringLiteral( "qgis/measure/displayunits" ),
|
||||
QgsUnitTypes::encodeUnit( Qgis::DistanceUnit::Unknown ) ).toString() );
|
||||
settings.value( QStringLiteral( "qgis/measure/displayunits" ), QgsUnitTypes::encodeUnit( Qgis::DistanceUnit::Unknown ) ).toString()
|
||||
);
|
||||
setupTableHeader();
|
||||
mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast< int >( mDisplayedDistanceUnit ) ) );
|
||||
mUnitsCombo->setCurrentIndex( mUnitsCombo->findData( static_cast<int>( mDisplayedDistanceUnit ) ) );
|
||||
}
|
||||
|
||||
void Qgs3DMeasureDialog::unitsChanged( int index )
|
||||
{
|
||||
mDisplayedDistanceUnit = static_cast< Qgis::DistanceUnit >( mUnitsCombo->itemData( index ).toInt() );
|
||||
mDisplayedDistanceUnit = static_cast<Qgis::DistanceUnit>( mUnitsCombo->itemData( index ).toInt() );
|
||||
updateTable();
|
||||
updateTotal();
|
||||
}
|
||||
@ -265,7 +265,7 @@ void Qgs3DMeasureDialog::updateTable()
|
||||
QVector<QgsPoint>::const_iterator it;
|
||||
bool isFirstPoint = true; // first point
|
||||
QgsPoint p1, p2;
|
||||
const QVector< QgsPoint > tmpPoints = mTool->points();
|
||||
const QVector<QgsPoint> tmpPoints = mTool->points();
|
||||
for ( it = tmpPoints.constBegin(); it != tmpPoints.constEnd(); ++it )
|
||||
{
|
||||
p2 = *it;
|
||||
|
||||
@ -86,10 +86,10 @@ class Qgs3DMeasureDialog : public QDialog, private Ui::QgsMeasureBase
|
||||
int mDecimalPlaces = 3;
|
||||
|
||||
//! Distance unit of the map
|
||||
Qgis::DistanceUnit mMapDistanceUnit = Qgis::DistanceUnit::Unknown;
|
||||
Qgis::DistanceUnit mMapDistanceUnit = Qgis::DistanceUnit::Unknown;
|
||||
|
||||
//! Distance unit of the displayed value
|
||||
Qgis::DistanceUnit mDisplayedDistanceUnit = Qgis::DistanceUnit::Unknown;
|
||||
Qgis::DistanceUnit mDisplayedDistanceUnit = Qgis::DistanceUnit::Unknown;
|
||||
|
||||
//! Convert from mMapDistanceUnit to mDisplayedDistanceUnit
|
||||
double convertLength( double length, Qgis::DistanceUnit toUnit ) const;
|
||||
|
||||
@ -32,7 +32,6 @@ class Qgs3DModelSourceLineEdit : public QgsAbstractFileContentSourceLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for Qgs3DModelSourceLineEdit, with the specified \a parent widget.
|
||||
*/
|
||||
@ -42,7 +41,7 @@ class Qgs3DModelSourceLineEdit : public QgsAbstractFileContentSourceLineEdit
|
||||
|
||||
private:
|
||||
#ifndef SIP_RUN
|
||||
///@cond PRIVATE
|
||||
///@cond PRIVATE
|
||||
QString fileFilter() const override;
|
||||
QString selectFileTitle() const override;
|
||||
QString fileFromUrlTitle() const override;
|
||||
|
||||
@ -32,7 +32,8 @@ Q_NOWARN_DEPRECATED_POP
|
||||
|
||||
#include <Qt3DRender/QCamera>
|
||||
|
||||
Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *parent ) : QWidget( parent )
|
||||
Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
@ -42,10 +43,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mZoomInButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->zoom( 5 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->zoom( 5 );
|
||||
}
|
||||
);
|
||||
|
||||
// Zoom out button
|
||||
@ -53,10 +53,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mZoomOutButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->zoom( -5 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->zoom( -5 );
|
||||
}
|
||||
);
|
||||
|
||||
// Tilt up button
|
||||
@ -64,10 +63,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mTiltUpButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( 1 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( 1 );
|
||||
}
|
||||
);
|
||||
|
||||
// Tilt down button
|
||||
@ -75,10 +73,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mTiltDownButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( -1 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->tiltUpAroundViewCenter( -1 );
|
||||
}
|
||||
);
|
||||
|
||||
// Compas
|
||||
@ -89,10 +86,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mCompass,
|
||||
&QwtDial::valueChanged,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->setCameraHeadingAngle( float( mCompass->value() ) );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->setCameraHeadingAngle( float( mCompass->value() ) );
|
||||
}
|
||||
);
|
||||
|
||||
// Move up button
|
||||
@ -100,10 +96,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mMoveUpButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->moveView( 0, 1 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->moveView( 0, 1 );
|
||||
}
|
||||
);
|
||||
|
||||
// Move right button
|
||||
@ -111,10 +106,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mMoveRightButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->moveView( 1, 0 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->moveView( 1, 0 );
|
||||
}
|
||||
);
|
||||
|
||||
// Move down button
|
||||
@ -122,10 +116,9 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mMoveDownButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->moveView( 0, -1 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->moveView( 0, -1 );
|
||||
}
|
||||
);
|
||||
|
||||
// Move left button
|
||||
@ -133,9 +126,8 @@ Qgs3DNavigationWidget::Qgs3DNavigationWidget( Qgs3DMapCanvas *canvas, QWidget *p
|
||||
mMoveLeftButton,
|
||||
&QToolButton::clicked,
|
||||
m3DMapCanvas,
|
||||
[ = ]
|
||||
{
|
||||
m3DMapCanvas->cameraController()->moveView( -1, 0 );
|
||||
}
|
||||
[=] {
|
||||
m3DMapCanvas->cameraController()->moveView( -1, 0 );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ Qgs3DOptionsWidget::Qgs3DOptionsWidget( QWidget *parent )
|
||||
mInvertVerticalAxisCombo->setCurrentIndex( mInvertVerticalAxisCombo->findData( QVariant::fromValue( axisInversion ) ) );
|
||||
|
||||
const Qt3DRender::QCameraLens::ProjectionType defaultProjection = settings.enumValue( QStringLiteral( "map3d/defaultProjection" ), Qt3DRender::QCameraLens::PerspectiveProjection, QgsSettings::App );
|
||||
cboCameraProjectionType->setCurrentIndex( cboCameraProjectionType->findData( static_cast< int >( defaultProjection ) ) );
|
||||
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() );
|
||||
@ -70,9 +70,9 @@ QString Qgs3DOptionsWidget::helpKey() const
|
||||
void Qgs3DOptionsWidget::apply()
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.setEnumValue( QStringLiteral( "map3d/defaultNavigation" ), mCameraNavigationModeCombo->currentData().value< Qgis::NavigationMode >(), QgsSettings::App );
|
||||
settings.setEnumValue( QStringLiteral( "map3d/axisInversion" ), mInvertVerticalAxisCombo->currentData().value< Qgis::VerticalAxisInversion >(), QgsSettings::App );
|
||||
settings.setValue( QStringLiteral( "map3d/defaultProjection" ), static_cast< Qt3DRender::QCameraLens::ProjectionType >( cboCameraProjectionType->currentData().toInt() ), QgsSettings::App );
|
||||
settings.setEnumValue( QStringLiteral( "map3d/defaultNavigation" ), mCameraNavigationModeCombo->currentData().value<Qgis::NavigationMode>(), QgsSettings::App );
|
||||
settings.setEnumValue( QStringLiteral( "map3d/axisInversion" ), mInvertVerticalAxisCombo->currentData().value<Qgis::VerticalAxisInversion>(), 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 );
|
||||
|
||||
@ -86,7 +86,6 @@ void Qgs3DOptionsWidget::apply()
|
||||
Qgs3DOptionsFactory::Qgs3DOptionsFactory()
|
||||
: QgsOptionsWidgetFactory( tr( "3D" ), QIcon(), QStringLiteral( "3d" ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QIcon Qgs3DOptionsFactory::icon() const
|
||||
|
||||
@ -31,14 +31,12 @@ class Qgs3DOptionsWidget : public QgsOptionsPageWidget, private Ui::Qgs3DOptions
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for Qgs3DOptionsWidget with the specified \a parent widget.
|
||||
*/
|
||||
Qgs3DOptionsWidget( QWidget *parent );
|
||||
QString helpKey() const override;
|
||||
void apply() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -47,13 +45,11 @@ class Qgs3DOptionsFactory : public QgsOptionsWidgetFactory
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
Qgs3DOptionsFactory();
|
||||
|
||||
QIcon icon() const override;
|
||||
QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const override;
|
||||
QString pagePositionHint() const override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ class Qgs3DViewsManagerDialog : public QDialog, private Ui::Qgs3DViewsManagerDia
|
||||
void currentChanged( const QModelIndex ¤t, const QModelIndex &previous );
|
||||
|
||||
void on3DViewsListChanged();
|
||||
|
||||
private:
|
||||
QStringListModel *mListModel = nullptr;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ QgsMaterialSettingsWidget *QgsGoochMaterialWidget::create()
|
||||
|
||||
void QgsGoochMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsGoochMaterialSettings *goochMaterial = dynamic_cast< const QgsGoochMaterialSettings * >( settings );
|
||||
const QgsGoochMaterialSettings *goochMaterial = dynamic_cast<const QgsGoochMaterialSettings *>( settings );
|
||||
if ( !goochMaterial )
|
||||
return;
|
||||
btnDiffuse->setColor( goochMaterial->diffuse() );
|
||||
@ -67,10 +67,10 @@ void QgsGoochMaterialWidget::setSettings( const QgsAbstractMaterialSettings *set
|
||||
|
||||
mPropertyCollection = settings->dataDefinedProperties();
|
||||
|
||||
mDiffuseDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mWarmDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Warm ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mCoolDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Cool ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mSpecularDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mDiffuseDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mWarmDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Warm ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mCoolDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Cool ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mSpecularDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
}
|
||||
|
||||
void QgsGoochMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique technique )
|
||||
@ -101,7 +101,7 @@ void QgsGoochMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique
|
||||
|
||||
QgsAbstractMaterialSettings *QgsGoochMaterialWidget::settings()
|
||||
{
|
||||
std::unique_ptr< QgsGoochMaterialSettings > m = std::make_unique< QgsGoochMaterialSettings >();
|
||||
std::unique_ptr<QgsGoochMaterialSettings> m = std::make_unique<QgsGoochMaterialSettings>();
|
||||
m->setDiffuse( btnDiffuse->color() );
|
||||
m->setWarm( btnWarm->color() );
|
||||
m->setCool( btnCool->color() );
|
||||
|
||||
@ -34,7 +34,6 @@ class QgsGoochMaterialWidget : public QgsMaterialSettingsWidget, private Ui::Goo
|
||||
void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override;
|
||||
void setTechnique( QgsMaterialSettingsRenderingTechnique technique ) override;
|
||||
QgsAbstractMaterialSettings *settings() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSGOOCHMATERIALWIDGET_H
|
||||
|
||||
@ -72,7 +72,7 @@ QgsLightsWidget::QgsLightsWidget( QWidget *parent )
|
||||
connect( spinDirectionalIntensity, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::updateCurrentDirectionalLightParameters );
|
||||
connect( btnDirectionalColor, &QgsColorButton::colorChanged, this, &QgsLightsWidget::updateCurrentDirectionalLightParameters );
|
||||
|
||||
connect( dialAzimuth, &QSlider::valueChanged, this, [this]( int value ) {spinBoxAzimuth->setValue( ( value + 180 ) % 360 );} );
|
||||
connect( dialAzimuth, &QSlider::valueChanged, this, [this]( int value ) { spinBoxAzimuth->setValue( ( value + 180 ) % 360 ); } );
|
||||
connect( sliderAltitude, &QSlider::valueChanged, spinBoxAltitude, &QgsDoubleSpinBox::setValue );
|
||||
connect( spinBoxAzimuth, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::onDirectionChange );
|
||||
connect( spinBoxAltitude, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, &QgsLightsWidget::onDirectionChange );
|
||||
@ -83,17 +83,17 @@ QgsLightsWidget::QgsLightsWidget( QWidget *parent )
|
||||
|
||||
void QgsLightsWidget::setLights( const QList<QgsLightSource *> sources )
|
||||
{
|
||||
QList< QgsPointLightSettings > pointLights;
|
||||
QList< QgsDirectionalLightSettings > directionalLights;
|
||||
QList<QgsPointLightSettings> pointLights;
|
||||
QList<QgsDirectionalLightSettings> directionalLights;
|
||||
for ( const QgsLightSource *source : sources )
|
||||
{
|
||||
switch ( source->type() )
|
||||
{
|
||||
case Qgis::LightSourceType::Point:
|
||||
pointLights.append( *qgis::down_cast< const QgsPointLightSettings *>( source ) );
|
||||
pointLights.append( *qgis::down_cast<const QgsPointLightSettings *>( source ) );
|
||||
break;
|
||||
case Qgis::LightSourceType::Directional:
|
||||
directionalLights.append( *qgis::down_cast< const QgsDirectionalLightSettings *>( source ) );
|
||||
directionalLights.append( *qgis::down_cast<const QgsDirectionalLightSettings *>( source ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -138,7 +138,7 @@ void QgsLightsWidget::selectedLightChanged( const QItemSelection &selected, cons
|
||||
return;
|
||||
}
|
||||
|
||||
const QgsLightsModel::LightType lightType = static_cast< QgsLightsModel::LightType >( mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightTypeRole ).toInt() );
|
||||
const QgsLightsModel::LightType lightType = static_cast<QgsLightsModel::LightType>( mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightTypeRole ).toInt() );
|
||||
const int listIndex = mLightsModel->data( selected.indexes().at( 0 ), QgsLightsModel::LightListIndex ).toInt();
|
||||
|
||||
switch ( lightType )
|
||||
@ -302,14 +302,12 @@ void QgsLightsWidget::onDirectionChange()
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// QgsLightsModel
|
||||
//
|
||||
QgsLightsModel::QgsLightsModel( QObject *parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int QgsLightsModel::rowCount( const QModelIndex &parent ) const
|
||||
@ -425,12 +423,12 @@ QList<QgsDirectionalLightSettings> QgsLightsModel::directionalLights() const
|
||||
|
||||
void QgsLightsModel::setPointLightSettings( int index, const QgsPointLightSettings &light )
|
||||
{
|
||||
mPointLights[ index ] = light;
|
||||
mPointLights[index] = light;
|
||||
}
|
||||
|
||||
void QgsLightsModel::setDirectionalLightSettings( int index, const QgsDirectionalLightSettings &light )
|
||||
{
|
||||
mDirectionalLights[ index ] = light;
|
||||
mDirectionalLights[index] = light;
|
||||
}
|
||||
|
||||
QModelIndex QgsLightsModel::addPointLight( const QgsPointLightSettings &light )
|
||||
|
||||
@ -27,7 +27,6 @@ class QgsLightsModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
enum LightType
|
||||
{
|
||||
Point,
|
||||
@ -59,7 +58,6 @@ class QgsLightsModel : public QAbstractListModel
|
||||
QModelIndex addDirectionalLight( const QgsDirectionalLightSettings &light );
|
||||
|
||||
private:
|
||||
|
||||
QList<QgsPointLightSettings> mPointLights;
|
||||
QList<QgsDirectionalLightSettings> mDirectionalLights;
|
||||
};
|
||||
@ -96,8 +94,8 @@ class QgsLightsWidget : public QWidget, private Ui::QgsLightsWidget
|
||||
void onAddDirectionalLight();
|
||||
void setAzimuthAltitude();
|
||||
void onDirectionChange();
|
||||
private:
|
||||
|
||||
private:
|
||||
void showSettingsForPointLight( const QgsPointLightSettings &settings );
|
||||
void showSettingsForDirectionalLight( const QgsDirectionalLightSettings &settings );
|
||||
|
||||
|
||||
@ -28,9 +28,9 @@ QgsLine3DSymbolWidget::QgsLine3DSymbolWidget( QWidget *parent )
|
||||
spinWidth->setClearValue( 0.0, tr( "Hairline" ) );
|
||||
spinExtrusion->setClearValue( 0.0 );
|
||||
|
||||
cboAltClamping->addItem( tr( "Absolute" ), static_cast< int >( Qgis::AltitudeClamping::Absolute ) );
|
||||
cboAltClamping->addItem( tr( "Relative" ), static_cast< int >( Qgis::AltitudeClamping::Relative ) );
|
||||
cboAltClamping->addItem( tr( "Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Terrain ) );
|
||||
cboAltClamping->addItem( tr( "Absolute" ), static_cast<int>( Qgis::AltitudeClamping::Absolute ) );
|
||||
cboAltClamping->addItem( tr( "Relative" ), static_cast<int>( Qgis::AltitudeClamping::Relative ) );
|
||||
cboAltClamping->addItem( tr( "Terrain" ), static_cast<int>( Qgis::AltitudeClamping::Terrain ) );
|
||||
|
||||
QgsLine3DSymbol defaultLine;
|
||||
setSymbol( &defaultLine, nullptr );
|
||||
@ -56,25 +56,24 @@ Qgs3DSymbolWidget *QgsLine3DSymbolWidget::create( QgsVectorLayer * )
|
||||
|
||||
void QgsLine3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsLine3DSymbol *lineSymbol = dynamic_cast< const QgsLine3DSymbol *>( symbol );
|
||||
const QgsLine3DSymbol *lineSymbol = dynamic_cast<const QgsLine3DSymbol *>( symbol );
|
||||
if ( !lineSymbol )
|
||||
return;
|
||||
|
||||
spinWidth->setValue( lineSymbol->width() );
|
||||
spinOffset->setValue( lineSymbol->offset() );
|
||||
spinExtrusion->setValue( lineSymbol->extrusionHeight() );
|
||||
cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast< int >( lineSymbol->altitudeClamping() ) ) );
|
||||
cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast<int>( lineSymbol->altitudeClamping() ) ) );
|
||||
cboAltBinding->setCurrentIndex( static_cast<int>( lineSymbol->altitudeBinding() ) );
|
||||
chkSimpleLines->setChecked( lineSymbol->renderAsSimpleLines() );
|
||||
widgetMaterial->setSettings( lineSymbol->materialSettings(), layer );
|
||||
widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines
|
||||
: QgsMaterialSettingsRenderingTechnique::Triangles );
|
||||
widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines : QgsMaterialSettingsRenderingTechnique::Triangles );
|
||||
updateGuiState();
|
||||
}
|
||||
|
||||
QgsAbstract3DSymbol *QgsLine3DSymbolWidget::symbol()
|
||||
{
|
||||
std::unique_ptr< QgsLine3DSymbol > sym = std::make_unique< QgsLine3DSymbol >();
|
||||
std::unique_ptr<QgsLine3DSymbol> sym = std::make_unique<QgsLine3DSymbol>();
|
||||
sym->setWidth( spinWidth->value() );
|
||||
sym->setOffset( static_cast<float>( spinOffset->value() ) );
|
||||
sym->setExtrusionHeight( spinExtrusion->value() );
|
||||
@ -94,12 +93,11 @@ void QgsLine3DSymbolWidget::updateGuiState()
|
||||
{
|
||||
const bool simple = chkSimpleLines->isChecked();
|
||||
spinExtrusion->setEnabled( !simple );
|
||||
widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines
|
||||
: QgsMaterialSettingsRenderingTechnique::Triangles );
|
||||
widgetMaterial->setTechnique( chkSimpleLines->isChecked() ? QgsMaterialSettingsRenderingTechnique::Lines : QgsMaterialSettingsRenderingTechnique::Triangles );
|
||||
|
||||
// Altitude binding is not taken into account if altitude clamping is absolute.
|
||||
// See: Qgs3DUtils::clampAltitudes()
|
||||
const bool absoluteClamping = cboAltClamping->currentData().toInt() == static_cast< int >( Qgis::AltitudeClamping::Absolute );
|
||||
const bool absoluteClamping = cboAltClamping->currentData().toInt() == static_cast<int>( Qgis::AltitudeClamping::Absolute );
|
||||
cboAltBinding->setEnabled( !absoluteClamping );
|
||||
}
|
||||
|
||||
@ -108,23 +106,23 @@ void QgsLine3DSymbolWidget::simple3DLinesToggled( bool active )
|
||||
if ( active )
|
||||
{
|
||||
//remove "terrain" option for altitude clamping
|
||||
int terrainIndex = cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Terrain ) );
|
||||
int terrainIndex = cboAltClamping->findData( static_cast<int>( Qgis::AltitudeClamping::Terrain ) );
|
||||
if ( terrainIndex >= 0 )
|
||||
{
|
||||
cboAltClamping->removeItem( terrainIndex );
|
||||
}
|
||||
if ( cboAltClamping->currentIndex() == -1 )
|
||||
{
|
||||
cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Relative ) ) );
|
||||
cboAltClamping->setCurrentIndex( cboAltClamping->findData( static_cast<int>( Qgis::AltitudeClamping::Relative ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure "terrain" option is available
|
||||
int terrainIndex = cboAltClamping->findData( static_cast< int >( Qgis::AltitudeClamping::Terrain ) );
|
||||
int terrainIndex = cboAltClamping->findData( static_cast<int>( Qgis::AltitudeClamping::Terrain ) );
|
||||
if ( terrainIndex == -1 )
|
||||
{
|
||||
cboAltClamping->addItem( tr( "Terrain" ), static_cast< int >( Qgis::AltitudeClamping::Terrain ) );
|
||||
cboAltClamping->addItem( tr( "Terrain" ), static_cast<int>( Qgis::AltitudeClamping::Terrain ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,6 @@ class QgsLine3DSymbolWidget : public Qgs3DSymbolWidget, private Ui::Line3DSymbol
|
||||
private slots:
|
||||
void updateGuiState();
|
||||
void simple3DLinesToggled( bool active );
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSLINE3DSYMBOLWIDGET_H
|
||||
|
||||
@ -26,11 +26,8 @@
|
||||
#include "qgssettings.h"
|
||||
#include "qgs3dmapexportsettings.h"
|
||||
|
||||
QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExportSettings *exportSettings, QWidget *parent ) :
|
||||
QWidget( parent ),
|
||||
ui( new Ui::Map3DExportWidget ),
|
||||
mScene( scene ),
|
||||
mExportSettings( exportSettings )
|
||||
QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExportSettings *exportSettings, QWidget *parent )
|
||||
: QWidget( parent ), ui( new Ui::Map3DExportWidget ), mScene( scene ), mExportSettings( exportSettings )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
ui->terrainResolutionSpinBox->setClearValue( 128 );
|
||||
@ -41,14 +38,14 @@ QgsMap3DExportWidget::QgsMap3DExportWidget( Qgs3DMapScene *scene, Qgs3DMapExport
|
||||
|
||||
loadSettings();
|
||||
|
||||
connect( ui->sceneNameLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & ) { settingsChanged(); } );
|
||||
connect( ui->selectFolderWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & ) { settingsChanged(); } );
|
||||
connect( ui->smoothEdgesCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->terrainResolutionSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->exportNormalsCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->exportTexturesCheckBox, &QCheckBox::stateChanged, this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->terrainTextureResolutionSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->scaleSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [ = ]( int ) { settingsChanged(); } );
|
||||
connect( ui->sceneNameLineEdit, &QLineEdit::textChanged, this, [=]( const QString & ) { settingsChanged(); } );
|
||||
connect( ui->selectFolderWidget, &QgsFileWidget::fileChanged, this, [=]( const QString & ) { settingsChanged(); } );
|
||||
connect( ui->smoothEdgesCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } );
|
||||
connect( ui->terrainResolutionSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } );
|
||||
connect( ui->exportNormalsCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } );
|
||||
connect( ui->exportTexturesCheckBox, &QCheckBox::stateChanged, this, [=]( int ) { settingsChanged(); } );
|
||||
connect( ui->terrainTextureResolutionSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } );
|
||||
connect( ui->scaleSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [=]( int ) { settingsChanged(); } );
|
||||
|
||||
// sets the export settings to whatever is on the scene
|
||||
settingsChanged();
|
||||
|
||||
@ -38,8 +38,10 @@ class QgsMap3DExportWidget : public QWidget
|
||||
void exportScene();
|
||||
private slots:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
Ui::Map3DExportWidget *ui;
|
||||
|
||||
private:
|
||||
Qgs3DMapScene *mScene = nullptr;
|
||||
Qgs3DMapExportSettings *mExportSettings = nullptr;
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
QgsMaterialWidget::QgsMaterialWidget( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
, mCurrentSettings( std::make_unique< QgsPhongMaterialSettings >() )
|
||||
, mCurrentSettings( std::make_unique<QgsPhongMaterialSettings>() )
|
||||
, mTechnique( QgsMaterialSettingsRenderingTechnique::Triangles )
|
||||
{
|
||||
setupUi( this );
|
||||
@ -32,8 +32,7 @@ QgsMaterialWidget::QgsMaterialWidget( QWidget *parent )
|
||||
const QStringList materialTypes = Qgs3D::materialRegistry()->materialSettingsTypes();
|
||||
for ( const QString &type : materialTypes )
|
||||
{
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(),
|
||||
Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
}
|
||||
|
||||
connect( mMaterialTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsMaterialWidget::materialTypeChanged );
|
||||
@ -52,8 +51,7 @@ void QgsMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique tech
|
||||
if ( !Qgs3D::materialRegistry()->materialSettingsMetadata( type )->supportsTechnique( technique ) )
|
||||
continue;
|
||||
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(),
|
||||
Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(), Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
}
|
||||
|
||||
const int prevIndex = mMaterialTypeComboBox->findData( prevType );
|
||||
@ -69,7 +67,7 @@ void QgsMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique tech
|
||||
else
|
||||
mMaterialTypeComboBox->setCurrentIndex( prevIndex );
|
||||
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) )
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast<QgsMaterialSettingsWidget *>( mStackedWidget->currentWidget() ) )
|
||||
w->setTechnique( technique );
|
||||
|
||||
mMaterialTypeComboBox->blockSignals( false );
|
||||
@ -97,7 +95,7 @@ void QgsMaterialWidget::setType( const QString &type )
|
||||
|
||||
void QgsMaterialWidget::materialTypeChanged()
|
||||
{
|
||||
std::unique_ptr< QgsAbstractMaterialSettings > currentSettings( settings() );
|
||||
std::unique_ptr<QgsAbstractMaterialSettings> currentSettings( settings() );
|
||||
const QString existingType = currentSettings ? currentSettings->type() : QString();
|
||||
const QString newType = mMaterialTypeComboBox->currentData().toString();
|
||||
if ( existingType == newType )
|
||||
@ -107,7 +105,7 @@ void QgsMaterialWidget::materialTypeChanged()
|
||||
{
|
||||
// change material to a new (with different type)
|
||||
// base new layer on existing materials's properties
|
||||
std::unique_ptr< QgsAbstractMaterialSettings > newMaterial( am->create() );
|
||||
std::unique_ptr<QgsAbstractMaterialSettings> newMaterial( am->create() );
|
||||
if ( newMaterial )
|
||||
{
|
||||
if ( currentSettings )
|
||||
@ -127,7 +125,7 @@ void QgsMaterialWidget::materialTypeChanged()
|
||||
|
||||
void QgsMaterialWidget::materialWidgetChanged()
|
||||
{
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) )
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast<QgsMaterialSettingsWidget *>( mStackedWidget->currentWidget() ) )
|
||||
{
|
||||
mCurrentSettings.reset( w->settings() );
|
||||
}
|
||||
@ -139,7 +137,7 @@ void QgsMaterialWidget::updateMaterialWidget()
|
||||
if ( mStackedWidget->currentWidget() != mPageDummy )
|
||||
{
|
||||
// stop updating from the original widget
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast< QgsMaterialSettingsWidget * >( mStackedWidget->currentWidget() ) )
|
||||
if ( QgsMaterialSettingsWidget *w = qobject_cast<QgsMaterialSettingsWidget *>( mStackedWidget->currentWidget() ) )
|
||||
disconnect( w, &QgsMaterialSettingsWidget::changed, this, &QgsMaterialWidget::materialWidgetChanged );
|
||||
mStackedWidget->removeWidget( mStackedWidget->currentWidget() );
|
||||
}
|
||||
@ -161,4 +159,3 @@ void QgsMaterialWidget::updateMaterialWidget()
|
||||
// When anything is not right
|
||||
mStackedWidget->setCurrentWidget( mPageDummy );
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,8 @@ class QgsMaterialWidget : public QWidget, private Ui::MaterialWidgetBase
|
||||
void updateMaterialWidget();
|
||||
QgsVectorLayer *mLayer = nullptr;
|
||||
|
||||
std::unique_ptr< QgsAbstractMaterialSettings > mCurrentSettings;
|
||||
std::unique_ptr<QgsAbstractMaterialSettings> mCurrentSettings;
|
||||
QgsMaterialSettingsRenderingTechnique mTechnique;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSMATERIALWIDGET_H
|
||||
|
||||
@ -30,7 +30,7 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget *
|
||||
mSpinBoxVerticaleScale->setClearValue( 1.0 );
|
||||
mArrowsSpacingSpinBox->setClearValue( 25.0 );
|
||||
|
||||
mComboBoxTextureType->addItem( tr( "Single Color" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::SingleColor ) );
|
||||
mComboBoxTextureType->addItem( tr( "Single Color" ), static_cast<int>( QgsMesh3DSymbol::RenderingStyle::SingleColor ) );
|
||||
mComboBoxTextureType->setCurrentIndex( 0 );
|
||||
|
||||
mCullingMode->addItem( tr( "No Culling" ), Qgs3DTypes::NoCulling );
|
||||
@ -50,8 +50,7 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget *
|
||||
connect( mChkSmoothTriangles, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mGroupBoxWireframe, &QGroupBox::toggled, this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mColorButtonWireframe, &QgsColorButton::colorChanged, this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mSpinBoxWireframeLineWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ),
|
||||
this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mSpinBoxWireframeLineWidth, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mLodSlider, &QSlider::valueChanged, this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mColorRampShaderMinMaxReloadButton, &QPushButton::clicked, this, &QgsMesh3DSymbolWidget::reloadColorRampShaderMinMax );
|
||||
@ -60,29 +59,24 @@ QgsMesh3DSymbolWidget::QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget *
|
||||
connect( mColorRampShaderMinEdit, &QLineEdit::editingFinished, this, &QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged );
|
||||
connect( mColorRampShaderMaxEdit, &QLineEdit::editingFinished, this, &QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged );
|
||||
|
||||
connect( mComboBoxTextureType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
|
||||
this, &QgsMesh3DSymbolWidget::onColoringTypeChanged );
|
||||
connect( mComboBoxTextureType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
|
||||
this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mComboBoxTextureType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::onColoringTypeChanged );
|
||||
connect( mComboBoxTextureType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mMeshSingleColorButton, &QgsColorButton::colorChanged, this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mSpinBoxVerticaleScale, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ),
|
||||
this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mSpinBoxVerticaleScale, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mComboBoxDatasetVertical, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
|
||||
this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mComboBoxDatasetVertical, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mCheckBoxVerticalMagnitudeRelative, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mGroupBoxArrowsSettings, &QGroupBox::toggled, this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mArrowsSpacingSpinBox, static_cast<void ( QDoubleSpinBox::* )()>( &QDoubleSpinBox::editingFinished ),
|
||||
this, &QgsMesh3DSymbolWidget::changed );
|
||||
connect( mArrowsSpacingSpinBox, static_cast<void ( QDoubleSpinBox::* )()>( &QDoubleSpinBox::editingFinished ), this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mArrowsFixedSizeCheckBox, &QCheckBox::clicked, this, &QgsMesh3DSymbolWidget::changed );
|
||||
|
||||
connect( mGroupBoxTextureSettings, &QgsCollapsibleGroupBox::collapsedStateChanged, this, &QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged );
|
||||
connect( mGroupBoxTextureSettings, &QgsCollapsibleGroupBox::collapsedStateChanged, this, &QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged );
|
||||
}
|
||||
|
||||
void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol )
|
||||
@ -100,11 +94,10 @@ void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol )
|
||||
|
||||
|
||||
mSpinBoxVerticaleScale->setValue( symbol->verticalScale() );
|
||||
mComboBoxTextureType->setCurrentIndex( mComboBoxTextureType->findData( static_cast< int >( symbol->renderingStyle() ) ) );
|
||||
mComboBoxTextureType->setCurrentIndex( mComboBoxTextureType->findData( static_cast<int>( symbol->renderingStyle() ) ) );
|
||||
mMeshSingleColorButton->setColor( symbol->singleMeshColor() );
|
||||
mColorRampShaderWidget->setFromShader( symbol->colorRampShader() );
|
||||
mColorRampShaderWidget->setMinimumMaximumAndClassify( symbol->colorRampShader().minimumValue(),
|
||||
symbol->colorRampShader().maximumValue() );
|
||||
mColorRampShaderWidget->setMinimumMaximumAndClassify( symbol->colorRampShader().minimumValue(), symbol->colorRampShader().maximumValue() );
|
||||
|
||||
setColorRampMinMax( symbol->colorRampShader().minimumValue(), symbol->colorRampShader().maximumValue() );
|
||||
mComboBoxDatasetVertical->setCurrentIndex( symbol->verticalDatasetGroupIndex() );
|
||||
@ -117,7 +110,7 @@ void QgsMesh3DSymbolWidget::setSymbol( const QgsMesh3DSymbol *symbol )
|
||||
|
||||
void QgsMesh3DSymbolWidget::configureForTerrain()
|
||||
{
|
||||
mComboBoxTextureType->addItem( tr( "Color Ramp Shader" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::ColorRamp ) );
|
||||
mComboBoxTextureType->addItem( tr( "Color Ramp Shader" ), static_cast<int>( QgsMesh3DSymbol::RenderingStyle::ColorRamp ) );
|
||||
enableVerticalSetting( false );
|
||||
enableArrowSettings( false );
|
||||
|
||||
@ -126,7 +119,7 @@ void QgsMesh3DSymbolWidget::configureForTerrain()
|
||||
|
||||
void QgsMesh3DSymbolWidget::configureForDataset()
|
||||
{
|
||||
mComboBoxTextureType->addItem( tr( "2D Contour Color Ramp Shader" ), static_cast< int >( QgsMesh3DSymbol::RenderingStyle::ColorRamp2DRendering ) );
|
||||
mComboBoxTextureType->addItem( tr( "2D Contour Color Ramp Shader" ), static_cast<int>( QgsMesh3DSymbol::RenderingStyle::ColorRamp2DRendering ) );
|
||||
mGroupBoxColorRampShader->hide();
|
||||
enableVerticalSetting( true );
|
||||
enableArrowSettings( true );
|
||||
@ -158,9 +151,9 @@ void QgsMesh3DSymbolWidget::setLayer( QgsMeshLayer *meshLayer, bool updateSymbol
|
||||
{
|
||||
mDatasetGroupListModel->syncToLayer( meshLayer );
|
||||
QgsMeshLayer3DRenderer *renderer = static_cast<QgsMeshLayer3DRenderer *>( meshLayer->renderer3D() );
|
||||
if ( renderer && renderer->type() == QLatin1String( "mesh" ) )
|
||||
if ( renderer && renderer->type() == QLatin1String( "mesh" ) )
|
||||
{
|
||||
if ( renderer->symbol() && renderer->symbol()->type() == QLatin1String( "mesh" ) )
|
||||
if ( renderer->symbol() && renderer->symbol()->type() == QLatin1String( "mesh" ) )
|
||||
{
|
||||
setSymbol( static_cast<const QgsMesh3DSymbol *>( renderer->symbol() ) );
|
||||
return;
|
||||
@ -168,14 +161,14 @@ void QgsMesh3DSymbolWidget::setLayer( QgsMeshLayer *meshLayer, bool updateSymbol
|
||||
}
|
||||
}
|
||||
|
||||
const std::unique_ptr< QgsMesh3DSymbol > defaultSymbol = std::make_unique< QgsMesh3DSymbol >();
|
||||
const std::unique_ptr<QgsMesh3DSymbol> defaultSymbol = std::make_unique<QgsMesh3DSymbol>();
|
||||
// set symbol does not take ownership!
|
||||
setSymbol( defaultSymbol.get() );
|
||||
|
||||
reloadColorRampShaderMinMax(); //As the symbol is new, the Color ramp shader needs to be initialized with min max value
|
||||
}
|
||||
|
||||
QgsMeshLayer *QgsMesh3DSymbolWidget::meshLayer() const {return mLayer;}
|
||||
QgsMeshLayer *QgsMesh3DSymbolWidget::meshLayer() const { return mLayer; }
|
||||
|
||||
double QgsMesh3DSymbolWidget::lineEditValue( const QLineEdit *lineEdit ) const
|
||||
{
|
||||
@ -189,7 +182,7 @@ double QgsMesh3DSymbolWidget::lineEditValue( const QLineEdit *lineEdit ) const
|
||||
|
||||
std::unique_ptr<QgsMesh3DSymbol> QgsMesh3DSymbolWidget::symbol() const
|
||||
{
|
||||
std::unique_ptr< QgsMesh3DSymbol > sym( mSymbol->clone() );
|
||||
std::unique_ptr<QgsMesh3DSymbol> sym( mSymbol->clone() );
|
||||
|
||||
sym->setCullingMode( static_cast<Qgs3DTypes::CullingMode>( mCullingMode->currentData().toInt() ) );
|
||||
sym->setSmoothedTriangles( mChkSmoothTriangles->isChecked() );
|
||||
@ -252,8 +245,8 @@ void QgsMesh3DSymbolWidget::onColorRampShaderMinMaxChanged()
|
||||
|
||||
void QgsMesh3DSymbolWidget::onColoringTypeChanged()
|
||||
{
|
||||
mGroupBoxColorRampShader->setVisible( static_cast< QgsMesh3DSymbol::RenderingStyle >( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::ColorRamp );
|
||||
mMeshSingleColorWidget->setVisible( static_cast< QgsMesh3DSymbol::RenderingStyle >( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::SingleColor );
|
||||
mGroupBoxColorRampShader->setVisible( static_cast<QgsMesh3DSymbol::RenderingStyle>( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::ColorRamp );
|
||||
mMeshSingleColorWidget->setVisible( static_cast<QgsMesh3DSymbol::RenderingStyle>( mComboBoxTextureType->currentData().toInt() ) == QgsMesh3DSymbol::RenderingStyle::SingleColor );
|
||||
}
|
||||
|
||||
void QgsMesh3DSymbolWidget::onTextureSettingsCollapseStateChanged( bool collapsed )
|
||||
|
||||
@ -32,7 +32,7 @@ class QgsMesh3DSymbolWidget : public QWidget, private Ui::QgsMesh3dPropsWidget
|
||||
public:
|
||||
explicit QgsMesh3DSymbolWidget( QgsMeshLayer *meshLayer, QWidget *parent = nullptr );
|
||||
|
||||
std::unique_ptr< QgsMesh3DSymbol > symbol() const;
|
||||
std::unique_ptr<QgsMesh3DSymbol> symbol() const;
|
||||
|
||||
void setLayer( QgsMeshLayer *meshLayer, bool updateSymbol = true );
|
||||
QgsMeshLayer *meshLayer() const;
|
||||
@ -60,8 +60,7 @@ class QgsMesh3DSymbolWidget : public QWidget, private Ui::QgsMesh3dPropsWidget
|
||||
void setColorRampMinMax( double min, double max );
|
||||
QgsMeshLayer *mLayer = nullptr;
|
||||
QgsMeshDatasetGroupListModel *mDatasetGroupListModel = nullptr;
|
||||
std::unique_ptr< QgsMesh3DSymbol > mSymbol;
|
||||
|
||||
std::unique_ptr<QgsMesh3DSymbol> mSymbol;
|
||||
};
|
||||
|
||||
#endif // QGSMESH3DSYMBOLWIDGET_H
|
||||
|
||||
@ -66,7 +66,7 @@ void QgsMeshLayer3DRendererWidget::setRenderer( const QgsMeshLayer3DRenderer *re
|
||||
|
||||
QgsMeshLayer3DRenderer *QgsMeshLayer3DRendererWidget::renderer()
|
||||
{
|
||||
std::unique_ptr< QgsMesh3DSymbol > sym = mWidgetMesh->symbol();
|
||||
std::unique_ptr<QgsMesh3DSymbol> sym = mWidgetMesh->symbol();
|
||||
sym->setEnabled( mChkEnabled->isChecked() );
|
||||
mRenderer.reset( new QgsMeshLayer3DRenderer( sym.release() ) );
|
||||
mRenderer->setLayer( qobject_cast<QgsMeshLayer *>( mLayer ) );
|
||||
@ -87,7 +87,7 @@ void QgsMeshLayer3DRendererWidget::onEnabledClicked()
|
||||
|
||||
void QgsMeshLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer )
|
||||
{
|
||||
mLayer = layer ;
|
||||
mLayer = layer;
|
||||
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( layer );
|
||||
mWidgetMesh->setLayer( meshLayer );
|
||||
QgsAbstract3DRenderer *r = layer->renderer3D();
|
||||
@ -104,8 +104,8 @@ void QgsMeshLayer3DRendererWidget::syncToLayer( QgsMapLayer *layer )
|
||||
}
|
||||
}
|
||||
|
||||
QgsMeshLayer3DRendererWidgetFactory::QgsMeshLayer3DRendererWidgetFactory( QObject *parent ):
|
||||
QObject( parent )
|
||||
QgsMeshLayer3DRendererWidgetFactory::QgsMeshLayer3DRendererWidgetFactory( QObject *parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
setIcon( QIcon( ":/images/themes/default/3d.svg" ) );
|
||||
setTitle( tr( "3D View" ) );
|
||||
|
||||
@ -30,13 +30,11 @@ QgsMetalRoughMaterialWidget::QgsMetalRoughMaterialWidget( QWidget *parent, bool
|
||||
setSettings( &defaultMaterial, nullptr );
|
||||
|
||||
connect( mButtonBaseColor, &QgsColorButton::colorChanged, this, &QgsMetalRoughMaterialWidget::changed );
|
||||
connect( mSpinMetalness, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( mSpinMetalness, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
|
||||
updateWidgetState();
|
||||
emit changed();
|
||||
} );
|
||||
connect( mSpinRoughness, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( mSpinRoughness, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
|
||||
updateWidgetState();
|
||||
emit changed();
|
||||
} );
|
||||
@ -49,12 +47,11 @@ QgsMaterialSettingsWidget *QgsMetalRoughMaterialWidget::create()
|
||||
|
||||
void QgsMetalRoughMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QgsMetalRoughMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer * )
|
||||
{
|
||||
const QgsMetalRoughMaterialSettings *material = dynamic_cast< const QgsMetalRoughMaterialSettings * >( settings );
|
||||
const QgsMetalRoughMaterialSettings *material = dynamic_cast<const QgsMetalRoughMaterialSettings *>( settings );
|
||||
if ( !material )
|
||||
return;
|
||||
mButtonBaseColor->setColor( material->baseColor() );
|
||||
@ -68,7 +65,7 @@ void QgsMetalRoughMaterialWidget::setSettings( const QgsAbstractMaterialSettings
|
||||
|
||||
QgsAbstractMaterialSettings *QgsMetalRoughMaterialWidget::settings()
|
||||
{
|
||||
std::unique_ptr< QgsMetalRoughMaterialSettings > m = std::make_unique< QgsMetalRoughMaterialSettings >();
|
||||
std::unique_ptr<QgsMetalRoughMaterialSettings> m = std::make_unique<QgsMetalRoughMaterialSettings>();
|
||||
m->setBaseColor( mButtonBaseColor->color() );
|
||||
m->setMetalness( static_cast<float>( mSpinMetalness->value() ) );
|
||||
m->setRoughness( static_cast<float>( mSpinRoughness->value() ) );
|
||||
|
||||
@ -33,7 +33,6 @@ class QgsNullMaterialWidget : public QgsMaterialSettingsWidget, private Ui::Null
|
||||
static QgsMaterialSettingsWidget *create();
|
||||
void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override;
|
||||
QgsAbstractMaterialSettings *settings() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSNULLMATERIALWIDGET_H
|
||||
|
||||
@ -34,8 +34,7 @@ QgsPhongMaterialWidget::QgsPhongMaterialWidget( QWidget *parent, bool hasOpacity
|
||||
connect( btnDiffuse, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
|
||||
connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
|
||||
connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongMaterialWidget::changed );
|
||||
connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
|
||||
updateWidgetState();
|
||||
emit changed();
|
||||
} );
|
||||
@ -110,7 +109,7 @@ void QgsPhongMaterialWidget::setTechnique( QgsMaterialSettingsRenderingTechnique
|
||||
|
||||
void QgsPhongMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsPhongMaterialSettings *phongMaterial = dynamic_cast< const QgsPhongMaterialSettings * >( settings );
|
||||
const QgsPhongMaterialSettings *phongMaterial = dynamic_cast<const QgsPhongMaterialSettings *>( settings );
|
||||
if ( !phongMaterial )
|
||||
return;
|
||||
btnDiffuse->setColor( phongMaterial->diffuse() );
|
||||
@ -127,16 +126,16 @@ void QgsPhongMaterialWidget::setSettings( const QgsAbstractMaterialSettings *set
|
||||
|
||||
mPropertyCollection = settings->dataDefinedProperties();
|
||||
|
||||
mDiffuseDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mAmbientDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mSpecularDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mDiffuseDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Diffuse ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mAmbientDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mSpecularDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Specular ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
|
||||
updateWidgetState();
|
||||
}
|
||||
|
||||
QgsAbstractMaterialSettings *QgsPhongMaterialWidget::settings()
|
||||
{
|
||||
std::unique_ptr< QgsPhongMaterialSettings > m = std::make_unique< QgsPhongMaterialSettings >();
|
||||
std::unique_ptr<QgsPhongMaterialSettings> m = std::make_unique<QgsPhongMaterialSettings>();
|
||||
m->setDiffuse( btnDiffuse->color() );
|
||||
m->setAmbient( btnAmbient->color() );
|
||||
m->setSpecular( btnSpecular->color() );
|
||||
|
||||
@ -33,8 +33,7 @@ QgsPhongTexturedMaterialWidget::QgsPhongTexturedMaterialWidget( QWidget *parent
|
||||
|
||||
connect( btnAmbient, &QgsColorButton::colorChanged, this, &QgsPhongTexturedMaterialWidget::changed );
|
||||
connect( btnSpecular, &QgsColorButton::colorChanged, this, &QgsPhongTexturedMaterialWidget::changed );
|
||||
connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [ = ]
|
||||
{
|
||||
connect( spinShininess, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, [=] {
|
||||
updateWidgetState();
|
||||
emit changed();
|
||||
} );
|
||||
@ -51,7 +50,7 @@ QgsMaterialSettingsWidget *QgsPhongTexturedMaterialWidget::create()
|
||||
|
||||
void QgsPhongTexturedMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer * )
|
||||
{
|
||||
const QgsPhongTexturedMaterialSettings *phongMaterial = dynamic_cast< const QgsPhongTexturedMaterialSettings * >( settings );
|
||||
const QgsPhongTexturedMaterialSettings *phongMaterial = dynamic_cast<const QgsPhongTexturedMaterialSettings *>( settings );
|
||||
if ( !phongMaterial )
|
||||
return;
|
||||
btnAmbient->setColor( phongMaterial->ambient() );
|
||||
@ -69,7 +68,7 @@ void QgsPhongTexturedMaterialWidget::setSettings( const QgsAbstractMaterialSetti
|
||||
|
||||
QgsAbstractMaterialSettings *QgsPhongTexturedMaterialWidget::settings()
|
||||
{
|
||||
std::unique_ptr< QgsPhongTexturedMaterialSettings > m = std::make_unique< QgsPhongTexturedMaterialSettings >();
|
||||
std::unique_ptr<QgsPhongTexturedMaterialSettings> m = std::make_unique<QgsPhongTexturedMaterialSettings>();
|
||||
m->setAmbient( btnAmbient->color() );
|
||||
m->setSpecular( btnSpecular->color() );
|
||||
m->setShininess( spinShininess->value() );
|
||||
|
||||
@ -74,11 +74,11 @@ QgsPoint3DSymbolWidget::QgsPoint3DSymbolWidget( QWidget *parent )
|
||||
connect( spinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsPoint3DSymbolWidget::changed );
|
||||
connect( lineEditModel, &QgsAbstractFileContentSourceLineEdit::sourceChanged, this, &QgsPoint3DSymbolWidget::changed );
|
||||
connect( widgetMaterial, &QgsMaterialWidget::changed, this, &QgsPoint3DSymbolWidget::changed );
|
||||
connect( btnChangeSymbol, static_cast<void ( QgsSymbolButton::* )( )>( &QgsSymbolButton::changed ), this, &QgsPoint3DSymbolWidget::changed );
|
||||
connect( btnChangeSymbol, static_cast<void ( QgsSymbolButton::* )()>( &QgsSymbolButton::changed ), this, &QgsPoint3DSymbolWidget::changed );
|
||||
|
||||
// Sync between billboard height and TZ
|
||||
connect( spinBillboardHeight, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), spinTZ, &QDoubleSpinBox::setValue );
|
||||
connect( spinTZ, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), spinBillboardHeight, &QDoubleSpinBox::setValue );
|
||||
connect( spinBillboardHeight, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), spinTZ, &QDoubleSpinBox::setValue );
|
||||
connect( spinTZ, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), spinBillboardHeight, &QDoubleSpinBox::setValue );
|
||||
}
|
||||
|
||||
Qgs3DSymbolWidget *QgsPoint3DSymbolWidget::create( QgsVectorLayer * )
|
||||
@ -88,7 +88,7 @@ Qgs3DSymbolWidget *QgsPoint3DSymbolWidget::create( QgsVectorLayer * )
|
||||
|
||||
void QgsPoint3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsPoint3DSymbol *pointSymbol = dynamic_cast< const QgsPoint3DSymbol *>( symbol );
|
||||
const QgsPoint3DSymbol *pointSymbol = dynamic_cast<const QgsPoint3DSymbol *>( symbol );
|
||||
if ( !pointSymbol )
|
||||
return;
|
||||
|
||||
@ -171,9 +171,9 @@ void QgsPoint3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVe
|
||||
QgsAbstract3DSymbol *QgsPoint3DSymbolWidget::symbol()
|
||||
{
|
||||
QVariantMap vm;
|
||||
std::unique_ptr< QgsPoint3DSymbol > sym = std::make_unique< QgsPoint3DSymbol >();
|
||||
std::unique_ptr<QgsPoint3DSymbol> sym = std::make_unique<QgsPoint3DSymbol>();
|
||||
sym->setBillboardSymbol( static_cast<QgsMarkerSymbol *>( QgsSymbol::defaultSymbol( Qgis::GeometryType::Point ) ) );
|
||||
switch ( cboShape->currentData().value< Qgis::Point3DShape >() )
|
||||
switch ( cboShape->currentData().value<Qgis::Point3DShape>() )
|
||||
{
|
||||
case Qgis::Point3DShape::Sphere:
|
||||
vm[QStringLiteral( "radius" )] = spinRadius->value();
|
||||
@ -217,7 +217,7 @@ QgsAbstract3DSymbol *QgsPoint3DSymbolWidget::symbol()
|
||||
tr.rotate( rot );
|
||||
|
||||
sym->setAltitudeClamping( static_cast<Qgis::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setShape( cboShape->itemData( cboShape->currentIndex() ).value< Qgis::Point3DShape >() );
|
||||
sym->setShape( cboShape->itemData( cboShape->currentIndex() ).value<Qgis::Point3DShape>() );
|
||||
sym->setShapeProperties( vm );
|
||||
sym->setMaterialSettings( widgetMaterial->settings() );
|
||||
sym->setTransform( tr );
|
||||
@ -245,7 +245,7 @@ void QgsPoint3DSymbolWidget::onShapeChanged()
|
||||
transformationWidget->show();
|
||||
QList<QWidget *> activeWidgets;
|
||||
QgsMaterialSettingsRenderingTechnique technique = QgsMaterialSettingsRenderingTechnique::InstancedPoints;
|
||||
switch ( cboShape->currentData().value< Qgis::Point3DShape >() )
|
||||
switch ( cboShape->currentData().value<Qgis::Point3DShape>() )
|
||||
{
|
||||
case Qgis::Point3DShape::Sphere:
|
||||
activeWidgets << labelRadius << spinRadius;
|
||||
|
||||
@ -93,7 +93,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
|
||||
mRenderingStyleComboBox->setCurrentIndex( 0 );
|
||||
mStackedWidget->setCurrentIndex( 0 );
|
||||
|
||||
whileBlocking( mPointBudgetSpinBox )->setMinimum( std::min( mLayer->pointCount() / 2, ( qint64 )100000 ) );
|
||||
whileBlocking( mPointBudgetSpinBox )->setMinimum( std::min( mLayer->pointCount() / 2, ( qint64 ) 100000 ) );
|
||||
whileBlocking( mPointBudgetSpinBox )->setMaximum( mLayer->pointCount() + 1 );
|
||||
whileBlocking( mPointBudgetSpinBox )->setValue( 1000000 );
|
||||
|
||||
@ -101,7 +101,7 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
|
||||
setSymbol( symbol );
|
||||
|
||||
connect( mPointSizeSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, &QgsPointCloud3DSymbolWidget::emitChangedSignal );
|
||||
connect( mRenderingStyleComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsPointCloud3DSymbolWidget::onRenderingStyleChanged );
|
||||
connect( mRenderingStyleComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsPointCloud3DSymbolWidget::onRenderingStyleChanged );
|
||||
connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked, this, &QgsPointCloud3DSymbolWidget::setMinMaxFromLayer );
|
||||
connect( mColorRampShaderWidget, &QgsColorRampShaderWidget::widgetChanged, this, &QgsPointCloud3DSymbolWidget::emitChangedSignal );
|
||||
connect( mSingleColorBtn, &QgsColorButton::colorChanged, this, &QgsPointCloud3DSymbolWidget::emitChangedSignal );
|
||||
@ -114,16 +114,14 @@ QgsPointCloud3DSymbolWidget::QgsPointCloud3DSymbolWidget( QgsPointCloudLayer *la
|
||||
connect( mPointBudgetSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } );
|
||||
|
||||
connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() { emitChangedSignal(); } );
|
||||
connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() {mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() ); } );
|
||||
connect( mTriangulateGroupBox, &QGroupBox::toggled, this, [&]() { mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() ); } );
|
||||
|
||||
connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { emitChangedSignal(); } );
|
||||
connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]()
|
||||
{ mHorizontalTriangleThresholdSpinBox->setEnabled( mHorizontalTriangleCheckBox->isChecked() ); } );
|
||||
connect( mHorizontalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { mHorizontalTriangleThresholdSpinBox->setEnabled( mHorizontalTriangleCheckBox->isChecked() ); } );
|
||||
connect( mHorizontalTriangleThresholdSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } );
|
||||
|
||||
connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { emitChangedSignal(); } );
|
||||
connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]()
|
||||
{ mVerticalTriangleThresholdSpinBox->setEnabled( mVerticalTriangleCheckBox->isChecked() ); } );
|
||||
connect( mVerticalTriangleCheckBox, &QCheckBox::stateChanged, this, [&]() { mVerticalTriangleThresholdSpinBox->setEnabled( mVerticalTriangleCheckBox->isChecked() ); } );
|
||||
connect( mVerticalTriangleThresholdSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ), this, [&]() { emitChangedSignal(); } );
|
||||
|
||||
mPointSizeSpinBox->setEnabled( !mTriangulateGroupBox->isChecked() );
|
||||
@ -310,8 +308,7 @@ void QgsPointCloud3DSymbolWidget::setCustomMinMaxValues( QgsRgbPointCloud3DSymbo
|
||||
return;
|
||||
}
|
||||
|
||||
if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ==
|
||||
QgsContrastEnhancement::NoEnhancement )
|
||||
if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() == QgsContrastEnhancement::NoEnhancement )
|
||||
{
|
||||
symbol->setRedContrastEnhancement( nullptr );
|
||||
symbol->setGreenContrastEnhancement( nullptr );
|
||||
@ -355,18 +352,21 @@ void QgsPointCloud3DSymbolWidget::setCustomMinMaxValues( QgsRgbPointCloud3DSymbo
|
||||
|
||||
if ( redEnhancement )
|
||||
{
|
||||
redEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
|
||||
redEnhancement->setContrastEnhancementAlgorithm( static_cast<QgsContrastEnhancement::ContrastEnhancementAlgorithm>(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
|
||||
) );
|
||||
}
|
||||
if ( greenEnhancement )
|
||||
{
|
||||
greenEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
|
||||
greenEnhancement->setContrastEnhancementAlgorithm( static_cast<QgsContrastEnhancement::ContrastEnhancementAlgorithm>(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
|
||||
) );
|
||||
}
|
||||
if ( blueEnhancement )
|
||||
{
|
||||
blueEnhancement->setContrastEnhancementAlgorithm( static_cast< QgsContrastEnhancement::ContrastEnhancementAlgorithm >(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
|
||||
blueEnhancement->setContrastEnhancementAlgorithm( static_cast<QgsContrastEnhancement::ContrastEnhancementAlgorithm>(
|
||||
( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
|
||||
) );
|
||||
}
|
||||
symbol->setRedContrastEnhancement( redEnhancement );
|
||||
symbol->setGreenContrastEnhancement( greenEnhancement );
|
||||
@ -380,7 +380,8 @@ void QgsPointCloud3DSymbolWidget::minMaxModified()
|
||||
if ( ( QgsContrastEnhancement::ContrastEnhancementAlgorithm )( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) == QgsContrastEnhancement::NoEnhancement )
|
||||
{
|
||||
mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
|
||||
mContrastEnhancementAlgorithmComboBox->findData( ( int ) QgsContrastEnhancement::StretchToMinimumMaximum ) );
|
||||
mContrastEnhancementAlgorithmComboBox->findData( ( int ) QgsContrastEnhancement::StretchToMinimumMaximum )
|
||||
);
|
||||
}
|
||||
emitChangedSignal();
|
||||
}
|
||||
@ -406,7 +407,8 @@ void QgsPointCloud3DSymbolWidget::setMinMaxValue( const QgsContrastEnhancement *
|
||||
// QgsMultiBandColorRenderer is using individual contrast enhancements for each
|
||||
// band, but this widget GUI has one for all
|
||||
mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
|
||||
static_cast< int >( ce->contrastEnhancementAlgorithm() ) ) );
|
||||
static_cast<int>( ce->contrastEnhancementAlgorithm() )
|
||||
) );
|
||||
}
|
||||
|
||||
void QgsPointCloud3DSymbolWidget::reloadColorRampShaderMinMax()
|
||||
@ -436,7 +438,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged()
|
||||
}
|
||||
else if ( newSymbolType == QLatin1String( "color-ramp" ) && mLayer->renderer()->type() == QLatin1String( "ramp" ) )
|
||||
{
|
||||
const QgsPointCloudAttributeByRampRenderer *renderer2d = dynamic_cast< const QgsPointCloudAttributeByRampRenderer * >( mLayer->renderer() );
|
||||
const QgsPointCloudAttributeByRampRenderer *renderer2d = dynamic_cast<const QgsPointCloudAttributeByRampRenderer *>( mLayer->renderer() );
|
||||
mBlockChangedSignals++;
|
||||
mRenderingParameterComboBox->setAttribute( renderer2d->attribute() );
|
||||
mColorRampShaderMinEdit->setValue( renderer2d->minimum() );
|
||||
@ -447,7 +449,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged()
|
||||
}
|
||||
else if ( newSymbolType == QLatin1String( "rgb" ) )
|
||||
{
|
||||
const QgsPointCloudRgbRenderer *renderer2d = dynamic_cast< const QgsPointCloudRgbRenderer * >( mLayer->renderer() );
|
||||
const QgsPointCloudRgbRenderer *renderer2d = dynamic_cast<const QgsPointCloudRgbRenderer *>( mLayer->renderer() );
|
||||
mBlockChangedSignals++;
|
||||
if ( renderer2d )
|
||||
{
|
||||
@ -463,8 +465,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged()
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( mRedAttributeComboBox->findText( QStringLiteral( "Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Green" ) ) > -1 &&
|
||||
mRedAttributeComboBox->findText( QStringLiteral( "Blue" ) ) > -1 )
|
||||
if ( mRedAttributeComboBox->findText( QStringLiteral( "Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Green" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral( "Blue" ) ) > -1 )
|
||||
{
|
||||
mRedAttributeComboBox->setAttribute( QStringLiteral( "Red" ) );
|
||||
mGreenAttributeComboBox->setAttribute( QStringLiteral( "Green" ) );
|
||||
@ -481,7 +482,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged()
|
||||
blueAttributeChanged();
|
||||
}
|
||||
|
||||
( void )( renderer2d );
|
||||
( void ) ( renderer2d );
|
||||
mBlockChangedSignals--;
|
||||
}
|
||||
else if ( newSymbolType == QLatin1String( "classification" ) )
|
||||
@ -511,8 +512,8 @@ void QgsPointCloud3DSymbolWidget::rampAttributeChanged()
|
||||
|
||||
if ( mRenderingParameterComboBox->currentAttribute() == QLatin1String( "Z" ) )
|
||||
{
|
||||
const double zScale = static_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->zScale();
|
||||
const double zOffset = static_cast< const QgsPointCloudLayerElevationProperties * >( mLayer->elevationProperties() )->zOffset();
|
||||
const double zScale = static_cast<const QgsPointCloudLayerElevationProperties *>( mLayer->elevationProperties() )->zScale();
|
||||
const double zOffset = static_cast<const QgsPointCloudLayerElevationProperties *>( mLayer->elevationProperties() )->zOffset();
|
||||
mProviderMin = mProviderMin * zScale + zOffset;
|
||||
mProviderMax = mProviderMax * zScale + zOffset;
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ class QgsPointCloud3DSymbolWidget : public QWidget, private Ui::QgsPointCloud3DS
|
||||
bool mBlockMinMaxChanged = false;
|
||||
bool mBlockSetMinMaxFromLayer = false;
|
||||
|
||||
double mProviderMin = std::numeric_limits< double >::quiet_NaN();
|
||||
double mProviderMax = std::numeric_limits< double >::quiet_NaN();
|
||||
double mProviderMin = std::numeric_limits<double>::quiet_NaN();
|
||||
double mProviderMax = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
void createValidators();
|
||||
void setCustomMinMaxValues( QgsRgbPointCloud3DSymbol *r ) const;
|
||||
|
||||
@ -105,8 +105,8 @@ void QgsPointCloudLayer3DRendererWidget::setDockMode( bool dockMode )
|
||||
mWidgetPointCloudSymbol->setDockMode( dockMode );
|
||||
}
|
||||
|
||||
QgsPointCloudLayer3DRendererWidgetFactory::QgsPointCloudLayer3DRendererWidgetFactory( QObject *parent ):
|
||||
QObject( parent )
|
||||
QgsPointCloudLayer3DRendererWidgetFactory::QgsPointCloudLayer3DRendererWidgetFactory( QObject *parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
setIcon( QIcon( ":/images/themes/default/3d.svg" ) );
|
||||
setTitle( tr( "3D View" ) );
|
||||
|
||||
@ -65,7 +65,7 @@ Qgs3DSymbolWidget *QgsPolygon3DSymbolWidget::create( QgsVectorLayer * )
|
||||
|
||||
void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast< const QgsPolygon3DSymbol * >( symbol );
|
||||
const QgsPolygon3DSymbol *polygonSymbol = dynamic_cast<const QgsPolygon3DSymbol *>( symbol );
|
||||
if ( !polygonSymbol )
|
||||
return;
|
||||
|
||||
@ -81,8 +81,8 @@ void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, Qgs
|
||||
|
||||
widgetMaterial->setSettings( polygonSymbol->materialSettings(), layer );
|
||||
|
||||
btnHeightDD->init( static_cast< int >( QgsAbstract3DSymbol::Property::Height ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true );
|
||||
btnExtrusionDD->init( static_cast< int >( QgsAbstract3DSymbol::Property::ExtrusionHeight ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true );
|
||||
btnHeightDD->init( static_cast<int>( QgsAbstract3DSymbol::Property::Height ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true );
|
||||
btnExtrusionDD->init( static_cast<int>( QgsAbstract3DSymbol::Property::ExtrusionHeight ), polygonSymbol->dataDefinedProperties(), QgsAbstract3DSymbol::propertyDefinitions(), layer, true );
|
||||
|
||||
groupEdges->setChecked( polygonSymbol->edgesEnabled() );
|
||||
spinEdgeWidth->setValue( polygonSymbol->edgeWidth() );
|
||||
@ -91,7 +91,7 @@ void QgsPolygon3DSymbolWidget::setSymbol( const QgsAbstract3DSymbol *symbol, Qgs
|
||||
|
||||
QgsAbstract3DSymbol *QgsPolygon3DSymbolWidget::symbol()
|
||||
{
|
||||
std::unique_ptr< QgsPolygon3DSymbol > sym = std::make_unique< QgsPolygon3DSymbol >();
|
||||
std::unique_ptr<QgsPolygon3DSymbol> sym = std::make_unique<QgsPolygon3DSymbol>();
|
||||
sym->setOffset( static_cast<float>( spinOffset->value() ) );
|
||||
sym->setExtrusionHeight( spinExtrusion->value() );
|
||||
sym->setAltitudeClamping( static_cast<Qgis::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
@ -123,6 +123,6 @@ void QgsPolygon3DSymbolWidget::updateGuiState()
|
||||
{
|
||||
// Altitude binding is not taken into account if altitude clamping is absolute.
|
||||
// See: Qgs3DUtils::clampAltitudes()
|
||||
const bool absoluteClamping = cboAltClamping->currentIndex() == static_cast< int >( Qgis::AltitudeClamping::Absolute );
|
||||
const bool absoluteClamping = cboAltClamping->currentIndex() == static_cast<int>( Qgis::AltitudeClamping::Absolute );
|
||||
cboAltBinding->setEnabled( !absoluteClamping );
|
||||
}
|
||||
|
||||
@ -58,7 +58,6 @@ QgsRuleBased3DRendererWidget::QgsRuleBased3DRendererWidget( QWidget *parent )
|
||||
connect( mCopyAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::copy );
|
||||
connect( mPasteAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::paste );
|
||||
connect( mDeleteAction, &QAction::triggered, this, &QgsRuleBased3DRendererWidget::removeRule );
|
||||
|
||||
}
|
||||
|
||||
QgsRuleBased3DRendererWidget::~QgsRuleBased3DRendererWidget()
|
||||
@ -108,7 +107,7 @@ void QgsRuleBased3DRendererWidget::setDockMode( bool dockMode )
|
||||
|
||||
void QgsRuleBased3DRendererWidget::addRule()
|
||||
{
|
||||
std::unique_ptr< QgsAbstract3DSymbol > newSymbol( QgsApplication::symbol3DRegistry()->defaultSymbolForGeometryType( mLayer->geometryType() ) );
|
||||
std::unique_ptr<QgsAbstract3DSymbol> newSymbol( QgsApplication::symbol3DRegistry()->defaultSymbolForGeometryType( mLayer->geometryType() ) );
|
||||
newSymbol->setDefaultPropertiesFromLayer( mLayer );
|
||||
QgsRuleBased3DRenderer::Rule *newrule = new QgsRuleBased3DRenderer::Rule( newSymbol.release() );
|
||||
|
||||
@ -230,9 +229,7 @@ Qt::ItemFlags QgsRuleBased3DRendererModel::flags( const QModelIndex &index ) con
|
||||
|
||||
const Qt::ItemFlag checkable = ( index.column() == 0 ? Qt::ItemIsUserCheckable : Qt::NoItemFlags );
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable | checkable |
|
||||
Qt::ItemIsDragEnabled | drop;
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | checkable | Qt::ItemIsDragEnabled | drop;
|
||||
}
|
||||
|
||||
QVariant QgsRuleBased3DRendererModel::data( const QModelIndex &index, int role ) const
|
||||
@ -543,8 +540,7 @@ void QgsRuleBased3DRendererModel::insertRule( const QModelIndex &parent, int bef
|
||||
|
||||
void QgsRuleBased3DRendererModel::updateRule( const QModelIndex &parent, int row )
|
||||
{
|
||||
emit dataChanged( index( row, 0, parent ),
|
||||
index( row, columnCount( parent ), parent ) );
|
||||
emit dataChanged( index( row, 0, parent ), index( row, columnCount( parent ), parent ) );
|
||||
}
|
||||
|
||||
|
||||
@ -588,8 +584,8 @@ Qgs3DRendererRulePropsWidget::Qgs3DRendererRulePropsWidget( QgsRuleBased3DRender
|
||||
connect( editDescription, &QLineEdit::textChanged, this, &Qgs3DRendererRulePropsWidget::widgetChanged );
|
||||
connect( groupSymbol, &QGroupBox::toggled, this, &Qgs3DRendererRulePropsWidget::widgetChanged );
|
||||
connect( mSymbolWidget, &QgsSymbol3DWidget::widgetChanged, this, &Qgs3DRendererRulePropsWidget::widgetChanged );
|
||||
connect( mFilterRadio, &QRadioButton::toggled, this, [ = ]( bool toggled ) { filterFrame->setEnabled( toggled ) ; } );
|
||||
connect( mElseRadio, &QRadioButton::toggled, this, [ = ]( bool toggled ) { if ( toggled ) editFilter->setText( QStringLiteral( "ELSE" ) );} );
|
||||
connect( mFilterRadio, &QRadioButton::toggled, this, [=]( bool toggled ) { filterFrame->setEnabled( toggled ); } );
|
||||
connect( mElseRadio, &QRadioButton::toggled, this, [=]( bool toggled ) { if ( toggled ) editFilter->setText( QStringLiteral( "ELSE" ) ); } );
|
||||
}
|
||||
|
||||
Qgs3DRendererRulePropsWidget::~Qgs3DRendererRulePropsWidget() = default;
|
||||
@ -602,7 +598,7 @@ void Qgs3DRendererRulePropsWidget::testFilter()
|
||||
QgsExpression filter( editFilter->text() );
|
||||
if ( filter.hasParserError() )
|
||||
{
|
||||
QMessageBox::critical( this, tr( "Test Filter" ), tr( "Filter expression parsing error:\n" ) + filter.parserErrorString() );
|
||||
QMessageBox::critical( this, tr( "Test Filter" ), tr( "Filter expression parsing error:\n" ) + filter.parserErrorString() );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -652,7 +648,7 @@ void Qgs3DRendererRulePropsWidget::apply()
|
||||
const QString filter = mElseRadio->isChecked() ? QStringLiteral( "ELSE" ) : editFilter->text();
|
||||
mRule->setFilterExpression( filter );
|
||||
mRule->setDescription( editDescription->text() );
|
||||
std::unique_ptr< QgsAbstract3DSymbol > newSymbol;
|
||||
std::unique_ptr<QgsAbstract3DSymbol> newSymbol;
|
||||
if ( groupSymbol->isChecked() )
|
||||
newSymbol = mSymbolWidget->symbol();
|
||||
mRule->setSymbol( newSymbol.release() );
|
||||
|
||||
@ -41,8 +41,7 @@ class QgsRuleBased3DRendererModel : public QAbstractItemModel
|
||||
|
||||
Qt::ItemFlags flags( const QModelIndex &index ) const override;
|
||||
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
|
||||
QVariant headerData( int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole ) const override;
|
||||
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
|
||||
int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
|
||||
int columnCount( const QModelIndex & = QModelIndex() ) const override;
|
||||
//! provide model index for parent's child item
|
||||
@ -72,14 +71,13 @@ class QgsRuleBased3DRendererModel : public QAbstractItemModel
|
||||
void removeRule( const QModelIndex &index );
|
||||
|
||||
void willAddRules( const QModelIndex &parent, int count ); // call beginInsertRows
|
||||
void finishedAddingRules(); // call endInsertRows
|
||||
void finishedAddingRules(); // call endInsertRows
|
||||
|
||||
protected:
|
||||
QgsRuleBased3DRenderer::Rule *mRootRule = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsRuleBased3DRendererWidget : public QgsPanelWidget, private Ui::QgsRuleBased3DRendererWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -122,8 +120,6 @@ class QgsRuleBased3DRendererWidget : public QgsPanelWidget, private Ui::QgsRuleB
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//////
|
||||
|
||||
class QgsSymbol3DWidget;
|
||||
@ -141,8 +137,7 @@ class Qgs3DRendererRulePropsWidget : public QgsPanelWidget, private Ui::Qgs3DRen
|
||||
Editing
|
||||
};
|
||||
|
||||
Qgs3DRendererRulePropsWidget( QgsRuleBased3DRenderer::Rule *rule, QgsVectorLayer *layer,
|
||||
QWidget *parent = nullptr );
|
||||
Qgs3DRendererRulePropsWidget( QgsRuleBased3DRenderer::Rule *rule, QgsVectorLayer *layer, QWidget *parent = nullptr );
|
||||
~Qgs3DRendererRulePropsWidget() override;
|
||||
|
||||
QgsRuleBased3DRenderer::Rule *rule() { return mRule; }
|
||||
@ -162,7 +157,6 @@ class Qgs3DRendererRulePropsWidget : public QgsPanelWidget, private Ui::Qgs3DRen
|
||||
|
||||
QgsSymbol3DWidget *mSymbolWidget = nullptr;
|
||||
std::unique_ptr<QgsAbstract3DSymbol> mSymbol; // a clone of original symbol
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSRULEBASED3DRENDERERWIDGET_H
|
||||
|
||||
@ -34,7 +34,6 @@ class QgsShadowRenderingSettingsWidget : public QWidget, private Ui::ShadowRende
|
||||
QgsShadowSettings toShadowSettings();
|
||||
public slots:
|
||||
void onDirectionalLightsCountChanged( int newCount );
|
||||
|
||||
};
|
||||
|
||||
#endif // SHADOWRENDERINGSETTINGSWIDGET_H
|
||||
|
||||
@ -38,19 +38,19 @@ QgsMaterialSettingsWidget *QgsSimpleLineMaterialWidget::create()
|
||||
|
||||
void QgsSimpleLineMaterialWidget::setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer )
|
||||
{
|
||||
const QgsSimpleLineMaterialSettings *lineMaterial = dynamic_cast< const QgsSimpleLineMaterialSettings * >( settings );
|
||||
const QgsSimpleLineMaterialSettings *lineMaterial = dynamic_cast<const QgsSimpleLineMaterialSettings *>( settings );
|
||||
if ( !lineMaterial )
|
||||
return;
|
||||
|
||||
btnAmbient->setColor( lineMaterial->ambient() );
|
||||
|
||||
mPropertyCollection = settings->dataDefinedProperties();
|
||||
mAmbientDataDefinedButton->init( static_cast< int >( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
mAmbientDataDefinedButton->init( static_cast<int>( QgsAbstractMaterialSettings::Property::Ambient ), mPropertyCollection, settings->propertyDefinitions(), layer, true );
|
||||
}
|
||||
|
||||
QgsAbstractMaterialSettings *QgsSimpleLineMaterialWidget::settings()
|
||||
{
|
||||
std::unique_ptr< QgsSimpleLineMaterialSettings > m = std::make_unique< QgsSimpleLineMaterialSettings >();
|
||||
std::unique_ptr<QgsSimpleLineMaterialSettings> m = std::make_unique<QgsSimpleLineMaterialSettings>();
|
||||
m->setAmbient( btnAmbient->color() );
|
||||
|
||||
mPropertyCollection.setProperty( QgsAbstractMaterialSettings::Property::Ambient, mAmbientDataDefinedButton->toProperty() );
|
||||
|
||||
@ -30,7 +30,6 @@ class QgsSimpleLineMaterialWidget : public QgsMaterialSettingsWidget, private Ui
|
||||
|
||||
void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer ) override;
|
||||
QgsAbstractMaterialSettings *settings() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSSIMPLELINEMATERIALWIDGET_H
|
||||
|
||||
@ -48,18 +48,18 @@ void QgsSkyboxRenderingSettingsWidget::setSkyboxSettings( const QgsSkyboxSetting
|
||||
|
||||
panoramicTextureImageSource->setSource( skyboxSettings.panoramicTexturePath() );
|
||||
QMap<QString, QString> cubeMapFaces = skyboxSettings.cubeMapFacesPaths();
|
||||
posXImageSource->setSource( cubeMapFaces[ QStringLiteral( "posX" ) ] );
|
||||
posYImageSource->setSource( cubeMapFaces[ QStringLiteral( "posY" ) ] );
|
||||
posZImageSource->setSource( cubeMapFaces[ QStringLiteral( "posZ" ) ] );
|
||||
negXImageSource->setSource( cubeMapFaces[ QStringLiteral( "negX" ) ] );
|
||||
negYImageSource->setSource( cubeMapFaces[ QStringLiteral( "negY" ) ] );
|
||||
negZImageSource->setSource( cubeMapFaces[ QStringLiteral( "negZ" ) ] );
|
||||
posXImageSource->setSource( cubeMapFaces[QStringLiteral( "posX" )] );
|
||||
posYImageSource->setSource( cubeMapFaces[QStringLiteral( "posY" )] );
|
||||
posZImageSource->setSource( cubeMapFaces[QStringLiteral( "posZ" )] );
|
||||
negXImageSource->setSource( cubeMapFaces[QStringLiteral( "negX" )] );
|
||||
negYImageSource->setSource( cubeMapFaces[QStringLiteral( "negY" )] );
|
||||
negZImageSource->setSource( cubeMapFaces[QStringLiteral( "negZ" )] );
|
||||
}
|
||||
|
||||
QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings()
|
||||
{
|
||||
QgsSkyboxSettings settings;
|
||||
settings.setSkyboxType( static_cast< QgsSkyboxEntity::SkyboxType >( skyboxTypeComboBox->currentIndex() ) );
|
||||
settings.setSkyboxType( static_cast<QgsSkyboxEntity::SkyboxType>( skyboxTypeComboBox->currentIndex() ) );
|
||||
settings.setPanoramicTexturePath( panoramicTextureImageSource->source() );
|
||||
settings.setCubeMapFace( QStringLiteral( "posX" ), posXImageSource->source() );
|
||||
settings.setCubeMapFace( QStringLiteral( "posY" ), posYImageSource->source() );
|
||||
@ -72,7 +72,7 @@ QgsSkyboxSettings QgsSkyboxRenderingSettingsWidget::toSkyboxSettings()
|
||||
|
||||
void QgsSkyboxRenderingSettingsWidget::showSkyboxSettings( int )
|
||||
{
|
||||
const QgsSkyboxEntity::SkyboxType type = static_cast< QgsSkyboxEntity::SkyboxType >( skyboxTypeComboBox->currentIndex() );
|
||||
const QgsSkyboxEntity::SkyboxType type = static_cast<QgsSkyboxEntity::SkyboxType>( skyboxTypeComboBox->currentIndex() );
|
||||
const bool isPanoramic = type == QgsSkyboxEntity::PanoramicSkybox;
|
||||
const bool isDistinctFaces = type == QgsSkyboxEntity::DistinctTexturesSkybox;
|
||||
|
||||
@ -91,5 +91,4 @@ void QgsSkyboxRenderingSettingsWidget::showSkyboxSettings( int )
|
||||
posYImageSource->setVisible( isDistinctFaces );
|
||||
posZImageSourceLabel->setVisible( isDistinctFaces );
|
||||
posZImageSource->setVisible( isDistinctFaces );
|
||||
|
||||
}
|
||||
|
||||
@ -55,9 +55,9 @@ QgsSymbol3DWidget::QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent )
|
||||
|
||||
std::unique_ptr<QgsAbstract3DSymbol> QgsSymbol3DWidget::symbol()
|
||||
{
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) )
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast<Qgs3DSymbolWidget *>( widgetStack->currentWidget() ) )
|
||||
{
|
||||
return std::unique_ptr< QgsAbstract3DSymbol >( w->symbol() );
|
||||
return std::unique_ptr<QgsAbstract3DSymbol>( w->symbol() );
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -67,7 +67,7 @@ void QgsSymbol3DWidget::setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorL
|
||||
mLayer = vlayer;
|
||||
mStyleWidget->setLayerType( mLayer->geometryType() );
|
||||
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) )
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast<Qgs3DSymbolWidget *>( widgetStack->currentWidget() ) )
|
||||
{
|
||||
if ( w->symbolType() == symbol->type() )
|
||||
{
|
||||
@ -92,7 +92,7 @@ void QgsSymbol3DWidget::setSymbolFromStyle( const QString &name, QgsStyle::Style
|
||||
style = QgsStyle::defaultStyle();
|
||||
|
||||
// get new instance of symbol from style
|
||||
const std::unique_ptr< QgsAbstract3DSymbol > s( style->symbol3D( name ) );
|
||||
const std::unique_ptr<QgsAbstract3DSymbol> s( style->symbol3D( name ) );
|
||||
if ( !s )
|
||||
return;
|
||||
|
||||
@ -111,15 +111,12 @@ void QgsSymbol3DWidget::saveSymbol()
|
||||
|
||||
QgsStyle *destinationStyle = saveDlg.destinationStyle();
|
||||
|
||||
std::unique_ptr< QgsAbstract3DSymbol > newSymbol( symbol() );
|
||||
std::unique_ptr<QgsAbstract3DSymbol> newSymbol( symbol() );
|
||||
|
||||
// check if there is no symbol with same name
|
||||
if ( destinationStyle->symbol3DNames().contains( saveDlg.name() ) )
|
||||
{
|
||||
const int res = QMessageBox::warning( this, tr( "Save 3D Symbol" ),
|
||||
tr( "A 3D symbol with the name '%1' already exists. Overwrite?" )
|
||||
.arg( saveDlg.name() ),
|
||||
QMessageBox::Yes | QMessageBox::No );
|
||||
const int res = QMessageBox::warning( this, tr( "Save 3D Symbol" ), tr( "A 3D symbol with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
|
||||
if ( res != QMessageBox::Yes )
|
||||
{
|
||||
return;
|
||||
@ -142,7 +139,7 @@ void QgsSymbol3DWidget::updateSymbolWidget( const QgsAbstract3DSymbol *newSymbol
|
||||
if ( widgetStack->currentWidget() != widgetUnsupported )
|
||||
{
|
||||
// stop updating from the original widget
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast< Qgs3DSymbolWidget * >( widgetStack->currentWidget() ) )
|
||||
if ( Qgs3DSymbolWidget *w = qobject_cast<Qgs3DSymbolWidget *>( widgetStack->currentWidget() ) )
|
||||
disconnect( w, &Qgs3DSymbolWidget::changed, this, &QgsSymbol3DWidget::widgetChanged );
|
||||
widgetStack->removeWidget( widgetStack->currentWidget() );
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class QgsSymbol3DWidget : public QWidget
|
||||
QgsSymbol3DWidget( QgsVectorLayer *layer, QWidget *parent = nullptr );
|
||||
|
||||
//! Returns a new symbol instance or NULLPTR
|
||||
std::unique_ptr< QgsAbstract3DSymbol > symbol();
|
||||
std::unique_ptr<QgsAbstract3DSymbol> symbol();
|
||||
|
||||
//! Sets symbol (does not take ownership)
|
||||
void setSymbol( const QgsAbstract3DSymbol *symbol, QgsVectorLayer *vlayer );
|
||||
@ -56,7 +56,6 @@ class QgsSymbol3DWidget : public QWidget
|
||||
void saveSymbol();
|
||||
|
||||
private:
|
||||
|
||||
void updateSymbolWidget( const QgsAbstract3DSymbol *newSymbol );
|
||||
|
||||
QStackedWidget *widgetStack = nullptr;
|
||||
@ -65,7 +64,6 @@ class QgsSymbol3DWidget : public QWidget
|
||||
QgsStyleItemsListWidget *mStyleWidget = nullptr;
|
||||
|
||||
QgsVectorLayer *mLayer = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
#include <QStackedWidget>
|
||||
|
||||
|
||||
|
||||
QgsSingleSymbol3DRendererWidget::QgsSingleSymbol3DRendererWidget( QgsVectorLayer *layer, QWidget *parent )
|
||||
: QWidget( parent )
|
||||
, mLayer( layer )
|
||||
@ -74,7 +73,7 @@ void QgsSingleSymbol3DRendererWidget::setLayer( QgsVectorLayer *layer )
|
||||
|
||||
std::unique_ptr<QgsAbstract3DSymbol> QgsSingleSymbol3DRendererWidget::symbol()
|
||||
{
|
||||
return widgetSymbol->symbol(); // cloned or null
|
||||
return widgetSymbol->symbol(); // cloned or null
|
||||
}
|
||||
|
||||
// -------
|
||||
@ -101,14 +100,14 @@ QgsVectorLayer3DRendererWidget::QgsVectorLayer3DRendererWidget( QgsMapLayer *lay
|
||||
layout->addWidget( widgetBaseProperties );
|
||||
|
||||
widgetNoRenderer = new QLabel;
|
||||
widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( qobject_cast< QgsVectorLayer *>( layer ), this );
|
||||
widgetSingleSymbolRenderer = new QgsSingleSymbol3DRendererWidget( qobject_cast<QgsVectorLayer *>( layer ), this );
|
||||
widgetRuleBasedRenderer = new QgsRuleBased3DRendererWidget( this );
|
||||
|
||||
widgetRendererStack->addWidget( widgetNoRenderer );
|
||||
widgetRendererStack->addWidget( widgetSingleSymbolRenderer );
|
||||
widgetRendererStack->addWidget( widgetRuleBasedRenderer );
|
||||
|
||||
connect( cboRendererType, qOverload< int >( &QComboBox::currentIndexChanged ), this, &QgsVectorLayer3DRendererWidget::onRendererTypeChanged );
|
||||
connect( cboRendererType, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsVectorLayer3DRendererWidget::onRendererTypeChanged );
|
||||
connect( widgetSingleSymbolRenderer, &QgsSingleSymbol3DRendererWidget::widgetChanged, this, &QgsVectorLayer3DRendererWidget::widgetChanged );
|
||||
connect( widgetRuleBasedRenderer, &QgsRuleBased3DRendererWidget::widgetChanged, this, &QgsVectorLayer3DRendererWidget::widgetChanged );
|
||||
connect( widgetRuleBasedRenderer, &QgsRuleBased3DRendererWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
||||
@ -171,7 +170,7 @@ void QgsVectorLayer3DRendererWidget::apply()
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
std::unique_ptr< QgsAbstract3DSymbol > symbol = widgetSingleSymbolRenderer->symbol();
|
||||
std::unique_ptr<QgsAbstract3DSymbol> symbol = widgetSingleSymbolRenderer->symbol();
|
||||
QgsVectorLayer3DRenderer *r = new QgsVectorLayer3DRenderer( symbol ? symbol.release() : nullptr );
|
||||
r->setLayer( qobject_cast<QgsVectorLayer *>( mLayer ) );
|
||||
widgetBaseProperties->apply( r );
|
||||
|
||||
@ -45,7 +45,7 @@ class QgsSingleSymbol3DRendererWidget : public QWidget
|
||||
void setLayer( QgsVectorLayer *layer );
|
||||
|
||||
//! Returns the cloned symbol or NULLPTR.
|
||||
std::unique_ptr< QgsAbstract3DSymbol > symbol();
|
||||
std::unique_ptr<QgsAbstract3DSymbol> symbol();
|
||||
|
||||
signals:
|
||||
void widgetChanged();
|
||||
@ -53,11 +53,9 @@ class QgsSingleSymbol3DRendererWidget : public QWidget
|
||||
private:
|
||||
QgsSymbol3DWidget *widgetSymbol = nullptr;
|
||||
QgsVectorLayer *mLayer = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
//! Widget for configuration of 3D renderer of a vector layer
|
||||
class QgsVectorLayer3DRendererWidget : public QgsMapLayerConfigWidget
|
||||
{
|
||||
@ -101,5 +99,4 @@ class QgsVectorLayer3DRendererWidgetFactory : public QObject, public QgsMapLayer
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // QGSVECTORLAYER3DRENDERERWIDGET_H
|
||||
|
||||
@ -51,7 +51,7 @@ QgsAnnotationItemPropertiesWidget::QgsAnnotationItemPropertiesWidget( QgsAnnotat
|
||||
mStack->setCurrentWidget( mPageNoItem );
|
||||
|
||||
connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged );
|
||||
connect( mBlendModeComboBox, qOverload< int >( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged );
|
||||
connect( mBlendModeComboBox, qOverload<int>( &QgsBlendModeComboBox::currentIndexChanged ), this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged );
|
||||
connect( mEffectWidget, &QgsEffectStackCompactWidget::changed, this, &QgsAnnotationItemPropertiesWidget::onLayerPropertyChanged );
|
||||
|
||||
setDockMode( true );
|
||||
@ -66,7 +66,7 @@ void QgsAnnotationItemPropertiesWidget::syncToLayer( QgsMapLayer *layer )
|
||||
if ( layer == mLayer )
|
||||
return;
|
||||
|
||||
mLayer = qobject_cast< QgsAnnotationLayer * >( layer );
|
||||
mLayer = qobject_cast<QgsAnnotationLayer *>( layer );
|
||||
if ( !mLayer )
|
||||
return;
|
||||
|
||||
@ -138,7 +138,7 @@ void QgsAnnotationItemPropertiesWidget::onChanged()
|
||||
|
||||
if ( QgsAnnotationItem *existingItem = mLayer->item( mMapLayerConfigWidgetContext.annotationId() ) )
|
||||
{
|
||||
std::unique_ptr< QgsAnnotationItem > newItem( existingItem->clone() );
|
||||
std::unique_ptr<QgsAnnotationItem> newItem( existingItem->clone() );
|
||||
mItemWidget->updateItem( newItem.get() );
|
||||
|
||||
mLayer->replaceItem( mMapLayerConfigWidgetContext.annotationId(), newItem.release() );
|
||||
@ -228,7 +228,7 @@ QgsAnnotationItemPropertiesWidgetFactory::QgsAnnotationItemPropertiesWidgetFacto
|
||||
|
||||
QgsMapLayerConfigWidget *QgsAnnotationItemPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const
|
||||
{
|
||||
return new QgsAnnotationItemPropertiesWidget( qobject_cast< QgsAnnotationLayer * >( layer ), canvas, parent );
|
||||
return new QgsAnnotationItemPropertiesWidget( qobject_cast<QgsAnnotationLayer *>( layer ), canvas, parent );
|
||||
}
|
||||
|
||||
bool QgsAnnotationItemPropertiesWidgetFactory::supportLayerPropertiesDialog() const
|
||||
@ -245,4 +245,3 @@ bool QgsAnnotationItemPropertiesWidgetFactory::supportsLayer( QgsMapLayer *layer
|
||||
{
|
||||
return layer->type() == Qgis::LayerType::Annotation;
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ class QgsAnnotationItemPropertiesWidget : public QgsMapLayerConfigWidget, public
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
QgsAnnotationItemPropertiesWidget( QgsAnnotationLayer *layer, QgsMapCanvas *canvas, QWidget *parent );
|
||||
~QgsAnnotationItemPropertiesWidget() override;
|
||||
|
||||
@ -45,17 +44,16 @@ class QgsAnnotationItemPropertiesWidget : public QgsMapLayerConfigWidget, public
|
||||
|
||||
void onChanged();
|
||||
void onLayerPropertyChanged();
|
||||
private:
|
||||
|
||||
private:
|
||||
void setItemId( const QString &itemId );
|
||||
|
||||
QPointer< QgsAnnotationLayer > mLayer;
|
||||
QPointer< QgsAnnotationItemBaseWidget > mItemWidget;
|
||||
QPointer<QgsAnnotationLayer> mLayer;
|
||||
QPointer<QgsAnnotationItemBaseWidget> mItemWidget;
|
||||
QWidget *mPageNoItem = nullptr;
|
||||
bool mBlockLayerUpdates = false;
|
||||
|
||||
std::unique_ptr< QgsPaintEffect > mPaintEffect;
|
||||
|
||||
std::unique_ptr<QgsPaintEffect> mPaintEffect;
|
||||
};
|
||||
|
||||
|
||||
@ -72,5 +70,4 @@ class QgsAnnotationItemPropertiesWidgetFactory : public QObject, public QgsMapLa
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // QGSANNOTATIONITEMPROPERTIESWIDGET_H
|
||||
|
||||
@ -59,8 +59,7 @@ QgsAnnotationLayerProperties::QgsAnnotationLayerProperties( QgsAnnotationLayer *
|
||||
QgsSettings settings;
|
||||
if ( !settings.contains( QStringLiteral( "/Windows/AnnotationLayerProperties/tab" ) ) )
|
||||
{
|
||||
settings.setValue( QStringLiteral( "Windows/AnnotationLayerProperties/tab" ),
|
||||
mOptStackedWidget->indexOf( mOptsPage_Information ) );
|
||||
settings.setValue( QStringLiteral( "Windows/AnnotationLayerProperties/tab" ), mOptStackedWidget->indexOf( mOptsPage_Information ) );
|
||||
}
|
||||
|
||||
mBtnStyle = new QPushButton( tr( "Style" ) );
|
||||
|
||||
@ -54,10 +54,9 @@ class APP_EXPORT QgsAnnotationLayerProperties : public QgsLayerPropertiesDialog,
|
||||
|
||||
QPushButton *mBtnStyle = nullptr;
|
||||
|
||||
std::unique_ptr< QgsPaintEffect > mPaintEffect;
|
||||
std::unique_ptr<QgsPaintEffect> mPaintEffect;
|
||||
|
||||
QgsCoordinateReferenceSystem mBackupCrs;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSANNOTATIONLAYERPROPERTIES_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -36,16 +36,13 @@ class QgsAppDirectoryItemGuiProvider : public QObject, public QgsDataItemGuiProv
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsAppDirectoryItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
|
||||
private:
|
||||
|
||||
void addFavorite( QgsDirectoryItem *item );
|
||||
void removeFavorite( QgsFavoriteItem *favorite );
|
||||
void renameFavorite( QgsFavoriteItem *favorite );
|
||||
@ -62,19 +59,16 @@ class QgsAppFileItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsAppFileItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
int precedenceWhenPopulatingMenus() const override;
|
||||
bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) override;
|
||||
|
||||
private:
|
||||
|
||||
bool rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList< QPointer< QgsDataItem > > &parentItems );
|
||||
bool rename( const QString &oldPath, const QString &newName, QgsDataItemGuiContext context, const QList<QPointer<QgsDataItem>> &parentItems );
|
||||
};
|
||||
|
||||
|
||||
@ -83,14 +77,11 @@ class QgsProjectHomeItemGuiProvider : public QObject, public QgsDataItemGuiProvi
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsProjectHomeItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
};
|
||||
|
||||
|
||||
@ -99,14 +90,11 @@ class QgsFavoritesItemGuiProvider : public QObject, public QgsDataItemGuiProvide
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFavoritesItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
};
|
||||
|
||||
|
||||
@ -115,22 +103,18 @@ class QgsLayerItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsLayerItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
int precedenceWhenPopulatingMenus() const override;
|
||||
bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
|
||||
private:
|
||||
|
||||
void addLayersFromItems( const QList<QgsDataItem *> &items );
|
||||
void showPropertiesForItem( QgsLayerItem *item, QgsDataItemGuiContext context );
|
||||
void deleteLayers( const QStringList &itemPath, QgsDataItemGuiContext context );
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -139,13 +123,11 @@ class QgsFieldsItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldsItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
};
|
||||
|
||||
@ -155,13 +137,11 @@ class QgsFieldItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context ) override;
|
||||
|
||||
QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
@ -176,7 +156,6 @@ class QgsFieldsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadata
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName );
|
||||
};
|
||||
|
||||
@ -185,26 +164,22 @@ class QgsFieldDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataW
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName, const QgsField &field );
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsFieldDomainDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldDomainDetailsWidget( QWidget *parent, const QgsFieldDomain *domain );
|
||||
~QgsFieldDomainDetailsWidget() override;
|
||||
|
||||
static QString htmlMetadata( QgsFieldDomain *domain, const QString &title );
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr< QgsFieldDomain > mDomain;
|
||||
std::unique_ptr<QgsFieldDomain> mDomain;
|
||||
};
|
||||
|
||||
class QgsFieldDomainsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase
|
||||
@ -212,7 +187,6 @@ class QgsFieldDomainsDetailsWidget : public QWidget, private Ui_QgsBrowserItemMe
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldDomainsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri );
|
||||
};
|
||||
|
||||
@ -222,31 +196,25 @@ class QgsFieldDomainItemGuiProvider : public QObject, public QgsDataItemGuiProvi
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsFieldDomainItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsRelationshipDetailsWidget : public QWidget, private Ui_QgsBrowserItemMetadataWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsRelationshipDetailsWidget( QWidget *parent, const QgsWeakRelation &relation );
|
||||
~QgsRelationshipDetailsWidget() override;
|
||||
|
||||
static QString htmlMetadata( const QgsWeakRelation &relation, const QString &title );
|
||||
|
||||
private:
|
||||
|
||||
QgsWeakRelation mRelation;
|
||||
};
|
||||
|
||||
@ -255,7 +223,6 @@ class QgsRelationshipsDetailsWidget : public QWidget, private Ui_QgsBrowserItemM
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsRelationshipsDetailsWidget( QWidget *parent, const QString &providerKey, const QString &uri, const QString &schema, const QString &tableName );
|
||||
};
|
||||
|
||||
@ -265,33 +232,26 @@ class QgsRelationshipItemGuiProvider : public QObject, public QgsDataItemGuiProv
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsRelationshipItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsDatabaseItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsDatabaseItemGuiProvider();
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
bool acceptDrop( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context,
|
||||
const QMimeData *data,
|
||||
Qt::DropAction action ) override;
|
||||
bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction action ) override;
|
||||
|
||||
|
||||
void openSqlDialog( const QString &connectionUri, const QString &provider, const QString &query, QgsDataItemGuiContext context, const QString &identifierName = QString() );
|
||||
@ -299,27 +259,20 @@ class QgsDatabaseItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
public slots:
|
||||
|
||||
void openSqlDialogGeneric( const QString &connectionUri, const QString &provider, const QString &query );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QgsProjectItemGuiProvider : public QObject, public QgsDataItemGuiProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsProjectItemGuiProvider() = default;
|
||||
|
||||
QString name() override;
|
||||
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu,
|
||||
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
|
||||
bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context ) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSINBUILTDATAITEMPROVIDERS_H
|
||||
|
||||
|
||||
|
||||
@ -27,14 +27,12 @@
|
||||
QgsAppCanvasFiltering::QgsAppCanvasFiltering( QObject *parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QgsAppCanvasFiltering::setupElevationControllerAction( QAction *action, QgsMapCanvas *canvas )
|
||||
{
|
||||
action->setCheckable( true );
|
||||
connect( action, &QAction::toggled, canvas, [canvas, action, this]( bool checked )
|
||||
{
|
||||
connect( action, &QAction::toggled, canvas, [canvas, action, this]( bool checked ) {
|
||||
if ( checked )
|
||||
{
|
||||
createElevationController( action, canvas );
|
||||
@ -56,30 +54,26 @@ void QgsAppCanvasFiltering::createElevationController( QAction *senderAction, Qg
|
||||
|
||||
QAction *setProjectLimitsAction = new QAction( tr( "Set Elevation Range…" ), controller );
|
||||
controller->menu()->addAction( setProjectLimitsAction );
|
||||
connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), []
|
||||
{
|
||||
connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), [] {
|
||||
QgisApp::instance()->showProjectProperties( tr( "Elevation" ) );
|
||||
} );
|
||||
QAction *disableAction = new QAction( tr( "Disable Elevation Filter" ), controller );
|
||||
controller->menu()->addAction( disableAction );
|
||||
connect( disableAction, &QAction::triggered, senderAction, [senderAction]
|
||||
{
|
||||
connect( disableAction, &QAction::triggered, senderAction, [senderAction] {
|
||||
senderAction->setChecked( false );
|
||||
} );
|
||||
|
||||
mCanvasElevationControllerMap.insert( canvas, controller );
|
||||
connect( canvas, &QObject::destroyed, this, [canvas, this]
|
||||
{
|
||||
connect( canvas, &QObject::destroyed, this, [canvas, this] {
|
||||
mCanvasElevationControllerMap.remove( canvas );
|
||||
} );
|
||||
connect( controller, &QObject::destroyed, this, [canvas, this]
|
||||
{
|
||||
connect( controller, &QObject::destroyed, this, [canvas, this] {
|
||||
mCanvasElevationControllerMap.remove( canvas );
|
||||
} );
|
||||
|
||||
// bridge is parented to controller
|
||||
QgsCanvasElevationControllerBridge *bridge = new QgsCanvasElevationControllerBridge( controller, canvas );
|
||||
( void )bridge;
|
||||
( void ) bridge;
|
||||
}
|
||||
|
||||
QgsCanvasElevationControllerBridge::QgsCanvasElevationControllerBridge( QgsElevationControllerWidget *controller, QgsMapCanvas *canvas )
|
||||
@ -100,13 +94,11 @@ QgsCanvasElevationControllerBridge::QgsCanvasElevationControllerBridge( QgsEleva
|
||||
{
|
||||
// for main canvas, attach settings to project settings
|
||||
mController->setFixedRangeSize( QgsProject::instance()->elevationProperties()->elevationFilterRangeSize() );
|
||||
connect( mController, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size )
|
||||
{
|
||||
connect( mController, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size ) {
|
||||
QgsProject::instance()->elevationProperties()->setElevationFilterRangeSize( size );
|
||||
} );
|
||||
mController->setInverted( QgsProject::instance()->elevationProperties()->invertElevationFilter() );
|
||||
connect( mController, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted )
|
||||
{
|
||||
connect( mController, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted ) {
|
||||
QgsProject::instance()->elevationProperties()->setInvertElevationFilter( inverted );
|
||||
} );
|
||||
}
|
||||
@ -131,7 +123,7 @@ void QgsCanvasElevationControllerBridge::canvasLayersChanged()
|
||||
}
|
||||
|
||||
// and connect to new
|
||||
const QList< QgsMapLayer * > layers = mCanvas->layers( true );
|
||||
const QList<QgsMapLayer *> layers = mCanvas->layers( true );
|
||||
for ( QgsMapLayer *layer : layers )
|
||||
{
|
||||
connect( layer->elevationProperties(), &QgsMapLayerElevationProperties::changed, this, &QgsCanvasElevationControllerBridge::updateSignificantElevations );
|
||||
|
||||
@ -31,7 +31,6 @@ class QgsCanvasElevationControllerBridge : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsCanvasElevationControllerBridge( QgsElevationControllerWidget *controller, QgsMapCanvas *canvas );
|
||||
|
||||
private slots:
|
||||
@ -44,7 +43,7 @@ class QgsCanvasElevationControllerBridge : public QObject
|
||||
private:
|
||||
QTimer *mUpdateCanvasTimer = nullptr;
|
||||
QgsElevationControllerWidget *mController = nullptr;
|
||||
QPointer< QgsMapCanvas> mCanvas;
|
||||
QPointer<QgsMapCanvas> mCanvas;
|
||||
QgsWeakMapLayerPointerList mCanvasLayers;
|
||||
};
|
||||
|
||||
@ -53,17 +52,14 @@ class QgsAppCanvasFiltering : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsAppCanvasFiltering( QObject *parent );
|
||||
|
||||
void setupElevationControllerAction( QAction *action, QgsMapCanvas *canvas );
|
||||
|
||||
private:
|
||||
|
||||
void createElevationController( QAction *senderAction, QgsMapCanvas *canvas );
|
||||
|
||||
QHash< QgsMapCanvas *, QgsElevationControllerWidget * > mCanvasElevationControllerMap;
|
||||
|
||||
QHash<QgsMapCanvas *, QgsElevationControllerWidget *> mCanvasElevationControllerMap;
|
||||
};
|
||||
|
||||
#endif // QGSAPPCANVASFILTERING_H
|
||||
|
||||
@ -44,4 +44,3 @@ QgsCanvasRefreshBlocker::~QgsCanvasRefreshBlocker()
|
||||
if ( !mReleased )
|
||||
release();
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
class QgsCanvasRefreshBlocker
|
||||
{
|
||||
public:
|
||||
|
||||
QgsCanvasRefreshBlocker();
|
||||
QgsCanvasRefreshBlocker( const QgsCanvasRefreshBlocker &other ) = delete;
|
||||
QgsCanvasRefreshBlocker &operator=( const QgsCanvasRefreshBlocker &other ) = delete;
|
||||
@ -30,7 +29,6 @@ class QgsCanvasRefreshBlocker
|
||||
~QgsCanvasRefreshBlocker();
|
||||
|
||||
private:
|
||||
|
||||
bool mReleased = false;
|
||||
};
|
||||
|
||||
|
||||
@ -199,4 +199,3 @@ void QgsDecorationCopyright::render( const QgsMapSettings &mapSettings, QgsRende
|
||||
//Paint label to canvas
|
||||
QgsTextRenderer::drawText( QPointF( xOffset, yOffset ), 0.0, horizontalAlignment, displayStringList, context, mTextFormat );
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,6 @@ class APP_EXPORT QgsDecorationCopyright : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
QgsDecorationCopyright( QObject *parent = nullptr );
|
||||
|
||||
|
||||
@ -67,8 +67,7 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
|
||||
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
|
||||
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
|
||||
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 );
|
||||
} );
|
||||
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
|
||||
@ -76,10 +75,7 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
|
||||
spnHorizontal->setClearValue( 0 );
|
||||
spnHorizontal->setValue( mDeco.mMarginHorizontal );
|
||||
spnVertical->setValue( mDeco.mMarginVertical );
|
||||
wgtUnitSelection->setUnits( { Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
} );
|
||||
wgtUnitSelection->setUnits( { Qgis::RenderUnit::Millimeters, Qgis::RenderUnit::Percentage, Qgis::RenderUnit::Pixels } );
|
||||
wgtUnitSelection->setUnit( mDeco.mMarginUnit );
|
||||
|
||||
// font settings
|
||||
@ -119,7 +115,7 @@ void QgsDecorationCopyrightDialog::apply()
|
||||
{
|
||||
mDeco.setTextFormat( mButtonFontStyle->textFormat() );
|
||||
mDeco.mLabelText = txtCopyrightText->toPlainText();
|
||||
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.setPlacement( static_cast<QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.mMarginUnit = wgtUnitSelection->unit();
|
||||
mDeco.mMarginHorizontal = spnHorizontal->value();
|
||||
mDeco.mMarginVertical = spnVertical->value();
|
||||
|
||||
@ -66,8 +66,7 @@ QgsDecorationGrid::QgsDecorationGrid( QObject *parent )
|
||||
|
||||
projectRead();
|
||||
|
||||
connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::destinationCrsChanged,
|
||||
this, &QgsDecorationGrid::checkMapUnitsChanged );
|
||||
connect( QgisApp::instance()->mapCanvas(), &QgsMapCanvas::destinationCrsChanged, this, &QgsDecorationGrid::checkMapUnitsChanged );
|
||||
}
|
||||
|
||||
QgsDecorationGrid::~QgsDecorationGrid() = default;
|
||||
@ -87,17 +86,14 @@ void QgsDecorationGrid::projectRead()
|
||||
QgsDecorationItem::projectRead();
|
||||
|
||||
mEnabled = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/Enabled" ), false );
|
||||
mMapUnits = static_cast< Qgis::DistanceUnit >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/MapUnits" ),
|
||||
static_cast< int >( Qgis::DistanceUnit::Unknown ) ) );
|
||||
mGridStyle = static_cast< GridStyle >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Style" ),
|
||||
QgsDecorationGrid::Line ) );
|
||||
mMapUnits = static_cast<Qgis::DistanceUnit>( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast<int>( Qgis::DistanceUnit::Unknown ) ) );
|
||||
mGridStyle = static_cast<GridStyle>( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Style" ), QgsDecorationGrid::Line ) );
|
||||
mGridIntervalX = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/IntervalX" ), 10 );
|
||||
mGridIntervalY = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/IntervalY" ), 10 );
|
||||
mGridOffsetX = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/OffsetX" ), 0 );
|
||||
mGridOffsetY = QgsProject::instance()->readDoubleEntry( mConfigurationName, QStringLiteral( "/OffsetY" ), 0 );
|
||||
mShowGridAnnotation = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/ShowAnnotation" ), false );
|
||||
mGridAnnotationDirection = static_cast< GridAnnotationDirection >( QgsProject::instance()->readNumEntry( mConfigurationName,
|
||||
QStringLiteral( "/AnnotationDirection" ), 0 ) );
|
||||
mGridAnnotationDirection = static_cast<GridAnnotationDirection>( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), 0 ) );
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement elem;
|
||||
@ -128,8 +124,8 @@ void QgsDecorationGrid::projectRead()
|
||||
elem = doc.documentElement();
|
||||
mLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( elem, rwContext ) );
|
||||
}
|
||||
if ( ! mLineSymbol )
|
||||
mLineSymbol = std::make_unique< QgsLineSymbol >();
|
||||
if ( !mLineSymbol )
|
||||
mLineSymbol = std::make_unique<QgsLineSymbol>();
|
||||
|
||||
if ( mMarkerSymbol )
|
||||
setMarkerSymbol( nullptr );
|
||||
@ -140,12 +136,12 @@ void QgsDecorationGrid::projectRead()
|
||||
elem = doc.documentElement();
|
||||
mMarkerSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( elem, rwContext ) );
|
||||
}
|
||||
if ( ! mMarkerSymbol )
|
||||
if ( !mMarkerSymbol )
|
||||
{
|
||||
// set default symbol : cross with width=3
|
||||
QgsSymbolLayerList symbolList;
|
||||
symbolList << new QgsSimpleMarkerSymbolLayer( Qgis::MarkerShape::Cross, 3, 0 );
|
||||
mMarkerSymbol = std::make_unique< QgsMarkerSymbol >( symbolList );
|
||||
mMarkerSymbol = std::make_unique<QgsMarkerSymbol>( symbolList );
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,14 +149,14 @@ void QgsDecorationGrid::saveToProject()
|
||||
{
|
||||
QgsDecorationItem::saveToProject();
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Enabled" ), mEnabled );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast< int >( mMapUnits ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Style" ), static_cast< int >( mGridStyle ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MapUnits" ), static_cast<int>( mMapUnits ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Style" ), static_cast<int>( mGridStyle ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/IntervalX" ), mGridIntervalX );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/IntervalY" ), mGridIntervalY );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/OffsetX" ), mGridOffsetX );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/OffsetY" ), mGridOffsetY );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/ShowAnnotation" ), mShowGridAnnotation );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), static_cast< int >( mGridAnnotationDirection ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationDirection" ), static_cast<int>( mGridAnnotationDirection ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationFont" ), mGridAnnotationFont.toString() );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationFrameDistance" ), mAnnotationFrameDistance );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/AnnotationPrecision" ), mGridAnnotationPrecision );
|
||||
@ -190,7 +186,6 @@ void QgsDecorationGrid::saveToProject()
|
||||
doc.appendChild( elem );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MarkerSymbol" ), doc.toString() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -206,22 +201,22 @@ void QgsDecorationGrid::run()
|
||||
|
||||
void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderContext &context )
|
||||
{
|
||||
if ( ! mEnabled )
|
||||
if ( !mEnabled )
|
||||
return;
|
||||
|
||||
QList< QPair< qreal, QLineF > > verticalLines;
|
||||
QList<QPair<qreal, QLineF>> verticalLines;
|
||||
yGridLines( mapSettings, verticalLines );
|
||||
QList< QPair< qreal, QLineF > > horizontalLines;
|
||||
QList<QPair<qreal, QLineF>> horizontalLines;
|
||||
xGridLines( mapSettings, horizontalLines );
|
||||
|
||||
QList< QPair< qreal, QLineF > >::const_iterator vIt = verticalLines.constBegin();
|
||||
QList< QPair< qreal, QLineF > >::const_iterator hIt = horizontalLines.constBegin();
|
||||
QList<QPair<qreal, QLineF>>::const_iterator vIt = verticalLines.constBegin();
|
||||
QList<QPair<qreal, QLineF>>::const_iterator hIt = horizontalLines.constBegin();
|
||||
|
||||
switch ( mGridStyle )
|
||||
{
|
||||
case Line:
|
||||
{
|
||||
if ( ! mLineSymbol )
|
||||
if ( !mLineSymbol )
|
||||
return;
|
||||
|
||||
mLineSymbol->startRender( context );
|
||||
@ -250,7 +245,7 @@ void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderCont
|
||||
|
||||
case Marker:
|
||||
{
|
||||
if ( ! mMarkerSymbol )
|
||||
if ( !mMarkerSymbol )
|
||||
return;
|
||||
|
||||
mMarkerSymbol->startRender( context );
|
||||
@ -279,10 +274,10 @@ void QgsDecorationGrid::render( const QgsMapSettings &mapSettings, QgsRenderCont
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDecorationGrid::drawCoordinateAnnotations( QgsRenderContext &context, const QList< QPair< qreal, QLineF > > &hLines, const QList< QPair< qreal, QLineF > > &vLines )
|
||||
void QgsDecorationGrid::drawCoordinateAnnotations( QgsRenderContext &context, const QList<QPair<qreal, QLineF>> &hLines, const QList<QPair<qreal, QLineF>> &vLines )
|
||||
{
|
||||
QString currentAnnotationString;
|
||||
QList< QPair< qreal, QLineF > >::const_iterator it = hLines.constBegin();
|
||||
QList<QPair<qreal, QLineF>>::const_iterator it = hLines.constBegin();
|
||||
for ( ; it != hLines.constEnd(); ++it )
|
||||
{
|
||||
currentAnnotationString = QString::number( it->first, 'f', mGridAnnotationPrecision );
|
||||
@ -401,7 +396,8 @@ static bool clipByRect( QLineF &line, const QPolygonF &rect )
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( intersectionList.size() < 2 ) return false; // no intersection
|
||||
if ( intersectionList.size() < 2 )
|
||||
return false; // no intersection
|
||||
|
||||
line = QLineF( intersectionList.at( 0 ), intersectionList.at( 1 ) );
|
||||
return true;
|
||||
@ -418,7 +414,7 @@ static QPolygonF canvasExtent( const QgsMapSettings &mapSettings )
|
||||
return poly;
|
||||
}
|
||||
|
||||
int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const
|
||||
int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList<QPair<qreal, QLineF>> &lines ) const
|
||||
{
|
||||
// prepare horizontal lines
|
||||
lines.clear();
|
||||
@ -445,7 +441,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa
|
||||
Q_ASSERT( std::fabs( len - lineWest.length() ) < 1e-6 ); // no shear
|
||||
|
||||
const double roundCorrection = mapBoundingRect.top() > 0 ? 1.0 : 0.0;
|
||||
double dist = static_cast< int >( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;
|
||||
double dist = static_cast<int>( ( mapBoundingRect.top() - mGridOffsetY ) / mGridIntervalY + roundCorrection ) * mGridIntervalY + mGridOffsetY;
|
||||
dist = dist - mapBoundingRect.top();
|
||||
while ( dist < len )
|
||||
{
|
||||
@ -462,7 +458,7 @@ int QgsDecorationGrid::xGridLines( const QgsMapSettings &mapSettings, QList< QPa
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const
|
||||
int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList<QPair<qreal, QLineF>> &lines ) const
|
||||
{
|
||||
// prepare vertical lines
|
||||
|
||||
@ -490,7 +486,7 @@ int QgsDecorationGrid::yGridLines( const QgsMapSettings &mapSettings, QList< QPa
|
||||
|
||||
const QRectF mapBoundingRect = mapPolygon.boundingRect();
|
||||
const double roundCorrection = mapBoundingRect.left() > 0 ? 1.0 : 0.0;
|
||||
double dist = static_cast< int >( ( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;
|
||||
double dist = static_cast<int>( ( mapBoundingRect.left() - mGridOffsetX ) / mGridIntervalX + roundCorrection ) * mGridIntervalX + mGridOffsetX;
|
||||
dist = dist - mapBoundingRect.left();
|
||||
while ( dist < len )
|
||||
{
|
||||
@ -538,7 +534,7 @@ void QgsDecorationGrid::checkMapUnitsChanged()
|
||||
{
|
||||
mEnabled = false;
|
||||
mMapUnits = Qgis::DistanceUnit::Unknown; // make sure isDirty() returns true
|
||||
if ( ! QgisApp::instance()->mapCanvas()->isFrozen() )
|
||||
if ( !QgisApp::instance()->mapCanvas()->isFrozen() )
|
||||
{
|
||||
update();
|
||||
}
|
||||
@ -549,9 +545,7 @@ bool QgsDecorationGrid::isDirty()
|
||||
{
|
||||
// checks if stored map units is undefined or different from canvas map units
|
||||
// or if interval is 0
|
||||
return mMapUnits == Qgis::DistanceUnit::Unknown ||
|
||||
mMapUnits != QgisApp::instance()->mapCanvas()->mapSettings().mapUnits() ||
|
||||
qgsDoubleNear( mGridIntervalX, 0.0 ) || qgsDoubleNear( mGridIntervalY, 0.0 );
|
||||
return mMapUnits == Qgis::DistanceUnit::Unknown || mMapUnits != QgisApp::instance()->mapCanvas()->mapSettings().mapUnits() || qgsDoubleNear( mGridIntervalX, 0.0 ) || qgsDoubleNear( mGridIntervalY, 0.0 );
|
||||
}
|
||||
|
||||
void QgsDecorationGrid::setDirty( bool dirty )
|
||||
@ -599,7 +593,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const
|
||||
{
|
||||
// get current layer and make sure it is a raster layer and CRSs match
|
||||
QgsMapLayer *layer = QgisApp::instance()->mapCanvas()->currentLayer();
|
||||
if ( ! layer )
|
||||
if ( !layer )
|
||||
{
|
||||
QMessageBox::warning( nullptr, tr( "Get Interval from Layer" ), tr( "No active layer" ) );
|
||||
return false;
|
||||
@ -616,8 +610,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const
|
||||
return false;
|
||||
}
|
||||
const QgsCoordinateReferenceSystem layerCRS = layer->crs();
|
||||
const QgsCoordinateReferenceSystem mapCRS =
|
||||
QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs();
|
||||
const QgsCoordinateReferenceSystem mapCRS = QgisApp::instance()->mapCanvas()->mapSettings().destinationCrs();
|
||||
// is this the best way to compare CRS? should we also make sure map has OTF enabled?
|
||||
// TODO calculate transformed values if necessary
|
||||
if ( layerCRS != mapCRS )
|
||||
@ -640,10 +633,8 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values ) const
|
||||
ratio = extent.yMinimum() / values[1];
|
||||
values[3] = ( ratio - std::floor( ratio ) ) * values[1];
|
||||
|
||||
QgsDebugMsgLevel( QStringLiteral( "xmax: %1 xmin: %2 width: %3 xInterval: %4 xOffset: %5" ).arg(
|
||||
extent.xMaximum() ).arg( extent.xMinimum() ).arg( rlayer->width() ).arg( values[0] ).arg( values[2] ), 2 );
|
||||
QgsDebugMsgLevel( QStringLiteral( "ymax: %1 ymin: %2 height: %3 yInterval: %4 yOffset: %5" ).arg(
|
||||
extent.yMaximum() ).arg( extent.yMinimum() ).arg( rlayer->height() ).arg( values[1] ).arg( values[3] ), 2 );
|
||||
QgsDebugMsgLevel( QStringLiteral( "xmax: %1 xmin: %2 width: %3 xInterval: %4 xOffset: %5" ).arg( extent.xMaximum() ).arg( extent.xMinimum() ).arg( rlayer->width() ).arg( values[0] ).arg( values[2] ), 2 );
|
||||
QgsDebugMsgLevel( QStringLiteral( "ymax: %1 ymin: %2 height: %3 yInterval: %4 yOffset: %5" ).arg( extent.yMaximum() ).arg( extent.yMinimum() ).arg( rlayer->height() ).arg( values[1] ).arg( values[3] ), 2 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -30,20 +30,18 @@ class QgsMarkerSymbol;
|
||||
#include <QFont>
|
||||
#include "qgis_app.h"
|
||||
|
||||
class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
class APP_EXPORT QgsDecorationGrid : public QgsDecorationItem
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsDecorationGrid( QObject *parent = nullptr );
|
||||
~ QgsDecorationGrid() override;
|
||||
~QgsDecorationGrid() override;
|
||||
|
||||
enum GridStyle
|
||||
{
|
||||
Line = 0, // lines
|
||||
Marker //markers
|
||||
Marker //markers
|
||||
};
|
||||
|
||||
enum GridAnnotationDirection
|
||||
@ -69,15 +67,15 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
|
||||
|
||||
//! Sets coordinate grid style.
|
||||
void setGridStyle( GridStyle style ) {mGridStyle = style;}
|
||||
void setGridStyle( GridStyle style ) { mGridStyle = style; }
|
||||
GridStyle gridStyle() const { return mGridStyle; }
|
||||
|
||||
//! Sets coordinate interval in x-direction for composergrid.
|
||||
void setGridIntervalX( double interval ) { mGridIntervalX = interval;}
|
||||
void setGridIntervalX( double interval ) { mGridIntervalX = interval; }
|
||||
double gridIntervalX() const { return mGridIntervalX; }
|
||||
|
||||
//! Sets coordinate interval in y-direction for composergrid.
|
||||
void setGridIntervalY( double interval ) { mGridIntervalY = interval;}
|
||||
void setGridIntervalY( double interval ) { mGridIntervalY = interval; }
|
||||
double gridIntervalY() const { return mGridIntervalY; }
|
||||
|
||||
//! Sets x-coordinate offset for composer grid
|
||||
@ -94,27 +92,27 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
//! Sets with of grid pen
|
||||
void setGridPenWidth( double w ) { mGridPen.setWidthF( w ); }
|
||||
//! Sets the color of the grid pen
|
||||
void setGridPenColor( const QColor &c ) { mGridPen.setColor( c ); }
|
||||
void setGridPenColor( const QColor &c ) { mGridPen.setColor( c ); }
|
||||
|
||||
//! Sets font for grid annotations
|
||||
void setGridAnnotationFont( const QFont &f ) { mGridAnnotationFont = f; }
|
||||
QFont gridAnnotationFont() const { return mGridAnnotationFont; }
|
||||
|
||||
//! Sets coordinate precision for grid annotations
|
||||
void setGridAnnotationPrecision( int p ) {mGridAnnotationPrecision = p;}
|
||||
int gridAnnotationPrecision() const {return mGridAnnotationPrecision;}
|
||||
void setGridAnnotationPrecision( int p ) { mGridAnnotationPrecision = p; }
|
||||
int gridAnnotationPrecision() const { return mGridAnnotationPrecision; }
|
||||
|
||||
//! Sets flag if grid annotation should be shown
|
||||
void setShowGridAnnotation( bool show ) {mShowGridAnnotation = show;}
|
||||
bool showGridAnnotation() const {return mShowGridAnnotation;}
|
||||
void setShowGridAnnotation( bool show ) { mShowGridAnnotation = show; }
|
||||
bool showGridAnnotation() const { return mShowGridAnnotation; }
|
||||
|
||||
//! Sets distance between map frame and annotations
|
||||
void setAnnotationFrameDistance( double d ) {mAnnotationFrameDistance = d;}
|
||||
double annotationFrameDistance() const {return mAnnotationFrameDistance;}
|
||||
void setAnnotationFrameDistance( double d ) { mAnnotationFrameDistance = d; }
|
||||
double annotationFrameDistance() const { return mAnnotationFrameDistance; }
|
||||
|
||||
//! Sets grid annotation direction. Can be horizontal, vertical, direction of axis and horizontal and vertical
|
||||
void setGridAnnotationDirection( GridAnnotationDirection d ) {mGridAnnotationDirection = d;}
|
||||
GridAnnotationDirection gridAnnotationDirection() const {return mGridAnnotationDirection;}
|
||||
void setGridAnnotationDirection( GridAnnotationDirection d ) { mGridAnnotationDirection = d; }
|
||||
GridAnnotationDirection gridAnnotationDirection() const { return mGridAnnotationDirection; }
|
||||
|
||||
//! Sets symbol that is used to draw grid lines. Takes ownership
|
||||
void setLineSymbol( QgsLineSymbol *symbol );
|
||||
@ -154,7 +152,6 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
void checkMapUnitsChanged();
|
||||
|
||||
private:
|
||||
|
||||
//! Enum for different frame borders
|
||||
enum Border
|
||||
{
|
||||
@ -187,8 +184,8 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
//! Annotation can be horizontal / vertical or different for axes
|
||||
GridAnnotationDirection mGridAnnotationDirection;
|
||||
|
||||
std::unique_ptr< QgsLineSymbol > mLineSymbol;
|
||||
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
|
||||
std::unique_ptr<QgsLineSymbol> mLineSymbol;
|
||||
std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
|
||||
|
||||
Qgis::DistanceUnit mMapUnits;
|
||||
|
||||
@ -198,20 +195,20 @@ class APP_EXPORT QgsDecorationGrid: public QgsDecorationItem
|
||||
* \param hLines horizontal coordinate lines in item coordinates
|
||||
* \param vLines vertical coordinate lines in item coordinates
|
||||
*/
|
||||
void drawCoordinateAnnotations( QgsRenderContext &context, const QList< QPair< qreal, QLineF > > &hLines, const QList< QPair< qreal, QLineF > > &vLines );
|
||||
void drawCoordinateAnnotations( QgsRenderContext &context, const QList<QPair<qreal, QLineF>> &hLines, const QList<QPair<qreal, QLineF>> &vLines );
|
||||
void drawCoordinateAnnotation( QgsRenderContext &context, QPointF pos, const QString &annotationString );
|
||||
|
||||
/**
|
||||
* Returns the grid lines with associated coordinate value
|
||||
* \returns 0 in case of success
|
||||
*/
|
||||
int xGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const;
|
||||
int xGridLines( const QgsMapSettings &mapSettings, QList<QPair<qreal, QLineF>> &lines ) const;
|
||||
|
||||
/**
|
||||
* Returns the grid lines for the y-coordinates. Not vertical in case of rotation
|
||||
* \returns 0 in case of success
|
||||
*/
|
||||
int yGridLines( const QgsMapSettings &mapSettings, QList< QPair< qreal, QLineF > > &lines ) const;
|
||||
int yGridLines( const QgsMapSettings &mapSettings, QList<QPair<qreal, QLineF>> &lines ) const;
|
||||
|
||||
//! Returns the item border of a point (in item coordinates)
|
||||
Border borderForLineCoord( QPointF point, const QPainter *p ) const;
|
||||
|
||||
@ -38,7 +38,7 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
|
||||
|
||||
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationGridDialog::buttonBox_accepted );
|
||||
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationGridDialog::buttonBox_rejected );
|
||||
connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int ) { updateSymbolButtons(); } );
|
||||
connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [=]( int ) { updateSymbolButtons(); } );
|
||||
connect( mPbtnUpdateFromExtents, &QPushButton::clicked, this, &QgsDecorationGridDialog::mPbtnUpdateFromExtents_clicked );
|
||||
connect( mPbtnUpdateFromLayer, &QPushButton::clicked, this, &QgsDecorationGridDialog::mPbtnUpdateFromLayer_clicked );
|
||||
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationGridDialog::showHelp );
|
||||
@ -47,7 +47,7 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
|
||||
mLineSymbolButton->setSymbolType( Qgis::SymbolType::Line );
|
||||
|
||||
grpEnable->setChecked( mDeco.enabled() );
|
||||
connect( grpEnable, &QGroupBox::toggled, this, [ = ] { updateSymbolButtons(); } );
|
||||
connect( grpEnable, &QGroupBox::toggled, this, [=] { updateSymbolButtons(); } );
|
||||
|
||||
// mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) );
|
||||
|
||||
@ -57,14 +57,10 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
|
||||
// mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::InsideMapFrame, tr( "Inside frame" ) );
|
||||
// mAnnotationPositionComboBox->insertItem( QgsDecorationGrid::OutsideMapFrame, tr( "Outside frame" ) );
|
||||
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal,
|
||||
tr( "Horizontal" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical,
|
||||
tr( "Vertical" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical,
|
||||
tr( "Horizontal and Vertical" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection,
|
||||
tr( "Boundary direction" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Horizontal, tr( "Horizontal" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::Vertical, tr( "Vertical" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::HorizontalAndVertical, tr( "Horizontal and Vertical" ) );
|
||||
mAnnotationDirectionComboBox->insertItem( QgsDecorationGrid::BoundaryDirection, tr( "Boundary direction" ) );
|
||||
|
||||
updateGuiElements();
|
||||
|
||||
@ -83,7 +79,6 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
|
||||
|
||||
void QgsDecorationGridDialog::updateGuiElements()
|
||||
{
|
||||
|
||||
grpEnable->setChecked( mDeco.enabled() );
|
||||
|
||||
mIntervalXEdit->setValue( mDeco.gridIntervalX() );
|
||||
@ -93,7 +88,7 @@ void QgsDecorationGridDialog::updateGuiElements()
|
||||
|
||||
mGridTypeComboBox->setCurrentIndex( mGridTypeComboBox->findData( mDeco.gridStyle() ) );
|
||||
mDrawAnnotationCheckBox->setChecked( mDeco.showGridAnnotation() );
|
||||
mAnnotationDirectionComboBox->setCurrentIndex( static_cast< int >( mDeco.gridAnnotationDirection() ) );
|
||||
mAnnotationDirectionComboBox->setCurrentIndex( static_cast<int>( mDeco.gridAnnotationDirection() ) );
|
||||
mCoordinatePrecisionSpinBox->setValue( mDeco.gridAnnotationPrecision() );
|
||||
|
||||
mDistanceToMapFrameSpinBox->setValue( mDeco.annotationFrameDistance() );
|
||||
@ -122,7 +117,7 @@ void QgsDecorationGridDialog::updateDecoFromGui()
|
||||
mDeco.setGridIntervalY( mIntervalYEdit->value() );
|
||||
mDeco.setGridOffsetX( mOffsetXEdit->value() );
|
||||
mDeco.setGridOffsetY( mOffsetYEdit->value() );
|
||||
mDeco.setGridStyle( static_cast< QgsDecorationGrid::GridStyle >( mGridTypeComboBox->currentData().toInt() ) );
|
||||
mDeco.setGridStyle( static_cast<QgsDecorationGrid::GridStyle>( mGridTypeComboBox->currentData().toInt() ) );
|
||||
|
||||
mDeco.setTextFormat( mAnnotationFontButton->textFormat() );
|
||||
mDeco.setAnnotationFrameDistance( mDistanceToMapFrameSpinBox->value() );
|
||||
@ -145,8 +140,8 @@ void QgsDecorationGridDialog::updateDecoFromGui()
|
||||
mDeco.setGridAnnotationDirection( QgsDecorationGrid::BoundaryDirection );
|
||||
}
|
||||
mDeco.setGridAnnotationPrecision( mCoordinatePrecisionSpinBox->value() );
|
||||
mDeco.setLineSymbol( mLineSymbolButton->clonedSymbol< QgsLineSymbol >() );
|
||||
mDeco.setMarkerSymbol( mMarkerSymbolButton->clonedSymbol< QgsMarkerSymbol >() );
|
||||
mDeco.setLineSymbol( mLineSymbolButton->clonedSymbol<QgsLineSymbol>() );
|
||||
mDeco.setMarkerSymbol( mMarkerSymbolButton->clonedSymbol<QgsMarkerSymbol>() );
|
||||
}
|
||||
|
||||
void QgsDecorationGridDialog::showHelp()
|
||||
|
||||
@ -49,7 +49,6 @@ class APP_EXPORT QgsDecorationGridDialog : public QDialog, private Ui::QgsDecora
|
||||
void updateGuiElements();
|
||||
void updateDecoFromGui();
|
||||
void updateInterval( bool force = false );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -250,15 +250,13 @@ void QgsDecorationImage::render( const QgsMapSettings &mapSettings, QgsRenderCon
|
||||
context.painter()->translate( deviceWidth - xOffset - size.width(), yOffset );
|
||||
break;
|
||||
case BottomRight:
|
||||
context.painter()->translate( deviceWidth - xOffset - size.width(),
|
||||
deviceHeight - yOffset - size.height() );
|
||||
context.painter()->translate( deviceWidth - xOffset - size.width(), deviceHeight - yOffset - size.height() );
|
||||
break;
|
||||
case TopCenter:
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, yOffset );
|
||||
break;
|
||||
case BottomCenter:
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset,
|
||||
deviceHeight - yOffset - size.height() );
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, deviceHeight - yOffset - size.height() );
|
||||
break;
|
||||
default:
|
||||
QgsDebugError( QStringLiteral( "Unsupported placement index of %1" ).arg( static_cast<int>( mPlacement ) ) );
|
||||
|
||||
@ -26,19 +26,18 @@ class QAction;
|
||||
class QToolBar;
|
||||
class QPainter;
|
||||
|
||||
class APP_EXPORT QgsDecorationImage: public QgsDecorationItem
|
||||
class APP_EXPORT QgsDecorationImage : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Format of source image
|
||||
*/
|
||||
enum Format
|
||||
{
|
||||
FormatSVG, //!< SVG image
|
||||
FormatRaster, //!< Raster image
|
||||
FormatSVG, //!< SVG image
|
||||
FormatRaster, //!< Raster image
|
||||
FormatUnknown, //!< Invalid or unknown image type
|
||||
};
|
||||
|
||||
@ -65,7 +64,6 @@ class APP_EXPORT QgsDecorationImage: public QgsDecorationItem
|
||||
QString imagePath();
|
||||
|
||||
private:
|
||||
|
||||
//! The image fill color used with parameter-enabled SVG files
|
||||
QColor mColor;
|
||||
//! The image outline color used with parameter-enabled SVG files
|
||||
|
||||
@ -51,8 +51,7 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW
|
||||
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
|
||||
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
|
||||
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
spinHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 );
|
||||
} );
|
||||
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
|
||||
@ -61,16 +60,16 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW
|
||||
spinHorizontal->setValue( mDeco.mMarginHorizontal );
|
||||
spinVertical->setValue( mDeco.mMarginVertical );
|
||||
wgtUnitSelection->setUnits(
|
||||
{
|
||||
Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
} );
|
||||
{ Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
}
|
||||
);
|
||||
wgtUnitSelection->setUnit( mDeco.mMarginUnit );
|
||||
|
||||
// enabled
|
||||
grpEnable->setChecked( mDeco.enabled() );
|
||||
connect( grpEnable, &QGroupBox::toggled, this, [ = ] { updateEnabledColorButtons(); } );
|
||||
connect( grpEnable, &QGroupBox::toggled, this, [=] { updateEnabledColorButtons(); } );
|
||||
|
||||
wgtImagePath->setFilePath( mDeco.imagePath() );
|
||||
connect( wgtImagePath, &QgsFileWidget::fileChanged, this, &QgsDecorationImageDialog::updateImagePath );
|
||||
@ -84,8 +83,8 @@ QgsDecorationImageDialog::QgsDecorationImageDialog( QgsDecorationImage &deco, QW
|
||||
pbnChangeOutlineColor->setColor( mDeco.mOutlineColor );
|
||||
pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) );
|
||||
pbnChangeOutlineColor->setColorDialogTitle( tr( "Select SVG Image Outline Color" ) );
|
||||
connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawImage(); } );
|
||||
connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawImage(); } );
|
||||
connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawImage(); } );
|
||||
connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawImage(); } );
|
||||
|
||||
drawImage();
|
||||
}
|
||||
@ -111,7 +110,7 @@ void QgsDecorationImageDialog::apply()
|
||||
mDeco.mColor = pbnChangeColor->color();
|
||||
mDeco.mOutlineColor = pbnChangeOutlineColor->color();
|
||||
mDeco.mSize = spinSize->value();
|
||||
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.setPlacement( static_cast<QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.mMarginUnit = wgtUnitSelection->unit();
|
||||
mDeco.setEnabled( grpEnable->isChecked() );
|
||||
mDeco.mMarginHorizontal = spinHorizontal->value();
|
||||
@ -121,18 +120,13 @@ void QgsDecorationImageDialog::apply()
|
||||
|
||||
void QgsDecorationImageDialog::updateEnabledColorButtons()
|
||||
{
|
||||
|
||||
if ( mDeco.mImageFormat == QgsDecorationImage::FormatSVG )
|
||||
{
|
||||
QColor defaultFill, defaultStroke;
|
||||
double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
|
||||
bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
|
||||
bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
|
||||
QgsApplication::svgCache()->containsParams( mDeco.imagePath(), hasFillParam, hasDefaultFillColor, defaultFill,
|
||||
hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
|
||||
hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
|
||||
hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
|
||||
hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
|
||||
QgsApplication::svgCache()->containsParams( mDeco.imagePath(), hasFillParam, hasDefaultFillColor, defaultFill, hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity, hasStrokeParam, hasDefaultStrokeColor, defaultStroke, hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth, hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
|
||||
|
||||
pbnChangeColor->setEnabled( grpEnable->isChecked() && hasFillParam );
|
||||
pbnChangeColor->setAllowOpacity( hasFillOpacityParam );
|
||||
@ -234,7 +228,7 @@ void QgsDecorationImageDialog::drawImage()
|
||||
|
||||
if ( !missing )
|
||||
{
|
||||
QPixmap px( maxLength, maxLength );
|
||||
QPixmap px( maxLength, maxLength );
|
||||
px.fill( Qt::transparent );
|
||||
|
||||
QPainter painter;
|
||||
@ -258,7 +252,7 @@ void QgsDecorationImageDialog::drawImage()
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap px( 200, 200 );
|
||||
QPixmap px( 200, 200 );
|
||||
px.fill( Qt::transparent );
|
||||
QPainter painter;
|
||||
painter.begin( &px );
|
||||
|
||||
@ -59,13 +59,13 @@ void QgsDecorationItem::update()
|
||||
void QgsDecorationItem::projectRead()
|
||||
{
|
||||
mEnabled = QgsProject::instance()->readBoolEntry( mConfigurationName, QStringLiteral( "/Enabled" ), false );
|
||||
mPlacement = static_cast< Placement >( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast< int >( mPlacement ) ) );
|
||||
mPlacement = static_cast<Placement>( QgsProject::instance()->readNumEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast<int>( mPlacement ) ) );
|
||||
mMarginUnit = QgsUnitTypes::decodeRenderUnit( QgsProject::instance()->readEntry( mConfigurationName, QStringLiteral( "/MarginUnit" ), QgsUnitTypes::encodeUnit( mMarginUnit ) ) );
|
||||
}
|
||||
|
||||
void QgsDecorationItem::saveToProject()
|
||||
{
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Enabled" ), mEnabled );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast< int >( mPlacement ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/Placement" ), static_cast<int>( mPlacement ) );
|
||||
QgsProject::instance()->writeEntry( mConfigurationName, QStringLiteral( "/MarginUnit" ), QgsUnitTypes::encodeUnit( mMarginUnit ) );
|
||||
}
|
||||
|
||||
@ -33,7 +33,6 @@ class APP_EXPORT QgsDecorationItem : public QObject, public QgsMapDecoration
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Item placements
|
||||
enum Placement
|
||||
{
|
||||
@ -79,7 +78,6 @@ class APP_EXPORT QgsDecorationItem : public QObject, public QgsMapDecoration
|
||||
void update();
|
||||
|
||||
protected:
|
||||
|
||||
//! True if decoration item has to be displayed
|
||||
bool mEnabled = false;
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ void QgsDecorationLayoutExtent::projectRead()
|
||||
elem = doc.documentElement();
|
||||
mSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( elem, rwContext ) );
|
||||
}
|
||||
if ( ! mSymbol )
|
||||
if ( !mSymbol )
|
||||
{
|
||||
mSymbol.reset( new QgsFillSymbol() );
|
||||
QgsSimpleLineSymbolLayer *layer = new QgsSimpleLineSymbolLayer( QColor( 0, 0, 0, 100 ), 0, Qt::DashLine );
|
||||
@ -128,12 +128,12 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe
|
||||
QTransform transform = m2p.transform();
|
||||
|
||||
// only loop through open layout designers
|
||||
const QSet< QgsLayoutDesignerDialog * > designers = QgisApp::instance()->layoutDesigners();
|
||||
const QSet<QgsLayoutDesignerDialog *> designers = QgisApp::instance()->layoutDesigners();
|
||||
|
||||
for ( QgsLayoutDesignerDialog *designer : designers )
|
||||
{
|
||||
QgsLayout *layout = designer->currentLayout();
|
||||
QList< QgsLayoutItemMap * > maps;
|
||||
QList<QgsLayoutItemMap *> maps;
|
||||
layout->layoutItems( maps );
|
||||
for ( const QgsLayoutItemMap *map : std::as_const( maps ) )
|
||||
{
|
||||
@ -141,12 +141,10 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe
|
||||
QPointF labelPoint = extent.at( 1 );
|
||||
QgsGeometry g = QgsGeometry::fromQPolygonF( extent );
|
||||
|
||||
if ( map->crs() !=
|
||||
mapSettings.destinationCrs() )
|
||||
if ( map->crs() != mapSettings.destinationCrs() )
|
||||
{
|
||||
// reproject extent
|
||||
QgsCoordinateTransform ct( map->crs(),
|
||||
mapSettings.destinationCrs(), QgsProject::instance() );
|
||||
QgsCoordinateTransform ct( map->crs(), mapSettings.destinationCrs(), QgsProject::instance() );
|
||||
g = g.densifyByCount( 20 );
|
||||
try
|
||||
{
|
||||
@ -165,8 +163,7 @@ void QgsDecorationLayoutExtent::render( const QgsMapSettings &mapSettings, QgsRe
|
||||
|
||||
if ( mLabelExtents )
|
||||
{
|
||||
QgsTextRenderer::drawText( labelPoint, ( map->mapRotation() - mapSettings.rotation() ) * M_PI / 180.0, Qgis::TextHorizontalAlignment::Right, QStringList() << tr( "%1: %2" ).arg( designer->masterLayout()->name(), map->displayName() ),
|
||||
context, mTextFormat );
|
||||
QgsTextRenderer::drawText( labelPoint, ( map->mapRotation() - mapSettings.rotation() ) * M_PI / 180.0, Qgis::TextHorizontalAlignment::Right, QStringList() << tr( "%1: %2" ).arg( designer->masterLayout()->name(), map->displayName() ), context, mTextFormat );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ class APP_EXPORT QgsDecorationLayoutExtent : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsDecorationLayoutExtent.
|
||||
*/
|
||||
@ -91,7 +90,7 @@ class APP_EXPORT QgsDecorationLayoutExtent : public QgsDecorationItem
|
||||
void render( const QgsMapSettings &mapSettings, QgsRenderContext &context ) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr< QgsFillSymbol > mSymbol;
|
||||
std::unique_ptr<QgsFillSymbol> mSymbol;
|
||||
QgsTextFormat mTextFormat;
|
||||
bool mLabelExtents = true;
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ void QgsDecorationLayoutExtentDialog::updateGuiElements()
|
||||
void QgsDecorationLayoutExtentDialog::updateDecoFromGui()
|
||||
{
|
||||
mDeco.setEnabled( grpEnable->isChecked() );
|
||||
mDeco.setSymbol( mSymbolButton->clonedSymbol< QgsFillSymbol >() );
|
||||
mDeco.setSymbol( mSymbolButton->clonedSymbol<QgsFillSymbol>() );
|
||||
mDeco.setTextFormat( mButtonFontStyle->textFormat() );
|
||||
mDeco.setLabelExtents( mCheckBoxLabelExtents->isChecked() );
|
||||
}
|
||||
|
||||
@ -47,7 +47,6 @@ class APP_EXPORT QgsDecorationLayoutExtentDialog : public QDialog, private Ui::Q
|
||||
|
||||
void updateGuiElements();
|
||||
void updateDecoFromGui();
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSDECORATIONLAYOUTEXTENTDIALOG_H
|
||||
|
||||
@ -153,7 +153,7 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
|
||||
{
|
||||
try
|
||||
{
|
||||
mRotationInt = QgsBearingUtils:: bearingTrueNorth( mapSettings.destinationCrs(), mapSettings.transformContext(), context.extent().center() );
|
||||
mRotationInt = QgsBearingUtils::bearingTrueNorth( mapSettings.destinationCrs(), mapSettings.transformContext(), context.extent().center() );
|
||||
}
|
||||
catch ( QgsException & )
|
||||
{
|
||||
@ -163,14 +163,8 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
|
||||
}
|
||||
|
||||
const double radiansDouble = mRotationInt * M_PI / 180.0;
|
||||
const int xShift = static_cast<int>( (
|
||||
( centerXDouble * std::cos( radiansDouble ) ) +
|
||||
( centerYDouble * std::sin( radiansDouble ) )
|
||||
) - centerXDouble );
|
||||
const int yShift = static_cast<int>( (
|
||||
( -centerXDouble * std::sin( radiansDouble ) ) +
|
||||
( centerYDouble * std::cos( radiansDouble ) )
|
||||
) - centerYDouble );
|
||||
const int xShift = static_cast<int>( ( ( centerXDouble * std::cos( radiansDouble ) ) + ( centerYDouble * std::sin( radiansDouble ) ) ) - centerXDouble );
|
||||
const int yShift = static_cast<int>( ( ( -centerXDouble * std::sin( radiansDouble ) ) + ( centerYDouble * std::cos( radiansDouble ) ) ) - centerYDouble );
|
||||
// need width/height of paint device
|
||||
QPaintDevice *device = context.painter()->device();
|
||||
const float deviceHeight = static_cast<float>( device->height() ) / context.devicePixelRatio();
|
||||
@ -219,15 +213,13 @@ void QgsDecorationNorthArrow::render( const QgsMapSettings &mapSettings, QgsRend
|
||||
context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2, yOffset );
|
||||
break;
|
||||
case BottomRight:
|
||||
context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2,
|
||||
deviceHeight - yOffset - maxLength + ( maxLength - size.height() ) / 2 );
|
||||
context.painter()->translate( deviceWidth - xOffset - maxLength + ( maxLength - size.width() ) / 2, deviceHeight - yOffset - maxLength + ( maxLength - size.height() ) / 2 );
|
||||
break;
|
||||
case TopCenter:
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, yOffset );
|
||||
break;
|
||||
case BottomCenter:
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset,
|
||||
deviceHeight - yOffset - size.height() );
|
||||
context.painter()->translate( deviceWidth / 2 - size.width() / 2 + xOffset, deviceHeight - yOffset - size.height() );
|
||||
break;
|
||||
default:
|
||||
QgsDebugError( QStringLiteral( "Unsupported placement index of %1" ).arg( static_cast<int>( mPlacement ) ) );
|
||||
|
||||
@ -29,12 +29,11 @@ class QAction;
|
||||
class QToolBar;
|
||||
class QPainter;
|
||||
|
||||
class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem
|
||||
class APP_EXPORT QgsDecorationNorthArrow : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsDecorationNorthArrow, with the specified \a parent object.
|
||||
*/
|
||||
@ -55,7 +54,6 @@ class APP_EXPORT QgsDecorationNorthArrow: public QgsDecorationItem
|
||||
QString svgPath();
|
||||
|
||||
private:
|
||||
|
||||
// static const double DEG2RAD;
|
||||
static const double TOL;
|
||||
|
||||
|
||||
@ -52,12 +52,11 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
|
||||
spinAngle->setEnabled( !mDeco.mAutomatic );
|
||||
sliderRotation->setEnabled( !mDeco.mAutomatic );
|
||||
|
||||
connect( cboxAutomatic, &QAbstractButton::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
connect( cboxAutomatic, &QAbstractButton::toggled, this, [=]( bool checked ) {
|
||||
spinAngle->setEnabled( !checked );
|
||||
sliderRotation->setEnabled( !checked );
|
||||
} );
|
||||
connect( spinAngle, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsDecorationNorthArrowDialog::spinAngle_valueChanged );
|
||||
connect( spinAngle, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsDecorationNorthArrowDialog::spinAngle_valueChanged );
|
||||
connect( sliderRotation, &QSlider::valueChanged, this, &QgsDecorationNorthArrowDialog::sliderRotation_valueChanged );
|
||||
|
||||
// placement
|
||||
@ -67,8 +66,7 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
|
||||
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
|
||||
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
|
||||
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
spinHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 );
|
||||
} );
|
||||
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
|
||||
@ -77,11 +75,11 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
|
||||
spinHorizontal->setValue( mDeco.mMarginHorizontal );
|
||||
spinVertical->setValue( mDeco.mMarginVertical );
|
||||
wgtUnitSelection->setUnits(
|
||||
{
|
||||
Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
} );
|
||||
{ Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
}
|
||||
);
|
||||
wgtUnitSelection->setUnit( mDeco.mMarginUnit );
|
||||
|
||||
// enabled
|
||||
@ -89,8 +87,7 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
|
||||
|
||||
mSvgPathLineEdit->setText( mDeco.mSvgPath );
|
||||
connect( mSvgPathLineEdit, &QLineEdit::textChanged, this, &QgsDecorationNorthArrowDialog::updateSvgPath );
|
||||
connect( mSvgSelectorBtn, &QPushButton::clicked, this, [ = ]
|
||||
{
|
||||
connect( mSvgSelectorBtn, &QPushButton::clicked, this, [=] {
|
||||
QgsSvgSelectorDialog svgDlg( this );
|
||||
svgDlg.setWindowTitle( tr( "Select SVG file" ) );
|
||||
svgDlg.svgSelector()->setSvgPath( mSvgPathLineEdit->text().trimmed() );
|
||||
@ -112,8 +109,8 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
|
||||
pbnChangeOutlineColor->setColor( mDeco.mOutlineColor );
|
||||
pbnChangeOutlineColor->setContext( QStringLiteral( "gui" ) );
|
||||
pbnChangeOutlineColor->setColorDialogTitle( tr( "Select North Arrow Outline Color" ) );
|
||||
connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawNorthArrow(); } );
|
||||
connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [ = ]( QColor ) { drawNorthArrow(); } );
|
||||
connect( pbnChangeColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawNorthArrow(); } );
|
||||
connect( pbnChangeOutlineColor, &QgsColorButton::colorChanged, this, [=]( QColor ) { drawNorthArrow(); } );
|
||||
|
||||
drawNorthArrow();
|
||||
}
|
||||
@ -153,7 +150,7 @@ void QgsDecorationNorthArrowDialog::apply()
|
||||
mDeco.mOutlineColor = pbnChangeOutlineColor->color();
|
||||
mDeco.mSize = spinSize->value();
|
||||
mDeco.mRotationInt = sliderRotation->value();
|
||||
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.setPlacement( static_cast<QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.mMarginUnit = wgtUnitSelection->unit();
|
||||
mDeco.setEnabled( grpEnable->isChecked() );
|
||||
mDeco.mAutomatic = cboxAutomatic->isChecked();
|
||||
@ -202,7 +199,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
|
||||
size.setHeight( maxLength * viewBox.height() / viewBox.width() );
|
||||
}
|
||||
|
||||
QPixmap myPainterPixmap( maxLength, maxLength );
|
||||
QPixmap myPainterPixmap( maxLength, maxLength );
|
||||
myPainterPixmap.fill( Qt::transparent );
|
||||
|
||||
QPainter myQPainter;
|
||||
@ -221,14 +218,8 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
|
||||
//work out how to shift the image so that it appears in the center of the canvas
|
||||
//(x cos a + y sin a - x, -x sin a + y cos a - y)
|
||||
const double myRadiansDouble = ( M_PI / 180 ) * rotation;
|
||||
const int xShift = static_cast<int>( (
|
||||
( centerXDouble * std::cos( myRadiansDouble ) ) +
|
||||
( centerYDouble * std::sin( myRadiansDouble ) )
|
||||
) - centerXDouble );
|
||||
const int yShift = static_cast<int>( (
|
||||
( -centerXDouble * std::sin( myRadiansDouble ) ) +
|
||||
( centerYDouble * std::cos( myRadiansDouble ) )
|
||||
) - centerYDouble );
|
||||
const int xShift = static_cast<int>( ( ( centerXDouble * std::cos( myRadiansDouble ) ) + ( centerYDouble * std::sin( myRadiansDouble ) ) ) - centerXDouble );
|
||||
const int yShift = static_cast<int>( ( ( -centerXDouble * std::sin( myRadiansDouble ) ) + ( centerYDouble * std::cos( myRadiansDouble ) ) ) - centerYDouble );
|
||||
|
||||
//draw the pixmap in the proper position
|
||||
myQPainter.translate( xShift, yShift );
|
||||
@ -242,7 +233,7 @@ void QgsDecorationNorthArrowDialog::drawNorthArrow()
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap myPainterPixmap( 200, 200 );
|
||||
QPixmap myPainterPixmap( 200, 200 );
|
||||
myPainterPixmap.fill( Qt::transparent );
|
||||
QPainter myQPainter;
|
||||
myQPainter.begin( &myPainterPixmap );
|
||||
|
||||
@ -40,7 +40,7 @@ QgsDecorationOverlay::QgsDecorationOverlay( QWidget *parent )
|
||||
|
||||
void QgsDecorationOverlay::paintEvent( QPaintEvent * )
|
||||
{
|
||||
const QList< QgsMapDecoration * > decorations = QgisApp::instance()->activeDecorations();
|
||||
const QList<QgsMapDecoration *> decorations = QgisApp::instance()->activeDecorations();
|
||||
if ( decorations.empty() )
|
||||
return;
|
||||
|
||||
|
||||
@ -151,19 +151,19 @@ void QgsDecorationScaleBar::setupScaleBar()
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
std::unique_ptr< QgsTicksScaleBarRenderer > tickStyle = std::make_unique< QgsTicksScaleBarRenderer >();
|
||||
std::unique_ptr<QgsTicksScaleBarRenderer> tickStyle = std::make_unique<QgsTicksScaleBarRenderer>();
|
||||
tickStyle->setTickPosition( mStyleIndex == 0 ? QgsTicksScaleBarRenderer::TicksDown : QgsTicksScaleBarRenderer::TicksUp );
|
||||
mStyle = std::move( tickStyle );
|
||||
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr<QgsFillSymbol> fillSymbol = std::make_unique<QgsFillSymbol>();
|
||||
fillSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) )
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast<QgsSimpleFillSymbolLayer *>( fillSymbol->symbolLayer( 0 ) ) )
|
||||
{
|
||||
fill->setStrokeStyle( Qt::NoPen );
|
||||
}
|
||||
mSettings.setFillSymbol( fillSymbol.release() );
|
||||
|
||||
std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >();
|
||||
std::unique_ptr<QgsLineSymbol> lineSymbol = std::make_unique<QgsLineSymbol>();
|
||||
lineSymbol->setColor( mColor ); // Compatibility with pre 3.2 configuration
|
||||
lineSymbol->setWidth( 0.3 );
|
||||
lineSymbol->setOutputUnit( Qgis::RenderUnit::Millimeters );
|
||||
@ -175,27 +175,27 @@ void QgsDecorationScaleBar::setupScaleBar()
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
mStyle = std::make_unique< QgsSingleBoxScaleBarRenderer >();
|
||||
mStyle = std::make_unique<QgsSingleBoxScaleBarRenderer>();
|
||||
|
||||
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr<QgsFillSymbol> fillSymbol = std::make_unique<QgsFillSymbol>();
|
||||
fillSymbol->setColor( mColor );
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol->symbolLayer( 0 ) ) )
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast<QgsSimpleFillSymbolLayer *>( fillSymbol->symbolLayer( 0 ) ) )
|
||||
{
|
||||
fill->setStrokeStyle( Qt::NoPen );
|
||||
}
|
||||
mSettings.setFillSymbol( fillSymbol.release() );
|
||||
|
||||
std::unique_ptr< QgsFillSymbol > fillSymbol2 = std::make_unique< QgsFillSymbol >();
|
||||
std::unique_ptr<QgsFillSymbol> fillSymbol2 = std::make_unique<QgsFillSymbol>();
|
||||
fillSymbol2->setColor( QColor( 255, 255, 255, 0 ) );
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast< QgsSimpleFillSymbolLayer * >( fillSymbol2->symbolLayer( 0 ) ) )
|
||||
if ( QgsSimpleFillSymbolLayer *fill = dynamic_cast<QgsSimpleFillSymbolLayer *>( fillSymbol2->symbolLayer( 0 ) ) )
|
||||
{
|
||||
fill->setStrokeStyle( Qt::NoPen );
|
||||
}
|
||||
mSettings.setAlternateFillSymbol( fillSymbol2.release() );
|
||||
|
||||
mSettings.setHeight( mStyleIndex == 2 ? 1 : 3 );
|
||||
std::unique_ptr< QgsLineSymbol > lineSymbol = std::make_unique< QgsLineSymbol >();
|
||||
std::unique_ptr<QgsLineSymbol> lineSymbol = std::make_unique<QgsLineSymbol>();
|
||||
lineSymbol->setColor( mOutlineColor ); // Compatibility with pre 3.2 configuration
|
||||
lineSymbol->setWidth( mStyleIndex == 2 ? 0.2 : 0.3 );
|
||||
lineSymbol->setOutputUnit( Qgis::RenderUnit::Millimeters );
|
||||
@ -229,8 +229,7 @@ double QgsDecorationScaleBar::mapWidth( const QgsMapSettings &settings ) const
|
||||
double measure = 0;
|
||||
try
|
||||
{
|
||||
measure = da.measureLine( QgsPointXY( mapExtent.xMinimum(), yPosition ),
|
||||
QgsPointXY( mapExtent.xMaximum(), yPosition ) );
|
||||
measure = da.measureLine( QgsPointXY( mapExtent.xMinimum(), yPosition ), QgsPointXY( mapExtent.xMaximum(), yPosition ) );
|
||||
}
|
||||
catch ( QgsCsException & )
|
||||
{
|
||||
@ -271,7 +270,7 @@ void QgsDecorationScaleBar::render( const QgsMapSettings &mapSettings, QgsRender
|
||||
//If scale bar is very small reset to 1/4 of the canvas wide
|
||||
if ( scaleBarWidth < 30 )
|
||||
{
|
||||
scaleBarWidth = deviceWidth / 4.0; // value in pixels
|
||||
scaleBarWidth = deviceWidth / 4.0; // value in pixels
|
||||
unitsPerSegment = scaleBarWidth * scaleBarUnitsPerPixel; // value in map units
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class QPainter;
|
||||
#include <QColor>
|
||||
#include "qgis_app.h"
|
||||
|
||||
class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem
|
||||
class APP_EXPORT QgsDecorationScaleBar : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -51,7 +51,6 @@ class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem
|
||||
void setupScaleBar();
|
||||
|
||||
private:
|
||||
|
||||
//! The size preferred size of the scale bar
|
||||
int mPreferredSize;
|
||||
//! Should we snap to integer times power of 10?
|
||||
@ -70,7 +69,7 @@ class APP_EXPORT QgsDecorationScaleBar: public QgsDecorationItem
|
||||
QgsScaleBarSettings mSettings;
|
||||
|
||||
//! Scalebar style
|
||||
std::unique_ptr< QgsScaleBarRenderer > mStyle;
|
||||
std::unique_ptr<QgsScaleBarRenderer> mStyle;
|
||||
|
||||
//! Margin percentage values
|
||||
int mMarginHorizontal = 0;
|
||||
|
||||
@ -64,8 +64,7 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
|
||||
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
|
||||
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
|
||||
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 );
|
||||
} );
|
||||
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
|
||||
@ -74,11 +73,11 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
|
||||
spnHorizontal->setValue( mDeco.mMarginHorizontal );
|
||||
spnVertical->setValue( mDeco.mMarginVertical );
|
||||
wgtUnitSelection->setUnits(
|
||||
{
|
||||
Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
} );
|
||||
{ Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
}
|
||||
);
|
||||
wgtUnitSelection->setUnit( mDeco.mMarginUnit );
|
||||
|
||||
grpEnable->setChecked( mDeco.enabled() );
|
||||
@ -110,7 +109,7 @@ void QgsDecorationScaleBarDialog::showHelp()
|
||||
|
||||
void QgsDecorationScaleBarDialog::apply()
|
||||
{
|
||||
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.setPlacement( static_cast<QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.mMarginUnit = wgtUnitSelection->unit();
|
||||
mDeco.mMarginHorizontal = spnHorizontal->value();
|
||||
mDeco.mMarginVertical = spnVertical->value();
|
||||
|
||||
@ -219,4 +219,3 @@ void QgsDecorationTitle::render( const QgsMapSettings &mapSettings, QgsRenderCon
|
||||
// Paint label to canvas
|
||||
QgsTextRenderer::drawText( QPointF( xOffset, yOffset ), 0.0, horizontalAlignment, displayStringList, context, mTextFormat );
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ class APP_EXPORT QgsDecorationTitle : public QgsDecorationItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
QgsDecorationTitle( QObject *parent = nullptr );
|
||||
|
||||
|
||||
@ -74,8 +74,7 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW
|
||||
cboPlacement->addItem( tr( "Bottom Left" ), QgsDecorationItem::BottomLeft );
|
||||
cboPlacement->addItem( tr( "Bottom Center" ), QgsDecorationItem::BottomCenter );
|
||||
cboPlacement->addItem( tr( "Bottom Right" ), QgsDecorationItem::BottomRight );
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( cboPlacement, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
spnHorizontal->setMinimum( cboPlacement->currentData() == QgsDecorationItem::TopCenter || cboPlacement->currentData() == QgsDecorationItem::BottomCenter ? -100 : 0 );
|
||||
} );
|
||||
cboPlacement->setCurrentIndex( cboPlacement->findData( mDeco.placement() ) );
|
||||
@ -84,11 +83,11 @@ QgsDecorationTitleDialog::QgsDecorationTitleDialog( QgsDecorationTitle &deco, QW
|
||||
spnHorizontal->setValue( mDeco.mMarginHorizontal );
|
||||
spnVertical->setValue( mDeco.mMarginVertical );
|
||||
wgtUnitSelection->setUnits(
|
||||
{
|
||||
Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
} );
|
||||
{ Qgis::RenderUnit::Millimeters,
|
||||
Qgis::RenderUnit::Percentage,
|
||||
Qgis::RenderUnit::Pixels
|
||||
}
|
||||
);
|
||||
wgtUnitSelection->setUnit( mDeco.mMarginUnit );
|
||||
|
||||
// font settings
|
||||
@ -129,7 +128,7 @@ void QgsDecorationTitleDialog::apply()
|
||||
mDeco.setTextFormat( mButtonFontStyle->textFormat() );
|
||||
mDeco.mLabelText = txtTitleText->toPlainText();
|
||||
mDeco.mBackgroundColor = pbnBackgroundColor->color();
|
||||
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.setPlacement( static_cast<QgsDecorationItem::Placement>( cboPlacement->currentData().toInt() ) );
|
||||
mDeco.mMarginUnit = wgtUnitSelection->unit();
|
||||
mDeco.mMarginHorizontal = spnHorizontal->value();
|
||||
mDeco.mMarginVertical = spnVertical->value();
|
||||
|
||||
@ -45,9 +45,9 @@ QgsDocumentationPanelWidget::QgsDocumentationPanelWidget( QWidget *parent )
|
||||
|
||||
mWebViewContainer->layout()->addWidget( mWebView );
|
||||
|
||||
connect( mActionPyQgis, &QAction::triggered, this, [] {QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::PyQgis, Qgis::DocumentationBrowser::DeveloperToolsPanel );} );
|
||||
connect( mActionQt, &QAction::triggered, this, [] {QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::Qt, Qgis::DocumentationBrowser::DeveloperToolsPanel );} );
|
||||
connect( mActionOpenInBrowser, &QAction::triggered, this, [this] {QgisApp::instance()->openURL( mWebView->url().toString(), false );} );
|
||||
connect( mActionPyQgis, &QAction::triggered, this, [] { QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::PyQgis, Qgis::DocumentationBrowser::DeveloperToolsPanel ); } );
|
||||
connect( mActionQt, &QAction::triggered, this, [] { QgisApp::instance()->showApiDocumentation( Qgis::DocumentationApi::Qt, Qgis::DocumentationBrowser::DeveloperToolsPanel ); } );
|
||||
connect( mActionOpenInBrowser, &QAction::triggered, this, [this] { QgisApp::instance()->openURL( mWebView->url().toString(), false ); } );
|
||||
}
|
||||
|
||||
void QgsDocumentationPanelWidget::showUrl( const QUrl &url )
|
||||
|
||||
@ -37,7 +37,6 @@ class QgsDocumentationPanelWidget : public QgsDevToolWidget, private Ui::QgsDocu
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsDocumentationPanelWidget.
|
||||
*/
|
||||
@ -47,14 +46,11 @@ class QgsDocumentationPanelWidget : public QgsDevToolWidget, private Ui::QgsDocu
|
||||
void showUrl( const QUrl &url );
|
||||
|
||||
private:
|
||||
|
||||
#ifdef HAVE_WEBENGINE
|
||||
QWebEngineView *mWebView = nullptr;
|
||||
#else
|
||||
QgsWebView *mWebView = nullptr;
|
||||
#endif
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
QgsNetworkLogger::QgsNetworkLogger( QgsNetworkAccessManager *manager, QObject *parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, mNam( manager )
|
||||
, mRootNode( std::make_unique< QgsNetworkLoggerRootNode >() )
|
||||
, mRootNode( std::make_unique<QgsNetworkLoggerRootNode>() )
|
||||
{
|
||||
// logger must be created on the main thread
|
||||
Q_ASSERT( QThread::currentThread() == QApplication::instance()->thread() );
|
||||
@ -46,19 +46,19 @@ void QgsNetworkLogger::enableLogging( bool enabled )
|
||||
{
|
||||
if ( enabled )
|
||||
{
|
||||
connect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload< const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload<QgsNetworkRequestParameters>( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload<const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload<QgsNetworkReplyContent>( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished, Qt::UniqueConnection );
|
||||
connect( mNam, qOverload<QgsNetworkRequestParameters>( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut, Qt::UniqueConnection );
|
||||
connect( mNam, &QgsNetworkAccessManager::downloadProgress, this, &QgsNetworkLogger::downloadProgress, Qt::UniqueConnection );
|
||||
connect( mNam, &QgsNetworkAccessManager::requestEncounteredSslErrors, this, &QgsNetworkLogger::requestEncounteredSslErrors, Qt::UniqueConnection );
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated );
|
||||
disconnect( mNam, qOverload< const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated );
|
||||
disconnect( mNam, qOverload< QgsNetworkReplyContent >( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished );
|
||||
disconnect( mNam, qOverload< QgsNetworkRequestParameters >( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut );
|
||||
disconnect( mNam, qOverload<QgsNetworkRequestParameters>( &QgsNetworkAccessManager::requestAboutToBeCreated ), this, &QgsNetworkLogger::requestAboutToBeCreated );
|
||||
disconnect( mNam, qOverload<const QgsNetworkRequestParameters &>( &QgsNetworkAccessManager::requestCreated ), this, &QgsNetworkLogger::requestCreated );
|
||||
disconnect( mNam, qOverload<QgsNetworkReplyContent>( &QgsNetworkAccessManager::finished ), this, &QgsNetworkLogger::requestFinished );
|
||||
disconnect( mNam, qOverload<QgsNetworkRequestParameters>( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsNetworkLogger::requestTimedOut );
|
||||
disconnect( mNam, &QgsNetworkAccessManager::downloadProgress, this, &QgsNetworkLogger::downloadProgress );
|
||||
disconnect( mNam, &QgsNetworkAccessManager::requestEncounteredSslErrors, this, &QgsNetworkLogger::requestEncounteredSslErrors );
|
||||
}
|
||||
@ -79,7 +79,7 @@ void QgsNetworkLogger::requestAboutToBeCreated( QgsNetworkRequestParameters para
|
||||
|
||||
beginInsertRows( QModelIndex(), childCount, childCount );
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerRequestGroup > group = std::make_unique< QgsNetworkLoggerRequestGroup >( parameters );
|
||||
std::unique_ptr<QgsNetworkLoggerRequestGroup> group = std::make_unique<QgsNetworkLoggerRequestGroup>( parameters );
|
||||
mRequestGroups.insert( parameters.requestId(), group.get() );
|
||||
mRootNode->addChild( std::move( group ) );
|
||||
endInsertRows();
|
||||
@ -145,7 +145,7 @@ void QgsNetworkLogger::downloadProgress( int requestId, qint64 bytesReceived, qi
|
||||
|
||||
requestGroup->setProgress( bytesReceived, bytesTotal );
|
||||
|
||||
emit dataChanged( requestIndex, requestIndex, QVector<int >() << Qt::ToolTipRole );
|
||||
emit dataChanged( requestIndex, requestIndex, QVector<int>() << Qt::ToolTipRole );
|
||||
}
|
||||
|
||||
void QgsNetworkLogger::requestEncounteredSslErrors( int requestId, const QList<QSslError> &errors )
|
||||
@ -177,7 +177,7 @@ QList<QAction *> QgsNetworkLogger::actions( const QModelIndex &index, QObject *p
|
||||
{
|
||||
QgsDevToolsModelNode *node = index2node( index );
|
||||
if ( !node )
|
||||
return QList< QAction * >();
|
||||
return QList<QAction *>();
|
||||
|
||||
return node->actions( parent );
|
||||
}
|
||||
@ -200,7 +200,7 @@ QModelIndex QgsNetworkLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode *
|
||||
|
||||
QgsDevToolsModelGroup *grandParentNode = parentNode->parent();
|
||||
if ( !grandParentNode )
|
||||
return QModelIndex(); // root node -> invalid index
|
||||
return QModelIndex(); // root node -> invalid index
|
||||
|
||||
int row = grandParentNode->indexOf( parentNode );
|
||||
Q_ASSERT( row >= 0 );
|
||||
@ -210,8 +210,8 @@ QModelIndex QgsNetworkLogger::indexOfParentLayerTreeNode( QgsDevToolsModelNode *
|
||||
|
||||
void QgsNetworkLogger::removeRequestRows( const QList<int> &rows )
|
||||
{
|
||||
QList< int > res = rows;
|
||||
std::sort( res.begin(), res.end(), std::greater< int >() );
|
||||
QList<int> res = rows;
|
||||
std::sort( res.begin(), res.end(), std::greater<int>() );
|
||||
|
||||
for ( int row : std::as_const( res ) )
|
||||
{
|
||||
@ -246,11 +246,10 @@ int QgsNetworkLogger::columnCount( const QModelIndex &parent ) const
|
||||
|
||||
QModelIndex QgsNetworkLogger::index( int row, int column, const QModelIndex &parent ) const
|
||||
{
|
||||
if ( column < 0 || column >= columnCount( parent ) ||
|
||||
row < 0 || row >= rowCount( parent ) )
|
||||
if ( column < 0 || column >= columnCount( parent ) || row < 0 || row >= rowCount( parent ) )
|
||||
return QModelIndex();
|
||||
|
||||
QgsDevToolsModelGroup *n = dynamic_cast< QgsDevToolsModelGroup * >( index2node( parent ) );
|
||||
QgsDevToolsModelGroup *n = dynamic_cast<QgsDevToolsModelGroup *>( index2node( parent ) );
|
||||
if ( !n )
|
||||
return QModelIndex(); // have no children
|
||||
|
||||
@ -343,7 +342,7 @@ void QgsNetworkLoggerProxyModel::setShowCached( bool show )
|
||||
bool QgsNetworkLoggerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
|
||||
{
|
||||
QgsDevToolsModelNode *node = mLogger->index2node( mLogger->index( source_row, 0, source_parent ) );
|
||||
if ( QgsNetworkLoggerRequestGroup *request = dynamic_cast< QgsNetworkLoggerRequestGroup * >( node ) )
|
||||
if ( QgsNetworkLoggerRequestGroup *request = dynamic_cast<QgsNetworkLoggerRequestGroup *>( node ) )
|
||||
{
|
||||
if ( ( request->status() == QgsNetworkLoggerRequestGroup::Status::Complete || request->status() == QgsNetworkLoggerRequestGroup::Status::Canceled )
|
||||
& !mShowSuccessful )
|
||||
|
||||
@ -38,7 +38,6 @@ class QgsNetworkLogger : public QAbstractItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLogger, logging requests from the specified \a manager.
|
||||
*
|
||||
@ -73,12 +72,12 @@ class QgsNetworkLogger : public QAbstractItemModel
|
||||
*
|
||||
* The actions should be parented to \a parent.
|
||||
*/
|
||||
QList< QAction * > actions( const QModelIndex &index, QObject *parent );
|
||||
QList<QAction *> actions( const QModelIndex &index, QObject *parent );
|
||||
|
||||
/**
|
||||
* Removes a list of request \a rows from the log.
|
||||
*/
|
||||
void removeRequestRows( const QList< int > &rows );
|
||||
void removeRequestRows( const QList<int> &rows );
|
||||
|
||||
/**
|
||||
* Returns the root node of the log.
|
||||
@ -108,7 +107,6 @@ class QgsNetworkLogger : public QAbstractItemModel
|
||||
void requestEncounteredSslErrors( int requestId, const QList<QSslError> &errors );
|
||||
|
||||
private:
|
||||
|
||||
//! Returns index for a given node
|
||||
QModelIndex node2index( QgsDevToolsModelNode *node ) const;
|
||||
QModelIndex indexOfParentLayerTreeNode( QgsDevToolsModelNode *parentNode ) const;
|
||||
@ -116,10 +114,9 @@ class QgsNetworkLogger : public QAbstractItemModel
|
||||
QgsNetworkAccessManager *mNam = nullptr;
|
||||
bool mIsLogging = false;
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerRootNode > mRootNode;
|
||||
|
||||
QHash< int, QgsNetworkLoggerRequestGroup * > mRequestGroups;
|
||||
std::unique_ptr<QgsNetworkLoggerRootNode> mRootNode;
|
||||
|
||||
QHash<int, QgsNetworkLoggerRequestGroup *> mRequestGroups;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -134,7 +131,6 @@ class QgsNetworkLoggerProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerProxyModel, filtering the specified network \a logger.
|
||||
*/
|
||||
@ -164,7 +160,6 @@ class QgsNetworkLoggerProxyModel : public QSortFilterProxyModel
|
||||
bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
|
||||
|
||||
private:
|
||||
|
||||
QgsNetworkLogger *mLogger = nullptr;
|
||||
|
||||
QString mFilterString;
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
QgsNetworkLoggerRootNode::QgsNetworkLoggerRootNode()
|
||||
: QgsDevToolsModelGroup( QString() )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QVariant QgsNetworkLoggerRootNode::data( int ) const
|
||||
@ -49,7 +48,7 @@ void QgsNetworkLoggerRootNode::removeRow( int row )
|
||||
QVariant QgsNetworkLoggerRootNode::toVariant() const
|
||||
{
|
||||
QVariantList res;
|
||||
for ( const std::unique_ptr< QgsDevToolsModelNode > &child : mChildren )
|
||||
for ( const std::unique_ptr<QgsDevToolsModelNode> &child : mChildren )
|
||||
res << child->toVariant();
|
||||
return res;
|
||||
}
|
||||
@ -73,8 +72,8 @@ QgsNetworkLoggerRequestGroup::QgsNetworkLoggerRequestGroup( const QgsNetworkRequ
|
||||
mHeaders.append( qMakePair( QString( header ), QString( request.request().rawHeader( header ) ) ) );
|
||||
}
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerRequestDetailsGroup > detailsGroup = std::make_unique< QgsNetworkLoggerRequestDetailsGroup >( request );
|
||||
mDetailsGroup = static_cast< QgsNetworkLoggerRequestDetailsGroup * >( addChild( std::move( detailsGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerRequestDetailsGroup> detailsGroup = std::make_unique<QgsNetworkLoggerRequestDetailsGroup>( request );
|
||||
mDetailsGroup = static_cast<QgsNetworkLoggerRequestDetailsGroup *>( addChild( std::move( detailsGroup ) ) );
|
||||
|
||||
mTimer.start();
|
||||
}
|
||||
@ -84,9 +83,7 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return QStringLiteral( "%1 %2 %3" ).arg( QString::number( mRequestId ),
|
||||
mOperation == QNetworkAccessManager::Operation::CustomOperation ? mVerb : operationToString( mOperation ),
|
||||
mUrl.url() );
|
||||
return QStringLiteral( "%1 %2 %3" ).arg( QString::number( mRequestId ), mOperation == QNetworkAccessManager::Operation::CustomOperation ? mVerb : operationToString( mOperation ), mUrl.url() );
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
{
|
||||
@ -101,17 +98,11 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const
|
||||
// ?? adding <br/> instead of \n after (very long) url seems to break url up
|
||||
// COMPLETE, Status: 200 - text/xml; charset=utf-8 - 2334 bytes - 657 milliseconds
|
||||
return QStringLiteral( "%1<br/>%2 - Status: %3 - %4 - %5 bytes - %6 msec - %7 replies" )
|
||||
.arg( mUrl.url(),
|
||||
statusToString( mStatus ),
|
||||
QString::number( mHttpStatus ),
|
||||
mContentType,
|
||||
bytes,
|
||||
mStatus == Status::Pending ? QString::number( mTimer.elapsed() / 1000 ) : QString::number( mTotalTime ),
|
||||
QString::number( mReplies ) );
|
||||
.arg( mUrl.url(), statusToString( mStatus ), QString::number( mHttpStatus ), mContentType, bytes, mStatus == Status::Pending ? QString::number( mTimer.elapsed() / 1000 ) : QString::number( mTotalTime ), QString::number( mReplies ) );
|
||||
}
|
||||
|
||||
case RoleStatus:
|
||||
return static_cast< int >( mStatus );
|
||||
return static_cast<int>( mStatus );
|
||||
|
||||
case RoleId:
|
||||
return mRequestId;
|
||||
@ -159,26 +150,23 @@ QVariant QgsNetworkLoggerRequestGroup::data( int role ) const
|
||||
|
||||
QList<QAction *> QgsNetworkLoggerRequestGroup::actions( QObject *parent )
|
||||
{
|
||||
QList< QAction * > res;
|
||||
QList<QAction *> res;
|
||||
QAction *openUrlAction = new QAction( QObject::tr( "Open URL" ), parent );
|
||||
QObject::connect( openUrlAction, &QAction::triggered, openUrlAction, [ = ]
|
||||
{
|
||||
QObject::connect( openUrlAction, &QAction::triggered, openUrlAction, [=] {
|
||||
QDesktopServices::openUrl( mUrl );
|
||||
} );
|
||||
res << openUrlAction;
|
||||
|
||||
QAction *copyUrlAction = new QAction( QObject::tr( "Copy URL" ), parent );
|
||||
QObject::connect( copyUrlAction, &QAction::triggered, openUrlAction, [ = ]
|
||||
{
|
||||
QObject::connect( copyUrlAction, &QAction::triggered, openUrlAction, [=] {
|
||||
QApplication::clipboard()->setText( mUrl.url() );
|
||||
} );
|
||||
res << copyUrlAction;
|
||||
|
||||
QAction *copyAsCurlAction = new QAction( QObject::tr( "Copy As cURL" ), parent );
|
||||
QObject::connect( copyAsCurlAction, &QAction::triggered, copyAsCurlAction, [ = ]
|
||||
{
|
||||
QObject::connect( copyAsCurlAction, &QAction::triggered, copyAsCurlAction, [=] {
|
||||
QString curlHeaders;
|
||||
for ( const QPair< QString, QString > &header : std::as_const( mHeaders ) )
|
||||
for ( const QPair<QString, QString> &header : std::as_const( mHeaders ) )
|
||||
curlHeaders += QStringLiteral( "-H '%1: %2' " ).arg( header.first, header.second );
|
||||
|
||||
switch ( mOperation )
|
||||
@ -217,21 +205,16 @@ QList<QAction *> QgsNetworkLoggerRequestGroup::actions( QObject *parent )
|
||||
|| ( mOperation == QNetworkAccessManager::CustomOperation && !mData.isEmpty() ) )
|
||||
curlData = QStringLiteral( "--data '%1' " ).arg( QString( mData ) );
|
||||
|
||||
QString curlCmd = QStringLiteral( "curl '%1' %2 %3--compressed" ).arg(
|
||||
mUrl.url(),
|
||||
curlHeaders,
|
||||
curlData );
|
||||
QString curlCmd = QStringLiteral( "curl '%1' %2 %3--compressed" ).arg( mUrl.url(), curlHeaders, curlData );
|
||||
QApplication::clipboard()->setText( curlCmd );
|
||||
} );
|
||||
res << copyAsCurlAction;
|
||||
|
||||
QAction *copyJsonAction = new QAction( QObject::tr( "Copy as JSON" ), parent );
|
||||
QObject::connect( copyJsonAction, &QAction::triggered, openUrlAction, [ = ]
|
||||
{
|
||||
QObject::connect( copyJsonAction, &QAction::triggered, openUrlAction, [=] {
|
||||
const QVariant value = toVariant();
|
||||
const QString json = QString::fromStdString( QgsJsonUtils::jsonFromVariant( value ).dump( 2 ) );
|
||||
QApplication::clipboard()->setText( json );
|
||||
|
||||
} );
|
||||
res << copyJsonAction;
|
||||
|
||||
@ -290,8 +273,8 @@ void QgsNetworkLoggerRequestGroup::setReply( const QgsNetworkReplyContent &reply
|
||||
mContentType = reply.rawHeader( "Content - Type" );
|
||||
mReplyFromCache = reply.attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool();
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerReplyGroup > replyGroup = std::make_unique< QgsNetworkLoggerReplyGroup >( reply ) ;
|
||||
mReplyGroup = static_cast< QgsNetworkLoggerReplyGroup * >( addChild( std::move( replyGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerReplyGroup> replyGroup = std::make_unique<QgsNetworkLoggerReplyGroup>( reply );
|
||||
mReplyGroup = static_cast<QgsNetworkLoggerReplyGroup *>( addChild( std::move( replyGroup ) ) );
|
||||
}
|
||||
|
||||
void QgsNetworkLoggerRequestGroup::setTimedOut()
|
||||
@ -311,8 +294,8 @@ void QgsNetworkLoggerRequestGroup::setSslErrors( const QList<QSslError> &errors
|
||||
mHasSslErrors = !errors.empty();
|
||||
if ( mHasSslErrors )
|
||||
{
|
||||
std::unique_ptr< QgsNetworkLoggerSslErrorGroup > errorGroup = std::make_unique< QgsNetworkLoggerSslErrorGroup >( errors );
|
||||
mSslErrorsGroup = static_cast< QgsNetworkLoggerSslErrorGroup * >( addChild( std::move( errorGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerSslErrorGroup> errorGroup = std::make_unique<QgsNetworkLoggerSslErrorGroup>( errors );
|
||||
mSslErrorsGroup = static_cast<QgsNetworkLoggerSslErrorGroup *>( addChild( std::move( errorGroup ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,24 +363,22 @@ QString QgsNetworkLoggerRequestGroup::cacheControlToString( QNetworkRequest::Cac
|
||||
QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const QgsNetworkRequestParameters &request )
|
||||
: QgsDevToolsModelGroup( QObject::tr( "Request" ) )
|
||||
{
|
||||
addKeyValueNode( QObject::tr( "Operation" ), request.operation() == QNetworkAccessManager::Operation::CustomOperation
|
||||
? request.request().attribute( QNetworkRequest::CustomVerbAttribute ).toString()
|
||||
: QgsNetworkLoggerRequestGroup::operationToString( request.operation() ) );
|
||||
addKeyValueNode( QObject::tr( "Operation" ), request.operation() == QNetworkAccessManager::Operation::CustomOperation ? request.request().attribute( QNetworkRequest::CustomVerbAttribute ).toString() : QgsNetworkLoggerRequestGroup::operationToString( request.operation() ) );
|
||||
addKeyValueNode( QObject::tr( "Thread" ), request.originatingThreadId() );
|
||||
addKeyValueNode( QObject::tr( "Initiator" ), request.initiatorClassName().isEmpty() ? QObject::tr( "unknown" ) : request.initiatorClassName() );
|
||||
if ( request.initiatorRequestId().isValid() )
|
||||
addKeyValueNode( QObject::tr( "ID" ), request.initiatorRequestId().toString() );
|
||||
addKeyValueNode( QObject::tr( "Cache (control)" ), QgsNetworkLoggerRequestGroup::cacheControlToString( static_cast< QNetworkRequest::CacheLoadControl >( request.request().attribute( QNetworkRequest::CacheLoadControlAttribute ).toInt() ) ) );
|
||||
addKeyValueNode( QObject::tr( "Cache (control)" ), QgsNetworkLoggerRequestGroup::cacheControlToString( static_cast<QNetworkRequest::CacheLoadControl>( request.request().attribute( QNetworkRequest::CacheLoadControlAttribute ).toInt() ) ) );
|
||||
addKeyValueNode( QObject::tr( "Cache (save)" ), request.request().attribute( QNetworkRequest::CacheSaveControlAttribute ).toBool() ? QObject::tr( "Can store result in cache" ) : QObject::tr( "Result cannot be stored in cache" ) );
|
||||
|
||||
if ( !QUrlQuery( request.request().url() ).queryItems().isEmpty() )
|
||||
{
|
||||
std::unique_ptr< QgsNetworkLoggerRequestQueryGroup > queryGroup = std::make_unique< QgsNetworkLoggerRequestQueryGroup >( request.request().url() );
|
||||
mQueryGroup = static_cast< QgsNetworkLoggerRequestQueryGroup * >( addChild( std::move( queryGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerRequestQueryGroup> queryGroup = std::make_unique<QgsNetworkLoggerRequestQueryGroup>( request.request().url() );
|
||||
mQueryGroup = static_cast<QgsNetworkLoggerRequestQueryGroup *>( addChild( std::move( queryGroup ) ) );
|
||||
}
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerRequestHeadersGroup > requestHeadersGroup = std::make_unique< QgsNetworkLoggerRequestHeadersGroup >( request );
|
||||
mRequestHeaders = static_cast< QgsNetworkLoggerRequestHeadersGroup * >( addChild( std::move( requestHeadersGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerRequestHeadersGroup> requestHeadersGroup = std::make_unique<QgsNetworkLoggerRequestHeadersGroup>( request );
|
||||
mRequestHeaders = static_cast<QgsNetworkLoggerRequestHeadersGroup *>( addChild( std::move( requestHeadersGroup ) ) );
|
||||
|
||||
switch ( request.operation() )
|
||||
{
|
||||
@ -408,8 +389,8 @@ QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const
|
||||
case QNetworkAccessManager::PostOperation:
|
||||
case QNetworkAccessManager::PutOperation:
|
||||
{
|
||||
std::unique_ptr< QgsNetworkLoggerPostContentGroup > postContentGroup = std::make_unique< QgsNetworkLoggerPostContentGroup >( request );
|
||||
mPostContent = static_cast< QgsNetworkLoggerPostContentGroup * >( addChild( std::move( postContentGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerPostContentGroup> postContentGroup = std::make_unique<QgsNetworkLoggerPostContentGroup>( request );
|
||||
mPostContent = static_cast<QgsNetworkLoggerPostContentGroup *>( addChild( std::move( postContentGroup ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -419,8 +400,8 @@ QgsNetworkLoggerRequestDetailsGroup::QgsNetworkLoggerRequestDetailsGroup( const
|
||||
{
|
||||
if ( !request.content().isEmpty() )
|
||||
{
|
||||
std::unique_ptr< QgsNetworkLoggerPostContentGroup > postContentGroup = std::make_unique< QgsNetworkLoggerPostContentGroup >( request );
|
||||
mPostContent = static_cast< QgsNetworkLoggerPostContentGroup * >( addChild( std::move( postContentGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerPostContentGroup> postContentGroup = std::make_unique<QgsNetworkLoggerPostContentGroup>( request );
|
||||
mPostContent = static_cast<QgsNetworkLoggerPostContentGroup *>( addChild( std::move( postContentGroup ) ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -448,9 +429,9 @@ QgsNetworkLoggerRequestQueryGroup::QgsNetworkLoggerRequestQueryGroup( const QUrl
|
||||
: QgsDevToolsModelGroup( QObject::tr( "Query" ) )
|
||||
{
|
||||
QUrlQuery query( url );
|
||||
const QList<QPair<QString, QString> > queryItems = query.queryItems();
|
||||
const QList<QPair<QString, QString>> queryItems = query.queryItems();
|
||||
|
||||
for ( const QPair< QString, QString > &query : queryItems )
|
||||
for ( const QPair<QString, QString> &query : queryItems )
|
||||
{
|
||||
addKeyValueNode( query.first, query.second );
|
||||
}
|
||||
@ -491,13 +472,13 @@ QgsNetworkLoggerReplyGroup::QgsNetworkLoggerReplyGroup( const QgsNetworkReplyCon
|
||||
addKeyValueNode( QObject::tr( "Status" ), reply.attribute( QNetworkRequest::HttpStatusCodeAttribute ).toString() );
|
||||
if ( reply.error() != QNetworkReply::NoError )
|
||||
{
|
||||
addKeyValueNode( QObject::tr( "Error Code" ), QString::number( static_cast< int >( reply.error() ) ) );
|
||||
addKeyValueNode( QObject::tr( "Error Code" ), QString::number( static_cast<int>( reply.error() ) ) );
|
||||
addKeyValueNode( QObject::tr( "Error" ), reply.errorString() );
|
||||
}
|
||||
addKeyValueNode( QObject::tr( "Cache (result)" ), reply.attribute( QNetworkRequest::SourceIsFromCacheAttribute ).toBool() ? QObject::tr( "Used entry from cache" ) : QObject::tr( "Read from network" ) );
|
||||
|
||||
std::unique_ptr< QgsNetworkLoggerReplyHeadersGroup > headersGroup = std::make_unique< QgsNetworkLoggerReplyHeadersGroup >( reply );
|
||||
mReplyHeaders = static_cast< QgsNetworkLoggerReplyHeadersGroup * >( addChild( std::move( headersGroup ) ) );
|
||||
std::unique_ptr<QgsNetworkLoggerReplyHeadersGroup> headersGroup = std::make_unique<QgsNetworkLoggerReplyHeadersGroup>( reply );
|
||||
mReplyHeaders = static_cast<QgsNetworkLoggerReplyHeadersGroup *>( addChild( std::move( headersGroup ) ) );
|
||||
}
|
||||
|
||||
QVariant QgsNetworkLoggerReplyGroup::toVariant() const
|
||||
|
||||
@ -36,7 +36,6 @@ class QAction;
|
||||
class QgsNetworkLoggerRootNode final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
QgsNetworkLoggerRootNode();
|
||||
QVariant data( int role = Qt::DisplayRole ) const override final;
|
||||
|
||||
@ -81,14 +80,13 @@ class QgsNetworkLoggerSslErrorGroup;
|
||||
class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
//! Request statu
|
||||
enum class Status
|
||||
{
|
||||
Pending, //!< Request underway
|
||||
Pending, //!< Request underway
|
||||
Complete, //!< Request was successfully completed
|
||||
Error, //!< Request encountered an error
|
||||
TimeOut, //!< Request timed out
|
||||
Error, //!< Request encountered an error
|
||||
TimeOut, //!< Request timed out
|
||||
Canceled, //!< Request was manually canceled
|
||||
};
|
||||
|
||||
@ -98,7 +96,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup
|
||||
*/
|
||||
QgsNetworkLoggerRequestGroup( const QgsNetworkRequestParameters &request );
|
||||
QVariant data( int role = Qt::DisplayRole ) const override;
|
||||
QList< QAction * > actions( QObject *parent ) override final;
|
||||
QList<QAction *> actions( QObject *parent ) override final;
|
||||
QVariant toVariant() const override;
|
||||
|
||||
/**
|
||||
@ -126,7 +124,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup
|
||||
*
|
||||
* Will automatically create children encapsulating the reply details.
|
||||
*/
|
||||
void setReply( const QgsNetworkReplyContent &reply );
|
||||
void setReply( const QgsNetworkReplyContent &reply );
|
||||
|
||||
/**
|
||||
* Flags the reply as having timed out.
|
||||
@ -159,7 +157,6 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup
|
||||
static QString cacheControlToString( QNetworkRequest::CacheLoadControl control );
|
||||
|
||||
private:
|
||||
|
||||
QUrl mUrl;
|
||||
int mRequestId = 0;
|
||||
QNetworkAccessManager::Operation mOperation;
|
||||
@ -175,7 +172,7 @@ class QgsNetworkLoggerRequestGroup final : public QgsDevToolsModelGroup
|
||||
Status mStatus = Status::Pending;
|
||||
bool mHasSslErrors = false;
|
||||
bool mReplyFromCache = false;
|
||||
QList< QPair< QString, QString > > mHeaders;
|
||||
QList<QPair<QString, QString>> mHeaders;
|
||||
QgsNetworkLoggerRequestDetailsGroup *mDetailsGroup = nullptr;
|
||||
QgsNetworkLoggerReplyGroup *mReplyGroup = nullptr;
|
||||
QgsNetworkLoggerSslErrorGroup *mSslErrorsGroup = nullptr;
|
||||
@ -213,7 +210,6 @@ class QgsNetworkLoggerPostContentGroup;
|
||||
class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerRequestDetailsGroup, populated from the
|
||||
* specified \a request details.
|
||||
@ -222,7 +218,6 @@ class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup
|
||||
QVariant toVariant() const override;
|
||||
|
||||
private:
|
||||
|
||||
QgsNetworkLoggerRequestQueryGroup *mQueryGroup = nullptr;
|
||||
QgsNetworkLoggerRequestHeadersGroup *mRequestHeaders = nullptr;
|
||||
QgsNetworkLoggerPostContentGroup *mPostContent = nullptr;
|
||||
@ -245,13 +240,11 @@ class QgsNetworkLoggerRequestDetailsGroup final : public QgsDevToolsModelGroup
|
||||
class QgsNetworkLoggerRequestHeadersGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerRequestHeadersGroup, populated from the
|
||||
* specified \a request details.
|
||||
*/
|
||||
QgsNetworkLoggerRequestHeadersGroup( const QgsNetworkRequestParameters &request );
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -271,13 +264,11 @@ class QgsNetworkLoggerRequestHeadersGroup final : public QgsDevToolsModelGroup
|
||||
class QgsNetworkLoggerRequestQueryGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerRequestQueryGroup, populated from the
|
||||
* specified \a url.
|
||||
*/
|
||||
QgsNetworkLoggerRequestQueryGroup( const QUrl &url );
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -295,7 +286,6 @@ class QgsNetworkLoggerRequestQueryGroup final : public QgsDevToolsModelGroup
|
||||
class QgsNetworkLoggerPostContentGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerPostContentGroup, populated from the
|
||||
* specified \a request details.
|
||||
@ -324,7 +314,6 @@ class QgsNetworkLoggerReplyHeadersGroup;
|
||||
class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerReplyGroup, populated from the
|
||||
* specified \a reply details.
|
||||
@ -333,9 +322,7 @@ class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup
|
||||
QVariant toVariant() const override;
|
||||
|
||||
private:
|
||||
|
||||
QgsNetworkLoggerReplyHeadersGroup *mReplyHeaders = nullptr;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -355,13 +342,11 @@ class QgsNetworkLoggerReplyGroup final : public QgsDevToolsModelGroup
|
||||
class QgsNetworkLoggerReplyHeadersGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerReplyHeadersGroup, populated from the
|
||||
* specified \a reply details.
|
||||
*/
|
||||
QgsNetworkLoggerReplyHeadersGroup( const QgsNetworkReplyContent &reply );
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -381,7 +366,6 @@ class QgsNetworkLoggerReplyHeadersGroup final : public QgsDevToolsModelGroup
|
||||
class QgsNetworkLoggerSslErrorGroup final : public QgsDevToolsModelGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerSslErrorGroup, populated from the
|
||||
* specified \a errors.
|
||||
@ -391,5 +375,4 @@ class QgsNetworkLoggerSslErrorGroup final : public QgsDevToolsModelGroup
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // QGSNETWORKLOGGERNODE_H
|
||||
|
||||
@ -51,22 +51,20 @@ QgsNetworkLoggerTreeView::QgsNetworkLoggerTreeView( QgsNetworkLogger *logger, QW
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
connect( this, &QgsNetworkLoggerTreeView::customContextMenuRequested, this, &QgsNetworkLoggerTreeView::contextMenu );
|
||||
|
||||
connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value )
|
||||
{
|
||||
connect( verticalScrollBar(), &QAbstractSlider::sliderMoved, this, [this]( int value ) {
|
||||
if ( value == verticalScrollBar()->maximum() )
|
||||
mAutoScroll = true;
|
||||
else
|
||||
mAutoScroll = false;
|
||||
} );
|
||||
|
||||
connect( mLogger, &QAbstractItemModel::rowsInserted, this, [ = ]
|
||||
{
|
||||
connect( mLogger, &QAbstractItemModel::rowsInserted, this, [=] {
|
||||
if ( mLogger->rowCount() > ( QgsNetworkLogger::MAX_LOGGED_REQUESTS * 1.2 ) ) // 20 % more as buffer
|
||||
{
|
||||
// never trim expanded nodes
|
||||
const int toTrim = mLogger->rowCount() - QgsNetworkLogger::MAX_LOGGED_REQUESTS;
|
||||
int trimmed = 0;
|
||||
QList< int > rowsToTrim;
|
||||
QList<int> rowsToTrim;
|
||||
rowsToTrim.reserve( toTrim );
|
||||
for ( int i = 0; i < mLogger->rowCount(); ++i )
|
||||
{
|
||||
@ -132,7 +130,7 @@ void QgsNetworkLoggerTreeView::contextMenu( QPoint point )
|
||||
{
|
||||
mMenu->clear();
|
||||
|
||||
const QList< QAction * > actions = mLogger->actions( modelIndex, mMenu );
|
||||
const QList<QAction *> actions = mLogger->actions( modelIndex, mMenu );
|
||||
mMenu->addActions( actions );
|
||||
if ( !mMenu->actions().empty() )
|
||||
{
|
||||
@ -185,15 +183,12 @@ QgsNetworkLoggerPanelWidget::QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logg
|
||||
connect( mActionShowSuccessful, &QAction::toggled, mTreeView, &QgsNetworkLoggerTreeView::setShowSuccessful );
|
||||
connect( mActionShowCached, &QAction::toggled, mTreeView, &QgsNetworkLoggerTreeView::setShowCached );
|
||||
connect( mActionClear, &QAction::triggered, mLogger, &QgsNetworkLogger::clear );
|
||||
connect( mActionRecord, &QAction::toggled, this, [ = ]( bool enabled )
|
||||
{
|
||||
connect( mActionRecord, &QAction::toggled, this, [=]( bool enabled ) {
|
||||
QgsSettings().setValue( QStringLiteral( "logNetworkRequests" ), enabled, QgsSettings::App );
|
||||
mLogger->enableLogging( enabled );
|
||||
} );
|
||||
connect( mActionSaveLog, &QAction::triggered, this, [ = ]()
|
||||
{
|
||||
if ( QMessageBox::warning( this, tr( "Save Network Log" ),
|
||||
tr( "Security warning: network logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
|
||||
connect( mActionSaveLog, &QAction::triggered, this, [=]() {
|
||||
if ( QMessageBox::warning( this, tr( "Save Network Log" ), tr( "Security warning: network logs may contain sensitive data including usernames or passwords. Treat this log as confidential and be careful who you share it with. Continue?" ), QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No )
|
||||
return;
|
||||
|
||||
const QString saveFilePath = QFileDialog::getSaveFileName( this, tr( "Save Network Log" ), QDir::homePath(), tr( "Log files" ) + " (*.json)" );
|
||||
@ -231,8 +226,7 @@ QgsNetworkLoggerPanelWidget::QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logg
|
||||
|
||||
mToolbar->addSeparator();
|
||||
QCheckBox *disableCacheCheck = new QCheckBox( tr( "Disable cache" ) );
|
||||
connect( disableCacheCheck, &QCheckBox::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
connect( disableCacheCheck, &QCheckBox::toggled, this, [=]( bool checked ) {
|
||||
// note -- we deliberately do NOT store this as a permanent setting in QSettings
|
||||
// as it is designed to be a temporary debugging tool only and we don't want
|
||||
// users to accidentally leave this enabled and cause unnecessary server load...
|
||||
|
||||
@ -29,11 +29,10 @@ class QgsNetworkLoggerProxyModel;
|
||||
*
|
||||
* \since QGIS 3.14
|
||||
*/
|
||||
class QgsNetworkLoggerTreeView: public QTreeView
|
||||
class QgsNetworkLoggerTreeView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerTreeView, attached to the specified \a logger.
|
||||
*/
|
||||
@ -66,7 +65,6 @@ class QgsNetworkLoggerTreeView: public QTreeView
|
||||
void contextMenu( QPoint point );
|
||||
|
||||
private:
|
||||
|
||||
void expandChildren( const QModelIndex &index );
|
||||
QMenu *mMenu = nullptr;
|
||||
QgsNetworkLogger *mLogger = nullptr;
|
||||
@ -87,14 +85,12 @@ class QgsNetworkLoggerPanelWidget : public QgsDevToolWidget, private Ui::QgsNetw
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsNetworkLoggerPanelWidget, linked with the specified \a logger.
|
||||
*/
|
||||
QgsNetworkLoggerPanelWidget( QgsNetworkLogger *logger, QWidget *parent );
|
||||
|
||||
private:
|
||||
|
||||
QgsNetworkLoggerTreeView *mTreeView = nullptr;
|
||||
QgsNetworkLogger *mLogger = nullptr;
|
||||
};
|
||||
|
||||
@ -19,15 +19,13 @@
|
||||
|
||||
class QgsNetworkLogger;
|
||||
|
||||
class QgsNetworkLoggerWidgetFactory: public QgsDevToolWidgetFactory
|
||||
class QgsNetworkLoggerWidgetFactory : public QgsDevToolWidgetFactory
|
||||
{
|
||||
public:
|
||||
|
||||
QgsNetworkLoggerWidgetFactory( QgsNetworkLogger *logger );
|
||||
QgsDevToolWidget *createWidget( QWidget *parent = nullptr ) const override;
|
||||
|
||||
private:
|
||||
|
||||
QgsNetworkLogger *mLogger = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@ -39,10 +39,9 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW
|
||||
//mTreeView->resizeColumnToContents( 0 );
|
||||
//mTreeView->resizeColumnToContents( 1 );
|
||||
|
||||
mTreeView->setItemDelegateForColumn( 1, new CostDelegate( static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Elapsed ), static_cast< int >( QgsRuntimeProfilerNode::CustomRole::ParentElapsed ), mTreeView ) );
|
||||
mTreeView->setItemDelegateForColumn( 1, new CostDelegate( static_cast<int>( QgsRuntimeProfilerNode::CustomRole::Elapsed ), static_cast<int>( QgsRuntimeProfilerNode::CustomRole::ParentElapsed ), mTreeView ) );
|
||||
|
||||
connect( mProfiler, &QgsRuntimeProfiler::groupAdded, this, [ = ]( const QString & group )
|
||||
{
|
||||
connect( mProfiler, &QgsRuntimeProfiler::groupAdded, this, [=]( const QString &group ) {
|
||||
mCategoryComboBox->addItem( QgsRuntimeProfiler::translateGroupName( group ).isEmpty() ? group : QgsRuntimeProfiler::translateGroupName( group ), group );
|
||||
if ( mCategoryComboBox->count() == 1 )
|
||||
{
|
||||
@ -51,8 +50,7 @@ QgsProfilerPanelWidget::QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QW
|
||||
}
|
||||
} );
|
||||
|
||||
connect( mCategoryComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
|
||||
{
|
||||
connect( mCategoryComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [=]( int ) {
|
||||
mProxyModel->setGroup( mCategoryComboBox->currentData().toString() );
|
||||
} );
|
||||
|
||||
@ -88,7 +86,7 @@ void QgsProfilerProxyModel::setGroup( const QString &group )
|
||||
bool QgsProfilerProxyModel::filterAcceptsRow( int row, const QModelIndex &source_parent ) const
|
||||
{
|
||||
const QModelIndex index = sourceModel()->index( row, 0, source_parent );
|
||||
return sourceModel()->data( index, static_cast< int >( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString() == mGroup;
|
||||
return sourceModel()->data( index, static_cast<int>( QgsRuntimeProfilerNode::CustomRole::Group ) ).toString() == mGroup;
|
||||
}
|
||||
|
||||
|
||||
@ -154,4 +152,3 @@ void CostDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option,
|
||||
QStyledItemDelegate::paint( painter, option, index );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@ class QgsProfilerProxyModel : public QSortFilterProxyModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsProfilerProxyModel( QgsRuntimeProfiler *profiler, QObject *parent );
|
||||
|
||||
void setGroup( const QString &group );
|
||||
@ -37,11 +36,7 @@ class QgsProfilerProxyModel : public QSortFilterProxyModel
|
||||
bool filterAcceptsRow( int row, const QModelIndex &source_parent ) const override;
|
||||
|
||||
private:
|
||||
|
||||
QString mGroup;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -56,17 +51,14 @@ class QgsProfilerPanelWidget : public QgsDevToolWidget, private Ui::QgsProfilerP
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsProfilerPanelWidget.
|
||||
*/
|
||||
QgsProfilerPanelWidget( QgsRuntimeProfiler *profiler, QWidget *parent );
|
||||
|
||||
private:
|
||||
|
||||
QgsRuntimeProfiler *mProfiler = nullptr;
|
||||
QgsProfilerProxyModel *mProxyModel = nullptr;
|
||||
|
||||
};
|
||||
|
||||
// adapted from KDAB's "hotspot"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user