7 #include "qwt_legend.h"
11 QVector< US_Model >& aimodels,
12 QMap< QString, QString >& adv_vals, QWidget*
p ) :
20 setObjectName(
"US_AdvDmgaMC" );
25 setWindowTitle( tr(
"DMGA-MC Advanced Controls" ) );
30 tr(
"Attribute Distribution" ),
31 tr(
"Attribute Name" ),
34 data_plot->setCanvasBackground( Qt::black );
39 QLabel* lb_modelsim =
us_banner( tr(
"Simulate data using parameters from " "Monte Carlo statistics or from "
40 "current iteration model" ) );
42 QButtonGroup* um_group =
new QButtonGroup(
this );
47 um_group->addButton(
rb_mean, 0 );
49 um_group->addButton(
rb_mode, 2 );
57 mtpal.setColor( QPalette::Text, Qt::blue );
61 QPushButton* pb_nextparm =
us_pushbutton( tr(
"Next Parameter >" ) );
62 QPushButton* pb_prevparm =
us_pushbutton( tr(
"< Previous Parameter" ) );
65 ls_params << tr(
"Component 1 Sedimentation Coefficient" );
66 ls_params << tr(
"Component 1 Diffusion Coefficient" );
67 ls_params << tr(
"Component 1 Molecular Weight" );
68 ls_params << tr(
"Component 1 Frictional Ratio" );
69 ls_params << tr(
"Component 1 Vbar (20_W)" );
70 ls_params << tr(
"Component 1 Partial Concentration" );
71 ls_params << tr(
"Reaction 1 k_Dissociation:" );
72 ls_params << tr(
"Reaction 1 k_off Rate:" );
77 QLabel* lb_ms_mean =
us_label( tr(
"Mean" ) );
78 QLabel* lb_ms_95lo =
us_label( tr(
"95% Conf.Low" ) );
79 QLabel* lb_ms_95hi =
us_label( tr(
"95% Conf.High" ) );
80 QLabel* lb_ms_medi =
us_label( tr(
"Median" ) );
81 QLabel* lb_ms_mode =
us_label( tr(
"Mode" ) );
103 paramLayout->addWidget( lb_modelsim, row++, 0, 1, 12 );
111 paramLayout->addWidget( pb_prevparm, row, 0, 1, 3 );
112 paramLayout->addWidget( pb_nextparm, row, 3, 1, 3 );
115 paramLayout->addWidget( pb_simulate, row, 4, 1, 4 );
116 paramLayout->addWidget( pb_close, row++, 8, 1, 4 );
129 connect(
ct_modelnbr, SIGNAL( valueChanged (
double ) ),
131 connect(
rb_mean, SIGNAL( toggled (
bool ) ),
133 connect(
rb_median, SIGNAL( toggled (
bool ) ),
135 connect(
rb_mode, SIGNAL( toggled (
bool ) ),
137 connect(
rb_curmod, SIGNAL( toggled (
bool ) ),
139 connect( pb_prevparm, SIGNAL( clicked () ),
141 connect( pb_nextparm, SIGNAL( clicked () ),
143 connect(
cb_params, SIGNAL( activated (
int ) ),
146 connect( pb_help, SIGNAL( clicked() ),
147 this, SLOT (
help() ) );
148 connect( pb_simulate, SIGNAL( clicked() ),
150 connect( pb_close, SIGNAL( clicked() ),
151 this, SLOT (
done() ) );
156 int fwid = fmet.maxWidth();
157 int rhgt = lb_modelsim->height();
158 int csizw = fwid * 2;
168 le_modtype ->setText( tr(
"Mean model, %1 components, %2 reaction(s)" )
169 .arg( ncomp ).arg( nreac ) );
173 for (
int ii = 0; ii <
ncomp; ii++ )
175 QString comp = tr(
"Component %1 " ).arg( ii + 1 );
176 ls_params << comp + tr(
"Sedimentation Coefficient" );
177 ls_params << comp + tr(
"Diffusion Coefficient" );
178 ls_params << comp + tr(
"Molecular Weight" );
179 ls_params << comp + tr(
"Frictional Ratio" );
181 ls_params << comp + tr(
"Partial Concentration" );
184 for (
int ii = 0; ii < nreac; ii++ )
186 QString reac = tr(
"Reaction %1 " ).arg( ii + 1 );
187 ls_params << reac + tr(
"k_Dissociation:" );
196 qDebug() <<
"AdvD:Pre-adjust size" << size();
198 qDebug() <<
"AdvD:Post-adjust size" << size();
200 qDebug() <<
"AdvD:Post-resize size" << size();
204 qApp->processEvents();
213 (
rb_mode ->isChecked() ?
"mode" :
214 (
rb_curmod->isChecked() ?
"model" :
"" ) ) );
227 imodl = ( imodl < nmodl ) ? ( imodl + 1 ) : 1;
234 int mx = (int)mnbr - 1;
243 if ( ! chekd )
return;
246 bool ck_mean =
rb_mean ->isChecked();
248 bool ck_mode =
rb_mode ->isChecked();
251 QString smtype = ck_mean ? tr(
"mean" ) :
"";
252 smtype = ck_medi ? tr(
"median" ) : smtype;
253 smtype = ck_mode ? tr(
"mode" ) : smtype;
254 smtype = ck_cmod ? tr(
"model" ) : smtype;
262 QString mtlabl = ck_mean ? tr(
"Mean" ) :
"";
263 mtlabl = ck_medi ? tr(
"Median" ) : mtlabl;
264 mtlabl = ck_mode ? tr(
"Mode" ) : mtlabl;
265 mtlabl = ck_cmod ? tr(
"Iteration %1" ).arg( iter ) : mtlabl;
266 le_modtype ->setText( mtlabl + tr(
" model, %1 components, %2 reaction(s)" )
267 .arg( ncomp ).arg( nreac ) );
278 const QString ytitle = tr(
"Frequency" );
279 const double pad_lo = 0.95;
280 const double pad_hi = 1.05;
281 QVector< double > xvec_in;
282 QVector< double > xvec_pl;
283 QVector< double > yvec_pl;
287 QString attrib =
cb_params->currentText();
288 int jc = attrib.section(
" ", 1, 1 ).toInt() - 1;
290 jc = attrib.contains( tr(
"Component" ) ) ? jc : -1;
291 jr = attrib.contains( tr(
"Reaction" ) ) ? jr : -1;
292 QString xtitle = attrib.section(
" ", 2, -1 ).simplified();
297 for (
int ii = 0; ii < nxi; ii++ )
305 sc = &
imodels[ ii ].components[ jc ];
307 xval = xtitle.contains( tr(
"Diffusion" ) ) ? sc->
D : xval;
308 xval = xtitle.contains( tr(
"Molecular" ) ) ? sc->
mw : xval;
309 xval = xtitle.contains( tr(
"Frictional" ) ) ? sc->
f_f0 : xval;
310 xval = xtitle.contains( tr(
"Vbar" ) ) ? sc->
vbar20 : xval;
311 xval = xtitle.contains( tr(
"Concentration" ) )
317 as = &
imodels[ ii ].associations[ jr ];
319 xval = xtitle.contains( tr(
"Rate" ) ) ? as->
k_off : xval;
330 double* xvi = xvec_in.data();
335 double xprev = xvi[ 0 ];
339 for (
int ii = 1; ii < nxi; ii++ )
341 double xval = xvi[ ii ];
346 xkmax = qMax( xkmax, xknt );
362 double* xvp = xvec_pl.data();
363 double* yvp = yvec_pl.data();
364 int nxyp = xvec_pl.size();
365 double ymax = xkmax * pad_hi;
370 xvec_pl.resize( nxyp );
371 yvec_pl.resize( nxyp );
375 xvec_pl[ 1 ] = xvec_pl[ 0 ];
376 yvec_pl[ 1 ] = yvec_pl[ 0 ];
377 xvec_pl[ 0 ] = xvec_pl[ 1 ] * pad_lo;
379 xvec_pl[ 2 ] = xvec_pl[ 1 ] * pad_hi;
385 xvec_pl[ 2 ] = xvec_pl[ 1 ];
386 yvec_pl[ 2 ] = yvec_pl[ 1 ];
387 xvec_pl[ 1 ] = xvec_pl[ 0 ];
388 yvec_pl[ 1 ] = yvec_pl[ 0 ];
389 xvec_pl[ 0 ] = xvec_pl[ 1 ] * pad_lo;
391 xvec_pl[ 3 ] = xvec_pl[ 2 ] * pad_hi;
395 xvp = xvec_pl.data();
396 yvp = yvec_pl.data();
401 data_plot->setTitle ( tr(
"Distribution" ) );
402 data_plot->setAxisTitle ( QwtPlot::yLeft, ytitle );
403 data_plot->setAxisTitle ( QwtPlot::xBottom, xtitle );
404 data_plot->setAxisScale ( QwtPlot::yLeft, 0.0, ymax );
405 data_plot->setAxisAutoScale( QwtPlot::xBottom );
409 curve->setStyle( QwtPlotCurve::Sticks );
410 curve->setData ( xvp, yvp, nxyp );
413 QVector< QVector< double > > mstats;
418 if ( dx < ( ncomp * 6 ) )
420 int cx = ( dx / 6 ) * 6;
422 dx = ( ax == 0 ) ? ( cx + 3 ) : dx;
423 dx = ( ax == 1 ) ? ( cx + 4 ) : dx;
424 dx = ( ax == 2 ) ? ( cx + 2 ) : dx;
425 dx = ( ax == 3 ) ? ( cx + 5 ) : dx;
426 dx = ( ax == 4 ) ? ( cx + 1 ) : dx;
427 dx = ( ax == 5 ) ? ( cx ) : dx;
432 le_ms_mean->setText( QString::number( mstats[ dx ][ 2 ] ) );
433 le_ms_95lo->setText( QString::number( mstats[ dx ][ 9 ] ) );
434 le_ms_95hi->setText( QString::number( mstats[ dx ][ 10 ] ) );
435 le_ms_medi->setText( QString::number( mstats[ dx ][ 3 ] ) );
436 le_ms_mode->setText( QString::number( mstats[ dx ][ 8 ] ) );
437 le_ms_iter->setText( QString::number( xvalcm ) );
440 QwtLegend* legend =
new QwtLegend;
443 xm[ 0 ] = mstats[ dx ][ 2 ];
444 xm[ 1 ] = mstats[ dx ][ 3 ];
445 xm[ 2 ] = mstats[ dx ][ 8 ];
447 ym[ 0 ] = xkmax * 1.015;
448 ym[ 1 ] = xkmax * 1.025;
449 ym[ 2 ] = xkmax * 1.035;
450 ym[ 3 ] = xkmax * 1.045;
451 const QString cl_mean = tr(
"Mean" );
452 const QString cl_medi = tr(
"Median" );
453 const QString cl_mode = tr(
"Mode" );
454 QString cl_iter = tr(
"Iteration %1" ).arg( iter );
456 const QColor co_bord ( Qt::blue );
457 const QColor co_mean ( Qt::cyan );
458 const QColor co_medi (
"orange" );
459 const QColor co_mode ( Qt::red );
460 const QColor co_iter (
"lime" );
461 legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
464 data_plot->insertLegend( legend, QwtPlot::BottomLegend );
465 curve->setItemAttribute( QwtPlotItem::Legend,
false );
474 sym_mean.setStyle( QwtSymbol::Ellipse );
475 sym_mean.setPen ( QPen ( co_bord ) );
476 sym_mean.setBrush( QBrush( co_mean ) );
477 sym_mean.setSize ( 6 );
478 curv_mean->setStyle( QwtPlotCurve::NoCurve );
479 curv_mean->setSymbol( sym_mean );
480 curv_mean->setItemAttribute( QwtPlotItem::Legend,
true );
481 sym_medi.setStyle( QwtSymbol::Rect );
482 sym_medi.setPen ( QPen ( co_bord ) );
483 sym_medi.setBrush( QBrush( co_medi ) );
484 sym_medi.setSize ( 6 );
485 curv_medi->setStyle( QwtPlotCurve::NoCurve );
486 curv_medi->setSymbol( sym_medi );
487 curv_medi->setItemAttribute( QwtPlotItem::Legend,
true );
488 sym_mode.setStyle( QwtSymbol::DTriangle );
489 sym_mode.setPen ( QPen ( co_bord ) );
490 sym_mode.setBrush( QBrush( co_mode ) );
491 sym_mode.setSize ( 8 );
492 curv_mode->setStyle( QwtPlotCurve::NoCurve );
493 curv_mode->setSymbol( sym_mode );
494 curv_mode->setItemAttribute( QwtPlotItem::Legend,
true );
495 sym_iter.setStyle( QwtSymbol::Cross );
496 sym_iter.setPen ( QPen ( co_iter ) );
497 sym_iter.setBrush( QBrush( co_iter ) );
498 sym_iter.setSize ( 8 );
499 curv_iter->setStyle( QwtPlotCurve::NoCurve );
500 curv_iter->setSymbol( sym_iter );
501 curv_iter->setItemAttribute( QwtPlotItem::Legend,
true );
502 curv_mean->setData ( xm , ym , 1 );
503 curv_medi->setData ( xm + 1, ym + 1, 1 );
504 curv_mode->setData ( xm + 2, ym + 2, 1 );
505 curv_iter->setData ( xm + 3, ym + 3, 1 );
517 disx = ( disx <
ls_params.size() ) ? disx : 0;
529 disx = ( disx < 0 ) ? (
ls_params.size() - 1 ) : disx;
541 (
rb_mode ->isChecked() ?
"mode" :
542 (
rb_curmod->isChecked() ?
"model" :
"" ) ) );
549 fem_wind->simulate();