1 #include <QApplication>
26 #include "qwt_scale_engine.h"
37 int main(
int argc,
char* argv[] )
39 QApplication application( argc, argv );
47 return application.exec();
65 setWindowTitle( tr(
"Import Ramp Data (Lechner, 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_banner( tr(
"Status:" ) );
108 stpal.setColor( QPalette::Text, Qt::blue );
112 QLabel* lb_runID =
us_label( tr(
"Run ID:" ) );
114 lb_runID->setVisible(
false );
122 QLabel* lb_run =
us_banner( tr(
"Load the Run" ) );
149 QFontMetrics fmet( font );
153 static QChar clambda( 955 );
171 QGridLayout* mwl_controls =
new QGridLayout();
173 QLabel* lb_runinfo =
us_banner( tr(
"Run Information" ) );
176 QLabel* lb_runID2 =
us_label( tr(
"Run ID:" ) );
181 QLabel* lb_dir =
us_label( tr(
"Directory:" ) );
191 QGridLayout* ccw =
new QGridLayout();
208 tr(
"Cell / Channel / Wavelength" ), -1 );
213 tr(
"Enter Associated Triple (c/c/w) Info:" ) );
214 lb_ccwinfo->setMaximumHeight(25);
230 QLabel* lb_solution =
us_label( tr(
"Solution:" ) );
240 settings ->addWidget( lb_DB, row++, 0, 1, 4 );
241 settings ->addWidget( wg_investigator, row, 0, 1, 2 );
244 settings ->addWidget( lb_run, row++, 0, 1, 4 );
249 settings ->addWidget(
pb_loadUS3, row++, 2, 1, 2 );
255 ccw ->addWidget( lb_runinfo, row++, 0, 1, 12 );
256 ccw ->addWidget( lb_runID2, row, 0, 1, 3 );
257 ccw ->addWidget(
le_runID2, row++, 3, 1, 9 );
258 ccw ->addWidget( lb_dir, row, 0, 1, 3 );
259 ccw ->addWidget(
le_dir, row++, 3, 1, 9 );
260 ccw ->addWidget(
lb_triple, row++, 0, 1, 12 );
264 ccw ->addWidget(
lw_triple, row, 0, 8, 4 );
268 ccw ->addWidget(
lb_Bottom, row, 4, 1, 4 );
269 ccw ->addWidget(
le_Bottom, row++, 8, 1, 4 );
270 ccw ->addWidget(
lb_Radius, row, 4, 1, 4 );
271 ccw ->addWidget(
le_Radius, row++, 8, 1, 4 );
273 ccw ->addWidget( lb_ccwinfo, row++, 4, 1, 8 );
281 ccw ->addWidget( lb_solution, row, 0, 1, 3 );
283 mwl_controls ->addWidget(
lb_mwlctrl, row++, 0, 1, 4 );
284 mwl_controls ->addWidget(
le_lambraw, row++, 0, 1, 4 );
285 mwl_controls ->addWidget(
lb_lambstrt, row, 0, 1, 1 );
286 mwl_controls ->addWidget(
cb_lambstrt, row, 1, 1, 1 );
287 mwl_controls ->addWidget(
lb_lambstop, row, 2, 1, 1 );
288 mwl_controls ->addWidget(
cb_lambstop, row++, 3, 1, 1 );
289 mwl_controls ->addWidget(
lb_lambplot, row, 0, 1, 1 );
290 mwl_controls ->addWidget(
cb_lambplot, row, 1, 1, 1 );
291 mwl_controls ->addWidget(
pb_lambprev, row, 2, 1, 1 );
292 mwl_controls ->addWidget(
pb_lambnext, row++, 3, 1, 1 );
294 ccw ->addWidget( lb_status, row++, 0, 1, 12 );
295 ccw ->addWidget(
le_status, row++, 0, 1, 12 );
297 settings ->addLayout( ccw, row++, 0, 1, 4 );
299 settings ->addWidget( pb_reset, row, 0, 1, 1 );
300 settings ->addWidget( pb_help, row, 1, 1, 1 );
301 settings ->addWidget(
pb_saveUS3, row, 2, 1, 1 );
302 settings ->addWidget( pb_close, row++, 3, 1, 1 );
308 tr(
"Intensity (/AU)" ) );
312 data_plot->enableAxis( QwtPlot::xBottom,
true );
313 data_plot->enableAxis( QwtPlot::yLeft ,
true );
315 data_plot->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
316 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
319 picker ->setRubberBand ( QwtPicker::VLineRubberBand );
320 picker->setMousePattern ( QwtEventPattern::MouseSelect1,
321 Qt::LeftButton, Qt::ControlModifier );
323 QGridLayout* todo =
new QGridLayout();
326 QLabel* lb_todoinfo =
us_banner( tr(
"Instructions ( to do list )" ), 0 );
330 lw_todoinfo->setSelectionMode( QAbstractItemView::NoSelection );
333 todo->addWidget( lb_todoinfo, row++, 0, 1, 4 );
338 connect( pb_investigator, SIGNAL( clicked() ),
356 connect(
lw_triple, SIGNAL( itemSelectionChanged() ),
370 connect( pb_reset, SIGNAL( clicked() ),
372 connect( pb_help, SIGNAL( clicked() ),
376 connect( pb_close, SIGNAL( clicked() ),
381 QVBoxLayout* left =
new QVBoxLayout;
383 left->addLayout( settings );
385 QVBoxLayout* right =
new QVBoxLayout;
387 right->addLayout( mwl_controls );
388 right->addLayout( plot );
389 right->addLayout( todo );
391 QHBoxLayout*
main =
new QHBoxLayout(
this );
392 main->setSpacing ( 2 );
393 main->setContentsMargins ( 2, 2, 2, 2 );
395 main->addLayout( left );
396 main->addLayout( right );
397 main->setStretchFactor( left, 3 );
398 main->setStretchFactor( right, 5 );
400 DbgLv(1) <<
"CGui: GUI setup complete";
402 DbgLv(1) <<
"CGui: reset complete";
409 QString dir = QFileDialog::getExistingDirectory(
this,
410 tr(
"Raw MWL Data Directory" ),
412 QFileDialog::DontResolveSymlinks );
417 qApp->processEvents();
419 if ( dir.isEmpty() )
return;
421 dir.replace(
"\\",
"/" );
426 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
429 le_status->setText( tr(
"Importing MWL Ramp data ..." ) );
430 qApp->processEvents();
432 QString runID_xml_mwl;
444 if (
runID != runID_xml_mwl )
446 int status = QMessageBox::information(
this,
448 tr(
"The runID from xml-file doesn't match directory name." ),
449 tr(
"&OK" ), tr(
"&Cancel" ),
455 QApplication::restoreOverrideCursor();
459 runID = runID_xml_mwl;
492 QApplication::restoreOverrideCursor();
497 le_status->setText( tr(
"Finished Import of MWL Ramp data" ));
541 lw_todoinfo->addItem(
"Load or import some AUC data" );
545 data_plot ->setAxisScale( QwtPlot::xBottom, 0, 1e10 );
546 data_plot ->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
576 int status = QMessageBox::information(
this,
577 tr(
"New Data Warning" ),
578 tr(
"This will erase all data currently on the screen, and "
579 "reset the program to its starting condition. No hard-drive "
580 "data or database information will be affected. Proceed? " ),
581 tr(
"&OK" ), tr(
"&Cancel" ),
584 if ( status != 0 )
return;
589 le_status->setText( tr(
"(no data loaded)" ) );
592 data_plot->setTitle( tr(
"Ramp Data" ) );
601 SIGNAL( investigator_accepted(
int ) ),
612 QString number = ( invID > 0 )
613 ? QString::number( invID ) +
": "
671 DbgLv(1) <<
"CGui: enabCtl: have-data";
690 lb_triple ->setText( tr(
"Cell / Channel" ) );
701 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}$" );
712 DbgLv(1) <<
"CGui: enabCtl: enabRunID complete";
716 DbgLv(1) <<
"CGui: enabCtl: enabSvBtn complete";
726 connect(
le_runID2, SIGNAL( textEdited( QString ) ),
745 bool completed =
true;
753 + tr(
": Load or import some AUC data" ) );
762 + tr(
": Load or import some AUC data" ) );
767 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}$" );
779 + tr(
": Edit run information" ) );
791 tr(
": Select solution for triple " ) +
803 tr(
": Select centerpiece for triple " ) +
820 tr(
": Verify database connectivity" ) );
835 tr(
": Select a different runID" ) );
844 + tr(
": Select operator in run information" ) );
855 tr(
": Define reference scans" ) );
866 QRegExp rx(
"^[A-Za-z0-9_-]{1,80}$" );
869 if ( rx.indexIn( new_runID ) >= 0 )
872 if (
runID.length() > 50 )
874 QMessageBox::warning(
this,
875 tr(
"RunID Name Too Long" ),
876 tr(
"The runID name may be at most\n"
877 "50 characters in length." ) );
904 DbgLv(1) <<
"CGui: edRuninfo: IN";
905 qDebug()<<
"___________________savestatus"<<
saveStatus;
915 DbgLv(1) <<
"CGui: edRuninfo: getExpInfo complete";
922 DbgLv(1) <<
"CGui: ldUS3: IN";
934 DbgLv(1) <<
"CGui: ldUS3: RTN";
941 QString dir = QFileDialog::getExistingDirectory(
this,
942 tr(
"US3 Raw Data Directory"),
944 QFileDialog::DontResolveSymlinks );
947 qApp->processEvents();
949 if ( dir.isEmpty() )
return;
951 dir.replace(
"\\",
"/" );
952 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
960 le_status->setText( tr(
"Loading data from local disk ..." ) );
961 qApp->processEvents();
964 QStringList components = dir.split(
"/", QString::SkipEmptyParts );
965 QString new_runID = components.last();
967 QRegExp rx(
"^[A-Za-z0-9_-]{1,80}$" );
968 if ( rx.indexIn( new_runID ) < 0 )
970 QMessageBox::warning(
this,
971 tr(
"Bad runID Name" ),
972 tr(
"The runID name may consist only of alphanumeric\n"
973 "characters, the underscore, and the hyphen." ) );
985 le_status->setText( tr(
"Loading data from Disk (raw data) ..." ) );
986 qApp->processEvents();
987 DbgLv(1) <<
"CGui: ldUS3Dk: call read";
988 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
990 QApplication::restoreOverrideCursor();
995 QMessageBox::warning(
this,
996 tr(
"No Files Found" ),
997 tr(
"There were no files of the form *.auc\n"
998 "found in the specified directory." ) );
1004 QMessageBox::warning(
this,
1005 tr(
"UltraScan Error" ),
1006 tr(
"Could not read data file.\n" ) );
1013 qDebug()<<
"____________after_init_out";
1018 le_status->setText( tr(
"Loading data from Disk (experiment) ..." ) );
1019 qApp->processEvents();
1028 QString readFile =
runID +
"."
1030 QMessageBox::information(
this,
1032 tr(
"US3 run data ok, but unable to assocate run with DB.\n " ) +
1033 tr(
"Cannot open read file: " ) + dir + readFile );
1038 QString readFile =
runID +
"."
1040 QMessageBox::information(
this,
1042 tr(
"US3 run data ok, but there is an error in association with DB.\n"
1043 "Improper XML in read file: " ) + dir + readFile );
1048 QMessageBox::information(
this,
1050 tr(
"Unknown error: " ) + status );
1055 le_status->setText( tr(
"Loading data from Disk (project) ..." ) );
1056 qApp->processEvents();
1057 DbgLv(1) <<
"CGui: ldUS3Dk: call prj-rDk";
1063 QMessageBox::information(
this,
1065 tr(
"The project was not found.\n"
1066 "Please select an existing project and try again.\n" ) );
1071 QMessageBox::information(
this,
1072 tr(
"Disk Read Problem" ),
1073 tr(
"Could not read data from the disk.\n"
1074 "Disk status: " ) + QString::number( status ) );
1081 le_status->setText( tr(
"Project and experiment are loaded." ) );
1082 qApp->processEvents();
1083 QString psolGUID =
"";
1084 DbgLv(1) <<
"CGui: SOLCHK:loop";
1089 QString csolGUID =
all_chaninfo[ ii ].solution.solutionGUID;
1090 qDebug()<<
"___________-sol"<<csolGUID;
1092 if ( csolGUID == psolGUID )
1101 if ( csolGUID.isEmpty() )
1104 DbgLv(1) <<
"SOLCHK: ii csolGUID EMPTY" << ii << csolGUID;
1107 csolGUID = psolGUID;
1111 status =
all_chaninfo[ ii ].solution.readFromDisk( csolGUID );
1112 qDebug()<<
"buffer"<<
all_chaninfo[ ii ].solution.solutionDesc;
1114 psolGUID = csolGUID;
1115 qDebug()<<
"____status"<<status;
1121 QMessageBox::information(
this,
1123 tr(
"A solution this run refers to was not found,"
1124 " or could not be read.\n"
1125 "Please select an existing solution and try again.\n" ) );
1126 DbgLv(1) <<
"SOLERR: ii psolGUID csolGUI" << ii << psolGUID << csolGUID;
1131 QMessageBox::information(
this,
1133 tr(
"The buffer this solution refers to was not found.\n"
1134 "Please restore and try again.\n" ) );
1139 QMessageBox::information(
this,
1141 tr(
"One of the analytes this solution refers to was not found.\n"
1142 "Please restore and try again.\n" ) );
1147 QMessageBox::information(
this,
1148 tr(
"Disk Read Problem" ),
1149 tr(
"Could not read data from the disk.\n"
1150 "Disk status: " ) + QString::number( status ) );
1152 qDebug()<<
"all_chaninfo[ ii ].solutionDesc0"<<
all_chaninfo[ ii ].solution.solutionDesc;
1156 qDebug()<<
"all_chaninfo[ ii ].solutionDesc1"<<
all_chaninfo[ ii ].solution.solutionDesc;
1158 DbgLv(1) <<
"CGui: SOLCHK:loop-END";
1160 le_status->setText( tr(
"Solutions are now loaded." ) );
1161 qApp->processEvents();
1171 if (
allData.size() == 0 )
return;
1173 le_status->setText( tr(
"%1 data triples are now loaded." )
1175 qApp->processEvents();
1178 DbgLv(1) <<
"CGui: call setTripleInfo";
1198 DbgLv(1) <<
"CGui: call plot_current";
1199 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1201 QApplication::restoreOverrideCursor();
1225 le_status->setText( tr(
"Local disk data load is complete." ) );
1226 qApp->processEvents();
1227 DbgLv(1) <<
"CGui: ldUS3Dk: RTN";
1301 DbgLv(1) <<
"CGui: gExpInf: IN";
1314 QMessageBox::information(
this,
1316 tr(
"Error making the DB connection.\n" ) );
1326 QMessageBox::information(
this,
1328 tr(
"The current runID already exists in the database.\n"
1329 "To edit that information, load it from the database\n"
1330 "to start with." ) );
1362 connect( expInfo, SIGNAL( updateExpInfoSelection(
US_ExperimentRa& ) ),
1365 connect( expInfo, SIGNAL( cancelExpInfoSelection() ),
1368 connect( expInfo, SIGNAL( use_db (
bool ) ),
1369 SLOT ( update_disk_db(
bool ) ) );
1372 DbgLv(1) <<
"CGui: gExpInf: RTN";
1396 const int chanID = 1;
1413 connect( solutionInfo, SIGNAL( updateSolutionGuiSelection(
US_Solution ) ),
1416 connect( solutionInfo, SIGNAL( cancelSolutionGuiSelection() ),
1419 connect( solutionInfo, SIGNAL( use_db (
bool ) ),
1420 SLOT ( update_disk_db(
bool ) ) );
1422 solutionInfo->exec();
1430 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1441 QApplication::restoreOverrideCursor();
1465 le_status->setText( tr(
"The current c/c/w information has been"
1466 " copied to all." ) );
1467 qApp->processEvents();
1522 QString bottom = QString::number (
allData[ cellchan ].bottom);
1523 QString meniscus = QString::number (
allData[ cellchan ].meniscus);
1524 QString radius = QString::number (
allData[ cellchan ].radius);
1551 int trListSave =
lw_triple->currentRow();
1558 qDebug()<<
"__________nchans"<<nchans;
1559 for (
int iii = 0; iii<nchans; iii++)
1564 cellchan = qMax( 0, qMin( trListSave, ( nchans - 1 ) ) );
1567 qDebug()<<
"____triplistx"<<
cellchan;
1580 for (
int wvx = 0; wvx <
nlambda; wvx++ )
1585 if ( ilamb == plambda )
lambda = wvx;
1595 connect(
lw_triple, SIGNAL( itemSelectionChanged() ),
1628 qDebug()<<
"all_chaninfo.size();_____________"<<
all_chaninfo.size();
1644 for (
int cc = 0; cc <
allData.size(); cc++)
1648 for (
int wl = 0; wl <
allData[cc].intarray.size(); wl++)
1650 for (
int w2t = 0; w2t <
allData[cc].intarray[wl].size(); w2t++)
1652 double old =
allData[cc].intarray[wl][w2t];
1654 allData[cc].intarray[wl][w2t] = log10(temp);
1974 QString dirname = writeDir.absolutePath() +
"/" +
runID +
"/";
1985 if ( ! writeDir.exists(
runID ) )
1987 if ( ! writeDir.mkpath( dirname ) )
1989 QMessageBox::information(
this,
1991 tr(
"Cannot write to " ) + writeDir.absolutePath() );
2007 DbgLv(1) <<
"SV: fileCount" << fileCount;
2012 QString writeFile =
runID +
"."
2014 QMessageBox::information(
this,
2016 tr(
"Cannot open write file: " ) + dirname + writeFile );
2022 QMessageBox::information(
this,
2024 tr(
"The run information file was not written. "
2025 "Please click on the "
2026 "'Associate Run with DB' button \n\n " ) +
2027 QString::number( fileCount ) +
" " +
2028 runID + tr(
" files written." ) );
2035 QMessageBox::information(
this,
2037 tr(
"Solution information is incomplete. Please click on the "
2038 "'Manage Solutions' button for each "
2039 "cell, channel, and wavelength combination \n\n " ) +
2040 QString::number( fileCount ) +
" " +
2041 runID + tr(
" files written." ) );
2047 QMessageBox::information(
this,
2049 tr(
"Error: " ) + status );
2052 qDebug()<<
"_________________savestatus___status"<<
saveStatus<<status;
2054 le_status->setText( tr(
"%1 %2 files were written to disk." )
2055 .arg( fileCount ).arg(
runID ) );
2056 qApp->processEvents();
2428 QMessageBox::information(
this,
2430 tr(
"Database connectivity error" ) );
2435 QStringList q(
"get_abstractCenterpiece_names" );
2438 QList<listInfo> options;
2442 option.
ID = db.
value( 0 ).toString();
2448 if ( options.size() > 0 )
2451 DbgLv(1) <<
"CGui: centpInfoDB RTN";
2461 if ( ! f.open( QIODevice::ReadOnly ) )
return false;
2463 QList<listInfo> options;
2464 QXmlStreamReader xml( &f );
2465 while ( ! xml.atEnd() )
2469 if ( xml.isStartElement() )
2471 if ( xml.name() ==
"abstractCenterpiece" )
2474 QXmlStreamAttributes a = xml.attributes();
2475 option.
ID = a.value(
"id").toString();
2476 option.
text = a.value(
"name").toString();
2482 bool error = xml.hasError();
2485 if ( error )
return false;
2488 if ( options.size() > 0 )
2491 for (
int i = 0; i < options.size() - 1; i++ )
2492 for (
int j = i + 1; j < options.size(); j++ )
2493 if ( options[ i ].
text > options[ j ].
text )
2494 options.swap( i, j );
2499 DbgLv(1) <<
"CGui: centpInfoDk RTN";
2524 int n_wl = currentData.
intarray.size();
2525 int n = currentData.
intarray[0].size();
2528 QVector< double > w2tv( currentData.
intarray[0].size() );
2529 QVector< double > intarrayv( currentData.
intarray[0].size() );
2533 double* w2t = w2tv.data();
2534 double* intarray = intarrayv.data();
2538 for (
int ii = 0; ii < n; ii++)
2540 w2t [ii] = currentData.
w2t[ii];
2552 c->setData( w2t, intarray, (
int)n );
2553 double minw2t = w2t[0];
2554 double maxw2t = w2t[n-1];
2558 QVector<double>::iterator maxY = std::max_element(intarrayv.begin(), intarrayv.end());
2559 QVector<double>::iterator minY = std::min_element(intarrayv.begin(), intarrayv.end());
2561 double minint = *minY;
2562 double maxint = *maxY;
2565 double padw2t = ( maxw2t - minw2t ) / 30.0;
2566 double padint = ( maxint - minint ) / 10.0;
2567 qDebug() << minint << maxint << padint;
2568 qDebug() << minw2t << maxw2t << padw2t << minw2t-padw2t<<maxw2t+padw2t;
2570 qDebug()<<QwtPlot::xBottom<<QwtPlot::yLeft;
2571 data_plot->setAxisScaleEngine(QwtPlot::xBottom,
new QwtLog10ScaleEngine);
2572 data_plot->setAxisScale( QwtPlot::xBottom , 100, maxw2t + padw2t );
2573 data_plot->setAxisScale( QwtPlot::yLeft, minint - padint, maxint + padint );
2577 data_plot->setAxisTitle( 0,
"Absorbance / AU");
2581 data_plot->setAxisTitle(0,
"Intensity / AU");
2744 int wvx = qMax( 0,
cb_lambplot->currentIndex() - 1 );
2753 int wvx = qMin( wvxmax,
cb_lambplot->currentIndex() + 1 );
2785 connect(
cb_lambplot, SIGNAL( currentIndexChanged(
int ) ),
2928 for (
int trx = 0; trx <
allData.size(); trx++ )
2936 QString celchn = QString( edata->cell ) +
" / "
2937 + QString( edata->chan );
2941 chaninfo = chaninfo;