3 #include <QApplication>
4 #include <QDomDocument>
23 #define DbgLv(a) if(dbg_level>=a)qDebug()
29 int main(
int argc,
char* argv[] )
31 QApplication application( argc, argv );
39 return application.exec();
70 setWindowTitle( tr(
"Buoyancy Equilibrium Data Analysis" ) );
73 QVBoxLayout* top =
new QVBoxLayout(
this );
74 top->setSpacing ( 2 );
75 top->setContentsMargins ( 2, 2, 2, 2 );
78 QHBoxLayout* runInfo =
new QHBoxLayout();
79 QLabel* lb_info =
us_label( tr(
"Dataset Info:" ), -1 );
80 runInfo->addWidget( lb_info );
85 top->addLayout( runInfo );
87 QHBoxLayout*
main =
new QHBoxLayout();
88 QVBoxLayout* left =
new QVBoxLayout;
91 QGridLayout* specs =
new QGridLayout;
97 QPushButton* pb_investigator =
us_pushbutton( tr(
"Select Investigator" ) );
99 specs->addWidget( pb_investigator, s_row, 0 );
102 pb_investigator->setEnabled(
false );
105 QString number = (
id > 0 ) ?
117 connect( pb_load, SIGNAL( clicked() ), SLOT(
load() ) );
118 specs->addWidget( pb_load, s_row, 0, 1, 2 );
122 specs->addWidget(
pb_details, s_row++, 2, 1, 2 );
125 QLabel* lb_triple =
us_label( tr(
"Cell / Channel / Wavelength:" ), -1 );
126 specs->addWidget( lb_triple, s_row, 0, 1, 2 );
129 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
131 specs->addWidget(
cb_triple, s_row++, 2, 1, 2 );
135 specs->addWidget(
lbl_rpms, s_row, 0, 1, 2 );
136 specs->addWidget(
cb_rpms, s_row++, 2, 1, 2 );
139 QLabel* lbl_scan =
us_label( tr(
"Scan Focus:" ), -1 );
140 lbl_scan->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
141 specs->addWidget( lbl_scan, s_row, 0, 1, 2 );
150 QButtonGroup* bg_points =
new QButtonGroup(
this );
161 specs->addLayout( box1, s_row, 0, 1, 2 );
162 specs->addLayout( box2, s_row++, 2, 1, 2 );
165 specs->addWidget( lbl_meniscus, s_row, 0, 1, 2 );
168 connect (
le_meniscus, SIGNAL( editingFinished (
void)),
this,
172 specs->addWidget( lbl_stretch, s_row, 0, 1, 2 );
174 specs->addWidget(
le_stretch, s_row++, 2, 1, 2 );
177 specs->addWidget( lbl_bottom, s_row, 0, 1, 2 );
179 specs->addWidget(
le_bottom, s_row++, 2, 1, 2 );
180 connect (
le_bottom, SIGNAL( editingFinished (
void)),
this,
184 specs->addWidget( lbl_bottom_calc, s_row, 0, 1, 2 );
192 specs->addWidget( lbl_dens_0, s_row, 0, 1, 2 );
194 specs->addWidget(
le_dens_0, s_row++, 2, 1, 2 );
195 connect (
le_dens_0, SIGNAL( editingFinished (
void)),
this,
199 specs->addWidget( lbl_buffer_density, s_row, 0, 1, 2 );
206 specs->addWidget( lbl_vbar, s_row, 0, 1, 2 );
208 specs->addWidget(
le_vbar, s_row++, 2, 1, 2 );
209 connect (
le_vbar, SIGNAL( editingFinished (
void)),
this,
212 QLabel*
lbl_MW =
us_label( tr(
"Gradient Mat. MW (g/mol):" ), -1 );
213 specs->addWidget( lbl_MW, s_row, 0, 1, 2 );
215 specs->addWidget(
le_MW, s_row++, 2, 1, 2 );
216 connect (
le_MW, SIGNAL( editingFinished (
void)),
this,
220 specs->addWidget( lbl_temperature, s_row, 0, 1, 2 );
225 specs->addWidget( lbl_peakName, s_row, 0, 1, 2 );
228 connect (
le_peakName, SIGNAL( editingFinished (
void)),
this,
232 specs->addWidget( lbl_peakPosition, s_row, 0, 1, 2 );
237 specs->addWidget( lbl_peakDensity, s_row, 0, 1, 2 );
242 specs->addWidget( lbl_peakVbar, s_row, 0, 1, 2 );
247 QBoxLayout* buttons =
new QHBoxLayout;
250 connect(
pb_save, SIGNAL( clicked() ), SLOT(
save() ) );
251 specs->addWidget(
pb_save, s_row, 0, 1, 2 );
255 specs->addWidget(
pb_write, s_row++, 2, 1, 2 );
258 connect( pb_reset, SIGNAL( clicked() ), SLOT(
reset() ) );
259 buttons->addWidget( pb_reset );
262 connect( pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
263 buttons->addWidget( pb_help );
266 connect( pb_accept, SIGNAL( clicked() ), SLOT( close() ) );
267 buttons->addWidget( pb_accept );
271 tr(
"Absorbance Data" ),
272 tr(
"Radius (in cm)" ), tr(
"Absorbance" ) );
276 data_plot->enableAxis( QwtPlot::xBottom,
true );
277 data_plot->enableAxis( QwtPlot::yLeft ,
true );
281 pick->setRubberBand ( QwtPicker::VLineRubberBand );
282 pick->setMousePattern( QwtEventPattern::MouseSelect1,
283 Qt::LeftButton, Qt::ControlModifier );
285 left->addLayout( specs );
287 left->addLayout( buttons );
289 main->addLayout( left );
290 main->addLayout(
plot );
291 main->setStretchFactor(
plot, 3 );
292 top ->addLayout( main );
346 double omega_s, C, C0, r2, k1, k2, k3, k4;
353 k3 = exp( k1 * ( k4 ) * r2);
381 connect( dialog, SIGNAL( changed (
bool ) ),
384 if ( dialog->exec() == QDialog::Rejected )
return;
391 QMessageBox::warning(
this,
392 tr(
"No Files Found" ),
393 tr(
"There were no files of the form *.auc\n"
394 "found in the specified directory." ) );
399 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
410 + QString( QChar(
data.
type[ 1 ] ) );
415 for (
int ii=0; ii<
triples.size(); ii++)
421 for (
int ii = 0; ii <
triples.size(); ii++ )
423 QString triple = QString(
triples.at( ii ) ).replace(
" / ",
"." );
424 QString file =
runID +
"." +
dataType +
"." + triple +
".auc";
433 for (
int ii = 0; ii <
triples.size(); ii++ )
435 QString triple = QString(
triples.at( ii ) ).replace(
" / ",
"." );
436 QString file =
runID +
"." +
dataType +
"." + triple +
".auc";
445 if ( xf.open( QIODevice::ReadOnly | QIODevice::Text ) )
447 QXmlStreamReader xml( &xf );
449 while( ! xml.atEnd() )
453 if ( xml.isStartElement() && xml.name() ==
"experiment" )
455 QXmlStreamAttributes xa = xml.attributes();
456 expType = xa.value(
"type" ).toString();
471 QMessageBox::warning(
this, tr(
"Connection Problem" ),
472 tr(
"Could not connect to database \n" ) + db.lastError() );
477 query <<
"get_experiment_info_by_runID" <<
runID
482 expType = db.value( 8 ).toString();
496 connect(
pick, SIGNAL( cMouseUp(
const QwtDoublePoint& ) ),
497 SLOT (
mouse (
const QwtDoublePoint& ) ) );
499 connect(
cb_rpms, SIGNAL( currentIndexChanged(
int ) ),
504 QMessageBox::warning(
this, tr(
"Wrong Type of Data" ),
505 tr(
"This analysis program requires data of type \"Buoyancy\".\n"
506 "Please load a different dataset with the correct type.") );
513 if ( dataType ==
"FI")
515 str1 =
"Fluorescence Data";
516 str2 =
"Fluorescence Intensity";
518 else if ( dataType ==
"RI")
520 str1 =
"Absorbance Data";
523 else if ( dataType ==
"RA")
525 str1 =
"Absorbance Data";
528 else if ( dataType ==
"IP")
530 str1 =
"Interference Data";
534 data_plot->setAxisTitle( QwtPlot::yLeft, str2 );
543 dt = ( temp_spread > dt ) ? temp_spread : dt;
548 QMessageBox::warning(
this,
549 tr(
"Temperature Problem" ),
550 tr(
"The temperature in this run varied over the course\n"
551 "of the run to a larger extent than allowed by the\n"
552 "current threshold (" )
554 +
" " +
DEGC + tr(
". The accuracy of experimental\n"
555 "results may be affected significantly." ) );
565 double maximum = -1.0e99;
599 marker =
new QwtPlotMarker;
600 QBrush brush( Qt::white );
601 QPen pen ( brush, 2.0 );
603 marker->setValue( p.x(), maximum );
604 marker->setSymbol( QwtSymbol(
623 qApp->processEvents();
637 QString inv_text = QString::number( investigator ) +
": "
657 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
658 data_plot->detachItems( QwtPlotItem::Rtti_PlotMarker );
662 data_plot->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
663 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
703 QVector< double > rvec( rsize );
704 QVector< double > vvec( rsize );
705 double* r = rvec.data();
706 double* v = vvec.data();
708 data_plot->detachItems( QwtPlotItem::Rtti_PlotCurve );
711 double maxR = -1.0e99;
712 double minR = 1.0e99;
713 double maxV = -1.0e99;
714 double minV = 1.0e99;
716 QString srpm =
cb_rpms->currentText();
721 for (
int ii = 0; ii < ssize; ii++ )
725 QString arpm = QString::number( s->
rpm );
738 for (
int jj = 0; jj < rsize; jj++ )
743 maxR =
max( maxR, r[ count ] );
744 minR =
min( minR, r[ count ] );
745 maxV =
max( maxV, v[ count ] );
746 minV =
min( minV, v[ count ] );
751 QString title = tr(
"Raw Data at " )
752 + QString::number( s->
seconds ) + tr(
" seconds" )
753 +
" #" + QString::number( ii );
756 c->setData( r, v, count );
760 c->setPen( QPen( Qt::red ) );
764 double padR = ( maxR - minR ) / 30.0;
765 double padV = ( maxV - minV ) / 30.0;
767 data_plot->setAxisScale( QwtPlot::yLeft , minV - padV, maxV + padV );
768 data_plot->setAxisScale( QwtPlot::xBottom, minR - padR, maxR + padR );
786 QwtScaleDiv* y_axis =
data_plot->axisScaleDiv( QwtPlot::yLeft );
788 double padding = ( y_axis->upperBound() - y_axis->lowerBound() ) / 30.0;
791 v [ 0 ] = y_axis->upperBound() - padding;
792 v [ 1 ] = y_axis->lowerBound() + padding;
795 v_line->setData( r, v, 2 );
797 QPen pen = QPen( QBrush( Qt::white ), 2.0 );
829 te->
e->setFontFamily(
"Arial");
830 te->
e->setFontPointSize( 13 );
831 te->
e->append(
"UltraScan Buoyant Density Equilibrium Analysis Report:\n");
832 te->
e->setFontPointSize( 11 );
833 for (
int i=0; i<
dpoint.size(); i++)
835 te->
e->append(
"Peak " + str.setNum( i+1 ) +
" (" +
dpoint[i].name +
836 " from experiment \"" +
dpoint[i].dataset +
"\"):" );
837 te->
e->append(
"Sample location:\t" +
dpoint[i].triple );
838 te->
e->append(
"Sample description:\t" +
dpoint[i].description );
839 te->
e->append(
"Rotor speed:\t" + str.setNum(
dpoint[i].speed ) +
" rpm, (Rotor stretch: "
840 + str2.setNum(
dpoint[i].stretch) +
" cm)" );
841 te->
e->append(
"Peak position:\t" + str.setNum(
dpoint[i].peakPosition ) +
" cm");
842 te->
e->append(
"Peak density:\t" + str.setNum(
dpoint[i].peakDensity ) +
" g/ml");
843 te->
e->append(
"Peak vbar:\t\t" + str.setNum(
dpoint[i].peakVbar ) +
" ml/g");
844 te->
e->append(
"Buffer density:\t" + str.setNum(
dpoint[i].bufferDensity ) +
" g/ml");
845 te->
e->append(
"Meniscus position:\t" + str.setNum(
dpoint[i].meniscus ) +
" cm");
846 te->
e->append(
"Bottom of cell:\t" + str.setNum(
dpoint[i].bottom ) +
847 " cm (Centerpiece bottom at rest: " + str2.setNum(
dpoint[i].centerpiece ) +
" cm)" );
848 te->
e->append(
"Temperature:\t" + str.setNum(
dpoint[i].temperature ) +
" �C");
849 te->
e->append(
"Gradient-forming\nmaterial details:");
850 te->
e->append(
"Molecular weight:\t" + str.setNum(
dpoint[i].gradientMW ) +
" g/mol" );
851 te->
e->append(
"Loading density:\t" + str.setNum(
dpoint[i].gradientC0 ) +
" g/mol" );
852 te->
e->append(
"vbar:\t\t" + str.setNum(
dpoint[i].gradientVbar ) +
" ml/g" );
855 te->setMinimumHeight( 400 );
856 te->setMinimumWidth( 600 );
863 QString srpm =
cb_rpms->itemText( index ), str;
864 qDebug() <<
"rpmval: " << srpm;
923 for (
int jd = 0; jd <
allData.size(); jd++ )
936 QString arpm = QString::number( drpm );
955 sData[ jj ].scan_count++;
973 for (
int ii = 0; ii < ksd; ii++ )
975 QString arpm = QString::number(
sData[ ii ].speed );