3 #include <QApplication>
15 int main(
int argc,
char* argv[] )
17 QApplication application( argc, argv );
25 return application.exec();
30 setWindowTitle( tr(
"Time Derivative - dC/dt Analysis" ) );
36 QLabel* lb_sValue =
us_label( tr(
"S-value Cutoff:" ) );
39 connect(
ct_sValue, SIGNAL( valueChanged (
double ) ),
42 QLabel* lb_graph =
us_label( tr(
"Graph Selection" ) );
43 lb_graph->setAlignment ( Qt::AlignCenter );
49 QButtonGroup* group =
new QButtonGroup(
this );
51 group->addButton(
rb_sed , 1 );
52 group->addButton(
rb_avg , 2 );
54 connect( group, SIGNAL( buttonClicked(
int ) ), SLOT(
set_graph(
int ) ) );
56 QBoxLayout* rb_layout0 =
new QHBoxLayout();
57 rb_layout0->addLayout( rb_layout1 );
58 rb_layout0->addLayout( rb_layout2 );
59 rb_layout0->addLayout( rb_layout3 );
62 QLabel* lb_bPos =
us_label( tr(
"Boundary Pos (%):" ) );
74 connect(
pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
75 connect(
pb_view, SIGNAL( clicked() ), SLOT(
view() ) );
76 connect(
pb_save, SIGNAL( clicked() ), SLOT(
save() ) );
89 qApp->processEvents();
122 connect(
ct_sValue, SIGNAL( valueChanged (
double ) ),
124 qApp->processEvents();
167 le_skipped->setText( QString::number( skipped ) );
171 QMessageBox::warning(
this,
173 tr(
"You must have at least four non-skipped scans "
174 "for this analysis." ) );
188 for (
int i = 0; i < scanCount; i++ )
190 dcdt << QVector< double >( points );
191 sValues << QVector< double >( points );
200 int previous = skipped;
204 for (
int i = skipped + 1; i < scanCount; i++ )
212 double range = thisScan->
plateau - baseline;
213 double lower_limit = baseline + range * positionPct;
215 double plateau = thisScan->
plateau;
216 double prevPlateau = prevScan->
plateau;
219 double omega = thisScan->
rpm * M_PI / 30.0;
222 bool started =
false;
224 for (
int j = 0; j < points; j++ )
226 double currentV = thisScan->
rvalues[ j ];
227 double previousV = prevScan->
rvalues[ j ];
229 if ( currentV < lower_limit )
continue;
237 double dC = previousV / prevPlateau - currentV / plateau;
238 dcdt[ count ][ size ] = dC / dt;
239 double radius = d->
radius( j );
243 (
sq( omega ) * ( prevScan->
seconds + dt / 2.0 ) );
245 s_max =
max( s_max,
sValues[ count ][ size ] );
265 connect(
ct_sValue, SIGNAL( valueChanged (
double ) ),
267 qApp->processEvents();
273 double s_min = 9.9e10;
275 for (
int i = 0; i < count; i++ )
284 double increment = ( s_max - s_min ) /
arrayLength;
288 avgS[ i ] = s_min + i * increment;
298 for (
int i = 0; i < count; i++ )
311 double m = (
dcdt [ i ][ k ] -
dcdt [ i ][ k - 1 ] ) /
319 next:
avgDcdt[ j ] /= ( count - 1 );
326 data_plot1->setTitle( tr(
"Time Derivative (dC/dt)\n" ) +
327 tr(
"Run " ) + d->
runID + tr(
": Cell " ) + d->
cell
330 data_plot1->setAxisTitle( QwtPlot::yLeft , tr(
"g<sup>*</sup>(s)" ) );
332 QVector< double > x( points );
334 QwtText title = QwtText( tr(
"<b>Sedimentation Coefficient x "
335 "10<sup>13</sup> sec</b>" ) );
337 data_plot1->setAxisTitle( QwtPlot::xBottom, title );
343 data_plot1->setAxisTitle( QwtPlot::xBottom, tr(
"Radius (cm)" ) );
345 for (
int i = 0; i < count; i++ )
350 for (
int j = arrayStart[ i ]; j < end; j++ )
354 tr(
"Scan " ) + QString::number( i + 1 ) );
359 data_plot1->setAxisAutoScale( QwtPlot::xBottom );
363 for (
int i = 0; i < count; i++ )
366 tr(
"Scan " ) + QString::number( i + 1 ) );
368 curve->setData(
sValues[ i ].data(),
dcdt[ i ].data(),
377 tr(
"Average g<sup>*</sup>(s)" ) );
386 qApp->processEvents();
412 double avglcu = avgmax * 0.05;
421 aslox = aslox < 0 ? ii : aslox;
428 QString xastr =
table_row( tr(
"Average S at Maximum dCdt:" ),
429 QString::number(
avgS[ asmxx ],
'f', 3 ) );
430 xastr +=
table_row( tr(
"Average S at interest zone Start:" ),
431 QString::number(
avgS[ aslox ],
'f', 3 ) );
432 xastr +=
table_row( tr(
"Average S at interest zone End:" ),
433 QString::number(
avgS[ ashix ],
'f', 3 ) );
434 xastr +=
table_row( tr(
"Interest zone percent of maximum:" ),
435 QString(
"5% and above" ) );
437 QString title =
"US_dCdt";
438 QString head1 = tr(
"Time - Derivative (dC/dt) Analysis" );
442 ts <<
indent( 2 ) +
"</body>\n</html>\n";
449 QTextStream ts( &mtext );
476 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
478 QString filebase = dir +
"/" + d->
runID +
"/dcdt."
479 + QString(
triples.at( index ) ).replace(
" / ",
"" ) +
".";
481 QString htmlFile = filebase +
"report.html";
482 QString plot1File = filebase +
"velocity.svgz";
483 QString plot2File = filebase +
"x-to-radius.svgz";
484 QString plot3File = filebase +
"x-to-S.svgz";
485 QString plot4File = filebase +
"average-S.svgz";
486 QString textFile = filebase +
"average-S.csv";
487 QString dsinfFile = QString( filebase ).replace(
"/dcdt.",
"/dsinfo." )
488 +
"dataset_info.html";
495 QFile f_rep( htmlFile );
497 if ( ! f_rep.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
499 QMessageBox::warning(
this,
501 tr(
"Could not open\n" ) + htmlFile +
"\n" +
502 tr(
"\nfor writing" ) );
503 QApplication::restoreOverrideCursor();
507 QTextStream ts( &f_rep );
537 QFile dcdt_data( textFile );
539 if ( ! dcdt_data.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
541 QMessageBox::warning(
this,
543 tr(
"Could not open\n" ) + textFile +
"\n" +
544 tr(
"\nfor writing" ) );
545 QApplication::restoreOverrideCursor();
549 QTextStream ts_data( &dcdt_data );
550 const QString sep(
"\",\"" );
551 const QString quo(
"\"" );
552 const QString eln(
"\"\n" );
553 ts_data <<
"\"average.S\",\"average.Dcdt\"\n";
557 QString strS = QString::number(
avgS [ i ],
'f', 6 ).simplified();
558 QString strD = QString::number(
avgDcdt[ i ],
'e', 5 ).simplified();
559 ts_data << quo << strS << sep << strD << eln;
564 QStringList repfiles;
574 htmlFile = htmlFile .mid( htmlFile .lastIndexOf(
"/" ) + 1 );
575 plot1File = plot1File.mid( plot1File.lastIndexOf(
"/" ) + 1 );
576 plot2File = plot2File.mid( plot2File.lastIndexOf(
"/" ) + 1 );
577 plot3File = plot3File.mid( plot3File.lastIndexOf(
"/" ) + 1 );
578 plot4File = plot4File.mid( plot4File.lastIndexOf(
"/" ) + 1 );
579 textFile = textFile .mid( textFile .lastIndexOf(
"/" ) + 1 );
580 dsinfFile = dsinfFile.mid( dsinfFile.lastIndexOf(
"/" ) + 1 );
582 QString wmsg = tr(
"Wrote:\n " )
583 + htmlFile +
"\n " + plot1File +
"\n " + plot2File +
"\n "
584 + plot3File +
"\n " + plot4File +
"\n " + textFile +
"\n "
591 wmsg += tr(
"\n\nReport files were also saved to the database." );
594 QApplication::restoreOverrideCursor();
595 QMessageBox::warning(
this, tr(
"Success" ), wmsg );