Skip to content

Commit a2f5126

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents fbea7d4 + a53bf7e commit a2f5126

9 files changed

+359
-240
lines changed

resources/context_help/HeatmapGui

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Heatmap Plugin Help</h1>
1+
<h3>Heatmap Plugin Help</h3>
22
<p>The Heatmap plugin uses Kernel Density Estimation to create a density (heatmap)
33
raster of an input point vector layer. The density is calculated based on the
44
number of points in a location, with larger numbers of clustered points resulting

resources/context_help/PythonConsole

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Python Console for QGIS</h1>
1+
<h3>Python Console for QGIS</h3>
22
<a href="#console">Console</a><br>
33
<a href="#editor">Editor</a><br>
44
<a href="#settings">Settings</a><br><br>

src/app/qgssnappingdialog.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <QLineEdit>
3131
#include <QDockWidget>
3232
#include <QPushButton>
33+
#include <QDoubleSpinBox>
3334

3435

3536
class QgsSnappingDock : public QDockWidget
@@ -172,7 +173,7 @@ void QgsSnappingDialog::apply()
172173
snapToList << "to_vertex_and_segment";
173174
}
174175

175-
toleranceList << QString::number( qobject_cast<QLineEdit*>( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->text().toDouble(), 'f' );
176+
toleranceList << QString::number( qobject_cast<QDoubleSpinBox*>( mLayerTreeWidget->itemWidget( currentItem, 3 ) )->value(), 'f' );
176177
toleranceUnitList << QString::number( qobject_cast<QComboBox*>( mLayerTreeWidget->itemWidget( currentItem, 4 ) )->currentIndex() );
177178

178179
QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( currentItem, 5 ) );
@@ -274,12 +275,12 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
274275
mLayerTreeWidget->setItemWidget( item, 2, cbxSnapTo );
275276

276277
//snapping tolerance
277-
QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget );
278-
QDoubleValidator *validator = new QDoubleValidator( leTolerance );
279-
leTolerance->setValidator( validator );
280-
leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) );
278+
QDoubleSpinBox* sbTolerance = new QDoubleSpinBox( mLayerTreeWidget );
279+
sbTolerance->setRange( 0., 100000000. );
280+
sbTolerance->setDecimals( 5 );
281+
sbTolerance->setValue( defaultSnappingTolerance );
281282

282-
mLayerTreeWidget->setItemWidget( item, 3, leTolerance );
283+
mLayerTreeWidget->setItemWidget( item, 3, sbTolerance );
283284

284285
//snap to vertex/ snap to segment
285286
QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget );
@@ -295,14 +296,20 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
295296
mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
296297
}
297298

