1 #include <QApplication>
35 int main(
int argc,
char* argv[] )
37 QApplication application( argc, argv );
45 return application.exec();
63 setWindowTitle( tr(
"Import Experimental Data (Beckman-XLA/XLI,"
64 " Aviv Fluorescence, OpenAUC Multiwavelength)" ) );
72 QGridLayout* settings =
new QGridLayout;
78 if ( DB.isEmpty() ) DB <<
"Undefined";
79 QLabel* lb_DB =
us_banner( tr(
"Database: " ) + DB.at( 0 ) );
84 QWidget* wg_investigator;
85 QPushButton* pb_investigator =
us_pushbutton( tr(
"Select Investigator"));
89 wg_investigator = (QWidget*)pb_investigator;
93 QLabel* lb_investigator =
us_label( tr(
"Investigator:" ) );
94 wg_investigator = (QWidget*)lb_investigator;
95 pb_investigator->setVisible(
false );
105 QLabel* lb_status =
us_label( tr(
"Status:" ) );
108 stpal.setColor( QPalette::Text, Qt::white );
109 stpal.setColor( QPalette::Base, Qt::blue );
113 QLabel* lb_runID =
us_label( tr(
"Run ID:" ) );
115 lb_runID->setVisible(
false );
123 QLabel* lb_run =
us_banner( tr(
"Load the Run" ) );
139 QLabel* lb_tolerance =
us_label( tr(
"Separation Tolerance:" ) );
145 QFontMetrics fmet( font );
146 static QChar clambda( 955 );
162 QLabel* lb_runinfo =
us_banner( tr(
"Run Information" ) );
165 QLabel* lb_runID2 =
us_label( tr(
"Run ID:" ) );
170 QLabel* lb_dir =
us_label( tr(
"Directory:" ) );
179 QGridLayout* ccw =
new QGridLayout();
182 tr(
"Cell / Channel / Wavelength" ), -1 );
187 tr(
"Enter Associated Triple (c/c/w) Info:" ) );
210 QLabel* lb_solution =
us_label( tr(
"Solution:" ) );
216 lb_from->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
221 lb_to->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
236 settings ->addWidget( lb_DB, row++, 0, 1, 4 );
237 settings ->addWidget( wg_investigator, row, 0, 1, 2 );
240 settings ->addWidget( lb_run, row++, 0, 1, 4 );
241 settings ->addWidget(
pb_import, row, 0, 1, 2 );
243 settings ->addWidget(
pb_loadUS3, row, 0, 1, 2 );
244 settings ->addWidget(
pb_details, row++, 2, 1, 2 );
245 settings ->addWidget( lb_tolerance, row, 0, 1, 2 );
247 settings ->addWidget(
lb_mwlctrl, row++, 0, 1, 4 );
251 settings ->addWidget(
cb_lambstop, row++, 3, 1, 1 );
255 settings ->addWidget(
pb_lambnext, row++, 3, 1, 1 );
257 ccw ->addWidget( lb_runinfo, row++, 0, 1, 12 );
258 ccw ->addWidget( lb_runID2, row, 0, 1, 3 );
259 ccw ->addWidget(
le_runID2, row++, 3, 1, 9 );
260 ccw ->addWidget( lb_dir, row, 0, 1, 3 );
261 ccw ->addWidget(
le_dir, row++, 3, 1, 9 );
262 ccw ->addWidget(
lb_triple, row++, 0, 1, 12 );
265 ccw ->addWidget(
lw_triple, row, 0, 7, 4 );
266 ccw ->addWidget( lb_ccwinfo, row++, 4, 1, 8 );
270 ccw ->addWidget(
pb_define, row, 4, 1, 4 );
271 ccw ->addWidget(
pb_process, row++, 8, 1, 4 );
278 ccw ->addWidget( lb_solution, row, 0, 1, 3 );
280 ccw ->addWidget( lb_status, row, 0, 1, 2 );
281 ccw ->addWidget(
le_status, row++, 2, 1, 10 );
283 settings ->addLayout( ccw, row++, 0, 1, 4 );
285 settings ->addWidget( pb_reset, row, 0, 1, 1 );
286 settings ->addWidget( pb_help, row, 1, 1, 1 );
287 settings ->addWidget(
pb_saveUS3, row, 2, 1, 1 );
288 settings ->addWidget( pb_close, row++, 3, 1, 1 );
292 tr(
"Absorbance Data" ),
293 tr(
"Radius (in cm)" ),
294 tr(
"Absorbance" ) );
298 data_plot->enableAxis( QwtPlot::xBottom,
true );
299 data_plot->enableAxis( QwtPlot::yLeft ,
true );
301 data_plot->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
302 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
305 picker ->setRubberBand ( QwtPicker::VLineRubberBand );
306 picker->setMousePattern ( QwtEventPattern::MouseSelect1,
307 Qt::LeftButton, Qt::ControlModifier );
309 QGridLayout* todo =
new QGridLayout();
312 QLabel* lb_todoinfo =
us_banner( tr(
"Instructions ( to do list )" ), 0 );
316 lw_todoinfo->setSelectionMode( QAbstractItemView::NoSelection );
319 todo->addWidget(
lb_scan, row++, 0, 1, 4 );
320 todo->addWidget(
lb_from, row, 0, 1, 2 );
321 todo->addWidget(
ct_from, row++, 2, 1, 2 );
322 todo->addWidget(
lb_to, row, 0, 1, 2 );
323 todo->addWidget(
ct_to, row++, 2, 1, 2 );
325 todo->addWidget(
pb_include, row++, 2, 1, 2 );
326 todo->addWidget( lb_todoinfo, row++, 0, 1, 4 );
331 connect( pb_investigator, SIGNAL( clicked() ),
343 connect(
ct_tolerance, SIGNAL( valueChanged (
double ) ),
347 connect(
lw_triple, SIGNAL( itemSelectionChanged() ),
375 connect( pb_reset, SIGNAL( clicked() ),
377 connect( pb_help, SIGNAL( clicked() ),
381 connect( pb_close, SIGNAL( clicked() ),
386 QVBoxLayout* left =
new QVBoxLayout;
388 left->addLayout( settings );
390 QVBoxLayout* right =
new QVBoxLayout;
392 right->addLayout( plot );
393 right->addLayout( todo );
395 QHBoxLayout*
main =
new QHBoxLayout(
this );
396 main->setSpacing ( 2 );
397 main->setContentsMargins ( 2, 2, 2, 2 );
399 main->addLayout( left );
400 main->addLayout( right );
401 main->setStretchFactor( left, 3 );
402 main->setStretchFactor( right, 5 );
404 DbgLv(1) <<
"CGui: GUI setup complete";
406 DbgLv(1) <<
"CGui: reset complete";
444 ct_to ->disconnect();
445 ct_to ->setMinValue( 0 );
446 ct_to ->setMaxValue( 0 );
447 ct_to ->setValue ( 0 );
469 lw_todoinfo->addItem(
"Load or import some AUC data" );
473 data_plot ->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
474 data_plot ->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
506 QApplication::restoreOverrideCursor();
507 QApplication::restoreOverrideCursor();
511 int status = QMessageBox::information(
this,
512 tr(
"New Data Warning" ),
513 tr(
"This will erase all data currently on the screen, and "
514 "reset the program to its starting condition. No hard-drive "
515 "data or database information will be affected. Proceed? " ),
516 tr(
"&OK" ), tr(
"&Cancel" ),
519 if ( status != 0 )
return;
524 le_status->setText( tr(
"(no data loaded)" ) );
537 data_plot->setTitle( tr(
"Absorbance Data" ) );
546 SIGNAL( investigator_accepted(
int ) ),
557 QString number = ( invID > 0 )
558 ? QString::number( invID ) +
": "
572 QMessageBox::warning(
this,
574 tr(
"There is no default database set." ) );
618 else if ( impType == 2 )
624 DbgLv(1) <<
"CGui:IMP: IN";
625 bool success =
false;
626 le_status->setText( tr(
"Importing experimental data ..." ) );
630 if ( ! success )
return;
641 if ( ! success )
return;
646 if ( ! success )
return;
652 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
655 DbgLv(1) <<
"CGui:IMP: init_excludes CALL";
660 QApplication::restoreOverrideCursor();
662 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
665 connect(
ct_to , SIGNAL( valueChanged (
double ) ),
671 DbgLv(1) <<
"CGui:IMP: enableControls CALL";
680 DbgLv(1) <<
"CGui: import: RTN";
681 le_status->setText( tr(
"Legacy data has been imported." ) );
688 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
693 bool success =
false;
707 QApplication::restoreOverrideCursor();
723 QApplication::restoreOverrideCursor();
725 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
728 connect(
ct_to , SIGNAL( valueChanged (
double ) ),
745 DbgLv(1) <<
"CGui:iM: IN";
746 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
749 le_status->setText( tr(
"Importing MWL data ..." ) );
750 qApp->processEvents();
751 DbgLv(1) <<
"CGui:iM: import_data";
756 QMessageBox::warning(
this,
757 tr(
"Duplicate Wavelengths" ),
758 tr(
"Duplicate wavelengths were encountered in the import"
759 " of the Multi-WaveLength data.\n\n"
760 "All duplicate triples were skipped." ) );
766 qApp->processEvents();
767 QApplication::restoreOverrideCursor();
768 QApplication::restoreOverrideCursor();
769 le_status->setText( tr(
"MWL import error (no data loaded)" ) );
770 qApp->processEvents();
774 DbgLv(1) <<
"CGui:iM: RTN: import_data";
779 QApplication::restoreOverrideCursor();
794 DbgLv(1) <<
"CGui:iM: show_mwl_control";
796 DbgLv(1) <<
"CGui:iM: RTN:show_mwl_control";
797 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
800 le_status->setText( tr(
"Duplicating wavelengths ..." ) );
801 qApp->processEvents();
807 le_status->setText( tr(
"Building raw data AUCs ..." ) );
808 qApp->processEvents();
809 DbgLv(1) <<
"CGui:iM: buildraw";
811 DbgLv(1) <<
"CGui:iM: init_out";
815 le_status->setText( tr(
"Building Lambda list ..." ) );
816 qApp->processEvents();
819 DbgLv(1) <<
"CGui:iM: mwlsetup";
824 QStringList tmsfs = ddir.entryList( QStringList(
"*.time_state.*" ),
825 QDir::Files, QDir::Name );
828 if ( tmst_dname.right( 1 ) !=
"/" )
831 if ( tmsfs.count() == 2 )
834 defs_fnamei = tmsfs[ 1 ];
837 defs_fnamei.contains(
".xml" ) )
842 else if ( tmsfs[ 0 ].contains(
".xml" ) &&
843 tmsfs[ 1 ].contains(
".tmst" ) )
860 qApp->processEvents();
861 QApplication::restoreOverrideCursor();
862 DbgLv(1) <<
"CGui:iM: DONE";
869 QDir readDir( importDir );
871 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
872 le_status->setText( tr(
"Loading AUC simulation data ..." ) );
873 QStringList nameFilters = QStringList(
"*.auc" );
874 QStringList files = readDir.entryList( nameFilters,
875 QDir::Files | QDir::Readable, QDir::Name );
879 for (
int trx = 0; trx < files.size(); trx++ )
881 QString fname = files[ trx ];
882 QString fpath = importDir +
"/" + fname;
890 QString triple = QString::number( rdata.cell ) +
" / "
891 + QString( rdata.channel ) +
" / "
892 + QString::number( qRound( rdata.scanData[ 0 ].wavelength ) );
901 qApp->processEvents();
902 QApplication::restoreOverrideCursor();
904 QString fname = files[ 0 ];
905 runType = QString( fname ).section(
".", -5, -5 );
906 runID = QString( fname ).section(
".", 0, -6 );
923 QStringList tmsfs = ddir.entryList( QStringList(
"*.time_state.*" ),
924 QDir::Files, QDir::Name );
927 if ( tmst_dname.right( 1 ) !=
"/" )
929 DbgLv(1) <<
"rTS: tmst_dname" << tmst_dname <<
"tmsfs count" << tmsfs.count();
931 if ( tmsfs.count() == 2 )
934 defs_fnamei = tmsfs[ 1 ];
938 defs_fnamei.contains(
".xml" ) )
943 else if ( tmsfs[ 0 ].contains(
".xml" ) &&
944 tmsfs[ 1 ].contains(
".tmst" ) )
962 le_status->setText( tr(
"AUC simulation data import IS COMPLETE." ) );
981 int currentScanCount = 0;
986 bool drops = ( currentScanCount > 1 );
1005 lb_triple ->setText( tr(
"Cell / Channel / Wavelength" ) );
1016 lb_triple ->setText( tr(
"Cell / Channel / Radius" ) );
1029 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
1043 DbgLv(1) <<
"CGui: enabCtl: enabSvBtn complete";
1053 connect(
le_runID2, SIGNAL( textEdited( QString ) ),
1068 DbgLv(1) <<
"CGui:enabScContr: isMwl" <<
isMwl;
1079 ct_to ->disconnect();
1080 ct_to ->setMinValue( 0.0 );
1081 ct_to ->setMaxValue(
outData[ tripDatax ]->scanData.size()
1083 ct_to ->setValue ( 0 );
1085 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
1088 connect(
ct_to , SIGNAL( valueChanged (
double ) ),
1099 bool completed =
true;
1107 + tr(
": Load or import some AUC data" ) );
1116 + tr(
": Load or import some AUC data" ) );
1121 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
1135 + tr(
": Modify run ID (optional)" ) );
1139 + tr(
": Edit run information" ) );
1151 tr(
": Select solution for triple " ) +
1163 tr(
": Select centerpiece for triple " ) +
1180 tr(
": Verify database connectivity" ) );
1195 tr(
": Select a different runID" ) );
1204 + tr(
": Select operator in run information" ) );
1215 tr(
": Define reference scans" ) );
1229 QRegExp rx(
"^[A-Za-z0-9_-]{1,80}$" );
1232 if ( rx.indexIn( new_runID ) >= 0 )
1235 if (
runID.length() > 50 )
1237 QMessageBox::warning(
this,
1238 tr(
"RunID Name Too Long" ),
1239 tr(
"The runID name may be at most\n"
1240 "50 characters in length." ) );
1267 DbgLv(1) <<
"CGui: edRuninfo: IN";
1276 DbgLv(1) <<
"CGui: edRuninfo: getExpInfo complete";
1285 connect( &dialog, SIGNAL( dkdb_changed (
bool ) ),
1288 if ( dialog.exec() == QDialog::Rejected )
1291 if (
runID == QString(
"" ) )
1295 qApp->processEvents();
1297 DbgLv(1) <<
"CGui: ldUS3: IN";
1306 DbgLv(1) <<
"CGui: ldUS3: RTN";
1316 dir.replace(
"\\",
"/" );
1317 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
1327 le_status->setText( tr(
"Loading data from local disk ..." ) );
1328 qApp->processEvents();
1331 QStringList components = dir.split(
"/", QString::SkipEmptyParts );
1332 QString new_runID = components.last();
1334 QRegExp rx(
"^[A-Za-z0-9_-]{1,80}$" );
1335 if ( rx.indexIn( new_runID ) < 0 )
1337 QMessageBox::warning(
this,
1338 tr(
"Bad runID Name" ),
1339 tr(
"The runID name may consist only of alphanumeric\n"
1340 "characters, the underscore, and the hyphen." ) );
1352 le_status->setText( tr(
"Loading data from Disk (raw data) ..." ) );
1353 qApp->processEvents();
1354 DbgLv(1) <<
"CGui: ldUS3Dk: call read";
1355 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1357 QApplication::restoreOverrideCursor();
1361 QMessageBox::warning(
this,
1362 tr(
"No Files Found" ),
1363 tr(
"There were no files of the form *.auc\n"
1364 "found in the specified directory." ) );
1370 QMessageBox::warning(
this,
1371 tr(
"UltraScan Error" ),
1372 tr(
"Could not read data file.\n" ) );
1378 le_status->setText( tr(
"Loading data from Disk (experiment) ..." ) );
1379 qApp->processEvents();
1385 QString readFile =
runID +
"."
1387 QMessageBox::information(
this,
1389 tr(
"US3 run data ok, but unable to assocate run with DB.\n " ) +
1390 tr(
"Cannot open read file: " ) + dir + readFile );
1395 QString readFile =
runID +
"."
1397 QMessageBox::information(
this,
1399 tr(
"US3 run data ok, but there is an error in association with DB.\n"
1400 "Improper XML in read file: " ) + dir + readFile );
1405 QMessageBox::information(
this,
1407 tr(
"Unknown error: " ) + status );
1412 le_status->setText( tr(
"Loading data from Disk (project) ..." ) );
1413 qApp->processEvents();
1414 DbgLv(1) <<
"CGui: ldUS3Dk: call prj-rDk";
1420 QMessageBox::information(
this,
1422 tr(
"The project was not found.\n"
1423 "Please select an existing project and try again.\n" ) );
1428 QMessageBox::information(
this,
1429 tr(
"Disk Read Problem" ),
1430 tr(
"Could not read data from the disk.\n"
1431 "Disk status: " ) + QString::number( status ) );
1438 le_status->setText( tr(
"Project and experiment are loaded." ) );
1439 qApp->processEvents();
1440 QString psolGUID =
"";
1441 DbgLv(1) <<
"CGui: SOLCHK:loop";
1446 QString csolGUID =
all_tripinfo[ ii ].solution.solutionGUID;
1448 if ( csolGUID == psolGUID )
1456 if ( csolGUID.isEmpty() )
1458 DbgLv(1) <<
"SOLCHK: ii csolGUID EMPTY" << ii << csolGUID;
1461 csolGUID = psolGUID;
1465 status =
all_tripinfo[ ii ].solution.readFromDisk( csolGUID );
1466 psolGUID = csolGUID;
1472 QMessageBox::information(
this,
1474 tr(
"A solution this run refers to was not found,"
1475 " or could not be read.\n"
1476 "Please select an existing solution and try again.\n" ) );
1477 DbgLv(1) <<
"SOLERR: ii psolGUID csolGUI" << ii << psolGUID << csolGUID;
1482 QMessageBox::information(
this,
1484 tr(
"The buffer this solution refers to was not found.\n"
1485 "Please restore and try again.\n" ) );
1490 QMessageBox::information(
this,
1492 tr(
"One of the analytes this solution refers to was not found.\n"
1493 "Please restore and try again.\n" ) );
1498 QMessageBox::information(
this,
1499 tr(
"Disk Read Problem" ),
1500 tr(
"Could not read data from the disk.\n"
1501 "Disk status: " ) + QString::number( status ) );
1508 DbgLv(1) <<
"CGui: SOLCHK:loop-END";
1510 le_status->setText( tr(
"Solutions are now loaded." ) );
1511 qApp->processEvents();
1520 DbgLv(1) <<
"CGui: call rdRIDk";
1525 QString readFile =
runID +
"."
1527 QMessageBox::information(
this,
1529 tr(
"US3 run data ok, but unable to read intensity profile.\n " ) +
1530 tr(
"Cannot open read file: " ) + dir + readFile );
1535 QString readFile =
runID +
"."
1537 QMessageBox::information(
this,
1539 tr(
"US3 run data ok, but unable to read intensity profile.\n " ) +
1540 tr(
"Improper XML in read file: " ) + dir + readFile );
1545 QMessageBox::information(
this,
1547 tr(
"Unknown error: " ) + status );
1564 if (
allData.size() == 0 )
return;
1566 le_status->setText( tr(
"%1 data triples are NOW LOADED." )
1568 qApp->processEvents();
1592 DbgLv(1) <<
"CGui: chan trip" << ii << idax
1593 <<
"centp sol" << cCenterpiece << cSolution.
solutionGUID;
1604 DbgLv(1) <<
"CGui: call setTripleInfo";
1606 DbgLv(1) <<
"CGui: call init_excludes";
1617 DbgLv(1) <<
"CGui: call enableScanControls";
1624 DbgLv(1) <<
"CGui: call plot_current";
1625 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1627 QApplication::restoreOverrideCursor();
1629 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
1632 connect(
ct_to , SIGNAL( valueChanged (
double ) ),
1661 QStringList tmsfs = ddir.entryList( QStringList(
"*.time_state.*" ),
1662 QDir::Files, QDir::Name );
1663 QString defs_fnamei;
1665 if ( tmst_dname.right( 1 ) !=
"/" )
1667 DbgLv(1) <<
"lTS: tmst_dname" << tmst_dname <<
"tmsfs count" << tmsfs.count();
1669 if ( tmsfs.count() == 2 )
1672 defs_fnamei = tmsfs[ 1 ];
1676 defs_fnamei.contains(
".xml" ) )
1681 else if ( tmsfs[ 0 ].contains(
".xml" ) &&
1682 tmsfs[ 1 ].contains(
".tmst" ) )
1704 le_status->setText( tr(
"Local disk data load IS COMPLETE." ) );
1705 qApp->processEvents();
1706 DbgLv(1) <<
"CGui: ldUS3Dk: RTN";
1712 DbgLv(1) <<
"CGui: ldUS3DB: IN";
1713 le_status->setText( tr(
"Loading data from DB ..." ) );
1714 qApp->processEvents();
1723 QMessageBox::information(
this,
1725 tr(
"Error making the DB connection.\n" ) );
1731 QString dirname = readDir.absolutePath() +
"/" +
runID +
"/";
1733 DbgLv(1) <<
"CGui: ldUS3DB: call rdDBExp";
1734 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1735 le_status->setText( tr(
"Loading data from DB (Experiment) ..." ) );
1736 qApp->processEvents();
1739 QApplication::restoreOverrideCursor();
1741 if ( status != QString(
"" ) )
1743 QMessageBox::information(
this, tr(
"Error" ), status +
"\n" );
1748 DbgLv(1) <<
"CGui: ldUS3DB: call ldUS3Dk";
1749 le_status->setText( tr(
"Loading data from DB (Disk data) ..." ) );
1750 qApp->processEvents();
1758 le_status->setText( tr(
"%1 data triples are NOW LOADED from DB." )
1760 qApp->processEvents();
1762 DbgLv(1) <<
"CGui: ldUS3DB: RTN";
1767 DbgLv(1) <<
"CGui: gExpInf: IN";
1779 QMessageBox::information(
this,
1781 tr(
"Error making the DB connection.\n" ) );
1791 QMessageBox::information(
this,
1793 tr(
"The current runID already exists in the database.\n"
1794 "To edit that information, load it from the database\n"
1795 "to start with." ) );
1805 for (
int i = 0; i <
allData.size(); i++ )
1808 for (
int j = 0; j < raw.
scanData.size(); j++ )
1809 sum += raw.
scanData[ j ].temperature;
1818 strncpy( optSysPtr,
allData[ 0 ].type, 2 );
1819 optSysPtr[ 2 ] =
'\0';
1823 for (
int i = 0; i <
allData.size(); i++ )
1826 for (
int j = 0; j < raw->
scanData.size(); j++ )
1839 for (
int i = 0; i <
ExpData.
rpms.size() - 1; i++ )
1856 connect( expInfo, SIGNAL( updateExpInfoSelection(
US_Experiment& ) ),
1859 connect( expInfo, SIGNAL( cancelExpInfoSelection() ),
1862 connect( expInfo, SIGNAL( use_db (
bool ) ),
1866 DbgLv(1) <<
"CGui: gExpInf: RTN";
1890 const int chanID = 1;
1907 connect( solutionInfo, SIGNAL( updateSolutionGuiSelection(
US_Solution ) ),
1910 connect( solutionInfo, SIGNAL( cancelSolutionGuiSelection() ),
1913 connect( solutionInfo, SIGNAL( use_db (
bool ) ),
1916 solutionInfo->exec();
1924 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1936 int ldax = tripListx + 1;
1941 while ( idax < ldax )
1944 DbgLv(0) <<
"CGui: updSol: dax" << idax
1952 QApplication::restoreOverrideCursor();
1953 QApplication::restoreOverrideCursor();
1993 le_status->setText( tr(
"The current c/c/w information has been"
1994 " copied to all." ) );
1995 qApp->processEvents();
2005 QStringList tripleDescriptions;
2006 QVector< US_DataIO::RawData > currentData;
2014 celchn = celchn.section(
" / ", 0, 1 );
2015 tripleDescriptions << celchn;
2023 currentData << *
outData[ ii ];
2029 tripleDescriptions );
2031 qApp->processEvents();
2050 for (
int trx = trxs; trx < trxe; trx++ )
2051 outData[ trx ]->description = chdesc;
2058 QString chann =
lw_triple->currentItem()->text()
2059 .section(
"/", 1, 1 ).simplified();
2060 pb_dropChan ->setText( tr(
"Drop All Channel '%1's" ).arg( chann ) );
2094 int trListSave =
lw_triple->currentRow();
2099 DbgLv(1) <<
" sTI: nch ntr" << nchans << ntrips <<
"trLSv" << trListSave;
2104 for (
int ccx = 0; ccx < nchans; ccx++ )
2116 + QString(
" / %1-%2 (%3)" )
2121 tripListx = qMax( 0, qMin( trListSave, ( nchans - 1 ) ) );
2133 DbgLv(1) <<
" sTI: pltx" << pltx <<
"nlambda" <<
nlambda;
2138 for (
int wvx = 0; wvx <
nlambda; wvx++ )
2143 if ( ilamb == plambda ) pltx = wvx;
2156 DbgLv(1) <<
" sTI: NOT Mwl";
2157 for (
int trx = 0; trx < ntrips; trx++ )
2162 tripListx = qMax( 0, qMin( trListSave, ( ntrips - 1 ) ) );
2167 connect(
lw_triple, SIGNAL( itemSelectionChanged() ),
2172 QString chann =
lw_triple->currentItem()->text()
2173 .section(
"/", 1, 1 ).simplified();
2174 pb_dropChan ->setText( tr(
"Drop All Channel '%1's" ).arg( chann ) );
2186 dt = ( temp_spread > dt ) ? temp_spread : dt;
2191 QMessageBox::warning(
this,
2192 tr(
"Temperature Problem" ),
2193 tr(
"The temperature in this run varied over the course\n"
2194 "of the run to a larger extent than allowed by the\n"
2195 "current threshold (" )
2197 +
" " +
DEGC + tr(
"). The accuracy of experimental\n"
2198 "results may be affected significantly." ) );
2217 while ( idax < ldax )
2230 int from = (int)scan;
2231 int to = (int)
ct_to->value();
2235 ct_to->disconnect();
2236 ct_to->setValue( scan );
2239 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
2249 int from = (int)
ct_from->value();
2257 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
2266 if ( ( from == 0 && to == 0 ) ||
isMwl )
2278 for (
int i = from - 1; i <= to - 1; i++ ) focus << i;
2289 for (
int i = 0; i <
allData.size(); i++ )
2299 int scanStart = (int)
ct_from->value() - 1;
2300 int scanEnd = (int)
ct_to ->value() - 1;
2303 scanStart = ( scanStart < 0 ) ? 0 : scanStart;
2304 int scanCount = scanEnd - scanStart + 1;
2308 while ( scanNdx < scanStart )
2310 if ( excludes.
contains( scanNdx ) )
2318 while ( excluded < scanCount )
2320 if ( ! excludes.
contains( scanNdx ) )
2354 connect(
picker, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
2355 SLOT (
cClick (
const QwtDoublePoint& ) ) );
2370 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2377 for (
int i = 0; i <
subsets.size() - 1; i++ )
2378 for (
int j = i + 1; j <
subsets.size(); j++ )
2389 DbgLv(1) <<
"CGui:pSS: split CALL";
2404 QApplication::restoreOverrideCursor();
2427 for (
int jj = 0; jj < klamb; jj++ )
2437 int status = QMessageBox::information(
this,
2438 tr(
"Inconsistent Reference Wavelengths" ),
2439 tr(
"Differences in wavelength ranges exist for the channels.\n"
2440 "The safest course is to always open the full range of\n"
2441 "input wavelengths for the Reference channel.\n\n"
2442 "If you are sure that Reference wavelengths will cover\n"
2443 "all other channels, you may \"Proceed\".\n\n"
2444 "Otherwise, you should \"Cancel\".\n" ),
2445 tr(
"&Cancel" ), tr(
"&Proceed" ) );
2447 if ( status == 0 )
return;
2451 connect(
picker, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
2452 SLOT (
cClick (
const QwtDoublePoint& ) ) );
2477 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2479 le_status->setText( tr(
"The reference scans are being defined..." ) );
2480 qApp->processEvents();
2501 for (
int trx = 0; trx <
outData.size(); trx++ )
2512 QApplication::restoreOverrideCursor();
2519 le_status->setText( tr(
"The reference scans have been defined." ) );
2520 qApp->processEvents();
2565 int ref_size = referenceData->
xvalues.size();
2567 for (
int ss = 0; ss < referenceData->
scanData.size(); ss++ )
2605 else if ( countBad > 0 )
2610 for (
int rr = lastGood + 1; rr < ss; rr++ )
2623 for (
int trx = 0; trx <
outData.size(); trx++ )
2627 for (
int ss = 0; ss < currentData->
scanData.size(); ss++ )
2631 for (
int rr = 0; rr < scan->
rvalues.size(); rr++ )
2633 double rvalue = scan->
rvalues[ rr ];
2637 if ( rvalue < 1.0 ) rvalue = 1.0;
2663 QVector< double > scan_nbrs;
2674 double scndiv = 0.1;
2675 double scnmax = (double)riscans;
2676 double scnfra = scnmax * scndiv;
2677 while ( scnfra > 0.999 )
2680 scnfra = scnmax * scndiv;
2682 DbgLv(1) <<
"CGui: show_intensity scndiv scnfra" << scndiv << scnfra;
2684 for (
int ii = 0; ii < riwvlns; ii++ )
2688 for (
int jj = 0; jj < riscans; jj++ )
2690 double scnnbr = wvbase + scndiv * (double)( jj + 1 );
2691 scan_nbrs << scnnbr;
2699 scan_nbrs << (
double)( ii + 1 );
2701 DbgLv(1) <<
"CGui: show_intensity scn1 scnn" << scan_nbrs[0]
2702 << scan_nbrs[ scan_nbrs.size() - 1 ] <<
"isMwl" <<
isMwl;
2707 (
const QVector< double > ) scan_nbrs );
2709 qApp->processEvents();
2715 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
2716 le_status->setText( tr(
"The reference scans are being canceled..." ) );
2717 qApp->processEvents();
2722 for (
int ii = 0; ii <
outData.size(); ii++ )
2728 int iwavl =
out_triples[ ii ].section(
" / ", 2, 2 ).toInt();
2734 <<
"has NO CORRESPONDING RI PROFILE POINT!!!";
2736 QMessageBox::information(
this,
2738 tr(
"Triple %1 has NO CORRESPONDING RI PROFILE POINT!!!" )
2746 if ( jwavl < kwavl )
2757 for (
int jj = 0; jj < currentData->
scanData.size(); jj++ )
2762 for (
int kk = 0; kk < scan->
rvalues.size(); kk++ )
2764 double rvalue = scan->
rvalues[ kk ];
2766 scan->
rvalues[ kk ] = rppro / pow( 10, rvalue );
2793 le_status->setText( tr(
"The reference scans have been canceled." ) );
2794 QApplication::restoreOverrideCursor();
2795 qApp->processEvents();
2801 QStringList selected;
2802 QStringList celchns;
2810 if ( seldiag->exec() != QDialog::Accepted )
2815 int selsiz = selected.size();
2816 DbgLv(1) <<
"DelTrip: selected size" << selsiz;
2821 for (
int ss = 0; ss < selsiz; ss++ )
2828 DbgLv(1) <<
"DelTrip: EXCLUDED ss trx sel" << ss << trx << selected[ss];
2833 DbgLv(1) <<
"DelTrip: bldout call";
2835 DbgLv(1) <<
"DelTrip: bldout RTN";
2852 QString chann =
lw_triple->currentItem()->text()
2853 .section(
"/", 1, 1 ).simplified();
2854 int status = QMessageBox::information(
this,
2855 tr(
"Drop Triples with Selected Channel" ),
2856 tr(
"You have selected a list item that implies you wish to"
2857 " drop triples that have channel '%1'\n\n"
2858 "If that is what you intend, click \"Proceed\".\n\n"
2859 "Otherwise, you should \"Cancel\".\n" ).arg( chann ),
2860 tr(
"&Proceed" ), tr(
"&Cancel" ) );
2862 if ( status != 0 )
return;
2864 for (
int trx = 0; trx <
all_triples.size(); trx++ )
2867 .section(
"/", 1, 1 ).simplified();
2869 if ( tchan == chann )
2872 DbgLv(1) <<
"DelChan: EXCLUDED chn trx" << chann << trx;
2889 QString celchn =
lw_triple->currentItem()->text()
2890 .section(
"/", 0, 1 ).simplified();
2891 int status = QMessageBox::information(
this,
2892 tr(
"Drop Triples of Selected Cell/Channel" ),
2893 tr(
"You have selected a list item that implies you wish to"
2894 " drop all triples from cell/channel \"%1\"\n\n"
2895 "If that is what you intend, click \"Proceed\".\n\n"
2896 "Otherwise, you should \"Cancel\".\n" ).arg( celchn ),
2897 tr(
"&Proceed" ), tr(
"&Cancel" ) );
2899 if ( status != 0 )
return;
2901 for (
int trx = 0; trx <
all_triples.size(); trx++ )
2904 .section(
"/", 0, 1 ).simplified();
2906 if ( tcelchn == celchn )
2909 DbgLv(1) <<
"DelChan: EXCLUDED cc trx" << celchn << trx;
2927 QVector< int > speeds;
2930 int nitrips =
allData.count();
2931 int kotrips = nitrips * nspeeds;
2932 bool is_buoy =
ExpData.
expType.contains(
"buoyancy", Qt::CaseInsensitive );
2934 DbgLv(1) <<
"SV: nspeeds,itrips,otrips" << nspeeds << nitrips << notrips;
2935 DbgLv(1) <<
"SV: speeds" << speeds;
2937 if ( nspeeds < 2 || notrips != kotrips || is_buoy )
2948 QMessageBox::information(
this,
2949 tr(
"Multi-Speed Data to be Saved" ),
2950 tr(
"%1 speeds are present in the data to be saved\n"
2951 "It will be split into single-speed runs.\n"
2952 "The %2 input triples will result in\n"
2953 " %3 total output triples." )
2954 .arg( nspeeds ).arg( nitrips ).arg( notrips ) );
2956 QString runIDsave =
runID;
2957 QString runIDbase = runIDsave +
"-";
2958 QVector< US_DataIO::RawData > oriData =
allData;
2961 if(nripro>(-2))
return;
2965 for (
int spx = 0; spx < nspeeds; spx++ )
2967 int ispeed = speeds[ spx ];
2968 runID = runIDbase + QString::number( ispeed );
2969 double speed = (double)ispeed;
2976 for (
int trx = 0; trx < nitrips; trx++ )
2978 allData[ trx ].scanData.clear();
2983 for (
int ss = 0; ss < oriData[ trx ].scanData.count(); ss++ )
2985 if ( oriData[ trx ].scanData[ ss ].rpm == speed )
2987 allData[ trx ].scanData << oriData[ trx ].scanData[ ss ];
2989 if ( trx == 0 && ss < nripro )
2993 DbgLv(1) <<
"SV: trx" << trx <<
"scans" <<
allData[ trx ].scanData.count();
2999 =
runID +
"." + fname.section(
".", -5, -1 );
3002 memcpy( (
unsigned char*)
out_tripinfo[ trx ].tripleGUID, uuid, 16 );
3003 memcpy( (
unsigned char*)
allData [ trx ].rawGUID , uuid, 16 );
3016 QMessageBox::information(
this,
3017 tr(
"Save is Complete" ),
3018 tr(
"The save of all data and reports is complete." ) );
3027 QString dirname = writeDir.absolutePath() +
"/" +
runID +
"/";
3030 writeDir.exists(
runID ) )
3032 QMessageBox::information(
this,
3034 tr(
"The write directory, " ) + dirname +
3035 tr(
" already exists. Please change run ID to a unique value." ) );
3039 if ( ! writeDir.exists(
runID ) )
3041 if ( ! writeDir.mkpath( dirname ) )
3043 QMessageBox::information(
this,
3045 tr(
"Cannot write to " ) + writeDir.absolutePath() );
3055 status = QMessageBox::information(
this,
3057 tr(
"The run has not yet been associated with the database."
3058 " Click 'OK' to proceed anyway, or click 'Cancel'"
3059 " and then click on the 'Edit Run Information'"
3060 " button to enter this information first.\n" ),
3061 tr(
"&OK" ), tr(
"&Cancel" ),
3067 le_status->setText( tr(
"Saving data to disk ..." ) );
3068 qApp->processEvents();
3070 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3075 QApplication::restoreOverrideCursor();
3083 DbgLv(1) <<
"SV: fileCount" << fileCount;
3088 QString writeFile =
runID +
"."
3090 QMessageBox::information(
this,
3092 tr(
"Cannot open write file: " ) + dirname + writeFile );
3098 QMessageBox::information(
this,
3100 tr(
"The run information file was not written. "
3101 "Please click on the "
3102 "'Associate Run with DB' button \n\n " ) +
3103 QString::number( fileCount ) +
" " +
3104 runID + tr(
" files written." ) );
3111 QMessageBox::information(
this,
3113 tr(
"Solution information is incomplete. Please click on the "
3114 "'Manage Solutions' button for each "
3115 "cell, channel, and wavelength combination \n\n " ) +
3116 QString::number( fileCount ) +
" "
3117 +
runID + tr(
" files written." ) );
3123 QMessageBox::information(
this,
3125 tr(
"Error: " ) + status );
3135 DbgLv(1) <<
"SV: saveRIDisk status" << status;
3139 QString writeFile =
runID +
"."
3141 QMessageBox::information(
this,
3143 tr(
"Cannot open write file: " ) + dirname + writeFile );
3148 QMessageBox::information(
this,
3150 tr(
"Error: " ) + status );
3163 QString filename =
runID +
"."
3165 if ( d.exists( filename ) && ! d.remove( filename ) )
3166 qDebug() <<
"Unable to remove file" << filename;
3174 le_status->setText( tr(
"Writing Time State to disk..." ) );
3179 le_status->setText( tr(
"%1 %2 files were written to disk." )
3180 .arg( fileCount ).arg(
runID ) );
3181 qApp->processEvents();
3197 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3198 le_status->setText( tr(
"Saving plot and report files ..." ) );
3199 qApp->processEvents();
3201 if ( ! QDir( dir ).exists() )
3202 QDir().mkdir( dir );
3208 QStringList rmvfilt;
3209 rmvfilt <<
"*.svgz" <<
"*.png" <<
"*.svg";
3210 QStringList rmvfiles = d.entryList( rmvfilt, QDir::Files, QDir::Name );
3212 for (
int ii = 0; ii < rmvfiles.size(); ii++ )
3213 if ( ! d.remove( rmvfiles[ ii ] ) )
3214 qDebug() <<
"Unable to remove file" << rmvfiles[ ii ];
3221 QStringList parts = t.split(
" / ");
3223 QString cell = parts[ 0 ];
3224 QString channel = parts[ 1 ];
3225 QString wl = parts[ 2 ];
3227 QString triple =
"";
3231 double r = wl.toDouble() * 1000.0;
3232 QString radius = QString::number( (
int)
round( r ) );
3233 triple = cell + channel + radius;
3238 triple = cell + channel + wl;
3241 QString filename = dir +
"/cnvt." + triple +
".raw.svgz";
3248 qDebug() << filename <<
"plot not saved";
3256 le_status->setText( tr(
"Saving of plot files IS COMPLETE." ) );
3257 qApp->processEvents();
3258 QApplication::restoreOverrideCursor();
3259 QApplication::restoreOverrideCursor();
3274 QMessageBox::information(
this,
3276 tr(
"Database connectivity error" ) );
3281 DbgLv(1) <<
"DBSv: tripleGUID "
3287 int status = QMessageBox::information(
this,
3289 tr(
"This will overwrite the raw data currently in the " ) +
3290 tr(
"database, and all existing edit profiles, models " ) +
3291 tr(
"and noise data will be deleted too. Proceed? " ),
3292 tr(
"&OK" ), tr(
"&Cancel" ),
3294 if ( status != 0 )
return;
3299 int status = QMessageBox::information(
this,
3301 tr(
"Once this data is written to the DB you will not " ) +
3302 tr(
"be able to make changes to it without erasing the " ) +
3303 tr(
"edit profiles, models and noise files too. Proceed? " ),
3304 tr(
"&OK" ), tr(
"&Cancel" ),
3306 if ( status != 0 )
return;
3310 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3311 le_status->setText( tr(
"Preparing Save with DB check ..." ) );
3312 qApp->processEvents();
3319 QApplication::restoreOverrideCursor();
3325 QMessageBox::information(
this,
3327 tr(
"This investigator or instrument operator was not found\n"
3328 "in the database.\n" ) );
3334 QMessageBox::information(
this,
3336 tr(
"Bad GUID format.\n"
3337 "Please click on Edit Run Information"
3338 " and re-select hardware.\n" ) );
3344 QMessageBox::information(
this,
3346 tr(
"Don't recognize the rotor configuration.\n"
3347 "Please click on Edit Run Information"
3348 " and re-select hardware.\n") );
3355 QMessageBox::information(
this,
3362 le_status->setText( tr(
"Preparing Save with Disk write ..." ) );
3363 qApp->processEvents();
3369 DbgLv(1) <<
"DBSv: local files saved";
3371 QString error = QString(
"" );
3375 QString dir = resultDir.absolutePath() +
"/" +
ExpData.
runID +
"/";
3379 QMessageBox::information(
this,
3381 tr(
"Cannot read from " ) + dir );
3385 QStringList nameFilters = QStringList(
"*.auc" );
3387 QDir readDir( dir );
3389 QStringList files = readDir.entryList( nameFilters,
3390 QDir::Files | QDir::Readable, QDir::Name );
3391 DbgLv(1) <<
"DBSv: files count" << files.size();
3393 if ( files.size() == 0 )
3395 QMessageBox::warning(
this,
3396 tr(
"No Files Found" ),
3397 tr(
"There were no files of the form *.auc\n"
3398 "found in the specified directory." ) );
3405 QMessageBox::warning(
this,
3406 tr(
"Duplicate runID" ),
3407 tr(
"This runID already exists in the database. To edit that "
3408 "run information, load it from there to begin with.\n" ) );
3415 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3416 le_status->setText( tr(
"Saving Experiment to DB ..." ) );
3417 qApp->processEvents();
3419 QApplication::restoreOverrideCursor();
3423 QMessageBox::warning(
this,
3424 tr(
"Project missing" ),
3425 tr(
"The project associated with this experiment could not be "
3426 "updated or added to the database.\n" ) );
3432 QMessageBox::warning(
this,
3433 tr(
"Duplicate runID" ),
3434 tr(
"The runID already exists in the database.\n" ) );
3441 QMessageBox::warning(
this,
3443 tr(
"There was a problem with the xml data"
3444 " read from the database.\n" ) );
3449 QMessageBox::warning(
this,
3450 tr(
"Problem saving experiment information" ),
3451 tr(
"MySQL Error : " ) + db.
lastError() +
" ("
3452 + QString::number( status ) +
")" );
3461 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3462 le_status->setText( tr(
"Writing raw data to DB ..." ) );
3463 qApp->processEvents();
3465 QString writeStatus =
3468 QApplication::restoreOverrideCursor();
3470 if ( ! writeStatus.isEmpty() )
3472 QMessageBox::warning(
this,
3473 tr(
"Problem saving experiment" ),
3474 tr(
"Unspecified database error: " ) + writeStatus );
3475 le_status->setText( tr(
"*ERROR* Problem saving experiment." ) );
3481 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3482 le_status->setText( tr(
"Writing updated Raw records to disk..." ) );
3486 QApplication::restoreOverrideCursor();
3487 qApp->processEvents();
3488 DbgLv(1) <<
"DBSv: REPEAT disk save for raw IDs";
3492 le_status->setText( tr(
"Writing Time State to DB..." ) );
3495 le_status->setText( tr(
"DB data save complete. Saving reports..." ) );
3496 qApp->processEvents();
3501 QApplication::restoreOverrideCursor();
3502 QApplication::restoreOverrideCursor();
3504 le_status->setText( tr(
"DB data and reports save IS COMPLETE." ) );
3505 qApp->processEvents();
3520 QMessageBox::information(
this,
3522 tr(
"Database connectivity error" ) );
3528 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3530 QDir d( dir,
"cnvt*", QDir::Name, QDir::Files | QDir::Readable );
3532 QStringList files = d.entryList( QDir::Files );
3535 QDir d2( dir,
"rundetail*", QDir::Name, QDir::Files | QDir::Readable );
3537 files << d2.entryList( QDir::Files );
3540 QString now = QDateTime::currentDateTime().toString();
3545 myReport.
html =
"<p>Report created " + now +
"</p>";
3548 QString errorMsg =
"";
3549 foreach( QString file, files )
3552 QStringList parts = file.split(
"." );
3556 QString description = QString(
"" );
3561 description =
outData[ ii ]->description;
3569 dir, file, &db, 1, description );
3572 errorMsg += file +
" was not saved to report database; error code: "
3573 + QString::number( status ) +
"\n";
3574 qDebug() <<
"US_ConvertGui.saveDocumentFromFile error: "
3578 QApplication::restoreOverrideCursor();
3580 if ( ! errorMsg.isEmpty() )
3582 QMessageBox::warning(
this,
3583 tr(
"Problem saving reports to DB" ),
3594 dir = QFileDialog::getExistingDirectory(
this,
3595 tr(
"Raw Data Directory" ),
3597 QFileDialog::DontResolveSymlinks );
3599 dir.replace(
"\\",
"/" );
3601 if ( dir.isEmpty() )
3604 QDir readDir( dir,
"*", QDir::Name, QDir::Files | QDir::Readable );
3605 readDir.makeAbsolute();
3606 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
3609 QString new_runID = dir.section(
"/", -2, -2 );
3610 QRegExp rx(
"[^A-Za-z0-9_-]" );
3613 bool runID_changed =
false;
3614 while ( ( pos = rx.indexIn( new_runID ) ) != -1 )
3616 new_runID.replace( pos, 1,
"_" );
3617 runID_changed =
true;
3619 DbgLv(1) <<
"CGui:gI: dir" << dir <<
"new_runID" << new_runID
3620 <<
"rID_chgd" << runID_changed;
3623 if ( runID_changed )
3625 QMessageBox::warning(
this,
3626 tr(
"RunID Name Changed" ),
3627 tr(
"The runID name has been changed. It may consist only"
3628 "of alphanumeric \n"
3629 " characters, the underscore, and the hyphen. New runID: " )
3641 QStringList nameFilters = QStringList(
"*" );
3642 QStringList files = readDir.entryList( nameFilters,
3643 QDir::Files | QDir::Readable, QDir::Name );
3652 int ntotf = files.size();
3653 DbgLv(1) <<
"CGui:gI: ntotf" << ntotf;
3655 for (
int jj = 0; jj < ntotf; jj++ )
3657 QString fname = files[ jj ];
3659 if ( fname.endsWith(
".mwrs" ) )
3662 else if ( fname.endsWith(
".auc" ) )
3665 else if ( fname.endsWith(
"time_state.xml" ) )
3670 else if ( fname.endsWith(
"time_state.tmst" ) )
3678 DbgLv(1) <<
"CGui:gI: nmwrs nauc nother" << nmwrs << nauc << nother;
3680 if ( nmwrs > nother )
3683 else if ( nauc > nother )
3689 DbgLv(1) <<
"CGui:gI: RTN impType" << impType;
3698 DbgLv(1) <<
"CGui:RD: rdLegDat CALL";
3699 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3701 QApplication::restoreOverrideCursor();
3704 if (
legacyData.size() == 0 )
return(
false );
3714 DbgLv(1) <<
"CGui:CV: IN";
3719 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3722 DbgLv(1) <<
"CGui:CV: ndat ntrip runType" <<
allData.size()
3724 QApplication::restoreOverrideCursor();
3726 if (
allData.size() == 0 )
return(
false );
3765 QMessageBox::information(
this,
3767 tr(
"Database connectivity error" ) );
3772 QStringList q(
"get_abstractCenterpiece_names" );
3775 QList<listInfo> options;
3779 option.
ID = db.
value( 0 ).toString();
3785 if ( options.size() > 0 )
3788 DbgLv(1) <<
"CGui: centpInfoDB RTN";
3798 if ( ! f.open( QIODevice::ReadOnly ) )
return false;
3800 QList<listInfo> options;
3801 QXmlStreamReader xml( &f );
3802 while ( ! xml.atEnd() )
3806 if ( xml.isStartElement() )
3808 if ( xml.name() ==
"abstractCenterpiece" )
3811 QXmlStreamAttributes a = xml.attributes();
3812 option.
ID = a.value(
"id").toString();
3813 option.
text = a.value(
"name").toString();
3819 bool error = xml.hasError();
3822 if ( error )
return false;
3825 if ( options.size() > 0 )
3828 for (
int i = 0; i < options.size() - 1; i++ )
3829 for (
int j = i + 1; j < options.size(); j++ )
3830 if ( options[ i ].
text > options[ j ].
text )
3831 options.swap( i, j );
3836 DbgLv(1) <<
"CGui: centpInfoDk RTN";
3847 if ( currentData.
scanData.empty() )
return;
3850 DbgLv(1) <<
" PlCur: PlTit RTN";
3863 char chtype[ 3 ] = {
'R',
'A',
'\0' };
3866 QString dataType = QString( chtype ).left( 2 );
3868 QStringList parts = triple.split(
" / ");
3869 DbgLv(1) <<
" PlTit: triple" << triple <<
"parts" << parts;
3871 QString cell = parts[ 0 ];
3872 QString channel = parts[ 1 ];
3877 QString xLegend = tr(
"Radius (in cm)" );
3878 QString yLegend = tr(
"Absorbance" );
3879 QString ccwlong =
runID + tr(
"\nCell: " ) + cell
3880 + tr(
" Channel: " ) + channel
3881 + tr(
" Wavelength: " ) + wavelen;
3882 QString ccrlong = QString( ccwlong ).replace(
"Wavelength:",
"Radius:" );
3883 DbgLv(1) <<
" PlTit: dataType" << dataType;
3885 if ( dataType ==
"RA" )
3887 title = tr(
"Radial Absorbance Data\nRun ID: " ) + ccwlong;
3890 else if ( dataType ==
"RI" &&
isPseudo )
3892 title = tr(
"Pseudo Absorbance Data\nRun ID: " ) + ccwlong;
3895 else if ( dataType ==
"RI" )
3897 title = tr(
"Radial Intensity Data\nRun ID: " ) + ccwlong;
3898 yLegend = tr(
"Radial Intensity at " ) + wavelen +
" nm";
3901 else if ( dataType ==
"IP" )
3903 title = tr(
"Interference Data\nRun ID: " ) + ccwlong;
3904 yLegend = tr(
"Fringes" );
3907 else if ( dataType ==
"FI" )
3909 title = tr(
"Fluorescence Intensity Data\nRun ID: " ) + ccwlong;
3910 yLegend = tr(
"Fluorescence Intensity" );
3913 else if ( dataType ==
"WA" )
3915 title = tr(
"Wavelength Data\nRun ID: " ) + ccrlong;
3916 xLegend = tr(
"Wavelength" );
3917 yLegend = tr(
"Absorbance" );
3920 else if ( dataType ==
"WI" )
3922 title = tr(
"Wavelength Intensity Data\nRun ID: " ) + ccrlong;
3923 xLegend = tr(
"Wavelength" );
3924 yLegend = tr(
"Intensity" );
3928 title = tr(
"File type not recognized" );
3931 data_plot->setAxisTitle( QwtPlot::yLeft, yLegend );
3932 data_plot->setAxisTitle( QwtPlot::xBottom, xLegend );
3943 int size = currentData->
xvalues.size();
3945 QVector< double > rvec( size );
3946 QVector< double > vvec( size );
3948 double* r = rvec.data();
3949 double* v = vvec.data();
3951 double maxR = -1.0e99;
3952 double minR = 1.0e99;
3953 double maxV = -1.0e99;
3954 double minV = 1.0e99;
3956 for (
int i = 0; i < currentData->
scanData.size(); i++ )
3959 if ( currentExcludes.
contains( i ) )
continue;
3962 for (
int j = 0; j < size; j++ )
3964 r[ j ] = currentData->
radius( j );
3967 if ( v[ j ] > 1.0e99 || isnan( v[ j ] ) )
3971 qDebug() <<
"(r, v) = ( " << r[j] <<
", " << v[j] <<
")"
3972 <<
" (minR, maxR) = ( " << minR <<
", " << maxR <<
")" << endl
3973 <<
" (minV, maxV) = ( " << minV <<
", " << maxV <<
")" << endl;
3977 maxR =
max( maxR, r[ j ] );
3978 minR =
min( minR, r[ j ] );
3979 maxV =
max( maxV, v[ j ] );
3980 minV =
min( minV, v[ j ] );
3983 QString title = tr(
"Raw Data at " )
3984 + QString::number( s->
seconds ) + tr(
" seconds" );
3987 c->setData( r, v, size );
3992 double padR = ( maxR - minR ) / 30.0;
3993 double padV = ( maxV - minV ) / 30.0;
3995 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
3996 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
4010 QwtPlotItemList list =
data_plot->itemList();
4011 QList< QwtPlotCurve* > curves;
4013 for (
int i = 0; i < list.size(); i++ )
4015 if ( list[ i ]->title().text().contains(
"Raw" ) )
4016 curves << dynamic_cast< QwtPlotCurve* >( list[ i ] );
4019 QPen
p = curves[ 0 ]->pen();
4020 QBrush b = curves[ 0 ]->brush();
4024 for (
int i = 0; i < curves.size(); i++ )
4026 if ( focus.contains( i ) )
4028 p.setColor( Qt::red );
4036 curves[ i ]->setPen ( p );
4037 curves[ i ]->setBrush( b );
4049 QwtScaleDiv* y_axis =
data_plot->axisScaleDiv( QwtPlot::yLeft );
4051 double padding = ( y_axis->upperBound() - y_axis->lowerBound() ) / 30.0;
4054 v [ 0 ] = y_axis->upperBound() - padding;
4055 v [ 1 ] = y_axis->lowerBound() + padding;
4058 v_line->setData( r, v, 2 );
4060 QPen pen = QPen( QBrush( Qt::white ), 2.0 );
4061 v_line->setPen( pen );
4068 QMessageBox::warning(
this, tr(
"Database Problem" ),
4069 tr(
"Database returned the following error: \n" ) + error );
4075 DbgLv(1) <<
"lambdaStartChanged" << value;
4080 DbgLv(1) <<
"lambdaStartChanged" << value <<
"sl el tLx cCh"
4086 .tripleDesc.section(
" / ", 2, 2 ).toInt();
4090 DbgLv(1) <<
"lStChg: trx iwavl chnID excl" << trx << iwavl
4095 DbgLv(1) <<
"lStChg: BlOutDa RTN";
4097 DbgLv(1) <<
"lStChg: RsLambd RTN";
4103 DbgLv(1) <<
"lambdaEndChanged" << value;
4108 DbgLv(1) <<
"lEnChg: val" << value <<
"sl el tLx cCh"
4114 .tripleDesc.section(
" / ", 2, 2 ).toInt();
4121 DbgLv(1) <<
"lEnChg: BlOutDa RTN";
4123 DbgLv(1) <<
"lEnChg: RsLambd RTN";
4139 int wvx = qMax( 0,
cb_lambplot->currentIndex() - 1 );
4148 int wvx = qMin( wvxmax,
cb_lambplot->currentIndex() + 1 );
4182 <<
" triple" <<
lw_triple->currentItem()->text();
4190 connect(
cb_lambstrt, SIGNAL( currentIndexChanged(
int ) ),
4192 connect(
cb_lambstop, SIGNAL( currentIndexChanged(
int ) ),
4194 connect(
cb_lambplot, SIGNAL( currentIndexChanged(
int ) ),
4219 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
4230 for (
int wvx = 0; wvx <
nlambda; wvx++ )
4235 if ( ilamb == plambda ) plx = wvx;
4238 DbgLv(1) <<
"rsL: plambda" << plambda <<
"plx" << plx;
4242 QStringList celchns;
4243 QString pwvln =
" / " + QString::number(
exp_lambdas[ 0 ] )
4244 +
"-" + QString::number(
exp_lambdas[ nlambda - 1 ] )
4245 +
" (" + QString::number( nlambda ) +
")";
4249 DbgLv(1) <<
"rsL: ncc nl szcc szci" << ncelchn << nlambda << celchns.count()
4252 for (
int ii = 0; ii < ncelchn; ii++ )
4258 QApplication::restoreOverrideCursor();
4261 DbgLv(1) <<
"rsL: sTrInf RTN";
4264 DbgLv(1) <<
"rsL: InExcl RTN";
4267 DbgLv(1) <<
"rsL: PlCurr RTN";
4273 QVector< double > ri_prof;
4280 int ref_size = refData->
xvalues.size();
4286 DbgLv(1) <<
"PseCalcAvgMWL: ccx tripx nlambda" << ccx << tripx <<
nlambda;
4290 for (
int wvx = 0; wvx <
nlambda; wvx++ )
4293 ref_size = refData->
xvalues.size();
4294 int nscan = refData->
scanData.size();
4298 for (
int ss = 0; ss < nscan; ss++ )
4317 double rip_avg = count > 0 ? ( sum / (double)count ) : 1.0;
4323 int rip_size = ri_prof.size();
4325 DbgLv(1) <<
"PseCalcAvgMWL: wvx" << wvx <<
"rsiz wavl" << rip_size << iwavl;
4329 for (
int trx = 0; trx <
outData.size(); trx++ )
4331 int jwavl =
out_triples[ trx ].section(
" / ", -1, -1 ).toInt();
4333 if ( jwavl != iwavl )
continue;
4338 for (
int ss = 0; ss < currentData->
scanData.size(); ss++ )
4342 int ndx = ( ss < rip_size ) ? ss : rip_size - 1;
4343 double ripval = ri_prof[ ndx ];
4345 for (
int rr = 0; rr < scan->
rvalues.size(); rr++ )
4349 double rvalue = qMax( 1.0, scan->
rvalues[ rr ] );
4351 scan->
rvalues[ rr ] = log10( ripval / rvalue );
4359 DbgLv(1) <<
"PseCalcAvgMWL: tripx" << tripx;
4380 for (
int ii = 0; ii <
nlamb_i; ii++ )
4382 QString clamb = QString::number(
all_lambdas[ ii ] );
4392 for (
int ii = 0; ii <
nlambda; ii++ )
4394 QString clamb = QString::number(
exp_lambdas[ ii ] );
4419 static QChar clambda( 955 );
4420 QString lambmsg = tr(
"MWL imported : %1 triples : %2 %3 to %4" )
4421 .arg( ntriple ).arg( clambda ).arg( rlamb_s ).arg( rlamb_e );
4424 qApp->processEvents();
4431 bool success =
true;
4433 DbgLv(1) <<
"CGui:IOD: have_trip" << have_trip;
4447 for (
int trx = 0; trx <
allData.size(); trx++ )
4458 QString triple = QString::number( edata->cell ) +
" / "
4459 + QString( edata->channel ) +
" / "
4461 ? QString::number( qRound( edata->scanData[ 0 ].wavelength ) )
4462 : tripinfo.
tripleDesc.section(
" / ", 2, 2 ) );
4463 QString celchn = triple.section(
" / ", 0, 1 );
4465 chanID = ( chanID < 1 ) ? (
all_channels.count() + 1 ) : chanID;
4471 chaninfo = tripinfo;
4473 DbgLv(1) <<
"CGui:IOD: trx" << trx <<
"triple" << triple;
4490 DbgLv(1) <<
"CGui:IOD: ochx" << trx <<
"celchn cID" << celchn << chanID;
4495 char chtype[ 3 ] = {
'R',
'A',
'\0' };
4496 strncpy( chtype,
allData[ 0 ].type, 2 );
4497 QString dataType = QString( chtype ).left( 2 );
4501 DbgLv(1) <<
"CGui:IOD: rSS nspeed" << nspeed;
4514 DbgLv(1) <<
"CGui:IOD: isMwl" <<
isMwl <<
"c.count t.count"
4521 DbgLv(1) <<
"CGui:IOD: isMwl" <<
isMwl <<
"c.count t.count"
4527 DbgLv(1) <<
"CGui:IOD: updSS call";
4528 QVector< SP_SPEEDPROFILE > testss =
speedsteps;
4535 else if ( nstest < 0 )
4537 QMessageBox::critical(
this,
4538 tr(
"Invalid MWL Speedsteps" ),
4539 tr(
"The \"set_speed\" values in MWRS files have"
4540 " resulted in too many speed steps or steps"
4541 " where speeds decrease.\n\nImport is ABORTED!!" ) );
4545 DbgLv(1) <<
"CGui:IOD: updSS nspeed nstest nspeedc"
4546 << nspeed << nstest << nspeedc <<
"ss0 timf omgf"
4555 DbgLv(1) <<
"CGui:IOD: trx" << trx <<
"triple" << triple;
4559 DbgLv(1) <<
"CGui:IOD: nspeed" << nspeed <<
"sp0.rspeed sp0.avspeed"
4564 DbgLv(1) <<
"CGui:IOD: RETURN";
4579 for (
int trx = 0; trx <
allData.size(); trx++ )
4583 if ( tripinfo->
excluded )
continue;
4588 QString celchn = triple.section(
" / ", 0, 1 );
4609 connect(
ct_tolerance, SIGNAL( valueChanged (
double ) ),
4632 for (
int trx = 0; trx < nitrips; trx++ )
4636 for (
int ss = 0; ss < edata->
scanData.size(); ss++ )
4638 int speed = qRound( edata->
scanData[ ss ].rpm );
4640 if ( ! speeds.contains( speed ) )
4646 if ( speed != pspeed )
4652 DbgLv(1) <<
"cS: trx nspeed notrips" << nspeed << notrips;
4655 if ( pNotrips != NULL )
4656 *pNotrips = notrips;
4665 QString tmst_fbase =
runID +
".time_state.tmst";
4666 QString defs_fbase =
runID +
".time_state.xml";
4668 if ( tmst_fdir.right( 1 ) !=
"/" ) tmst_fdir +
"/";
4669 QString tmst_fname = tmst_fdir + tmst_fbase;
4670 QString defs_fname = tmst_fdir + defs_fbase;
4671 QString defs_fnamei = QString(
tmst_fnamei ).section(
".", 0, -2 ) +
".xml";
4674 QVector< double > rrpms;
4676 DbgLv(1) <<
"wTS: nspeed" << nspeed <<
"tmst_fname" << tmst_fname;
4687 int ntimes = timestate.
time_range( &constti, &timeinc, &ftime );
4688 int nvalues = timestate.
field_keys( &fkeys, &ffmts );
4692 if (
tmst_fnamei == tmst_fname && defs_fnamei == defs_fname )
4694 DbgLv(1) <<
"wTS: existing TMST in run directory - NO UPDATE.";
4699 bool use_exstsf = ( ntimes >= nmscans );
4700 use_exstsf = ( fkeys.contains(
"RawSpeed" ) ) ? use_exstsf :
false;
4701 use_exstsf = ( nvalues > 2 ) ? use_exstsf :
false;
4704 use_exstsf = ( ntimes > nmscans ) ? use_exstsf :
false;
4705 use_exstsf = ( timeinc > 0.0 ) ? use_exstsf :
false;
4709 use_exstsf = ( ntimes >= nmscans ) ? use_exstsf :
false;
4710 use_exstsf = ( timeinc == 0.0 ) ? use_exstsf :
false;
4711 use_exstsf = ( fkeys.contains(
"Time" ) ) ? use_exstsf :
false;
4713 DbgLv(1) <<
"wTS: use_exstsf" << use_exstsf <<
"ntimes nmscans nvalues"
4714 << ntimes << nmscans << nvalues;
4722 QFile::copy( defs_fnamei, defs_fname );
4723 DbgLv(1) <<
"wTS: COPY from IMPORTS";
4730 if ( defs_fname != defs_fnamei )
4731 QFile::rename( defs_fnamei, defs_fname );
4732 DbgLv(1) <<
"wTS: RENAME in RESULTS";
4738 QFile::copy( defs_fnamei, defs_fname );
4750 QFile::remove( defs_fnamei );
4752 DbgLv(1) <<
"wTS: DELETE from RESULTS";
4756 DbgLv(1) <<
"wTS: EMPTY: tmst_fnamei";
4760 timestate.
set_key(
"Time",
"F4" );
4761 timestate.
set_key(
"RawSpeed",
"I4" );
4762 timestate.
set_key(
"SetSpeed",
"I4" );
4763 timestate.
set_key(
"Omega2T",
"F4" );
4764 timestate.
set_key(
"Temperature",
"F4" );
4765 timestate.
set_key(
"Scan",
"I2" );
4770 for (
int sc = 0; sc < rdata->
scanData.size(); sc++ )
4773 int scan_nbr = sc + 1;
4774 double sctime = scan->
seconds;
4775 double raw_speed = ( sc < nmscans ) ? rrpms[ sc ] : scan->
rpm;
4776 int set_speed = qRound( raw_speed / 100.0 ) * 100;
4779 while( sctime >
speedsteps[ ssx ].time_last && ssx < (nspeed - 1) )
4781 set_speed =
speedsteps[ ssx ].set_speed <= 0 ? set_speed
4784 DbgLv(1) <<
"wTS: sc snbr" << sc << scan_nbr <<
"set_speed" << set_speed
4785 <<
"raw_speed" << raw_speed;
4788 timestate.
set_value(
"RawSpeed", raw_speed );
4789 timestate.
set_value(
"SetSpeed", set_speed );
4792 timestate.
set_value(
"Scan", scan_nbr );
4816 DbgLv(1) <<
"wTSdb: connect" << db.lastErrno() << db.lastError();
4819 DbgLv(1) <<
"wTSdb: connect" << db.lastErrno() << db.lastError();
4821 QString tmst_fbase =
runID +
".time_state.tmst";
4822 QString tmst_fdir = ( QString(
currentDir ).right( 1 ) ==
"/" )
4824 QString tmst_fname = tmst_fdir + tmst_fbase;
4826 DbgLv(1) <<
"wTSdb: fname " << tmst_fname <<
"cksm" << tmst_cksm;
4831 DbgLv(1) <<
"wTSdb: post-create timestateID" << timestateID;
4835 if ( timestateID > 0 )
4839 NULL, NULL, &cksum, NULL );
4840 DbgLv(1) <<
"wTSdb: examine status" << status <<
"cksum-db" << cksum;
4842 if ( status ==
US_DB2::OK && cksum != tmst_cksm )
4846 DbgLv(1) <<
"wTSdb: upload status" << status;
4861 DbgLv(1) <<
"BldLCtr: ntrip" << ntrip;
4863 DbgLv(1) <<
"BldLCtr: st ccx" << ccx;
4868 for (
int trx = 0; trx < ntrip; trx++ )
4871 int iwavl =
out_triples [ trx ].section(
" / ", 2, 2 ).toInt();
4872 DbgLv(1) <<
"BldLCtr: trx ichan ccx iwavl" << trx << ichan << ccx << iwavl;
4877 DbgLv(1) <<
"BldLCtr: trx ichan ccx ccxo iwavl nlam" << trx << ichan << ccx