Skip to content

Commit

Permalink
Clarify in doxygen what scale values represent
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 8, 2017
1 parent 08a9bcb commit 463e722
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions python/core/qgsmaplayer.sip
Expand Up @@ -760,8 +760,8 @@ Return pointer to layer's undo stack

bool isInScaleRange( double scale ) const;
%Docstring
Tests whether the layer should be visible at the specified scale.
\param scale scale denominator to test
Tests whether the layer should be visible at the specified ``scale``.
The ``scale`` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
:return: true if the layer is visible at the given scale.
.. versionadded:: 2.16
.. seealso:: minimumScale()
Expand Down
8 changes: 5 additions & 3 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -141,9 +141,10 @@ Constructor
:rtype: int
%End

double scale();
double scale() const;
%Docstring
Get the last reported scale of the canvas
Returns the last reported scale of the canvas.
The ``scale`` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
:rtype: float
%End

Expand Down Expand Up @@ -405,7 +406,8 @@ set wheel zoom factor (should be greater than 1)

void zoomScale( double scale );
%Docstring
Zoom to a specific scale
Zooms the canvas to a specific ``scale``.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
%End

void zoomByFactor( double scaleFactor, const QgsPointXY *center = 0 );
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -8734,8 +8734,7 @@ void QgisApp::saveLastMousePosition( const QgsPointXY &p )

void QgisApp::showScale( double scale )
{
// Why has MapCanvas the scale inverted?
mScaleWidget->setScale( 1.0 / scale );
mScaleWidget->setScale( scale );

// Not sure if the lines below do anything meaningful /Homann
if ( mScaleWidget->width() > mScaleWidget->minimumWidth() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsstatusbarscalewidget.cpp
Expand Up @@ -80,7 +80,7 @@ QgsStatusBarScaleWidget::~QgsStatusBarScaleWidget()
void QgsStatusBarScaleWidget::setScale( double scale )
{
mScale->blockSignals( true );
mScale->setScale( 1.0 / scale );
mScale->setScale( scale );
mScale->blockSignals( false );
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsstatusbarscalewidget.h
Expand Up @@ -44,8 +44,8 @@ class APP_EXPORT QgsStatusBarScaleWidget : public QWidget
virtual ~QgsStatusBarScaleWidget();

/**
* \brief setScale set the selected scale from double
* \param scale
* Set the selected \a scale from double.
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
*/
void setScale( double scale );

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsmaplayer.h
Expand Up @@ -679,8 +679,8 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
QgsMapLayerStyleManager *styleManager() const;

/** Tests whether the layer should be visible at the specified scale.
* \param scale scale denominator to test
/** Tests whether the layer should be visible at the specified \a scale.
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* \returns true if the layer is visible at the given scale.
* \since QGIS 2.16
* \see minimumScale()
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -277,10 +277,10 @@ void QgsMapCanvas::setCurrentLayer( QgsMapLayer *layer )
emit currentLayerChanged( layer );
}

double QgsMapCanvas::scale()
double QgsMapCanvas::scale() const
{
return mapSettings().scale();
} // scale
}

bool QgsMapCanvas::isDrawing()
{
Expand Down
12 changes: 9 additions & 3 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -172,8 +172,11 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! \since QGIS 2.4
int mapUpdateInterval() const;

//! Get the last reported scale of the canvas
double scale();
/**
* Returns the last reported scale of the canvas.
* The \a scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
*/
double scale() const;

//! Returns the mapUnitsPerPixel (map units per pixel) for the canvas
double mapUnitsPerPixel() const;
Expand Down Expand Up @@ -365,7 +368,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! set wheel zoom factor (should be greater than 1)
void setWheelFactor( double factor );

//! Zoom to a specific scale
/**
* Zooms the canvas to a specific \a scale.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
*/
void zoomScale( double scale );

//! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgstextformatwidget.cpp
Expand Up @@ -1227,7 +1227,7 @@ void QgsTextFormatWidget::onSubstitutionsChanged( const QgsStringReplacementColl

void QgsTextFormatWidget::previewScaleChanged( double scale )
{
lblFontPreview->setScale( 1.0 / scale );
lblFontPreview->setScale( scale );
}

void QgsTextFormatWidget::updateSvgWidgets( const QString &svgPath )
Expand Down
3 changes: 1 addition & 2 deletions src/gui/qgstextpreview.cpp
Expand Up @@ -19,7 +19,6 @@

QgsTextPreview::QgsTextPreview( QWidget *parent )
: QLabel( parent )
, mScale( -1 )
, mMapUnits( QgsUnitTypes::DistanceMeters )
{
// initially use a basic transform with no scale
Expand Down Expand Up @@ -78,7 +77,7 @@ void QgsTextPreview::updateContext()
{
if ( mScale >= 0 )
{
QgsMapToPixel newCoordXForm = QgsMapToPixel::fromScale( mScale, mMapUnits, QgsApplication::desktop()->logicalDpiX() );
QgsMapToPixel newCoordXForm = QgsMapToPixel::fromScale( 1.0 / mScale, mMapUnits, QgsApplication::desktop()->logicalDpiX() );
mContext.setMapToPixel( newCoordXForm );
}
update();
Expand Down
11 changes: 7 additions & 4 deletions src/gui/qgstextpreview.h
Expand Up @@ -63,14 +63,17 @@ class GUI_EXPORT QgsTextPreview : public QLabel
*/
QgsTextFormat format() const { return mFormat; }

/** Sets the scale to use for previewing format sizes in map units.
* \param scale preview map scale
/**
* Sets the \a scale to use for previewing format sizes in map units.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* \see scale()
* \see setMapUnits()
*/
void setScale( double scale );

/** Returns the scale used for previewing format sizes in map units.
/**
* Returns the scale used for previewing format sizes in map units.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
* \see setScale()
* \see mapUnits()
*/
Expand All @@ -92,7 +95,7 @@ class GUI_EXPORT QgsTextPreview : public QLabel
private:
QgsTextFormat mFormat;
QgsRenderContext mContext;
double mScale;
double mScale = -1;
QgsUnitTypes::DistanceUnit mMapUnits;
void updateContext();
};
Expand Down

0 comments on commit 463e722

Please sign in to comment.