23 setObjectName(
"US_AdvAnalysisPc" );
26 setAttribute( Qt::WA_DeleteOnClose,
false );
27 QFontMetrics fmet( font() );
30 setWindowTitle( tr(
"PCSA Advanced Controls" ) );
44 DbgLv(1) <<
"AA: define GUI elements";
47 QLabel* lb_fitctrl =
us_banner( tr(
"Fitting Controls:" ) );
48 QLabel* lb_bfmstat =
us_banner( tr(
"Best Final Model Status:" ) );
49 QLabel* lb_mrecctrl =
us_banner( tr(
"Final & Model Records Controls:" ) );
50 QLabel* lb_mrecstat =
us_banner( tr(
"Model Records Status:" ) );
51 QLabel* lb_curvtype =
us_label ( tr(
"Curve Type:" ) );
52 QLabel* lb_x_range =
us_label ( tr(
"X Range:" ) );
53 QLabel* lb_y_range =
us_label ( tr(
"Y Range:" ) );
58 QLabel* lb_crpoints =
us_label ( tr(
"Curve Resolution Points:" ) );
59 QLabel* lb_mciters =
us_label ( tr(
"Monte Carlo Iterations:" ) );
60 QLabel* lb_progress =
us_label ( tr(
"Progress:" ) );
95 cb_curvtype->addItem( tr(
"Horizontal Line [ C(s) ]" ) );
96 cb_curvtype->addItem( tr(
"Second-Order Power Law" ) );
108 DbgLv(1) <<
"AA: populate finmodelLayout";
138 DbgLv(1) <<
"AA: populate mreclistLayout";
168 int fwidth = fmet.maxWidth();
170 int cminw = fwidth * 4;
171 int csizw = cminw + fwidth;
206 tr(
"An initial best final model, with RMSD of %1,\n"
207 " has been read." ).arg(
mrec.
rmsd ) );
210 tr(
"An initial model records list, with %1 fits,\n"
211 " has been read." ).arg(
nmrecs ) );
226 tr(
"No initial best final model has been read" ) );
228 tr(
"No initial model records list has been read" ) );
233 DbgLv(1) <<
"AA: connect buttons";
234 connect(
cb_curvtype, SIGNAL( currentIndexChanged(
int ) ),
238 connect(
le_x_lower, SIGNAL( textChanged(
const QString& ) ),
239 this, SLOT( slowerChanged(
double ) ) );
240 connect(
le_x_upper, SIGNAL( textChanged(
const QString& ) ),
241 this, SLOT( supperChanged(
double ) ) );
242 connect(
le_y_lower, SIGNAL( textChanged(
const QString& ) ),
243 this, SLOT( klowerChanged(
double ) ) );
244 connect(
le_y_upper, SIGNAL( textChanged(
const QString& ) ),
245 this, SLOT( kupperChanged(
double ) ) );
246 connect(
le_sigmpar1, SIGNAL( textChanged(
const QString& ) ),
247 this, SLOT( sipar1Changed(
double ) ) );
248 connect(
le_sigmpar2, SIGNAL( textChanged(
const QString& ) ),
249 this, SLOT( sipar2Changed(
double ) ) );
250 connect(
le_crpoints, SIGNAL( textChanged(
const QString& ) ),
251 this, SLOT( pointsChanged(
double ) ) );
253 connect(
le_mciters, SIGNAL( textChanged(
const QString& ) ),
273 connect(
pb_help, SIGNAL( clicked() ),
274 this, SLOT(
help() ) );
282 DbgLv(1) <<
"Post-resize size" << size();
283 qApp->processEvents();
293 DbgLv(1) <<
"advanced_results - state=" << state;
295 if ( p_mrecsmc != 0 )
317 DbgLv(1) <<
"AA:Accept: mr mnmx x y"
318 << p_mrecs->at(0).xmin << p_mrecs->at(0).xmax
319 << p_mrecs->at(0).ymin << p_mrecs->at(0).ymax;
320 DbgLv(1) <<
"AA:Accept: mr-size mr0-RMSD" << p_mrecs->size()
321 << p_mrecs->at(9).rmsd <<
"mr0-solsize" << p_mrecs->at(0).csolutes.size();
347 DbgLv(1) <<
"curvtypeChanged" << ivalue;
355 bool is_line = ! is_sigm;
366 lb_y_endpt->setText( tr(
"Line Y End Points:" ) );
371 void US_AdvAnalysisPc::slowerChanged(
double value )
373 DbgLv(1) <<
"slowerChanged" << value;
377 void US_AdvAnalysisPc::supperChanged(
double value )
379 DbgLv(1) <<
"supperChanged" << value;
383 void US_AdvAnalysisPc::sipar1Changed(
double value )
385 DbgLv(1) <<
"sipar1Changed" << value;
389 void US_AdvAnalysisPc::sipar2Changed(
double value )
391 DbgLv(1) <<
"sipar2Changed" << value;
395 void US_AdvAnalysisPc::klowerChanged(
double value )
397 DbgLv(1) <<
"klowerChanged" << value;
401 void US_AdvAnalysisPc::kupperChanged(
double value )
403 DbgLv(1) <<
"kupperChanged" << value;
407 void US_AdvAnalysisPc::pointsChanged(
double value )
409 DbgLv(1) <<
"pointsChanged" << value;
416 DbgLv(1) <<
"mciterChanged" << value;
426 QString dsearch =
"";
433 if ( mrldDiag.exec() != QDialog::Accepted )
435 DbgLv(1) <<
"mrldDiag.exec==rejected";
444 double xmin =
mrecs[ 0 ].xmin;
445 double xmax =
mrecs[ 0 ].xmax;
446 double ymin =
mrecs[ 0 ].ymin;
447 double ymax =
mrecs[ 0 ].ymax;
448 DbgLv(1) <<
"mrldDiag post-accept xmin xmax ymin ymax"
449 << xmin << xmax << ymin << ymax <<
"nmrecs" <<
nmrecs;
451 for (
int mr = 0; mr <
nmrecs; mr++ )
453 mrecs[ mr ].xmin = xmin;
454 mrecs[ mr ].xmax = xmax;
455 mrecs[ mr ].ymin = ymin;
456 mrecs[ mr ].ymax = ymax;
472 tr(
"A new Best Final Model derives from the top spot\n"
473 " of the just-loaded Model Records list.\n"
474 "The %1 model has %2 computed solutes\n"
475 " and an RMSD of %3" )
479 DbgLv(1) <<
"post-set-fittings mr0 rmsd" <<
mrecs[0].rmsd;
490 DbgLv(1) <<
"store_mrecs";
496 QString store_file =
store_dir +
"/pcsa-mrs-new_mrecs.xml";
497 store_file = QFileDialog::getSaveFileName(
this,
498 tr(
"Specify XML File Name for Model Records Store" ),
store_dir,
499 tr(
"Model Records files (*pcsa-mrs-*.xml);;"
500 "Any XML files (*.xml);;Any files (*)" ) );
502 if ( store_file.isEmpty() )
504 DbgLv(1) <<
"store_mrecs - FILE NAME EMPTY";
507 else DbgLv(1) <<
"store_mrecs - FILE NAME *NOT* EMPTY" << store_file;
509 store_file = store_file.replace(
"\\",
"/" );
510 QString fdir = store_file.section(
"/", 0, -2 ) +
"/";
511 QString fname = store_file.section(
"/", -1, -1 );
514 if ( store_file.endsWith(
"." ) )
516 store_file = store_file.left( store_file.length() - 1 );
517 fname = fname .left( fname .length() - 1 );
520 else if ( ! store_file.endsWith(
".xml" ) )
522 store_file = store_file +
".xml";
523 fname = fname +
".xml";
526 if ( fname.startsWith(
"." ) )
528 store_file = fdir + fname.mid( 1 );
531 else if ( ! fname.startsWith(
"pcsa-mrs-" ) )
533 store_file = fdir +
"pcsa-mrs-" + fname;
537 QFile fileo( store_file );
539 if ( !fileo.open( QIODevice::WriteOnly | QIODevice::Text ) )
541 QMessageBox::critical(
this, tr(
"Open Error" ),
542 tr(
"Cannot open file %1 ." ).arg( store_file ) );
548 double xmin =
mrecs[ 0 ].xmin;
549 double xmax =
mrecs[ 0 ].xmax;
550 double ymin =
mrecs[ 0 ].ymin;
551 double ymax =
mrecs[ 0 ].ymax;
552 int stype =
mrecs[ 0 ].stype;
553 QXmlStreamWriter xmlo( &fileo );
557 ctype, xmin, xmax, ymin, ymax, stype );
561 fdir = store_file.section(
"/", 0, -2 ) +
"/";
562 fname = store_file.section(
"/", -1, -1 );
564 tr(
"Model Records have been stored in file\n"
565 " \"%1\", of directory\n \"%2\"." )
566 .arg( fname ).arg( fdir),
true );
572 DbgLv(1) <<
"load_bfm";
579 QString load_file =
store_dir +
"/pcsa-bfm-old_mrecs.xml";
580 load_file = QFileDialog::getOpenFileName(
this,
581 tr(
"Select XML File Name for Best Final Model Load" ),
store_dir,
582 tr(
"Best Final Model files (*pcsa-bfm-*.xml);;"
583 "Any XML files (*.xml);;Any files (*)" ) );
585 if ( load_file.isEmpty() )
590 load_file = load_file.replace(
"\\",
"/" );
591 QString fdir = load_file.section(
"/", 0, -2 ) +
"/";
592 QString fname = load_file.section(
"/", -1, -1 );
595 QFile filei( load_file );
597 if ( !filei.open( QIODevice::ReadOnly ) )
599 QMessageBox::critical(
this, tr(
"Open Error" ),
600 tr(
"Cannot open file %1 ." ).arg( load_file ) );
606 bool is_bfmf =
false;
607 QString xmlname =
"";
608 QXmlStreamReader xmli( &filei );
610 while ( ! xmli.atEnd() )
614 if ( xmli.isComment() )
616 QString comm = xmli.text().toString();
619 if ( comm.contains(
"PcsaBestFinalModel" ) )
624 QMessageBox::critical(
this, tr(
"File Type Error" ),
625 tr(
"File \"%1\" is not a PcsaBestFinalModel XML file." )
632 xmlname = xmli.name().toString();
634 if ( xmli.isStartElement() )
637 QXmlStreamAttributes xattrs = xmli.attributes();
639 if ( xmlname ==
"modelrecord" )
641 nisols = xattrs.value(
"curve_points" )
643 mrec.
taskx = xattrs.value(
"taskx" ).toString().toInt();
644 mrec.
str_y = xattrs.value(
"start_y" ).toString().toDouble();
645 mrec.
end_y = xattrs.value(
"end_y" ).toString().toDouble();
646 mrec.
par1 = xattrs.value(
"par1" ).toString().toDouble();
647 mrec.
par2 = xattrs.value(
"par2" ).toString().toDouble();
648 mrec.
par3 = xattrs.value(
"par3" ).toString().toDouble();
649 mrec.
rmsd = xattrs.value(
"rmsd" ).toString().toDouble();
650 mrec.
ctype = xattrs.value(
"type" ).toString().toInt();
651 mrec.
xmin = xattrs.value(
"xmin" ).toString().toDouble();
652 mrec.
xmax = xattrs.value(
"xmax" ).toString().toDouble();
653 mrec.
ymin = xattrs.value(
"ymin" ).toString().toDouble();
654 mrec.
ymax = xattrs.value(
"ymax" ).toString().toDouble();
661 else if ( xmlname ==
"c_solute" )
664 csolute.
x = xattrs.value(
"x" ).toString().toDouble();
665 csolute.
y = xattrs.value(
"y" ).toString().toDouble();
666 csolute.
z = xattrs.value(
"z" ).toString().toDouble();
667 csolute.
c = xattrs.value(
"c" ).toString().toDouble();
678 if ( xmli.hasError() )
680 QMessageBox::critical(
this, tr(
"XML Invalid" ),
681 tr(
"File \"%1\" is not a valid XML file." ).arg( fname ) );
685 else if ( ! is_bfmf )
687 QMessageBox::critical(
this, tr(
"File Type Error" ),
688 tr(
"File \"%1\" is not a PcsaBestFinalModel XML file." )
707 tr(
"A new Best Final Model has been loaded from file\n"
708 " \"%1\", of directory\n \"%2\".\n"
709 "The %3 model has %4 computed solutes\n"
710 " and an RMSD of %5" )
711 .arg( fname ).arg( fdir).arg( sctype ).arg( ncsols ).arg(
mrec.
rmsd ) );
724 DbgLv(1) <<
"store_bfm";
726 QString store_file =
store_dir +
"/pcsa-bfm-new_bfm.xml";
727 store_file = QFileDialog::getSaveFileName(
this,
728 tr(
"Specify XML File Name for Best Final Model Store" ),
store_dir,
729 tr(
"Best Final Model files (*pcsa-bfm-*.xml);;"
730 "Any XML files (*.xml);;Any files (*)" ) );
732 if ( store_file.isEmpty() )
737 store_file = store_file.replace(
"\\",
"/" );
738 QString fdir = store_file.section(
"/", 0, -2 ) +
"/";
739 QString fname = store_file.section(
"/", -1, -1 );
742 if ( store_file.endsWith(
"." ) )
744 store_file = store_file.left( store_file.length() - 1 );
745 fname = fname .left( fname .length() - 1 );
748 else if ( ! store_file.endsWith(
".xml" ) )
750 store_file = store_file +
".xml";
751 fname = fname +
".xml";
754 if ( fname.startsWith(
"." ) )
756 store_file = fdir + fname.mid( 1 );
759 else if ( ! fname.startsWith(
"pcsa-bfm-" ) )
761 store_file = fdir +
"pcsa-bfm-" + fname;
765 QFile fileo( store_file );
767 if ( !fileo.open( QIODevice::WriteOnly | QIODevice::Text ) )
769 QMessageBox::critical(
this, tr(
"Open Error" ),
770 tr(
"Cannot open file %1 ." ).arg( store_file ) );
783 QXmlStreamWriter xmlo;
784 xmlo.setDevice( &fileo );
785 xmlo.setAutoFormatting(
true );
786 xmlo.writeStartDocument(
"1.0" );
787 xmlo.writeComment(
"DOCTYPE PcsaBestFinalModel" );
788 xmlo.writeCharacters(
"\n" );
789 xmlo.writeStartElement(
"modelrecord" );
790 xmlo.writeAttribute(
"version",
"1.0" );
791 xmlo.writeAttribute(
"type", QString::number(
ctype ) );
792 xmlo.writeAttribute(
"xmin", QString::number( xmin ) );
793 xmlo.writeAttribute(
"xmax", QString::number( xmax ) );
794 xmlo.writeAttribute(
"ymin", QString::number( ymin ) );
795 xmlo.writeAttribute(
"ymax", QString::number( ymax ) );
796 xmlo.writeAttribute(
"curve_points", QString::number( kisols ) );
797 xmlo.writeAttribute(
"taskx", QString::number(
mrec.
taskx ) );
798 xmlo.writeAttribute(
"start_y", QString::number(
mrec.
str_y ) );
799 xmlo.writeAttribute(
"end_y", QString::number(
mrec.
end_y ) );
800 xmlo.writeAttribute(
"par1", QString::number(
mrec.
par1 ) );
801 xmlo.writeAttribute(
"par2", QString::number(
mrec.
par2 ) );
802 xmlo.writeAttribute(
"par3", QString::number(
mrec.
par3 ) );
803 xmlo.writeAttribute(
"rmsd", QString::number(
mrec.
rmsd ) );
805 for (
int cc = 0; cc <
ncsols; cc++ )
807 xmlo.writeStartElement(
"c_solute" );
809 xmlo.writeAttribute(
"x", QString::number( sval ) );
810 xmlo.writeAttribute(
"y", QString::number(
mrec.
csolutes[ cc ].y ) );
811 xmlo.writeAttribute(
"z", QString::number(
mrec.
csolutes[ cc ].z ) );
812 xmlo.writeAttribute(
"c", QString::number(
mrec.
csolutes[ cc ].c ) );
813 xmlo.writeEndElement();
816 xmlo.writeEndElement();
817 xmlo.writeEndDocument();
821 fdir = store_file.section(
"/", 0, -2 ) +
"/";
822 fname = store_file.section(
"/", -1, -1 );
825 tr(
"The Best Final Model has been stored in file\n"
826 " \"%1\", of directory\n \"%2\"." )
827 .arg( fname ).arg( fdir),
true );
833 DbgLv(1) <<
"reset_bfm";
837 stat_bfm( tr(
"Best Final Model has been reset to original state." ) );
843 stat_bfm( tr(
"An initial best final model, with RMSD of %1,"
844 " has been restored." ).arg(
mrec.
rmsd ),
true );
849 stat_bfm( tr(
"The initial empty best final model\n"
850 " has been restored." ),
true );
860 DbgLv(1) <<
"reset_mrecs";
865 stat_mrecs( tr(
"Model Records have been reset to original state." ) );
869 stat_mrecs( tr(
"An initial model records list, with %1 fits,\n"
870 " has been restored." ).arg(
nmrecs ),
true );
875 stat_mrecs( tr(
"The initial empty model records list\n"
876 " has been restored." ),
true );
887 DbgLv(1) <<
"build_bfm";
893 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
894 stat_bfm( tr(
"A new Best Final Model is being built ..." ) );
943 if (
mrecs.size() > 0 )
951 QList< US_SolveSim::DataSet* > dsets;
973 tr(
"A new Best Final Model has been built\n"
974 " from the specified fitting controls.\n"
975 "The %1 model has %2 computed solutes\n"
976 " and an RMSD of %3" )
980 tr(
"A new best final %1-solute model ( RMSD = %2 )\n"
981 " now occupies the top curve model records list spot." )
988 QApplication::restoreOverrideCursor();
989 qApp->processEvents();
1000 DbgLv(1) <<
"start_montecarlo";
1004 stat_bfm( tr(
"%1 Monte Carlo iterations are being computed..." )
1016 double ymin_p =
le_y_lower ->text().toDouble();
1017 double ymax_p =
le_y_upper ->text().toDouble();
1018 double difp1 = qAbs( ( par1_m - par1_p ) / par1_m );
1019 double difp2 = qAbs( ( par2_m - par2_p ) / par2_m );
1020 double dymin = qAbs( ( ymin_m - ymin_p ) / ymin_m );
1021 double dymax = qAbs( ( ymax_m - ymax_p ) / ymax_m );
1023 if ( nsol_p != nsol_m || difp1 > 1.0e-4 || difp2 > 1.0e-4 ||
1024 dymin > 1.0e-4 || dymin > 1.0e-4 )
1031 DbgLv(1) <<
" MC reset curves: p1_m p2_m p1_p p2_p ns_m ns_p"
1032 << par1_m << par2_m << par1_p << par2_p << nsol_m << nsol_p;
1033 DbgLv(1) <<
" MC reset curves: dp1 dp2 sdp1 sdp2"
1034 << difp1 << difp2 << (par1_m-par1_p) << (par2_m-par2_p);
1035 DbgLv(1) <<
" MC reset curves: dyl dyh sdyl sdyh"
1036 << dymin << dymax << (ymin_m-ymin_p) << (ymax_m-ymax_p);
1044 QList< US_SolveSim::DataSet* > dsets;
1047 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
1053 for (
int iter = 0; iter <
mciters; iter++ )
1058 dsets[ 0 ]->run_data =
wdata;
1087 tr(
"%1 are completed ( last: %2-solute, RMSD=%3 )" )
1088 .arg(
kciters ).arg(
ncsols ).arg( mrec_mc.rmsd ),
true, 1 );
1090 qApp->processEvents();
1095 qApp->processEvents();
1099 QApplication::restoreOverrideCursor();
1100 qApp->processEvents();
1106 tr(
"%1 Monte Carlo iterations are being"
1107 " computed in %2 threads..." ).arg(
mciters ).arg(
nthr ) );
1112 dsets[ 0 ]->run_data =
wdata;
1125 <<
"ncsols" <<
ncsols <<
"res tskx,thrn" << 1 << 0;
1127 tr(
"%1 are completed ( last: %2-solute, RMSD=%3 )" )
1130 qApp->processEvents();
1143 wtbase.
dsets = dsets;
1148 for (
int jt = 0; jt <
nthr; jt++ )
1154 for (
int jt = 0; jt <
nthr; jt++ )
1162 wtask.
thrn = jt + 1;
1163 wtask.
taskx = jt + 1;
1193 DbgLv(1) <<
"AA: set_gaus: gausmoo" << gausmoo;
1199 for (
int ss = 0; ss < nscans; ss++ )
1201 QVector< double > vv( npoints );
1203 for (
int rr = 0; rr < npoints; rr++ )
1205 vv[ rr ] = qAbs( rdata->
value( ss, rr ) );
1221 int ntpoints = nscans * npoints;
1223 for (
int rr = 0; rr < ntpoints; rr++ )
1226 rmsds = sqrt( rmsds / (
double)ntpoints );
1227 double sigscl = rmsdi / rmsds;
1229 for (
int rr = 0; rr < ntpoints; rr++ )
1231 DbgLv(1) <<
"AA: gausmoo: rmsd-i rmsc-s sigscl" << rmsdi << rmsds << sigscl;
1246 for (
int ss = 0; ss < nscans; ss++ )
1248 for (
int rr = 0; rr < npoints; rr++ )
1269 <<
"ncsols" <<
ncsols <<
"res tskx,thrn" << wresult.
taskx << wresult.
thrn;
1272 tr(
"%1 are completed ( last: %2-solute, RMSD=%3 )" )
1275 qApp->processEvents();
1285 QApplication::restoreOverrideCursor();
1286 qApp->processEvents();
1292 DbgLv(1) <<
" ksiters" <<
ksiters <<
" apply_gaussians";
1318 DbgLv(1) <<
"==montecarlo_done()==";
1319 stat_bfm( tr(
"Building MC models and final composite..." ),
true );
1322 QVector< US_ZSolute > compsols;
1323 QStringList sortlst;
1326 QStringList mfnames;
1334 + QDateTime::currentDateTime().toUTC()
1335 .toString(
"yyMMddhhmm" );
1336 QString analysType =
"PCSA-SL-MC";
1337 analysType = ( ctype ==
CTYPE_IS ) ?
"PCSA-IS-MC" : analysType;
1338 analysType = ( ctype ==
CTYPE_DS ) ?
"PCSA-DS-MC" : analysType;
1339 analysType = ( ctype ==
CTYPE_HL ) ?
"PCSA-HL-MC" : analysType;
1340 analysType = ( ctype ==
CTYPE_2O ) ?
"PCSA-2O-MC" : analysType;
1341 QString analysID = dates +
"_" + analysType +
"_local_";
1342 QString base_mdesc = runID +
"." + tripID +
"." + analysID;
1350 for (
int jmc = 0; jmc <
mciters; jmc++ )
1354 int nsols = csolutes.size();
1357 for (
int cc = 0; cc < nsols; cc++ )
1361 double sol_x = csolutes[ cc ].x;
1362 double sol_y = csolutes[ cc ].y;
1363 double sol_z = csolutes[ cc ].z;
1364 double sol_c = csolutes[ cc ].c;
1365 QString sol_id = QString().sprintf(
"%.4f:%.4f:%d",
1366 sol_x * 1.e13, sol_y, nccsol++ );
1367 DbgLv(1) <<
"MCD: cc" << cc <<
"sol_id" << sol_id;
1375 compsols << compsol;
1399 QString iterID = QString().sprintf(
"mc%04d", jmc + 1 );
1411 QString pskmatch = QString();
1413 double cnorm = 1.0 / (double)mciters;
1416 for (
int cc = 0; cc < nccsol; cc++ )
1418 QString sol_id = sortlst[ cc ];
1419 QString skmatch = sol_id.section(
":", 0, 1 );
1420 int ccin = sol_id.section(
":", 2, 2 ).toInt();
1421 ccompsol = compsols[ ccin ];
1423 if ( skmatch != pskmatch )
1427 pcompsol.
c *= cnorm;
1432 pcompsol = ccompsol;
1434 DbgLv(1) <<
"MCD: cc ccin ncsols" << cc << ccin <<
ncsols;
1439 pcompsol.
c += ccompsol.
c;
1444 pcompsol.
c *= cnorm;
1456 for (
int cc = 0; cc <
ncsols; cc++ )
1481 for (
int cc = 0; cc <
ncsols; cc++ )
1503 for (
int ss = 0; ss < nscans; ss++ )
1507 for (
int rr = 0; rr < npoints; rr++ )
1511 - rinoi - tinoi ) );
1515 varia /= (double)( nscans * npoints );
1523 tr(
"MC models and final %1-solute composite model are built." )
1524 .arg( ncsols ),
true );
1527 tr(
"A new best final %1-solute model ( RMSD = %2 )\n"
1528 " now occupies the top curve model records list spot." )
1529 .arg( ncsols ).arg(
mrec.
rmsd ),
true );
1540 QMessageBox::information(
this, tr(
"UNDER CONSTRUCTION" ),
1541 tr(
"Implementation of <b>%1</b> is not yet complete." ).arg( proc ) );
1549 int stype = mrec.
stype;
1550 int attr_x = ( stype >> 6 ) & 7;
1551 int attr_y = ( stype >> 3 ) & 7;
1554 double xmin = mrec.
xmin;
1555 double xmax = mrec.
xmax;
1556 double ymin = mrec.
ymin;
1557 double ymax = mrec.
ymax;
1558 double prng = (double)( nisols - 1 );
1559 double xrng = xmax - xmin;
1560 double xinc = xrng / prng;
1561 double par1 = mrec.
par1;
1562 double par2 = mrec.
par2;
1563 double xoinc = 1.0 / prng;
1565 DbgLv(1) <<
"AA:CP: xinc" << xinc <<
"ctype" <<
ctype;
1569 double ydif = ymax - ymin;
1570 double p1rt = sqrt( 2.0 * par1 );
1572 for (
int kk = 0; kk <
nisols; kk++ )
1574 double xval = xmin + xoff * xrng;
1575 double efac = 0.5 * erf( ( xoff - par2 ) / p1rt ) + 0.5;
1576 double yval = ymin + ydif * efac;
1577 mrec.
isolutes[ kk ].x = xval * xscl;
1578 mrec.
isolutes[ kk ].y = yval * yscl;
1585 double yval = mrec.
str_y;
1586 double yinc = ( mrec.
end_y - mrec.
str_y ) / prng;
1589 for (
int kk = 0; kk <
nisols; kk++ )
1591 mrec.
isolutes[ kk ].x = xval * xscl;
1592 mrec.
isolutes[ kk ].y = yval * yscl;
1596 DbgLv(1) <<
"AA:CP: ni" << nisols <<
"last yv" << yval;
1601 double ydif = ymin - ymax;
1602 double p1rt = sqrt( 2.0 * par1 );
1604 for (
int kk = 0; kk <
nisols; kk++ )
1606 double xval = xmin + xoff * xrng;
1607 double efac = 0.5 * erf( ( xoff - par2 ) / p1rt ) + 0.5;
1608 double yval = ymax + ydif * efac;
1609 mrec.
isolutes[ kk ].x = xval * xscl;
1610 mrec.
isolutes[ kk ].y = yval * yscl;
1617 double yval = mrec.
end_y;
1620 for (
int kk = 0; kk <
nisols; kk++ )
1622 mrec.
isolutes[ kk ].x = xval * xscl;
1623 mrec.
isolutes[ kk ].y = yval * yscl;
1626 DbgLv(1) <<
"AA:CP: ni" << nisols <<
"last yv" << yval;
1643 double bval = ( ( mrec.
str_y - cval ) / qMax( 0.00001, aval ) )
1646 for (
int kk = 0; kk <
nisols; kk++ )
1648 double yval = aval * pow( xval, bval ) + cval;
1649 mrec.
isolutes[ kk ].x = xval * xscl;
1650 mrec.
isolutes[ kk ].y = yval * yscl;
1676 for (
int cc = 0; cc <
ncsols; cc++ )
1706 for (
int ss = 0; ss < nscans; ss++ )
1708 for (
int rr = 0; rr < npoints; rr++ )
1711 varia +=
sq( rval );
1716 varia /= (double)( nscans * npoints );
1717 double rmsd = sqrt( varia );
1719 if ( rmsd > rmsdsv && rmsd >
mrecs[ 3 ].rmsd )
1760 bool append,
int aft_line )
1764 QString sttext = tedit->toPlainText();
1768 QStringList stlines = sttext.split(
"\n" );
1771 for (
int ii = 0; ii < qMin( aft_line, stlines.size() ); ii++ )
1773 sttext += stlines[ ii ] +
"\n";
1782 tedit->setText( sttext + msg );
1787 tedit->setText( msg );
1799 int stype = s_mrec.
stype;
1800 int attr_x = ( stype >> 6 ) & 7;
1801 int attr_y = ( stype >> 3 ) & 7;
1805 double xmin = s_mrec.
xmin;
1806 double xmax = s_mrec.
xmax;
1807 double ymin = s_mrec.
ymin;
1808 double ymax = s_mrec.
ymax;
1809 ctype = s_mrec.
ctype;
1810 DbgLv(1) <<
"AA:SF: ctype x,y min,max" << ctype << xmin << xmax
1818 for (
int ii = 0; ii <
nmrecs; ii++ )
1820 s_mrec = s_mrecs[ ii ];
1821 ymin = qMin( ymin, s_mrec.
str_y );
1822 ymax = qMax( ymax, s_mrec.
end_y );
1825 for (
int jj = 0; jj <
nisols; jj++ )
1827 double xval = s_mrec.
isolutes[ jj ].x * xscl;
1828 double yval = s_mrec.
isolutes[ jj ].y * yscl;
1829 xmin = qMin( xmin, xval );
1830 xmax = qMax( xmax, xval );
1831 ymin = qMin( ymin, yval );
1832 ymax = qMax( ymax, yval );
1833 if(xval==0.0 || yval==0.0)
1834 DbgLv(1) <<
"AA:SF: ii jj ni" << ii << jj << nisols <<
"x y" << xval << yval;
1840 ctypex = ( ctype ==
CTYPE_SL ) ? 0 : ctypex;
1841 ctypex = ( ctype ==
CTYPE_IS ) ? 1 : ctypex;
1842 ctypex = ( ctype ==
CTYPE_DS ) ? 2 : ctypex;
1843 ctypex = ( ctype ==
CTYPE_HL ) ? 3 : ctypex;
1844 ctypex = ( ctype ==
CTYPE_2O ) ? 4 : ctypex;
1846 le_x_lower ->setText( QString::number( xmin ) );
1847 le_x_upper ->setText( QString::number( xmax ) );
1848 le_y_lower ->setText( QString::number( ymin ) );
1849 le_y_upper ->setText( QString::number( ymax ) );
1851 DbgLv(1) <<
"AA:SF: (2) x,y min,max" << ctype << xmin << xmax << ymin << ymax;
1858 bool needMrs = (
mrecs.size() < 2 ||
mrecs[ 1 ].csolutes.size() < 1 );
1863 QMessageBox::critical(
this, tr(
"Invalid Operation" ),
1864 tr(
"<b>%1</b> is not a valid operation<br/>"
1865 " when no Model Records have been computed.<br/>"
1866 "Your options at this point are:"
1867 "<ul><li>Go back to the main analysis controls window and do"
1868 " a fit with <b>Start Fit</b>, then return here to retry; or"
1869 "</li><li>Do a <b>Load Model Records</b> here, and then\n"
1870 " retry this operation.</li></ul>" ).arg( oper ) );
1880 bool inCompat =
false;
1887 int rtype =
mrecs[ 1 ].ctype;
1888 double rxmin =
mrecs[ 1 ].xmin;
1889 double rxmax =
mrecs[ 1 ].xmax;
1890 double rymin =
mrecs[ 1 ].ymin;
1891 double rymax =
mrecs[ 1 ].ymax;
1892 DbgLv(1) <<
"AA:BI: ftype rtype" << ftype << rtype <<
"fname" << fname;
1894 inCompat = ( inCompat || ( ftype != rtype ) );
1895 DbgLv(1) <<
"AA:BI: (1)inCompat" << inCompat;
1896 inCompat = ( inCompat || ( fxmin > rxmax ) );
1897 inCompat = ( inCompat || ( fxmax < rxmin ) );
1898 inCompat = ( inCompat || ( fymin > rymax ) );
1899 inCompat = ( inCompat || ( fymax < rymin ) );
1900 DbgLv(1) <<
"AA:BI: (5)inCompat" << inCompat;
1904 const char* ctps[] = {
"Straight Line",
1905 "Increasing Sigmoid",
1906 "Decreasing Sigmoid",
1907 "Horizontal Line" };
1909 ftx = ( ftype ==
CTYPE_SL ) ? 0 : ftx;
1910 ftx = ( ftype ==
CTYPE_IS ) ? 1 : ftx;
1911 ftx = ( ftype ==
CTYPE_DS ) ? 2 : ftx;
1912 ftx = ( ftype ==
CTYPE_HL ) ? 3 : ftx;
1914 rtx = ( rtype ==
CTYPE_SL ) ? 0 : rtx;
1915 rtx = ( rtype ==
CTYPE_IS ) ? 1 : rtx;
1916 rtx = ( rtype ==
CTYPE_DS ) ? 2 : rtx;
1917 rtx = ( rtype ==
CTYPE_HL ) ? 3 : rtx;
1918 QString fpars = QString( ctps[ ftx ] )
1919 + tr(
" ; s %1 to %2 ; f/f0 %3 to %4" )
1920 .arg( fxmin ).arg( fxmax ).arg( fymin ).arg( fymax );
1921 QString rpars = QString( ctps[ rtx ] )
1922 + tr(
" ; s %1 to %2 ; f/f0 %3 to %4" )
1923 .arg( rxmin ).arg( rxmax ).arg( rymin ).arg( rymax );
1925 QMessageBox::critical(
this, tr(
"Incompatible Final Model" ),
1926 tr(
"File <b>%1</b> has fitting controls incompatible<br/>"
1927 " with the existing model records."
1928 "<ul><li>File: %2.</li>"
1929 "<li>Records: %3.</li></ul>" )
1930 .arg( fname ).arg( fpars ).arg( rpars ) );
1948 qry <<
"count_mrecs" << invID;
1949 qDebug() <<
"QRY:" << qry;
1951 qDebug() <<
" nmrec" << nmrec;
1955 qry <<
"get_mrecs_desc" << invID;
1956 qDebug() <<
"QRY:" << qry;
1960 qDebug() <<
" numRows" << dbP->
numRows();
1962 while ( dbP->
next() )
1964 int mrID = dbP->
value( 0 ).toInt();
1965 mrID1 = ( mrID1 < 0 ) ? mrID : mrID1;
1966 QString mrGUID = dbP->
value( 1 ).toString();
1967 int edID = dbP->
value( 2 ).toInt();
1968 QString edGUID = dbP->
value( 3 ).toString();
1969 int moID = dbP->
value( 4 ).toInt();
1970 QString moGUID = dbP->
value( 5 ).toString();
1971 QString descr = dbP->
value( 6 ).toString();
1972 QString cksm = dbP->
value( 7 ).toString();
1973 QString size = dbP->
value( 8 ).toString();
1974 QString utime = dbP->
value( 9 ).toString();
1975 qDebug() <<
" mrID mrGUID" << mrID << mrGUID;
1976 qDebug() <<
" edID edGUID" << edID << edGUID;
1977 qDebug() <<
" moID moGUID" << moID << moGUID;
1978 qDebug() <<
" desc" << descr;
1979 qDebug() <<
" cksm size" << cksm << size;
1980 qDebug() <<
" utime" << utime;
1985 qry <<
"get_mrecs_desc" <<
"0";
1986 qDebug() <<
"QRY:" << qry;
1990 qDebug() <<
" numRows" << dbP->
numRows();
1992 while ( dbP->
next() )
1994 int mrID = dbP->
value( 0 ).toInt();
1995 QString mrGUID = dbP->
value( 1 ).toString();
1996 int edID = dbP->
value( 2 ).toInt();
1997 QString edGUID = dbP->
value( 3 ).toString();
1998 int moID = dbP->
value( 4 ).toInt();
1999 QString moGUID = dbP->
value( 5 ).toString();
2000 QString descr = dbP->
value( 6 ).toString();
2001 QString cksm = dbP->
value( 7 ).toString();
2002 QString size = dbP->
value( 8 ).toString();
2003 QString utime = dbP->
value( 9 ).toString();
2004 qDebug() <<
" mrID mrGUID" << mrID << mrGUID;
2005 qDebug() <<
" edID edGUID" << edID << edGUID;
2006 qDebug() <<
" moID moGUID" << moID << moGUID;
2007 qDebug() <<
" desc" << descr;
2008 qDebug() <<
" cksm size" << cksm << size;
2009 qDebug() <<
" utime" << utime;
2020 qry <<
"get_editID" << edGUID;
2021 qDebug() <<
"QRY:" << qry;
2023 QString editID = dbP->
value( 0 ).toString();
2024 qDebug() <<
" editID edGUID" << editID << edGUID;
2027 qry <<
"count_mrecs_by_editID" << invID << editID;
2028 qDebug() <<
"QRY:" << qry;
2030 qDebug() <<
" nmredt" << nmredt;
2034 qry <<
"get_mrecs_desc_by_editID" << invID << editID;
2035 qDebug() <<
"QRY:" << qry;
2039 qDebug() <<
" numRows" << dbP->
numRows();
2041 while ( dbP->
next() )
2043 int mrID = dbP->
value( 0 ).toInt();
2044 QString mrGUID = dbP->
value( 1 ).toString();
2045 int edID = dbP->
value( 2 ).toInt();
2046 QString edGUID = dbP->
value( 3 ).toString();
2047 int moID = dbP->
value( 4 ).toInt();
2048 QString moGUID = dbP->
value( 5 ).toString();
2049 QString descr = dbP->
value( 6 ).toString();
2050 QString cksm = dbP->
value( 7 ).toString();
2051 QString size = dbP->
value( 8 ).toString();
2052 QString utime = dbP->
value( 9 ).toString();
2053 qDebug() <<
" mrID mrGUID" << mrID << mrGUID;
2054 qDebug() <<
" edID edGUID" << edID << edGUID;
2055 qDebug() <<
" moID moGUID" << moID << moGUID;
2056 qDebug() <<
" desc" << descr;
2057 qDebug() <<
" cksm size" << cksm << size;
2058 qDebug() <<
" utime" << utime;
2068 qry <<
"get_mrecs_info" << QString::number( mrID1 );
2069 qDebug() <<
"QRY:" << qry;
2073 qDebug() <<
" numRows" << dbP->
numRows();
2076 QString mrGUID = dbP->
value( 0 ).toString();
2077 QString xmlstr = dbP->
value( 1 ).toString();
2078 int edID = dbP->
value( 2 ).toInt();
2079 QString edGUID = dbP->
value( 3 ).toString();
2080 int moID = dbP->
value( 4 ).toInt();
2081 QString moGUID = dbP->
value( 5 ).toString();
2082 QString descr = dbP->
value( 6 ).toString();
2083 QString cksm = dbP->
value( 7 ).toString();
2084 int xsize = dbP->
value( 8 ).toInt();
2085 QString utime = dbP->
value( 9 ).toString();
2086 qDebug() <<
" mrID mrGUID" << mrID1 << mrGUID;
2087 qDebug() <<
" edID edGUID" << edID << edGUID;
2088 qDebug() <<
" moID moGUID" << moID << moGUID;
2089 qDebug() <<
" desc" << descr;
2090 qDebug() <<
" cksm size" << cksm << xsize <<
"xml len" << xmlstr.length();
2091 QString xmls1 = QString( xmlstr ).left ( 1600 );
2092 QString xmls2 = QString( xmlstr ).right( 1600 );
2093 qDebug() <<
"==== XML1" << xmls1 <<
"XML1 ======";
2094 qDebug() <<
"==== XML2" << xmls2 <<
"XML2 ======";