3 #include <QApplication>
21 #define PA_TMDIS_MS 0 // default Plotall time per distro in milliseconds
24 int main(
int argc,
char* argv[] )
26 QApplication application( argc, argv );
34 return application.exec();
40 return ( solu1.
s < solu2.
s ) ||
41 ( ( solu1.
s == solu2.
s ) && ( solu1.
k < solu2.
k ) );
49 setWindowTitle( tr(
"Combine Pseudo-3D Distribution Overlays" ) );
53 QHBoxLayout*
main =
new QHBoxLayout(
this );
54 QVBoxLayout* left =
new QVBoxLayout();
55 QGridLayout* spec =
new QGridLayout();
56 main->setSpacing ( 2 );
57 main->setContentsMargins( 2, 2, 2, 2 );
58 left->setSpacing ( 0 );
59 left->setContentsMargins( 0, 1, 0, 1 );
60 spec->setSpacing ( 1 );
61 spec->setContentsMargins( 0, 0, 0, 0 );
68 QLabel* lb_info1 =
us_banner( tr(
"Pseudo-3D Plotting Controls" ) );
71 QLabel* lb_resolu =
us_label( tr(
"Pseudo-3D Resolution:" ) );
72 lb_resolu->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
76 connect(
ct_resolu, SIGNAL( valueChanged(
double ) ),
79 QLabel* lb_xreso =
us_label( tr(
"X Resolution:" ) );
80 lb_xreso->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
84 connect(
ct_xreso, SIGNAL( valueChanged(
double ) ),
87 QLabel* lb_yreso =
us_label( tr(
"Y Resolution:" ) );
88 lb_yreso->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
92 connect(
ct_yreso, SIGNAL( valueChanged(
double ) ),
95 QLabel* lb_zfloor =
us_label( tr(
"Z Floor Percent:" ) );
96 lb_zfloor->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
100 connect(
ct_zfloor, SIGNAL( valueChanged(
double ) ),
121 lb_plt_kmin->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
125 connect(
ct_plt_kmin, SIGNAL( valueChanged(
double ) ),
129 lb_plt_kmax->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
133 connect(
ct_plt_kmax, SIGNAL( valueChanged(
double ) ),
137 lb_plt_smin->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
141 connect(
ct_plt_smin, SIGNAL( valueChanged(
double ) ),
145 lb_plt_smax->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
149 connect(
ct_plt_smax, SIGNAL( valueChanged(
double ) ),
152 QLabel* lb_plt_dlay =
us_label( tr(
"Plot Loop Delay Seconds:" ) );
153 lb_plt_dlay->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
162 QLabel* lb_curr_distr =
us_label( tr(
"Current Distro:" ) );
163 lb_curr_distr->setAlignment( Qt::AlignVCenter | Qt::AlignLeft );
171 te_distr_info->setText ( tr(
"Run: runID.triple (method)\n" )
172 + tr(
" analysisID" ) );
176 tr(
"Default Color Map: w-cyan-magenta-red-black" ), -1,
true );
181 QLabel* lb_x_axis =
us_label( tr(
"Plot X:" ) );
182 QLabel* lb_y_axis =
us_label( tr(
"Plot Y:" ) );
209 rb_x_s ->setChecked(
true );
210 rb_y_s ->setEnabled(
false );
213 rb_x_s ->setToolTip( tr(
"Set X axis to Sedimentation Coefficient" ) );
214 rb_x_ff0 ->setToolTip( tr(
"Set X axis to Frictional Ratio" ) );
215 rb_x_mw ->setToolTip( tr(
"Set X axis to Molecular Weight" ) );
216 rb_x_vbar->setToolTip( tr(
"Set X axis to Partial Specific Volume" ) );
217 rb_x_D ->setToolTip( tr(
"Set X axis to Diffusion Coefficient" ) );
218 rb_x_f ->setToolTip( tr(
"Set X axis to Frictional Coefficient" ) );
219 rb_y_s ->setToolTip( tr(
"Set Y axis to Sedimentation Coefficient" ) );
220 rb_y_ff0 ->setToolTip( tr(
"Set Y axis to Frictional Ratio" ) );
221 rb_y_mw ->setToolTip( tr(
"Set Y axis to Molecular Weight" ) );
222 rb_y_vbar->setToolTip( tr(
"Set Y axis to Partial Specific Volume" ) );
223 rb_y_D ->setToolTip( tr(
"Set Y axis to Diffusion Coefficient" ) );
224 rb_y_f ->setToolTip( tr(
"Set Y axis to Frictional Coefficient" ) );
225 connect(
bg_x_axis, SIGNAL( buttonReleased(
int ) ),
227 connect(
bg_y_axis, SIGNAL( buttonReleased(
int ) ),
238 this, SLOT(
stop() ) );
247 connect(
pb_reset, SIGNAL( clicked() ),
248 this, SLOT(
reset() ) );
278 connect(
pb_help, SIGNAL( clicked() ),
279 this, SLOT(
help() ) );
283 connect(
pb_close, SIGNAL( clicked() ),
284 this, SLOT( close() ) );
291 spec->addWidget( lb_info1, s_row++, 0, 1, 8 );
292 spec->addWidget( lb_resolu, s_row, 0, 1, 4 );
293 spec->addWidget(
ct_resolu, s_row++, 4, 1, 4 );
294 spec->addWidget( lb_xreso, s_row, 0, 1, 4 );
295 spec->addWidget(
ct_xreso, s_row++, 4, 1, 4 );
296 spec->addWidget( lb_yreso, s_row, 0, 1, 4 );
297 spec->addWidget(
ct_yreso, s_row++, 4, 1, 4 );
298 spec->addWidget( lb_zfloor, s_row, 0, 1, 4 );
299 spec->addWidget(
ct_zfloor, s_row++, 4, 1, 4 );
300 spec->addWidget(
ck_autosxy, s_row, 0, 1, 4 );
301 spec->addWidget(
ck_autoscz, s_row++, 4, 1, 4 );
302 spec->addWidget(
ck_conloop, s_row, 0, 1, 4 );
303 spec->addWidget(
ck_zpcent, s_row++, 4, 1, 4 );
304 spec->addWidget(
ck_savepl, s_row, 0, 1, 4 );
305 spec->addWidget(
ck_locsave, s_row++, 4, 1, 4 );
314 spec->addWidget( lb_plt_dlay, s_row, 0, 1, 4 );
316 spec->addWidget( lb_curr_distr, s_row, 0, 1, 4 );
318 spec->addWidget(
te_distr_info, s_row, 0, 2, 8 ); s_row += 2;
320 spec->addWidget( lb_x_axis, s_row, 0, 1, 2 );
321 spec->addLayout( gl_x_s, s_row, 2, 1, 1 );
322 spec->addLayout( gl_x_ff0, s_row, 3, 1, 1 );
323 spec->addLayout( gl_x_mw, s_row, 4, 1, 1 );
324 spec->addLayout( gl_x_vbar, s_row, 5, 1, 1 );
325 spec->addLayout( gl_x_D, s_row, 6, 1, 1 );
326 spec->addLayout( gl_x_f, s_row++, 7, 1, 1 );
327 spec->addWidget( lb_y_axis, s_row, 0, 1, 2 );
328 spec->addLayout( gl_y_s, s_row, 2, 1, 1 );
329 spec->addLayout( gl_y_ff0, s_row, 3, 1, 1 );
330 spec->addLayout( gl_y_mw, s_row, 4, 1, 1 );
331 spec->addLayout( gl_y_vbar, s_row, 5, 1, 1 );
332 spec->addLayout( gl_y_D, s_row, 6, 1, 1 );
333 spec->addLayout( gl_y_f, s_row++, 7, 1, 1 );
334 spec->addWidget(
pb_pltall, s_row, 0, 1, 4 );
335 spec->addWidget(
pb_stopplt, s_row++, 4, 1, 4 );
336 spec->addWidget(
pb_refresh, s_row, 0, 1, 4 );
337 spec->addWidget(
pb_reset, s_row++, 4, 1, 4 );
339 spec->addWidget(
le_prefilt, s_row++, 0, 1, 8 );
340 spec->addWidget(
pb_prefilt, s_row, 0, 1, 4 );
341 spec->addWidget(
pb_ldcolor, s_row++, 4, 1, 4 );
342 spec->addWidget(
pb_lddistr, s_row, 0, 1, 4 );
343 spec->addWidget(
pb_rmvdist, s_row++, 4, 1, 4 );
344 spec->addWidget(
pb_help, s_row, 0, 1, 4 );
345 spec->addWidget(
pb_close, s_row++, 4, 1, 4 );
355 data_plot->enableAxis( QwtPlot::xBottom,
true );
356 data_plot->enableAxis( QwtPlot::yLeft,
true );
357 data_plot->enableAxis( QwtPlot::yRight,
true );
358 data_plot->setAxisScale( QwtPlot::xBottom, 1.0, 40.0 );
359 data_plot->setAxisScale( QwtPlot::yLeft, 1.0, 4.0 );
360 data_plot->setAxisScale( QwtPlot::yRight, 0.0, 0.2 );
361 data_plot->setCanvasBackground( Qt::white );
362 QwtText zTitle(
"Partial Concentration" );
365 data_plot->setAxisTitle( QwtPlot::yRight, zTitle );
368 pick->setRubberBand( QwtPicker::RectRubberBand );
371 left->addLayout( spec );
374 main->addLayout( left );
375 main->addLayout( plot );
376 main->setStretchFactor( left, 3 );
377 main->setStretchFactor( plot, 5 );
392 data_plot->detachItems( QwtPlotItem::Rtti_PlotSpectrogram );
405 ct_xreso->setRange( 10.0, 1000.0, 1.0 );
447 colormap =
new QwtLinearColorMap( Qt::white, Qt::black );
448 colormap->addColorStop( 0.10, Qt::cyan );
449 colormap->addColorStop( 0.50, Qt::magenta );
450 colormap->addColorStop( 0.80, Qt::red );
451 cmapname = tr(
"Default Color Map: w-cyan-magenta-red-black" );
459 le_prefilt->setText( tr(
"(no prefilter)" ) );
465 int syssiz =
system.size();
470 if ( curr_distr < 0 || curr_distr >= syssiz )
473 <<
" ( sys.size()=" << syssiz <<
" )";
482 QList< S_Solute >* sol_d = &tsys->
sk_distro;
488 data_plot->setAxisTitle( QwtPlot::yRight,
489 tr(
"Percent of Total Concentration" ) );
495 data_plot->setAxisTitle( QwtPlot::yRight,
496 tr(
"Partial Concentration" ) );
506 data_plot->detachItems( QwtPlotItem::Rtti_PlotSpectrogram );
509 int csum = bg.red() + bg.green() + bg.blue();
510 pick->setTrackerPen( QPen( csum > 600 ? QColor( Qt::black ) :
511 QColor( Qt::white ) ) );
514 QwtPlotSpectrogram *d_spectrogram =
new QwtPlotSpectrogram();
516 d_spectrogram->setColorMap( *
colormap );
520 drect = QwtDoubleRect( 0.0, 0.0, 0.0, 0.0 );
533 for (
int jj = 0; jj < sol_d->size(); jj++ )
535 double zval = sol_d->at( jj ).c;
542 for (
int ii = 0; ii <
system.size(); ii++ )
548 for (
int jj = 0; jj < sol_z->size(); jj++ )
550 double zval = sol_z->at( jj ).c;
566 QwtScaleWidget *rightAxis =
data_plot->axisWidget( QwtPlot::yRight );
567 rightAxis->setColorBarEnabled(
true );
576 data_plot->setAxisAutoScale( QwtPlot::yLeft );
577 data_plot->setAxisAutoScale( QwtPlot::xBottom );
581 double lStep =
data_plot->axisStepSize( QwtPlot::yLeft );
582 double bStep =
data_plot->axisStepSize( QwtPlot::xBottom );
588 d_spectrogram->colorMap() );
594 QString dtext = tr(
"Run: " ) + tsys->
run_name
599 DbgLv(2) <<
"(1) sv_plot" << sv_plot <<
"looping" <<
looping;
605 const QString s_attrs[] = {
"s",
"ff0",
"MW",
"vbar",
"D",
"f" };
609 QString runid = tsys->
run_name.section(
".", 0, -2 );
610 QString triple = tsys->
run_name.section(
".", -1, -1 );
611 QString report = QString(
"pseudo3d_" ) + s_attrs[
plot_x ]
612 +
"_" + s_attrs[
plot_y ];
616 if ( !dirof.exists( ) )
618 QString ofname = tsys->
method +
"." + triple +
"." + report +
".png";
619 QString ofpath = ofdir +
"/" + ofname;
622 plotmap.save( ofpath );
623 dtext = dtext + tr(
"\nPLOT %1 SAVED to local" )
628 QDateTime time0=QDateTime::currentDateTime();
632 query <<
"get_editID" << tsys->
editGUID;
635 int idEdit = db.value( 0 ).toString().toInt();
637 freport.
runID = runid;
639 QDateTime time1=QDateTime::currentDateTime();
641 <<
"svtime:" << time0.msecsTo(time1);
642 dtext = dtext + tr(
" and DB" );
647 dtext = dtext + tr(
"\n(no plot saved)" );
745 QString dtext = tr(
"Run: " ) + tsys->
run_name
750 pb_pltall->setText( tr(
"Plot All Distros in a Loop" ) );
752 tr(
"\nWith continuous loop, plot files are not saved." );
755 pb_pltall->setText( tr(
"Plot All Distros" ) );
767 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
769 dialog.move( this->pos() + QPoint( 200, 200 ) );
771 connect( &dialog, SIGNAL( changed(
bool ) ),
773 QApplication::restoreOverrideCursor();
775 if ( dialog.exec() != QDialog::Accepted )
780 for (
int jj = 0; jj < models.count(); jj++ )
802 QString mdesc = mdescr.section( mdescr.left( 1 ), 1, 1 );
808 tsys.
run_name = mdesc.section(
".", 0, -3 );
809 QString asys = mdesc.section(
".", -2, -2 );
810 tsys.
analys_name = asys.section(
"_", 0, -4 ) +
"_"
811 + asys.section(
"_", -2, -1 );
813 tsys.
method = ( mdesc.contains(
"-CG" ) )
814 ? tsys.
method.replace(
"2DSA",
"2DSA-CG" )
819 DbgLv(1) <<
"LD: method" << tsys.
method <<
"mdesc" << mdesc;
821 if ( tsys.
method ==
"Manual" || tsys.
method ==
"CUSTOMGRID" )
823 int jj = mdesc.indexOf(
".model" );
824 mdesc = ( jj < 1 ) ? mdesc : mdesc.left( jj );
836 QString miter = mdescr.section( mdescr.left( 1 ), 6 );
837 int kiter = miter.isEmpty() ? 0 : miter.toInt();
857 double tot_conc = 0.0;
859 for (
int jj = 0; jj < nsolmc; jj++ )
863 sol_sk.
c = model.
components[ jj ].signal_concentration;
888 tot_conc += sol_sk.
c;
897 DbgLv(1) <<
"LD: nsolsk nsolxy nsolmc" << nsolsk << nsolxy << nsolmc;
903 for (
int jj = 0; jj < nsolmc; jj++ )
910 cozpc = sol_sk.
c * 100.0 / tot_conc;
920 cozpc = sol_xy.
c * 100.0 / tot_conc;
940 DbgLv(1) <<
"LD: auto_sxy call set_limits";
942 DbgLv(1) <<
"LD: auto_sxy rtn fr set_limits";
954 DbgLv(1) <<
"LD: non-auto_sxy call set_limits";
956 DbgLv(1) <<
"LD: non-auto_sxy rtn fr set_limits";
966 pb_pltall->setText( tr(
"Plot All Distros in a Loop" ) );
968 pb_pltall->setText( tr(
"Plot All Distros" ) );
969 DbgLv(1) <<
"LD: RETURN";
974 QString filter = tr(
"Color Map files (*cm-*.xml);;" )
975 + tr(
"Any XML files (*.xml);;" )
976 + tr(
"Any files (*)" );
979 QString fname = QFileDialog::getOpenFileName(
this,
980 tr(
"Load Color Map File" ),
983 if ( fname.isEmpty() )
987 QList< QColor > cmcolor;
988 QList< double > cmvalue;
991 colormap =
new QwtLinearColorMap( cmcolor.first(), cmcolor.last() );
993 for (
int jj = 1; jj < cmvalue.size() - 1; jj++ )
995 colormap->addColorStop( cmvalue.at( jj ), cmcolor.at( jj ) );
997 QFileInfo fi( fname );
998 cmapname = tr(
"Color Map: " ) + fi.baseName();
1038 double smin = 1.0e30;
1039 double smax = -1.0e30;
1040 double kmin = 1.0e30;
1041 double kmax = -1.0e30;
1054 for (
int ii = 0; ii <
system.size(); ii++ )
1058 for (
int jj = 0; jj < tsys->
xy_distro.size(); jj++ )
1060 double sval = tsys->
xy_distro.at( jj ).s;
1061 double kval = tsys->
xy_distro.at( jj ).k;
1062 smin = qMin( smin, sval );
1063 smax = qMax( smax, sval );
1064 kmin = qMin( kmin, kval );
1065 kmax = qMax( kmax, kval );
1070 sinc = ( smax - smin ) / 10.0;
1071 kinc = ( kmax - kmin ) / 10.0;
1072 sinc = ( sinc <= 0.0 ) ? ( smin * 0.05 ) : sinc;
1073 kinc = ( kinc <= 0.0 ) ? ( kmin * 0.05 ) : kinc;
1074 DbgLv(1) <<
"SL: real smin smax kmin kmax" << smin << smax << kmin << kmax;
1079 DbgLv(1) <<
"SL: adjusted smin smax kmin kmax" << smin << smax << kmin << kmax;
1083 sinc = pow( 10.0, qFloor( log10( smax ) ) - 3.0 );
1084 kinc = pow( 10.0, qFloor( log10( kmax ) ) - 3.0 );
1085 if ( qAbs( ( smax - smin ) / smax ) < 0.001 )
1090 if ( qAbs( ( kmax - kmin ) / kmax ) < 0.001 )
1096 smin = qFloor( smin / sinc ) * sinc;
1097 smax = qFloor( smax / sinc ) * sinc + sinc;
1098 smin = (
plot_x !=
ATTR_S ) ? qMax( smin, 0.0 ) : smin;
1099 smin = (
plot_x ==
ATTR_K ) ? qMax( smin, 0.5 ) : smin;
1100 kmin = qFloor( kmin / kinc ) * kinc;
1101 kmax = qFloor( kmax / kinc ) * kinc + kinc;
1103 DbgLv(1) <<
"SL: setVal kmin kmax" << kmin << kmax;
1129 int sizi = listsols.size();
1144 QList< S_Solute > reduced;
1145 QList< S_Solute >::iterator jj = listsols.begin();
1147 reduced.append( *jj );
1151 while ( (++jj) != listsols.end() )
1155 if ( sol1.
s != sol2.
s || sol1.
k != sol2.
k )
1157 reduced.append( sol2 );
1164 sol2.
s = ( sol1.
s + sol2.
s ) * 0.5;
1165 sol2.
k = ( sol1.
k + sol2.
k ) * 0.5;
1166 reduced.replace( reduced.size() - 1, sol2 );
1167 kdup =
max( kdup, ++jdup );
1175 double sc = 1.0 / (double)( kdup + 1 );
1176 DbgLv(1) <<
"KDUP" << kdup;
1179 for (
int ii = 0; ii < reduced.size(); ii++ )
1181 reduced[ ii ].c *= sc;
1185 DbgLv(1) <<
" reduced-size" << reduced.size();
1188 DbgLv(1) <<
" sol-size" << listsols.size();
1194 int tm_id =
event->timerId();
1198 QWidget::timerEvent( event );
1202 int syssiz =
system.size();
1203 int maxsiz = syssiz - 1;
1208 if ( jdistr > maxsiz )
1251 srdiag.move( this->pos() + QPoint( 200, 200 ) );
1252 connect( &srdiag, SIGNAL( dkdb_changed (
bool ) ),
1255 if ( srdiag.exec() == QDialog::Accepted )
1261 pfmsg = tr(
"(no prefilter)" );
1263 else if ( nruns > 1 )
1264 pfmsg = tr(
"RunID prefilter - %1 runs: " ).arg( nruns )
1265 + QString(
pfilts[ 0 ] ).left( 20 ) +
"*, ...";
1268 pfmsg = tr(
"RunID prefilter - 1 run: " )
1269 + QString(
pfilts[ 0 ] ).left( 20 ) +
" ...";
1278 qDebug() <<
"Remove Distros";
1281 if ( rmvd.exec() == QDialog::Accepted )
1303 const QString xlabs[] = {
"s",
"f/f0",
"MW",
"vbar",
"D",
"f" };
1304 const double xvlos[] = { 1.0, 1.0, 2e+4, 0.60, 1e-8, 1e-8 };
1305 const double xvhis[] = { 10.0, 4.0, 1e+5, 0.80, 1e-7, 1e-7 };
1306 const double xmins[] = { -10000.0, 1.0, 0.0, 0.01, 1e-9, 1e-9 };
1307 const double xmaxs[] = { 10000.0, 50.0, 1e+10, 3.00, 1e-5, 1e-5 };
1308 const double xincs[] = { 0.01, 0.01, 1000.0, 0.01, 1e-9, 1e-9 };
1313 + tr(
" Minimum:" ) );
1315 + tr(
" Maximum:" ) );
1317 ct_plt_smax->setRange( xmins[ plot_x ], xmaxs[ plot_x ], xincs[ plot_x ] );
1338 const QString ylabs[] = {
"s",
"f/f0",
"MW",
"vbar",
"D",
"f" };
1339 const double yvlos[] = { 1.0, 1.0, 2e+4, 0.60, 1e-8, 1e-8 };
1340 const double yvhis[] = { 10.0, 4.0, 1e+5, 0.80, 1e-7, 1e-7 };
1341 const double ymins[] = { -10000.0, 1.0, 0.0, 0.01, 1e-9, 1e-9 };
1342 const double ymaxs[] = { 10000.0, 50.0, 1e+10, 3.00, 1e-5, 1e-5 };
1343 const double yincs[] = { 0.01, 0.01, 1000.0, 0.01, 1e-9, 1e-9 };
1346 qDebug() <<
"select-y: plot_y" <<
plot_y;
1349 + tr(
" Minimum:" ) );
1351 + tr(
" Maximum:" ) );
1352 qDebug() <<
" ylab" << ylabs[
plot_y];
1357 qDebug() <<
" yval-lo val-hi" << yvlos[
plot_y] << yvhis[
plot_y];
1385 double tot_conc = 0.0;
1389 for (
int ii = 0; ii < nsolsk; ii++ )
1406 tot_conc += sol_sk.
c;
1415 DbgLv(1) <<
"Bld: nsolsk nsolxy" << nsolsk << nsolxy;
1418 for (
int ii = 0; ii < nsolxy; ii++ )
1421 double cozpc = sol_xy.
c * 100.0 / tot_conc;
1436 a_title = tr(
"Sedimentation Coefficient (1e-13)"
1437 " for water at 20" ) +
DEGC;
1438 else if ( pltndx ==
ATTR_K )
1439 a_title = tr(
"Frictional Ratio f/f0" );
1440 else if ( pltndx ==
ATTR_W )
1441 a_title = tr(
"Molecular Weight (Dalton)" );
1442 else if ( pltndx ==
ATTR_V )
1443 a_title = tr(
"Vbar at 20" ) +
DEGC;
1444 else if ( pltndx ==
ATTR_D )
1445 a_title = tr(
"Diffusion Coefficient" );
1446 else if ( pltndx ==
ATTR_F )
1447 a_title = tr(
"Frictional Coefficient" );