299+
//resize treewidget columns
300+
for ( int i = 0 ; i < 4 ; ++i )
301+
{
302+
mLayerTreeWidget->resizeColumnToContents( i );
303+
}
304+
298305
int idx = layerIdList.indexOf( currentVectorLayer->id() );
299306
if ( idx < 0 )
300307
{
301308
if ( myDockFlag )
302309
{
303310
connect( cbxEnable, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
304311
connect( cbxSnapTo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
305-
connect( leTolerance, SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) );
312+
connect( sbTolerance, SIGNAL( valueChanged( double ) ), this, SLOT( apply() ) );
306313
connect( cbxUnits, SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
307314

308315
if ( cbxAvoidIntersection )
@@ -336,7 +343,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
336343
}
337344

338345
cbxSnapTo->setCurrentIndex( snappingStringIdx );
339-
leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) );
346+
sbTolerance->setValue( toleranceList[idx].toDouble() );
340347
cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
341348
if ( cbxAvoidIntersection )
342349
{
@@ -347,7 +354,7 @@ void QgsSnappingDialog::addLayer( QgsMapLayer *theMapLayer )
347354
{
348355
connect( cbxEnable, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
349356
connect( cbxSnapTo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
350-
connect( leTolerance, SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) );
357+
connect( sbTolerance, SIGNAL( valueChanged( double ) ), this, SLOT( apply() ) );
351358
connect( cbxUnits, SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
352359

353360
if ( cbxAvoidIntersection )

src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp

+61
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVecto
414414
connect( btnGraduatedDelete, SIGNAL( clicked() ), this, SLOT( deleteClasses() ) );
415415
connect( btnDeleteAllClasses, SIGNAL( clicked() ), this, SLOT( deleteAllClasses() ) );
416416
connect( btnGraduatedAdd, SIGNAL( clicked() ), this, SLOT( addClass() ) );
417+
connect( cbxLinkBoundaries, SIGNAL( toggled( bool ) ), this, SLOT( toggleBoundariesLink( bool ) ) );
417418

418419
// initialize from previously set renderer
419420
updateUiFromRenderer();
@@ -699,11 +700,57 @@ void QgsGraduatedSymbolRendererV2Widget::changeRange( int rangeIdx )
699700
{
700701
double lowerValue = dialog.lowerValue().toDouble();
701702
double upperValue = dialog.upperValue().toDouble();
703+
704+
QString label = createLabel( range.lowerValue(), range.upperValue() );
705+
QString newLabel;
706+
702707
mRenderer->updateRangeUpperValue( rangeIdx, upperValue );
703708
mRenderer->updateRangeLowerValue( rangeIdx, lowerValue );
709+
710+
//If the label was the label automatically generated, we generate a new one for the new range
711+
if ( range.label() == label )
712+
{
713+
newLabel = createLabel( lowerValue, upperValue );
714+
mRenderer->updateRangeLabel( rangeIdx, newLabel );
715+
}
716+
717+
//If the boundaries have to stay linked, we update the ranges above and below, as well as their label if needed
718+
if ( cbxLinkBoundaries->isChecked() )
719+
{
720+
if ( rangeIdx > 0 )
721+
{
722+
const QgsRendererRangeV2& rangeLower = mRenderer->ranges()[rangeIdx - 1];
723+
label = createLabel( rangeLower.lowerValue(), rangeLower.upperValue() );
724+
mRenderer->updateRangeUpperValue( rangeIdx - 1, lowerValue );
725+
726+
if ( label == rangeLower.label() )
727+
{
728+
newLabel = createLabel( rangeLower.lowerValue(), lowerValue );
729+
mRenderer->updateRangeLabel( rangeIdx - 1, newLabel );
730+
}
731+
}
732+
733+
if ( rangeIdx < mRenderer->ranges().size() - 1 )
734+
{
735+
const QgsRendererRangeV2& rangeUpper = mRenderer->ranges()[rangeIdx + 1];
736+
label = createLabel( rangeUpper.lowerValue(), rangeUpper.upperValue() );
737+
mRenderer->updateRangeLowerValue( rangeIdx + 1, upperValue );
738+
739+
if ( label == rangeUpper.label() )
740+
{
741+
newLabel = createLabel( upperValue, rangeUpper.upperValue() );
742+
mRenderer->updateRangeLabel( rangeIdx + 1, newLabel );
743+
}
744+
}
745+
}
704746
}
705747
}
706748

749+
QString QgsGraduatedSymbolRendererV2Widget::createLabel( double lowerValue, double upperValue )
750+
{
751+
return QString::number( lowerValue , 'f', 4 ) + " - " + QString::number( upperValue, 'f', 4 );
752+
}
753+
707754
void QgsGraduatedSymbolRendererV2Widget::addClass()
708755
{
709756
mModel->addClass( mGraduatedSymbol );
@@ -720,6 +767,20 @@ void QgsGraduatedSymbolRendererV2Widget::deleteAllClasses()
720767
mModel->removeAllRows();
721768
}
722769

770+
void QgsGraduatedSymbolRendererV2Widget::toggleBoundariesLink( bool linked )
771+
{
772+
//If the checkbox controlling the link between boundaries was unchecked and we check it, we have to link the boundaries
773+
//This is done by updating all lower ranges to the upper value of the range above
774+
if ( linked )
775+
{
776+
for ( int i = 1;i < mRenderer->ranges().size();++i )
777+
{
778+
mRenderer->updateRangeLowerValue( i, mRenderer->ranges()[i-1].upperValue() );
779+
}
780+
refreshSymbolView();
781+
}
782+
}
783+
723784
void QgsGraduatedSymbolRendererV2Widget::changeCurrentValue( QStandardItem * item )
724785
{
725786
if ( item->column() == 2 )

src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.h

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
9494
void deleteClasses();
9595
/**Removes all classes from the classification*/
9696
void deleteAllClasses();
97+
/**Toggle the link between classes boundaries */
98+
void toggleBoundariesLink( bool linked );
9799

98100
void rotationFieldChanged( QString fldName );
99101
void sizeScaleFieldChanged( QString fldName );
@@ -115,6 +117,8 @@ class GUI_EXPORT QgsGraduatedSymbolRendererV2Widget : public QgsRendererV2Widget
115117
void changeRangeSymbol( int rangeIdx );
116118
void changeRange( int rangeIdx );
117119

120+
QString createLabel( double lowerValue, double upperValue );
121+
118122
void changeSelectedSymbols();
119123

120124
QList<QgsSymbolV2*> selectedSymbols();

src/plugins/heatmap/heatmap.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "qgsdistancearea.h"
3434
#include "qgscoordinatereferencesystem.h"
3535
#include "qgslogger.h"
36+
#include "qgsmessagebar.h"
3637

3738
// Qt4 Related Includes
3839
#include <QAction>
@@ -111,6 +112,14 @@ void Heatmap::run()
111112
{
112113
HeatmapGui d( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags, &mSessionSettings );
113114

115+
// Start working on the input vector
116+
QgsVectorLayer* inputLayer = d.inputVectorLayer();
117+
if ( !inputLayer )
118+
{
119+
mQGisIface->messageBar()->pushMessage( tr( "Layer not found" ), tr( "The heatmap plugin requires at least one point vector layer" ), QgsMessageBar::INFO, mQGisIface->messageTimeout() );
120+
return;
121+
}
122+
114123
if ( d.exec() == QDialog::Accepted )
115124
{
116125
// everything runs here
@@ -123,9 +132,6 @@ void Heatmap::run()
123132
mDecay = d.decayRatio();
124133
int kernelShape = d.kernelShape();
125134

126-
// Start working on the input vector
127-
QgsVectorLayer* inputLayer = d.inputVectorLayer();
128-
129135
// Getting the rasterdataset in place
130136
GDALAllRegister();
131137

@@ -135,7 +141,7 @@ void Heatmap::run()
135141
myDriver = GetGDALDriverManager()->GetDriverByName( d.outputFormat().toUtf8() );
136142
if ( myDriver == NULL )
137143
{
138-
QMessageBox::information( 0, tr( "GDAL driver error" ), tr( "Cannot open the driver for the specified format" ) );
144+
mQGisIface->messageBar()->pushMessage( tr( "GDAL driver error" ), tr( "Cannot open the driver for the specified format" ), QgsMessageBar::WARNING, mQGisIface->messageTimeout() );
139145
return;
140146
}
141147

@@ -169,7 +175,7 @@ void Heatmap::run()
169175
heatmapDS = ( GDALDataset * ) GDALOpen( TO8F( d.outputFilename() ), GA_Update );
170176
if ( !heatmapDS )
171177
{
172-
QMessageBox::information( 0, tr( "Raster update error" ), tr( "Could not open the created raster for updating. The heatmap was not generated." ) );
178+
mQGisIface->messageBar()->pushMessage( tr( "Raster update error" ), tr( "Could not open the created raster for updating. The heatmap was not generated." ), QgsMessageBar::WARNING );
173179
return;
174180
}
175181
poBand = heatmapDS->GetRasterBand( 1 );
@@ -225,7 +231,7 @@ void Heatmap::run()
225231
QApplication::processEvents();
226232
if ( p.wasCanceled() )
227233
{
228-
QMessageBox::information( 0, tr( "Heatmap generation aborted" ), tr( "QGIS will now load the partially-computed raster." ) );
234+
mQGisIface->messageBar()->pushMessage( tr( "Heatmap generation aborted" ), tr( "QGIS will now load the partially-computed raster" ), QgsMessageBar::INFO, mQGisIface->messageTimeout() );
229235
break;
230236
}
231237

src/plugins/heatmap/heatmapgui.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,14 @@ QString HeatmapGui::outputFormat()
633633
QgsVectorLayer* HeatmapGui::inputVectorLayer()
634634
{
635635
QString myLayerId = inputLayerCombo->itemData( inputLayerCombo->currentIndex() ).toString();
636-
637-
QgsVectorLayer* inputLayer = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( myLayerId ) );
638-
if ( !inputLayer )
636+
if ( !myLayerId.isEmpty() )
637+
{
638+
QgsVectorLayer* inputLayer = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( myLayerId ) );
639+
return inputLayer;
640+
}
641+
else
639642
{
640-
QMessageBox::information( 0, tr( "Layer not found" ), tr( "Layer %1 not found." ).arg( myLayerId ) );
641643
return 0;
642644
}
643-
return inputLayer;
644645
}
645646

src/ui/qgsgraduatedsymbolrendererv2widget.ui

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>505</width>
9+
<width>615</width>
1010
<height>339</height>
1111
</rect>
1212
</property>
@@ -240,6 +240,16 @@
240240
</property>
241241
</widget>
242242
</item>
243+
<item>
244+
<widget class="QCheckBox" name="cbxLinkBoundaries">
245+
<property name="text">
246+
<string>Link classes boundaries</string>
247+
</property>
248+
<property name="checked">
249+
<bool>true</bool>
250+
</property>
251+
</widget>
252+
</item>
243253
<item>
244254
<spacer>
245255
<property name="orientation">

0 commit comments

Comments
 (0)