BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleCoreShellForm Class Reference

Description

Form for editing a core/shell particle.

Definition at line 28 of file ParticleCoreShellForm.h.

Inheritance diagram for ParticleCoreShellForm:
[legend]
Collaboration diagram for ParticleCoreShellForm:
[legend]

Classes

struct  Location
 

Public Member Functions

 ParticleCoreShellForm (QWidget *parent, ParticleCoreShellItem *item, SampleEditorController *ec, bool allowRemove=true)
 
ParticleCoreShellItemcoreShellItem () const
 
void createCoreWidgets ()
 
void createShellWidgets ()
 
void enableStructureEditing (bool b)
 

Private Member Functions

void onCoreComboChanged ()
 
void onShellComboChanged ()
 
void showCoreInRealSpace ()
 
void showShellInRealSpace ()
 

Private Attributes

Location core
 
SampleEditorControllerm_ec
 
ParticleCoreShellItemm_item
 
QAction * m_removeAction = nullptr
 
Location shell
 

Constructor & Destructor Documentation

◆ ParticleCoreShellForm()

ParticleCoreShellForm::ParticleCoreShellForm ( QWidget *  parent,
ParticleCoreShellItem item,
SampleEditorController ec,
bool  allowRemove = true 
)

Definition at line 52 of file ParticleCoreShellForm.cpp.

