Skip to content

Commit

Permalink
add option to load result to canvas in Heatmap plugin (fix #6645)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 28, 2014
1 parent e846a89 commit 8c97462
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/heatmap/heatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,11 @@ void Heatmap::run()
// Finally close the dataset
GDALClose(( GDALDatasetH ) heatmapDS );

// Open the file in QGIS window
mQGisIface->addRasterLayer( d.outputFilename(), QFileInfo( d.outputFilename() ).baseName() );
// Open the file in QGIS window if requested
if ( d.addToCanvas() )
{
mQGisIface->addRasterLayer( d.outputFilename(), QFileInfo( d.outputFilename() ).baseName() );
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/plugins/heatmap/heatmapgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WindowFlags fl, QMap<QString, QVari
updateBBox();
updateSize();

mAddToCanvas->setChecked( s.value( "/Heatmap/addToCanvas", true ).toBool() );

blockAllSignals( false );

//finally set right the ok button
Expand Down Expand Up @@ -215,6 +217,7 @@ void HeatmapGui::saveSettings()
// Save persistent settings
QSettings s;
s.setValue( "/Heatmap/lastFormat", QVariant( formatCombo->currentIndex() ) );
s.setValue( "/Heatmap/addToCanvas", mAddToCanvas->isChecked() );

// Store temporary settings, which only apply to this session
mHeatmapSessionSettings->insert( QString( "lastInputLayer" ), QVariant( inputLayerCombo->itemData( inputLayerCombo->currentIndex() ) ) );
Expand Down Expand Up @@ -582,6 +585,11 @@ int HeatmapGui::weightField()
return weightFieldCombo->itemData( weightindex ).toInt();
}

bool HeatmapGui::addToCanvas()
{
return mAddToCanvas->isChecked();
}

QString HeatmapGui::outputFilename()
{
QString outputFileName;
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/heatmap/heatmapgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
/** Returns the attrinute field for weighted heat */
int weightField();

/** Returns state of the add to canvas checkbox*/
bool addToCanvas();

/** Returns the output filename/path */
QString outputFilename();

Expand Down
7 changes: 7 additions & 0 deletions src/plugins/heatmap/heatmapguibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
</layout>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="mAddToCanvas">
<property name="text">
<string>Add generated file to map</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
Expand Down

0 comments on commit 8c97462

Please sign in to comment.