diff --git a/GUI/Model/Sample/RoughnessCatalog.cpp b/GUI/Model/Sample/RoughnessCatalog.cpp index 06f0a33a5e5dc7be17e74ed40fb0d12ff88ebc85..a15fc4b469ead3b48f3e05f844968340fb0c568b 100644 --- a/GUI/Model/Sample/RoughnessCatalog.cpp +++ b/GUI/Model/Sample/RoughnessCatalog.cpp @@ -15,6 +15,7 @@ #include "GUI/Model/Sample/RoughnessCatalog.h" #include "Base/Util/Assert.h" #include "GUI/Model/Sample/RoughnessItems.h" +#include "Sample/Interface/RoughnessModels.h" RoughnessItem* RoughnessCatalog::create(Type type) { @@ -53,3 +54,43 @@ RoughnessCatalog::Type RoughnessCatalog::type(const RoughnessItem* item) ASSERT_NEVER; } + +//-------------------------------------------------------------------------- + +RoughnessModel* RoughnessModelCatalog::create(Type type) +{ + switch (type) { + case Type::Erf: + return new ErfRoughness(); + case Type::Tanh: + return new TanhRoughness(); + } + ASSERT_NEVER; +} + +QVector<RoughnessModelCatalog::Type> RoughnessModelCatalog::types() +{ + return {Type::Erf, Type::Tanh}; +} + +UiInfo RoughnessModelCatalog::uiInfo(Type type) +{ + switch (type) { + case Type::Erf: + return {"Erf", "Laterally averaged depth profile is Erf function", ""}; + case Type::Tanh: + return {"Tanh", "Laterally averaged depth profile is Tanh function", ""}; + } + ASSERT_NEVER; +} + +RoughnessModelCatalog::Type RoughnessModelCatalog::type(const RoughnessModel* model) +{ + if (dynamic_cast<const ErfRoughness*>(model)) + return Type::Erf; + + if (dynamic_cast<const TanhRoughness*>(model)) + return Type::Tanh; + + ASSERT_NEVER; +} diff --git a/GUI/Model/Sample/RoughnessCatalog.h b/GUI/Model/Sample/RoughnessCatalog.h index 51bc20fe9202eb4574c98efcb1896d681d3b8d95..92b126433a92255b77d43d760c97d8efefb89609 100644 --- a/GUI/Model/Sample/RoughnessCatalog.h +++ b/GUI/Model/Sample/RoughnessCatalog.h @@ -19,6 +19,7 @@ #include <QVector> class RoughnessItem; +class RoughnessModel; class RoughnessCatalog { public: @@ -38,4 +39,24 @@ public: static Type type(const RoughnessItem* item); }; +//-------------------------------------------------------------------------- + +class RoughnessModelCatalog { +public: + // Do not change the numbering! It is serialized! + enum class Type : uint8_t { Erf = 0, Tanh = 1 }; + + //! Creates the item of the given type. + static RoughnessModel* create(Type type); + + //! List of available types, sorted as expected in the UI. + static QVector<Type> types(); + + //! UiInfo on the given type. + static UiInfo uiInfo(Type t); + + //! Returns the enum type of the given item. + static Type type(const RoughnessModel* model); +}; + #endif // BORNAGAIN_GUI_MODEL_SAMPLE_ROUGHNESSCATALOG_H diff --git a/GUI/View/Sample/RoughnessForm.cpp b/GUI/View/Sample/RoughnessForm.cpp index 8500bce181e0063e1d204fc79e7f4fd8ce42db04..b68da12bdf4b8c7cdc9d4eb24ea4090f83f9da41 100644 --- a/GUI/View/Sample/RoughnessForm.cpp +++ b/GUI/View/Sample/RoughnessForm.cpp @@ -58,61 +58,7 @@ void RoughnessForm::createRoughnessWidgets() { RoughnessItem* roughness = m_rs.certainItem(); - if (auto* rsi = dynamic_cast<BasicRoughnessItem*>(roughness)) { - + if (auto* rsi = dynamic_cast<BasicRoughnessItem*>(roughness)) m_layout->addGroupOfValues("Parameters", rsi->roughnessProperties()); - - // m_layout->addValue(itf->positionVariance()); - // m_layout->addValue(itf->length()); - // m_layout->addValue(itf->rotationAngle()); - // m_layout->addSelection(itf->decayFunctionSelection()); - } - // else if (auto* itf = dynamic_cast<InterferenceRadialParacrystalItem*>(interference)) { - // m_layout->addValue(itf->positionVariance()); - // m_layout->addValue(itf->peakDistance()); - // m_layout->addValue(itf->dampingLength()); - // m_layout->addValue(itf->domainSize()); - // m_layout->addValue(itf->kappa()); - // m_layout->addSelection(itf->probabilityDistributionSelection()); - // } else if (auto* itf = dynamic_cast<InterferenceHardDiskItem*>(interference)) { - // m_layout->addValue(itf->positionVariance()); - // m_layout->addValue(itf->radius()); - // addDensityRelatedValue(itf->density()); - // } else if (auto* itf = dynamic_cast<Interference2DLatticeItem*>(interference)) { - // m_layout->addValue(itf->positionVariance()); - // auto* w = new LatticeTypeSelectionForm(this, itf, m_ec); - // m_layout->addBoldRow(itf->latticeTypeSelection().piLabel(), w); - // m_layout->addSelection(itf->decayFunctionSelection()); - // } else if (auto* itf = dynamic_cast<InterferenceFinite2DLatticeItem*>(interference)) { - // m_layout->addValue(itf->positionVariance()); - // m_layout->addBoldRow("Domain size 1:", - // GUI::Util::createIntSpinBox([itf] { return itf->domainSize1(); }, - // [itf](int v) { - // itf->setDomainSize1(v); - // emit gDoc->sampleChanged(); - // }, - // RealLimits::lowerLimited(1), - // "Domain size 1 in number of unit - // cells")); - // m_layout->addBoldRow("Domain size 2:", - // GUI::Util::createIntSpinBox([itf] { return itf->domainSize2(); }, - // [itf](int v) { - // itf->setDomainSize2(v); - // emit gDoc->sampleChanged(); - // }, - // RealLimits::lowerLimited(1), - // "Domain size 2 in number of unit - // cells")); - // auto* w = new LatticeTypeSelectionForm(this, itf, m_ec); - // m_layout->addBoldRow(itf->latticeTypeSelection().piLabel(), w); - // } else if (auto* itf = dynamic_cast<Interference2DParacrystalItem*>(interference)) { - // m_layout->addValue(itf->positionVariance()); - // m_layout->addValue(itf->dampingLength()); - // m_layout->addValue(itf->domainSize1()); - // m_layout->addValue(itf->domainSize2()); - // auto* w = new LatticeTypeSelectionForm(this, itf, m_ec); - // m_layout->addBoldRow(itf->latticeTypeSelection().piLabel(), w); - // m_layout->addSelection(itf->probabilityDistributionSelection1()); - // m_layout->addSelection(itf->probabilityDistributionSelection2()); - // } + // m_layout->addGroupOfValues("Parameters", rsi->roughnessProperties()); }