Skip to content

Commit 73fcb66

Browse files
committed
Used QsgScaleComboBox in scale based visibility. Also fix #6213
1 parent 413e9dc commit 73fcb66

File tree

5 files changed

+37
-25
lines changed

5 files changed

+37
-25
lines changed

src/app/qgsrasterlayerproperties.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,17 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
8383

8484
// set up the scale based layer visibility stuff....
8585
chkUseScaleDependentRendering->setChecked( lyr->hasScaleBasedVisibility() );
86-
leMinimumScale->setText( QString::number( lyr->minimumScale(), 'f' ) );
87-
leMinimumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
88-
leMaximumScale->setText( QString::number( lyr->maximumScale(), 'f' ) );
89-
leMaximumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
86+
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
87+
if ( projectScales )
88+
{
89+
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
90+
cbMinimumScale->updateScales( scalesList );
91+
cbMaximumScale->updateScales( scalesList );
92+
}
93+
cbMinimumScale->setScale( 1.0 / lyr->minimumScale() );
94+
cbMaximumScale->setScale( 1.0 / lyr->maximumScale() );
95+
96+
9097
leNoDataValue->setValidator( new QDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );
9198

9299
// build GUI components
@@ -750,8 +757,8 @@ void QgsRasterLayerProperties::apply()
750757

751758
// set up the scale based layer visibility stuff....
752759
mRasterLayer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
753-
mRasterLayer->setMinimumScale( leMinimumScale->text().toFloat() );
754-
mRasterLayer->setMaximumScale( leMaximumScale->text().toFloat() );
760+
mRasterLayer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
761+
mRasterLayer->setMaximumScale( 1.0 / cbMaximumScale->scale() );
755762

756763
//update the legend pixmap
757764
pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );

src/app/qgsvectorlayerproperties.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,15 @@ void QgsVectorLayerProperties::reset( void )
586586

587587
// set up the scale based layer visibility stuff....
588588
chkUseScaleDependentRendering->setChecked( layer->hasScaleBasedVisibility() );
589-
leMinimumScale->setText( QString::number( layer->minimumScale(), 'f' ) );
590-
leMinimumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
591-
leMaximumScale->setText( QString::number( layer->maximumScale(), 'f' ) );
592-
leMaximumScale->setValidator( new QDoubleValidator( 0, std::numeric_limits<float>::max(), 1000, this ) );
589+
bool projectScales = QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" );
590+
if ( projectScales )
591+
{
592+
QStringList scalesList = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" );
593+
cbMinimumScale->updateScales( scalesList );
594+
cbMaximumScale->updateScales( scalesList );
595+
}
596+
cbMinimumScale->setScale( 1.0 / layer->minimumScale() );
597+
cbMaximumScale->setScale( 1.0 / layer->maximumScale() );
593598

594599
// symbology initialization
595600
if ( legendtypecombobox->count() == 0 )
@@ -682,8 +687,8 @@ void QgsVectorLayerProperties::apply()
682687

683688
// set up the scale based layer visibility stuff....
684689
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
685-
layer->setMinimumScale( leMinimumScale->text().toFloat() );
686-
layer->setMaximumScale( leMaximumScale->text().toFloat() );
690+
layer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
691+
layer->setMaximumScale( 1.0 / cbMaximumScale->scale() );
687692

688693
// provider-specific options
689694
if ( layer->dataProvider() )

src/core/qgsmaprenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
382382
.arg( ml->extent().toString() )
383383
);
384384

385-
if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() < mScale && mScale < ml->maximumScale() ) || mOverview )
385+
if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() <= mScale && mScale < ml->maximumScale() ) || mOverview )
386386
{
387387
connect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
388388

src/ui/qgsrasterlayerpropertiesbase.ui

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@
589589
<enum>Qt::RightToLeft</enum>
590590
</property>
591591
<property name="text">
592-
<string>Maximum</string>
592+
<string>Less than:</string>
593593
</property>
594594
</widget>
595595
</item>
@@ -599,15 +599,15 @@
599599
<enum>Qt::RightToLeft</enum>
600600
</property>
601601
<property name="text">
602-
<string>Minimum</string>
602+
<string>More than or equal to:</string>
603603
</property>
604604
</widget>
605605
</item>
606606
<item row="0" column="3">
607-
<widget class="QLineEdit" name="leMaximumScale"/>
607+
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
608608
</item>
609609
<item row="0" column="1">
610-
<widget class="QLineEdit" name="leMinimumScale"/>
610+
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
611611
</item>
612612
</layout>
613613
</widget>
@@ -1052,8 +1052,8 @@ p, li { white-space: pre-wrap; }
10521052
<tabstop>tableTransparency</tabstop>
10531053
<tabstop>leDisplayName</tabstop>
10541054
<tabstop>leLayerSource</tabstop>
1055-
<tabstop>leMinimumScale</tabstop>
1056-
<tabstop>leMaximumScale</tabstop>
1055+
<tabstop>cbMinimumScale</tabstop>
1056+
<tabstop>cbMaximumScale</tabstop>
10571057
<tabstop>leSpatialRefSys</tabstop>
10581058
<tabstop>pbnChangeSpatialRefSys</tabstop>
10591059
<tabstop>tePyramidDescription</tabstop>

src/ui/qgsvectorlayerpropertiesbase.ui

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,22 +492,22 @@
492492
<item row="0" column="2">
493493
<widget class="QLabel" name="textLabel1_2_2">
494494
<property name="text">
495-
<string>Maximum</string>
495+
<string>Less than:</string>
496496
</property>
497497
</widget>
498498
</item>
499499
<item row="0" column="0">
500500
<widget class="QLabel" name="textLabel1">
501501
<property name="text">
502-
<string>Minimum</string>
502+
<string>More than or equal to:</string>
503503
</property>
504504
</widget>
505505
</item>
506506
<item row="0" column="1">
507-
<widget class="QLineEdit" name="leMinimumScale"/>
507+
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
508508
</item>
509509
<item row="0" column="3">
510-
<widget class="QLineEdit" name="leMaximumScale"/>
510+
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
511511
</item>
512512
</layout>
513513
</widget>
@@ -968,8 +968,8 @@
968968
<layoutdefault spacing="6" margin="11"/>
969969
<tabstops>
970970
<tabstop>pbnIndex</tabstop>
971-
<tabstop>leMinimumScale</tabstop>
972-
<tabstop>leMaximumScale</tabstop>
971+
<tabstop>cbMinimumScale</tabstop>
972+
<tabstop>cbMaximumScale</tabstop>
973973
<tabstop>txtSubsetSQL</tabstop>
974974
<tabstop>pbnQueryBuilder</tabstop>
975975
</tabstops>

0 commit comments

Comments
 (0)