Skip to content
Snippets Groups Projects
Commit 0aebfd7c authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

add RoughnessModelCatalog

parent 6f655bb8
No related branches found
No related tags found
1 merge request!2703Allow changing roughness height statistics in GUI
......@@ -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;
}
......@@ -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
......@@ -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());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment