3 #include <QApplication>
17 #include "qwt_legend.h"
20 int main(
int argc,
char* argv[] )
22 QApplication application( argc, argv );
30 return application.exec();
38 setWindowTitle( tr(
"Combined van Holde - Weischet Distributions:" ) );
44 QBoxLayout* mainLayout =
new QHBoxLayout(
this );
45 QGridLayout* leftLayout =
new QGridLayout;
46 QVBoxLayout* rightLayout =
new QVBoxLayout;
47 mainLayout ->setSpacing ( 2 );
48 mainLayout ->setContentsMargins( 2, 2, 2, 2 );
49 leftLayout ->setSpacing ( 0 );
50 leftLayout ->setContentsMargins( 0, 1, 0, 1 );
51 rightLayout->setSpacing ( 0 );
52 rightLayout->setContentsMargins( 0, 1, 0, 1 );
70 tr(
"Select Distribution Plot Type(s):" ) );
71 QLabel* lb_runinfo =
us_banner( tr(
"Information for this Run:" ) );
72 QLabel* lb_runid =
us_label ( tr(
"Current Run ID:" ) );
73 QLabel* lb_svproj =
us_label ( tr(
"Save Plot under Project:" ) );
74 QLabel* lb_runids =
us_banner( tr(
"Run IDs:" ) );
75 QLabel* lb_triples =
us_banner( tr(
"Cell / Channel / Wavelength:" ) );
79 QLayout* lo_intconc =
us_checkbox( tr(
"Use Integ.Concentrations" ),
89 leftLayout->addLayout(
dkdb_cntrls, row++, 0, 1, 8 );
90 leftLayout->addWidget( pb_loadda, row, 0, 1, 4 );
91 leftLayout->addWidget(
pb_saveda, row++, 4, 1, 4 );
92 leftLayout->addWidget(
pb_resetd, row, 0, 1, 4 );
93 leftLayout->addWidget(
pb_resetp, row++, 4, 1, 4 );
94 leftLayout->addWidget(
pb_plot3d, row, 0, 1, 4 );
95 leftLayout->addWidget( pb_help, row, 4, 1, 2 );
96 leftLayout->addWidget( pb_close, row++, 6, 1, 2 );
97 leftLayout->addWidget( lb_distrtype, row++, 0, 1, 8 );
98 leftLayout->addLayout( lo_distrib, row, 0, 1, 2 );
99 leftLayout->addLayout( lo_envelope, row, 2, 1, 2 );
100 leftLayout->addLayout( lo_intconc, row++, 4, 1, 4 );
101 leftLayout->addWidget( lb_runinfo, row++, 0, 1, 8 );
102 leftLayout->addWidget( lb_runid, row, 0, 1, 3 );
103 leftLayout->addWidget(
le_runid, row++, 3, 1, 5 );
104 leftLayout->addWidget( lb_svproj, row, 0, 1, 3 );
105 leftLayout->addWidget(
cmb_svproj, row++, 3, 1, 5 );
106 leftLayout->addWidget( lb_runids, row++, 0, 1, 8 );
107 leftLayout->addWidget(
lw_runids, row, 0, 1, 8 );
108 leftLayout->setRowStretch( row, 1 );
110 leftLayout->addWidget( lb_triples, row++, 0, 1, 8 );
111 leftLayout->addWidget(
lw_triples, row, 0, 7, 8 );
112 leftLayout->setRowStretch( row, 7 );
118 connect( pb_loadda, SIGNAL( clicked() ),
119 this, SLOT(
load() ) );
121 this, SLOT(
save() ) );
128 connect( pb_help, SIGNAL( clicked() ),
129 this, SLOT(
help() ) );
130 connect( pb_close, SIGNAL( clicked() ),
131 this, SLOT( close() ) );
133 connect(
ck_distrib, SIGNAL( stateChanged(
int) ),
135 connect(
ck_envelope, SIGNAL( stateChanged(
int) ),
137 connect(
ck_intconc, SIGNAL( stateChanged(
int) ),
140 connect(
lw_runids, SIGNAL( currentRowChanged(
int ) ),
142 connect(
lw_triples, SIGNAL( currentRowChanged(
int ) ),
146 tr(
"G(s) Distributions" ),
147 tr(
"Sedimentation Coefficient x 1e+13 (corr. for 20,W)" ),
148 tr(
"Boundary Fraction (%)" ) );
151 QString etitle = tr(
"Signal Concentration" );
152 QwtText qtitle( etitle );
155 qtitle.setText( etitle );
158 data_plot1->enableAxis ( QwtPlot::yRight,
true );
159 data_plot1->enableAxis ( QwtPlot::yLeft,
true );
160 data_plot1->enableAxis ( QwtPlot::xBottom,
true );
161 data_plot1->setAxisScale( QwtPlot::xBottom, 1.0, 10.0 );
162 data_plot1->setAxisScale( QwtPlot::yLeft, 0.0, 100.0 );
163 data_plot1->setAxisScale( QwtPlot::yRight, 0.0, 6.0 );
164 data_plot1->setAxisTitle( QwtPlot::yRight, qtitle );
166 grid->enableXMin(
true );
167 grid->enableYMin(
true );
171 QwtLegend *legend =
new QwtLegend;
172 legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
175 data_plot1->insertLegend( legend, QwtPlot::BottomLegend );
177 rightLayout->addLayout( plot );
179 mainLayout ->addLayout( leftLayout );
180 mainLayout ->addLayout( rightLayout );
181 mainLayout ->setStretchFactor( leftLayout, 2 );
182 mainLayout ->setStretchFactor( rightLayout, 5 );
184 le_runid ->setText(
"(current run ID)" );
185 cmb_svproj ->addItem(
"(project name for plot save)" );
188 int hh = lb_svproj->height();
189 int ww = lb_svproj->width() / 3;
193 for (
int ii = 0; ii < 8; ii++ )
194 leftLayout ->setColumnMinimumWidth( ii, ww );
195 leftLayout ->setColumnStretch ( 0, 1 );
196 leftLayout ->setColumnStretch ( 1, 1 );
213 connect( &srdiag, SIGNAL( changed(
bool ) ),
217 int nruns = runids.size();
218 if ( nruns < 1 )
return;
219 DbgLv(1) <<
"Selected runIDs[0]" << runids[0] <<
"count" << nruns;
228 le_runid->setText( tr(
"starting data load ..." ) );
229 qApp->processEvents();
231 for (
int ii = 0; ii < nruns; ii++ )
233 runid = runids[ ii ];
234 freport.
readDB( runid, &db );
235 int ntripl = freport.
triples.count();
237 DbgLv(1) <<
" ii,runid,ntrip,dists" << ii << runid << ntripl << distx;
239 for (
int jj = 0; jj < ntripl; jj++ )
243 int ndocs = tripl->
docs.count();
244 DbgLv(1) <<
" jj,ndocs" << jj << ndocs;
245 le_runid->setText( tr(
"loading triple %1 of %2 from run %3" )
246 .arg( jj + 1 ).arg( ntripl ).arg( runid ) );
247 qApp->processEvents();
248 bool havedis =
false;
249 bool haveenv =
false;
255 for (
int kk = 0; kk < ndocs; kk++ )
259 DbgLv(1) <<
" kk,fname" << kk << fname;
261 if ( fname.contains(
"s-c-distrib.csv" ) )
264 dpath = tmpdir +
"/" + runid +
"." + fname;
265 int stat = db.readBlobFromDB( dpath,
266 QString(
"download_reportContents" ), ddoc->
documentID );
267 DbgLv(1) <<
" readBlob stat" << stat;
268 DbgLv(1) <<
" dpath" << dpath;
272 qDebug() <<
"*ERROR* download_reportContents" << stat;
273 qDebug() <<
" DPATH" << dpath;
280 else if ( fname.contains(
"s-c-envelope.csv" ) )
283 epath = tmpdir +
"/" + runid +
"." + fname;
284 DbgLv(1) <<
" epath" << epath;
285 int stat = db.readBlobFromDB( epath,
286 QString(
"download_reportContents" ), edoc->
documentID );
287 DbgLv(1) <<
" readBlob stat" << stat;
291 qDebug() <<
"*ERROR* download_reportContents" << stat;
292 qDebug() <<
" EPATH" << epath;
302 QString fname = dpath.section(
"/", -1, -1 );
306 DbgLv(1) <<
" havedis run trip" << runid << tripl <<
"haveenv" << haveenv;
307 DbgLv(1) <<
" dpath" << dpath;
308 DbgLv(1) <<
" epath" << epath;
311 if ( fid.open( QIODevice::ReadOnly | QIODevice::Text ) )
313 QTextStream tsd( &fid );
317 fie.open( QIODevice::ReadOnly | QIODevice::Text ) )
318 tse.setDevice( &fie );
326 distIDs << runid +
"." + trname;
342 for (
int ii = 0; ii < nruns; ii++ )
344 runid = runids[ ii ];
345 QString rundir = resdir + runid +
"/";
347 QStringList datfilt(
"vHW.*s-c-distrib.csv" );
348 QStringList dfiles = QDir( rundir )
349 .entryList( datfilt, QDir::Files, QDir::Name );
352 int ndfile = dfiles.count();
356 QMessageBox::information(
this, tr(
"No Distribution Plots" ),
357 tr(
"The selected Run ID Directory\n %1\n"
358 "contained no vHW distribution plots." )
362 for (
int ii = 0; ii < ndfile; ii++ )
364 QString fname = dfiles[ ii ];
365 QString fpath = rundir +
"/" + fname;
366 QString epath = QString( fpath ).replace(
"distrib.csv",
368 QString tripl = fname.section(
".", 1, 1 );
374 if ( fid.open( QIODevice::ReadOnly | QIODevice::Text ) )
376 QTextStream tsd( &fid );
379 bool haveenv = fie.open( QIODevice::ReadOnly | QIODevice::Text );
381 tse.setDevice( &fie );
387 distIDs << runid +
"." + tripl;
397 int nrunids = runids.count();
405 for (
int ii = 0; ii < nrunids; ii++ )
416 if ( nrunids == nlitems )
461 grid->enableXMin(
true );
462 grid->enableYMin(
true );
469 QString ptitle = tr(
"G(s) Distributions" );
471 if ( dplot && eplot )
473 ptitle = tr(
"G(s)/g(s) Distributions" );
477 ptitle = tr(
"G(s) Distributions" );
481 ptitle = tr(
"g(s) Distributions" );
486 for (
int ii = 0; ii <
pdistrs.size(); ii++ )
493 QVector< double > dconcs;
497 int ndispt = ddesc.
bfracs.size();
498 int nenvpt = ddesc.
efreqs.size();
499 double* xx = ddesc.
dsedcs.data();
500 double* yy = ddesc.
bfracs.data();
501 double* xs = ddesc.
esedcs.data();
502 double* yf = ddesc.
efreqs.data();
503 double fscl = dconc ? ( ddesc.
totconc * 0.01 ) : 1.0;
505 QString dcID = distrID + tr(
" (integ.)" );
506 QString ecID = distrID + tr(
" (diff.)" );
507 QwtPlotCurve* dcurve;
508 QwtPlotCurve* ecurve;
509 QPen dlpen( QPen( Qt::yellow ) );
510 QPen elpen( QPen( QBrush( ddesc.
color ), 3.0 ) );
512 if ( dplot && !dconc )
515 dcurve->setStyle ( QwtPlotCurve::Lines );
516 dcurve->setSymbol( ddesc.
symbol );
517 dcurve->setPen ( dlpen );
518 dcurve->setData ( xx, yy, ndispt );
519 dcurve->setYAxis ( QwtPlot::yLeft );
522 if ( dplot && dconc )
525 dconcs.reserve( ndispt );
527 for (
int ii = 0; ii < ndispt; ii++ )
528 dconcs << ( yy[ ii ] * fscl );
530 double* yc = dconcs.data();
532 dcurve->setStyle ( QwtPlotCurve::Lines );
533 dcurve->setSymbol( ddesc.
symbol );
534 dcurve->setPen ( dlpen );
535 dcurve->setData ( xx, yc, ndispt );
536 dcurve->setYAxis ( QwtPlot::yRight );
541 int kk=ddesc.
efreqs.size();
542 DbgLv(2) <<
" xs0 yf0" << xs[0] << yf[0];
543 DbgLv(2) <<
" xs1 yf1" << xs[1] << yf[1];
544 DbgLv(2) <<
" xsm yfm" << xs[kk-2] << yf[kk-2];
545 DbgLv(2) <<
" xsn yfn" << xs[kk-1] << yf[kk-1];
547 ecurve->setStyle ( QwtPlotCurve::Lines );
548 ecurve->setPen ( elpen );
549 ecurve->setData ( xs, yf, nenvpt );
550 ecurve->setYAxis ( QwtPlot::yRight );
553 data_plot1->setAxisAutoScale( QwtPlot::xBottom );
554 data_plot1->setAxisAutoScale( QwtPlot::yLeft );
555 data_plot1->setAxisAutoScale( QwtPlot::yRight );
556 data_plot1->enableAxis ( QwtPlot::yLeft, dplot && ! dconc );
557 data_plot1->enableAxis ( QwtPlot::yRight, eplot || dconc );
566 QString
runID = ( oproj ==
"All" ) ?
pdistrs[ 0 ].runID : oproj;
567 QString trname =
pdistrs[ 0 ].triple;
569 QString fnamsvg =
"vHW.0Z9999.combo-distrib.svgz";
570 QString fnampng =
"vHW.0Z9999.combo-distrib.png";
571 QString fnamdat =
"vHW.0Z9999.combo-sb-distrib.csv";
572 QString fnamenv =
"vHW.0Z9999.combo-s-envelope.csv";
573 QString fnamlst =
"vHW.0Z9999.combo-list-include.rpt";
574 QString plotFile = fdir +
"/" + fnamsvg;
575 QString dataFile = fdir +
"/" + fnamdat;
576 QString denvFile = fdir +
"/" + fnamenv;
577 QString listFile = fdir +
"/" + fnamlst;
580 QString svmsg = tr(
"Saved:\n " ) + fnampng +
"\n "
585 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
588 for (
int ii = 0; ii <
pdistrs.size(); ii++ )
590 QString prun =
pdistrs[ ii ].runID;
591 if ( oproj ==
"All" )
593 if ( ! prunids.contains( prun ) )
600 else if ( prun == runID )
609 int nruns = prunids.size();
612 while( iruns < nruns )
614 if ( ! QFile( fdir ).exists() )
616 QDir().mkpath( fdir );
623 svmsg += tr(
"in directory:" ) +
"\n " + fdir +
"\n";
631 QString trfirst =
pdistrs[ 0 ].triple;
633 QString trdesc =
"Combined Analyses (" + trfirst
634 +
"..." + trlast +
")";
640 .replace(
'/',
'.' );
644 query <<
"get_experiment_info_by_runID" << runID << invID;
647 QString expID = db.value( 1 ).toString();
648 DbgLv(1) <<
"SV: runID expID" << runID << expID;
652 query <<
"get_rawDataIDs" << expID;
656 rawID = db.value( 0 ).toString();
657 QString efname = db.value( 2 ).toString();
658 DbgLv(1) <<
"SV: rawID" << rawID <<
"efname" << efname <<
"trip1" << trip1;
660 if ( efname.contains( trip1 ) )
665 query <<
"get_editedDataIDs" << rawID;
669 QString aeditID = db.value( 0 ).toString();
670 QString efname = db.value( 2 ).toString();
671 if ( eeditID.isEmpty() )
673 DbgLv(1) <<
"SV: editID" << eeditID <<
"raw exp trip1 fname"
674 << rawID << expID << trip1 << efname;
675 if ( efname.contains( trip1 ) )
678 DbgLv(1) <<
"SV: Name-Trip MATCH: editID" << editID;
682 if ( ! editID.isEmpty() )
684 idEdit = editID.toInt();
688 idEdit = eeditID.toInt();
690 DbgLv(1) <<
"SV: editID idEdit" << editID << idEdit <<
" eeditID" << eeditID;
694 rfiles << fnamsvg << fnampng << fnamdat << fnamenv << fnamlst;
698 DbgLv(1) <<
"SV:runID" << runID <<
"idEdit" << idEdit
699 <<
"fnamlst" << fnamlst <<
"trdesc" << trdesc;
700 if ( iruns == ( nruns - 1 ) )
703 svmsg += tr(
"\nThe files were also saved to the database" );
705 svmsg += tr(
"\n*ERROR* in saving files to the database" );
709 if ( ++iruns >= nruns )
break;
711 runID = prunids[ iruns ];
712 jdist = prndxs [ iruns ];
713 trname =
pdistrs[ jdist ].triple;
715 plotFile = fdir +
"/" + fnamsvg;
716 dataFile = fdir +
"/" + fnamdat;
717 denvFile = fdir +
"/" + fnamenv;
718 listFile = fdir +
"/" + fnamlst;
721 QApplication::restoreOverrideCursor();
724 QMessageBox::information(
this, tr(
"Combo Distro Plot File Save" ), svmsg );
730 DbgLv(1) <<
"RunIDSel:row" << row;
731 if ( row < 0 )
return;
732 QListWidgetItem* item =
lw_runids->item( row );
733 runID = item->text();
739 for (
int ii = 0; ii <
distros.size(); ii++ )
741 DbgLv(1) <<
"RunIDSel: ii runID" << ii <<
distros[ii].runID;
745 QString distrID = ddesc.
runID +
" ("
761 DbgLv(1) <<
"TripleSel:row" << row;
762 if ( row < 0 )
return;
763 QListWidgetItem* item =
lw_triples->item( row );
764 triple = item->text().section(
":", 0, 0 ).right( 7 ).mid( 0, 5 );
769 for (
int ii = 0; ii <
distros.size(); ii++ )
777 QString distrID = ddesc.
runID +
" (" + ddesc.
triple +
") : "
780 DbgLv(1) <<
"TripleSel:distrID" << distrID;
781 if ( !
pdisIDs.contains( distrID ) )
783 DbgLv(1) <<
"TripleSel:distrID NEW TO LIST";
792 DbgLv(1) <<
"TripleSel:distrID ALREADY IN LIST";
810 int ncolors =
colors.size();
814 while ( js >= nsymbs )
817 while ( jc >= ncolors )
821 dsymbol.setPen( QColor( Qt::white ) );
822 dsymbol.setSize( 8 );
823 dsymbol.setStyle( (QwtSymbol::Style)
symbols[ js ] );
824 dsymbol.setBrush( ddesc.
color );
839 symbols << (int)( QwtSymbol::Ellipse );
840 symbols << (int)( QwtSymbol::Rect );
841 symbols << (int)( QwtSymbol::Triangle );
842 symbols << (int)( QwtSymbol::Diamond );
843 symbols << (int)( QwtSymbol::LTriangle );
844 symbols << (int)( QwtSymbol::Hexagon );
845 symbols << (int)( QwtSymbol::Star2 );
846 symbols << (int)( QwtSymbol::DTriangle );
848 colors << QColor( 255, 0, 0 );
849 colors << QColor( 0, 255, 0 );
850 colors << QColor( 0, 0, 255 );
851 colors << QColor( 255, 255, 0 );
852 colors << QColor( 255, 0, 255 );
853 colors << QColor( 0, 255, 255 );
854 colors << QColor( 122, 0, 255 );
855 colors << QColor( 0, 255, 122 );
856 colors << QColor( 0, 122, 255 );
857 colors << QColor( 255, 122, 0 );
858 colors << QColor( 122, 255, 0 );
859 colors << QColor( 80, 0, 255 );
860 colors << QColor( 255, 0, 80 );
861 colors << QColor( 80, 0, 255 );
862 colors << QColor( 255, 0, 80 );
863 colors << QColor( 0, 255, 80 );
864 colors << QColor( 0, 80, 255 );
865 colors << QColor( 80, 255, 0 );
866 colors << QColor( 255, 80, 40 );
867 colors << QColor( 40, 255, 40 );
868 colors << QColor( 40, 40, 255 );
874 QString etriple = ctriple;
876 if ( ! etriple.contains(
" / " ) )
877 etriple = etriple.left( 1 ) +
" / " +
878 etriple.mid( 1, 1 ) +
" / " +
887 QString ctriple = etriple;
889 if ( ctriple.contains(
" / " ) )
890 ctriple = ctriple.replace(
" / ",
"" ).simplified();
891 else if ( ctriple.contains(
"/" ) )
892 ctriple = ctriple.replace(
"/",
"" ).simplified();
893 else if ( ctriple.contains(
"." ) )
894 ctriple = ctriple.replace(
".",
"" ).simplified();
906 int ndpts = ddesc.
dsedcs.size();
907 double max_cept = 1.0e-6;
908 double min_cept = 1.0e+6;
909 double sed_bin = ddesc.
dsedcs.at( 0 );
910 double his_sum = 0.0;
911 double env_sum = 0.0;
912 double div_scl = (double)nSensit * (
double)ndpts * 0.01;
919 for (
int jj = 0; jj < ndpts; jj++ )
921 min_cept = qMin( min_cept, ddesc.
dsedcs.at( jj ) );
922 max_cept = qMax( max_cept, ddesc.
dsedcs.at( jj ) );
926 sed_bin = ( max_cept - min_cept ) / div_scl;
927 max_step = max_cept * 4.0 / 3.0;
928 steps = (int)( max_step / sed_bin );
930 if ( nepts <= steps )
935 ddesc.
esedcs.fill( 0.0, nepts );
936 ddesc.
efreqs.fill( 0.0, nepts );
939 double pisqr = sqrt( M_PI * 2.0 );
940 double* xval = ddesc.
esedcs.data();
941 double* yval = ddesc.
efreqs.data();
942 double scale = max_step / (double)nepts;
944 for (
int jj = 0; jj < nepts; jj++ )
946 xval[ jj ] = scale * (double)jj;
950 sigma = sed_bin * 0.02 * (double)nSmooth;
952 for (
int jj = 0; jj < steps; jj++ )
955 sed_lo = sed_bin * (double)jj;
956 sed_hi = sed_lo + sed_bin;
957 sval = ( sed_lo + sed_hi ) * 0.5;
959 for (
int kk = 0; kk < ndpts; kk++ )
961 sedc = ddesc.
dsedcs.at( kk );
963 if ( sedc >= sed_lo && sedc < sed_hi )
968 his_sum += ( bink * sed_bin );
972 for (
int kk = 0; kk < nepts; kk++ )
974 double xdif = ( xval[ kk ] - sval ) / sigma;
975 yval[ kk ] += ( ( bink / ( sigma * pisqr ) )
976 * exp( -( xdif * xdif ) / 2.0 ) );
981 for (
int kk = 0; kk < nepts; kk++ )
983 env_sum += yval[ kk ];
986 env_sum *= xval[ 1 ];
987 scale = his_sum / env_sum;
988 DbgLv(2) <<
"ED: hsum esum scale " << his_sum << env_sum << scale;
993 for (
int kk = 0; kk < nepts; kk++ )
997 if ( yval[ kk ] != 0.0 )
999 if ( fnz < 0 ) fnz = kk;
1004 fnz = qMax( ( fnz - 2 ), 0 );
1005 lnz = qMin( ( lnz + 2 ), nepts );
1008 for (
int ii = fnz; ii < lnz; ii++ )
1010 xval[ nepts ] = xval[ ii ];
1011 yval[ nepts ] = yval[ ii ];
1015 ddesc.
esedcs.resize( nepts );
1016 ddesc.
efreqs.resize( nepts );
1026 DbgLv(1) <<
"Upd_Dk_Db isDB" << isDB;
1032 DistrDesc& ddesc,
bool haveenv,
int distx )
1035 QString fline = tsd.readLine().simplified();
1036 DbgLv(1) <<
"FID: fline0" << fline;
1038 if ( fline.contains(
"%Boundary" ) )
1039 ddesc.
tdescr = tr(
"(Unknown description)" );
1043 fline = tsd.readLine();
1046 while ( !tsd.atEnd() )
1048 fline = tsd.readLine().simplified();
1050 str = fline.section(
",", 0, 0);
1051 double bound = str.remove(
"\"").toDouble();
1052 str = fline.section(
",", 3, 3);
1053 double sedc = str.remove(
"\"").toDouble();
1060 int kk = ddesc.
dsedcs.size()-1;
1061 DbgLv(1) <<
"Distro runid" << ddesc.
runID <<
" triple" << ddesc.
triple << kk;
1068 fline = tse.readLine();
1074 while ( !tse.atEnd() )
1076 fline = tse.readLine().simplified();
1077 str = fline.section(
",", 0, 0 );
1078 double sedc = str.remove(
"\"" ).toDouble();
1079 str = fline.section(
",", 1, 1 );
1080 double freq = str.remove(
"\"" ).toDouble();
1084 lnz = ddesc.
esedcs.size();
1094 str = fline.section(
",", 4, 4 );
1095 double conc = str.remove(
"\"" ).toDouble();
1097 DbgLv(1) <<
"TotConc" << ddesc.
totconc <<
"str" << str;
1098 DbgLv(1) <<
"FLine" << fline;
1102 QMessageBox::warning(
this,
1103 tr(
"No Total Concentration" ),
1104 tr(
"The Envelope CSV for Run %1 does not contain"
1105 " a Total Concentration value. The vHW application"
1106 " should be re-run to re-create this report." )
1107 .arg( ddesc.
runID ) );
1115 int nepts = ddesc.
esedcs.size();
1116 fnz = qMax( ( fnz - 2 ), 0 );
1117 lnz = qMin( ( lnz + 2 ), nepts );
1121 for (
int jj = fnz; jj < lnz; jj++ )
1126 ysum += ddesc.
efreqs[ jj ];
1130 double sclf = ( ddesc.
totconc == 0.0 ) ? 1.0 : ( ddesc.
totconc / ysum );
1133 for (
int jj = 0; jj < nepts; jj++ )
1134 ddesc.
efreqs[ jj ] *= sclf;
1136 if ( nepts < ddesc.
esedcs.size() )
1138 ddesc.
esedcs.resize( nepts );
1139 ddesc.
efreqs.resize( nepts );
1141 DbgLv(1) <<
" Envel nepts" << nepts << ddesc.
esedcs.size();
1142 int kk = ddesc.
esedcs.size()-1;
1159 QFile(
dat1File ).copy( dataFile );
1160 QFile(
lis1File ).copy( listFile );
1171 QFile dfile( dataFile );
1173 if ( ! dfile.open( QIODevice::WriteOnly | QIODevice::Text ) )
1175 qDebug() <<
"***Error opening output file" << dataFile;
1179 QTextStream tsd( &dfile );
1182 int lastp = nplots - 1;
1186 for (
int ii = 0; ii < nplots; ii++ )
1188 maxnvl = qMax( maxnvl,
pdistrs[ ii ].dsedcs.size() );
1191 pd = pd.section(
":", 0, 0 ).simplified();
1192 line +=
"\"" + pd +
".X\",\"" + pd +
".Y\"";
1201 for (
int jj = 0; jj < maxnvl; jj++ )
1204 for (
int ii = 0; ii < nplots; ii++ )
1206 double bscl = dconc ? (
pdistrs[ ii ].totconc * 0.01 ) : 1.0;
1207 int nvals =
pdistrs[ ii ].dsedcs.size();
1208 double* xx =
pdistrs[ ii ].dsedcs.data();
1209 double* yy =
pdistrs[ ii ].bfracs.data();
1210 int kk = qMin( jj, ( nvals - 1 ) );
1211 double sval = xx[ kk ];
1212 double boun = yy[ kk ] * bscl;
1214 QString dat = QString().sprintf(
"\"%12.5f\",\"%10.5f\"", sval, boun );
1215 dat.replace(
" ",
"" );
1229 QFile lfile( listFile );
1230 if ( ! lfile.open( QIODevice::WriteOnly | QIODevice::Text ) )
1232 qDebug() <<
"***Error opening output file" << listFile;
1235 QTextStream tsl( &lfile );
1237 for (
int ii = 0; ii < nplots; ii++ )
1239 line = pdlong[ ii ] +
"\n";
1253 QFile(
env1File ).copy( denvFile );
1262 QFile dfile( denvFile );
1264 if ( ! dfile.open( QIODevice::WriteOnly | QIODevice::Text ) )
1266 qDebug() <<
"***Error opening output file" << denvFile;
1270 QTextStream tsd( &dfile );
1273 int lastp = nplots - 1;
1277 for (
int ii = 0; ii < nplots; ii++ )
1279 maxnvl = qMax( maxnvl,
pdistrs[ ii ].esedcs.size() );
1282 pd = pd.section(
":", 0, 0 ).simplified();
1283 line +=
"\"" + pd +
".X\",\"" + pd +
".Y\"";
1292 for (
int jj = 0; jj < maxnvl; jj++ )
1295 for (
int ii = 0; ii < nplots; ii++ )
1297 int nvals =
pdistrs[ ii ].esedcs.size();
1298 double* xx =
pdistrs[ ii ].esedcs.data();
1299 double* yy =
pdistrs[ ii ].efreqs.data();
1300 int kk = qMin( jj, ( nvals - 1 ) );
1301 double sval = xx[ kk ];
1302 double eval = yy[ kk ];
1304 QString dat = QString().sprintf(
"\"%12.5f\",\"%10.5f\"", sval, eval );
1305 dat.replace(
" ",
"" );
1323 QStringList& files,
US_DB2* db,
int& idEdit, QString& trdesc )
1329 for (
int ii = 0; ii < files.size(); ii++ )
1331 QString fname = files[ ii ];
1340 int status = freport.
readDB( runID, db );
1341 DbgLv(1) <<
"DFF:report readDB status" << status <<
"ID" << freport.
ID;
1342 DbgLv(1) <<
"DFF: report triples size" << freport.
triples.size();
1343 for (
int ii = 0; ii < freport.
triples.size(); ii++ )
1345 int ndoc = freport.
triples[ii].docs.size();
1346 DbgLv(1) <<
"DFF: triple" << ii <<
"docssize" << ndoc
1347 <<
"ID" << freport.
triples[ii].tripleID
1348 <<
"triple" << freport.
triples[ii].triple;
1352 DbgLv(1) <<
"DFF: doc" << 0
1353 <<
"ID" << freport.
triples[ii].docs[0].documentID
1354 <<
"label" << freport.
triples[ii].docs[0].label;
1355 DbgLv(1) <<
"DFF: doc" << jj
1356 <<
"ID" << freport.
triples[ii].docs[jj].documentID
1357 <<
"label" << freport.
triples[ii].docs[jj].label;
1360 QString fname = files[0];
1361 QString tripl(
"0/Z/9999" );
1363 DbgLv(1) <<
"DFF:triple" << tripl <<
"ndx" << ndx;
1366 int ndoc = freport.
triples[ndx].docs.size();
1367 DbgLv(1) <<
"DFF: triple" << ndx <<
"docs size" << ndoc
1368 <<
"ID" << freport.
triples[ndx].tripleID
1369 <<
"triple" << freport.
triples[ndx].triple;
1372 DbgLv(1) <<
"DFF: doc" << 0
1373 <<
"ID" << freport.
triples[ndx].docs[0].documentID
1374 <<
"label" << freport.
triples[ndx].docs[0].label;
1376 DbgLv(1) <<
"DFF: doc" << jj
1377 <<
"ID" << freport.
triples[ndx].docs[jj].documentID
1378 <<
"label" << freport.
triples[ndx].docs[jj].label;
1392 int p_type = eplot ? 0 : ( icflag ? 2 : 1 );
1393 QString wtitle = tr(
"Multiwavelength 3-Dimensional vHW Viewer" );
1394 QString ptitle = eplot ? tr(
"g(s) Distributions" )
1395 : tr(
"G(s) Distributions" );
1397 QString xatitle = tr(
"Sed.C.(*e13)" );
1398 QString yatitle = tr(
"Lambda(nm)" );
1401 QString zatitle = eplot ? tr(
"Concen." )
1402 : ( icflag ? tr(
"BF*Conc." ) : tr(
"Concen." ) );
1406 double xmax = -xmin;
1407 double ymax = -ymin;
1408 double zmax = -zmin;
1417 QList< double > xvals;
1418 QList< double > yvals;
1423 for (
int ii = 0; ii < ndist; ii++ )
1426 QString wvlen = QString( ddesc.
triple ).mid( 2 );
1427 double yval = wvlen.toDouble();
1428 ymin = qMin( ymin, yval );
1429 ymax = qMax( ymax, yval );
1430 int ndispt = ddesc.
bfracs.size();
1431 int nenvpt = ddesc.
efreqs.size();
1432 double* xx = ddesc.
dsedcs.data();
1433 double* zz = ddesc.
bfracs.data();
1434 double* xs = ddesc.
esedcs.data();
1435 double* zf = ddesc.
efreqs.data();
1437 if ( ! yvals.contains( yval ) )
1443 int ndpts = eplot ? nenvpt : ndispt;
1444 xx = eplot ? xs : xx;
1445 zz = eplot ? zf : zz;
1446 double zfscl = eplot ? 1.0 : ( ddesc.
totconc * 0.01 );
1447 zfscl = icflag ? zfscl : 1.0;
1452 for (
int jj = 0; jj < ndpts; jj++ )
1454 double xval = xx[ jj ];
1455 double zval = zz[ jj ] * zfscl;
1457 if ( zval == 0.0 )
continue;
1459 xval = qRound( xval * 1.0e4 ) * 1.0e-4;
1461 if ( ! xvals.contains( xval ) )
1467 xmin = qMin( xmin, xval );
1468 xmax = qMax( xmax, xval );
1469 zmin = qMin( zmin, zval );
1470 zmax = qMax( zmax, zval );
1472 xyzdat << QVector3D( xval, yval, zval );
1474 DbgLv(0) <<
"Raw:xyzd: ii jj" << ii << jj <<
"xyz" << xval << yval << zval;
1477 minpt = qMin( minpt, knzdp );
1478 maxpt = qMax( maxpt, knzdp );
1483 DbgLv(0) <<
" nrow ncol nxval nyval" << nrow << ncol << nxval << nyval;
1484 DbgLv(0) <<
" xmin xmax" << xmin << xmax <<
"ymin ymax" << ymin << ymax
1485 <<
"zmin zmax" << zmin << zmax <<
"xyzd size" <<
xyzdat.size();
1487 if ( minpt != maxpt )
1490 xmin = qRound( xmin * 1.0e4 ) * 1.0e-4;
1491 xmax = qRound( xmax * 1.0e4 ) * 1.0e-4;
1493 double yval = yvals[ 0 ];
1494 double xinc = ( xmax - xmin ) / (
double)nrow;
1495 QVector< QVector3D > xyzold =
xyzdat;
1496 int kidpt = xyzold.count();
1500 DbgLv(0) <<
" xmin xinc" << xmin << xinc <<
"xyzold count" << kidpt;
1502 for (
int ii = 0; ii < nrow; ii++, xval += xinc )
1504 DbgLv(0) <<
" xv0 xvn" << xvals[0] << xvals[nrow-1];
1506 for (
int ii = 0; ii < ncol; ii++ )
1508 QVector< double > xvsic;
1509 QVector< double > zvsic;
1513 DbgLv(0) <<
" col" << ii <<
"yval" << yval;
1515 for (
int jj = 0; jj < kidpt; jj++ )
1517 double yvalo = xyzold[ jj ].y();
1519 if ( yvalo == yval )
1521 double xval = xyzold[ jj ].x();
1522 double zval = xyzold[ jj ].z();
1525 if ( zval == 0.0 && krmv < nrmv )
1531 if ( zval == 0.0 )
continue;
1542 int jrow = xvsic.count();
1543 double xlast = qMin( xmax, xvsic[ jrow - 1 ] + xinc );
1544 double zlast = zvsic[ jrow - 1 ];
1545 DbgLv(0) <<
" jrow" << jrow <<
"nrow" << nrow
1546 <<
"xv0,xvn" << xvsic[0] << xvsic[jrow-1];
1548 for (
int jj = 0; jj < nrow; jj++ )
1550 double xval = ( jj < jrow ) ? xvsic[ jj ] : xlast;
1552 double zval = ( jj < jrow ) ? zvsic[ jj ] : zlast;
1553 xyzdat << QVector3D( xval, yval, zval );
1564 connect(
p3d_ctld, SIGNAL( has_closed() ),
1568 int cx = qApp->desktop()->width() -
p3d_ctld->width() - 40;
1574 p3d_pltw->setTitles ( wtitle, ptitle, xatitle, yatitle, zatitle );
1575 DbgLv(0) <<
"p3db:N: titles" << ptitle << xatitle << yatitle << zatitle;
1585 p3d_pltw->setTitles ( wtitle, ptitle, xatitle, yatitle, zatitle );
1588 DbgLv(0) <<
"p3db:E: titles" << ptitle << xatitle << yatitle << zatitle;
1600 DbgLv(1) <<
"VC: control_closed";