Skip to content

Commit

Permalink
identify/highlight default constants
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Mar 27, 2014
1 parent 8fff180 commit 3dfacc7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions python/core/qgis.sip
Expand Up @@ -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;
};


Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -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 );
Expand Down
16 changes: 8 additions & 8 deletions src/app/qgsoptions.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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() );
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgis.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgsversion.h"
#endif
#include <QCoreApplication>
#include <QColor>
#include <QDate>
#include <QTime>
#include <QDateTime>
Expand Down Expand Up @@ -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[] =
Expand Down
13 changes: 13 additions & 0 deletions src/core/qgis.h
Expand Up @@ -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[];
Expand Down

0 comments on commit 3dfacc7

Please sign in to comment.