Merge pull request #1570 from slarosa/heatmap-plugin

[heatmap-plugin] replace messagebar to messagebox
This commit is contained in:
Nathan Woodrow 2014-09-14 14:08:52 +10:00
commit f214a0181e
2 changed files with 18 additions and 11 deletions

View File

@ -33,6 +33,7 @@
#include "qgsdistancearea.h"
#include "qgscoordinatereferencesystem.h"
#include "qgslogger.h"
#include "qgsmessagebar.h"
// Qt4 Related Includes
#include <QAction>
@ -111,6 +112,14 @@ void Heatmap::run()
{
HeatmapGui d( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags, &mSessionSettings );
// Start working on the input vector
QgsVectorLayer* inputLayer = d.inputVectorLayer();
if ( !inputLayer )
{
mQGisIface->messageBar()->pushMessage( tr( "Layer not found" ), tr( "The heatmap plugin requires at least one point vector layer" ), QgsMessageBar::INFO, mQGisIface->messageTimeout() );
return;
}
if ( d.exec() == QDialog::Accepted )
{
// everything runs here
@ -123,9 +132,6 @@ void Heatmap::run()
mDecay = d.decayRatio();
int kernelShape = d.kernelShape();
// Start working on the input vector
QgsVectorLayer* inputLayer = d.inputVectorLayer();
// Getting the rasterdataset in place
GDALAllRegister();
@ -135,7 +141,7 @@ void Heatmap::run()
myDriver = GetGDALDriverManager()->GetDriverByName( d.outputFormat().toUtf8() );
if ( myDriver == NULL )
{
QMessageBox::information( 0, tr( "GDAL driver error" ), tr( "Cannot open the driver for the specified format" ) );
mQGisIface->messageBar()->pushMessage( tr( "GDAL driver error" ), tr( "Cannot open the driver for the specified format" ), QgsMessageBar::WARNING, mQGisIface->messageTimeout() );
return;
}
@ -169,7 +175,7 @@ void Heatmap::run()
heatmapDS = ( GDALDataset * ) GDALOpen( TO8F( d.outputFilename() ), GA_Update );
if ( !heatmapDS )
{
QMessageBox::information( 0, tr( "Raster update error" ), tr( "Could not open the created raster for updating. The heatmap was not generated." ) );
mQGisIface->messageBar()->pushMessage( tr( "Raster update error" ), tr( "Could not open the created raster for updating. The heatmap was not generated." ), QgsMessageBar::WARNING );
return;
}
poBand = heatmapDS->GetRasterBand( 1 );
@ -225,7 +231,7 @@ void Heatmap::run()
QApplication::processEvents();
if ( p.wasCanceled() )
{
QMessageBox::information( 0, tr( "Heatmap generation aborted" ), tr( "QGIS will now load the partially-computed raster." ) );
mQGisIface->messageBar()->pushMessage( tr( "Heatmap generation aborted" ), tr( "QGIS will now load the partially-computed raster" ), QgsMessageBar::INFO, mQGisIface->messageTimeout() );
break;
}

View File

@ -633,13 +633,14 @@ QString HeatmapGui::outputFormat()
QgsVectorLayer* HeatmapGui::inputVectorLayer()
{
QString myLayerId = inputLayerCombo->itemData( inputLayerCombo->currentIndex() ).toString();
QgsVectorLayer* inputLayer = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( myLayerId ) );
if ( !inputLayer )
if ( !myLayerId.isEmpty() )
{
QMessageBox::information( 0, tr( "Layer not found" ), tr( "Layer %1 not found." ).arg( myLayerId ) );
return 0;
}
QgsVectorLayer* inputLayer = qobject_cast<QgsVectorLayer *>( QgsMapLayerRegistry::instance()->mapLayer( myLayerId ) );
return inputLayer;
}
else
{
return 0;
}
}