Skip to content

Commit

Permalink
Used QsgScaleComboBox in scale based visibility. Also fix #6213
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Sep 21, 2012
1 parent 413e9dc commit 73fcb66
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
19 changes: 13 additions & 6 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -83,10 +83,17 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv

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


leNoDataValue->setValidator( new QDoubleValidator( -std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), 1000, this ) );

// build GUI components
Expand Down Expand Up @@ -750,8 +757,8 @@ void QgsRasterLayerProperties::apply()

// set up the scale based layer visibility stuff....
mRasterLayer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
mRasterLayer->setMinimumScale( leMinimumScale->text().toFloat() );
mRasterLayer->setMaximumScale( leMaximumScale->text().toFloat() );
mRasterLayer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
mRasterLayer->setMaximumScale( 1.0 / cbMaximumScale->scale() );

//update the legend pixmap
pixmapLegend->setPixmap( mRasterLayer->legendAsPixmap() );
Expand Down
17 changes: 11 additions & 6 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -586,10 +586,15 @@ void QgsVectorLayerProperties::reset( void )

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

// symbology initialization
if ( legendtypecombobox->count() == 0 )
Expand Down Expand Up @@ -682,8 +687,8 @@ void QgsVectorLayerProperties::apply()

// set up the scale based layer visibility stuff....
layer->toggleScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
layer->setMinimumScale( leMinimumScale->text().toFloat() );
layer->setMaximumScale( leMaximumScale->text().toFloat() );
layer->setMinimumScale( 1.0 / cbMinimumScale->scale() );
layer->setMaximumScale( 1.0 / cbMaximumScale->scale() );

// provider-specific options
if ( layer->dataProvider() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaprenderer.cpp
Expand Up @@ -382,7 +382,7 @@ void QgsMapRenderer::render( QPainter* painter, double* forceWidthScale )
.arg( ml->extent().toString() )
);

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

Expand Down
12 changes: 6 additions & 6 deletions src/ui/qgsrasterlayerpropertiesbase.ui
Expand Up @@ -589,7 +589,7 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Maximum</string>
<string>Less than:</string>
</property>
</widget>
</item>
Expand All @@ -599,15 +599,15 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Minimum</string>
<string>More than or equal to:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="leMaximumScale"/>
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leMinimumScale"/>
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -1052,8 +1052,8 @@ p, li { white-space: pre-wrap; }
<tabstop>tableTransparency</tabstop>
<tabstop>leDisplayName</tabstop>
<tabstop>leLayerSource</tabstop>
<tabstop>leMinimumScale</tabstop>
<tabstop>leMaximumScale</tabstop>
<tabstop>cbMinimumScale</tabstop>
<tabstop>cbMaximumScale</tabstop>
<tabstop>leSpatialRefSys</tabstop>
<tabstop>pbnChangeSpatialRefSys</tabstop>
<tabstop>tePyramidDescription</tabstop>
Expand Down
12 changes: 6 additions & 6 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -492,22 +492,22 @@
<item row="0" column="2">
<widget class="QLabel" name="textLabel1_2_2">
<property name="text">
<string>Maximum</string>
<string>Less than:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Minimum</string>
<string>More than or equal to:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leMinimumScale"/>
<widget class="QgsScaleComboBox" name="cbMinimumScale"/>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="leMaximumScale"/>
<widget class="QgsScaleComboBox" name="cbMaximumScale"/>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -968,8 +968,8 @@
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>pbnIndex</tabstop>
<tabstop>leMinimumScale</tabstop>
<tabstop>leMaximumScale</tabstop>
<tabstop>cbMinimumScale</tabstop>
<tabstop>cbMaximumScale</tabstop>
<tabstop>txtSubsetSQL</tabstop>
<tabstop>pbnQueryBuilder</tabstop>
</tabstops>
Expand Down

0 comments on commit 73fcb66

Please sign in to comment.