Skip to content
Snippets Groups Projects
Commit 57f45182 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm 'using'

parent fe3e41ee
No related branches found
No related tags found
1 merge request!2696PolyItem -> PolyPtr, with BaseItem as separate template parameter
...@@ -37,6 +37,14 @@ using std::variant; ...@@ -37,6 +37,14 @@ using std::variant;
namespace { namespace {
template <typename BaseItem, typename Catalog>
ParameterLabelItem* addLabel2(ParameterLabelItem* parent, const QString& category,
const BaseItem* p)
{
const auto title = category + " (" + Catalog::uiInfo(Catalog::type(p)).menuEntry + ")";
return new ParameterLabelItem(title, parent);
}
template <typename Catalog> template <typename Catalog>
ParameterLabelItem* addLabel(ParameterLabelItem* parent, const QString& category, ParameterLabelItem* addLabel(ParameterLabelItem* parent, const QString& category,
const typename Catalog::BaseItem* p) const typename Catalog::BaseItem* p)
...@@ -196,7 +204,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, ...@@ -196,7 +204,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel,
addParameterItem(label, itf->kappa()); addParameterItem(label, itf->kappa());
auto* pdf = itf->probabilityDistributionSelection().certainItem(); auto* pdf = itf->probabilityDistributionSelection().certainItem();
auto* pdfLabel = addLabel<Profile1DCatalog>(label, "PDF", pdf); auto* pdfLabel = addLabel2<Profile1DItem, Profile1DCatalog>(label, "PDF", pdf);
for (auto* d : pdf->profileProperties()) for (auto* d : pdf->profileProperties())
addParameterItem(pdfLabel, *d); addParameterItem(pdfLabel, *d);
} else if (auto* itf = dynamic_cast<Interference2DParacrystalItem*>(interference)) { } else if (auto* itf = dynamic_cast<Interference2DParacrystalItem*>(interference)) {
...@@ -209,10 +217,10 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, ...@@ -209,10 +217,10 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel,
auto* pdf1 = itf->probabilityDistributionSelection1().certainItem(); auto* pdf1 = itf->probabilityDistributionSelection1().certainItem();
auto* pdf2 = itf->probabilityDistributionSelection2().certainItem(); auto* pdf2 = itf->probabilityDistributionSelection2().certainItem();
const bool samePdfTypes = Profile2DCatalog::type(pdf1) == Profile2DCatalog::type(pdf2); const bool samePdfTypes = Profile2DCatalog::type(pdf1) == Profile2DCatalog::type(pdf2);
auto* pdf1Label = addLabel<Profile2DCatalog>(label, samePdfTypes ? "PDF1" : "PDF", pdf1); auto* pdf1Label = addLabel2<Profile2DItem, Profile2DCatalog>(label, samePdfTypes ? "PDF1" : "PDF", pdf1);
for (auto* d : pdf1->profileProperties()) for (auto* d : pdf1->profileProperties())
addParameterItem(pdf1Label, *d); addParameterItem(pdf1Label, *d);
auto* pdf2Label = addLabel<Profile2DCatalog>(label, samePdfTypes ? "PDF2" : "PDF", pdf2); auto* pdf2Label = addLabel2<Profile2DItem, Profile2DCatalog>(label, samePdfTypes ? "PDF2" : "PDF", pdf2);
for (auto* d : pdf2->profileProperties()) for (auto* d : pdf2->profileProperties())
addParameterItem(pdf2Label, *d); addParameterItem(pdf2Label, *d);
} else if (auto* itf = dynamic_cast<Interference1DLatticeItem*>(interference)) { } else if (auto* itf = dynamic_cast<Interference1DLatticeItem*>(interference)) {
...@@ -221,7 +229,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, ...@@ -221,7 +229,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel,
addParameterItem(label, itf->rotationAngle()); addParameterItem(label, itf->rotationAngle());
auto* df = itf->decayFunctionSelection().certainItem(); auto* df = itf->decayFunctionSelection().certainItem();
auto* dfLabel = addLabel<Profile1DCatalog>(label, "Decay function", df); auto* dfLabel = addLabel2<Profile1DItem, Profile1DCatalog>(label, "Decay function", df);
for (auto* d : df->profileProperties()) for (auto* d : df->profileProperties())
addParameterItem(dfLabel, *d); addParameterItem(dfLabel, *d);
} else if (auto* itf = dynamic_cast<Interference2DLatticeItem*>(interference)) { } else if (auto* itf = dynamic_cast<Interference2DLatticeItem*>(interference)) {
...@@ -229,7 +237,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel, ...@@ -229,7 +237,7 @@ void ParameterTreeBuilder::addInterference(ParameterLabelItem* layoutLabel,
addLattice(label, itf); addLattice(label, itf);
auto* df = itf->decayFunctionSelection().certainItem(); auto* df = itf->decayFunctionSelection().certainItem();
auto* dfLabel = addLabel<Profile2DCatalog>(label, "Decay function", df); auto* dfLabel = addLabel2<Profile2DItem, Profile2DCatalog>(label, "Decay function", df);
for (auto* d : df->profileProperties()) for (auto* d : df->profileProperties())
addParameterItem(dfLabel, *d); addParameterItem(dfLabel, *d);
} else if (auto* itf = dynamic_cast<InterferenceFinite2DLatticeItem*>(interference)) { } else if (auto* itf = dynamic_cast<InterferenceFinite2DLatticeItem*>(interference)) {
...@@ -293,7 +301,7 @@ void ParameterTreeBuilder::addLattice(ParameterLabelItem* parentLabel, ...@@ -293,7 +301,7 @@ void ParameterTreeBuilder::addLattice(ParameterLabelItem* parentLabel,
const Interference2DAbstractLatticeItem* itf) const Interference2DAbstractLatticeItem* itf)
{ {
auto* lattice = itf->latticeTypeItem(); auto* lattice = itf->latticeTypeItem();
auto* label = addLabel<Lattice2DCatalog>(parentLabel, "Lattice", lattice); auto* label = addLabel2<Lattice2DItem, Lattice2DCatalog>(parentLabel, "Lattice", lattice);
for (auto* d : lattice->geometryValues(!itf->xiIntegration())) for (auto* d : lattice->geometryValues(!itf->xiIntegration()))
addParameterItem(label, *d); addParameterItem(label, *d);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "GUI/Model/Sample/Lattice2DItems.h" #include "GUI/Model/Sample/Lattice2DItems.h"
Lattice2DCatalog::BaseItem* Lattice2DCatalog::create(Type type) Lattice2DItem* Lattice2DCatalog::create(Type type)
{ {
switch (type) { switch (type) {
case Type::Basic: case Type::Basic:
...@@ -49,7 +49,7 @@ UiInfo Lattice2DCatalog::uiInfo(Type type) ...@@ -49,7 +49,7 @@ UiInfo Lattice2DCatalog::uiInfo(Type type)
} }
} }
Lattice2DCatalog::Type Lattice2DCatalog::type(const BaseItem* item) Lattice2DCatalog::Type Lattice2DCatalog::type(const Lattice2DItem* item)
{ {
ASSERT(item); ASSERT(item);
......
...@@ -22,13 +22,11 @@ class Lattice2DItem; ...@@ -22,13 +22,11 @@ class Lattice2DItem;
class Lattice2DCatalog { class Lattice2DCatalog {
public: public:
using BaseItem = Lattice2DItem;
// Do not change the numbering! It is serialized! // Do not change the numbering! It is serialized!
enum class Type : uint8_t { Basic = 1, Square = 2, Hexagonal }; enum class Type : uint8_t { Basic = 1, Square = 2, Hexagonal };
//! Creates the item of the given type. //! Creates the item of the given type.
static BaseItem* create(Type type); static Lattice2DItem* create(Type type);
//! List of available types, sorted as expected in the UI. //! List of available types, sorted as expected in the UI.
static QVector<Type> types(); static QVector<Type> types();
...@@ -37,7 +35,7 @@ public: ...@@ -37,7 +35,7 @@ public:
static UiInfo uiInfo(Type t); static UiInfo uiInfo(Type t);
//! Returns the enum type of the given item. //! Returns the enum type of the given item.
static Type type(const BaseItem* item); static Type type(const Lattice2DItem* item);
}; };
#endif // BORNAGAIN_GUI_MODEL_SAMPLE_LATTICE2DCATALOG_H #endif // BORNAGAIN_GUI_MODEL_SAMPLE_LATTICE2DCATALOG_H
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "GUI/Model/Sample/ProfileItems.h" #include "GUI/Model/Sample/ProfileItems.h"
Profile1DCatalog::BaseItem* Profile1DCatalog::create(Type type) Profile1DItem* Profile1DCatalog::create(Type type)
{ {
switch (type) { switch (type) {
case Type::Cauchy: case Type::Cauchy:
...@@ -61,7 +61,7 @@ UiInfo Profile1DCatalog::uiInfo(Type type) ...@@ -61,7 +61,7 @@ UiInfo Profile1DCatalog::uiInfo(Type type)
} }
} }
Profile1DCatalog::Type Profile1DCatalog::type(const BaseItem* item) Profile1DCatalog::Type Profile1DCatalog::type(const Profile1DItem* item)
{ {
ASSERT(item); ASSERT(item);
...@@ -82,7 +82,7 @@ Profile1DCatalog::Type Profile1DCatalog::type(const BaseItem* item) ...@@ -82,7 +82,7 @@ Profile1DCatalog::Type Profile1DCatalog::type(const BaseItem* item)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
Profile2DCatalog::BaseItem* Profile2DCatalog::create(Type type) Profile2DItem* Profile2DCatalog::create(Type type)
{ {
switch (type) { switch (type) {
case Type::Cauchy: case Type::Cauchy:
...@@ -123,7 +123,7 @@ UiInfo Profile2DCatalog::uiInfo(Type type) ...@@ -123,7 +123,7 @@ UiInfo Profile2DCatalog::uiInfo(Type type)
} }
} }
Profile2DCatalog::Type Profile2DCatalog::type(const BaseItem* item) Profile2DCatalog::Type Profile2DCatalog::type(const Profile2DItem* item)
{ {
ASSERT(item); ASSERT(item);
......
...@@ -23,8 +23,6 @@ class Profile2DItem; ...@@ -23,8 +23,6 @@ class Profile2DItem;
class Profile1DCatalog { class Profile1DCatalog {
public: public:
using BaseItem = Profile1DItem;
// Do not change the numbering! It is serialized! // Do not change the numbering! It is serialized!
enum class Type : uint8_t { enum class Type : uint8_t {
Cauchy = 1, Cauchy = 1,
...@@ -36,7 +34,7 @@ public: ...@@ -36,7 +34,7 @@ public:
}; };
//! Creates the item of the given type. //! Creates the item of the given type.
static BaseItem* create(Type type); static Profile1DItem* create(Type type);
//! List of available types, sorted as expected in the UI. //! List of available types, sorted as expected in the UI.
static QVector<Type> types(); static QVector<Type> types();
...@@ -45,18 +43,16 @@ public: ...@@ -45,18 +43,16 @@ public:
static UiInfo uiInfo(Type t); static UiInfo uiInfo(Type t);
//! Returns the enum type of the given item. //! Returns the enum type of the given item.
static Type type(const BaseItem* item); static Type type(const Profile1DItem* item);
}; };
class Profile2DCatalog { class Profile2DCatalog {
public: public:
using BaseItem = Profile2DItem;
// Do not change the numbering! It is serialized! // Do not change the numbering! It is serialized!
enum class Type : uint8_t { Cauchy = 1, Gauss = 2, Gate = 3, Cone = 4, Voigt = 5 }; enum class Type : uint8_t { Cauchy = 1, Gauss = 2, Gate = 3, Cone = 4, Voigt = 5 };
//! Creates the item of the given type. //! Creates the item of the given type.
static BaseItem* create(Type type); static Profile2DItem* create(Type type);
//! List of available types, sorted as expected in the UI. //! List of available types, sorted as expected in the UI.
static QVector<Type> types(); static QVector<Type> types();
...@@ -65,7 +61,7 @@ public: ...@@ -65,7 +61,7 @@ public:
static UiInfo uiInfo(Type t); static UiInfo uiInfo(Type t);
//! Returns the enum type of the given item. //! Returns the enum type of the given item.
static Type type(const BaseItem* item); static Type type(const Profile2DItem* item);
}; };
#endif // BORNAGAIN_GUI_MODEL_SAMPLE_PROFILECATALOGS_H #endif // BORNAGAIN_GUI_MODEL_SAMPLE_PROFILECATALOGS_H
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