Skip to content
Permalink
Browse files

[vectortiles] Show current canvas vector tile zoom level in vector tile

renderer and labeling widgets

Makes it much easier to troubleshoot styles and determine which
rules are currently being applied in the canvas
  • Loading branch information
nyalldawson committed Sep 9, 2020
1 parent 6881946 commit c821288f181e812f4399e0e630f079e9ed8c4f1c
@@ -19,6 +19,8 @@
#include "qgsvectortilelayer.h"

#include "qgslabelinggui.h"
#include "qgsmapcanvas.h"
#include "qgsvectortileutils.h"

#include <QMenu>

@@ -283,6 +285,7 @@ bool QgsVectorTileBasicLabelingListModel::dropMimeData( const QMimeData *data,

QgsVectorTileBasicLabelingWidget::QgsVectorTileBasicLabelingWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
, mMapCanvas( canvas )
, mMessageBar( messageBar )
{

@@ -301,6 +304,15 @@ QgsVectorTileBasicLabelingWidget::QgsVectorTileBasicLabelingWidget( QgsVectorTil

connect( viewStyles, &QAbstractItemView::doubleClicked, this, &QgsVectorTileBasicLabelingWidget::editStyleAtIndex );

if ( mMapCanvas )
{
connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [ = ]( double scale )
{
mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( QgsVectorTileUtils::scaleToZoomLevel( scale, 0, 99 ) ) );
} );
mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 ) ) );
}

setLayer( layer );
}

@@ -65,6 +65,7 @@ class GUI_EXPORT QgsVectorTileBasicLabelingWidget : public QgsMapLayerConfigWidg
QgsVectorTileLayer *mVTLayer = nullptr;
std::unique_ptr<QgsVectorTileBasicLabeling> mLabeling;
QgsVectorTileBasicLabelingListModel *mModel = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;
};

@@ -21,6 +21,8 @@
#include "qgsvectortilelayer.h"
#include "qgssymbolselectordialog.h"
#include "qgsstyle.h"
#include "qgsmapcanvas.h"
#include "qgsvectortileutils.h"

#include <QAbstractListModel>
#include <QInputDialog>
@@ -298,6 +300,7 @@ bool QgsVectorTileBasicRendererListModel::dropMimeData( const QMimeData *data,

QgsVectorTileBasicRendererWidget::QgsVectorTileBasicRendererWidget( QgsVectorTileLayer *layer, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
, mMapCanvas( canvas )
, mMessageBar( messageBar )
{
setupUi( this );
@@ -314,6 +317,15 @@ QgsVectorTileBasicRendererWidget::QgsVectorTileBasicRendererWidget( QgsVectorTil

connect( viewStyles, &QAbstractItemView::doubleClicked, this, &QgsVectorTileBasicRendererWidget::editStyleAtIndex );

if ( mMapCanvas )
{
connect( mMapCanvas, &QgsMapCanvas::scaleChanged, this, [ = ]( double scale )
{
mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( QgsVectorTileUtils::scaleToZoomLevel( scale, 0, 99 ) ) );
} );
mLabelCurrentZoom->setText( tr( "Current zoom: %1" ).arg( QgsVectorTileUtils::scaleToZoomLevel( mMapCanvas->scale(), 0, 99 ) ) );
}

setLayer( layer );
}

@@ -65,6 +65,7 @@ class GUI_EXPORT QgsVectorTileBasicRendererWidget : public QgsMapLayerConfigWidg
QgsVectorTileLayer *mVTLayer = nullptr;
std::unique_ptr<QgsVectorTileBasicRenderer> mRenderer;
QgsVectorTileBasicRendererListModel *mModel = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;
};

@@ -93,6 +93,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mLabelCurrentZoom">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -93,6 +93,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="mLabelCurrentZoom">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>

0 comments on commit c821288

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