00001 #include "maintoolbar.h" 00002 #include <qmessagebox.h> 00003 #include <exception> 00004 00005 const char *MainToolbar::VIEW_FILE = "viewfile.vlb"; 00006 00007 MainToolbar::MainToolbar( ) { 00008 this->setCaption( "GLIMSView" ); 00009 00011 //added by EL April 13, 2006 00012 //to use a custom icon 00013 00014 QPixmap *pixmap = new QPixmap( "xpms/glimsV2.png", "PNG"); 00015 00016 this->setIcon(*pixmap); 00017 00018 //end addition by EL 00020 00021 mInit = true; 00022 mWorkspace = new QWorkspace( this ); 00023 00024 connect( mWorkspace, 00025 SIGNAL( windowActivated( QWidget * ) ), 00026 this, 00027 SLOT( setFocusWidget( QWidget * ) ) ); 00028 00029 this->setCentralWidget( mWorkspace ); 00030 00031 mHistDlg = new HistogramDlg( mWorkspace ); 00032 mHistDlg->setUser( &View::mGlbHistUser ); 00033 mHistDlg->hide(); 00034 00035 setGeometry( 20, 50, 800, 700 ); 00036 00037 mActGrp = new QActionGroup( NULL ); 00038 mFileToolbar = new QToolBar( this ); 00039 mNavToolbar = new QToolBar( this ); 00040 mEditToolbar = new QToolBar( this ); 00041 mToolToolbar = new QToolBar( this ); 00042 mStatBar = new QStatusBar( this ); 00043 00044 mLblLL = new QLabel( mStatBar ); 00045 mLblXY = new QLabel( mStatBar ); 00046 mLblLL->setMinimumWidth( 225 ); 00047 mLblXY->setMinimumWidth( 150 ); 00048 mLblLL->setMaximumWidth( 225 ); 00049 mLblXY->setMaximumWidth( 150 ); 00050 mStatBar->addWidget( mLblLL ); 00051 mStatBar->addWidget( mLblXY ); 00052 00053 mLblProjFile = new QLabel (mStatBar) ; 00054 mLblProjFile->setMaximumWidth( 2000 ); 00055 mLblProjFile->setMaximumWidth( 500 ); 00056 // mLblProjFile->setText("No Project Open") ; 00057 mStatBar->addWidget( mLblProjFile ); 00058 00059 buildMenu(); 00060 buildToolbar(); 00061 buildViews(); 00062 00063 mBandChooser = NULL; 00064 mProject = NULL; 00065 } 00066 00067 MainToolbar::~MainToolbar( ) { 00068 toXMLFile( "gvstate.xml", "GVState" ); 00069 } 00070 00071 void MainToolbar::buildViews( ) { 00072 if ( !fromXMLFile( "gvstate.xml", "GVState" ) ) 00073 buildDefaultViews(); 00074 00075 for ( int iview=0; iview < (int)mViewSet.size(); iview++ ) { 00076 connect( &mViewSet.getView( iview ), 00077 SIGNAL( mousePosChanged( View::MousePos, View::MousePos ) ), 00078 this, 00079 SLOT( setCoordLbls( View::MousePos, View::MousePos ) ) ); 00080 00081 connect( &View::mGlbHistUser, 00082 SIGNAL( ctableChanged() ), 00083 &mViewSet.getView( iview ), 00084 SLOT( ctableChanged() ) ); 00085 00086 mHistDlg->addHDS( &mViewSet.getView( iview ) ); 00087 } 00088 00089 View::mTool = View::PAN_HAND; 00090 } 00091 00092 void MainToolbar::buildDefaultViews( ) { 00093 View *v3 = new View( mWorkspace ); 00094 View *v2 = new View( mWorkspace ); 00095 View *v1 = new View( mWorkspace ); 00096 00097 v1->setEditable( false ); 00098 00099 ZoomAttr zattr; 00100 zattr.factor = 1.0; 00101 zattr.type = ZoomAttr::SCALE; 00102 v3->setZoomAttr( zattr ); 00103 00104 zattr.type = ZoomAttr::SCALE; 00105 zattr.factor = 2.0; 00106 v2->setZoomAttr( zattr ); 00107 00108 v1->setViewName( "Whole View" ); 00109 v2->setViewName( "Zoom View" ); 00110 v3->setViewName( "Fixed" ); 00111 00112 v1->setGeometry( 401, 0, 300, 300 ); 00113 v2->setGeometry( 401, 301, 300, 300 ); 00114 v3->setGeometry( 0, 0, 400, 600 ); 00115 // v1->parentWidget()->set 00116 00117 v1->setLinkParent( v3 ); 00118 v3->setLinkChild( v1 ); 00119 v3->setLinkParent( v2 ); 00120 v2->setLinkChild( v3 ); 00121 00122 mViewSet.addView( *v3 ); 00123 mViewSet.addView( *v2 ); 00124 mViewSet.addView( *v1 ); 00125 00126 mViewSet.setRSM( ImageFormat::SCALE_NN ); 00127 } 00128 00129 bool MainToolbar::fromXML( QDomElement &elem ) { 00130 int ivs; 00131 00132 Rect mainRect; 00133 ViewState viewset; 00134 View *view; 00135 QDomElement e; 00136 QDomNodeList nodelist; 00137 00138 nodelist = elem.elementsByTagName( "Rect" ); 00139 for ( unsigned int irect=0; irect < nodelist.count(); irect++ ) { 00140 e = nodelist.item( irect ).toElement(); 00141 std::string name = "Main"; 00142 if ( !name.compare( (const char*)e.attribute( "id" ) ) ) { 00143 if ( !mainRect.fromXML( e ) ) 00144 return false; 00145 break; 00146 } 00147 } 00148 00149 setGeometry( (int)mainRect.x, 00150 (int)mainRect.y, 00151 (int)mainRect.w, 00152 (int)mainRect.h ); 00153 00154 nodelist = elem.elementsByTagName( "ViewState" ); 00155 for ( int iview=0; iview < (int)nodelist.count(); iview++ ) { 00156 e = nodelist.item( iview ).toElement(); 00157 if ( !viewset.fromXML( e ) ) 00158 continue; 00159 00160 view = new View( mWorkspace ); 00161 view->getViewState() = viewset; 00162 mViewSet.addView( *view ); 00163 } 00164 00165 for ( ivs=0; ivs < (int)mViewSet.size(); ivs++ ) { 00166 // LINK THE CHILD 00167 for ( int ipv=0; ipv < (int)mViewSet.size(); ipv++ ) { 00168 ViewState &ipvs = mViewSet[ipv].getViewState(); 00169 ViewState &ivvs = mViewSet[ivs].getViewState(); 00170 if ( ipvs.mChildName == ivvs.mName ) { 00171 mViewSet[ivs].setLinkChild( &mViewSet[ipv] ); 00172 break; 00173 } 00174 } 00175 00176 // LINK THE PARENT 00177 for ( int icv=0; icv < (int)mViewSet.size(); icv++ ) { 00178 ViewState &icvs = mViewSet[icv].getViewState(); 00179 ViewState &ivvs = mViewSet[ivs].getViewState(); 00180 if ( icvs.mParentName == ivvs.mName ) { 00181 mViewSet[ivs].setLinkParent( &mViewSet[icv] ); 00182 break; 00183 } 00184 } 00185 } 00186 00187 for ( ivs=0; ivs < (int)mViewSet.size(); ivs++ ) { 00188 ViewState &vs = mViewSet[ivs].getViewState(); 00189 mViewSet[ivs].setGeometry( (int)vs.mGeom.x, 00190 (int)vs.mGeom.y, 00191 (int)vs.mGeom.w, 00192 (int)vs.mGeom.h ); 00193 mViewSet[ivs].loadCaption(); 00194 } 00195 00196 return true; 00197 } 00198 00199 bool MainToolbar::toXML( QDomDocument &doc, 00200 QDomElement &elem, 00201 std::string id ) { 00202 QDomElement base; 00203 base = createBaseTag( doc, elem, id, "GVViewState" ); 00204 00205 QRect r = geometry(); 00206 Rect mainRect; 00207 int nViews = (int)mViewSet.size(); 00208 00209 mainRect.x = r.x(); 00210 mainRect.y = r.y(); 00211 mainRect.w = r.width(); 00212 mainRect.h = r.height(); 00213 mainRect.toXML( doc, base, "Main" ); 00214 00215 for ( int iview=0; iview < nViews; iview++ ) { 00216 QRect pr = mViewSet[iview].parentWidget()->geometry(); 00217 QRect tr = mViewSet[iview].geometry(); 00218 00219 ViewState &vs = mViewSet[iview].getViewState(); 00220 vs.mGeom.x = pr.x(); 00221 vs.mGeom.y = pr.y(); 00222 #ifdef WIN32 00223 vs.mGeom.w = pr.width(); 00224 #else 00225 vs.mGeom.w = tr.width(); 00226 #endif 00227 vs.mGeom.h = tr.height(); 00228 00229 vs.toXML( doc, base ); 00230 } 00231 return true; 00232 } 00233 00234 void MainToolbar::buildMenu( ) { 00235 QAction *action = NULL ; 00236 QMenuBar *mb = this->menuBar(); 00237 00238 QPopupMenu *projectMenu = new QPopupMenu( mb ); 00239 mb->insertItem( tr("&Project"), projectMenu ); 00240 00241 QPopupMenu *imageMenu = new QPopupMenu( mb ); 00242 mb->insertItem( tr("&Image"), imageMenu ); 00243 00244 QPopupMenu *toolsMenu = new QPopupMenu( mb ); 00245 mb->insertItem( tr("&Tools"), toolsMenu ); 00246 00247 QPopupMenu *windowMenu = new QPopupMenu( mb ); 00248 mb->insertItem( tr("&Window"), windowMenu ); 00249 00250 QPopupMenu *helpMenu = new QPopupMenu( mb ); 00251 mb->insertItem( tr("&Help"), helpMenu ); 00252 00253 // ADD FILE MENU ITEMS 00254 action = new QAction( tr("Create New Project"), tr("Create &New Project"), 0, this ); 00255 action->addTo( projectMenu ); 00256 connect( action, SIGNAL( activated() ), this, SLOT( newProject() ) ); 00257 00258 action = new QAction( tr("Open Project"), tr("&Open Project"), 0, this ); 00259 action->addTo( projectMenu ); 00260 connect( action, SIGNAL( activated() ), this, SLOT( openProject() ) ); 00261 00262 action = new QAction( tr("Save Project"), tr("&Save Project"), 0, this ); 00263 action->addTo( projectMenu ); 00264 connect( action, SIGNAL( activated() ), this, SLOT( saveProject() ) ); 00265 00266 action = new QAction( tr("Save As"), tr("&Save As"), 0, this ); 00267 action->addTo( projectMenu ); 00268 connect( action, SIGNAL( activated() ), this, SLOT( saveProjectAs() ) ); 00269 00270 projectMenu->insertSeparator( 5 ); 00271 00272 QPopupMenu *importExportMenu = new QPopupMenu( projectMenu ); 00273 projectMenu->insertItem( tr("Import/Export" ), importExportMenu ); 00274 00275 action = new QAction( tr("Export GLIMS Shapefile"), tr("&Export GLIMS Shapefile"), 0, this ); 00276 action->addTo( importExportMenu ); 00277 connect( action, SIGNAL( activated() ), this, SLOT( exportGLIMSIngest() ) ); 00278 00279 action = new QAction( tr("Import GLIMS Ingest"), tr("&Import GLIMS Shapefile"), 0, this ); 00280 action->addTo( importExportMenu ); 00281 connect( action, SIGNAL( activated() ), this, SLOT( importGLIMSIngest() ) ); 00282 00283 00284 QPopupMenu *importShapefileMenu = new QPopupMenu( importExportMenu ); 00285 importExportMenu->insertItem( tr("Import Generic Shapefile" ), importShapefileMenu ); 00286 00287 action = new QAction( tr("Import Glacier IDs"), tr("&Import Glacier IDs"), 0, this ); 00288 action->addTo( importShapefileMenu ); 00289 connect( action, SIGNAL( activated() ), this, SLOT( importGIDsFromShapefile() ) ); 00290 00291 action = new QAction( tr("Import Segments"), tr("&Import Segments"), 0, this ); 00292 action->addTo( importShapefileMenu ); 00293 connect( action, SIGNAL( activated() ), this, SLOT( importSegmentsFromShapefile() ) ); 00294 00295 projectMenu->insertSeparator( 8 ); 00296 00297 action = new QAction( tr("Exit"), tr("&Exit"), 0, this ); 00298 action->addTo( projectMenu ); 00299 connect( action, SIGNAL( activated() ), this, SLOT( closeApp( ) ) ); 00300 00301 00302 action = new QAction( tr("Open Config"), tr("&Open Config"), 0, this ); 00303 action->addTo( toolsMenu ); 00304 connect( action, SIGNAL( activated() ), this, SLOT( openConfigDlg() ) ); 00305 00307 //Added by EL March 28, 2006 00308 //to add the menu option for the output of selected 00309 //shapes to a textfile. 00310 00311 action = new QAction( tr("Output to Spreadsheet"), tr("Output to &Spreadsheet"), 0, this ); 00312 action->addTo( toolsMenu ); 00313 connect( action, SIGNAL( activated() ), this, SLOT( openGtoSDlg() ) ); 00314 00315 action = new QAction( tr("Image Polygon Calculator"), tr("&Image Polygon Calculator"), 0, this ); 00316 action->addTo( toolsMenu ); 00317 connect( action, SIGNAL( activated() ), this, SLOT( openImgCalcDlg() ) ); 00318 00319 //End Added by EL 00321 00322 QPopupMenu *pluginMenu = new QPopupMenu( toolsMenu ); 00323 toolsMenu->insertItem( tr("&Additional Tools"), pluginMenu ); 00324 00325 mPlugSet = new PluginSet( mWorkspace, pluginMenu ); 00326 mPlugSet->hide(); 00327 00328 // ADD IMAGE MENU ITEMS 00329 action = new QAction( tr("Histogram"), tr("&Histogram"), 0, this ); 00330 action->addTo( imageMenu ); 00331 connect( action, SIGNAL( activated() ), this, SLOT( openHistDlg() ) ); 00332 00333 action = new QAction( tr("Band Selector"), tr("&Band Selector"), 0, this ); 00334 action->addTo( imageMenu ); 00335 connect( action, SIGNAL( activated() ), this, SLOT( openBandSel() ) ); 00336 00337 mMemBufAction = new QAction( tr("Memory Buffer"), tr("&Memory Buffer"), 00338 0, this, NULL, true ); 00339 mMemBufAction->addTo( imageMenu ); 00340 connect( mMemBufAction, SIGNAL( activated() ), this, SLOT( setMemBuf() ) ); 00341 00342 // RESAMPLE MENU 00343 QPopupMenu *resampleMenu = new QPopupMenu( imageMenu ); 00344 imageMenu->insertItem( tr("Resample" ), resampleMenu ); 00345 00346 QActionGroup *rsg = new QActionGroup( NULL ); 00347 00348 action = new QAction( tr("Nearest Neighbor"), tr("&Nearest Neighbor"), 0, this, NULL, true ); 00349 action->addTo( resampleMenu ); 00350 action->setOn( true ); 00351 connect( action, SIGNAL( activated() ), this, SLOT( setNN() ) ); 00352 rsg->insert( action ); 00353 00354 action = new QAction( tr("Bilinear"), tr("&Bilinear"), 0, this, NULL, true ); 00355 action->addTo( resampleMenu ); 00356 connect( action, SIGNAL( activated() ), this, SLOT( setBI() ) ); 00357 rsg->insert( action ); 00358 00359 /* 00360 action = new QAction( tr("Bicubic"), tr("&Bicubic"), 0, this, NULL, true ); 00361 action->addTo( resampleMenu ); 00362 connect( action, SIGNAL( activated() ), this, SLOT( setBC() ) ); 00363 rsg->add( action ); 00364 */ 00365 00366 // ADD WINDOW MENU ITEMS 00367 action = new QAction( tr("Tile"), tr("&Tile"), 0, this ); 00368 action->addTo( windowMenu ); 00369 connect( action, SIGNAL( activated() ), mWorkspace, SLOT( tile() ) ); 00370 00371 action = new QAction( tr("Cascade"), tr("&Cascade"), 0, this ); 00372 action->addTo( windowMenu ); 00373 connect( action, SIGNAL( activated() ), mWorkspace, SLOT( cascade() ) ); 00374 00375 windowMenu->insertSeparator(); 00376 00377 mViewActGroup = new QActionGroup( windowMenu, "Views", true ); 00378 mViewSet.setActGrp( mViewActGroup ); 00379 mViewSet.setMenuParent( windowMenu ); 00380 00381 00382 // ADD HELP MENU ITEMS 00383 action = new QAction( tr("About"), tr("&About"), 0, this ); 00384 action->addTo( helpMenu ); 00385 connect( action, SIGNAL( activated() ), this, SLOT( openAbout() ) ); 00386 00387 action = new QAction( tr("Users Guide"), tr("&Users Guide"), 0, this ); 00388 action->addTo( helpMenu ); 00389 connect( action, SIGNAL( activated() ), this, SLOT( openManual() ) ); 00390 } 00391 00392 void MainToolbar::buildToolbar( ) { 00393 char *xpmFNameSet[] = 00394 { 00395 "xpms/hand.xpm", 00396 "xpms/zoomin.xpm", 00397 "xpms/zoomout.xpm", 00398 "xpms/configtool.png", 00399 "xpms/linetool.xpm", 00400 "xpms/gid.png", 00401 "xpms/seltool.xpm", 00402 "xpms/joinline.png", 00403 "xpms/splitline.png", 00404 "xpms/contline.xpm", 00405 "xpms/fileopen.xpm", 00406 "xpms/filesave.xpm", 00407 "xpms/validate.png" 00408 }; 00409 00410 QPixmap xpmset[13]; 00411 for ( int i=0; i <= 12; i++ ) { 00412 QImage img( xpmFNameSet[i] ); 00413 xpmset[i].convertFromImage( img.smoothScale( 22, 22 ) ); 00414 } 00415 00416 setToolBarsMovable (true) ; 00417 QToolBar *tb_file = mFileToolbar; 00418 QToolBar *tb_nav = mNavToolbar; 00419 QToolBar *tb_edit = mEditToolbar; 00420 QToolBar *tb_tool = mToolToolbar; 00421 QAction *action; 00422 00423 // ********************************* 00424 // FILE TOOLBAR 00425 // open project 00426 action = new QAction( "", QIconSet( xpmset[10] ), "", 0, this, 0, false ); 00427 action->addTo( tb_file ); 00428 connect( action, SIGNAL( activated() ), this, SLOT( openProject() ) ); 00429 action->setToolTip( "Open Project" ); 00430 00431 // save project 00432 action = new QAction( "", QIconSet( xpmset[11] ), "", 0, this, 0, false ); 00433 action->addTo( tb_file ); 00434 connect( action, SIGNAL( activated() ), this, SLOT( saveProject() ) ); 00435 action->setToolTip( "Save Project" ); 00436 00437 // ********************************* 00438 // NAVIGATION TOOLBAR 00439 // pan 00440 action = new QAction( "", QIconSet( xpmset[0] ), "", 0, this, 0, true ); 00441 action->addTo( tb_nav ); 00442 mActGrp->insert( action ); 00443 connect( action, SIGNAL( activated() ), this, SLOT( setPanHand() ) ); 00444 action->setToolTip( "Pan Tool" ); 00445 00446 // zoom in 00447 action = new QAction( "", QIconSet( xpmset[1] ), "", 0, this, 0, true ); 00448 action->addTo( tb_nav ); 00449 mActGrp->insert( action ); 00450 connect( action, SIGNAL( activated() ), this, SLOT( setZoomInInc() ) ); 00451 action->setToolTip( "Zoom In" ); 00452 00453 // zoom out 00454 action = new QAction( "", QIconSet( xpmset[2] ), "", 0, this, 0, true ); 00455 action->addTo( tb_nav ); 00456 mActGrp->insert( action ); 00457 connect( action, SIGNAL( activated() ), this, SLOT( setZoomOutInc() ) ); 00458 action->setToolTip( "Zoom Out" ); 00459 00460 00461 // **************** 00462 // TOOL TOOLBAR 00463 // Selection tool 00464 action = new QAction( "", QIconSet( xpmset[6] ), "", 0, this, 0, true ); 00465 action->addTo( tb_tool ); 00466 connect( action, SIGNAL( activated() ), this, SLOT( setSelTool() ) ); 00467 mActGrp->insert( action ); 00468 action->setToolTip( "Selection Tool" ); 00469 00470 // GLIMS configuration tool 00471 mOpenConfigAction = new QAction( "", QIconSet( xpmset[3] ), "", 0, this, 0, false ); 00472 mOpenConfigAction->addTo( tb_tool ); 00473 mOpenConfigAction->setToolTip( "GLIMS Config Tool" ); 00474 00475 // Vector layer tool 00476 /* 00477 mOpenVectorLayerAction = new QAction( "", QIconSet( xpmset[3] ), "", 0, this, 0, false ); 00478 mOpenVectorLayerAction->addTo( tb_tool ); 00479 mOpenVectorLayerAction->setToolTip( "Vector Layers" ); 00480 */ 00481 00482 // Glacier ID tool 00483 action = new QAction( "", QIconSet( xpmset[5] ), "", 0, this, 0, true ); 00484 action->addTo( tb_tool ); 00485 connect( action, SIGNAL( activated() ), this, SLOT( setGIDTool() ) ); 00486 mActGrp->insert( action ); 00487 action->setToolTip( "Glacer ID Tool" ); 00488 00489 // Validate project 00490 mValidateProject = new QAction( "", QIconSet( xpmset[12] ), "", 0, this, 0, false ); 00491 mValidateProject->addTo( tb_tool ); 00492 mValidateProject->setToolTip( "Check Project Validation" ); 00493 00494 00495 // ******************************* 00496 // LINE EDITOR TOOLBAR 00497 // line tool 00498 action = new QAction( "", QIconSet( xpmset[4] ), "", 0, this, 0, true ); 00499 action->addTo( tb_edit ); 00500 connect( action, SIGNAL( activated() ), this, SLOT( setLineTool() ) ); 00501 mActGrp->insert( action ); 00502 action->setToolTip( "Line Tool" ); 00503 00504 // split line 00505 mBreakAction = new QAction( "", QIconSet( xpmset[8] ), "", 0, this, 0, false ); 00506 mBreakAction->addTo( tb_edit ); 00507 mBreakAction->setToolTip( "Split Line" ); 00508 00509 // join line 00510 mJoinAction = new QAction( "", QIconSet( xpmset[7] ), "", 0, this, 0, false ); 00511 mJoinAction->addTo( tb_edit ); 00512 mJoinAction->setToolTip( "Join Line" ); 00513 00514 /* 00515 mContAction = new QAction( "", QIconSet( xpmset[9] ), "", 0, this, 0, false ); 00516 mContAction->addTo( tb ); 00517 */ 00518 00519 } 00520 00521 void MainToolbar::newProject( ) { 00522 GLIMSProject *proj = new GLIMSProject( mWorkspace, &mViewSet ); 00523 proj->create(); 00524 if ( proj->isOpen() ) { 00525 setupProj( proj ); 00526 setProjectFileName ("New Project") ; 00527 } 00528 else { 00529 delete proj; 00530 } 00531 } 00532 00533 void MainToolbar::openProject( ) { 00534 GLIMSProject *proj = new GLIMSProject( mWorkspace, &mViewSet ); 00535 if ( !(proj->open()) ) { 00536 // FOR SOME REASON I AM NOT ABLE TO DELETE THIS IN WINDOWS??? (Dan) 00537 // glimsview crashes when the following line is uncommented and 00538 // a Open Project file chooser window is cancelled (deborah) 00539 // delete proj; 00540 return; 00541 } 00542 00543 setupProj( proj ); 00544 setProjectFileName ((proj->getFileName()).c_str()) ; 00545 } 00546 00547 void MainToolbar::setupProj( GLIMSProject *proj ) { 00548 int i; 00549 if ( !proj ) return; 00550 00551 mViewSet.initViews(); 00552 00553 if ( mProject ) delete mProject; 00554 00555 if ( mBandChooser ) delete mBandChooser; 00556 00557 Image * theImage = proj->getImage() ; 00558 00559 mBandChooser = new BandChooserDlg( mWorkspace, theImage ); 00560 00561 mBandChooser->show(); 00562 00563 ImageState theState = proj->getImage()->getImageState() ; 00564 00565 for ( i=0; i < (int)mViewSet.size(); i++ ) { 00566 Image *img = proj->getImage(); 00567 View &v = mViewSet.getView( i ); 00568 v.setImage( img ); 00569 mViewSet.getView( i ).setVectorLayerSet( proj->getVectorLayerSet() ); 00570 } 00571 00572 connect( mBandChooser, 00573 SIGNAL( selBandsChanged() ), 00574 proj->getVectorLayerSet(), 00575 SLOT( transformDatasets() ) ); 00576 00577 connect( mBandChooser, 00578 SIGNAL( selBandsChanged() ), 00579 &mViewSet, 00580 SLOT( resetViews() ) ); 00581 00582 for ( i=0; i < (int)mViewSet.size(); i++ ) { 00583 proj->getVectorEditor()->addView( &mViewSet.getView(i) ); 00584 } 00585 00586 connect( mBreakAction, 00587 SIGNAL( activated() ), 00588 proj->getVectorEditor(), 00589 SLOT( breakLine() ) ); 00590 00591 connect( mJoinAction, 00592 SIGNAL( activated() ), 00593 proj->getVectorEditor(), 00594 SLOT( joinLine() ) ); 00595 00596 connect( mOpenConfigAction, 00597 SIGNAL( activated() ), 00598 proj, 00599 SLOT( openConfigDlg() ) ); 00600 00601 connect( mValidateProject, 00602 SIGNAL( activated() ), 00603 proj, 00604 SLOT( validate() ) ); 00605 00609 /* 00610 connect( mOpenVectorLayerAction, 00611 SIGNAL( activated() ), 00612 proj, 00613 SLOT( openVectorLayerDlg() ) ); 00614 */ 00615 00616 mProject = proj; 00617 00618 // set the current software version date so it can be written 00619 // to the project file when saved. 00620 mProject->setCurrentVersion(AboutDlg::GV_DATE) ; 00621 00622 mMemBufAction->setOn( false ); 00623 00624 mPlugSet->setProj( mProject ); 00625 } 00626 00627 void MainToolbar::closeApp( ) { 00628 closeEvent( NULL ); 00629 } 00630 00631 void MainToolbar::closeProject( ) { 00632 setProjectFileName ("Project closed") ; 00633 } 00634 00635 void MainToolbar::print( ) {} 00636 00637 void MainToolbar::openBandSel( ) { 00638 if ( mBandChooser ) { 00639 mBandChooser->show(); 00640 mBandChooser->setFocus(); 00641 } 00642 } 00643 00644 void MainToolbar::openHistDlg( ) { 00645 mHistDlg->hide(); 00646 mHistDlg->show(); 00647 mHistDlg->setFocus(); 00648 } 00649 00650 void MainToolbar::repaintViews( bool ) { 00651 mViewSet.repaintViews(); 00652 } 00653 00654 void MainToolbar::setPanHand( ) { 00655 View::mTool = View::PAN_HAND; 00656 } 00657 00658 void MainToolbar::setZoomInInc( ) { 00659 View::mTool = View::ZOOMIN_INC; 00660 } 00661 00662 void MainToolbar::setZoomOutInc( ) { 00663 View::mTool = View::ZOOMOUT_INC; 00664 } 00665 00666 void MainToolbar::setLineTool( ) { 00667 View::mTool = View::LINE; 00668 if ( mProject ) 00669 mProject->getVectorLayerSet()->setActiveLayer( 0 ); 00670 } 00671 00672 void MainToolbar::setSelTool( ) { 00673 View::mTool = View::SELECTION; 00674 } 00675 00676 void MainToolbar::setGIDTool( ) { 00677 View::mTool = View::GLACIER_ID; 00678 if ( mProject ) 00679 mProject->getVectorLayerSet()->setActiveLayer( 1 ); 00680 } 00681 00682 void MainToolbar::setProjectFileName (QString fn) { 00683 mLblProjFile->setText(fn) ; 00684 } 00685 00686 void MainToolbar::setCoordLbls( View::MousePos ll, View::MousePos xy ) { 00687 char buf[100]; 00688 00689 if ( fabs( ll.x ) < 0.000001 || fabs( ll.x ) > 999.0 ) { 00690 if (ll.x < 0) { 00691 ll.x += 360.0 ; 00692 } 00693 ll.x = 0.0; 00694 } 00695 if ( fabs( ll.y ) < 0.000001 || fabs( ll.y ) > 999.0 ) { 00696 ll.y = 0.0; 00697 } 00698 00699 sprintf( buf, "%8.5f Lon X %7.5f Lat", ll.x, ll.y ); 00700 mLblLL->setText( buf ); 00701 00702 sprintf( buf, "%d X %d", (int)xy.x, (int)xy.y ); 00703 mLblXY->setText( buf ); 00704 } 00705 00706 void MainToolbar::setFocusWidget( QWidget *w ) { 00707 w->setFocus(); 00708 } 00709 00710 void MainToolbar::saveProject( ) { 00711 if ( mProject ) 00712 mProject->save(); 00713 } 00714 00715 void MainToolbar::saveProjectAs( ) { 00716 if ( mProject ) 00717 mProject->saveAs(); 00718 } 00719 00720 void MainToolbar::openConfigDlg( ) { 00721 if ( mProject ) 00722 mProject->openConfigDlg(); 00723 } 00724 00725 /* void openGtoSDlg() 00726 * added by EL 00727 */ 00728 void MainToolbar::openGtoSDlg(){ 00729 if( mProject ) { 00730 SpreadsheetDialog *ssDlg = new SpreadsheetDialog ( mProject ); 00731 ssDlg->show(); 00732 ssDlg->setFocus(); 00733 00734 } 00735 00736 } 00737 00738 /* void openImgCalcDlg() 00739 * added by EL 00740 */ 00741 void MainToolbar::openImgCalcDlg(){ 00742 if( mProject ) { 00743 imgCalcDlg = new ImageCalculatorDialog ( mProject ); 00744 imgCalcDlg->show(); 00745 imgCalcDlg->setFocus(); 00746 connect( imgCalcDlg, SIGNAL( imgCalcComplete() ), imgCalcDlg, SLOT(close() ) ) ; 00747 connect( imgCalcDlg, SIGNAL( imgCalcComplete() ), this, SLOT(imgCalcEnd()) ) ; 00748 } 00749 } 00750 00751 void MainToolbar::imgCalcEnd() { 00752 } 00753 00754 void MainToolbar::importGLIMSIngest( ) { 00755 GLIMSProject *proj = new GLIMSProject( mWorkspace, &mViewSet ); 00756 00757 // start ingest by getting the base image info from the exported shapefile 00758 QString loc = proj->importGLIMSIngestImageInfo () ; 00759 00760 // if ( proj->isOpen() ) { 00761 setupProj( proj ); 00762 // } 00763 00764 if (loc != "") { 00765 // set up project to finish importing GLIMS shapefiles when the band chooser has 00766 // loaded the image data 00767 connect (mBandChooser, SIGNAL(selBandsChanged()), mProject, SLOT(importGLIMSIngestData())) ; 00768 // setup toolbar to disconnect previous signal-slot when the project is done ingesting data 00769 connect (mProject, SIGNAL(finishedIngestion()), this, SLOT(ingestEnd())) ; 00770 } 00771 } 00772 00773 void MainToolbar::exportGLIMSIngest( ) { 00774 if ( mProject ) 00775 mProject->exportGLIMSIngest(); 00776 } 00777 00778 void MainToolbar::importSegmentsFromShapefile( ) { 00779 if ( mProject ) 00780 mProject->importSegmentsFromShapefile(); 00781 else 00782 QMessageBox::information( NULL, 00783 "Image Not Open", 00784 "You must have an image open in order to import shapefiles" ); 00785 } 00786 00787 void MainToolbar::importGIDsFromShapefile( ) { 00788 if ( mProject ) 00789 mProject->importGIDsFromShapefile(); 00790 else 00791 QMessageBox::information( NULL, 00792 "Image Not Open", 00793 "You must have an image open in order to import shapefiles" ); 00794 } 00795 00796 void MainToolbar::setMemBuf( ) { 00797 if ( mMemBufAction->isOn() ) { 00798 if ( !mProject ) { 00799 mMemBufAction->setOn( false ); 00800 return; 00801 } 00802 00803 mProject->getImage()->setMemBuf( true ); 00804 } else { 00805 if ( !mProject ) 00806 return; 00807 mProject->getImage()->setMemBuf( false ); 00808 } 00809 } 00810 00811 void MainToolbar::setNN( ) { 00812 mViewSet.setRSM( ImageFormat::SCALE_NN ); 00813 } 00814 00815 void MainToolbar::setBI( ) { 00816 mViewSet.setRSM( ImageFormat::SCALE_BI ); 00817 } 00818 00819 void MainToolbar::setBC( ) { 00820 mViewSet.setRSM( ImageFormat::SCALE_BC ); 00821 } 00822 00823 void MainToolbar::openAbout( ) { 00824 AboutDlg *abdlg = new AboutDlg; 00825 abdlg->exec(); 00826 } 00827 00828 void MainToolbar::openManual( ) { 00829 QMimeSourceFactory::defaultFactory()->addFilePath("."); 00830 QTextBrowser *tb = new QTextBrowser(); 00831 tb->setVScrollBarMode(QScrollView::Auto) ; 00832 tb->setCaption( "GLIMSView User's Guide" ); 00833 tb->setSource( "doc/GLIMSView_UsersGuide.html" ); 00834 tb->show(); 00835 tb->resize( 850, 600 ); 00836 } 00837 00838 00839 void MainToolbar::ingestEnd () { 00840 disconnect (mBandChooser, SIGNAL(selBandsChanged()), mProject, SLOT(importGLIMSIngestData())) ; 00841 } 00842 00843 00844 TraceLog glimslog ; 00845 00846 int main( int argc, char **argv ) { 00847 try { 00848 QApplication app( argc, argv ); 00849 MainToolbar mt ; 00850 app.setMainWidget( &mt ); 00851 mt.show(); 00852 return app.exec(); 00853 } 00854 catch (std::exception const &se) { 00855 QMessageBox::information( 0, "Bomb", "suck air" ); 00856 } 00857 00858 00859 } 00860
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |