00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <qgisapp.h>
00025 #include <qgisgui.h>
00026 #include <qgsmaplayer.h>
00027 #include <qgsrasterlayer.h>
00028 #include "pihmgis.h"
00029
00030 #include "pihmgisgui.h"
00031
00032
00033
00034
00035
00036 #include <QToolBar>
00037 #include <QMenuBar>
00038 #include <QMessageBox>
00039 #include <QMenu>
00040 #include <QLineEdit>
00041 #include <QAction>
00042 #include <QApplication>
00043 #include <QCursor>
00044
00045 #include <Q3PopupMenu>
00046 #include <QToolButton>
00047
00048
00049 #include <iostream>
00050
00051
00052 #include "RasterProcessing/FillPits/fillpits.h"
00053 #include "RasterProcessing/FlowGrid/flowgrid.h"
00054 #include "RasterProcessing/StreamGrid/streamgrid.h"
00055 #include "RasterProcessing/LinkGrid/linkgrid.h"
00056 #include "RasterProcessing/StreamPolyLine/streampolyline.h"
00057 #include "RasterProcessing/CatchmentGrid/catchmentgrid.h"
00058 #include "RasterProcessing/CatchmentPolygon/catchmentpolygon.h"
00059
00060 #include "VectorProcessing/shpFilesInputDialog/shpfilesinputdialog.h"
00061 #include "VectorProcessing/polygonToPolyLineDialog/polygontopolylinedialog.h"
00062 #include "VectorProcessing/simplifyLineDialog/simplifylinedialog.h"
00063 #include "VectorProcessing/splitLineDialog/splitlinedialog.h"
00064 #include "VectorProcessing/mergeFeaturesDialog/mergefeaturesdialog.h"
00065
00066 #include "DomainDecomposition/GenerateShapeTopology/generateshapetopology.h"
00067 #include "DomainDecomposition/RunTriangle/runtriangle.h"
00068 #include "DomainDecomposition/CreateTINs/createtins.h"
00069
00070 #include "ExtractData/mshFile/mshfile.h"
00071 #include "ExtractData/attFile/attfile.h"
00072 #include "ExtractData/rivFile/rivfile.h"
00073 #include "ExtractData/paraFile/parafile.h"
00074
00075 #include "runPIHM/runpihm.h"
00076 #include "sundials_types.h"
00077 #include "cvode.h"
00078 #include "cvode_spgmr.h"
00079 #include "sundials_smalldense.h"
00080 #include "nvector_serial.h"
00081 #include "sundials_math.h"
00082 #include "cvode_dense.h"
00083 #include "sundials_dense.h"
00084
00085 #include "Analysis/TimeSeries/timeseries.h"
00086 #include "Analysis/SpatialPlot/spatialplot.h"
00087
00088 #include "Help/about/about.h"
00089
00090
00091 #ifdef WIN32
00092 #define QGISEXTERN extern "C" __declspec( dllexport )
00093 #else
00094 #define QGISEXTERN extern "C"
00095 #endif
00096
00097 static const char * const sIdent = "$Id: plugin.cpp 5476 2006-05-19 09:53:08Z g_j_m $";
00098 static const char * const sName = "PIHMgis";
00099 static const char * const sDescription = "An Integrated GIS Interface to PennState Integrated Hydrologic Model (PIHM)";
00100 static const char * const sPluginVersion = "Version 0.1";
00101 static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
00102
00104
00105
00106
00108
00115 PIHMgis::PIHMgis(QgisApp * theQGisApp,
00116 QgisIface * theQgisInterface):
00117 QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
00118 mQGisApp(theQGisApp),
00119 mQGisIface(theQgisInterface)
00120 {
00121 }
00122
00123 PIHMgis::~PIHMgis()
00124 {
00125
00126 }
00127
00128
00129
00130
00131
00132 void PIHMgis::initGui()
00133 {
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00173 QMenu* rastMenu = new QMenu("&Raster-Processing", mQGisIface->app());
00174 rastMenu->addAction("Run All", this, SLOT(runFillPits()));
00175 rastMenu->addSeparator();
00176
00177 rastMenu->addAction( "Fill Pits", this, SLOT(runFillPits()));
00178 rastMenu->addAction( "Flow Grid", this, SLOT(runFlowGrid()));
00179 rastMenu->addAction( "Stream Grid", this, SLOT(runStreamGrid()));
00180 rastMenu->addAction( "Link Grid", this, SLOT(runLinkGrid()));
00181 rastMenu->addAction( "Stream Polyline", this, SLOT(runStreamPolyLine()));
00182 rastMenu->addAction( "Catchment Grid", this, SLOT(runCatchmentGrid()));
00183 rastMenu->addAction( "Catchment Polygon", this, SLOT(runCatchmentPolygon()));
00184
00185 QAction *rastAction = new QAction(" Raster Processing ", this);
00186 rastAction->setMenu(rastMenu);
00187 mQGisIface->addToolBarIcon(rastAction);
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00201 QMenu* vectMenu = new QMenu("&Vector-Processing", mQGisIface->app());
00202 vectMenu->addAction( "Run All", this, SLOT(runShpFileInput()));
00203 vectMenu->addSeparator();
00204 vectMenu->addAction( "Input Files", this, SLOT(runShpFileInput()));
00205 vectMenu->addAction( "Polygon To Line", this, SLOT(runPolygonToPolyline()));
00206 vectMenu->addAction( "Simplify Line", this, SLOT(runSimplifyLine()));
00207 vectMenu->addAction( "Split Line", this, SLOT(runSplitLine()));
00208 vectMenu->addAction( "Vector Merge", this, SLOT(runVectorMerge()));
00209
00210 QAction *vectAction = new QAction(" Vector Processing ", this);
00211 vectAction->setMenu(vectMenu);
00212 mQGisIface->addToolBarIcon(vectAction);
00214
00215
00217 QMenu* domainMenu = new QMenu("&Domain-Decomposition", mQGisIface->app());
00218 domainMenu->addAction( "Run All", this, SLOT(runGenerateShapeTopology()));
00219 domainMenu->addSeparator();
00220 domainMenu->addAction( "Read ShapeTopology", this, SLOT(runGenerateShapeTopology()));
00221 domainMenu->addAction( "Run Triangle", this, SLOT(runRunTriangle()));
00222 domainMenu->addAction( "TIN Generation", this, SLOT(runCreateTINs()));
00223
00224 QAction *domainAction = new QAction("Domain Decomposition", this);
00225 domainAction->setMenu(domainMenu);
00226 mQGisIface->addToolBarIcon(domainAction);
00228
00230 QMenu* xtractMenu = new QMenu("&Extract-Data", mQGisIface->app());
00231 xtractMenu->addAction( "Run All", this, SLOT(runMshFile()));
00232 xtractMenu->addSeparator();
00233 xtractMenu->addAction( "Generate MeshFile", this, SLOT(runMshFile()));
00234 xtractMenu->addAction( "Generate AttFile", this, SLOT(runAttFile()));
00235 xtractMenu->addAction( "Generate RivFile", this, SLOT(runRivFile()));
00236 xtractMenu->addAction( "Generate ParaFile", this, SLOT(runParaFile()));
00237
00238 QAction *xtractAction = new QAction("&DataModel Loader", this);
00239 xtractAction->setMenu(xtractMenu);
00240 mQGisIface->addToolBarIcon(xtractAction);
00242
00244 QMenu* pihmMenu = new QMenu("&PIHM", mQGisIface->app());
00245 pihmMenu->addAction( "Run PIHM", this, SLOT(runPIHM()));
00246
00247 QAction *pihmAction = new QAction(" PIHM ", this);
00248 pihmAction->setMenu(pihmMenu);
00249 mQGisIface->addToolBarIcon(pihmAction);
00251
00253 QMenu* analysisMenu = new QMenu("&Analysis", mQGisIface->app());
00254
00255 analysisMenu->addAction("Spatial Plots", this, SLOT(runSpatialPlots()));
00256
00257 QAction *analysisAction = new QAction(" Analysis ", this);
00258 analysisAction->setMenu(analysisMenu);
00259 mQGisIface->addToolBarIcon(analysisAction);
00261
00263 QMenu* helpMenu = new QMenu("&HELP", mQGisIface->app());
00264 helpMenu->addAction( "HelpContents", this, SLOT(runDoNothing()));
00265 helpMenu->addAction( "PIHMgis Homepage", this, SLOT(runDoNothing()));
00266 helpMenu->addAction( "About", this, SLOT(runAbout()));
00267 QAction *helpAction = new QAction(" Help ", this);
00268 helpAction->setMenu(helpMenu);
00269 mQGisIface->addToolBarIcon(helpAction);
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 }
00282
00283
00284 void PIHMgis::help()
00285 {
00286
00287 }
00288
00289
00290
00291
00292
00293 void PIHMgis::run()
00294 {
00295 PIHMgisGui *myPluginGui=new PIHMgisGui(mQGisApp, QgisGui::ModalDialogFlags);
00296
00297 connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
00298 connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
00299 myPluginGui->show();
00300 }
00301
00302
00303 void PIHMgis::unload()
00304 {
00305
00306 mQGisIface->removePluginMenu("&PIHMgis",mQActionPointer);
00307 mQGisIface->removeToolBarIcon(mQActionPointer);
00308 delete mQActionPointer;
00309 }
00310
00311 void PIHMgis::runDoNothing(){
00312
00313 }
00315 void PIHMgis::runFillPits(){
00316 fillpitsDlg* Dlg = new fillpitsDlg;
00317
00318 Dlg->setApplicationPointer(mQGisApp);
00319 Dlg->show();
00320 }
00321
00322 void PIHMgis::runFlowGrid(){
00323 FlowGridDlg* Dlg = new FlowGridDlg;
00324
00325 Dlg->setApplicationPointer(mQGisApp);
00326 Dlg->show();
00327 }
00328
00329 void PIHMgis::runStreamGrid(){
00330 StreamGridDlg* Dlg = new StreamGridDlg;
00331
00332 Dlg->setApplicationPointer(mQGisApp);
00333 Dlg->show();
00334 }
00335
00336 void PIHMgis::runLinkGrid(){
00337 LinkGridDlg* Dlg = new LinkGridDlg;
00338
00339 Dlg->setApplicationPointer(mQGisApp);
00340 Dlg->show();
00341 }
00342
00343 void PIHMgis::runStreamPolyLine(){
00344 StreamPolyLineDlg* Dlg = new StreamPolyLineDlg;
00345
00346 Dlg->setApplicationPointer(mQGisApp);
00347 Dlg->show();
00348 }
00349
00350 void PIHMgis::runCatchmentGrid(){
00351 CatchmentGridDlg* Dlg = new CatchmentGridDlg;
00352
00353 Dlg->setApplicationPointer(mQGisApp);
00354 Dlg->show();
00355 }
00356
00357 void PIHMgis::runCatchmentPolygon(){
00358 CatchmentPolygonDlg* Dlg = new CatchmentPolygonDlg;
00359
00360 Dlg->setApplicationPointer(mQGisApp);
00361 Dlg->show();
00362 }
00363
00365
00367 void PIHMgis::runShpFileInput(){
00368 shpFilesInputDialogDlg* Dlg = new shpFilesInputDialogDlg;
00369
00370 Dlg->show();
00371 }
00372
00373 void PIHMgis::runPolygonToPolyline(){
00374 polygonToPolyLineDialogDlg* Dlg = new polygonToPolyLineDialogDlg;
00375
00376 Dlg->show();
00377 }
00378
00379 void PIHMgis::runSimplifyLine(){
00380 simplifyLineDialogDlg* Dlg = new simplifyLineDialogDlg;
00381
00382 Dlg->show();
00383 }
00384
00385 void PIHMgis::runSplitLine(){
00386 splitLineDialogDlg* Dlg = new splitLineDialogDlg;
00387
00388 Dlg->show();
00389 }
00390
00391 void PIHMgis::runVectorMerge(){
00392 mergeFeaturesDialogDlg* Dlg = new mergeFeaturesDialogDlg;
00393
00394 Dlg->show();
00395 }
00397
00399 void PIHMgis::runGenerateShapeTopology(){
00400 generateShapeTopologyDlg* Dlg = new generateShapeTopologyDlg;
00401
00402 Dlg->show();
00403 }
00404
00405 void PIHMgis::runRunTriangle(){
00406 runTriangleDlg* Dlg = new runTriangleDlg;
00407
00408 Dlg->show();
00409 }
00410
00411 void PIHMgis::runCreateTINs(){
00412 createTINsDlg* Dlg = new createTINsDlg;
00413
00414 Dlg->show();
00415 }
00417 void PIHMgis::runMshFile(){
00418 mshFileDlg* Dlg = new mshFileDlg;
00419
00420 Dlg->show();
00421 }
00422
00423 void PIHMgis::runAttFile(){
00424 attFileDlg* Dlg = new attFileDlg;
00425
00426 Dlg->show();
00427 }
00428
00429 void PIHMgis::runRivFile(){
00430 rivFileDlg* Dlg = new rivFileDlg;
00431 Dlg->show();
00432 }
00433
00434 void PIHMgis::runParaFile(){
00435 paraFileDlg* Dlg = new paraFileDlg;
00436
00437 Dlg->show();
00438 }
00439
00441 void PIHMgis::runPIHM(){
00442 runPIHMDlg* Dlg = new runPIHMDlg;
00443 Dlg->show();
00444 }
00446 void PIHMgis::runTimeSeriesPlots(){
00447
00448
00449 }
00450
00451 void PIHMgis::runSpatialPlots(){
00452 spatialPlotDlg* Dlg = new spatialPlotDlg;
00453 Dlg->setApplicationPointer(mQGisApp);
00454 Dlg->show();
00455 }
00457 void PIHMgis::runAbout(){
00458 AboutDlg* Dlg = new AboutDlg;
00459 Dlg->show();
00460 }
00462
00463
00464
00466
00467
00468
00469
00470
00471
00472
00474
00475 void PIHMgis::drawRasterLayer(QString theQString)
00476 {
00477 mQGisIface->addRasterLayer(theQString);
00478 }
00479
00481
00482
00483 void PIHMgis::drawVectorLayer(QString thePathNameQString, QString theBaseNameQString, QString theProviderQString)
00484 {
00485 mQGisIface->addVectorLayer( thePathNameQString, theBaseNameQString, theProviderQString);
00486 }
00487
00488
00490
00491
00492
00493
00494
00495
00496
00498
00499
00505
00506 QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
00507 {
00508 return new PIHMgis(theQGisAppPointer, theQgisInterfacePointer);
00509 }
00510
00511
00512 QGISEXTERN QString name()
00513 {
00514 return sName;
00515 }
00516
00517
00518 QGISEXTERN QString description()
00519 {
00520 return sDescription;
00521 }
00522
00523
00524 QGISEXTERN int type()
00525 {
00526 return sPluginType;
00527 }
00528
00529
00530 QGISEXTERN QString version()
00531 {
00532 return sPluginVersion;
00533 }
00534
00535
00536 QGISEXTERN void unload(QgisPlugin * thePluginPointer)
00537 {
00538 delete thePluginPointer;
00539 }