3 #include <QApplication>
4 #include <QDomDocument>
26 #define DbgLv(a) if(dbg_level>=a)qDebug()
32 int main(
int argc,
char* argv[] )
34 QApplication application( argc, argv );
42 return application.exec();
59 setWindowTitle( tr(
"Edit UltraScan Data" ) );
62 QVBoxLayout* top =
new QVBoxLayout(
this );
63 top->setSpacing ( 2 );
64 top->setContentsMargins ( 2, 2, 2, 2 );
67 QHBoxLayout* runInfo =
new QHBoxLayout();
68 QLabel* lb_info =
us_label( tr(
"Run Info:" ), -1 );
69 runInfo->addWidget( lb_info );
74 top->addLayout( runInfo );
76 QHBoxLayout*
main =
new QHBoxLayout();
77 QVBoxLayout* left =
new QVBoxLayout;
80 QGridLayout* specs =
new QGridLayout;
83 QPushButton* pb_investigator =
us_pushbutton( tr(
"Select Investigator" ) );
86 pb_investigator->setEnabled(
false );
89 QString number = (
id > 0 ) ?
119 QFontMetrics fmet( font );
120 int fwid = fmet.maxWidth();
123 int swid = lwid + fwid;
125 QButtonGroup* r_group =
new QButtonGroup(
this );
126 QButtonGroup* x_group =
new QButtonGroup(
this );
149 QString lrsmry = tr(
"%1 raw: %2 %3 to %4" )
150 .arg( nlmbd ).arg(
chlamb ).arg( lmbdlo ).arg( lmbdhi );
152 QString lxsmry = tr(
"%1 MWL exports: %2 %3 to %4, raw index increment %5" )
153 .arg( nlmbd ).arg(
chlamb ).arg( lmbdlo ).arg( lmbdhi ).arg( lmbddl );
180 lambdas <<
"250" <<
"350" <<
"450" <<
"550" <<
"580" <<
"583" <<
"650";
187 cb_lend ->setCurrentIndex( 6 );
192 QLabel* lb_scan =
us_banner( tr(
"Scan Controls" ) );
195 QLabel* lb_from =
us_label( tr(
"Scan Focus from:" ), -1 );
196 lb_from->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
201 QLabel* lb_to =
us_label( tr(
"to:" ), -1 );
202 lb_to->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
214 QLabel* lb_edit =
us_banner( tr(
"Edit Controls" ) );
271 connect( pb_investigator, SIGNAL( clicked() ),
273 connect( pb_load, SIGNAL( clicked() ), SLOT(
load() ) );
274 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
283 connect(
ct_odlim, SIGNAL( valueChanged (
double ) ),
291 connect(
pb_undo, SIGNAL( clicked() ), SLOT(
undo() ) );
299 specs->addWidget( pb_investigator, s_row, 0, 1, 1 );
302 specs->addWidget( pb_load, s_row, 0, 1, 2 );
303 specs->addWidget(
pb_details, s_row++, 2, 1, 2 );
304 specs->addWidget(
lb_triple, s_row, 0, 1, 2 );
305 specs->addWidget(
cb_triple, s_row++, 2, 1, 2 );
306 specs->addWidget(
lb_rpms, s_row, 0, 1, 2 );
307 specs->addWidget(
cb_rpms, s_row++, 2, 1, 2 );
308 specs->addWidget(
lb_gaps, s_row, 0, 1, 2 );
309 specs->addWidget(
ct_gaps, s_row++, 2, 1, 2 );
310 specs->addWidget(
le_lxrng, s_row++, 0, 1, 4 );
311 specs->addWidget(
lb_mwlctl, s_row++, 0, 1, 4 );
312 specs->addLayout(
lo_lrange, s_row, 0, 1, 2 );
313 specs->addLayout(
lo_custom, s_row++, 2, 1, 2 );
314 specs->addWidget(
lb_ldelta, s_row, 0, 1, 1 );
315 specs->addWidget(
ct_ldelta, s_row, 1, 1, 1 );
316 specs->addWidget(
le_ltrng, s_row++, 2, 1, 2 );
317 specs->addWidget(
lb_lstart, s_row, 0, 1, 1 );
318 specs->addWidget(
cb_lstart, s_row, 1, 1, 1 );
319 specs->addWidget(
lb_lend, s_row, 2, 1, 1 );
320 specs->addWidget(
cb_lend, s_row++, 3, 1, 1 );
321 specs->addWidget(
pb_custom, s_row, 0, 1, 2 );
322 specs->addWidget(
pb_incall, s_row++, 2, 1, 2 );
323 specs->addLayout(
lo_radius, s_row, 0, 1, 2 );
324 specs->addLayout(
lo_waveln, s_row++, 2, 1, 2 );
325 specs->addWidget(
lb_lplot, s_row, 0, 1, 1 );
326 specs->addWidget(
cb_lplot, s_row, 1, 1, 1 );
327 specs->addWidget(
pb_larrow, s_row, 2, 1, 1 );
328 specs->addWidget(
pb_rarrow, s_row++, 3, 1, 1 );
329 specs->addWidget( lb_scan, s_row++, 0, 1, 4 );
330 specs->addWidget( lb_from, s_row, 0, 1, 2 );
331 specs->addWidget(
ct_from, s_row++, 2, 1, 2 );
332 specs->addWidget( lb_to, s_row, 0, 1, 2 );
333 specs->addWidget(
ct_to, s_row++, 2, 1, 2 );
336 specs->addWidget(
pb_edit1, s_row, 0, 1, 2 );
337 specs->addWidget(
pb_include, s_row++, 2, 1, 2 );
338 specs->addWidget( lb_edit, s_row++, 0, 1, 4 );
339 specs->addWidget(
lb_edtrsp, s_row, 0, 1, 2 );
340 specs->addWidget(
le_edtrsp, s_row++, 2, 1, 2 );
343 specs->addWidget(
pb_airGap, s_row, 0, 1, 2 );
344 specs->addWidget(
le_airGap, s_row++, 2, 1, 2 );
347 specs->addWidget(
pb_plateau, s_row, 0, 1, 2 );
348 specs->addWidget(
le_plateau, s_row++, 2, 1, 2 );
351 specs->addWidget(
lb_odlim, s_row, 0, 1, 2 );
352 specs->addWidget(
ct_odlim, s_row++, 2, 1, 2 );
353 specs->addWidget(
pb_noise, s_row, 0, 1, 2 );
355 specs->addWidget(
pb_invert, s_row, 0, 1, 2 );
356 specs->addWidget(
pb_spikes, s_row++, 2, 1, 2 );
358 specs->addWidget(
pb_undo, s_row++, 2, 1, 2 );
361 specs->addWidget(
pb_float, s_row, 0, 1, 2 );
362 specs->addWidget(
pb_write, s_row++, 2, 1, 2 );
366 QBoxLayout* buttons =
new QHBoxLayout;
371 connect( pb_reset, SIGNAL( clicked() ), SLOT(
reset() ) );
372 connect( pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
373 connect( pb_accept, SIGNAL( clicked() ), SLOT( close() ) );
375 buttons->addWidget( pb_reset );
376 buttons->addWidget( pb_help );
377 buttons->addWidget( pb_accept );
381 tr(
"Absorbance Data" ),
382 tr(
"Radius (in cm)" ), tr(
"Absorbance" ) );
386 data_plot->enableAxis( QwtPlot::xBottom,
true );
387 data_plot->enableAxis( QwtPlot::yLeft ,
true );
391 pick->setRubberBand ( QwtPicker::VLineRubberBand );
392 pick->setMousePattern( QwtEventPattern::MouseSelect1,
393 Qt::LeftButton, Qt::ControlModifier );
395 left->addLayout( specs );
397 left->addLayout( buttons );
399 main->addLayout( left );
400 main->addLayout(
plot );
401 main->setStretchFactor( left, 2 );
402 main->setStretchFactor(
plot, 3 );
403 top ->addLayout( main );
418 QString inv_text = QString::number( investigator ) +
": "
454 lb_gaps->setText( tr(
"Threshold for Scan Gaps" ) );
463 ct_to->setMinValue( 0 );
464 ct_to->setMaxValue( 0 );
465 ct_to->setValue ( 0 );
469 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
470 data_plot->detachItems( QwtPlotItem::Rtti_PlotMarker );
474 data_plot->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
475 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
551 lb_triple->setText( tr(
"Cell / Channel / Wavelength" ) );
589 ct_to->setMinValue( 0 );
590 ct_to->setMaxValue( 0 );
591 ct_to->setValue ( 0 );
609 qApp->processEvents();
616 int threshold = (int)
ct_gaps->value();
622 int rawScanNumber = -1;
623 bool deleteAll =
false;
629 if ( !
includes.contains( scanNumber ) )
continue;
638 for (
int i = leftPoint; i <= rightPoint; i++ )
648 if ( gapLength > maxGap )
655 if ( maxGap >= threshold )
657 QwtPlotCurve* curve = NULL;
658 bool deleteCurrent =
false;
661 ct_to->setValue( 0.0 );
663 QString seconds = QString::number( s.
seconds );
664 QwtPlotItemList items =
data_plot->itemList();
666 for (
int i = 0; i < items.size(); i++ )
668 if ( items[ i ]->rtti() == QwtPlotItem::Rtti_PlotCurve )
670 if ( items[ i ]->title().text().contains( seconds ) )
672 curve =
dynamic_cast< QwtPlotCurve*
>( items[ i ] );
680 qDebug() <<
"Cannot find curve during gap check";
688 QPen
p = curve->pen();
689 QBrush b = curve->brush();
691 p.setColor( Qt::red );
692 b.setColor( Qt::red );
695 curve->setBrush( b );
701 box.setWindowTitle( tr(
"Excessive Scan Gaps Detected" ) );
706 + QString::number( rawScanNumber )
707 + tr(
" has a maximum reading gap of " )
708 + QString::number( maxGap )
709 + tr(
" starting at radius " )
710 + QString::number( radius,
'f', 3 );
713 box.setInformativeText( tr(
"Delete?" ) );
715 QPushButton* pb_delete = box.addButton( tr(
"Delete" ),
716 QMessageBox::YesRole );
718 QPushButton* pb_deleteAll = box.addButton( tr(
"Delete All" ),
719 QMessageBox::AcceptRole );
721 QPushButton* pb_skip = box.addButton( tr(
"Skip" ),
722 QMessageBox::NoRole );
724 QPushButton* pb_cancel = box.addButton( tr(
"Cancel" ),
725 QMessageBox::RejectRole );
727 box.setEscapeButton ( pb_cancel );
728 box.setDefaultButton( pb_delete );
732 if ( box.clickedButton() == pb_delete )
733 deleteCurrent =
true;
735 else if ( box.clickedButton() == pb_deleteAll )
738 deleteCurrent =
true;
744 p.setColor( Qt::yellow );
745 b.setColor( Qt::yellow );
748 curve->setBrush( b );
752 if ( box.clickedButton() == pb_skip )
755 if ( box.clickedButton() == pb_cancel )
760 if ( deleteAll || deleteCurrent )
783 connect( dialog, SIGNAL( progress ( QString ) ),
785 connect( dialog, SIGNAL( changed (
bool ) ),
788 if ( dialog->exec() == QDialog::Rejected )
return;
801 QMessageBox::warning(
this,
802 tr(
"No Files Found" ),
803 tr(
"There were no files of the form *.auc\n"
804 "found in the specified directory." ) );
809 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
818 + QString( QChar(
data.
type[ 1 ] ) );
822 lb_gaps->setText( tr(
"Fringe Tolerance" ) );
824 ct_gaps->setRange ( 0.0, 20.0, 0.001 );
828 connect(
ct_gaps, SIGNAL( valueChanged (
double ) ),
833 lb_gaps->setText( tr(
"Threshold for Scan Gaps" ) );
836 ct_gaps->setRange ( 10.0, 100.0, 10.0 );
842 DbgLv(1) <<
"Ld: runtype" << runtype;
847 for (
int trx = 0; trx <
triples.size(); trx++ )
849 QString triple = QString(
triples.at( trx ) ).replace(
" / ",
"." );
850 QString file = runtype +
"." + triple +
".auc";
856 QString scell = triple.section(
".", 0, 0 ).simplified();
857 QString schan = triple.section(
".", 1, 1 ).simplified();
858 QString swavl = triple.section(
".", 2, 2 ).simplified();
867 QString celchn = scell +
" / " + schan;
869 if ( !
celchns.contains( celchn ) )
881 for (
int wvx = 0; wvx <
nwaveln; wvx++ )
888 workingDir = workingDir +
"/";
889 QString file = workingDir + runtype +
".xml";
893 if ( xf.open( QIODevice::ReadOnly | QIODevice::Text ) )
895 QXmlStreamReader xml( &xf );
897 while( ! xml.atEnd() )
901 if ( xml.isStartElement() && xml.name() ==
"experiment" )
903 QXmlStreamAttributes xa = xml.attributes();
904 expType = xa.value(
"type" ).toString();
921 QMessageBox::warning(
this, tr(
"Connection Problem" ),
922 tr(
"Could not connect to database\n" )
930 query <<
"get_experiment_info_by_runID" <<
runID
967 pb_write ->setText( tr(
"Save Edit Profiles" ) );
973 for (
int jd = 0; jd <
allData.size(); jd++ )
986 QString arpm = QString::number( drpm );
1003 ssDat =
sData[ jj ];
1005 sData[ jj ].scan_count++;
1023 for (
int ii = 0; ii < ksd; ii++ )
1025 QString arpm = QString::number(
sData[ ii ].speed );
1032 pick ->disconnect();
1033 connect(
pick, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
1034 SLOT (
mouse (
const QwtDoublePoint& ) ) );
1040 connect(
cb_rpms, SIGNAL( currentIndexChanged(
int ) ),
1046 bool notMwl = ( nwaveln < 3 );
1047 lb_rpms ->setVisible(
false );
1048 cb_rpms ->setVisible(
false );
1058 pb_write ->setText( tr(
"Save Current Edit Profile" ) );
1082 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
1085 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
1098 dt = ( temp_spread > dt ) ? temp_spread : dt;
1103 QMessageBox::warning(
this,
1104 tr(
"Temperature Problem" ),
1105 tr(
"The temperature in this run varied over the course\n"
1106 "of the run to a larger extent than allowed by the\n"
1107 "current threshold (" )
1109 +
" " +
DEGC + tr(
". The accuracy of experimental\n"
1110 "results may be affected significantly." ) );
1128 DbgLv(1) <<
"IS-MWL: load_mwl begun";
1130 DbgLv(1) <<
"IS-MWL: load_mwl complete";
1138 for (
int ccx = 0; ccx <
ncelchn; ccx++ )
1151 for (
int wvx = 0; wvx <
nwaveln; wvx++ )
1168 le_ltrng ->setText( tr(
"%1 raw: %2 %3 to %4" )
1170 le_lxrng ->setText( tr(
"%1 MWL exports: %2 %3 to %4,"
1171 " raw index increment %5" )
1181 for (
int wvx = 0; wvx <
nwavelo; wvx++ )
1193 int lastx = nwavelo - 1;
1197 cb_lend ->setCurrentIndex( lastx );
1203 int ndset = ncelchn *
nrpoint;
1204 int ndpoint = nscan *
maxwavl;
1205 DbgLv(1) <<
"IS-MWL: nrpoint nscan ndset ndpoint" << nrpoint << nscan
1206 << ndset << ndpoint;
1208 for (
int ii = 0; ii <
nrpoint; ii++ )
1215 QVector< double > wrdata;
1216 wrdata.fill( 0.0, ndpoint );
1218 DbgLv(1) <<
"IS-MWL: wrdata size" << wrdata.size() << ndpoint;
1220 for (
int ii = 0; ii < ndset; ii++ )
1224 DbgLv(1) <<
"IS-MWL: rdata size" <<
rdata.size() << ndset;
1233 for (
int ccx = 0; ccx <
ncelchn; ccx++ )
1237 for (
int jwx = 0; jwx <
nwaveln; jwx++ )
1242 DbgLv(1) <<
"IS-MWL: trx ccx wvx" << trx << ccx << wvx;
1244 for (
int scx = 0; scx < nscan; scx++ )
1248 int opx = scx * maxwavl + wvx;
1249 DbgLv(2) <<
"IS-MWL: scx odx opx" << scx << odx << opx;
1250 for (
int rax = 0; rax <
nrpoint; rax++ )
1259 DbgLv(1) <<
"IS-MWL: Triples loop complete";
1262 lb_triple->setText( tr(
"Cell / Channel" ) );
1266 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
1279 double timel = triple.
scanData[0].rpm / 400.0;
1280 double rpmc = 400.0;
1281 int nstep = (int)timel;
1283 for (
int ii=0; ii<nstep; ii++ )
1285 w2ti +=
sq( rpmc * M_PI / 30.0 );
1288 for (
int ii=0; ii<triple.
scanData.size(); ii++ )
1292 double rpmc = ds->
rpm;
1293 w2ti += ( timec - timel ) *
sq( rpmc * M_PI / 30.0 );
1294 qDebug() <<
"scan" << ii+1 <<
"delta-r rpm seconds" << ds->
delta_r
1295 << rpmc << timec <<
"omega2t w2t-integ" << ds->
omega2t << w2ti;
1298 double deltt = ds->
omega2t /
sq(rpmc*M_PI/30.0);
1299 double time1 = timel + deltt;
1300 qDebug() <<
" scan 1 omega2t-implied time" << time1;
1309 connect(
ct_odlim, SIGNAL( valueChanged (
double ) ),
1327 p.setColor( QPalette::Button, Qt::green );
1328 pb->setPalette( p );
1342 QString triple =
triples.at( index );
1343 QStringList parts = triple.split(
" / " );
1345 QString cell = parts[ 0 ];
1346 QString channel = parts[ 1 ];
1347 QString wl = parts[ 2 ];
1352 + QString( QChar(
data.
type[ 1 ] ) );
1356 QStringList sl = desc.split(
"," );
1358 desc = sl.join(
"," ).trimmed();
1364 QString title23 = tr(
"Run ID: %1\n"
1365 "Cell: %2 Channel: %3 Wavelength: %4" )
1366 .arg(
runID ).arg( cell ).arg( channel ).arg( wl );
1371 title =
"Radial Absorbance Data\n" + title23;
1375 title =
"Radial Intensity Data\n" + title23;
1376 data_plot->setAxisTitle( QwtPlot::yLeft, tr(
"Intensity " ) );
1381 title =
"Radial Interference Data\n" + title23;
1382 data_plot->setAxisTitle( QwtPlot::yLeft, tr(
"Fringes " ) );
1390 title =
"Fluorescence Intensity Data\n" + title23;
1391 data_plot->setAxisTitle( QwtPlot::yLeft, tr(
"Fluorescence Intensity " ) );
1394 title =
"File type not recognized";
1408 ct_to ->setMinValue( 0.0 );
1411 pick ->disconnect();
1412 connect(
pick, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
1413 SLOT (
mouse (
const QwtDoublePoint& ) ) );
1439 double maximum = -1.0e99;
1483 double meniscus_right = p.x();
1495 if ( !
includes.contains( i ) )
continue;
1501 for (
int j = start; j <= end; j++ )
1503 if ( maximum < s->rvalues[ j ] )
1526 marker =
new QwtPlotMarker;
1527 QBrush brush( Qt::white );
1528 QPen pen ( brush, 2.0 );
1531 marker->setSymbol( QwtSymbol(
1561 if ( qAbs( p.x() -
airGap_left ) < 0.020 )
return;
1572 QList< int > excludes;
1586 le_airGap->setText( wkstr.sprintf(
"%.3f - %.3f",
1590 DbgLv(1) <<
"AGap: plot_range()";
1593 qApp->processEvents();
1615 le_dataRange->setText( tr(
"**overlaps meniscus**" ) );
1626 if ( qAbs( p.x() -
range_left ) < 0.020 )
return;
1640 QList< int > excludes;
1656 qApp->processEvents();
1675 int row =
cb_rpms ->currentIndex();
1676 int jsd =
sd_offs[ index ] + row;
1677 QString arpm =
cb_rpms->itemText( row );
1687 if ( ++row >=
cb_rpms->count() )
1689 if ( ++index < cb_triple->count() )
1710 cb_rpms->setCurrentIndex( 0 );
1731 cb_rpms->setCurrentIndex( row );
1756 le_plateau->setText( tr(
"**beyond data end**" ) );
1770 ct_to->setValue( 0.0 );
1786 if ( pt - start < 5 || end - pt < 5 )
1788 QMessageBox::warning(
this,
1789 tr(
"Position Error" ),
1790 tr(
"The selected point is too close to the edge." ) );
1797 for (
int j = pt - 5; j <= pt + 5; j++ )
1800 double bl = sum / 11.0;
1804 le_baseline->setText( wkstr.sprintf(
"%.3f (%.3e)", p.x(), bl ) );
1827 QwtScaleDiv* y_axis =
data_plot->axisScaleDiv( QwtPlot::yLeft );
1829 double padding = ( y_axis->upperBound() - y_axis->lowerBound() ) / 30.0;
1832 v [ 0 ] = y_axis->upperBound() - padding;
1833 v [ 1 ] = y_axis->lowerBound() + padding;
1836 v_line->setData( r, v, 2 );
1838 QPen pen = QPen( QBrush( Qt::white ), 2.0 );
1881 for (
int jj = pt; jj < pt + 11; jj++ )
1884 double bl = sum / 11.0;
1933 data_plot->detachItems( QwtPlotItem::Rtti_PlotMarker );
2052 QList< int > excludes;
2079 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
2084 QVector< double > rvec( size );
2085 QVector< double > vvec( size );
2086 double* r = rvec.data();
2087 double* v = vvec.data();
2089 double maxR = -1.0e99;
2090 double minR = 1.0e99;
2091 double maxV = -1.0e99;
2092 double minV = 1.0e99;
2096 if ( !
includes.contains( i ) )
continue;
2100 for (
int j = 0; j < size; j++ )
2105 maxR = qMax( maxR, r[ j ] );
2106 minR = qMin( minR, r[ j ] );
2107 maxV = qMax( maxV, v[ j ] );
2108 minV = qMin( minV, v[ j ] );
2111 QString title = tr(
"Raw Data at " )
2112 + QString::number( s->
seconds ) + tr(
" seconds" )
2113 +
" #" + QString::number( i );
2116 c->setPaintAttribute( QwtPlotCurve::ClipPolygons,
true );
2117 c->setData( r, v, size );
2121 double padR = ( maxR - minR ) / 30.0;
2122 double padV = ( maxV - minV ) / 30.0;
2124 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
2125 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
2138 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
2142 QVector< double > rvec( rsize );
2143 QVector< double > vvec( rsize );
2144 double* r = rvec.data();
2145 double* v = vvec.data();
2146 double maxR = -1.0e99;
2147 double minR = 1.0e99;
2148 double maxV = -1.0e99;
2149 double minV = 1.0e99;
2155 int wvx =
cb_lplot->currentIndex();
2157 DbgLv(1) <<
"plot_range(): ccx wvx indext" << ccx << wvx << indext;
2163 if ( !
includes.contains( i ) )
continue;
2177 int ksd = jsd +
sd_knts[ indext ];
2179 for (
int jj = jsd; jj < ksd; jj++ )
2181 int sScan =
sData[ jj ].first_scan;
2182 int eScan =
sData[ jj ].scan_count + sScan - 1;
2184 if ( tScan < sScan || tScan > eScan )
2187 rngl =
sData[ jj ].dataLeft;
2188 rngr =
sData[ jj ].dataRight;
2189 menp =
sData[ jj ].meniscus;
2202 v[ 0 ] = s ->
rvalues[ indexLeft ];
2204 v[ 2 ] = s ->
rvalues[ indexLeft + 4 ];
2213 QString::number( tScan ) );
2214 c->setBrush( QBrush( Qt::cyan ) );
2215 c->setPen( QPen( Qt::cyan ) );
2216 c->setData( r, v, 5 );
2217 minR = qMin( minR, r[ 0 ] );
2218 minV = qMin( minV, v[ 0 ] );
2223 for (
int j = indexLeft; j <= indexRight; j++ )
2228 maxR = qMax( maxR, r[ count ] );
2229 minR = qMin( minR, r[ count ] );
2230 maxV = qMax( maxV, v[ count ] );
2231 minV = qMin( minV, v[ count ] );
2236 QString title = tr(
"Raw Data at " )
2237 + QString::number( s->
seconds ) + tr(
" seconds" )
2238 +
" #" + QString::number( i );
2241 c->setData( r, v, count );
2245 double padR = ( maxR - minR ) / 30.0;
2246 double padV = ( maxV - minV ) / 30.0;
2248 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
2249 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
2262 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
2266 double maxR = -1.0e99;
2267 double minR = 1.0e99;
2268 double maxV = -1.0e99;
2269 double minV = 1.0e99;
2279 QVector< double > rvec( size );
2280 QVector< double > vvec( size );
2281 double* r = rvec.data();
2282 double* v = vvec.data();
2284 for (
int j = indexLeft; j <= indexRight; j++ )
2289 maxR = qMax( maxR, r[ count ] );
2290 minR = qMin( minR, r[ count ] );
2291 maxV = qMax( maxV, v[ count ] );
2292 minV = qMin( minV, v[ count ] );
2297 QString title = tr(
"Raw Data at " )
2298 + QString::number( s->
seconds ) + tr(
" seconds" )
2299 +
" #" + QString::number(
includes.last() );
2302 c->setData( r, v, count );
2305 double padR = ( maxR - minR ) / 30.0;
2306 double padV = ( maxV - minV ) / 30.0;
2308 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
2309 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
2322 QVector< double > rvec( rsize );
2323 QVector< double > vvec( rsize );
2324 double* r = rvec.data();
2325 double* v = vvec.data();
2327 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
2330 double maxR = -1.0e99;
2331 double minR = 1.0e99;
2332 double maxV = -1.0e99;
2333 double minV = 1.0e99;
2334 QString srpm =
cb_rpms->currentText();
2338 for (
int ii = 0; ii < ssize; ii++ )
2342 QString arpm = QString::number( s->
rpm );
2349 for (
int jj = 0; jj < rsize; jj++ )
2354 maxR = qMax( maxR, r[ count ] );
2355 minR = qMin( minR, r[ count ] );
2356 maxV = qMax( maxV, v[ count ] );
2357 minV = qMin( minV, v[ count ] );
2362 QString title = tr(
"Raw Data at " )
2363 + QString::number( s->
seconds ) + tr(
" seconds" )
2364 +
" #" + QString::number( ii );
2367 c->setData( r, v, count );
2370 double padR = ( maxR - minR ) / 30.0;
2371 double padV = ( maxV - minV ) / 30.0;
2373 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
2374 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
2383 if ( !
isMwl )
return;
2385 QString rectype = tr(
"Wavelength" );
2386 double recvalu = 250;
2389 int recndx =
cb_lplot ->currentIndex();
2390 QString celchn =
celchns.at( ccx );
2391 QString scell = celchn.section(
"/", 0, 0 ).simplified();
2392 QString schan = celchn.section(
"/", 1, 1 ).simplified();
2395 DbgLv(1) <<
"PlMwl: index celchn" << index << celchn;
2399 DbgLv(1) <<
"PlMwl: x-r index cc nw rx" << index << ccx <<
nwavelo << recndx;
2405 QString dcell=QString::number(
data.
cell);
2407 QString dwavl=QString::number(
data.
scanData[0].wavelength);
2408 DbgLv(1) <<
"PlMwl: c triple" << scell << schan << svalu
2409 <<
"d triple" << dcell << dchan << dwavl;
2414 index = ccx *
nrpoint + recndx;
2415 DbgLv(1) <<
"PlMwl: x-w index cc nr rx" << index << ccx <<
nrpoint << recndx;
2417 rectype = tr(
"Radius" );
2421 DbgLv(1) <<
"PlMwl: ccx index rtype rval" << ccx << index << rectype << recvalu;
2427 + QString( QChar(
data.
type[ 1 ] ) );
2432 QString title = tr(
"Pseudo Absorbance Data\n"
2434 "Cell: %2 Channel: %3 %4: %5" )
2435 .arg(
runID ).arg( scell ).arg( schan )
2436 .arg( rectype ).arg( svalu );
2437 DbgLv(1) <<
"PlMwl: title" << title;
2440 data_plot->setAxisTitle( QwtPlot::yLeft, tr(
"Absorbance (OD)" ) );
2442 data_plot->detachItems ( QwtPlotItem::Rtti_PlotCurve );
2456 QVector< double > rvec( npoint );
2457 QVector< double > vvec( npoint );
2458 double* rr = rvec.data();
2459 double* vv = vvec.data();
2461 double maxR = -1.0e99;
2462 double minR = 1.0e99;
2463 double maxV = -1.0e99;
2464 double minV = 1.0e99;
2471 data_plot->setAxisTitle( QwtPlot::xBottom, tr(
"Radius (cm)" ) );
2472 DbgLv(1) <<
"PlMwl: START xa_RAD";
2474 for (
int ii = 0; ii < nscan; ii++ )
2478 DbgLv(1) <<
"PlMwl: ii" << ii <<
"NOT INCLUDED";
2485 for (
int jj = 0; jj < npoint; jj++ )
2491 maxR = qMax( maxR, rr[ jj ] );
2492 minR = qMin( minR, rr[ jj ] );
2493 maxV = qMax( maxV, valueV );
2494 minV = qMin( minV, valueV );
2500 QString ctitle = tr(
"Raw Data at " )
2501 + QString::number( scn->
seconds ) + tr(
" seconds" )
2502 +
" #" + QString::number( ii );
2505 cc->setPaintAttribute( QwtPlotCurve::ClipPolygons,
true );
2506 cc->setData( rr, vv, npoint );
2508 pick ->disconnect();
2509 connect(
pick, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
2510 SLOT (
mouse (
const QwtDoublePoint& ) ) );
2511 DbgLv(1) <<
"PlMwl: END xa_RAD kodlim odlimit" << kodlim <<
odlimit;
2516 DbgLv(1) <<
"PlMwl: START xa_WAV";
2517 data_plot->setAxisTitle( QwtPlot::xBottom, tr(
"Wavelength (nm)" ) );
2518 QVector< double > wrdata =
rdata[ index ];
2521 for (
int ii = 0; ii < nscan; ii++ )
2523 if ( !
includes.contains( ii ) )
continue;
2525 for (
int jj = 0; jj < npoint; jj++ )
2528 valueV = qMin( maxOD, wrdata[ dpx++ ] );
2531 maxR = qMax( maxR, rr[ jj ] );
2532 minR = qMin( minR, rr[ jj ] );
2533 maxV = qMax( maxV, valueV );
2534 minV = qMin( minV, valueV );
2541 QString ctitle = tr(
"Raw Data at " )
2542 + QString::number( scn->
seconds ) + tr(
" seconds" )
2543 +
" #" + QString::number( ii );
2546 cc->setPaintAttribute( QwtPlotCurve::ClipPolygons,
true );
2547 cc->setData( rr, vv, npoint );
2549 DbgLv(1) <<
"PlMwl: END xa_WAV kodlim odlimit" << kodlim <<
odlimit;
2553 double padR = ( maxR - minR ) / 30.0;
2554 double padV = ( maxV - minV ) / 30.0;
2555 padV = qMax( padV, 0.005 );
2557 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
2558 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
2560 DbgLv(1) <<
"PlMwl: call replot()";
2562 DbgLv(1) <<
"PlMwl: retn fr replot()";
2568 ct_to ->setMinValue( 0.0 );
2571 pick ->disconnect();
2572 connect(
pick, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
2573 SLOT (
mouse (
const QwtDoublePoint& ) ) );
2579 int from = (int)scan;
2580 int to = (int)
ct_to->value();
2584 ct_to->disconnect();
2585 ct_to->setValue( scan );
2588 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
2599 int from = (int)
ct_from->value();
2607 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
2628 int ifrom = qMax( from - 1, 0 );
2629 int ito = qMin( to,
includes.size() );
2631 for (
int ii = ifrom; ii < ito; ii++ )
2641 QwtPlotItemList list =
data_plot->itemList();
2642 QList< QwtPlotCurve* > curves;
2644 for (
int i = 0; i < list.size(); i++ )
2646 if ( list[ i ]->title().text().contains(
"Raw" ) )
2647 curves << dynamic_cast< QwtPlotCurve* >( list[ i ] );
2650 QPen
p = curves[ 0 ]->pen();
2651 QBrush b = curves[ 0 ]->brush();
2653 QColor foc = Qt::red;
2656 for (
int i = 0; i < curves.size(); i++ )
2658 int scnnbr = curves[ i ]->title().text().section(
"#", 1, 1 ).toInt();
2660 if ( focus.contains( scnnbr ) )
2671 curves[ i ]->setPen ( p );
2672 curves[ i ]->setBrush( b );
2691 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
2694 ct_to->disconnect();
2695 ct_to->setValue ( 0 );
2697 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
2709 int scanStart = (int)
ct_from->value();
2710 int scanEnd = (int)
ct_to ->value();
2712 for (
int i = scanEnd; i >= scanStart; i-- )
2725 connect( exclude, SIGNAL( update_exclude_profile( QList< int > ) ),
2728 connect( exclude, SIGNAL( cancel_exclude_profile(
void ) ),
2731 connect( exclude, SIGNAL( finish_exclude_profile( QList< int > ) ),
2735 qApp->processEvents();
2742 DbgLv(1) <<
"UPD_EXCL: size excl" << scanProfile.size();
2756 for (
int i = 0; i < excludes.size(); i++ )
2757 includes.removeAll( excludes[ i ] );
2759 DbgLv(1) <<
"FIN_EXCL: sizes excl incl" << excludes.size() <<
includes.size();
2767 int index1 = (int)
ct_from->value();
2772 connect( dialog, SIGNAL( scan_updated( QList< QPointF > ) ),
2775 qApp->processEvents();
2783 int index1 = (int)
ct_from->value();
2784 int current_scan =
includes[ index1 - 1 ];
2787 for (
int i = 0; i < changes.size(); i++ )
2789 int point = (int)changes[ i ].x();
2790 double value = changes[ i ].y();
2797 e.
scan = current_scan;
2803 QVector< double > rvec( points );
2804 QVector< double > vvec( points );
2805 double* r = rvec.data();
2806 double* v = vvec.data();
2823 for (
int i = left; i <= right; i++ )
2826 v[ count ] = s ->
rvalues[ i ];
2831 QwtPlotItemList items =
data_plot->itemList();
2832 QString seconds =
" " + QString::number( s->
seconds );
2836 for (
int i = 0; i < items.size(); i++ )
2838 if ( items[ i ]->rtti() == QwtPlotItem::Rtti_PlotCurve )
2840 c =
dynamic_cast< QwtPlotCurve*
>( items[ i ] );
2841 if ( c->title().text().contains( seconds ) )
2852 c->setData( r, v, count );
2856 qDebug() <<
"Can't find curve!";
2887 double smoothed_value;
2897 for (
int j = start; j < end; j++ )
2902 s->
rvalues[ j ] = smoothed_value;
2909 while ( c & ( 1 << ( 7 - index % 8 ) ) )
2912 index, start, end, &smoothed_value ) )
2913 s->
rvalues[ index ] = smoothed_value;
2986 int code = dialog->exec();
2987 qApp->processEvents();
2989 if ( code == QDialog::Accepted )
3023 mb.setIcon( QMessageBox::Question );
3024 mb.setText( tr(
"Ignore Edits?" ) );
3025 mb.setInformativeText(
3026 tr(
"Edits have been made. If you want to keep them,\n"
3027 "cancel and write the outputs first." ) );
3028 mb.addButton( tr(
"Ignore Edits" ), QMessageBox::RejectRole );
3029 mb.addButton( tr(
"Return to previous selection" ), QMessageBox::NoRole );
3030 int result = mb.exec();
3032 if ( result == QMessageBox::RejectRole )
3036 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
3064 le_ltrng ->setText( tr(
"%1 raw: %2 %3 to %4" )
3072 le_lxrng ->setText( tr(
"%1 MWL exports: %2 %3 to %4,"
3073 " raw index increment %5" )
3083 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
3088 QString swavl =
cb_lplot ->currentText();
3089 QString triple =
cb_triple->currentText() + (
isMwl ?
" / " + swavl :
"" );
3090 int idax =
triples.indexOf( triple );
3091 DbgLv(1) <<
"EDT:NewTr: sw tri dx" << swavl << triple << idax;
3112 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
3115 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
3125 QString arpm = QString::number(
data.
scanData[ ii ].rpm );
3139 QString trbase =
cb_triple->currentText();
3146 triple +=
" / " + swavl;
3151 bool app_edit = ( fname !=
"none" );
3152 DbgLv(1) <<
"EDT:NewTr: app_edit" << app_edit <<
"fname" << fname;
3156 QStringList editfiles;
3158 if ( fname ==
"same" )
3160 QString celchn = trbase +
" / ";
3165 DbgLv(1) <<
"EDT:NewTr: jdax ldax" << jdax << ldax;
3167 while ( jdax <= ldax )
3180 QString trtype =
isMwl ?
"cell/channel" :
"triple";
3181 QString trvalu =
isMwl ? trbase : triple;
3182 DbgLv(1) <<
"EDT:NewTr: tr type,valu" << trtype << trvalu;
3185 QPushButton* pb_appl;
3186 QString msg = tr(
"Edits have been loaded or saved<br/>"
3187 "for the current %1 (%2).<br/></br/>"
3188 "Do you wish to<br/>"
3190 "apply them (<b>Apply Edits</b>) or<br/>"
3192 "ignore them (<b>Ignore Edits</b>)<br/>"
3193 "in data displays?" )
3194 .arg( trtype ).arg( trvalu );
3195 mbox.setIcon ( QMessageBox::Question );
3196 mbox.setIcon ( QMessageBox::Question );
3197 mbox.setTextFormat( Qt::RichText );
3198 mbox.setText ( msg );
3199 mbox.addButton( tr(
"Ignore Edits" ),
3200 QMessageBox::RejectRole );
3201 pb_appl = mbox.addButton( tr(
"Apply Edits" ),
3202 QMessageBox::AcceptRole );
3203 mbox.setDefaultButton( pb_appl );
3205 app_edit = ( mbox.clickedButton() == pb_appl );
3227 DbgLv(1) <<
"EDT:NewTr: DONE";
3233 QString srpm =
cb_rpms->itemText( index );
3273 for (
int jr = 0; jr <
triples.size(); jr++ )
3299 int wvx =
cb_lplot ->currentIndex();
3301 QString triple =
cb_triple->currentText() +
" / " + swavl;
3302 idax =
triples.indexOf( triple );
3318 s = tr(
"meniscus" );
3320 s = tr(
"air gap" );
3322 s = tr(
"data range" );
3324 s = tr(
"plateau" );
3326 s = tr(
"baseline" );
3328 if ( ! s.isEmpty() )
3330 QMessageBox::information(
this,
3331 tr(
"Data missing" ),
3332 tr(
"You must define the " ) + s
3333 + tr(
" before writing the edit profile." ) );
3340 QMessageBox::critical(
this,
3341 tr(
"Meniscus/Data_Left Inconsistent" ),
3342 tr(
"The specified Meniscus (%1) extends into the "
3343 "Data Range (%2 to %3). Correct the Meniscus/Data_Left" )
3350 QMessageBox::critical(
this,
3351 tr(
"Plateau/Data_Right Inconsistent" ),
3352 tr(
"The specified Plateau (%1) is outside of the "
3353 "Data Range (%2 to %3). Correct the Meniscus/Data_Right" )
3363 QString now = QDateTime::currentDateTime()
3364 .toUTC().toString(
"yyMMddhhmm" );
3367 QString msg = tr(
"The base Edit Label for this edit session is <b>" )
3368 + now +
"</b> .<br/>"
3369 + tr(
"You may add an optional suffix to further distinquish<br/>"
3370 "the Edit Label. Use alphanumeric characters, underscores,<br/>"
3371 "or hyphens (no spaces). Enter 0 to 10 suffix characters." );
3372 sufx = QInputDialog::getText(
this,
3373 tr(
"Create a unique session Edit Label" ),
3381 sufx.remove( QRegExp(
"[^\\w\\d_-]" ) );
3386 QMessageBox::critical(
this,
3387 tr(
"Text length error" ),
3388 tr(
"You entered %1 characters for the Edit Label suffix.\n"
3389 "Re-enter, limiting length to 10 characters." )
3390 .arg( sufx.length() ) );
3392 sufx = sufx.left( 10 );
3400 QString filename =
files[ idax ];
3402 <<
"filename" << filename;
3403 QString rpart = filename.section(
".", 0, -6 );
3404 QString tpart = filename.section(
".", -5, -2 );
3405 filename = rpart +
"." +
editLabel +
"." + tpart +
".xml";
3406 QString wvpart =
"";
3407 DbgLv(1) <<
"EDT:WrTripl: filename" << filename;
3410 expType.compare(
"other", Qt::CaseInsensitive ) == 0 )
3415 if ( editGUID.isEmpty() )
3422 QString triple =
triples.at( idax );
3423 DbgLv(1) <<
"EDT:WrTripl: triple" << triple;
3426 int wrstat =
write_xml_file( filename, triple, editGUID, rawGUID );
3441 QMessageBox::warning(
this, tr(
"Connection Problem" ),
3442 tr(
"Could not connect to database \n" ) +
dbP->
lastError() );
3447 QString editID =
editIDs[ idax ];
3473 QMessageBox::warning(
this, tr(
"Connection Problem" ),
3474 tr(
"Could not connect to database: \n" ) + dbP->
lastError() );
3478 QStringList q(
"get_rawDataID_from_GUID" );
3486 QMessageBox::warning(
this,
3487 tr(
"AUC Data is not in DB" ),
3488 tr(
"Cannot find the raw data in the database.\n" ) );
3494 QString rawDataID = dbP->
value( 0 ).toString();
3497 q <<
"get_editedDataIDs" << rawDataID;
3502 QStringList editDataIDs;
3503 QStringList filenames;
3505 while ( dbP->
next() )
3507 editDataIDs << dbP->
value( 0 ).toString();
3508 filenames << dbP->
value( 2 ).toString();
3511 if ( editDataIDs.size() == 0 )
3513 QMessageBox::warning(
this,
3514 tr(
"Edit data is not in DB" ),
3515 tr(
"Cannot find any edit records in the database.\n" ) );
3522 if ( dialog.exec() == QDialog::Rejected )
return;
3527 int dataID = editDataIDs[ index ].toInt();
3534 index1 = filter.indexOf(
'.' ) + 1;
3536 filter =
"*" + filter.mid( index1 );
3537 filter.replace( QRegExp(
"auc$" ),
"xml" );
3538 filter = tr(
"Edits(" ) + filter + tr(
");;All XML (*.xml)" );
3541 filepath = QFileDialog::getOpenFileName(
this,
3542 tr(
"Select a saved edit file" ),
3545 DbgLv(1) <<
"AppPri: fpath" << filepath;
3547 if ( filepath.isEmpty() )
return;
3550 QStringList editfiles;
3551 filepath = filepath.replace(
"\\",
"/" );
3552 filename = filepath.section(
"/", -1, -1 );
3553 QString triple = filename.section(
".", -4, -2 )
3554 .replace(
".",
" / " );
3555 int idax =
triples.indexOf( triple );
3558 DbgLv(1) <<
"AppPri: nledits" << nledits << editfiles.count();
3562 QPushButton* pb_defb;
3563 QPushButton* pb_selo;
3564 QPushButton* pb_allw;
3565 QString edtLbl = editfiles[ 0 ].section(
".", -6, -6 );
3566 int swavl = editfiles[ 0 ].section(
".", -2, -2 ).toInt();
3567 int ewavl = editfiles[ nledits - 1 ].section(
".", -2, -2 ).toInt();
3570 QString msg = tr(
"%1 wavelengths (%2 to %3) have the same<br/>"
3571 "Edit Label of \"%4\" as the selected file.<br/>"
3573 "Specify whether you wish to apply edits only<br/>"
3574 "to the selected file (<b>Selected Only</b>)<br/>"
3575 "or to apply them to all wavelengths of the<br/>"
3576 "current cell/channel (<b>All Wavelengths</b>)." )
3577 .arg( nledits ).arg( swavl ).arg( ewavl ).arg( edtLbl );
3578 mbox.setIcon ( QMessageBox::Question );
3579 mbox.setTextFormat( Qt::RichText );
3580 mbox.setText ( msg );
3581 pb_selo = mbox.addButton( tr(
"Selected Only" ),
3582 QMessageBox::RejectRole );
3583 pb_allw = mbox.addButton( tr(
"All Wavelengths" ),
3584 QMessageBox::AcceptRole );
3585 pb_defb = nledits > 2 ? pb_allw : pb_selo;
3586 mbox.setDefaultButton( pb_defb );
3589 if ( mbox.clickedButton() == pb_selo )
3591 DbgLv(1) <<
"AppPri: SelOnly button clicked";
3594 editfiles << filename;
3601 DbgLv(1) <<
"AppPri: AllWavl button clicked";
3602 for (
int ii = 0; ii < nledits; ii++ )
3604 QString edfile = editfiles[ ii ];
3605 QString triple = edfile.section(
".", -4, -2 )
3606 .replace(
".",
" / " );
3607 int jdax =
triples.indexOf( triple );
3609 if ( edfile != filename )
3637 QMessageBox::warning(
this,
3639 tr(
"An error occurred when reading edit file\n\n" )
3648 QMessageBox::warning(
this,
3650 tr(
"The edit file was not created using the current data" ) );
3651 DbgLv(1) <<
"parsGUID rawGUID" << parameters.
dataGUID << uuid;
3670 int cndxs =
cb_rpms ->currentIndex();
3673 QStringList cefnames;
3683 QMessageBox::warning(
this, tr(
"Connection Problem" ),
3684 tr(
"Could not connect to database \n" ) + db.lastError() );
3688 QStringList q(
"get_rawDataID_from_GUID" );
3697 QMessageBox::warning(
this,
3698 tr(
"AUC Data is not in DB" ),
3699 tr(
"Cannot find the raw data in the database.\n" ) );
3705 QString rawDataID = db.value( 0 ).toString();
3708 q <<
"get_editedDataIDs" << rawDataID;
3713 QStringList editDataIDs;
3714 QStringList filenames;
3718 editDataIDs << db.value( 0 ).toString();
3719 filenames << db.value( 2 ).toString();
3722 if ( editDataIDs.size() == 0 )
3724 QMessageBox::warning(
this,
3725 tr(
"Edit data is not in DB" ),
3726 tr(
"Cannot find any edit records in the database.\n" ) );
3733 if ( dialog.exec() == QDialog::Rejected )
return;
3738 filename = filenames[ index ];
3739 int dataID = editDataIDs[ index ].toInt();
3741 QString
editLabel = filename.section(
".", -6, -6 );
3743 db.readBlobFromDB( filename,
"download_editData", dataID );
3745 cefnames << filename;
3748 for (
int ii = 1; ii <
outData.size(); ii++ )
3752 q <<
"get_rawDataID_from_GUID"
3756 rawDataID = db.value( 0 ).toString();
3759 q <<
"get_editedDataIDs" << rawDataID;
3766 dataID = db.value( 0 ).toString().toInt();
3767 filename = db.value( 2 ).toString();
3768 QString elb = filename.section(
".", -6, -6 );
3770 if ( elb == editLabel )
3774 db.readBlobFromDB( filename,
"download_editData", dataID );
3775 cefnames << filename;
3788 index1 = filter.indexOf(
'.' ) + 1;
3790 filter.insert( index1,
"*." );
3791 filter.replace( QRegExp(
"auc$" ),
"xml" );
3794 filename = QFileDialog::getOpenFileName(
this,
3795 tr(
"Select a saved edit file" ),
3798 if ( filename.isEmpty() )
return;
3800 filename = filename.replace(
"\\",
"/" );
3801 QString
editLabel = filename.section(
"/", -1, -1 ).section(
".", -6, -6 );
3802 QString
runID = filename.section(
"/", -1, -1 ).section(
".", 0, -7 );
3804 for (
int ii = 0; ii <
files.size(); ii++ )
3806 filename =
files[ ii ];
3807 filename = runID +
"." + editLabel +
"."
3808 + filename.section(
".", -5, -2 ) +
".xml";
3811 if ( QFile( filename ).exists() )
3812 cefnames << filename;
3819 for (
int ii = 0; ii < cefnames.size(); ii++ )
3822 filename = cefnames[ ii ];
3831 QMessageBox::warning(
this,
3833 tr(
"An error occurred when reading edit file\n\n" )
3842 QMessageBox::warning(
this,
3844 tr(
"The edit file was not created using the current data" ) );
3867 for (
int jj = 0; jj <
sd_knts[ ii ]; jj++ )
3882 le_airGap->setText( wkstr.sprintf(
"%.3f - %.3f",
3904 for (
int i = parameters.
excludes.size(); i > 0; i-- )
3910 for (
int i = 0; i < parameters.
editedPoints.size(); i++ )
3918 e.changes << QPointF( index1, value );
3965 cndxt = ( cndxt < 0 ) ? 0 : cndxt;
3966 cndxs = ( cndxs < 0 ) ? 0 : cndxs;
3968 cb_rpms ->setCurrentIndex( cndxs );
4003 int row =
cb_triple->currentIndex() + 1;
4004 row = ( row <
cb_triple->count() ) ? row : 0;
4008 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
4015 cb_rpms ->setCurrentIndex( 0 );
4025 bool all_ed_done =
false;
4032 for (
int jd = 0; jd <
outData.size(); jd++ )
4035 int ksd = jsd +
sd_knts[ jd ];
4036 QList< double > drpms;
4040 for (
int js = jsd; js < ksd; js++ )
4047 for (
int js = 0; js < rawdat->
scanData.size(); js++ )
4049 double drpm = rawdat->
scanData[ js ].rpm;
4051 if ( ! drpms.contains( drpm ) )
4070 DbgLv(1) <<
"all_ed_done" << all_ed_done;
4092 lb_gaps ->setVisible( !show );
4093 ct_gaps ->setVisible( !show );
4110 lo_lrange ->itemAtPosition( 0, 0 )->widget()->setVisible( show );
4111 lo_lrange ->itemAtPosition( 0, 1 )->widget()->setVisible( show );
4112 lo_custom ->itemAtPosition( 0, 0 )->widget()->setVisible( show );
4113 lo_custom ->itemAtPosition( 0, 1 )->widget()->setVisible( show );
4114 lo_radius ->itemAtPosition( 0, 0 )->widget()->setVisible( show );
4115 lo_radius ->itemAtPosition( 0, 1 )->widget()->setVisible( show );
4116 lo_waveln ->itemAtPosition( 0, 0 )->widget()->setVisible( show );
4117 lo_waveln ->itemAtPosition( 0, 1 )->widget()->setVisible( show );
4118 lo_writemwl->itemAtPosition( 0, 0 )->widget()->setVisible( show );
4119 lo_writemwl->itemAtPosition( 0, 1 )->widget()->setVisible( show );
4129 connect(
rb_lrange, SIGNAL( toggled (
bool ) ),
4131 connect(
rb_custom, SIGNAL( toggled (
bool ) ),
4133 connect(
ct_ldelta, SIGNAL( valueChanged (
double ) ),
4135 connect(
cb_lstart, SIGNAL( currentIndexChanged(
int ) ),
4137 connect(
cb_lend, SIGNAL( currentIndexChanged(
int ) ),
4139 connect(
rb_radius, SIGNAL( toggled (
bool ) ),
4141 connect(
rb_waveln, SIGNAL( toggled (
bool ) ),
4143 connect(
pb_custom, SIGNAL( clicked ( ) ),
4145 connect(
pb_incall, SIGNAL( clicked ( ) ),
4147 connect(
cb_lplot, SIGNAL( currentIndexChanged(
int ) ),
4149 connect(
pb_larrow, SIGNAL( clicked ( ) ),
4151 connect(
pb_rarrow, SIGNAL( clicked ( ) ),
4175 DbgLv(1) <<
"lselect range checked" << checked;
4189 cb_lend ->setEnabled( checked );
4197 DbgLv(1) <<
"lselect custom checked" << checked;
4211 cb_lend ->setEnabled( !checked );
4219 DbgLv(1) <<
"ldelta_value value" << value;
4229 DbgLv(1) <<
"lambda_start_value value" << value <<
slambda;
4238 DbgLv(1) <<
"lambda_end_value value" << value <<
elambda;
4249 int plambd =
cb_lplot ->currentText().toInt();
4252 int plotx =
cb_lplot ->currentIndex();
4254 <<
"sx ex nr" << strtx << endx <<
rawc_wvlns.size();
4261 for (
int ii = strtx; ii < endx; ii +=
dlambda )
4263 QString clam = rawc_wvlns[ ii ];
4264 int rlam = clam.toInt();
4270 plotx = qMax( 0,
expi_wvlns.indexOf( plambd ) );
4280 connect(
cb_lplot, SIGNAL( currentIndexChanged(
int ) ),
4282 cb_lplot->setCurrentIndex( plotx );
4286 le_lxrng ->setText( tr(
"%1 MWL exports: %2 %3 to %4," )
4289 : tr(
" from custom selections." ) ) );
4295 DbgLv(1) <<
"rpl: reset_outData() complete";
4301 DbgLv(1) <<
"xaxis_radius_on checked" << checked;
4305 lb_lplot->setText( tr(
"Plot (W nm):" ) );
4310 connect(
cb_lplot, SIGNAL( currentIndexChanged(
int ) ),
4319 DbgLv(1) <<
"xaxis_waveln_on checked" << checked;
4323 lb_lplot->setText( tr(
"Plot (R cm):" ) );
4328 connect(
cb_lplot, SIGNAL( currentIndexChanged(
int ) ),
4337 if ( value < 0 )
return;
4350 QString triple =
cb_triple->currentText() +
" / " + swavl;
4351 int idax =
triples.indexOf( triple );
4353 DbgLv(1) <<
"lambda_plot_value value" << value <<
plotrec;
4354 QString fname = ( menissv != 0.0 ) ?
editFnames[ idax ] :
"none";
4357 if ( fname ==
"none" )
4362 else if ( fname !=
"same" )
4381 DbgLv(1) <<
"lambda_plot_prev clicked";
4397 DbgLv(1) <<
"lambda_plot_next clicked";
4416 DbgLv(1) <<
"lambda_custom_list clicked";
4421 connect( sel_lambd, SIGNAL( new_lambda_list( QVector< int > ) ),
4424 if ( sel_lambd->exec() == QDialog::Accepted )
4426 DbgLv(1) <<
" lambda_custom_list ACCEPTED";
4427 int plotx =
cb_lplot ->currentIndex();
4435 connect(
cb_lplot, SIGNAL( currentIndexChanged(
int ) ),
4437 cb_lplot->setCurrentIndex( plotx );
4441 le_lxrng ->setText( tr(
"%1 MWL exports: %2 %3 to %4,"
4442 " from custom selections." )
4458 for (
int ii = 0; ii <
nwavelo; ii++ )
4467 cb_lend ->setCurrentIndex( endx );
4468 cb_lplot ->setCurrentIndex( nwavelo / 2 );
4475 DbgLv(1) <<
"lambda_include_all clicked";
4493 DbgLv(1) <<
"od_radius_limit value" << value;
4507 QString saved_info =
le_info->text();
4511 QMessageBox::warning(
this,
4512 tr(
"Invalid Selection" ),
4513 tr(
"The \"Save to all Wavelengths\" button is only valid\n"
4514 "for MultiWavelength data. No Save will be performed." ) );
4533 str = tr(
"meniscus" );
4535 str = tr(
"air gap" );
4537 str = tr(
"data range" );
4539 str = tr(
"plateau" );
4541 str = tr(
"baseline" );
4543 if ( ! str.isEmpty() )
4545 QMessageBox::information(
this,
4546 tr(
"Data missing" ),
4547 tr(
"You must define the " ) + str +
4548 tr(
" before writing the edit profile." ) );
4557 QString now = QDateTime::currentDateTime()
4558 .toUTC().toString(
"yyMMddhhmm" );
4561 QString msg = tr(
"The base Edit Label for this edit session is <b>" )
4562 + now +
"</b> .<br/>"
4563 + tr(
"You may add an optional suffix to further distinquish<br/>"
4564 "the Edit Label. Use alphanumeric characters, underscores,<br/>"
4565 "or hyphens (no spaces). Enter 0 to 10 suffix characters." );
4566 sufx = QInputDialog::getText(
this,
4567 tr(
"Create a unique session Edit Label" ),
4575 sufx.remove( QRegExp(
"[^\\w\\d_-]" ) );
4580 QMessageBox::critical(
this,
4581 tr(
"Text length error" ),
4582 tr(
"You entered %1 characters for the Edit Label suffix.\n"
4583 "Re-enter, limiting length to 10 characters." )
4584 .arg( sufx.length() ) );
4586 sufx = sufx.left( 10 );
4590 QVector< int > oldi_wvlns;
4594 bool chg_lamb = ( kwavelo !=
nwavelo );
4598 for ( wvx = 0; wvx <
nwavelo; wvx++ )
4600 if ( oldi_wvlns[ wvx ] !=
expi_wvlns[ wvx ] )
4616 QString scell = celchn.section(
"/", 0, 0 ).simplified();
4617 QString schan = celchn.section(
"/", 1, 1 ).simplified();
4618 QString tripbase = scell +
" / " + schan +
" / ";
4621 DbgLv(1) <<
"EDT:WrMwl: dax celchn" << odax << celchn;
4623 QString filebase =
files[ idax ].section(
".", 0, -6 )
4625 +
files[ idax ].section(
".", -5, -5 )
4626 +
"." + scell +
"." + schan +
".";
4627 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
4632 for ( wvx = 0; wvx <
expc_wvlns.size(); wvx++ )
4635 QString triple = tripbase + swavl;
4636 QString filename = filebase + swavl +
".xml";
4637 idax =
triples.indexOf( triple );
4639 DbgLv(1) <<
"EDT:WrMwl: wvx triple" << wvx << triple <<
"filename" << filename;
4641 DbgLv(1) <<
"EDT:WrMwl: idax,editGUIDs.size" << idax <<
editGUIDs.size();
4644 if ( editGUID.isEmpty() )
4649 DbgLv(1) <<
"EDT:WrMwl: editGUID" << editGUID;
4651 DbgLv(1) <<
"EDT:WrMwl: odax,outData.size" << odax <<
outData.size();
4653 (
unsigned char*)
outData[ odax ]->rawGUID );
4654 DbgLv(1) <<
"EDT:WrMwl: rawGUID" << rawGUID;
4657 le_info->setText( tr(
"Writing " ) + filename +
" ..." );
4658 qApp->processEvents();
4659 int wrstat =
write_xml_file( filename, triple, editGUID, rawGUID );
4660 DbgLv(1) <<
"EDT:WrMwl: write_xml_file stat" << wrstat;
4675 QMessageBox::warning(
this, tr(
"Connection Problem" ),
4676 tr(
"Could not connect to database \n" ) +
dbP->
lastError() );
4681 QString editID =
editIDs[ idax ];
4685 DbgLv(1) <<
"EDT:WrMwl: dax fname" << idax << filename <<
"wrstat" << wrstat;
4692 QApplication::restoreOverrideCursor();
4696 le_info->setText( saved_info );
4697 qApp->processEvents();
4698 DbgLv(1) <<
"EDT:WrMwl: DONE";
4703 QString& editGUID, QString& rawGUID )
4707 if ( ! efo.open( QFile::WriteOnly | QFile::Text ) )
4709 QMessageBox::information(
this,
4710 tr(
"File write error" ),
4711 tr(
"Could not open the file\n" ) +
workingDir + fname
4712 + tr(
"\n for writing. Check your permissions." ) );
4716 DbgLv(1) <<
"EDT:WrXml: IN: fname,triple,editGUID,rawGUID"
4717 << fname << triple << editGUID << rawGUID;
4718 QXmlStreamWriter xml( &efo );
4720 xml.setAutoFormatting(
true );
4721 xml.writeStartDocument();
4722 xml.writeDTD (
"<!DOCTYPE UltraScanEdits>" );
4723 xml.writeStartElement(
"experiment" );
4724 xml.writeAttribute (
"type",
expType );
4727 xml.writeStartElement(
"identification" );
4729 xml.writeStartElement(
"runid" );
4730 xml.writeAttribute (
"value",
runID );
4731 xml.writeEndElement ();
4733 xml.writeStartElement(
"editGUID" );
4734 xml.writeAttribute (
"value", editGUID );
4735 xml.writeEndElement ();
4737 xml.writeStartElement(
"rawDataGUID" );
4738 xml.writeAttribute (
"value", rawGUID );
4739 xml.writeEndElement ();
4741 xml.writeEndElement ();
4743 QStringList parts = triple.contains(
" / " ) ?
4744 triple.split(
" / " ) :
4745 triple.split(
"." );
4746 DbgLv(1) <<
"EDT:WrXml: parts.size" << parts.size();
4748 QString cell = parts[ 0 ];
4749 QString channel = parts[ 1 ];
4750 QString waveln = parts[ 2 ];
4752 DbgLv(1) <<
"EDT:WrXml: waveln" << waveln;
4754 xml.writeStartElement(
"run" );
4755 xml.writeAttribute (
"cell", cell );
4756 xml.writeAttribute (
"channel", channel );
4757 xml.writeAttribute (
"wavelength", waveln );
4762 xml.writeStartElement(
"excludes" );
4768 xml.writeStartElement(
"exclude" );
4769 xml.writeAttribute (
"scan", QString::number( ii ) );
4770 xml.writeEndElement ();
4774 xml.writeEndElement ();
4780 xml.writeStartElement(
"edited" );
4786 for (
int jj = 0; jj < e->
changes.size(); jj++ )
4788 xml.writeStartElement(
"edit" );
4789 xml.writeAttribute (
"scan", QString::number( e->
scan ) );
4790 xml.writeAttribute (
"radius",
4791 QString::number( e->
changes[ jj ].x(),
'f', 4 ) );
4792 xml.writeAttribute (
"value",
4793 QString::number( e->
changes[ jj ].y(),
'f', 4 ) );
4794 xml.writeEndElement ();
4798 xml.writeEndElement ();
4802 xml.writeStartElement(
"parameters" );
4806 xml.writeStartElement(
"meniscus" );
4807 xml.writeAttribute (
"radius",
4808 QString::number(
meniscus,
'f', 4 ) );
4809 xml.writeEndElement ();
4813 xml.writeStartElement(
"air_gap" );
4814 xml.writeAttribute (
"left",
4816 xml.writeAttribute (
"right",
4818 xml.writeAttribute (
"tolerance",
4819 QString::number(
ct_gaps->value(),
'f', 4 ) );
4820 xml.writeEndElement ();
4823 xml.writeStartElement(
"data_range" );
4824 xml.writeAttribute (
"left",
4826 xml.writeAttribute (
"right",
4828 xml.writeEndElement ();
4830 xml.writeStartElement(
"plateau" );
4831 xml.writeAttribute (
"radius",
4832 QString::number(
plateau,
'f', 4 ) );
4833 xml.writeEndElement ();
4835 xml.writeStartElement(
"baseline" );
4836 xml.writeAttribute (
"radius",
4837 QString::number(
baseline,
'f', 4 ) );
4838 xml.writeEndElement ();
4840 xml.writeStartElement(
"od_limit" );
4841 xml.writeAttribute (
"value",
4842 QString::number(
odlimit,
'f', 4 ) );
4843 xml.writeEndElement ();
4850 xml.writeStartElement(
"air_gap" );
4851 xml.writeAttribute (
"left",
4853 xml.writeAttribute (
"right",
4855 xml.writeAttribute (
"tolerance",
4856 QString::number(
ct_gaps->value(),
'f', 4 ) );
4857 xml.writeEndElement ();
4863 for (
int ii = jsd; ii < ksd; ii++ )
4865 double speed =
sData[ ii ].speed;
4866 int sStart =
sData[ ii ].first_scan;
4867 int sCount =
sData[ ii ].scan_count;
4869 double dataLeft =
sData[ ii ].dataLeft;
4870 double dataRight =
sData[ ii ].dataRight;
4872 xml.writeStartElement(
"speed" );
4873 xml.writeAttribute (
"value", QString::number( speed ) );
4874 xml.writeAttribute (
"scanStart", QString::number( sStart ) );
4875 xml.writeAttribute (
"scanCount", QString::number( sCount ) );
4877 xml.writeStartElement(
"meniscus" );
4878 xml.writeAttribute (
"radius", QString::number( meniscus,
'f', 4 ) );
4879 xml.writeEndElement ();
4881 xml.writeStartElement(
"data_range" );
4882 xml.writeAttribute (
"left", QString::number( dataLeft,
'f', 4 ) );
4883 xml.writeAttribute (
"right", QString::number( dataRight,
'f', 4 ) );
4884 xml.writeEndElement ();
4886 xml.writeEndElement ();
4890 xml.writeEndElement ();
4897 xml.writeStartElement(
"operations" );
4902 xml.writeStartElement(
"subtract_ri_noise" );
4903 xml.writeAttribute (
"order", QString::number(
noise_order ) );
4904 xml.writeEndElement ();
4910 xml.writeStartElement(
"remove_spikes" );
4911 xml.writeEndElement ();
4917 xml.writeStartElement(
"invert" );
4918 xml.writeEndElement ();
4924 xml.writeStartElement(
"floating_data" );
4925 xml.writeEndElement ();
4928 xml.writeEndElement ();
4931 xml.writeEndElement ();
4932 xml.writeEndElement ();
4933 xml.writeEndDocument ();
4941 QString& editID, QString& rawGUID )
4947 QMessageBox::warning(
this, tr(
"Connection Problem" ),
4948 tr(
"Could not connect to database \n" ) + dbP->
lastError() );
4952 QStringList query(
"get_rawDataID_from_GUID" );
4954 dbP->
query( query );
4958 QMessageBox::warning(
this,
4959 tr(
"AUC Data is not in DB" ),
4960 tr(
"Cannot save edit data to the database.\n"
4961 "The associated AUC data is not present." ) );
4966 QString rawDataID = dbP->
value( 0 ).toString();
4972 if ( editID.isEmpty() )
4974 query <<
"new_editedData" << rawDataID << editGUID <<
runID
4977 dbP->
query( query );
4981 QMessageBox::warning(
this, tr(
"Database Problem" ),
4982 tr(
"Could not insert metadata into the database\n" ) +
4989 editID = QString::number( idEdit );
4990 int dax =
editGUIDs.indexOf( editGUID );
4991 editIDs.replace( dax, editID );
4996 query <<
"update_editedData" << editID << rawDataID << editGUID
4997 <<
runID << fname <<
"";
4998 dbP->
query( query );
5002 QMessageBox::warning(
this, tr(
"Database Problem" ),
5003 tr(
"Could not update metadata in the database \n" ) +
5009 idEdit = editID.toInt();
5016 QMessageBox::warning(
this, tr(
"Database Problem" ),
5017 tr(
"Could not insert edit xml data into database \n" ) +
5061 QString filebase = filename.section(
".", 0, -3 );
5062 QStringList filter( filebase +
".*.xml" );
5063 QStringList edfiles = QDir(
workingDir ).entryList(
5064 filter, QDir::Files, QDir::Name );
5065 QStringList ldfiles;
5068 for (
int ii = 0; ii < edfiles.count(); ii++ )
5070 QString fname = edfiles[ ii ];
5071 QString triple = fname.section(
".", -4, -2 ).replace(
".",
" / " );
5073 if (
triples.contains( triple ) )
5077 int nledits = ldfiles.count();
5078 DbgLv(1) <<
"LiEdFi: nledits" << ldfiles.count() << filter;
5083 QStringList dbfiles;
5084 QStringList dbEdIds;
5085 QStringList dbquery;
5099 dbquery <<
"all_editedDataIDs" << invID;
5100 dbP->
query( dbquery );
5102 while ( dbP->
next() )
5104 QString idData = dbP->
value( 0 ).toString();
5105 QString efname = dbP->
value( 2 ).toString()
5106 .section(
"/", -1, -1 );
5107 QString triple = efname.section(
".", -4, -2 )
5108 .replace(
".",
" / " );
5113 if ( efname.startsWith( filebase ) &&
triples.contains( triple ) )
5117 DbgLv(1) <<
"LiEdFi: id fn dbfsiz" << idData << efname << dbfiles.count();
5121 int nlocals = ldfiles.count();
5122 nledits = dbfiles.count();
5123 DbgLv(1) <<
"LiEdFi: nlocals nledits" << nlocals << nledits;
5125 if ( nledits != nlocals )
5132 for (
int ii = 0; ii < dbfiles.count(); ii++ )
5135 int dataID = dbEdIds[ ii ].toInt();
5144 editfiles = ldfiles;
5145 nledits = editfiles.count();
5149 editfiles << filename;
5153 else if ( nledits > 1 )
5157 DbgLv(1) <<
"LiEdFi: nle fn0" << nledits << editfiles[0];
5188 le_airGap->setText( wkstr.sprintf(
"%.3f - %.3f",
5208 for (
int jj = pt - 5; jj <= pt + 5; jj++ )
5224 for (
int ii = parameters.
excludes.size(); ii > 0; ii-- )
5230 for (
int ii = 0; ii < parameters.
editedPoints.size(); ii++ )
5233 int index1 = (int)parameters.
editedPoints[ ii ].radius;
5238 e.changes << QPointF( index1, value );
5277 connect(
ct_odlim, SIGNAL( valueChanged (
double ) ),
5289 if ( !
isMwl )
return;
5292 QVector< int > ex_wvlns;
5296 for (
int ccx = 0; ccx <
ncelchn; ccx++ )
5301 DbgLv(1) <<
"rsoD: ccx kwv" << ccx << kwvln << ex_wvlns.size()
5302 <<
"nwv ccoff" <<
nwaveln << ccoff;
5304 for (
int wvo = 0; wvo < kwvln; wvo++ )
5306 int iwavl = ex_wvlns[ wvo ];
5307 int idatx = ccoff +
rawi_wvlns.indexOf( iwavl );
5315 DbgLv(1) <<
"rsoD: final ccoff" << ccoff <<
"aDa size" <<
allData.size()
5316 <<
"oDa size" <<
outData.size();
5331 for (
int wvx = 0; wvx <
nwaveln; wvx++ )