00001 #include "linedefdlg.h" 00002 00003 LineDefDlg::LineDefDlg( GLIMSLineData &linedata, int ildf ) : 00004 QDialog( NULL, NULL, true ), 00005 mLineData( linedata ), 00006 miLDF( ildf ) { 00007 setCaption( "Line Definition Config" ); // LABEL THE WINDOW 00008 00009 // THE MAIN LAYOUT FOR THE FORM 00010 QVBoxLayout *vboxl = new QVBoxLayout( this ); 00011 vboxl->setAutoAdd( true ); 00012 00013 // THE MAIN WIDGET FOR THE FORM 00014 QVBox *mainVB = new QVBox( this ); 00015 mainVB->setMargin( 8 ); 00016 00017 // TYPES OF WIDGETS THAT WILL BE USED IN THE FORM 00018 QHBox *hbox = NULL; 00019 QGrid *grid = NULL; 00020 QVBox *vbox = NULL; 00021 QLabel *lbl = NULL; 00022 QPushButton *but = NULL; 00023 00024 // ADD TYPE SECTION 00025 vbox = new QVBox( mainVB ); 00026 00027 grid = new QGrid( 2, vbox ); 00028 lbl = new QLabel( "Glacier Type: ", grid ); 00029 lbl->setMaximumWidth( 120 ); 00030 cmbGlacType = new QComboBox( grid, NULL ); 00031 00032 grid = new QGrid( 2, vbox ); 00033 lbl = new QLabel( "Segment Type: ", grid ); 00034 lbl->setMaximumWidth( 120 ); 00035 cmbSegType = new QComboBox( grid, NULL ); 00036 00037 00038 // ADD SEGMENT LABEL SECTION 00039 grid = new QGrid( 2, vbox ); 00040 lbl = new QLabel( "Segment Label: ", grid ); 00041 lbl->setMaximumWidth( 120 ); 00042 cmbSegLabel = new QComboBox( grid ); 00043 00044 00045 // ADD MATERIALS SECTION 00046 lbl = new QLabel( "Materials", mainVB ); 00047 grid = new QGrid( 2, mainVB ); 00048 00049 hbox = new QHBox( grid ); 00050 lbl = new QLabel( "Left: ", hbox ); 00051 cmbLMat = new QComboBox( hbox, NULL ); 00052 00053 hbox = new QHBox( grid ); 00054 lbl = new QLabel( " Right: ", hbox ); 00055 cmbRMat = new QComboBox( hbox, NULL ); 00056 00057 00058 // ADD FEATURE SECTION 00059 lbl = new QLabel( "Features", mainVB ); 00060 grid = new QGrid( 2, mainVB ); 00061 00062 hbox = new QHBox( grid ); 00063 lbl = new QLabel( "Left: ", hbox ); 00064 cmbLFtr = new QComboBox( hbox, NULL ); 00065 00066 hbox = new QHBox( grid ); 00067 lbl = new QLabel( " Right: ", hbox ); 00068 cmbRFtr = new QComboBox( hbox, NULL ); 00069 00070 00071 // ADD LOCAL UNCERT SECTION 00072 lbl = new QLabel( "Local Uncertainties", mainVB ); 00073 grid = new QGrid( 2, mainVB ); 00074 00075 hbox = new QHBox( grid ); 00076 lbl = new QLabel( "X: ", hbox ); 00077 txtLXUncert = new QLineEdit( hbox, NULL ); 00078 00079 hbox = new QHBox( grid ); 00080 lbl = new QLabel( " Y: ", hbox ); 00081 txtLYUncert = new QLineEdit( hbox, NULL ); 00082 00083 00084 // ADD GLOBAL UNCERT SECTION 00085 lbl = new QLabel( "Global Uncertainties", mainVB ); 00086 grid = new QGrid( 2, mainVB ); 00087 00088 hbox = new QHBox( grid ); 00089 lbl = new QLabel( "X: ", hbox ); 00090 txtGXUncert = new QLineEdit( hbox, NULL ); 00091 00092 hbox = new QHBox( grid ); 00093 lbl = new QLabel( " Y: ", hbox ); 00094 txtGYUncert = new QLineEdit( hbox, NULL ); 00095 00096 00097 // ADD LINE STYLE SECTION 00098 lbl = new QLabel( "Dislay", mainVB ); 00099 vbox = new QVBox( mainVB ); 00100 00101 grid = new QGrid( 2, vbox ); 00102 lbl = new QLabel( "Color: ", grid ); 00103 lbl->setMaximumWidth( 80 ); 00104 cmbColor = new QComboBox( grid, NULL ); 00105 00106 grid = new QGrid( 2, vbox ); 00107 lbl = new QLabel( "Style: ", grid ); 00108 lbl->setMaximumWidth( 80 ); 00109 cmbStyle = new QComboBox( grid, NULL ); 00110 00111 grid = new QGrid( 2, vbox ); 00112 lbl = new QLabel( "Width: ", grid ); 00113 lbl->setMaximumWidth( 80 ); 00114 cmbWidth = new QComboBox( grid, NULL ); 00115 00116 00117 // ADD BUTTONS FOR ADDING THE LDF OR CANCELING 00118 hbox = new QHBox( mainVB ); 00119 00120 but = new QPushButton( "Ok", hbox ); 00121 connect( but, SIGNAL( clicked() ), this, SLOT( butOkPress() ) ); 00122 00123 but = new QPushButton( "Cancel", hbox ); 00124 connect( but, SIGNAL( clicked() ), this, SLOT( butCancelPress() ) ); 00125 00126 // FILL THE COMBO BOXES WITH VALIDS 00127 loadValids(); 00128 00129 // LOAD SELECTED LDF DATA INTO FORM 00130 if ( miLDF != -1 ) 00131 setSelected(); 00132 } 00133 00134 void LineDefDlg::butOkPress( ) { 00135 LineDef ldf; // NEW LDF 00136 00137 // GRAB DATA FROM FORM & LOAD INTO ldf 00138 ldf.mGlacType = cmbGlacType->currentItem(); 00139 ldf.mType = cmbSegType->currentItem(); 00140 ldf.mLabel = cmbSegLabel->currentItem(); 00141 ldf.mLMat = cmbLMat->currentItem(); 00142 ldf.mRMat = cmbRMat->currentItem(); 00143 ldf.mLXUncert = atof( txtLXUncert->text().latin1() ); 00144 ldf.mLYUncert = atof( txtLYUncert->text().latin1() ); 00145 ldf.mGXUncert = atof( txtGXUncert->text().latin1() ); 00146 ldf.mGYUncert = atof( txtGYUncert->text().latin1() ); 00147 ldf.mLFeature = cmbLFtr->currentItem(); 00148 ldf.mRFeature = cmbRFtr->currentItem(); 00149 ldf.mColor = cmbColor->currentItem(); 00150 ldf.mWidth = cmbWidth->currentItem() +1; 00151 ldf.mStyle = cmbStyle->currentItem() +1; 00152 00153 // ADD OR EDIT LDF 00154 if ( miLDF == -1 ) 00155 mLineData.getLDFSet().add( ldf ); 00156 else 00157 mLineData.getLDFSet()[miLDF] = ldf; 00158 close(); 00159 } 00160 00161 void LineDefDlg::butCancelPress( ) { 00162 close(); 00163 } 00164 00165 00166 00167 void LineDefDlg::loadValids( ) { 00168 unsigned int i; 00169 00170 for ( i = 0; i < GLIMSGlobals::mGlbGlacTypes.size(); i++ ) 00171 cmbGlacType->insertItem( GLIMSGlobals::mGlbGlacTypes[i].value.c_str() ); 00172 00173 for ( i = 0; i < GLIMSGlobals::mGlbTypes.size(); i++ ) 00174 cmbSegType->insertItem( GLIMSGlobals::mGlbTypes[i].value.c_str() ); 00175 00176 for ( i = 0; i < GLIMSGlobals::mGlbLbls.size(); i++ ) 00177 cmbSegLabel->insertItem( GLIMSGlobals::mGlbLbls[i].value.c_str() ); 00178 00179 for ( i = 0; i < GLIMSGlobals::mGlbMDF.size(); i++ ) { 00180 cmbLMat->insertItem( GLIMSGlobals::mGlbMDF[i].value.c_str() ); 00181 cmbRMat->insertItem( GLIMSGlobals::mGlbMDF[i].value.c_str() ); 00182 } 00183 00184 for ( i = 0; i < GLIMSGlobals::mGlbFtrs.size(); i++ ) { 00185 cmbLFtr->insertItem( GLIMSGlobals::mGlbFtrs[i].value.c_str() ); 00186 cmbRFtr->insertItem( GLIMSGlobals::mGlbFtrs[i].value.c_str() ); 00187 } 00188 00189 for ( i = 0; i < GLIMSGlobals::AVAILCOLORSTR.size(); i++ ) 00190 cmbColor->insertItem( GLIMSGlobals::AVAILCOLORSTR[i].c_str() ); 00191 00192 cmbStyle->insertItem("Solid Line"); 00193 cmbStyle->insertItem("Dash Line"); 00194 cmbStyle->insertItem("Dot Line"); 00195 00196 cmbWidth->insertItem( "1" ); 00197 cmbWidth->insertItem( "2" ); 00198 cmbWidth->insertItem( "3" ); 00199 } 00200 00201 00202 00203 void LineDefDlg::setSelected( ) { 00204 LineDef ldf = mLineData.getLDFSet()[miLDF]; 00208 //mProj->getLineDef( mProj->mSelLDF, ldf, attr ); 00209 char buf[256]; 00210 00211 cmbGlacType->setCurrentItem( ldf.mGlacType ); 00212 cmbSegType->setCurrentItem( ldf.mType ); 00213 cmbSegLabel->setCurrentItem( ldf.mLabel ); 00214 cmbLMat->setCurrentItem( ldf.mLMat ); 00215 cmbRMat->setCurrentItem( ldf.mRMat ); 00216 cmbLFtr->setCurrentItem( ldf.mLFeature ); 00217 cmbRFtr->setCurrentItem( ldf.mRFeature ); 00218 sprintf( buf, "%.6f", ldf.mLXUncert ); 00219 txtLXUncert->setText( buf ); 00220 sprintf( buf, "%.6f", ldf.mLYUncert ); 00221 txtLYUncert->setText( buf ); 00222 sprintf( buf, "%.6f", ldf.mGXUncert ); 00223 txtGXUncert->setText( buf ); 00224 sprintf( buf, "%.6f", ldf.mGYUncert ); 00225 txtGYUncert->setText( buf ); 00226 00227 cmbColor->setCurrentItem( ldf.mColor ); 00228 cmbWidth->setCurrentItem( ldf.mWidth-1 ); 00229 cmbStyle->setCurrentItem( ldf.mStyle-1 ); 00230 } 00231 00232 00233 00234 00235
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |