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

add RoughnessForm

parent 11a47b59
No related branches found
No related tags found
1 merge request!2703Allow changing roughness height statistics in GUI
Pipeline #153987 failed
...@@ -124,11 +124,12 @@ void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters) ...@@ -124,11 +124,12 @@ void MinimizerAdapter::propagateResults(mumufit::Parameters& parameters)
parameters.setErrors(parErrorsAtMinimum()); parameters.setErrors(parErrorsAtMinimum());
// sets correlation matrix // sets correlation matrix
if (providesError()) { if (providesError()) {
auto lambda = [&](size_t i, size_t j) -> double auto lambda = [&](size_t i, size_t j) -> double {
{ return rootMinimizer()->Correlation(static_cast<unsigned int>(i), return rootMinimizer()->Correlation(static_cast<unsigned int>(i),
static_cast<unsigned int>(j)); }; static_cast<unsigned int>(j));
double2d_t matrix = FieldUtil::make<double>(fitRank(), fitRank(), lambda); };
parameters.setCorrelationMatrix(matrix); double2d_t matrix = FieldUtil::make<double>(fitRank(), fitRank(), lambda);
parameters.setCorrelationMatrix(matrix);
} }
} }
......
...@@ -93,12 +93,6 @@ void HeinzFormLayout::addVector(VectorProperty& d, bool vertically /*= true*/) ...@@ -93,12 +93,6 @@ void HeinzFormLayout::addVector(VectorProperty& d, bool vertically /*= true*/)
addBoldRow(d.label(), w); addBoldRow(d.label(), w);
} }
void HeinzFormLayout::setRowVisible(int row, bool visible)
{
QFormLayout::itemAt(row, QFormLayout::LabelRole)->widget()->setVisible(visible);
QFormLayout::itemAt(row, QFormLayout::FieldRole)->widget()->setVisible(visible);
}
void HeinzFormLayout::addStructureEditingRow(QPushButton* button) void HeinzFormLayout::addStructureEditingRow(QPushButton* button)
{ {
auto* w = new QWidget(QFormLayout::parentWidget()); auto* w = new QWidget(QFormLayout::parentWidget());
......
...@@ -108,9 +108,6 @@ public: ...@@ -108,9 +108,6 @@ public:
//! (vertically=false). //! (vertically=false).
void addVector(VectorProperty& d, bool vertically = true); void addVector(VectorProperty& d, bool vertically = true);
//! Shows or hides the widgets in a row.
void setRowVisible(int row, bool visible);
//! Adds a button for structure editing. //! Adds a button for structure editing.
//! //!
//! Creates a widget, places the given button as a child left-aligned into this widget and adds //! Creates a widget, places the given button as a child left-aligned into this widget and adds
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "GUI/View/Sample/HeinzFormLayout.h" #include "GUI/View/Sample/HeinzFormLayout.h"
#include "GUI/View/Sample/MaterialInplaceForm.h" #include "GUI/View/Sample/MaterialInplaceForm.h"
#include "GUI/View/Sample/ParticleLayoutForm.h" #include "GUI/View/Sample/ParticleLayoutForm.h"
#include "GUI/View/Sample/RoughnessForm.h"
#include "GUI/View/Widget/WidgetMoverButton.h" #include "GUI/View/Widget/WidgetMoverButton.h"
#include <QLineEdit> #include <QLineEdit>
#include <QMenu> #include <QMenu>
...@@ -111,7 +112,8 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorControll ...@@ -111,7 +112,8 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorControll
"Used for Average Layer Material calculations \n" "Used for Average Layer Material calculations \n"
"when corresponding simulation option is set.")); "when corresponding simulation option is set."));
m_layout->addSelection(m_layer->roughnessSelection()); // m_layout->addSelection(m_layer->roughnessSelection());
m_layout->addRow(new RoughnessForm(this, m_layer->roughnessSelection(), m_ec));
m_roughness_row = m_layout->rowCount() - 1; m_roughness_row = m_layout->rowCount() - 1;
// -- layouts // -- layouts
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Sample/RoughnessForm.cpp
//! @brief Implements class RoughnessForm.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2024
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/View/Sample/RoughnessForm.h"
#include "GUI/Model/Sample/RoughnessCatalog.h"
#include "GUI/Model/Sample/RoughnessItems.h"
#include "GUI/View/Sample/HeinzFormLayout.h"
RoughnessForm::RoughnessForm(QWidget* parent,
PolyPtr<RoughnessItem, RoughnessCatalog>& roughnessSelection,
SampleEditorController* ec)
: CollapsibleGroupBox(parent, expandRoughness)
, m_cb(new QComboBox(this))
, m_rs(roughnessSelection)
{
m_layout = new HeinzFormLayout(ec);
body()->setLayout(m_layout);
WheelEventEater::install(m_cb);
m_cb->addItems(m_rs.menuEntries());
m_cb->setCurrentIndex(m_rs.certainIndex());
m_cb->setMaxVisibleItems(m_cb->count());
m_cb->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
m_layout->addBoldRow("Type:", m_cb);
createRoughnessWidgets();
updateTitle();
connect(m_cb, &QComboBox::currentIndexChanged, [this](int) { onRoughnessTypeChanged(); });
}
void RoughnessForm::updateTitle()
{
setTitle("Roughness (" + m_cb->currentText() + ")");
}
void RoughnessForm::onRoughnessTypeChanged()
{
while (m_layout->rowCount() > 1)
m_layout->removeRow(1);
createRoughnessWidgets();
updateTitle();
}
void RoughnessForm::createRoughnessWidgets()
{
RoughnessItem* roughness = m_rs.certainItem();
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());
// }
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Sample/RoughnessForm.h
//! @brief Defines class RoughnessForm.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2024
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEW_SAMPLE_ROUGHNESSFORM_H
#define BORNAGAIN_GUI_VIEW_SAMPLE_ROUGHNESSFORM_H
#include "GUI/Model/Descriptor/PolyPtr.h"
#include "GUI/View/Widget/GroupBoxes.h"
#include <QComboBox>
class HeinzFormLayout;
class RoughnessCatalog;
class RoughnessItem;
class SampleEditorController;
class RoughnessForm : public CollapsibleGroupBox {
public:
RoughnessForm(QWidget* parent, PolyPtr<RoughnessItem, RoughnessCatalog>& roughnessSelection,
SampleEditorController* ec);
void onRoughnessTypeChanged();
private:
void updateTitle();
void createRoughnessWidgets();
HeinzFormLayout* m_layout;
QComboBox* m_cb;
PolyPtr<RoughnessItem, RoughnessCatalog>& m_rs;
bool expandRoughness = true;
};
#endif // BORNAGAIN_GUI_VIEW_SAMPLE_ROUGHNESSFORM_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