Skip to content

Commit 6d0e8e6

Browse files
committedNov 21, 2016
Make max canvas scale 1600% (fix #15861)
Max canvas sacle should be a multiple of 2 so that zooming in to the max and then back out again results in 100% zoom option. Additionally, make the min/max zoom level not come from QSettings as these aren't exposed anywhere
1 parent 2270603 commit 6d0e8e6

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
600600
mSimplifyMaximumScaleComboBox->setScale( 1.0 / mSettings->value( QStringLiteral( "/qgis/simplifyMaxScale" ), 1 ).toFloat() );
601601

602602
// Magnifier
603-
double magnifierMin = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
604-
double magnifierMax = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
603+
double magnifierMin = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
604+
double magnifierMax = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
605605
double magnifierVal = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();
606606
doubleSpinBoxMagnifierDefault->setRange( magnifierMin, magnifierMax );
607607
doubleSpinBoxMagnifierDefault->setSingleStep( 50 );

‎src/app/qgsstatusbarmagnifierwidget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
#include <qgsapplication.h>
2323
#include "qgsstatusbarmagnifierwidget.h"
2424
#include "qgsdoublespinbox.h"
25+
#include "qgisgui.h"
2526

2627
QgsStatusBarMagnifierWidget::QgsStatusBarMagnifierWidget( QWidget* parent )
2728
: QWidget( parent )
2829
{
2930
QSettings settings;
30-
int minimumFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
31-
int maximumFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
32-
int defaultFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();
31+
int minimumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
32+
int maximumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
33+
int defaultFactor = 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();
3334

3435
// label
3536
mLabel = new QLabel();

‎src/gui/qgisgui.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class QFont;
2525
/** \ingroup gui
2626
* /namespace QgisGui
2727
* The QgisGui namespace contains constants and helper functions used throughout the QGIS GUI.
28+
* \note not available in Python bindings
2829
*/
2930
namespace QgisGui
3031
{
@@ -48,6 +49,21 @@ namespace QgisGui
4849
*/
4950
static const Qt::WindowFlags ModalDialogFlags = 0;
5051

52+
/**
53+
* Minimum magnification level allowed in map canvases.
54+
* @see CANVAS_MAGNIFICATION_MAX
55+
* @note added in QGIS 3.0
56+
*/
57+
constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;
58+
59+
/**
60+
* Maximum magnification level allowed in map canvases.
61+
* @see CANVAS_MAGNIFICATION_MAX
62+
* @note added in QGIS 3.0
63+
*/
64+
// Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
65+
constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;
66+
5167
/**
5268
Open files, preferring to have the default file selector be the
5369
last one used, if any; also, prefer to start in the last directory

‎src/gui/qgsmapcanvas.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ QgsMapCanvas::~QgsMapCanvas()
225225
void QgsMapCanvas::setMagnificationFactor( double factor )
226226
{
227227
// do not go higher or lower than min max magnification ratio
228-
QSettings settings;
229-
double magnifierMin = settings.value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
230-
double magnifierMax = settings.value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
228+
double magnifierMin = QgisGui::CANVAS_MAGNIFICATION_MIN;
229+
double magnifierMax = QgisGui::CANVAS_MAGNIFICATION_MAX;
231230
factor = qBound( magnifierMin, factor, magnifierMax );
232231

233232
// the magnifier widget is in integer percent

0 commit comments

Comments
 (0)
Please sign in to comment.