00001 /* 00002 * IMPLENTATION OF CLASS: 00003 * GlacierIDDlg 00004 * 00005 * glacieriddlg.cpp 00006 */ 00007 00008 // LOCAL 00009 #include "glacieriddlg.h" 00010 00011 00012 /* 00013 * CONSTRUCTOR: 00014 * GlacierIDDlg 00015 * 00016 * PARAMS: 00017 * lt PTR to associated LineTool 00018 * 00019 * PURPOSE: 00020 * Initializes the form. 00021 */ 00022 00023 GlacierIDDlg::GlacierIDDlg( GLIMSGIDData &gds ) 00024 : QDialog( NULL, NULL, true ), 00025 mGIDData( gds ) { 00026 00027 // LABEL WINDOW 00028 setCaption( "Glacier ID Editor" ); 00029 00030 miGID = -1; 00031 initialize( ); 00032 } 00033 00034 00035 /* 00036 * 00037 * 00038 * CONSTRUCTOR: 00039 * GlacierIDDlg 00040 * 00041 * PARAMS: 00042 * 00043 * PURPOSE: 00044 * Initializes the form. This constructor takes an index 00045 * of a GID and fills the form with this GID for editing. 00046 * 00047 * 00048 * 00049 */ 00050 GlacierIDDlg::GlacierIDDlg( GLIMSGIDData &gds, int iGID ) : 00051 QDialog( NULL, NULL, true ), 00052 mGIDData( gds ) { 00053 miGID = iGID; 00054 initialize(); 00055 loadGID(); 00056 } 00057 00058 00059 /* 00060 * 00061 * 00062 * DESTRUCTOR: 00063 * ~GlacierIDDlg 00064 * 00065 * PARAMS: 00066 * 00067 * PURPOSE: 00068 * None 00069 * 00070 * 00071 * 00072 */ 00073 GlacierIDDlg::~GlacierIDDlg( ) { 00074 00075 } 00076 00077 00078 /* 00079 * 00080 * 00081 * FUNCTION: 00082 * initialize 00083 * 00084 * PARAMS: 00085 * 00086 * 00087 * PURPOSE: 00088 * This function initializes the form UI. 00089 * 00090 * 00091 * 00092 */ 00093 void GlacierIDDlg::initialize( ) { 00094 // MAIN LAYOUT 00095 QVBoxLayout *vboxl = new QVBoxLayout( this ); 00096 vboxl->setAutoAdd( true ); 00097 00098 QVBox *mainVB; 00099 QLabel *lbl; 00100 QVBox *vbox; 00101 QHBox *hbox; 00102 QGrid *grid; 00103 00104 QPushButton *butAdd; 00105 QPushButton *butClose; 00106 00107 // SET MAIN CONTAINER 00108 mainVB = new QVBox( this ); 00109 mainVB->setMargin( 8 ); 00110 00111 // FIRST SECTION GRID SPACE 00112 grid = new QGrid( 4, mainVB ); 00113 00114 // ADD LAT/LON FIELDS 00115 lbl = new QLabel( "Lat: ", grid ); 00116 mtxtLat = new QLineEdit( grid ); 00117 lbl = new QLabel( " Lon: ", grid ); 00118 mtxtLon = new QLineEdit( grid ); 00119 00120 // ADD NAME & WGMS FIELDS 00121 lbl = new QLabel( "Name: ", grid ); 00122 mtxtName = new QLineEdit( grid ); 00123 lbl = new QLabel( " WGMS ID: ", grid ); 00124 mtxtWGMSID = new QLineEdit( grid ); 00125 00126 // ADD LOCAL & PARENT ID FIELDS 00127 lbl = new QLabel( "Local ID: ", grid ); 00128 mtxtLocalID = new QLineEdit( grid ); 00129 lbl = new QLabel( " Parent ID: ", grid ); 00130 mtxtParentIMID = new QLineEdit( grid ); 00131 00132 grid = new QGrid( 2, mainVB ); 00133 00134 // ADD PRIMARY CLASSIFICATION & FORM FIELDS 00135 vbox = new QVBox( grid ); 00136 lbl = new QLabel( "Primary Classification:", vbox ); 00137 mcmbPrimCsfn = new QComboBox( vbox ); 00138 00139 vbox = new QVBox( grid ); 00140 lbl = new QLabel( "Form:", vbox ); 00141 mcmbForm = new QComboBox( vbox ); 00142 00143 // ADD F & L CHARACTERISTICS FIELDS 00144 vbox = new QVBox( grid ); 00145 lbl = new QLabel( "Frontal Characteristics:", vbox ); 00146 mcmbFrntChar = new QComboBox( vbox ); 00147 00148 vbox = new QVBox( grid ); 00149 lbl = new QLabel( "Longitudinal Characteristics:", vbox ); 00150 mcmbLonChar = new QComboBox( vbox ); 00151 00152 // ADD DMS & TONGUE ACT FIELDS 00153 vbox = new QVBox( grid ); 00154 lbl = new QLabel( "Dominant Mass Source:", vbox ); 00155 mcmbDomMassSrc = new QComboBox( vbox ); 00156 00157 vbox = new QVBox( grid ); 00158 lbl = new QLabel( "Tongue Activity:", vbox ); 00159 mcmbTongueAct = new QComboBox( vbox ); 00160 00161 // ADD GLACIER WIDTH/LENGTH/AREA FIELDS 00162 hbox = new QHBox( mainVB ); 00163 grid = new QGrid( 2, hbox ); 00164 lbl = new QLabel( "Width (m): ", grid ); 00165 mtxtWidth = new QLineEdit( grid ); 00166 grid = new QGrid( 2, hbox ); 00167 lbl = new QLabel( "Length (m): ", grid ); 00168 mtxtLength = new QLineEdit( grid ); 00169 grid = new QGrid( 2, hbox ); 00170 lbl = new QLabel( "Area (km^2): ", grid ); 00171 mtxtArea = new QLineEdit( grid ); 00172 00173 // ADD GLACIER ABZONE AREA, SPEED, ELA FIELDS 00174 hbox = new QHBox( mainVB ); 00175 grid = new QGrid( 2, hbox ); 00176 lbl = new QLabel( "Abzone Area (km^2): ", grid ); 00177 mtxtAbzoneArea = new QLineEdit( grid ); 00178 grid = new QGrid( 2, hbox ); 00179 lbl = new QLabel( "Speed (m/a): ", grid ); 00180 mtxtSpeed = new QLineEdit( grid ); 00181 grid = new QGrid( 2, hbox ); 00182 lbl = new QLabel( "ELA: ", grid ); 00183 mtxtELA = new QLineEdit( grid ); 00184 00185 // ADD ELA DESCRIPTION FIELD 00186 vbox = new QVBox( mainVB ); 00187 lbl = new QLabel( "ELA Description:", vbox ); 00188 mtxtELADesc = new QLineEdit( vbox ); 00189 00190 // ADD SNOWLINE ELEVATION FIELD 00191 grid = new QGrid( 2, mainVB ); 00192 lbl = new QLabel( "Snowline Elevation (m): ", grid ); 00193 mtxtSnowLineElev = new QLineEdit( grid ); 00194 00195 // ADD RECORD STATUS FIELD 00196 //grid = new QGrid( 2, mainVB ); 00197 //lbl = new QLabel( "Record Status: ", grid ); 00198 00199 // ADD BUTTONS 00200 hbox = new QHBox( mainVB ); 00201 if ( miGID == -1 ) 00202 butAdd = new QPushButton( "Add", hbox ); 00203 else 00204 butAdd = new QPushButton( "Update", hbox ); 00205 00206 butClose = new QPushButton( "Cancel", hbox ); 00207 00208 // CONNECT THE BUTTONS TO EVENT HANDLERS 00209 connect( butAdd, SIGNAL( clicked() ), this, SLOT( addClicked() ) ); 00210 connect( butClose, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) ); 00211 00212 // LOAD VALIDS 00213 loadValids(); 00214 00215 } 00216 00217 00218 00219 /* 00220 * 00221 * 00222 * FUNCTION: 00223 * loadGID 00224 * 00225 * PARAMS: 00226 * 00227 * 00228 * PURPOSE: 00229 * Fill the form with selected GID 00230 * 00231 * 00232 * 00233 */ 00234 void GlacierIDDlg::loadGID( ) { 00235 char buf[50]; // STRING BUFFER 00236 GlacierIDDef &gid = mGIDData.getDefSet()[miGID]; 00237 00238 // ----------------------------------------------------------- 00239 // LOAD THE FORM WITH DATA FROM GID 00240 sprintf( buf, "%3.4f", gid.mLat ); 00241 mtxtLat->setText( buf ); 00242 00243 sprintf( buf, "%3.4f", gid.mLon ); 00244 mtxtLon->setText( buf ); 00245 00246 mtxtName->setText( gid.mName.c_str() ); 00247 mtxtWGMSID->setText( gid.mWGMSID.c_str() ); 00248 mtxtLocalID->setText( gid.mLocalID.c_str() ); 00249 mtxtParentIMID->setText( gid.mParentID.c_str() ); 00250 00251 00252 00253 int setCur = 0 ; 00254 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbPrimCsfn, gid.mPrimCsfn) ; 00255 mcmbPrimCsfn->setCurrentItem( setCur ); 00256 00257 setCur = 0 ; 00258 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbForm, gid.mForm) ; 00259 mcmbForm->setCurrentItem( setCur ); 00260 00261 setCur = 0 ; 00262 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbFrntChar, gid.mFChar) ; 00263 mcmbFrntChar->setCurrentItem( setCur ); 00264 00265 setCur = 0 ; 00266 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbLonChar, gid.mLChar) ; 00267 mcmbLonChar->setCurrentItem( setCur ); 00268 00269 setCur = 0 ; 00270 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbDomMassSrc, gid.mDomMassSrc) ; 00271 mcmbDomMassSrc->setCurrentItem( setCur ); 00272 00273 setCur = 0 ; 00274 setCur = GLIMSGlobals::getNdxOfID(GLIMSGlobals::mGlbTongueAct, gid.mTongueAct) ; 00275 mcmbTongueAct->setCurrentItem( setCur ); 00276 00277 00278 00279 00280 sprintf( buf, "%3.2f", gid.mWidth ); 00281 mtxtWidth->setText( buf ); 00282 00283 sprintf( buf, "%3.2f", gid.mLength ); 00284 mtxtLength->setText( buf ); 00285 00286 sprintf( buf, "%3.2f", gid.mArea ); 00287 mtxtArea->setText( buf ); 00288 00289 sprintf( buf, "%3.2f", gid.mAbzoneArea ); 00290 mtxtAbzoneArea->setText( buf ); 00291 00292 sprintf( buf, "%3.2f", gid.mSpeed ); 00293 mtxtSpeed->setText( buf ); 00294 00295 sprintf( buf, "%3.2f", gid.mELA ); 00296 mtxtELA->setText( buf ); 00297 00298 sprintf( buf, "%3.2f", gid.mSnowLineElev ); 00299 mtxtSnowLineElev->setText( buf ); 00300 00301 mtxtELADesc->setText( gid.mELADesc.c_str() ); 00302 // ----------------------------------------------------------- 00303 } 00304 00305 00306 /* 00307 * 00308 * 00309 * FUNCTION: 00310 * loadValids 00311 * 00312 * PARAMS: 00313 * 00314 * 00315 * PURPOSE: 00316 * This uses the valids available from LineTool for these 00317 * combo boxes. 00318 * 00319 * 00320 * 00321 */ 00322 void GlacierIDDlg::loadValids( ) { 00323 unsigned int i=0; 00324 00325 // ----------------------------------------------------------- 00326 // LOAD THE VALIDS INTO THE COMBO BOXES 00327 for ( i = 0; i < GLIMSGlobals::mGlbPrimCsfn.size(); i++ ) 00328 mcmbPrimCsfn->insertItem( GLIMSGlobals::mGlbPrimCsfn[i].value.c_str() ); 00329 00330 for ( i = 0; i < GLIMSGlobals::mGlbForm.size(); i++ ) 00331 mcmbForm->insertItem( GLIMSGlobals::mGlbForm[i].value.c_str() ); 00332 00333 for ( i = 0; i < GLIMSGlobals::mGlbFrntChar.size(); i++ ) 00334 mcmbFrntChar->insertItem( GLIMSGlobals::mGlbFrntChar[i].value.c_str() ); 00335 00336 for ( i = 0; i < GLIMSGlobals::mGlbLonChar.size(); i++ ) 00337 mcmbLonChar->insertItem( GLIMSGlobals::mGlbLonChar[i].value.c_str() ); 00338 00339 for ( i = 0; i < GLIMSGlobals::mGlbDomMassSrc.size(); i++ ) 00340 mcmbDomMassSrc->insertItem( GLIMSGlobals::mGlbDomMassSrc[i].value.c_str() ); 00341 00342 for ( i = 0; i < GLIMSGlobals::mGlbTongueAct.size(); i++ ) 00343 mcmbTongueAct->insertItem( GLIMSGlobals::mGlbTongueAct[i].value.c_str() ); 00344 // ----------------------------------------------------------- 00345 } 00346 00347 00348 /* 00349 * 00350 * 00351 * SLOT: 00352 * addClicked 00353 * 00354 * PARAMS: 00355 * 00356 * 00357 * PURPOSE: 00358 * Event handler for the ADD button. This will capture 00359 * the data in the form and fill a new GID with it. Then 00360 * either add or overwrite to the GID set in LineTool. 00361 * 00362 * 00363 * 00364 */ 00365 void GlacierIDDlg::addClicked( ) { 00366 GlacierIDDef gid; 00367 00368 // ----------------------------------------------------------- 00369 // CAPTURE THE FORM DATA & FILL gid 00370 gid.mLat = atof((const char*)mtxtLat->text()); 00371 gid.mLon = atof((const char*)mtxtLon->text()); 00372 gid.mName = (const char*)mtxtName->text(); 00373 gid.mWGMSID = (const char*)mtxtWGMSID->text(); 00374 gid.mLocalID = (const char*)mtxtLocalID->text(); 00375 gid.mParentID = (const char*)mtxtParentIMID->text(); 00376 00377 gid.mPrimCsfn = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbPrimCsfn, (mcmbPrimCsfn->currentText()).ascii()) ; 00378 gid.mForm = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbForm, (mcmbForm->currentText()).ascii()) ; 00379 gid.mFChar = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbFrntChar, (mcmbFrntChar->currentText()).ascii()) ; 00380 gid.mLChar = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbLonChar, (mcmbLonChar->currentText()).ascii()) ; 00381 gid.mDomMassSrc = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbDomMassSrc, (mcmbDomMassSrc->currentText()).ascii()) ; 00382 gid.mTongueAct = GLIMSGlobals::getIntIDOf(GLIMSGlobals::mGlbTongueAct, (mcmbTongueAct->currentText()).ascii()) ; 00383 00384 00385 gid.mWidth = atof( (const char*)mtxtWidth->text() ); 00386 gid.mLength = atof( (const char*)mtxtLength->text() ); 00387 gid.mArea = atof( (const char*)mtxtArea->text() ); 00388 gid.mAbzoneArea = atof( (const char*)mtxtAbzoneArea->text() ); 00389 gid.mSpeed = atof( (const char*)mtxtSpeed->text() ); 00390 gid.mELA = atof( (const char*)mtxtELA->text() ); 00391 gid.mELADesc = (const char*)mtxtELADesc->text(); 00392 gid.mSnowLineElev = atof( (const char*)mtxtSnowLineElev->text() ); 00393 // ----------------------------------------------------------- 00394 00395 // ----------------------------------------------------------- 00396 // UPDATE THE LINETOOL GLACIER ID SET 00397 if ( miGID == -1 ) 00398 mGIDData.getDefSet().push_back( gid ); 00399 else 00400 mGIDData.getDefSet()[miGID] = gid; 00401 // ----------------------------------------------------------- 00402 00403 // RELOAD GlacierConfigDlg 00404 emit gidSetChanged(); 00405 00406 // CLOSE THIS FORM 00407 close(); 00408 } 00409 00410 00411 00412 /* 00413 * 00414 * 00415 * SLOT: 00416 * cancelClicked 00417 * 00418 * PARAMS: 00419 * 00420 * 00421 * PURPOSE: 00422 * Event handler for the CANCEL button. 00423 * 00424 * 00425 * 00426 */ 00427 void GlacierIDDlg::cancelClicked( ) { 00428 // CLOSE THIS FORM 00429 close(); 00430 } 00431 00432 00433 00434 /* 00435 * 00436 * 00437 * SLOT: 00438 * keyPressEvent 00439 * 00440 * PARAMS: 00441 * 00442 * 00443 * PURPOSE: 00444 * Event handler for the key press event. This routine 00445 * allows the user to capture lat lon from mouse coords 00446 * of the views while this window is focused. 00447 * 00448 * 00449 * 00450 */ 00451 void GlacierIDDlg::keyPressEvent( QKeyEvent * ) { 00452 /* 00453 char buf[100]; // STRING BUFFER 00454 00455 // ----------------------------------------------------------- 00456 // PROCESS KEY 00457 switch( ke->key() ) 00458 { 00459 // HANDLE F1 PRESSED 00460 case QKeyEvent::Key_F1: 00461 sprintf( buf, "%3.4f", mLineTool->mLat ); 00462 mtxtLat->setText( buf ); 00463 sprintf( buf, "%3.4f", mLineTool->mLon ); 00464 mtxtLon->setText( buf ); 00465 break; 00466 } 00467 // ----------------------------------------------------------- 00468 */ 00469 } 00470 00471
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |