BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleForm.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/SampleDesigner/ParticleForm.cpp
6 //! @brief Implements class ParticleForm
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
20 #include "GUI/Util/ActionFactory.h"
24 #include <QAction>
25 
26 ParticleForm::ParticleForm(QWidget* parent, ParticleItem* particleItem, bool allowAbundance,
27  SampleEditorController* ec, bool allowRemove)
28  : QGroupBox(parent)
29 {
30  const QString formfactor =
32  setTitle("Particle (" + formfactor + ")");
33 
34  FormLayouter layouter(this, ec);
35  layouter.addRow("Material", new MaterialInplaceForm(this, particleItem, ec));
36  layouter.addGroupOfValues("Geometry", particleItem->formfactor_at_bottom()->geometryValues());
37  layouter.addVector(particleItem->positionVector(), false);
38  layouter.addSelection(particleItem->rotation());
39  if (allowAbundance)
40  layouter.addValue(particleItem->abundance());
41 
42  auto* collapser = GroupBoxCollapser::installIntoGroupBox(this);
43 
44  auto* showInRealSpaceAction = ActionFactory::createShowInRealSpaceAction(
45  this, "particle", [=] { ec->requestViewInRealSpace(particleItem); });
46  collapser->addAction(showInRealSpaceAction);
47 
48  if (allowRemove) {
50  this, "particle", [=] { ec->removeParticle(particleItem); });
51  collapser->addAction(m_removeAction);
52  }
53 }
54 
56 {
57  if (m_removeAction)
58  m_removeAction->setVisible(b);
59 }
Defines class ActionFactory.
Defines class FormFactorItemCatalog.
Defines FormFactorItems classes.
Defines classes FormLayouter.
Defines class GroupBoxCollapser.
Defines class MaterialInplaceForm.
Defines class ParticleForm.
Defines class ParticleItem.
Defines class VectorDescriptor.
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.
static QString menuEntry(const FormFactorItem *item)
virtual DoubleDescriptors geometryValues() const =0
Utility class to populate a QFormLayout.
Definition: FormLayouter.h:36
int addGroupOfValues(const QString &labelText, const DoubleDescriptors &values)
Adds a row with a bold printed label and a set of DoubleDescriptors.
int addRow(QWidget *w)
Convenience method to add a widget.
int addValue(const DoubleDescriptor &d)
Adds a row with a bold printed label and a DoubleSpinBox.
int addVector(const VectorDescriptor &d, bool vertically=true)
Adds a row with a bold printed label and the 3 values of a 3D vector.
int addSelection(const SelectionDescriptor< T > &d)
Add a row with a selection.
Definition: FormLayouter.h:170
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
DoubleDescriptor abundance() const
SelectionDescriptor< RotationItem * > rotation()
Returns selection descriptor for rotation methods.
VectorDescriptor positionVector() const
Form to select a material and to edit it in-place.
ParticleForm(QWidget *parent, ParticleItem *item, bool allowAbundance, SampleEditorController *ec, bool allowRemove=true)
void enableStructureEditing(bool b)
QAction * m_removeAction
Definition: ParticleForm.h:33
FormFactorItem * formfactor_at_bottom() const
Class to modify a sample from the layer oriented sample editor.
void requestViewInRealSpace(SampleItem item)
void removeParticle(ItemWithParticles *item)