1
/***************************************************************************
2
* Copyright (C) 2003 by Tim Sutton *
5
* This is a plugin generated from the QGIS plugin template *
7
* This program is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
11
***************************************************************************/
12
#include "plugingui.h"
15
#include <QFileDialog>
16
#include <QMessageBox>
18
#include "graticulecreator.h"
19
#include <qgslogger.h>
24
QgsGridMakerPluginGui::QgsGridMakerPluginGui() : QgsGridMakerPluginGuiBase()
28
QgsGridMakerPluginGui::QgsGridMakerPluginGui(QWidget* parent, Qt::WFlags fl)
33
QgsGridMakerPluginGui::~QgsGridMakerPluginGui()
36
void QgsGridMakerPluginGui::on_pbnOK_clicked()
38
//check input file exists
40
QgsLogger::debug("GrativuleCreator called with: " +
41
leOutputShapeFile->text() + " " +
42
leLongitudeInterval->text() + " " +
43
leLatitudeInterval->text() + " " +
44
leOriginLongitude->text() + " " +
45
leOriginLatitude->text() + " " +
46
leEndPointLongitude->text() + " " +
47
leEndPointLatitude->text());
49
if (leOutputShapeFile->text().isEmpty())
51
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
52
QString(tr("Please enter the file name before pressing OK!") ));
56
bool myFlag=false; //presumed guilty
58
double myLongitudeInterval = leLongitudeInterval->text().toDouble(&myFlag);
61
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
62
QString(tr("Longitude Interval is invalid - please correct and try again." )));
65
myFlag=false;//reset test flag
66
double myLatitudeInterval = leLatitudeInterval->text().toDouble(&myFlag);
69
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
70
QString(tr("Latitude Interval is invalid - please correct and try again." )));
73
myFlag=false;//reset test flag
74
double myLongitudeOrigin = leOriginLongitude->text().toDouble(&myFlag);
77
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
78
QString(tr("Longitude Origin is invalid - please correct and try again.." )));
81
myFlag=false;//reset test flag
82
double myLatitudeOrigin = leOriginLatitude->text().toDouble(&myFlag);
85
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
86
QString(tr("Latitude Origin is invalid - please correct and try again." )));
89
myFlag=false;//reset test flag
90
double myEndPointLongitude = leEndPointLongitude->text().toDouble(&myFlag);
93
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
94
QString(tr("End Point Longitude is invalid - please correct and try again." )));
97
myFlag=false;//reset test flag
98
double myEndPointLatitude = leEndPointLatitude->text().toDouble(&myFlag);
101
QMessageBox::warning( 0, tr("QGIS - Grid Maker"),
102
QString(tr("End Point Latitude is invalid - please correct and try again." )));
107
if (radPoint->isChecked())
109
GraticuleCreator myGraticuleCreator ( leOutputShapeFile->text(),GraticuleCreator::POINT );
110
myGraticuleCreator.generatePointGraticule(
119
else if (radLine->isChecked())
121
GraticuleCreator myGraticuleCreator ( leOutputShapeFile->text(),GraticuleCreator::LINE );
122
myGraticuleCreator.generateLineGraticule(
133
GraticuleCreator myGraticuleCreator ( leOutputShapeFile->text(),GraticuleCreator::POLYGON);
134
myGraticuleCreator.generatePolygonGraticule(
144
// If you have a produced a raster layer using your plugin, you can ask qgis to
145
// add it to the view using:
146
// emit drawRasterLayer(QString("layername"));
147
// or for a vector layer
148
//emit drawVectorLayer(QString("pathname"),QString("layername"),QString("provider name (either ogr or postgres"));
151
emit drawVectorLayer(leOutputShapeFile->text(),QString("Graticule"),QString("ogr"));
157
void QgsGridMakerPluginGui::on_pbnSelectOutputFile_clicked()
159
QgsLogger::debug(" Gps File Importer Gui::pbnSelectOutputFile_clicked()");
160
QString myOutputFileNameQString = QFileDialog::getSaveFileName(
162
tr("Choose a filename to save under"),
164
tr("ESRI Shapefile (*.shp)"));
166
if (myOutputFileNameQString.right(4) != ".shp")
167
myOutputFileNameQString += ".shp";
169
leOutputShapeFile->setText(myOutputFileNameQString);
170
if ( leOutputShapeFile->text()=="" )
172
pbnOK->setEnabled(false);
176
pbnOK->setEnabled(true);
181
void QgsGridMakerPluginGui::on_pbnCancel_clicked()