Skip to content
Permalink
Browse files

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
  • Loading branch information
nyalldawson committed Nov 21, 2016
1 parent 2270603 commit 6d0e8e62f0c2948a80f64be2f5e63e1c0c9d0ba3
Showing with 24 additions and 8 deletions.
  1. +2 −2 src/app/qgsoptions.cpp
  2. +4 −3 src/app/qgsstatusbarmagnifierwidget.cpp
  3. +16 −0 src/gui/qgisgui.h
  4. +2 −3 src/gui/qgsmapcanvas.cpp
@@ -600,8 +600,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mSimplifyMaximumScaleComboBox->setScale( 1.0 / mSettings->value( QStringLiteral( "/qgis/simplifyMaxScale" ), 1 ).toFloat() );

// Magnifier
double magnifierMin = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
double magnifierMax = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
double magnifierMin = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
double magnifierMax = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
double magnifierVal = 100 * mSettings->value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();
doubleSpinBoxMagnifierDefault->setRange( magnifierMin, magnifierMax );
doubleSpinBoxMagnifierDefault->setSingleStep( 50 );
@@ -22,14 +22,15 @@
#include <qgsapplication.h>
#include "qgsstatusbarmagnifierwidget.h"
#include "qgsdoublespinbox.h"
#include "qgisgui.h"

QgsStatusBarMagnifierWidget::QgsStatusBarMagnifierWidget( QWidget* parent )
: QWidget( parent )
{
QSettings settings;
int minimumFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
int maximumFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
int defaultFactor = ( int ) 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();
int minimumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MIN;
int maximumFactor = 100 * QgisGui::CANVAS_MAGNIFICATION_MAX;
int defaultFactor = 100 * settings.value( QStringLiteral( "/qgis/magnifier_factor_default" ), 1.0 ).toDouble();

// label
mLabel = new QLabel();
@@ -25,6 +25,7 @@ class QFont;
/** \ingroup gui
* /namespace QgisGui
* The QgisGui namespace contains constants and helper functions used throughout the QGIS GUI.
* \note not available in Python bindings
*/
namespace QgisGui
{
@@ -48,6 +49,21 @@ namespace QgisGui
*/
static const Qt::WindowFlags ModalDialogFlags = 0;

/**
* Minimum magnification level allowed in map canvases.
* @see CANVAS_MAGNIFICATION_MAX
* @note added in QGIS 3.0
*/
constexpr double CANVAS_MAGNIFICATION_MIN = 0.1;

/**
* Maximum magnification level allowed in map canvases.
* @see CANVAS_MAGNIFICATION_MAX
* @note added in QGIS 3.0
*/
// Must be a factor of 2, so zooming in to max from 100% then zooming back out will result in 100% mag
constexpr double CANVAS_MAGNIFICATION_MAX = 16.0;

/**
Open files, preferring to have the default file selector be the
last one used, if any; also, prefer to start in the last directory
@@ -225,9 +225,8 @@ QgsMapCanvas::~QgsMapCanvas()
void QgsMapCanvas::setMagnificationFactor( double factor )
{
// do not go higher or lower than min max magnification ratio
QSettings settings;
double magnifierMin = settings.value( QStringLiteral( "/qgis/magnifier_factor_min" ), 0.1 ).toDouble();
double magnifierMax = settings.value( QStringLiteral( "/qgis/magnifier_factor_max" ), 10 ).toDouble();
double magnifierMin = QgisGui::CANVAS_MAGNIFICATION_MIN;
double magnifierMax = QgisGui::CANVAS_MAGNIFICATION_MAX;
factor = qBound( magnifierMin, factor, magnifierMax );

// the magnifier widget is in integer percent

0 comments on commit 6d0e8e6

Please sign in to comment.
You can’t perform that action at this time.