From 3dfacc77bc30cf1f30aa2a567171d8845d131974 Mon Sep 17 00:00:00 2001 From: Radim Blazek Date: Thu, 27 Mar 2014 14:25:03 +0100 Subject: [PATCH] identify/highlight default constants --- python/core/qgis.sip | 4 ++++ src/app/qgsidentifyresultsdialog.cpp | 8 ++++---- src/app/qgsoptions.cpp | 16 ++++++++-------- src/core/qgis.cpp | 7 +++++++ src/core/qgis.h | 13 +++++++++++++ 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/python/core/qgis.sip b/python/core/qgis.sip index c3f6fdc7e59..07e6cc5450e 100644 --- a/python/core/qgis.sip +++ b/python/core/qgis.sip @@ -152,6 +152,10 @@ class QGis //! Default threshold between map coordinates and device coordinates for map2pixel simplification static const float DEFAULT_MAPTOPIXEL_THRESHOLD; + + static const QColor DEFAULT_HIGHLIGHT_COLOR; + static double DEFAULT_HIGHLIGHT_BUFFER_MM; + static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM; }; diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index b2d8fd3fc20..785102a7145 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -1265,10 +1265,10 @@ void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item ) } QSettings settings; - QColor color = QColor( settings.value( "/Map/identify/highlight/color", "#ff0000" ).toString() ); - int alpha = settings.value( "/Map/identify/highlight/colorAlpha", "128" ).toInt(); - double buffer = settings.value( "/Map/identify/highlight/buffer", "0.5" ).toDouble(); - double minWidth = settings.value( "/Map/identify/highlight/minWidth", "1." ).toDouble(); + QColor color = QColor( settings.value( "/Map/highlight/color", QGis::DEFAULT_HIGHLIGHT_COLOR.name() ).toString() ); + int alpha = settings.value( "/Map/highlight/colorAlpha", QGis::DEFAULT_HIGHLIGHT_COLOR.alpha() ).toInt(); + double buffer = settings.value( "/Map/highlight/buffer", QGis::DEFAULT_HIGHLIGHT_BUFFER_MM ).toDouble(); + double minWidth = settings.value( "/Map/highlight/minWidth", QGis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM ).toDouble(); highlight->setColor( color ); // sets also fill with default alpha color.setAlpha( alpha ); diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 003ee32f0ce..5ad37e0c625 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -119,13 +119,13 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) : identifyValue = QGis::DEFAULT_SEARCH_RADIUS_MM; spinBoxIdentifyValue->setMinimum( 0.0 ); spinBoxIdentifyValue->setValue( identifyValue ); - QColor highlightColor = QColor( settings.value( "/Map/identify/highlight/color", "#ff0000" ).toString() ); - int highlightAlpha = settings.value( "/Map/identify/highlight/colorAlpha", "63" ).toInt(); + QColor highlightColor = QColor( settings.value( "/Map/highlight/color", QGis::DEFAULT_HIGHLIGHT_COLOR.name() ).toString() ); + int highlightAlpha = settings.value( "/Map/highlight/colorAlpha", QGis::DEFAULT_HIGHLIGHT_COLOR.alpha() ).toInt(); highlightColor.setAlpha( highlightAlpha ); mIdentifyHighlightColorButton->setColor( highlightColor ); - double highlightBuffer = settings.value( "/Map/identify/highlight/buffer", "0.5" ).toDouble(); + double highlightBuffer = settings.value( "/Map/highlight/buffer", QGis::DEFAULT_HIGHLIGHT_BUFFER_MM ).toDouble(); mIdentifyHighlightBufferSpinBox->setValue( highlightBuffer ); - double highlightMinWidth = settings.value( "/Map/identify/highlight/minWidth", "1." ).toDouble(); + double highlightMinWidth = settings.value( "/Map/highlight/minWidth", QGis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM ).toDouble(); mIdentifyHighlightMinWidthSpinBox->setValue( highlightMinWidth ); // custom environment variables @@ -1046,10 +1046,10 @@ void QgsOptions::saveOptions() settings.setValue( "/Map/identifyMode", cmbIdentifyMode->itemData( cmbIdentifyMode->currentIndex() ).toInt() ); settings.setValue( "/Map/identifyAutoFeatureForm", cbxAutoFeatureForm->isChecked() ); settings.setValue( "/Map/searchRadiusMM", spinBoxIdentifyValue->value() ); - settings.setValue( "/Map/identify/highlight/color", mIdentifyHighlightColorButton->color().name() ); - settings.setValue( "/Map/identify/highlight/colorAlpha", mIdentifyHighlightColorButton->color().alpha() ); - settings.setValue( "/Map/identify/highlight/buffer", mIdentifyHighlightBufferSpinBox->value() ); - settings.setValue( "/Map/identify/highlight/minWidth", mIdentifyHighlightMinWidthSpinBox->value() ); + settings.setValue( "/Map/highlight/color", mIdentifyHighlightColorButton->color().name() ); + settings.setValue( "/Map/highlight/colorAlpha", mIdentifyHighlightColorButton->color().alpha() ); + settings.setValue( "/Map/highlight/buffer", mIdentifyHighlightBufferSpinBox->value() ); + settings.setValue( "/Map/highlight/minWidth", mIdentifyHighlightMinWidthSpinBox->value() ); bool showLegendClassifiers = settings.value( "/qgis/showLegendClassifiers", false ).toBool(); settings.setValue( "/qgis/showLegendClassifiers", cbxLegendClassifiers->isChecked() ); diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 96065af6e0a..44ac5279bc0 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -20,6 +20,7 @@ #include "qgsversion.h" #endif #include +#include #include #include #include @@ -77,6 +78,12 @@ const double QGis::DEFAULT_SEARCH_RADIUS_MM = 2.; //! Default threshold between map coordinates and device coordinates for map2pixel simplification const float QGis::DEFAULT_MAPTOPIXEL_THRESHOLD = 1.0f; +const QColor QGis::DEFAULT_HIGHLIGHT_COLOR = QColor( 255, 0, 0, 128 ); + +double QGis::DEFAULT_HIGHLIGHT_BUFFER_MM = 0.5; + +double QGis::DEFAULT_HIGHLIGHT_MIN_WIDTH_MM = 1.0; + // description strings for units // Order must match enum indices const char* QGis::qgisUnitTypes[] = diff --git a/src/core/qgis.h b/src/core/qgis.h index a24ec65f2a5..5ebd8b2dbe1 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -275,6 +275,19 @@ class CORE_EXPORT QGis //! Default threshold between map coordinates and device coordinates for map2pixel simplification static const float DEFAULT_MAPTOPIXEL_THRESHOLD; + /** Default highlight color. The transparency is expected to only be applied to polygon + * fill. Lines and outlines are rendered opaque. + * @note added in 2.3 */ + static const QColor DEFAULT_HIGHLIGHT_COLOR; + + /** Default highlight buffer in mm. + * @note added in 2.3 */ + static double DEFAULT_HIGHLIGHT_BUFFER_MM; + + /** Default highlight line/outline minimum width in mm. + * @note added in 2.3 */ + static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM; + private: // String representation of unit types (set in qgis.cpp) static const char *qgisUnitTypes[];