11 #include <qwt_legend.h>
12 #include <qwt_double_interval.h>
13 #include <qwt_scale_widget.h>
14 #include <qwt_color_map.h>
15 #include <qwt_scale_draw.h>
19 double& xhi,
int& typ,
int& nkp,
int& nlp,
int& bmx )
21 xmax( xhi ), ctype( typ ), nkpts( nkp ), nlpts( nlp ), bmndx( bmx )
24 setObjectName(
"US_MLinesPlot" );
25 setAttribute( Qt::WA_DeleteOnClose,
true );
26 setWindowTitle( tr(
"Parametrically Constrained Spectrum Analysis "
27 "Model Lines Viewer" ) );
30 QSize p1size( 560, 480 );
48 QLabel* lb_datctrls =
us_banner( tr(
"PCSA Model Parameters" ) );
49 QLabel* lb_mtype =
us_label( tr(
"Model Type:" ) );
50 QLabel* lb_nlines =
us_label( tr(
"Lines (Models):" ) );
51 QLabel* lb_npoints =
us_label( tr(
"Max Points per Line:" ) );
52 QLabel* lb_varcount =
us_label( tr(
"Variation Count:" ) );
97 QFontMetrics fmet( font );
98 int fwidth = fmet.maxWidth();
100 int cminw = fwidth * ( nmodel < 1000 ? 6 : 7 );
101 int csizw = cminw + fwidth;
110 le_rmsde ->resize( tsizw, rheight );
111 le_rmsds ->resize( tsizw, rheight );
112 le_rmsdv ->resize( tsizw, rheight );
113 le_rmsde ->setMinimumWidth( tminw );
114 le_rmsds ->setMinimumWidth( tminw );
115 le_rmsdv ->setMinimumWidth( tminw );
116 DbgLv(1) <<
"RP: csizw cminw tsizw" << csizw << cminw << tsizw;
148 QString s_type = tr(
"Unknown" );
150 else if (
ctype ==
CTYPE_IS ) s_type = tr(
"Increasing Sigmoid" );
151 else if (
ctype ==
CTYPE_DS ) s_type = tr(
"Decreasing Sigmoid" );
152 else if (
ctype ==
CTYPE_HL ) s_type = tr(
"Horizontal Line [C(s)]" );
153 else if (
ctype ==
CTYPE_ALL ) s_type = tr(
"All (SL + IS + DS)" );
154 else if (
ctype ==
CTYPE_2O ) s_type = tr(
"Second-Order Power Law" );
166 tr(
"Sedimentation Coefficient (x 1e13)" ),
167 tr(
"Frictional Ratio (f/f0)" ) );
183 connect(
ct_neline, SIGNAL( valueChanged (
double ) ),
185 connect(
ct_nsline, SIGNAL( valueChanged (
double ) ),
187 connect(
ct_nvline, SIGNAL( valueChanged (
double ) ),
191 connect( pb_help, SIGNAL( clicked() ),
192 this, SLOT (
help() ) );
193 connect( pb_close, SIGNAL( clicked() ),
196 DbgLv(1) <<
"RP: p1size" << p1size;
201 setAttribute( Qt::WA_DeleteOnClose,
true );
219 DbgLv(1) <<
"RP:PD got_best" << got_best <<
"bmndx" <<
bmndx;
222 DbgLv(1) <<
"RP:PD us_grid RTN";
228 QVector< double > xvec(
nlpts, 0.0 );
229 QVector< double > yvec(
nlpts, 0.0 );
231 double* xx = xvec.data();
232 double* yy = yvec.data();
233 int nmodl =
mrecs.size();
235 int stype =
mrecs[ 0 ].stype;
236 int attr_x = ( stype >> 6 ) & 7;
237 int attr_y = ( stype >> 3 ) & 7;
238 int attr_z = stype & 7;
241 DbgLv(1) <<
"RP:PD stype" << stype <<
"attr_x attr_y attr_z"
242 << attr_x << attr_y << attr_z;
243 QString xtitl = tr(
"Sedimentation Coefficient (x 1e13)" );
244 QString ytitl = tr(
"Frictional Ratio (f/f0)" );
246 ? tr(
"Sedimentation Coefficient (x 1e13)" ) : xtitl;
248 ? tr(
"Frictional Ratio (f/f0)" ) : xtitl;
250 ? tr(
"Molecular Weight (Dalton)" ) : xtitl;
252 ? tr(
"Specific Density (vbar_20W)" ) : xtitl;
254 ? tr(
"Diffusion Coefficient" ) : xtitl;
256 ? tr(
"Sedimentation Coefficient (x 1e13)" ) : ytitl;
258 ? tr(
"Frictional Ratio (f/f0)" ) : ytitl;
260 ? tr(
"Molecular Weight (Dalton)" ) : ytitl;
262 ? tr(
"Specific Density (vbar_20W)" ) : ytitl;
264 ? tr(
"Diffusion Coefficient" ) : ytitl;
278 data_plot1->setAxisAutoScale( QwtPlot::xBottom );
292 data_plot1->setAxisAutoScale( QwtPlot::yLeft );
295 data_plot1->setAxisTitle( QwtPlot::xBottom, xtitl );
296 data_plot1->setAxisTitle( QwtPlot::yLeft, ytitl );
297 DbgLv(1) <<
"RP:PD got_best" << got_best;
298 DbgLv(1) <<
"RP:PD nmodel mrecs_size" <<
nmodel << nmodl;
302 DbgLv(1) <<
"RP:PD mrecs size" <<
mrecs.size() << nmodl;
314 QFont afont =
data_plot1->axisTitle( QwtPlot::yLeft ).font();
316 QwtScaleWidget* rightAxis =
data_plot1->axisWidget( QwtPlot::yRight );
320 rightAxis->setColorBarEnabled(
true );
321 rightAxis->setColorMap ( cdrange, revcmap );
322 data_plot1->enableAxis ( QwtPlot::yRight,
true );
323 data_plot1->axisTitle ( QwtPlot::yRight ).setFont( afont );
324 data_plot1->setAxisTitle( QwtPlot::yRight, tr(
"RMSD" ) );
327 QColor c_white ( Qt::white );
328 QColor c_yellow( Qt::yellow );
329 QColor c_cyan ( Qt::cyan );
330 QPen pen_best(
colormap->color2(), 3 );
331 QPen pen_gray( QColor( 64, 64, 64 ), 1 );
333 double elrange = (double)eloffs;
341 double max_conc = 0.0;
342 for (
int ii = 0; ii <
nsline; ii++ )
344 for (
int kk = 0; kk <
mrecs[ ii ].csolutes.size(); kk++ )
346 max_conc = qMax( max_conc,
mrecs[ ii ].csolutes[ kk ].c );
353 for (
int ii = (
nmodel - 1 ); ii >= 0; ii-- )
364 title = tr(
"Best Curve " ) + QString::number( ii );
366 curv->setPen ( pen_best );
369 else if ( ii < neline && ii > blnx )
371 title = tr(
"Elite Curve " ) + QString::number( ii );
373 double position = (double)( eloffs - ii ) / elrange;
377 else if ( ii > blnx )
379 title = tr(
"Curve " ) + QString::number( ii );
381 curv->setPen( pen_gray );
389 int klpts =
mrecs[ ii ].isolutes.size();
396 yy[ 0 ] =
mrecs[ ii ].str_y;
397 yy[ 1 ] =
mrecs[ ii ].end_y;
404 for (
int kk = 0; kk < klpts; kk++ )
406 xx[ kk ] =
mrecs[ ii ].isolutes[ kk ].x * xpscl;
407 yy[ kk ] =
mrecs[ ii ].isolutes[ kk ].y * ypscl;
413 curv->setData ( xx, yy, klpts );
417 int ncomp =
mrecs[ ii ].csolutes.size();
418 QColor c_symb = c_white;
420 if ( ii == 1 &&
mrecs[ 1 ].taskx ==
mrecs[ 0 ].taskx )
425 if ( ii == 2 &&
mrecs[ 2 ].taskx ==
mrecs[ 0 ].taskx )
431 for (
int kk = 0; kk < ncomp; kk++ )
433 double xv =
mrecs[ ii ].csolutes[ kk ].x * xpscl;
434 double yv =
mrecs[ ii ].csolutes[ kk ].y * ypscl;
435 double cv =
mrecs[ ii ].csolutes[ kk ].c;
436 double cfra = cv / max_conc;
437 int szd = qMax( szdmin, qRound( 9.0 * cfra ) );
438 title = tr(
"Solute Curve " ) + QString::number( ii )
439 +
" Point " + QString::number( kk );
442 symbol.setPen ( c_symb );
443 symbol.setSize ( szd );
444 symbol.setStyle( QwtSymbol::Ellipse );
445 symbol.setBrush( c_symb );
447 curv->setStyle ( QwtPlotCurve::NoCurve );
448 curv->setSymbol( symbol );
449 curv->setData ( &xv, &yv, 1 );
451 DbgLv(1) <<
"RP:PD ncomp" << ncomp <<
"x0 y0 xn yn"
452 << xx[0] << yy[0] << xx[ncomp-1] << yy[ncomp-1];
460 for (
int ii = 0; ii < nmodl; ii++ )
462 for (
int kk = 0; kk <
nlpts; kk++ )
464 xx[ kk ] =
mrecs[ ii ].isolutes[ kk ].x * xpscl;
465 yy[ kk ] =
mrecs[ ii ].isolutes[ kk ].y * ypscl;
468 title = tr(
"Curve " ) + QString::number( ii );
470 curv->setPen ( pen_plot );
471 curv->setData ( xx, yy, nlpts );
480 QVector< US_ModelRecord >& mrs )
532 cmapname = tr(
"Default (rainbow)" );
535 colormap =
new QwtLinearColorMap( Qt::magenta, Qt::red );
536 colormap->addColorStop( 0.2000, Qt::blue );
537 colormap->addColorStop( 0.4000, Qt::cyan );
538 colormap->addColorStop( 0.6000, Qt::green );
539 colormap->addColorStop( 0.8000, Qt::yellow );
540 DbgLv(1) <<
"dCM: RTN cmCstopSize" <<
colormap->colorStops().size();
541 for (
double pos=0.0; pos<=1.0; pos+=0.1 ) {
549 QwtDoubleInterval colorinterv( 0.0, 1.0 );
550 return QColor(
colormap->rgb( colorinterv, pos ) );
558 QwtDoubleInterval cinterv( 0.0, 1.0 );
559 QVector< double > cstops =
colormap->colorStops();
560 int kstops = cstops.size() - 1;
562 for (
int ii = kstops; ii >= 0; ii-- )
564 double csvalue = cstops[ ii ];
565 QColor mcolor(
colormap->rgb( cinterv, csvalue ) );
566 DbgLv(1) <<
"rCM: pos" << csvalue <<
"color" << mcolor;
567 rcolmap.addColorStop( 1.0 - csvalue, mcolor );
569 DbgLv(1) <<
"rCM: color1" << rcolmap.color1() <<
"color2" << rcolmap.color2();
571 for (
double pos=0.0; pos<=1.0; pos+=0.2 ) {
573 <<
"RevColor" << QColor(rcolmap.rgb(cinterv,pos)); }
603 QString filter = tr(
"Color Map files (*cm-*.xml);;"
604 "Any XML files (*.xml);;"
608 QString fname = QFileDialog::getOpenFileName(
this,
609 tr(
"Load Color Map File" ),
612 if ( fname.isEmpty() )
616 QList< QColor > cmcolors;
617 QList< double > cmvalues;
620 colormap =
new QwtLinearColorMap( cmcolors.first(), cmcolors.last() );
622 for (
int jj = 1; jj < cmvalues.size() - 1; jj++ )
624 colormap->addColorStop( cmvalues.at( jj ), cmcolors.at( jj ) );
627 cmapname = QFileInfo( fname ).baseName().replace(
".xml$",
"" );
630 for (
double pos=0.0; pos<=1.0; pos+=0.1 ) {