diff --git a/GUI/Model/Data/ApplicationModels.cpp b/GUI/Model/Data/ApplicationModels.cpp index 767adc2483c07bdac56b462b18a669e0d4133389..aaaf1338c91561c249a1d605972aa6f61f81af3e 100644 --- a/GUI/Model/Data/ApplicationModels.cpp +++ b/GUI/Model/Data/ApplicationModels.cpp @@ -13,7 +13,6 @@ // ************************************************************************************************ #include "GUI/Model/Data/ApplicationModels.h" -#include "GUI/Model/Data/DocumentModel.h" #include "GUI/Model/Data/RealDataModel.h" #include "GUI/Model/Instrument/InstrumentModel.h" #include "GUI/Model/Job/JobModel.h" @@ -25,7 +24,6 @@ ApplicationModels::ApplicationModels(QObject* parent) : QObject(parent) - , m_documentModel(nullptr) , m_materialModel(nullptr) , m_instrumentModel(nullptr) , m_sampleModel(nullptr) @@ -33,14 +31,12 @@ ApplicationModels::ApplicationModels(QObject* parent) , m_jobModel(nullptr) { //! creates and initializes models, order is important - m_documentModel = new DocumentModel(this); m_materialModel = new MaterialModel(this); m_sampleModel = new SampleModel(this); m_instrumentModel = new InstrumentModel(this); m_realDataModel = new RealDataModel(this); m_jobModel = new JobModel(this); - connectModel(m_documentModel); connectModel(m_materialModel); connectModel(m_sampleModel); connectModel(m_instrumentModel); @@ -52,11 +48,6 @@ ApplicationModels::ApplicationModels(QObject* parent) ApplicationModels::~ApplicationModels() = default; -DocumentModel* ApplicationModels::documentModel() const -{ - return m_documentModel; -} - MaterialModel* ApplicationModels::materialModel() const { return m_materialModel; @@ -85,9 +76,6 @@ JobModel* ApplicationModels::jobModel() const //! reset all models to initial state void ApplicationModels::resetModels() { - m_documentModel->clear(); - m_documentModel->insertItem<SimulationOptionsItem>(); - m_materialModel->clear(); m_materialModel->addRefractiveMaterial("Default", 1e-3, 1e-5); m_materialModel->addRefractiveMaterial("Vacuum", 0.0, 0.0); @@ -112,6 +100,11 @@ void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messa { try { for (auto* model : modelList()) { + if (reader->name().toString() == "DocumentModel") { + reader->skipCurrentElement(); + break; + } + if (model->getModelTag() == reader->name()) { model->readFrom(reader, messageService); break; @@ -128,7 +121,6 @@ void ApplicationModels::readFrom(QXmlStreamReader* reader, MessageService* messa QList<SessionModel*> ApplicationModels::modelList() { QList<SessionModel*> result; - result.append(m_documentModel); result.append(m_materialModel); result.append(m_instrumentModel); result.append(m_sampleModel); diff --git a/GUI/Model/Data/ApplicationModels.h b/GUI/Model/Data/ApplicationModels.h index 765a37afcbe361a71ab4bf6d52606efefaa896bf..500878004c388283e94dbb82740d7c2f2c3612dc 100644 --- a/GUI/Model/Data/ApplicationModels.h +++ b/GUI/Model/Data/ApplicationModels.h @@ -33,7 +33,6 @@ public: explicit ApplicationModels(QObject* parent = nullptr); ~ApplicationModels() override; - DocumentModel* documentModel() const; MaterialModel* materialModel() const; InstrumentModel* instrumentModel() const; SampleModel* sampleModel() const; diff --git a/GUI/Model/Data/DocumentModel.cpp b/GUI/Model/Data/DocumentModel.cpp deleted file mode 100644 index 7242015754ed82bbb9ede95cbb47a13dd1e32fc4..0000000000000000000000000000000000000000 --- a/GUI/Model/Data/DocumentModel.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Model/Data/DocumentModel.cpp -//! @brief Implements class DocumentModel -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/Model/Data/DocumentModel.h" -#include "GUI/Model/Session/SimulationOptionsItem.h" - -DocumentModel::DocumentModel(QObject* parent) - : SessionModel(GUI::Session::XML::DocumentModelTag, parent) -{ - setObjectName(GUI::Session::XML::DocumentModelTag); -} - -SimulationOptionsItem* DocumentModel::simulationOptionsItem() -{ - return topItem<SimulationOptionsItem>(); -} diff --git a/GUI/Model/Data/DocumentModel.h b/GUI/Model/Data/DocumentModel.h deleted file mode 100644 index c8b2afb0328a602d05bb12d688be2c0529a85372..0000000000000000000000000000000000000000 --- a/GUI/Model/Data/DocumentModel.h +++ /dev/null @@ -1,34 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/Model/Data/DocumentModel.h -//! @brief Defines class DocumentModel -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_MODEL_DATA_DOCUMENTMODEL_H -#define BORNAGAIN_GUI_MODEL_DATA_DOCUMENTMODEL_H - -#include "GUI/Model/Session/SessionModel.h" - -class SimulationOptionsItem; - -//! The DocumentModel class is a model with GUI settings related to the opened project. -//! Can be the place to store splitter position, etc. - -class DocumentModel : public SessionModel { - Q_OBJECT - -public: - explicit DocumentModel(QObject* parent = nullptr); - - SimulationOptionsItem* simulationOptionsItem(); -}; - -#endif // BORNAGAIN_GUI_MODEL_DATA_DOCUMENTMODEL_H diff --git a/GUI/Model/Group/ItemCatalog.cpp b/GUI/Model/Group/ItemCatalog.cpp index bf0b112236cd491062ac8264fe81de9fe49c17f6..9b9a3c560caecbb5502be6ffb828374757307dbc 100644 --- a/GUI/Model/Group/ItemCatalog.cpp +++ b/GUI/Model/Group/ItemCatalog.cpp @@ -309,8 +309,6 @@ ItemCatalog::ItemCatalog() addItem<FitParameterLinkItem>(); addItem<FitSuiteItem>(); - addItem<SimulationOptionsItem>(); - addItem<RealDataItem>(); addItem<MinimizerContainerItem>(); diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 8230fcf9275653eee38193e062463d3c31a7b49b..0e17b686d37d127f9051a79159c1425c8b94f74b 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -28,6 +28,11 @@ #include "GUI/Model/Session/SimulationOptionsItem.h" #include "GUI/Util/Error.h" +namespace { +const QString SimulationOptionsTag("SimulationOptions"); +} // namespace + + JobItem::JobItem() : SessionItem(M_TYPE) { setItemName(M_TYPE); @@ -55,8 +60,6 @@ JobItem::JobItem() : SessionItem(M_TYPE) registerTag(T_DATAVIEW, 1, 1, {Data1DViewItem::M_TYPE}); registerTag(T_PARAMETER_TREE, 0, -1, {ParameterContainerItem::M_TYPE}); - registerTag(T_SIMULATION_OPTIONS, 1, 1, {SimulationOptionsItem::M_TYPE}); - registerTag(T_FIT_SUITE, 1, 1, {FitSuiteItem::M_TYPE}); mapper()->setOnChildPropertyChange([this](SessionItem* item, const QString& name) { @@ -378,6 +381,22 @@ void JobItem::setPresentationType(const QString& type) setItemValue(P_PRESENTATION_TYPE, type); } +void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const +{ + writer->writeStartElement(SimulationOptionsTag); + m_simulationOptionsItem.writeContentTo(writer); + writer->writeEndElement(); +} + +void JobItem::readNonSessionItems(QXmlStreamReader* reader) +{ + reader->readNextStartElement(); + if (reader->name() == SimulationOptionsTag) { + m_simulationOptionsItem.readContentFrom(reader); + reader->skipCurrentElement(); + } +} + //! Updates the name of file to store intensity data. void JobItem::updateIntensityDataFileName() @@ -396,10 +415,10 @@ void JobItem::updateIntensityDataFileName() const SimulationOptionsItem& JobItem::simulationOptionsItem() const { - return *item<const SimulationOptionsItem>(T_SIMULATION_OPTIONS); + return m_simulationOptionsItem; } -void JobItem::copySimulationOptionsIntoJob(const SimulationOptionsItem* options) +void JobItem::copySimulationOptionsIntoJob(const SimulationOptionsItem& options) { - model()->copyItem(options, this, T_SIMULATION_OPTIONS); + m_simulationOptionsItem = options; } diff --git a/GUI/Model/Job/JobItem.h b/GUI/Model/Job/JobItem.h index 0b6bcdb84434a42918a29c483a388614f689c4b9..16d34064e0ec0db3afcdfa3d88cedf3d44008d44 100644 --- a/GUI/Model/Job/JobItem.h +++ b/GUI/Model/Job/JobItem.h @@ -15,10 +15,12 @@ #ifndef BORNAGAIN_GUI_MODEL_JOB_JOBITEM_H #define BORNAGAIN_GUI_MODEL_JOB_JOBITEM_H +#include "GUI/Model/Job/JobStatus.h" // enum cannot be forward declared #include "GUI/Model/Session/SessionItem.h" - -#include "GUI/Model/Job/JobStatus.h" // enum cannot be forward declared #include "GUI/Model/Session/SessionModel.h" // call to model() from templated fct +#include "GUI/Model/Session/SimulationOptionsItem.h" +#include <QDateTime> +#include <optional> class Data1DViewItem; class DataItem; @@ -34,9 +36,6 @@ class ParameterContainerItem; class RealDataItem; class SimulationOptionsItem; -#include <QDateTime> -#include <optional> - class BA_CORE_API_ JobItem : public SessionItem { private: @@ -57,7 +56,6 @@ private: static constexpr auto T_REALDATA{"Real Data tag"}; static constexpr auto T_DATAVIEW{"Data View tag"}; static constexpr auto T_PARAMETER_TREE{"Parameter tree tag"}; - static constexpr auto T_SIMULATION_OPTIONS{"Simulation options tag"}; static constexpr auto T_FIT_SUITE{"Fit suite tag"}; public: @@ -115,7 +113,7 @@ public: InstrumentItem* copyInstrumentIntoJob(const InstrumentItem* instrument); const SimulationOptionsItem& simulationOptionsItem() const; - void copySimulationOptionsIntoJob(const SimulationOptionsItem* options); + void copySimulationOptionsIntoJob(const SimulationOptionsItem& options); void setResults(const ISimulation* simulation); @@ -148,8 +146,13 @@ public: QString presentationType() const; void setPresentationType(const QString& type); + void writeNonSessionItems(QXmlStreamWriter* writer) const override; + void readNonSessionItems(QXmlStreamReader* reader) override; + private: void updateIntensityDataFileName(); + + SimulationOptionsItem m_simulationOptionsItem; }; template <typename T> T* JobItem::setDataType() diff --git a/GUI/Model/Job/JobModel.cpp b/GUI/Model/Job/JobModel.cpp index caf871b158cdfe50a419a7f010217c35a56cb5da..34c0f14ba4190c7fca2dc30c33f94d8a1e67a220 100644 --- a/GUI/Model/Job/JobModel.cpp +++ b/GUI/Model/Job/JobModel.cpp @@ -84,7 +84,7 @@ JobItem* JobModel::addJob(const MultiLayerItem* multiLayerItem, // TODO: remove when specular instrument is ready for magnetization if (instrumentItem->is<SpecularInstrumentItem>()) GUI::Model::JobFunctions::muteMagnetizationData(jobItem); - jobItem->copySimulationOptionsIntoJob(*optionItem); + jobItem->copySimulationOptionsIntoJob(optionItem); jobItem->setSampleName(multiLayerItem->itemName()); diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp index 03eafdb077435c35edb53daa342ec2294c7657b0..c18aa8d4c37839e4f781a7cf75136d33f1bcf481 100644 --- a/GUI/Model/Project/ProjectDocument.cpp +++ b/GUI/Model/Project/ProjectDocument.cpp @@ -13,11 +13,11 @@ // ************************************************************************************************ #include "GUI/Model/Project/ProjectDocument.h" -#include "GUI/Model/Data/DocumentModel.h" #include "GUI/Model/IO/ProjectUtils.h" #include "GUI/Model/Instrument/LinkInstrumentManager.h" #include "GUI/Model/Job/JobModel.h" #include "GUI/Model/Project/OutputDataIOService.h" +#include "GUI/Model/Session/SimulationOptionsItem.h" #include "GUI/Util/Error.h" #include "GUI/Util/MessageService.h" #include "GUI/Util/Path.h" @@ -34,6 +34,7 @@ const QString BornAgainTag("BornAgain"); const QString BornAgainVersionAttribute("Version"); const QString InfoTag("DocumentInfo"); const QString InfoNameAttribute("ProjectName"); +const QString SimulationOptionsTag("SimulationOptions"); } // namespace @@ -133,9 +134,9 @@ JobModel* ProjectDocument::jobModel() const return m_applicationModels.jobModel(); } -SimulationOptionsItem* ProjectDocument::simulationOptionsItem() const +SimulationOptionsItem* ProjectDocument::simulationOptionsItem() { - return m_applicationModels.documentModel()->simulationOptionsItem(); + return &m_simulationOptionsItem; } LinkInstrumentManager* ProjectDocument::linkInstrumentManager() @@ -318,7 +319,10 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device, while (reader.readNextStartElement()) if (reader.name() == InfoTag) reader.skipCurrentElement(); - else + else if (reader.name() == SimulationOptionsTag) { + m_simulationOptionsItem.readContentFrom(&reader); + reader.skipCurrentElement(); + } else m_applicationModels.readFrom(&reader, &messageService); } } @@ -348,6 +352,10 @@ void ProjectDocument::writeTo(QIODevice* device) writer.writeAttribute(InfoNameAttribute, projectName()); writer.writeEndElement(); // InfoTag + writer.writeStartElement(SimulationOptionsTag); + m_simulationOptionsItem.writeContentTo(&writer); + writer.writeEndElement(); + m_applicationModels.writeTo(&writer); writer.writeEndElement(); // BornAgain tag diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h index 4ffac40b4b848ef32a5827d9e1efb0746b3e4594..fcac92afdac9cd0fdf9df828365b6b2a4ec129fe 100644 --- a/GUI/Model/Project/ProjectDocument.h +++ b/GUI/Model/Project/ProjectDocument.h @@ -16,6 +16,7 @@ #define BORNAGAIN_GUI_MODEL_PROJECT_PROJECTDOCUMENT_H #include "GUI/Model/Data/ApplicationModels.h" +#include "GUI/Model/Session/SimulationOptionsItem.h" #include <QObject> #include <QVariant> #include <memory> @@ -74,7 +75,7 @@ public: MaterialModel* materialModel() const; RealDataModel* realDataModel() const; JobModel* jobModel() const; - SimulationOptionsItem* simulationOptionsItem() const; + SimulationOptionsItem* simulationOptionsItem(); LinkInstrumentManager* linkInstrumentManager(); @@ -134,6 +135,7 @@ private: bool m_singleInstrumentMode; bool m_singleSampleMode; Functionalities m_functionalities; + SimulationOptionsItem m_simulationOptionsItem; }; Q_DECLARE_OPERATORS_FOR_FLAGS(ProjectDocument::Functionalities) diff --git a/GUI/Model/Session/SimulationOptionsItem.cpp b/GUI/Model/Session/SimulationOptionsItem.cpp index 3f512e7038595e4519909b4498252159b52e3a73..59b3569c0ccfb90d3b8434513ac84a76651f0f2e 100644 --- a/GUI/Model/Session/SimulationOptionsItem.cpp +++ b/GUI/Model/Session/SimulationOptionsItem.cpp @@ -13,80 +13,47 @@ // ************************************************************************************************ #include "GUI/Model/Session/SimulationOptionsItem.h" -#include "GUI/Util/ComboProperty.h" +#include "GUI/Model/Session/SessionXML.h" +#include "GUI/Util/DeserializationException.h" +#include <QXmlStreamWriter> #include <thread> -// !! Attention !! Do not change the following texts, despite they are not matching the -// constants! They are used for file loading => keep stable! - -SimulationOptionsItem::SimulationOptionsItem() : SessionItem(M_TYPE) -{ - addProperty(P_RUN_IMMEDIATELY, true); - addProperty(P_NTHREADS, static_cast<int>(std::thread::hardware_concurrency())); - addProperty(P_COMPUTATION_METHOD_ANALYTICAL, true); - addProperty(P_MC_POINTS, 100)->setEnabled(false); - addProperty(P_AVERAGE_MATERIAL, false); - addProperty(P_INCLUDE_SPECULAR_PEAK, false); - - // -- add translators for legacy XML reading - - getItem(P_RUN_IMMEDIATELY) - ->setTranslatorForRolePropertySetter([](int role, const QVariant& value) { - if (role == Qt::DisplayRole && value.canConvert<ComboProperty>()) - return QVariant(value.value<ComboProperty>().currentIndex() - == 0); // 0 was "immediately" - return value; - }); - - getItem(P_NTHREADS)->setTranslatorForRolePropertySetter([](int role, const QVariant& value) { - if (role == Qt::DisplayRole && value.canConvert<ComboProperty>()) { - // first item was nThreads. Number of max threads has to be - // read from value, not from current machine's capabilities - const auto comboProperty = value.value<ComboProperty>(); - const int nThreads = comboProperty.getValues().size(); - const int selectedThreads = nThreads - comboProperty.currentIndex(); - return QVariant(selectedThreads); - } - return value; - }); - - getItem(P_COMPUTATION_METHOD_ANALYTICAL) - ->setTranslatorForRolePropertySetter([](int role, const QVariant& value) { - if (role == Qt::DisplayRole && value.canConvert<ComboProperty>()) - return QVariant(value.value<ComboProperty>().currentIndex() - == 0); // 0 was "Analytical" - return value; - }); - - getItem(P_AVERAGE_MATERIAL) - ->setTranslatorForRolePropertySetter([](int role, const QVariant& value) { - if (role == Qt::DisplayRole && value.canConvert<ComboProperty>()) - return QVariant(value.value<ComboProperty>().currentIndex() - == 1); // 1 was "Average" - return value; - }); - - getItem(P_INCLUDE_SPECULAR_PEAK) - ->setTranslatorForRolePropertySetter([](int role, const QVariant& value) { - if (role == Qt::DisplayRole && value.canConvert<ComboProperty>()) - return QVariant(value.value<ComboProperty>().currentIndex() == 1); // 1 was "Yes" - return value; - }); +namespace { +namespace Tags { +const QString RunImmediately("RunImmediately"); +const QString NumberOfThreads("NumberOfThreads"); +const QString Analytical("Analytical"); +const QString NumberOfMonteCarloPoints("NumberOfMonteCarloPoints"); +const QString UseAverageMaterials("UseAverageMaterials"); +const QString IncludeSpecularPeak("IncludeSpecularPeak"); +} // namespace Tags +} // namespace + +using namespace GUI::Session::XML; + +SimulationOptionsItem::SimulationOptionsItem() +{ + m_runImmediately = true; + m_numberOfThreads = std::thread::hardware_concurrency(); + m_computationMethodAnalytical = true; + m_numberOfMonteCarloPoints = 100; + m_useAverageMaterials = false; + m_includeSpecularPeak = false; } unsigned SimulationOptionsItem::numberOfThreads() const { - return getItemValue(P_NTHREADS).toUInt(); + return m_numberOfThreads; } void SimulationOptionsItem::setNumberOfThreads(unsigned number) { - setItemValue(P_NTHREADS, number); + m_numberOfThreads = number; } bool SimulationOptionsItem::runImmediately() const { - return getItemValue(P_RUN_IMMEDIATELY).toBool(); + return m_runImmediately; } bool SimulationOptionsItem::runInBackground() const @@ -96,18 +63,18 @@ bool SimulationOptionsItem::runInBackground() const void SimulationOptionsItem::setRunImmediately(bool runImmediately) { - setItemValue(P_RUN_IMMEDIATELY, runImmediately); + m_runImmediately = runImmediately; } void SimulationOptionsItem::setUseMonteCarloIntegration(int numberOfPoints) { - setItemValue(P_COMPUTATION_METHOD_ANALYTICAL, false); - setNumberOfMonteCarloPoints(numberOfPoints); + m_computationMethodAnalytical = false; + m_numberOfMonteCarloPoints = numberOfPoints; } void SimulationOptionsItem::setUseAnalytical() { - setItemValue(P_COMPUTATION_METHOD_ANALYTICAL, true); + m_computationMethodAnalytical = true; } bool SimulationOptionsItem::useMonteCarloIntegration() const @@ -117,35 +84,64 @@ bool SimulationOptionsItem::useMonteCarloIntegration() const bool SimulationOptionsItem::useAnalytical() const { - return getItemValue(P_COMPUTATION_METHOD_ANALYTICAL).toBool(); + return m_computationMethodAnalytical; } int SimulationOptionsItem::numberOfMonteCarloPoints() const { - return getItemValue(P_MC_POINTS).toInt(); + return m_numberOfMonteCarloPoints; } void SimulationOptionsItem::setNumberOfMonteCarloPoints(int npoints) { - setItemValue(P_MC_POINTS, npoints); + m_numberOfMonteCarloPoints = npoints; } void SimulationOptionsItem::setUseAverageMaterials(bool useAverageMaterials) { - setItemValue(P_AVERAGE_MATERIAL, useAverageMaterials); + m_useAverageMaterials = useAverageMaterials; } bool SimulationOptionsItem::useAverageMaterials() const { - return getItemValue(P_AVERAGE_MATERIAL).toBool(); + return m_useAverageMaterials; } void SimulationOptionsItem::setIncludeSpecularPeak(bool includeSpecularPeak) { - setItemValue(P_INCLUDE_SPECULAR_PEAK, includeSpecularPeak); + m_includeSpecularPeak = includeSpecularPeak; } bool SimulationOptionsItem::includeSpecularPeak() const { - return getItemValue(P_INCLUDE_SPECULAR_PEAK).toBool(); + return m_includeSpecularPeak; +} + +void SimulationOptionsItem::writeContentTo(QXmlStreamWriter* writer) const +{ + writeAttribute(writer, GUI::Session::XML::Version, int(1)); + writeAttribute(writer, Tags::RunImmediately, m_runImmediately); + writeAttribute(writer, Tags::NumberOfThreads, m_numberOfThreads); + writeAttribute(writer, Tags::Analytical, m_computationMethodAnalytical); + writeAttribute(writer, Tags::NumberOfMonteCarloPoints, m_numberOfMonteCarloPoints); + writeAttribute(writer, Tags::UseAverageMaterials, m_useAverageMaterials); + writeAttribute(writer, Tags::IncludeSpecularPeak, m_includeSpecularPeak); +} + +void SimulationOptionsItem::readContentFrom(QXmlStreamReader* reader) +{ + const int version = reader->attributes().value(GUI::Session::XML::Version).toInt(); + + if (version < 1) + throw DeserializationException::tooOld(); + + if (version > 1) + throw DeserializationException::tooNew(); + + m_runImmediately = readBoolAttribute(reader, Tags::RunImmediately); + m_numberOfThreads = readUIntAttribute(reader, Tags::NumberOfThreads); + m_computationMethodAnalytical = readBoolAttribute(reader, Tags::Analytical); + m_numberOfMonteCarloPoints = readUIntAttribute(reader, Tags::NumberOfMonteCarloPoints); + m_useAverageMaterials = readBoolAttribute(reader, Tags::UseAverageMaterials); + m_includeSpecularPeak = readBoolAttribute(reader, Tags::IncludeSpecularPeak); } diff --git a/GUI/Model/Session/SimulationOptionsItem.h b/GUI/Model/Session/SimulationOptionsItem.h index acb5dbc6210151922a811abe4a251f9173fbc9a7..6e79b150eba127538636459ade6e546627380973 100644 --- a/GUI/Model/Session/SimulationOptionsItem.h +++ b/GUI/Model/Session/SimulationOptionsItem.h @@ -15,25 +15,15 @@ #ifndef BORNAGAIN_GUI_MODEL_SESSION_SIMULATIONOPTIONSITEM_H #define BORNAGAIN_GUI_MODEL_SESSION_SIMULATIONOPTIONSITEM_H -#include "GUI/Model/Session/SessionItem.h" -#include <QMap> +class QXmlStreamWriter; +class QXmlStreamReader; //! The SimulationOptionsItem class holds simulation status (run policy, number of threads, //! integration flag). Used in SimulationView to define job settings. When job is started, -//! item is copied to the job as a child. - -class BA_CORE_API_ SimulationOptionsItem : public SessionItem { -private: - static constexpr auto P_RUN_IMMEDIATELY{"Run Policy"}; - static constexpr auto P_NTHREADS{"Number of Threads"}; - static constexpr auto P_COMPUTATION_METHOD_ANALYTICAL{"Computation method"}; - static constexpr auto P_MC_POINTS{"Number of MC points"}; - static constexpr auto P_AVERAGE_MATERIAL{"Material for Fresnel calculations"}; - static constexpr auto P_INCLUDE_SPECULAR_PEAK{"Include specular peak"}; +//! item is copied to the job. +class SimulationOptionsItem { public: - static constexpr auto M_TYPE{"SimulationOptions"}; - explicit SimulationOptionsItem(); void setNumberOfThreads(unsigned n); @@ -56,6 +46,17 @@ public: void setIncludeSpecularPeak(bool includeSpecularPeak); bool includeSpecularPeak() const; + + void writeContentTo(QXmlStreamWriter* writer) const; + void readContentFrom(QXmlStreamReader* reader); + +private: + bool m_runImmediately; + unsigned m_numberOfThreads; + bool m_computationMethodAnalytical; + unsigned m_numberOfMonteCarloPoints; + bool m_useAverageMaterials; + bool m_includeSpecularPeak; }; #endif // BORNAGAIN_GUI_MODEL_SESSION_SIMULATIONOPTIONSITEM_H