54  : QGroupBox(parent)
55  , m_item(item)
56  , m_ec(ec)
57 {
58  setTitle("Sim/shell particle");
59  FormLayouter layouter(this, ec);
60  layouter.setContentsMargins(30, 6, 0, 0);
61  layouter.addVector(item->positionVector(), false);
62  layouter.addSelection(item->rotation());
63  layouter.addValue(item->abundance());
64 
65  // - core
66  {
67  auto* coreParticleGroup = new QGroupBox(this);
68  coreParticleGroup->setObjectName("Particle");
69 
70  core.layouter = std::make_unique<FormLayouter>(coreParticleGroup, ec);
71 
72  core.formfactorCombo = createFormFactorCombo(
73  coreParticleGroup,
74  item->core() != nullptr ? item->core()->formfactor_at_bottom() : nullptr);
75  connect(core.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
77  core.layouter->addRow("Form factor:", core.formfactorCombo);
79 
80  auto* showInRealSpaceAction =
81  ActionFactory::createShowInRealSpaceAction(this, "core particle");
82  connect(showInRealSpaceAction, &QAction::triggered, this,
84  core.collapser->addAction(showInRealSpaceAction);
85 
87 
88  layouter.addRow(coreParticleGroup);
89  }
90 
91  // - shell
92  {
93  auto* shellParticleGroup = new QGroupBox(this);
94  shellParticleGroup->setObjectName("Particle");
95  shell.layouter = std::make_unique<FormLayouter>(shellParticleGroup, ec);
96  shell.formfactorCombo = createFormFactorCombo(
97  shellParticleGroup,
98  item->shell() != nullptr ? item->shell()->formfactor_at_bottom() : nullptr);
99  connect(shell.formfactorCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
101  shell.layouter->addRow("Form factor:", shell.formfactorCombo);
103 
104  auto* showInRealSpaceAction =
105  ActionFactory::createShowInRealSpaceAction(this, "shell particle");
106  connect(showInRealSpaceAction, &QAction::triggered, this,
108  shell.collapser->addAction(showInRealSpaceAction);
109 
111 
112  layouter.addRow(shellParticleGroup);
113  }
114 
115  auto* mainCollapser = GroupBoxCollapser::installIntoGroupBox(this);
116 
117  auto* showInRealSpaceAction = ActionFactory::createShowInRealSpaceAction(
118  this, "core/shell particle", [=] { ec->requestViewInRealSpace(item); });
119 
120  mainCollapser->addAction(showInRealSpaceAction);
121 
122  if (allowRemove) {
123  m_removeAction = ActionFactory::createRemoveAction(this, "core/shell particle",
124  [=] { ec->removeParticle(item); });
125  mainCollapser->addAction(m_removeAction);
126  }
127 }
static QAction * createShowInRealSpaceAction(QObject *parent, const QString &what, std::function< void()> slot=nullptr)
Create "show in RealSpace" action.
static QAction * createRemoveAction(QObject *parent, const QString &what, std::function< void()> slot=nullptr)
Create "remove" action.
Utility class to populate a QFormLayout.
Definition: FormLayouter.h:36
void addAction(QAction *action)
Add a tool button to the title bar, connected to the given action.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
DoubleDescriptor abundance() const
SelectionDescriptor< RotationItem * > rotation()
Returns selection descriptor for rotation methods.
VectorDescriptor positionVector() const
SampleEditorController * m_ec
ParticleCoreShellItem * m_item
ParticleItem * shell() const
ParticleItem * core() const
FormFactorItem * formfactor_at_bottom() const
void requestViewInRealSpace(SampleItem item)
void removeParticle(ItemWithParticles *item)
std::unique_ptr< FormLayouter > layouter

References ItemWithParticles::abundance(), GroupBoxCollapser::addAction(), FormLayouter::addRow(), FormLayouter::addSelection(), FormLayouter::addValue(), FormLayouter::addVector(), ParticleCoreShellForm::Location::collapser, ParticleCoreShellItem::core(), core, createCoreWidgets(), ActionFactory::createRemoveAction(), createShellWidgets(), ActionFactory::createShowInRealSpaceAction(), ParticleItem::formfactor_at_bottom(), ParticleCoreShellForm::Location::formfactorCombo, GroupBoxCollapser::installIntoGroupBox(), ParticleCoreShellForm::Location::layouter, m_removeAction, onCoreComboChanged(), onShellComboChanged(), ItemWithParticles::positionVector(), SampleEditorController::removeParticle(), SampleEditorController::requestViewInRealSpace(), ItemWithParticles::rotation(), FormLayouter::setContentsMargins(), ParticleCoreShellItem::shell(), shell, showCoreInRealSpace(), and showShellInRealSpace().

Here is the call graph for this function:

Member Function Documentation

◆ coreShellItem()

ParticleCoreShellItem * ParticleCoreShellForm::coreShellItem ( ) const

Definition at line 203 of file ParticleCoreShellForm.cpp.

204 {
205  return m_item;
206 }

References m_item.

Referenced by SampleEditorController::setCoreFormFactor(), and SampleEditorController::setShellFormFactor().

◆ createCoreWidgets()

void ParticleCoreShellForm::createCoreWidgets ( )

Definition at line 159 of file ParticleCoreShellForm.cpp.

160 {
161  QString groupTitle = "Core";
162 
163  if (ParticleItem* particle = m_item->core()) {
164  const QString formfactor =
165  FormFactorItemCatalog::menuEntry(particle->formfactor_at_bottom());
166  groupTitle += " (" + formfactor + ")";
167 
168  core.layouter->addGroupOfValues("Geometry",
169  particle->formfactor_at_bottom()->geometryValues());
170  core.layouter->addVector(particle->positionVector(), false);
171  core.layouter->addSelection(particle->rotation());
172  // no abundance since this is handled in CoreShell itself!
173  }
174 
175  core.collapser->setTitle(groupTitle);
176 }
static QString menuEntry(const FormFactorItem *item)
void setTitle(const QString &title)
Set the title of the group box. Do not use the method groupBox->setTitle() any more once the add-on i...

References ParticleCoreShellForm::Location::collapser, ParticleCoreShellItem::core(), core, ParticleCoreShellForm::Location::layouter, m_item, FormFactorItemCatalog::menuEntry(), and GroupBoxCollapser::setTitle().

Referenced by ParticleCoreShellForm(), and SampleEditorController::setCoreFormFactor().

Here is the call graph for this function:

◆ createShellWidgets()

void ParticleCoreShellForm::createShellWidgets ( )

Definition at line 178 of file ParticleCoreShellForm.cpp.

179 {
180  QString groupTitle = "Shell";
181 
182  if (ParticleItem* particle = m_item->shell()) {
183  const QString formfactor =
184  FormFactorItemCatalog::menuEntry(particle->formfactor_at_bottom());
185  groupTitle += " (" + formfactor + ")";
186 
187  shell.layouter->addGroupOfValues("Geometry",
188  particle->formfactor_at_bottom()->geometryValues());
189  shell.layouter->addSelection(particle->rotation());
190  // no position vector - not allowed in CoreShell
191  // no abundance since this is handled in CoreShell itself!
192  }
193 
194  shell.collapser->setTitle(groupTitle);
195 }

References ParticleCoreShellForm::Location::collapser, ParticleCoreShellForm::Location::layouter, m_item, FormFactorItemCatalog::menuEntry(), GroupBoxCollapser::setTitle(), ParticleCoreShellItem::shell(), and shell.

Referenced by ParticleCoreShellForm(), and SampleEditorController::setShellFormFactor().

Here is the call graph for this function:

◆ enableStructureEditing()

void ParticleCoreShellForm::enableStructureEditing ( bool  b)

Definition at line 197 of file ParticleCoreShellForm.cpp.

198 {
199  if (m_removeAction)
200  m_removeAction->setVisible(b);
201 }

References m_removeAction.

◆ onCoreComboChanged()

void ParticleCoreShellForm::onCoreComboChanged ( )
private

Definition at line 129 of file ParticleCoreShellForm.cpp.

130 {
131  while (core.layouter->layout()->rowCount() > 1)
132  core.layouter->layout()->removeRow(1);
133 
134  const auto type = (FormFactorItemCatalog::Type)core.formfactorCombo->currentData().toUInt();
135  m_ec->setCoreFormFactor(this, type);
136 }
void setCoreFormFactor(ParticleCoreShellForm *widget, FormFactorItemCatalog::Type type)

References core, ParticleCoreShellForm::Location::formfactorCombo, ParticleCoreShellForm::Location::layouter, m_ec, and SampleEditorController::setCoreFormFactor().

Referenced by ParticleCoreShellForm().

Here is the call graph for this function:

◆ onShellComboChanged()

void ParticleCoreShellForm::onShellComboChanged ( )
private

Definition at line 138 of file ParticleCoreShellForm.cpp.

139 {
140  while (shell.layouter->layout()->rowCount() > 1)
141  shell.layouter->layout()->removeRow(1);
142 
143  const auto type = (FormFactorItemCatalog::Type)shell.formfactorCombo->currentData().toUInt();
144  m_ec->setShellFormFactor(this, type);
145 }
void setShellFormFactor(ParticleCoreShellForm *widget, FormFactorItemCatalog::Type type)

References ParticleCoreShellForm::Location::formfactorCombo, ParticleCoreShellForm::Location::layouter, m_ec, SampleEditorController::setShellFormFactor(), and shell.

Referenced by ParticleCoreShellForm().

Here is the call graph for this function:

◆ showCoreInRealSpace()

void ParticleCoreShellForm::showCoreInRealSpace ( )
private

Definition at line 147 of file ParticleCoreShellForm.cpp.

148 {
149  if (m_item->core())
151 }

References ParticleCoreShellItem::core(), m_ec, m_item, and SampleEditorController::requestViewInRealSpace().

Referenced by ParticleCoreShellForm().

Here is the call graph for this function:

◆ showShellInRealSpace()

void ParticleCoreShellForm::showShellInRealSpace ( )
private

Definition at line 153 of file ParticleCoreShellForm.cpp.

154 {
155  if (m_item->shell())
157 }

References m_ec, m_item, SampleEditorController::requestViewInRealSpace(), and ParticleCoreShellItem::shell().

Referenced by ParticleCoreShellForm().

Here is the call graph for this function:

Member Data Documentation

◆ core

Location ParticleCoreShellForm::core
private

◆ m_ec

SampleEditorController* ParticleCoreShellForm::m_ec
private

◆ m_item

ParticleCoreShellItem* ParticleCoreShellForm::m_item
private

◆ m_removeAction

QAction* ParticleCoreShellForm::m_removeAction = nullptr
private

Definition at line 49 of file ParticleCoreShellForm.h.

Referenced by ParticleCoreShellForm(), and enableStructureEditing().

◆ shell

Location ParticleCoreShellForm::shell
private

The documentation for this class was generated from the following files: