From 511cfdefedafc3818dc23f306741fccd48004f8c Mon Sep 17 00:00:00 2001 From: Stephane ALBERT <stephane.albert@c-s.fr> Date: Wed, 21 Sep 2016 18:15:32 +0200 Subject: [PATCH] BUG: MANTIS-1267: linked overviews preferences to mvd::ImportImagesWidget and mvd::MultiResolutionPyramidWidget. --- .../Monteverdi/src/mvdMainWindow.cxx | 15 +++++++++++-- .../src/mvdImportImagesDialog.cxx | 22 ++++++++++++++++++- .../src/mvdMultiResolutionPyramidWidget.cxx | 19 ++++++++++------ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx index 04a7f75857..6292eb8cee 100644 --- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx +++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx @@ -1227,8 +1227,19 @@ MainWindow if( filenames.isEmpty() ) return; - if( !BuildGDALOverviews( filenames ) ) - return; + assert( I18nCoreApplication::Instance()!=NULL ); + + { + QVariant value( + I18nApplication::Instance()->RetrieveSettingsKey( + I18nCoreApplication::SETTINGS_KEY_OVERVIEWS_ENABLED + ) + ); + + if( !( value.isValid() ? value.toBool() : OVERVIEWS_ENABLED_DEFAULT ) || + !BuildGDALOverviews( filenames ) ) + return; + } if( filenames.count()==1 ) ImportImage( filenames.front(), 0 ); diff --git a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx index 98a2970b87..73b848ba0e 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx @@ -40,6 +40,8 @@ // // Monteverdi includes (sorted by alphabetic order) #include "mvdAlgorithm.h" +#include "mvdCore.h" +#include "mvdI18nCoreApplication.h" namespace mvd { @@ -210,7 +212,25 @@ ImportImagesDialog flags |= Qt::ItemIsSelectable; - unsigned int count = builder->CountResolutions( 2, 256 ); + unsigned int count = 0; + + { + assert( I18nCoreApplication::Instance()!=NULL ); + + QVariant value( + I18nCoreApplication::Instance()->RetrieveSettingsKey( + I18nCoreApplication::SETTINGS_KEY_OVERVIEWS_SIZE + ) + ); + + count = + builder->CountResolutions( + 2, + value.isValid() + ? value.toInt() + : OVERVIEWS_SIZE_DEFAULT + ); + } if( builder->GetOverviewsCount()>0 ) builder->SetBypassEnabled( true ); diff --git a/Modules/Visualization/MonteverdiGui/src/mvdMultiResolutionPyramidWidget.cxx b/Modules/Visualization/MonteverdiGui/src/mvdMultiResolutionPyramidWidget.cxx index 267d4f5075..6ccfea6eb2 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdMultiResolutionPyramidWidget.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdMultiResolutionPyramidWidget.cxx @@ -40,7 +40,9 @@ // // Monteverdi includes (sorted by alphabetic order) +#include "mvdCore.h" #include "mvdGui.h" +#include "mvdI18nCoreApplication.h" namespace mvd { @@ -237,13 +239,15 @@ MultiResolutionPyramidWidget m_UI->baseSpinBox->blockSignals( prevSignalsBlocked ); } + unsigned int maxResolutions = m_GDALOverviewsBuilder->CountResolutions(); + { - bool prevSignalsBlocked = m_UI->levelsSpinBox->blockSignals( true ); + bool prevSignalsBlocked = m_UI->levelsSpinBox->blockSignals( true ); - m_UI->levelsSpinBox->setRange( 0, m_GDALOverviewsBuilder->CountResolutions() ); - m_UI->levelsSpinBox->setValue( m_GDALOverviewsBuilder->GetNbResolutions() ); + m_UI->levelsSpinBox->setRange( 0, maxResolutions ); + m_UI->levelsSpinBox->setValue( m_GDALOverviewsBuilder->GetNbResolutions() ); - m_UI->levelsSpinBox->blockSignals( prevSignalsBlocked ); + m_UI->levelsSpinBox->blockSignals( prevSignalsBlocked ); } { @@ -251,7 +255,8 @@ MultiResolutionPyramidWidget m_UI->sizeSpinBox->setRange( 1, minSize ); - assert(m_GDALOverviewsBuilder->CountResolutions() >= m_GDALOverviewsBuilder->GetNbResolutions() ); + assert( maxResolutions >= + m_GDALOverviewsBuilder->GetNbResolutions() ); // Force C++ implicit cast by declaring local variables to force compiler // to find correct std::pow() signature. @@ -260,8 +265,8 @@ MultiResolutionPyramidWidget // error: call of pow(unsigned int, unsigned int) is ambiguous double rf = m_GDALOverviewsBuilder->GetResolutionFactor(); - int m = - m_GDALOverviewsBuilder->CountResolutions() - + unsigned int m = + maxResolutions - m_GDALOverviewsBuilder->GetNbResolutions(); m_UI->sizeSpinBox->setValue( -- GitLab