[Echempp-devel] GUI/Windows/Qt/EChem++/Model Makefile.am, 1.43, 1.44 batchExperimentDialog.cpp, 1.1
Status: Beta
Brought to you by:
berndspeiser
Update of /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv26240/GUI/Windows/Qt/EChem++/Model Modified Files: Makefile.am batchExperimentDialog.cpp equilibriumDialog.cpp equilibriumDialog.hpp experimentDialog.cpp experimentDialog.hpp mechanismDialog.cpp mechanismDialog.hpp mediator.cpp mediator.hpp modelMainWindow.cpp modelMainWindow.hpp modelParametersDialog.cpp modelParametersDialog.hpp modelPlotWidget.cpp modelPlotWidget.hpp scalingDialog.cpp scalingDialog.hpp solverDialog.cpp solverDialog.hpp svmDataDialog.cpp Log Message: Removed obsolete serialization code and old supply() functions. There should be no more ref. to TinyXML any more. Index: modelPlotWidget.hpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/modelPlotWidget.hpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** modelPlotWidget.hpp 3 Mar 2007 19:34:59 -0000 1.36 --- modelPlotWidget.hpp 22 Dec 2007 15:53:16 -0000 1.37 *************** *** 249,253 **** const std::string& type ); ! void saveActiveData( BSUtilities::xmlw::XmlStream& xml ); void removePlot( uint_t pos ); --- 249,253 ---- const std::string& type ); ! void saveActiveData( const QString& fileName ); void removePlot( uint_t pos ); Index: equilibriumDialog.hpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/equilibriumDialog.hpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** equilibriumDialog.hpp 19 Dec 2007 11:52:45 -0000 1.20 --- equilibriumDialog.hpp 22 Dec 2007 15:53:16 -0000 1.21 *************** *** 36,41 **** #include "Model/guiTypes.hpp" - #include "xmlwriter.h" - #include <qprogressdialog.h> #include <qlineedit.h> --- 36,39 ---- *************** *** 63,68 **** void supply(); - void supply( const QDomElement& dialog ); - void save( BSUtilities::xmlw::XmlStream& xml ); void setReactionNetwork( ecco::ReactionNetwork* const net ); --- 61,64 ---- Index: scalingDialog.hpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/scalingDialog.hpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** scalingDialog.hpp 25 Mar 2006 10:40:32 -0000 1.14 --- scalingDialog.hpp 22 Dec 2007 15:53:16 -0000 1.15 *************** *** 37,43 **** #include "Ecco/reactionNetwork.hpp" - #include "xmlwriter.h" - #include <qdom.h> - #include <vector> --- 37,40 ---- *************** *** 55,64 **** ~ScalingDialog(); - //! - void supply( const QDomElement& dialog ); - - //! - void save( BSUtilities::xmlw::XmlStream& xml); - //! use "PC" for potential controlled or "CC" fo current controlled void setTechnique( const std::string& tech ); --- 52,55 ---- *************** *** 89,95 **** private: - //! - void setConcentrationTolerances( const QDomElement& root ); - //! index = row index QMemArray<int> _concRows; --- 80,83 ---- Index: mediator.hpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/mediator.hpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** mediator.hpp 19 Dec 2007 11:52:48 -0000 1.41 --- mediator.hpp 22 Dec 2007 15:53:16 -0000 1.42 *************** *** 86,92 **** void supply(); - void readProjectFile( const QString& fileName ); - void writeProjectFile( const QString& fileName ); - void writeDataFile( const QString& fileName ); --- 86,89 ---- Index: Makefile.am =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/Makefile.am,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Makefile.am 19 Dec 2007 11:51:20 -0000 1.43 --- Makefile.am 22 Dec 2007 15:53:16 -0000 1.44 *************** *** 289,293 **** # in a similar way, -Werror should later be re-introduced here; it has to be deleted because # of `deprecated' warnings generated by vtk 5.0 ! ModSim_CXXFLAGS = -DTIXML_USE_STL $(CXXFLAGS) $(QT_CXXFLAGS) -Wall -pedantic-errors\ -Wno-non-virtual-dtor -Wno-deprecated -Wno-long-long -Wno-strict-aliasing --- 289,293 ---- # in a similar way, -Werror should later be re-introduced here; it has to be deleted because # of `deprecated' warnings generated by vtk 5.0 ! ModSim_CXXFLAGS = $(CXXFLAGS) $(QT_CXXFLAGS) -Wall -pedantic-errors\ -Wno-non-virtual-dtor -Wno-deprecated -Wno-long-long -Wno-strict-aliasing Index: scalingDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/scalingDialog.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** scalingDialog.cpp 26 Mar 2007 17:05:32 -0000 1.17 --- scalingDialog.cpp 22 Dec 2007 15:53:16 -0000 1.18 *************** *** 231,427 **** } - void - ScalingDialog::save( BSUtilities::xmlw::XmlStream& xml ) - { - // <scaling_dialog> - // <concentration rows="3"> - // <cd> - // <name>A</name> - // <ATOL>1.0</ATOL> - // <RTOL>1.0</RTOL> - // </cd> - // <cd> - // <name>B</name> - // <ATOL>1.0</ATOL> - // <RTOL>1.0</RTOL> - // </cd> - // <cd> - // <name>C</name> - // <ATOL>1.0</ATOL> - // <RTOL>1.0</RTOL> - // </cd> - // </concentration> - // <response type="Current" ATOL="..." RTOL="..."> - // </response> - // </scaling_dialog> - - xml << BSUtilities::xmlw::tag("scaling_dialog") - - << BSUtilities::xmlw::tag("concentration") - << BSUtilities::xmlw::attr("rows") << _concTable->numRows(); - - int i=0; - while( i < _concTable->numRows() ) - { - xml << BSUtilities::xmlw::tag("cd") - - << BSUtilities::xmlw::tag("name") - << BSUtilities::xmlw::chardata() << _concTable->verticalHeader()->label(i).ascii() - << BSUtilities::xmlw::endtag("name") - - << BSUtilities::xmlw::tag("ATOL") - << BSUtilities::xmlw::chardata() << _concTable->text(i,0).ascii() - << BSUtilities::xmlw::endtag("ATOL") - - << BSUtilities::xmlw::tag("RTOL") - << BSUtilities::xmlw::chardata() << _concTable->text(i,1).ascii() - << BSUtilities::xmlw::endtag("RTOL") - - << BSUtilities::xmlw::endtag("cd"); - - ++i; - } - xml << BSUtilities::xmlw::endtag("concentration"); - - xml << BSUtilities::xmlw::tag("response") - << BSUtilities::xmlw::attr("type") << _responseGroup->title().ascii() - << BSUtilities::xmlw::attr("ATOL") << _resATOLEdit->text().ascii() - << BSUtilities::xmlw::attr("RTOL") << _resRTOLEdit->text().ascii() - - << BSUtilities::xmlw::endtag("response"); - - xml << BSUtilities::xmlw::endtag("scaling_dialog"); - - } - - void - ScalingDialog::supply( const QDomElement& dialog ) - { - if( !(dialog.nodeName() == "scaling_dialog") ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "No scaling_dialog node given to ScalingDialog::supply()" ) ); - return; - } - - QDomNode node = dialog.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() & (node.nodeName() == "concentration") ) - { - QDomElement conc = node.toElement(); - QString rows = conc.attribute("rows"); - int N = rows.toInt(); - - _concTable->removeRows( _concRows ); - _concRows.resize(N); - _rowCounter = 0; - this->setConcentrationTolerances( conc ); - } - else if( node.isElement() & (node.nodeName() == "response") ) - { - QDomElement resp = node.toElement(); - - QString type = resp.attribute("type"); - QString ATOL = resp.attribute("ATOL"); - QString RTOL = resp.attribute("RTOL"); - - _responseGroup->setTitle( type ); - _resATOLEdit->setText( ATOL ); - _resRTOLEdit->setText( RTOL ); - - bool ok = false; - double value = _resATOLEdit->text().toDouble(&ok); - if( ok ) - { - _resATOL = value; - } - else - { - QMessageBox::critical( 0, "Critical Error", - "XML error in ScalingDialog::supply()!", - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton ); - } - - ok = false; - value = _resRTOLEdit->text().toDouble(&ok); - if( ok ) - { - _resRTOL = value; - } - else - { - QMessageBox::critical( 0, "Critical Error", - "XML error in ScalingDialog::supply()!", - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton ); - } - - - } - - node = node.nextSibling(); - } - } - - void - ScalingDialog::setConcentrationTolerances( const QDomElement& root ) - { - QDomNode node = root.firstChild(); - while( !node.isNull() ) - { - if( node.nodeName() == "cd" ) - { - // get name - QDomNodeList childs = node.childNodes(); - uint i = 0; - for(;i<childs.length();++i) - { - QDomNode entry = childs.item(i); - if( entry.isElement() & (entry.nodeName() == "name") ) - { - QDomElement name = entry.toElement(); - QString text = name.text(); - if( text.find("\n") != -1 ) - { - text.remove("\n"); - } - _concTable->insertRows(_rowCounter,1); - _concTable->verticalHeader()->setLabel(_rowCounter,text); - } - else if( entry.isElement() & (entry.nodeName() == "ATOL") ) - { - QDomElement ATOL = entry.toElement(); - QString text = ATOL.text(); - if( text.find("\n") != -1 ) - { - text.remove("\n"); - } - _concTable->setText(_rowCounter,0,text); - } - else if( entry.isElement() & (entry.nodeName() == "RTOL") ) - { - QDomElement RTOL = entry.toElement(); - QString text = RTOL.text(); - if( text.find("\n") != -1 ) - { - text.remove("\n"); - } - _concTable->setText(_rowCounter,1,text); - } - - } - ++_rowCounter; - } - node = node.nextSibling(); - } - } - - - } // namespace Model } // namespace GUI --- 231,234 ---- Index: svmDataDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/svmDataDialog.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** svmDataDialog.cpp 19 Dec 2007 11:56:24 -0000 1.1 --- svmDataDialog.cpp 22 Dec 2007 15:53:16 -0000 1.2 *************** *** 323,346 **** // define class labels experiment::ConditionDataModSim* cond_data = mainWindow->getActiveConditionData(); ! if(cond_data->khs[0] == 10000 && ! cond_data->homForwardRateConstants[1] == 0) // E { labels.push_back(1); std::cout << "label = 1 " << std::endl; } ! if(cond_data->khs[0] != 10000 && ! cond_data->homForwardRateConstants[1] == 0) // Eqr { labels.push_back(2); std::cout << "label = 2 " << std::endl; } ! if(cond_data->khs[0] == 10000 && ! cond_data->homForwardRateConstants[1] != 0) // EC { labels.push_back(3); std::cout << "label = 3 " << std::endl; } ! if(cond_data->khs[0] != 10000 && ! cond_data->homForwardRateConstants[1] != 0) // EqrC { labels.push_back(4); --- 323,346 ---- // define class labels experiment::ConditionDataModSim* cond_data = mainWindow->getActiveConditionData(); ! if(cond_data->mpc.khs[0] == 10000 && ! cond_data->mpc.homForwardRateConstants[1] == 0) // E { labels.push_back(1); std::cout << "label = 1 " << std::endl; } ! if(cond_data->mpc.khs[0] != 10000 && ! cond_data->mpc.homForwardRateConstants[1] == 0) // Eqr { labels.push_back(2); std::cout << "label = 2 " << std::endl; } ! if(cond_data->mpc.khs[0] == 10000 && ! cond_data->mpc.homForwardRateConstants[1] != 0) // EC { labels.push_back(3); std::cout << "label = 3 " << std::endl; } ! if(cond_data->mpc.khs[0] != 10000 && ! cond_data->mpc.homForwardRateConstants[1] != 0) // EqrC { labels.push_back(4); Index: modelPlotWidget.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/modelPlotWidget.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** modelPlotWidget.cpp 25 Mar 2007 17:45:48 -0000 1.59 --- modelPlotWidget.cpp 22 Dec 2007 15:53:16 -0000 1.60 *************** *** 460,468 **** void ! ModelPlotWidget::saveActiveData( BSUtilities::xmlw::XmlStream& xml ) { ! // std::cout << "ModelPlotWidget::saveActiveData()" << std::endl; ! ! xml << BSUtilities::xmlw::tag("model_plot_widget"); try --- 460,466 ---- void ! ModelPlotWidget::saveActiveData( const QString& fileName ) { ! // std::cout << "ModelPlotWidget::saveActiveData()" << std::endl; try *************** *** 475,591 **** VtkGraphs* graph = _page->getGraph(_activeGraph->row,_activeGraph->col); int dim = graph->dimension(); if( dim == 2 ) - { - // QTextStream outStream( outFile ); - - VtkAxisSystem<2>* axisSystem = dynamic_cast<VtkGraph<2>* >(graph)->getAxisSystem(); - std::vector<VtkAxisGroup<2>* > axisGroups = axisSystem->getAxisGroups(); - std::vector<VtkCurve<2>* > curves = axisGroups[0]->getCurves(); - - std::vector<VtkAxis* > axes = axisGroups[0]->getAxes(); - std::string xAxisUnit = axes[0]->getUnit(); - std::string yAxisUnit = axes[1]->getUnit(); - - std::vector<VtkCurve<2>*>::const_iterator p = curves.begin(); - uint_t i=0; - uint_t j=0; - std::vector<std::vector<double> > data; - - xml << BSUtilities::xmlw::tag("data") - - << BSUtilities::xmlw::attr("x_unit") << xAxisUnit - - << BSUtilities::xmlw::attr("y_unit") << yAxisUnit; - - for(;p!=curves.end();++p) { ! (*p)->getValues(data); ! xml << BSUtilities::xmlw::tag("curve") ! ! << BSUtilities::xmlw::attr("ID") << (*p)->getIdentifier() ! ! << BSUtilities::xmlw::attr("size") << data.size() ! ! << BSUtilities::xmlw::chardata() << "<![CDATA[" << "\n"; ! for(i=0;i<data.size();++i) ! { ! for(j=0;j<data[i].size();++j) { ! xml << data[i][j] << " "; } - xml << "\n"; - } - xml << "]]>"; - - xml << BSUtilities::xmlw::endtag("curve"); - - } - - xml << BSUtilities::xmlw::endtag("data"); ! } else if( dim == 3 ) ! { ! // QTextStream outStream( outFile ); ! ! VtkAxisSystem<3>* axisSystem = dynamic_cast<VtkGraph<3>* >(graph)->getAxisSystem(); ! std::vector<VtkAxisGroup<3>* > axisGroups = axisSystem->getAxisGroups(); ! ! std::vector<VtkAxis* > axes = axisGroups[0]->getAxes(); ! std::string xAxisUnit = axes[0]->getUnit(); ! std::string yAxisUnit = axes[1]->getUnit(); ! std::string zAxisUnit = axes[2]->getUnit(); ! std::vector<VtkCurve<3>* > curves = axisGroups[0]->getCurves(); ! std::vector<VtkCurve<3>*>::const_iterator p = curves.begin(); ! uint_t i=0; ! uint_t j=0; ! std::vector<std::vector<double> > data; ! ! xml << BSUtilities::xmlw::tag("data") ! ! << BSUtilities::xmlw::attr("x_unit") << xAxisUnit ! ! << BSUtilities::xmlw::attr("y_unit") << yAxisUnit ! ! << BSUtilities::xmlw::attr("z_unit") << zAxisUnit ! ! << BSUtilities::xmlw::chardata() << "<![CDATA[" << "\n"; ! ! for(;p!=curves.end();++p) ! { ! (*p)->getValues(data); ! xml << "Curve Id:" << (*p)->getIdentifier() << "\n"; ! ! for(i=0;i<data.size();++i) ! { ! for(j=0;j<data[i].size();++j) { ! xml << data[i][j] << " "; } - xml << "\n"; - } } ! ! xml << "]]>" ! ! << BSUtilities::xmlw::endtag("data"); ! ! } } catch( VisualizationError& error ) ! { ! QMessageBox::warning( 0, "Visualization Error", ! error.message().c_str(), ! QMessageBox::Ok, ! QMessageBox::NoButton, ! QMessageBox::NoButton ); ! } ! ! ! xml << BSUtilities::xmlw::endtag("model_plot_widget"); } --- 473,544 ---- VtkGraphs* graph = _page->getGraph(_activeGraph->row,_activeGraph->col); int dim = graph->dimension(); + + experiment::ModelPlotWidgetData mpwd; if( dim == 2 ) { ! VtkAxisSystem<2>* axisSystem = dynamic_cast<VtkGraph<2>* >(graph)->getAxisSystem(); ! std::vector<VtkAxisGroup<2>* > axisGroups = axisSystem->getAxisGroups(); ! std::vector<VtkCurve<2>* > curves = axisGroups[0]->getCurves(); ! std::vector<VtkCurve<2>*>::const_iterator p = curves.begin(); ! std::vector<VtkAxis* > axes = axisGroups[0]->getAxes(); ! mpwd.x_unit = axes[0]->getUnit(); ! mpwd.x_unit = axes[1]->getUnit(); ! mpwd.z_unit = "none"; ! for(;p!=curves.end();++p) { ! (*p)->getValues(mpwd.data); ! mpwd.ids.push_back((*p)->getIdentifier()); } ! } else if( dim == 3 ) ! { ! VtkAxisSystem<3>* axisSystem = dynamic_cast<VtkGraph<3>* >(graph)->getAxisSystem(); ! std::vector<VtkAxisGroup<3>* > axisGroups = axisSystem->getAxisGroups(); ! std::vector<VtkCurve<3>* > curves = axisGroups[0]->getCurves(); ! std::vector<VtkCurve<3>*>::const_iterator p = curves.begin(); + std::vector<VtkAxis* > axes = axisGroups[0]->getAxes(); + mpwd.x_unit = axes[0]->getUnit(); + mpwd.y_unit = axes[1]->getUnit(); + mpwd.z_unit = axes[2]->getUnit(); ! for(;p!=curves.end();++p) { ! (*p)->getValues(mpwd.data); ! mpwd.ids.push_back((*p)->getIdentifier()); } } ! ! std::ofstream ofs_xml(fileName.ascii()); ! if(!ofs_xml) ! { ! QMessageBox::warning( 0, QObject::tr( "I/O Warning" ), ! QObject::tr( "Cannot open file %1" ).arg( fileName.ascii() ) ); ! return; ! } ! boost::archive::xml_oarchive oa_xml(ofs_xml); ! try{ ! oa_xml << BOOST_SERIALIZATION_NVP(mpwd); ! } ! catch(std::exception& e) ! { ! QMessageBox::critical( 0, QObject::tr( "Critical Error" ), ! QObject::tr(e.what()) ); ! ofs_xml.close(); ! return; ! } ! ofs_xml.close(); } catch( VisualizationError& error ) ! { ! QMessageBox::warning( 0, "Visualization Error", ! error.message().c_str(), ! QMessageBox::Ok, ! QMessageBox::NoButton, ! QMessageBox::NoButton ); ! } } Index: experimentDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/experimentDialog.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** experimentDialog.cpp 19 Dec 2007 11:52:45 -0000 1.15 --- experimentDialog.cpp 22 Dec 2007 15:53:16 -0000 1.16 *************** *** 37,42 **** #include "Model/modelError.hpp" - #include "xmlReader.h" - #include <qcombobox.h> #include <qradiobutton.h> --- 37,40 ---- *************** *** 835,958 **** } - void - ExperimentDialog::save( BSUtilities::xmlw::XmlStream& xml ) - { - // e.g. - // <experiment_dialog dim="1" transport="semi-infinite diffusion" safety="3" boundary1="0" boundary2="1"> - // <excitation boundary="0" control="potential" technique="CV" file="/home/kl/echempp/data/excitationEox.xml"/> - // </experiment_dialog> - - - // <experiment_dialog dim="1" transport="finite diffusion" distance="0.005" boundary1="0" boundary2="1"> - // <excitation boundary="0" control="potential" technique="CV" file="/home/kl/echempp/data/excitation3_1.xml"></excitation> - // <excitation boundary="1" control="potential" technique="CV" file="/home/kl/echempp/data/excitation3_2.xml"></excitation> - // </experiment_dialog> - ::experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); - - xml << BSUtilities::xmlw::tag("experiment_dialog") - - << BSUtilities::xmlw::attr("dim") << 1 - - << BSUtilities::xmlw::attr("transport"); - - if( _semiRadioButton->isChecked() ) - { - xml << "semi-infinite diffusion" - << BSUtilities::xmlw::attr("safety") << _cond_data->safety; - } - else if( _finiteRadioButton->isChecked() ) - { - xml << "finite diffusion" - << BSUtilities::xmlw::attr("distance") << _cond_data->finiteDistance - << BSUtilities::xmlw::attr("electrodes"); - - if( _electrodeCheckBox->isChecked() ) - { - xml << 2; - } - else - { - xml << 1; - } - - } - else - { - throw ModelError("Inconsistent transport settings in ExperimentDialog::save()!"); - } - - xml << BSUtilities::xmlw::attr("boundary1") << _cond_data->boundary0 - << BSUtilities::xmlw::attr("boundary2") << _cond_data->boundary1; - - xml << BSUtilities::xmlw::tag("excitation") - - << BSUtilities::xmlw::attr("boundary") << _cond_data->boundary0 - << BSUtilities::xmlw::attr("control") << _controlComboBox0->currentText().ascii() - << BSUtilities::xmlw::attr("technique") << _methodComboBox0->currentText().ascii(); - - if( _cond_data->potentialControlled ) - { - //_cond_data->etExcitation0.save(xml); - - xml << BSUtilities::xmlw::endtag("excitation"); - - if( _finiteRadioButton->isChecked() & _electrodeCheckBox->isChecked() ) - { - xml << BSUtilities::xmlw::tag("excitation") - - << BSUtilities::xmlw::attr("boundary") << _cond_data->boundary1 - << BSUtilities::xmlw::attr("control") << _controlComboBox1->currentText().ascii() - << BSUtilities::xmlw::attr("technique") << _methodComboBox1->currentText().ascii(); - - // _cond_data->etExcitation1.save(xml); - - xml << BSUtilities::xmlw::endtag("excitation"); - } - } - else if( _cond_data->currentControlled ) - { - // _cond_data->itExcitation0.save(xml); - - xml << BSUtilities::xmlw::endtag("excitation"); - - if( _finiteRadioButton->isChecked() & _electrodeCheckBox->isChecked() ) - { - xml << BSUtilities::xmlw::tag("excitation") - - << BSUtilities::xmlw::attr("boundary") << _cond_data->boundary1 - << BSUtilities::xmlw::attr("control") << _controlComboBox1->currentText().ascii() - << BSUtilities::xmlw::attr("technique") << _methodComboBox1->currentText().ascii(); - - // _cond_data->itExcitation1.save(xml); - - xml << BSUtilities::xmlw::endtag("excitation"); - } - } - - - xml << BSUtilities::xmlw::endtag("experiment_dialog"); - - - } - - void - ExperimentDialog::supply( const QDomElement& dialog ) - { - // std::cout << "ExperimentDialog::supply()" << std::endl; - if( !(dialog.nodeName() == "experiment_dialog") ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "No experiment_dialog node given to ExperimentDialog::supply()" ) ); - return; - } - QString dimension = dialog.attribute("dim"); - if( dimension == "1" ) - { - this->createGeometry1D( dialog ); - } - // std::cout << "ExperimentDialog::supply() -- END" << std::endl; - } - void ExperimentDialog::supply() { --- 833,836 ---- Index: modelMainWindow.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/modelMainWindow.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** modelMainWindow.cpp 19 Dec 2007 18:01:34 -0000 1.59 --- modelMainWindow.cpp 22 Dec 2007 15:53:16 -0000 1.60 *************** *** 380,401 **** } - void - ModelMainWindow::loadProject( const std::string& file ) - { - try - { - _mediator->readProjectFile( file ); - } - catch( const ModelError& error ) - { - QMessageBox::warning( 0, "Model Error", - error.message(), - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton ); - } - - } - void ModelMainWindow::readXML(const char* filename) { --- 380,383 ---- *************** *** 437,444 **** try { - // _mediator->readProjectFile( fileName ); readXML(fileName.ascii()); - - this->setCaption("EChem++ - ModSim " + temp ); --- 419,423 ---- *************** *** 485,490 **** ep->set_title(fileName.ascii()); std::ofstream ofs_xml(fileName.ascii()); boost::archive::xml_oarchive oa_xml(ofs_xml); ! oa_xml << BOOST_SERIALIZATION_NVP(ep); ofs_xml.close(); } --- 464,486 ---- ep->set_title(fileName.ascii()); std::ofstream ofs_xml(fileName.ascii()); + if(!ofs_xml) + { + QMessageBox::warning( 0, QObject::tr( "I/O Warning" ), + QObject::tr( "Cannot open file %1" ).arg( fileName.ascii() ) ); + delete fd; + return; + } boost::archive::xml_oarchive oa_xml(ofs_xml); ! try{ ! oa_xml << BOOST_SERIALIZATION_NVP(ep); ! } ! catch(std::exception& e) ! { ! QMessageBox::critical( 0, QObject::tr( "Critical Error" ), ! QObject::tr(e.what()) ); ! ofs_xml.close(); ! delete fd; ! return; ! } ofs_xml.close(); } *************** *** 784,789 **** { // see save project ! _mediator->writeDataFile( fileName ); ! // _plotWidget->exportActiveGraph(file,"txt"); } else --- 780,785 ---- { // see save project ! // TODO FIXME ! // _mediator->writeDataFile( fileName ); } else Index: solverDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/solverDialog.cpp,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** solverDialog.cpp 19 Dec 2007 11:52:51 -0000 1.88 --- solverDialog.cpp 22 Dec 2007 15:53:16 -0000 1.89 *************** *** 284,381 **** } - void - SolverDialog::save( BSUtilities::xmlw::XmlStream& xml ) - { - // <solver_dialog> - // <solver time_scheme="ROS3P" time_controller="Lang" tolerance="1e-3" model_type="PDAE" auto_tols="1"/> - // <time_steps k1="" k2="" tau_init="" tau_max=""/> - // <grid_adaption coarsening="" max_level="" gamma="" alpha="" mue=""/> - // <init_mesh no_elements="" no_refinements="" fixed=""/> - // </solver_dialog> - - experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); - - xml << BSUtilities::xmlw::tag("solver_dialog"); - - xml << BSUtilities::xmlw::tag("solver") - << BSUtilities::xmlw::attr("time_scheme") << _cond_data->sc.timeScheme - << BSUtilities::xmlw::attr("time_controller") << _cond_data->sc.timeController - << BSUtilities::xmlw::attr("tolerance") << _cond_data->sc.TOL - << BSUtilities::xmlw::attr("model_type"); - - if( _residuumRB->isOn() ) - { - xml << "PDAE"; - } - else if( _gradientRB->isOn() ) - { - xml << "postProcessing"; - } - - xml << BSUtilities::xmlw::attr("auto_tols"); - - if(_tolCheckBox->isChecked()) - { - xml << 1; - } - else - { - xml << 0; - } - - xml << BSUtilities::xmlw::attr("step_policy"); - - if( _stepCheckBox->isChecked() ) - { - xml << 1; - } - else - { - xml << 0; - } - - xml << BSUtilities::xmlw::endtag("solver"); - - xml << BSUtilities::xmlw::tag("time_steps") - << BSUtilities::xmlw::attr("k1") << _cond_data->sc.k1 - << BSUtilities::xmlw::attr("k2") << _cond_data->sc.k2 - << BSUtilities::xmlw::attr("t_init") << _cond_data->sc.initTime - << BSUtilities::xmlw::attr("conc_init") << _cond_data->sc.initConcTol - << BSUtilities::xmlw::attr("tau_init") << _cond_data->sc.initStepSize - << BSUtilities::xmlw::attr("tau_max") << _cond_data->sc.maxStepSize - << BSUtilities::xmlw::attr("max_rej") << _cond_data->sc.maxRej - << BSUtilities::xmlw::attr("shrink") << _cond_data->sc.shrink - << BSUtilities::xmlw::attr("growth") << _cond_data->sc.growth - << BSUtilities::xmlw::attr("safety") << _cond_data->sc.safety - << BSUtilities::xmlw::endtag("time_steps"); - - xml << BSUtilities::xmlw::tag("grid_adaption") - << BSUtilities::xmlw::attr("coarsening") << _cond_data->sc.theta - << BSUtilities::xmlw::attr("max_level") << _cond_data->sc.maxLevel - << BSUtilities::xmlw::attr("gamma") << _cond_data->sc.gamma - << BSUtilities::xmlw::attr("alpha") << _cond_data->sc.alpha - << BSUtilities::xmlw::attr("mue") << _cond_data->sc.mue - << BSUtilities::xmlw::endtag("grid_adaption"); - - xml << BSUtilities::xmlw::tag("init_mesh") - << BSUtilities::xmlw::attr("no_elements") << _cond_data->sc.noElements - << BSUtilities::xmlw::attr("no_refinements") << _cond_data->sc.noRefinements - << BSUtilities::xmlw::attr("fixed"); - - if(_fixCheckBox->isChecked()) - { - xml << 1; - } - else - { - xml << 0; - } - - xml << BSUtilities::xmlw::endtag("init_mesh"); - - xml << BSUtilities::xmlw::endtag("solver_dialog"); - - } - void SolverDialog::supply() { --- 284,287 ---- *************** *** 419,567 **** void - SolverDialog::supply( const QDomElement& dialog ) - { - if( !(dialog.nodeName() == "solver_dialog") ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "No solver_dialog node given to SolverDialog::supply()" ) ); - return; - } - - experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); - - QDomNode node = dialog.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() && node.nodeName() == "solver" ) - { - // <solver time_scheme="ROS3P" time_controller="Lang" tolerance="1e-3" model_type="PDAE" auto_tols="1"/> - QDomElement solver = node.toElement(); - - QString time_scheme = solver.attribute("time_scheme"); - QString time_controller = solver.attribute("time_controller"); - QString tolerance = solver.attribute("tolerance"); - QString model_type = solver.attribute("model_type"); - QString auto_tols = solver.attribute("auto_tols"); - QString step_policy = solver.attribute("step_policy"); - - _timeSchemesListBox->setCurrentItem( _timeSchemesListBox->findItem(time_scheme) ); - _timeControllerListBox->setCurrentItem( _timeControllerListBox->findItem(time_controller) ); - _tolLineEdit->setText(tolerance); - - if( model_type == "PDAE" ) - { - // throw ModelError("Unknown solver!"); - _residuumRB->setChecked(true); - _cond_data->sc.residuum = true; - _gradientRB->setChecked(false); - _cond_data->sc.gradient = false; - this->sltResiduumRB(); - } - else if( model_type == "postProcessing" ) - { - _residuumRB->setChecked(false); - _cond_data->sc.residuum = false; - _gradientRB->setChecked(true); - _cond_data->sc.residuum = true; - this->sltGradientRB(); - } - - if( auto_tols == "1" ) - { - _tolCheckBox->setChecked(true); - } - else if( auto_tols == "0" ) - { - _tolCheckBox->setChecked(false); - } - - if( step_policy == "1" ) - { - _stepCheckBox->setChecked(true); - _cond_data->sc.stepPolicy = true; - } - else if( step_policy == "0" ) - { - _stepCheckBox->setChecked(false); - _cond_data->sc.stepPolicy = false; - } - - - - } - else if( node.isElement() && node.nodeName() == "time_steps" ) - { - // <time_steps k1="" k2="" tau_init="" tau_max=""/> - QDomElement timeStep = node.toElement(); - - QString k1 = timeStep.attribute("k1"); - QString k2 = timeStep.attribute("k2"); - QString t_init = timeStep.attribute("t_init"); - QString conc_init = timeStep.attribute("conc_init"); - QString tau_init = timeStep.attribute("tau_init"); - QString tau_max = timeStep.attribute("tau_max"); - QString max_rej = timeStep.attribute("max_rej"); - QString shrink = timeStep.attribute("shrink"); - QString growth = timeStep.attribute("growth"); - QString safety = timeStep.attribute("safety"); - _k1LineEdit->setText(k1); - _k2LineEdit->setText(k2); - _initTimeLineEdit->setText(t_init); - _initConcTolLineEdit->setText(conc_init); - _initStepSizeLineEdit->setText(tau_init); - _maxStepSizeLineEdit->setText(tau_max); - _maxRejLineEdit->setText(max_rej); - _shrinkLineEdit->setText(shrink); - _growthLineEdit->setText(growth); - _safetyLineEdit->setText(safety); - - } - else if( node.isElement() && node.nodeName() == "grid_adaption" ) - { - // <grid_adaption coarsening="" max_level="" gamma="" alpha="" mue=""/> - - QDomElement grid = node.toElement(); - - QString coarsening = grid.attribute("coarsening"); - QString max_level = grid.attribute("max_level"); - QString gamma = grid.attribute("gamma"); - QString alpha = grid.attribute("alpha"); - QString mue = grid.attribute("mue"); - - _thetaLineEdit->setText(coarsening); - _maxLevelLineEdit->setText(max_level); - _gammaLineEdit->setText(gamma); - _alphaLineEdit->setText(alpha); - _mueLineEdit->setText(mue); - - } - else if( node.isElement() && node.nodeName() == "init_mesh" ) - { - // <init_mesh no_elements="" no_refinements="" fixed=""/> - QDomElement mesh = node.toElement(); - - QString no_elements = mesh.attribute("no_elements"); - QString no_refinements = mesh.attribute("no_refinements"); - QString fixed = mesh.attribute("fixed"); - - _elementsLineEdit->setText(no_elements); - _refinementsLineEdit->setText(no_refinements); - if( fixed == "1" ) - { - _fixCheckBox->setChecked(true); - } - else - { - _fixCheckBox->setChecked(false); - } - } - - node = node.nextSibling(); - } - - } - - void SolverDialog::setGeometry( ecco::Geometry1D* const geometry ) { --- 325,328 ---- Index: equilibriumDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/equilibriumDialog.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** equilibriumDialog.cpp 19 Dec 2007 11:52:45 -0000 1.32 --- equilibriumDialog.cpp 22 Dec 2007 15:53:16 -0000 1.33 *************** *** 498,612 **** } - void - EquilibriumDialog::save( BSUtilities::xmlw::XmlStream& xml ) - { - // e.g. - // <equilibrium_dialog> - // <reactions hom="1" ads="1" hom_surf="1" het_surf="1"/> - // <vis hom="0" surf="0"/> - // <solver type="kin" tmax="100.0" accuracy="1e-3" hinit="1e-2"/> - // </equilibrium_dialog> - experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); - - xml << BSUtilities::xmlw::tag("equilibrium_dialog"); - - xml << BSUtilities::xmlw::tag("reactions") - - << BSUtilities::xmlw::attr("hom"); - - if( _homCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - xml << BSUtilities::xmlw::attr("ads"); - - if( _adsCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - xml << BSUtilities::xmlw::attr("hom_surf"); - - if( _homSurfCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - xml << BSUtilities::xmlw::attr("het_surf"); - - if( _hetSurfCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - - xml << BSUtilities::xmlw::endtag("reactions"); - - xml << BSUtilities::xmlw::tag("vis") - - << BSUtilities::xmlw::attr("hom"); - - if( _plotDissCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - xml << BSUtilities::xmlw::attr("surf"); - - if( _plotAdsCheckBox->isChecked() ) - { - xml << "1"; - } - else - { - xml << "0"; - } - - xml << BSUtilities::xmlw::endtag("vis"); - - xml << BSUtilities::xmlw::tag("solver") - - << BSUtilities::xmlw::attr("type"); - - if( _kinCheckBox->isChecked() ) - { - xml << "kin" - << BSUtilities::xmlw::attr("tmax") << _cond_data->maxTime - << BSUtilities::xmlw::attr("accuracy") << _cond_data->accuracy - << BSUtilities::xmlw::attr("hinit") << _cond_data->initStepSize; - } - else - { - xml << "equ"; - throw ModelError("Only kinetic calculations available!"); - } - - xml << BSUtilities::xmlw::endtag("solver"); - - xml << BSUtilities::xmlw::endtag("equilibrium_dialog"); - - } - void EquilibriumDialog::supply() { --- 498,501 ---- *************** *** 623,764 **** } - void - EquilibriumDialog::supply( const QDomElement& dialog ) - { - // std::cout << "EquilibriumDialog::supply()" << std::endl; - - if( !(dialog.nodeName() == "equilibrium_dialog") ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "No equilibrium_dialog node given to Mediator::supplyEquilibriumDialog()" ) ); - return; - } - - QDomNode node = dialog.firstChild(); - while( !node.isNull() ) - { - if( node.isElement() && node.nodeName() == "reactions" ) - { - QDomElement reactions = node.toElement(); - - QString hom = reactions.attribute("hom"); - QString ads = reactions.attribute("ads"); - QString homSurf = reactions.attribute("hom_surf"); - QString hetSurf = reactions.attribute("het_surf"); - - if( (hom == QString::null) | - (ads == QString::null) | - (homSurf == QString::null) | - (hetSurf == QString::null) ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "Not enough attributes specified!" ) ); - return; - } - if( hom == "1" ) - { - _homCheckBox->setChecked(true); - } - else if( hom == "0" ) - { - _homCheckBox->setChecked(false); - } - if( ads == "1" ) - { - _adsCheckBox->setChecked(true); - } - else if( ads == "0" ) - { - _adsCheckBox->setChecked(false); - } - if( homSurf == "1" ) - { - _homSurfCheckBox->setChecked(true); - } - else if( hetSurf == "0" ) - { - _hetSurfCheckBox->setChecked(false); - } - } - else if( node.isElement() && node.nodeName() == "vis" ) - { - QDomElement vis = node.toElement(); - - QString hom = vis.attribute("hom"); - QString surf = vis.attribute("surf"); - - if( (hom == QString::null) | - (surf == QString::null) ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "Not enough attributes specified!" ) ); - return; - } - - if(hom == "1" ) - { - _plotDissCheckBox->setChecked(true); - } - else if(hom == "0" ) - { - _plotDissCheckBox->setChecked(false); - } - if(surf == "1" ) - { - _plotAdsCheckBox->setChecked(true); - } - else if(surf == "0" ) - { - _plotAdsCheckBox->setChecked(false); - } - } - else if( node.isElement() && node.nodeName() == "solver" ) - { - - QDomElement solver = node.toElement(); - - QString type = solver.attribute("type"); - QString tmax = solver.attribute("tmax"); - QString accuracy = solver.attribute("accuracy"); - QString hinit = solver.attribute("hinit"); - - if( (type == QString::null) | - (tmax == QString::null) | - (accuracy == QString::null) | - (hinit == QString::null) ) - { - QMessageBox::critical( 0, - QObject::tr( "Critical Error" ), - QObject::tr( "Not enough attributes specified!" ) ); - return; - } - - if( type == "kin" ) - { - _kinCheckBox->setChecked(true); - _thermCheckBox->setChecked(false); - } - else if( type == "equ" ) - { - _kinCheckBox->setChecked(false); - _thermCheckBox->setChecked(true); - } - - _maxTimeLineEdit->setText(tmax); - _accuracyLineEdit->setText(accuracy); - _initStepLineEdit->setText(hinit); - - } - node = node.nextSibling(); - } - - // std::cout << "EquilibriumDialog::supply() --END" << std::endl; - } - - - } } // namespace modelGUI --- 512,515 ---- Index: solverDialog.hpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/solverDialog.hpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** solverDialog.hpp 19 Dec 2007 11:52:52 -0000 1.45 --- solverDialog.hpp 22 Dec 2007 15:53:16 -0000 1.46 *************** *** 45,51 **** #include "Ecco/ecco.hpp" - #include "xmlwriter.h" - #include <qdom.h> - #include <qprogressdialog.h> --- 45,48 ---- *************** *** 73,78 **** void supply(); - void supply( const QDomElement& dialog ); - void save( BSUtilities::xmlw::XmlStream& xml ); //! "PC" for potential controlled, "CC" for current controlled --- 70,73 ---- Index: mechanismDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/mechanismDialog.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** mechanismDialog.cpp 19 Dec 2007 11:52:46 -0000 1.28 --- mechanismDialog.cpp 22 Dec 2007 15:53:16 -0000 1.29 *************** *** 32,36 **** #include "Ecco/ecco.hpp" - #include <string> #include <iostream> --- 32,35 ---- *************** *** 84,90 **** std::cout << "~/echempp/.internals not found!" << std::endl; } ! _cond_data->mechanism = _currentTextEdit->text().ascii(); ! _cond_data->stoichiometricBalance = _cbStoichiometricBalance->isChecked(); ! _cond_data->chargeBalance = _cbChargeBalance->isChecked(); } --- 83,89 ---- std::cout << "~/echempp/.internals not found!" << std::endl; } ! _cond_data->mc.mechanism = _currentTextEdit->text().ascii(); ! _cond_data->mc.stoichiometricBalance = _cbStoichiometricBalance->isChecked(); ! _cond_data->mc.chargeBalance = _cbChargeBalance->isChecked(); } *************** *** 98,102 **** } - void MechanismDialog::sltOpenMechanism() --- 97,100 ---- *************** *** 114,154 **** if ( fd->exec() == QDialog::Accepted ) { fileName = fd->selectedFile(); - - QFile xmlFile( fileName ); - if( !xmlFile.open( IO_ReadOnly ) ) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Cannot open file %1" ).arg( fileName ) ); - return; - } - - QDomDocument domTree; - if( !domTree.setContent( &xmlFile ) ) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Parsing error for file %1" ).arg( fileName ) ); - xmlFile.close(); - return; - } - xmlFile.close(); - - // get information from the Tree - QDomElement root = domTree.documentElement(); - if( root.nodeName() == "mechanism_dialog" ) - { - this->supply(root); - } - else - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Root is no mechanism_dialog tag in %1" ).arg( fileName ) ); - } ! QString s = _currentTextEdit->text(); ! QDir dir; QString home = dir.homeDirPath(); --- 112,144 ---- if ( fd->exec() == QDialog::Accepted ) { + experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); fileName = fd->selectedFile(); ! std::ifstream ifs_xml(fileName.ascii()); ! if(!ifs_xml) ! { ! QMessageBox::warning( 0, QObject::tr( "I/O Warning" ), ! QObject::tr( "Cannot open file %1" ).arg(fileName)); ! delete fd; ! return; ! } ! boost::archive::xml_iarchive ia_xml(ifs_xml); ! try ! { ! ia_xml >> boost::serialization::make_nvp("mc", _cond_data->mc); ! } ! catch(std::exception& e) ! { ! QMessageBox::critical( 0, QObject::tr( "Critical Error" ), ! QObject::tr(e.what()) ); ! ! ifs_xml.close(); ! delete fd; ! return; ! } ! ifs_xml.close(); ! this->supply(); ! ! QString s = _currentTextEdit->text(); QDir dir; QString home = dir.homeDirPath(); *************** *** 190,216 **** if ( fd->exec() == QDialog::Accepted ) { fileName = fd->selectedFile(); ! std::string file(fileName.ascii()); ! std::ofstream fileStream( file.c_str() ); ! if(!fileStream) ! { ! QMessageBox::warning( 0, ! QObject::tr( "I/O Warning" ), ! QObject::tr( "Cannot open file %1" ).arg( file.c_str() ) ); ! return; } ! ! BSUtilities::xmlw::XmlStream xml( fileStream ); ! ! xml << BSUtilities::xmlw::prolog(); ! ! this->save(xml); ! ! _fileTextLabel->setText(fileName); ! ! fileStream.close(); } - delete fd; } --- 180,208 ---- if ( fd->exec() == QDialog::Accepted ) { + experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); fileName = fd->selectedFile(); ! std::ofstream ofs_xml(fileName.ascii()); ! if(!ofs_xml) ! { ! QMessageBox::warning( 0, QObject::tr( "I/O Warning" ), ! QObject::tr( "Cannot open file %1" ).arg( fileName.ascii() ) ); ! delete fd; ! return; ! } ! boost::archive::xml_oarchive oa_xml(ofs_xml); ! try{ ! oa_xml << boost::serialization::make_nvp("mc", _cond_data->mc); } ! catch(std::exception& e) ! { ! QMessageBox::critical( 0, QObject::tr( "Critical Error" ), ! QObject::tr(e.what()) ); ! ofs_xml.close(); ! delete fd; ! return; ! } ! ofs_xml.close(); } delete fd; } *************** *** 289,293 **** try { ! _net = compiler.compile( inFileName, _cond_data->activeBoundaries ); } catch( ecco::EccoError& error ) --- 281,285 ---- try { ! _net = compiler.compile( inFileName, _cond_data->mc.activeBoundaries ); } catch( ecco::EccoError& error ) *************** *** 472,478 **** this->inform(DialogAspect("MechanismDialog","Compile")); ! _cond_data->mechanism = _currentTextEdit->text().ascii(); ! _cond_data->stoichiometricBalance = _cbStoichiometricBalance->isChecked(); ! _cond_data->chargeBalance = _cbChargeBalance->isChecked(); } --- 464,470 ---- this->inform(DialogAspect("MechanismDialog","Compile")); ! _cond_data->mc.mechanism = _currentTextEdit->text().ascii(); ! _cond_data->mc.stoichiometricBalance = _cbStoichiometricBalance->isChecked(); ! _cond_data->mc.chargeBalance = _cbChargeBalance->isChecked(); } *************** *** 481,485 **** { experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); ! _cond_data->mechanism = ""; _currentTextEdit->clear(); _processTextEdit->clear(); --- 473,477 ---- { experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); ! _cond_data->mc.mechanism = ""; _currentTextEdit->clear(); _processTextEdit->clear(); *************** *** 498,603 **** } - - void - MechanismDialog::save( BSUtilities::xmlw::XmlStream& xml ) - { - - //<mechanism_dialog charge_balance="1/0" stoichiometric_balance="1/0"> - //<text> - //..... text ..... - //</text> - //</mechanism_dialog> - xml << BSUtilities::xmlw::tag("mechanism_dialog") - - << BSUtilities::xmlw::attr("charge_balance"); - - if( _cbChargeBalance->isChecked() ) - { - xml << 1; - } - else - { - xml << 0; - } - - xml << BSUtilities::xmlw::attr("stoichiometric_balance"); - - if( _cbStoichiometricBalance->isChecked() ) - { - xml << 1; - } - else - { - xml << 0; - } - - xml << BSUtilities::xmlw::tag("text") - - << BSUtilities::xmlw::chardata() - - << "<![CDATA[" << _currentTextEdit->text().ascii() << "]]>" - - << BSUtilities::xmlw::endtag("text") - - << BSUtilities::xmlw::endtag("mechanism_dialog"); - - } - void MechanismDialog::supply() { experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); ! _cbChargeBalance->setChecked( _cond_data->chargeBalance ); ! _cbStoichiometricBalance->setChecked( _cond_data->stoichiometricBalance ); ! _currentTextEdit->setText( _cond_data->mechanism ); ! } ! ! void ! MechanismDialog::supply( const QDomElement& dialog ) ! { ! // std::cout << "MechanismDialog::supply()" << std::endl; ! if( !(dialog.nodeName() == "mechanism_dialog") ) ! { ! QMessageBox::critical( 0, ! QObject::tr( "Critical Error" ), ! QObject::tr( "No mechanism_dialog node given to MechanismDialog::supply()" ) ); ! return; ! } ! ! int chargeBalance = dialog.attribute("charge_balance").toInt(); ! int stoichiometricBalance = dialog.attribute("stoichiometric_balance").toInt(); ! ! if( chargeBalance == 1 ) ! { ! _cbChargeBalance->setChecked(true); ! } ! else ! { ! _cbChargeBalance->setChecked(false); ! } ! ! if( stoichiometricBalance == 1 ) ! { ! _cbStoichiometricBalance->setChecked(true); ! } ! else ! { ! _cbStoichiometricBalance->setChecked(false); ! } ! ! ! QDomNode node = dialog.firstChild(); ! ! while( !node.isNull() ) ! { ! if( node.isElement() & (node.nodeName() == "text") ) ! { ! QDomElement text = node.toElement(); ! QString mechanism = text.text(); ! _currentTextEdit->setText( mechanism ); ! } ! node = node.nextSibling(); ! } ! // std::cout << "MechanismDialog::supply() -- END" << std::endl; } --- 490,500 ---- } void MechanismDialog::supply() { experiment::ConditionDataModSim* _cond_data = _mainWindow->getActiveConditionData(); ! _cbChargeBalance->setChecked( _cond_data->mc.chargeBalance ); ! _cbStoichiometricBalance->setChecked( _cond_data->mc.stoichiometricBalance ); ! _currentTextEdit->setText( _cond_data->mc.mechanism ); } Index: mediator.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/mediator.cpp,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** mediator.cpp 19 Dec 2007 11:52:48 -0000 1.137 --- mediator.cpp 22 Dec 2007 15:53:16 -0000 1.138 *************** *** 284,354 **** void - Mediator::writeProjectFile( const QString& fileName ) - { - std::string file(fileName.ascii()); - std::ofstream fileStream( file.c_str() ); - if(!fileStream) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Cannot open file %1" ).arg( file.c_str() ) ); - return; - } - BSUtilities::xmlw::XmlStream xml( fileStream ); - - xml << BSUtilities::xmlw::prolog(); - - xml << BSUtilities::xmlw::tag("echempp_project") - << BSUtilities::xmlw::attr("file") << file.c_str(); - - xml << BSUtilities::xmlw::tag("model"); - - _equilibriumDialog->save( xml ); - _experimentDialog->save( xml ); - _mechanismDialog->save( xml ); - _modelParameters->save( xml ); - _dataDialog->save( xml ); - _solverDialog->save( xml ); - _scalingDialog->save( xml ); - - xml << BSUtilities::xmlw::endtag("model"); - - xml << BSUtilities::xmlw::endtag("echempp_project"); - - fileStream.close(); - } - - void Mediator::writeDataFile( const QString& fileName ) { ! std::string file(fileName.ascii()); ! std::ofstream fileStream( file.c_str() ); ! if(!fileStream) ! { ! QMessageBox::warning( 0, ! QObject::tr( "I/O Warning" ), ! QObject::tr( "Cannot open file %1" ).arg( file.c_str() ) ); ! return; ! } ! ! BSUtilities::xmlw::XmlStream xml( fileStream ); ! ! xml << BSUtilities::xmlw::prolog(); ! ! xml << BSUtilities::xmlw::tag("echempp_data_file") ! << BSUtilities::xmlw::attr("file") << file.c_str(); ! ! xml << BSUtilities::xmlw::tag("model"); ! ! _experimentDialog->save( xml ); ! _mechanismDialog->save( xml ); ! _modelParameters->save( xml ); ! _plotWidget->saveActiveData( xml ); ! ! xml << BSUtilities::xmlw::endtag("model"); ! ! xml << BSUtilities::xmlw::endtag("echempp_data_file"); ! ! fileStream.close(); } --- 284,293 ---- void Mediator::writeDataFile( const QString& fileName ) { ! // _experimentDialog->save( xml ); ! // _mechanismDialog->save( xml ); ! // _modelParameters->save( xml ); ! _plotWidget->saveActiveData( fileName ); } *************** *** 385,440 **** void - Mediator::readProjectFile( const QString& fileName ) - { - // std::cout << "Mediator::readProjectFile()" << std::endl; - - // read the XML file and create DOM tree - QFile xmlFile( fileName ); - if( !xmlFile.open( IO_ReadOnly ) ) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Cannot open file %1" ).arg( fileName ) ); - return; - } - - QDomDocument domTree; - if( !domTree.setContent( &xmlFile ) ) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Warning" ), - QObject::tr( "Parsing error for file %1" ).arg( fileName ) ); - xmlFile.close(); - return; - } - xmlFile.close(); - - // get information from the Tree - QDomElement root = domTree.documentElement(); - QDomNode node = root.firstChild(); - - while( !node.isNull() ) - { - if( node.isElement() && node.nodeName() == "model" ) - { - QDomElement model = node.toElement(); - try - { - this->createModel( model ); - } - catch( ModelError& error ) - { - QMessageBox::warning( 0, - QObject::tr( "I/O Error" ), - QObject::tr( "Error while rebuilding settings of %1" ).arg( fileName ) ); - return; - } - } - node = node.nextSibling(); - } - // std::cout << "Mediator::readProjectFile() -- END" << std::endl; - } - - void Mediator::importData( const QString& fileName ) { --- 324,327 ---- *************** *** 542,598 **** { // std::cout << "Mediator::createModel()" << std::endl; ! _solverDialog->clear(); ! QDomNode node = model.firstChild(); ! while( !node.isNull() ) ! { ! if( node.isElement() && node.nodeName() == "equilibrium_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _equilibriumDialog->supply( dialog ); ! _equilibriumDialog->sltApply(); ! } ! else if( node.isElement() && node.nodeName() == "experiment_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _experimentDialog->supply( dialog ); ! _experimentDialog->sltApply(); ! } ! else if( node.isElement() && node.nodeName() == "mechanism_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _mechanismDialog->supply( dialog ); ! _mechanismDialog->sltCompile(); ! if( _mechanismDialog->aborted() ) ! { ! throw ModelError( "compilation aborted!" ); ! } ! } ! else if( node.isElement() && node.nodeName() == "model_parameters_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _modelParameters->supply( dialog ); ! _modelParameters->sltEquilibriumCalculation(); ! } ! else if( node.isElement() && node.nodeName() == "data_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _dataDialog->supply( dialog ); ! _dataDialog->sltApply(); ! } ! else if( node.isElement() && node.nodeName() == "solver_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _solverDialog->supply( dialog ); ! _solverDialog->sltApply(); ! } ! else if( node.isElement() && node.nodeName() == "scaling_dialog" ) ! { ! QDomElement dialog = node.toElement(); ! _scalingDialog->supply( dialog ); ! _scalingDialog->sltApply(); ! } ! node = node.nextSibling(); ! } // std::cout << "Mediator::createModel() -- END" << std::endl; } --- 429,485 ---- { // std::cout << "Mediator::createModel()" << std::endl; ! // _solverDialog->clear(); ! // QDomNode node = model.firstChild(); ! // while( !node.isNull() ) ! // { ! // if( node.isElement() && node.nodeName() == "equilibrium_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _equilibriumDialog->supply( dialog ); ! // _equilibriumDialog->sltApply(); ! // } ! // else if( node.isElement() && node.nodeName() == "experiment_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _experimentDialog->supply( dialog ); ! // _experimentDialog->sltApply(); ! // } ! // else if( node.isElement() && node.nodeName() == "mechanism_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _mechanismDialog->supply( dialog ); ! // _mechanismDialog->sltCompile(); ! // if( _mechanismDialog->aborted() ) ! // { ! // throw ModelError( "compilation aborted!" ); ! // } ! // } ! // else if( node.isElement() && node.nodeName() == "model_parameters_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _modelParameters->supply( dialog ); ! // _modelParameters->sltEquilibriumCalculation(); ! // } ! // else if( node.isElement() && node.nodeName() == "data_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _dataDialog->supply( dialog ); ! // _dataDialog->sltApply(); ! // } ! // else if( node.isElement() && node.nodeName() == "solver_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _solverDialog->supply( dialog ); ! // _solverDialog->sltApply(); ! // } ! // else if( node.isElement() && node.nodeName() == "scaling_dialog" ) ! // { ! // QDomElement dialog = node.toElement(); ! // _scalingDialog->supply( dialog ); ! // _scalingDialog->sltApply(); ! // } ! // node = node.nextSibling(); ! // } // std::cout << "Mediator::createModel() -- END" << std::endl; } Index: batchExperimentDialog.cpp =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/batchExperimentDialog.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** batchExperimentDialog.cpp 19 Dec 2007 11:56:24 -0000 1.1 --- batchExperimentDialog.cpp 22 Dec 2007 15:53:16 -0000 1.2 *************** *** 169,173 **** int i = getIndexFromName(name, "kh"); if(i != -1) ! return cond_data->khs[i].value(); } else if(name.contains("kf")) --- 169,173 ---- int i = getIndexFromName(name, "kh"); if(i != -1) ! return cond_data->mpc.khs[i].value(); } else if(name.contains("kf")) *************** *** 175,179 **** int i = getIndexFromName(name, "kf"); if(i != -1) ! return cond_data->homForwardRateConstants[i]; } else if(name.contains("D")) --- 175,179 ---- int i = getIndexFromName(name, "kf"); if(i != -1) ! return cond_data->mpc.homForwardRateConstants[i]; } else if(name.contains("D")) *************** *** 181,185 **** int i = getIndexFromName(name, "D"); if(i != -1) ! return cond_data->diffCoeffs[i].value(); } else if(name.contains("c")) --- 181,185 ---- int i = getIndexFromName(name, "D"); if(i != -1) ! return cond_data->mpc.diffCoeffs[i].value(); } else if(name.contains("c")) *************** *** 187,191 **** int i = getIndexFromName(name, "c"); if(i != -1); ! return cond_data->dissConcs[i].value(); } else if(name == "v") --- 187,191 ---- int i = getIndexFromName(name, "c"); if(i != -1); ! return cond_data->mpc.dissConcs[i].value(); } else if(name == "v") *************** *** 217,221 **** int i = getIndexFromName(name, "kh");... [truncated message content] |