00001 #include "imageinfdlg.h" 00002 #include <cstdlib> 00003 #include <qmessagebox.h> 00004 #include <qregexp.h> 00005 00006 ImageInfDlg::ImageInfDlg( ImageInf &imginf ) : 00007 mImgInf( imginf ) { 00008 QVBoxLayout *vb = new QVBoxLayout( this ); 00009 QHBox *hb; 00010 QHBox *fnb; 00011 char buf[50]; 00012 00013 00014 vb->setMargin( 8 ); 00015 vb->setAutoAdd( true ); 00016 00017 // file name box 00018 fnb = new QHBox( this ); 00019 new QLabel( "Image URL: ", fnb ); 00020 fne = new QLineEdit( fnb ); 00021 QToolTip::add (fne, "Location (URL) of image") ; 00022 fne->setText( mImgInf.mLocURL.c_str() ); 00023 00024 connect( fne, 00025 SIGNAL( textChanged( const QString & ) ), 00026 this, 00027 SLOT( fnchanged( const QString & ) ) ); 00028 00029 // acquisition date box 00030 hb = new QHBox( this ); 00031 new QLabel( "Acqusition Date/Time: ", hb ); 00032 le = new QLineEdit( hb ); 00033 QToolTip::add (le, "Image Acquisition Date and Time") ; 00034 le->setText( mImgInf.mAquiDateTime.c_str() ); 00035 00036 checkLe = new QPushButton("Check", hb) ; 00037 QToolTip::add (checkLe, "Check Image Acquisition Date-Time format") ; 00038 00039 connect( le, 00040 SIGNAL( textChanged( const QString & ) ), 00041 this, 00042 SLOT( aquchanged( const QString & ) ) ); 00043 00044 connect( checkLe, 00045 SIGNAL( pressed( ) ), 00046 this, 00047 SLOT( aquCompleted( ) ) ); 00048 00049 00050 // 2007-06-14 dls - Removed image ID references and functions 00051 // Image ID 00052 /* 00053 hb = new QHBox( this ); 00054 new QLabel( "Image ID: ", hb ); 00055 imgID = new QLineEdit( hb ); 00056 QToolTip::add (imgID, "Image ID") ; 00057 imgID->setText( mImgInf.mImageID.c_str() ); 00058 00059 connect( imgID, 00060 SIGNAL( textChanged( const QString & ) ), 00061 this, 00062 SLOT( imgIdChanged( const QString & ) ) ); 00063 */ 00064 00065 // Instrument ID 00066 hb = new QHBox( this ); 00067 new QLabel( "Instrument ID ", hb ); 00068 instID = new QLineEdit( hb ); 00069 QToolTip::add (instID, "Instrument ID") ; 00070 instID->setText( mImgInf.mInstID.c_str() ); 00071 00072 connect( instID, 00073 SIGNAL( textChanged( const QString & ) ), 00074 this, 00075 SLOT( instIdChanged( const QString & ) ) ); 00076 00077 // Origin ID 00078 hb = new QHBox( this ); 00079 new QLabel( "Origin ID: ", hb ); 00080 origID = new QLineEdit( hb ); 00081 QToolTip::add (origID, "Origin ID") ; 00082 origID->setText( mImgInf.mOrigID.c_str() ); 00083 00084 connect( origID, 00085 SIGNAL( textChanged( const QString & ) ), 00086 this, 00087 SLOT( origIdChanged( const QString & ) ) ); 00088 00089 // Center Lat 00090 hb = new QHBox( this ); 00091 new QLabel( "Center Latitude (°): ", hb ); 00092 cLat = new QLineEdit( hb ); 00093 QToolTip::add (cLat, "Center Latitude, degrees (°)") ; 00094 sprintf( buf, "%8.4f", mImgInf.mCenterLat ); 00095 cLat->setText( buf ); 00096 00097 connect( cLat, 00098 SIGNAL( textChanged( const QString & ) ), 00099 this, 00100 SLOT( cLatChanged( const QString & ) ) ); 00101 00102 // Center Lon 00103 hb = new QHBox( this ); 00104 new QLabel( "Center Longitude (°): ", hb ); 00105 cLon = new QLineEdit( hb ); 00106 QToolTip::add (cLon, "Center Longitude, degrees (°)") ; 00107 sprintf( buf, "%9.4f", mImgInf.mCenterLon ); 00108 cLon->setText( buf ); 00109 00110 connect( cLon, 00111 SIGNAL( textChanged( const QString & ) ), 00112 this, 00113 SLOT( cLonChanged( const QString & ) ) ); 00114 00115 // Center Lat Uncertainty 00116 hb = new QHBox( this ); 00117 new QLabel( "Center Latitude Uncertainty (m): ", hb ); 00118 cLatUnc = new QLineEdit( hb ); 00119 QToolTip::add (cLatUnc, "Center Latitude Uncertainty, degrees (°)") ; 00120 sprintf( buf, "%8.4f", mImgInf.mCenterLatUnc ); 00121 cLatUnc->setText( buf ); 00122 00123 connect( cLatUnc, 00124 SIGNAL( textChanged( const QString & ) ), 00125 this, 00126 SLOT( cLatUncChanged( const QString & ) ) ); 00127 00128 // Center Lon Uncertainty 00129 hb = new QHBox( this ); 00130 new QLabel( "Center Longitude Uncertainty (m): ", hb ); 00131 cLonUnc = new QLineEdit( hb ); 00132 QToolTip::add (cLonUnc, "Center Longitude Uncertainty, degrees (°)") ; 00133 sprintf( buf, "%9.4f", mImgInf.mCenterLonUnc ); 00134 cLonUnc->setText( buf ); 00135 00136 connect( cLonUnc, 00137 SIGNAL( textChanged( const QString & ) ), 00138 this, 00139 SLOT( cLonUncChanged( const QString & ) ) ); 00140 00141 00142 // Image Azimuth 00143 hb = new QHBox( this ); 00144 new QLabel( "Image Azimuth (°): ", hb ); 00145 imgAz = new QLineEdit( hb ); 00146 QToolTip::add (imgAz, "Image azimuth, degrees (°)") ; 00147 sprintf( buf, "%9.4f", mImgInf.mImageAzim ); 00148 imgAz->setText( buf ); 00149 00150 connect( imgAz, 00151 SIGNAL( textChanged( const QString & ) ), 00152 this, 00153 SLOT( imgAzChanged( const QString & ) ) ); 00154 00155 // Percentage of Cloud Cover 00156 hb = new QHBox( this ); 00157 new QLabel( "Cloud Cover (%): ", hb ); 00158 cloudPct = new QLineEdit( hb ); 00159 QToolTip::add (cloudPct, "Percentage of cloud cover in the image") ; 00160 sprintf( buf, "%9.4f", mImgInf.mCloudPct ); 00161 cloudPct->setText( buf ); 00162 00163 connect( cloudPct, 00164 SIGNAL( textChanged( const QString & ) ), 00165 this, 00166 SLOT( cloudPctChanged( const QString & ) ) ); 00167 00168 // Sun Azimuth 00169 hb = new QHBox( this ); 00170 new QLabel( "Sun Azimuth (°): ", hb ); 00171 sunAz = new QLineEdit( hb ); 00172 QToolTip::add (sunAz, "Sun Azimuth (°)") ; 00173 sprintf( buf, "%9.4f", mImgInf.mSunAzim ); 00174 sunAz->setText( buf ); 00175 00176 connect( sunAz, 00177 SIGNAL( textChanged( const QString & ) ), 00178 this, 00179 SLOT( sunAzChanged( const QString & ) ) ); 00180 00181 // Sun Elevation 00182 hb = new QHBox( this ); 00183 new QLabel( "Sun Elevation (°): ", hb ); 00184 sunElev = new QLineEdit( hb ); 00185 QToolTip::add (sunElev, "Sun elevation, degrees (°)") ; 00186 sprintf( buf, "%9.4f", mImgInf.mSunElev ); 00187 sunElev->setText( buf ); 00188 00189 connect( sunElev, 00190 SIGNAL( textChanged( const QString & ) ), 00191 this, 00192 SLOT( sunElevChanged( const QString & ) ) ); 00193 00194 // Instrument Azimuth 00195 hb = new QHBox( this ); 00196 new QLabel( "Instrument Azimuth (°): ", hb ); 00197 instAz = new QLineEdit( hb ); 00198 QToolTip::add (instAz, "Instrument azimuth, degrees (°)") ; 00199 sprintf( buf, "%9.4f", mImgInf.mInstrument_azimuth ); 00200 instAz->setText( buf ); 00201 00202 connect( instAz, 00203 SIGNAL( textChanged( const QString & ) ), 00204 this, 00205 SLOT( instAzChanged( const QString & ) ) ); 00206 00207 // Instrument Zenith 00208 hb = new QHBox( this ); 00209 new QLabel( "Instrument Zenith (°): ", hb ); 00210 instZen = new QLineEdit( hb ); 00211 QToolTip::add (instZen, "Instrument zenith, degrees (°)") ; 00212 sprintf( buf, "%9.4f", mImgInf.mInstrument_zenith ); 00213 instZen->setText( buf ); 00214 00215 connect( instZen, 00216 SIGNAL( textChanged( const QString & ) ), 00217 this, 00218 SLOT( instZenChanged( const QString & ) ) ); 00219 00220 // 00221 hb = new QHBox( this ); 00222 new QLabel( "Projection: ", hb ); 00223 proj = new QLineEdit( hb ); 00224 QToolTip::add (proj, "Projection name") ; 00225 proj->setText( mImgInf.mProjection.c_str() ); 00226 00227 connect( proj, 00228 SIGNAL( textChanged( const QString & ) ), 00229 this, 00230 SLOT( projChanged( const QString & ) ) ); 00231 00232 00233 } 00234 00235 00236 00237 00238 // ACQUISITION DATE CHANGED 00239 // set new acquisition date 00240 void ImageInfDlg::aquchanged( const QString &str ) { 00241 QString tempstr = str ; 00242 tempstr.replace ( QRegExp ("\""), "" ) ; 00243 tempstr.simplifyWhiteSpace () ; 00244 tempstr.replace ( QRegExp (" "), "" ) ; 00245 00246 mImgInf.mAquiDateTime = (const char*)tempstr ; 00247 } 00248 00249 // FILE NAME CHANGED 00250 // set new "file name" (image location URL) 00251 void ImageInfDlg::fnchanged( const QString &str ) { 00252 mImgInf.mLocURL = (const char*)str; 00253 } 00254 00255 00256 // 2007-06-14 dls - Removed image ID references and functions 00257 // IMAGE ID CHANGED 00258 /* 00259 void ImageInfDlg::imgIdChanged(const QString &str ) { 00260 mImgInf.mImageID = (const char*)str ; 00261 } 00262 */ 00263 00264 // INSTRUMENT ID CHANGED 00265 void ImageInfDlg::instIdChanged(const QString &str ) { 00266 mImgInf.mInstID = (const char*)str ; 00267 } 00268 00269 // ORIGIN CHANGED 00270 void ImageInfDlg::origIdChanged(const QString &str ) { 00271 mImgInf.mOrigID = (const char*)str ; 00272 } 00273 00274 // CENTER LAT CHANGED 00275 void ImageInfDlg::cLatChanged(const QString &str ) { 00276 mImgInf.mCenterLat = str.toDouble() ; 00277 } 00278 00279 // CENTER LON CHANGED 00280 void ImageInfDlg::cLonChanged(const QString &str ) { 00281 mImgInf.mCenterLon = str.toDouble() ; 00282 } 00283 00284 // CENTER LAT UNCERTAINTY CHANGED 00285 void ImageInfDlg::cLatUncChanged(const QString &str ) { 00286 mImgInf.mCenterLatUnc = str.toDouble() ; 00287 } 00288 00289 // CENTER LAT UNCERTAINTY CHANGED 00290 void ImageInfDlg::cLonUncChanged(const QString &str ) { 00291 mImgInf.mCenterLonUnc = str.toDouble() ; 00292 } 00293 00294 // IMAGE AZIMUTH CHANGED 00295 void ImageInfDlg::imgAzChanged(const QString &str ) { 00296 mImgInf.mImageAzim = str.toDouble() ; 00297 } 00298 00299 // PERCENTAGE CLOUD COVER CHANGED 00300 void ImageInfDlg::cloudPctChanged( const QString &str ) { 00301 mImgInf.mCloudPct = str.toDouble() ; 00302 } 00303 00304 // SUN AZIMUTH CHANGED 00305 void ImageInfDlg::sunAzChanged(const QString &str ) { 00306 mImgInf.mSunAzim = str.toDouble() ; 00307 } 00308 00309 // SUN ELEVATION CHANGED 00310 void ImageInfDlg::sunElevChanged(const QString &str ) { 00311 mImgInf.mSunElev = str.toDouble() ; 00312 } 00313 00314 // CHANGED 00315 void ImageInfDlg::instAzChanged(const QString &str ) { 00316 mImgInf.mInstrument_azimuth = str.toDouble() ; 00317 } 00318 00319 // CHANGED 00320 void ImageInfDlg::instZenChanged(const QString &str ) { 00321 mImgInf.mInstrument_zenith = str.toDouble() ; 00322 } 00323 00324 // CHANGED 00325 void ImageInfDlg::projChanged(const QString &str ) { 00326 mImgInf.mProjection = (const char*)str; 00327 } 00328 00329 00330 00331 00332 // LOAD DATA 00333 void ImageInfDlg::loadData () { 00334 00335 char buf[50]; // STRING BUFFER 00336 00337 QString tempstr = mImgInf.mAquiDateTime.c_str() ; 00338 tempstr.replace ( QRegExp ("\""), "" ) ; 00339 tempstr.simplifyWhiteSpace () ; 00340 tempstr.replace ( QRegExp (" "), "" ) ; 00341 mImgInf.mAquiDateTime = tempstr.latin1() ; 00342 00343 00344 le->setText( mImgInf.mAquiDateTime.c_str() ); 00345 fne->setText( mImgInf.mLocURL.c_str() ); 00346 00347 // added by dls 2006-01-09 00348 //imgID ->setText( mImgInf.mImageID.c_str() ) ; 00349 instID ->setText( mImgInf.mInstID.c_str() ) ; 00350 origID ->setText( mImgInf.mOrigID.c_str() ) ; 00351 00352 sprintf( buf, "%8.4f", mImgInf.mCenterLat ); 00353 cLat ->setText( buf ) ; 00354 00355 sprintf( buf, "%9.4f", mImgInf.mCenterLon ); 00356 cLon ->setText( buf ) ; 00357 00358 sprintf( buf, "%8.4f", mImgInf.mCenterLatUnc ); 00359 cLatUnc ->setText( buf ) ; 00360 00361 sprintf( buf, "%9.4f", mImgInf.mCenterLonUnc ); 00362 cLonUnc ->setText( buf ) ; 00363 00364 sprintf( buf, "%9.4f", mImgInf.mImageAzim ); 00365 imgAz ->setText( buf ) ; 00366 00367 sprintf( buf, "%8.4f", mImgInf.mCloudPct ); 00368 cloudPct ->setText( buf ) ; 00369 00370 sprintf( buf, "%9.4f", mImgInf.mSunAzim ); 00371 sunAz ->setText( buf ) ; 00372 00373 sprintf( buf, "%9.4f", mImgInf.mSunElev ); 00374 sunElev ->setText( buf ) ; 00375 00376 sprintf( buf, "%9.4f", mImgInf.mInstrument_azimuth ); 00377 instAz ->setText( buf ) ; 00378 00379 sprintf( buf, "%9.4f", mImgInf.mInstrument_zenith ); 00380 instZen ->setText( buf ) ; 00381 00382 proj ->setText( mImgInf.mProjection.c_str() ) ; 00383 00384 } 00385 00386 void ImageInfDlg::aquCompleted() { 00387 QString str = le->text() ; 00388 if (str.length() == 0) { 00389 QString errmsg = "Image Acquisition Date-Time is empty" ; 00390 QMessageBox::information( NULL, "Date-Time Check", errmsg ); 00391 } 00392 else if ( validIso8601DateTime(str) == false ) { 00393 QString errmsg = str + " is not correctly formatted. Please provide dates in the following format:\n\n YYYY-MM-DD\n YYYY-MM-DDThh:mmTZD\n YYYY-MM-DDThh:mm:ssTZD\n YYYY-MM-DDThh:mm:ss.sTZD\n\nWhere TZD is the time zone designator (Z or +hh:mm or -hh:mm).\nSee the Configuration Dialog, Image Info topic in Help for more info and examples." ; 00394 QMessageBox::information( NULL, "Date-Time Check", errmsg ); 00395 } 00396 else { 00397 QString errmsg = "Image Acquisition Date-Time appears to be valid" ; 00398 QMessageBox::information( NULL, "Date-Time Check", errmsg ); 00399 } 00400 } 00401 00402 00403 /* 00404 * Do the characters in the input string represent 00405 * a complete and valid date/time string? 00406 */ 00407 bool ImageInfDlg::validIso8601DateTime (QString &str) { 00408 return mImgInf.validIso8601DateTime (str) ; 00409 } 00410 00411 00412 00413 00414 00415 00416
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |