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

Description

Form for editing a mesocrystal.

Definition at line 28 of file MesoCrystalForm.h.

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

Public Member Functions

 MesoCrystalForm (QWidget *parent, MesoCrystalItem *item, SampleEditorController *ec, bool allowRemove=true)
 
void createBasisWidgets ()
 
void enableStructureEditing (bool b)
 
MesoCrystalItemmesoCrystalItem () const
 

Private Member Functions

QComboBox * createBasisCombo (QWidget *parent, ItemWithParticles *current)
 
void onBasisComboChanged ()
 

Private Attributes

QComboBox * m_basisCombo
 
SampleEditorControllerm_ec
 
MesoCrystalItemm_item
 
QFormLayout * m_layout
 
QAction * m_removeAction = nullptr
 
int m_rowOfBasisTypeCombo
 

Constructor & Destructor Documentation

◆ MesoCrystalForm()

MesoCrystalForm::MesoCrystalForm ( QWidget *  parent,
MesoCrystalItem item,
SampleEditorController ec,
bool  allowRemove = true 
)

Definition at line 26 of file MesoCrystalForm.cpp.

28  : QGroupBox(parent)
29  , m_item(item)
30  , m_ec(ec)
31 {
32  setTitle("Meso crystal");
33  setObjectName("MesoCrystal");
34  FormLayouter layouter(this, ec);
35  m_layout = layouter.layout();
36  layouter.setContentsMargins(30, 6, 0, 0);
37  layouter.addVector(item->positionVector(), false);
38  layouter.addSelection(item->rotation());
39  layouter.addValue(item->abundance());
40  layouter.addVector(item->vectorA(), false);
41  layouter.addVector(item->vectorB(), false);
42  layouter.addVector(item->vectorC(), false);
43 
44  layouter.addSelection(item->outerShape());
45 
47  connect(m_basisCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
49  m_rowOfBasisTypeCombo = layouter.addRow("Basis type", m_basisCombo);
51 
52  auto* collapser = GroupBoxCollapser::installIntoGroupBox(this);
53 
54  auto* showInRealSpaceAction = ActionFactory::createShowInRealSpaceAction(
55  this, "meso crystal", [=] { ec->requestViewInRealSpace(item); });
56  collapser->addAction(showInRealSpaceAction);
57 
58  if (allowRemove) {
60  [=] { ec->removeParticle(item); });
61  collapser->addAction(m_removeAction);
62  }
63 }
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
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
DoubleDescriptor abundance() const
SelectionDescriptor< RotationItem * > rotation()
Returns selection descriptor for rotation methods.
VectorDescriptor positionVector() const
QComboBox * m_basisCombo
MesoCrystalItem * m_item
QComboBox * createBasisCombo(QWidget *parent, ItemWithParticles *current)
QFormLayout * m_layout
SampleEditorController * m_ec
QAction * m_removeAction
VectorDescriptor vectorB() const
VectorDescriptor vectorC() const
VectorDescriptor vectorA() const
SelectionDescriptor< FormFactorItem * > outerShape() const
ItemWithParticles * basisParticle() const
void requestViewInRealSpace(SampleItem item)
void removeParticle(ItemWithParticles *item)

References ItemWithParticles::abundance(), FormLayouter::addRow(), FormLayouter::addSelection(), FormLayouter::addValue(), FormLayouter::addVector(), MesoCrystalItem::basisParticle(), createBasisCombo(), createBasisWidgets(), ActionFactory::createRemoveAction(), ActionFactory::createShowInRealSpaceAction(), GroupBoxCollapser::installIntoGroupBox(), FormLayouter::layout(), m_basisCombo, m_layout, m_removeAction, m_rowOfBasisTypeCombo, onBasisComboChanged(), MesoCrystalItem::outerShape(), ItemWithParticles::positionVector(), SampleEditorController::removeParticle(), SampleEditorController::requestViewInRealSpace(), ItemWithParticles::rotation(), FormLayouter::setContentsMargins(), MesoCrystalItem::vectorA(), MesoCrystalItem::vectorB(), and MesoCrystalItem::vectorC().

Here is the call graph for this function:

Member Function Documentation

◆ createBasisCombo()

QComboBox * MesoCrystalForm::createBasisCombo ( QWidget *  parent,
ItemWithParticles current 
)
private

Definition at line 65 of file MesoCrystalForm.cpp.

66 {
67  auto* combo = new QComboBox(parent);
69  combo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
70 
71  uint32_t currentData = 0;
72  for (auto type : FormFactorItemCatalog::types()) {
73  const auto ui = FormFactorItemCatalog::uiInfo(type);
74  combo->addItem(QIcon(ui.iconPath), ui.menuEntry, static_cast<uint32_t>(type));
75  if (auto* p = dynamic_cast<ParticleItem*>(current))
76  if (FormFactorItemCatalog::type(p->formfactor_at_bottom()) == type)
77  currentData = static_cast<uint32_t>(type);
78  }
79  for (auto type : ItemWithParticlesCatalog::assemblyTypes()) {
80  const auto ui = ItemWithParticlesCatalog::uiInfo(type);
81  combo->addItem(QIcon(ui.iconPath), ui.menuEntry, 1000 + static_cast<uint32_t>(type));
82  if (ItemWithParticlesCatalog::type(current) == type)
83  currentData = 1000 + static_cast<uint32_t>(type);
84  }
85 
86  combo->setMaxVisibleItems(combo->count());
87 
88  const auto currentIndex = combo->findData(currentData);
89  ASSERT(currentIndex >= 0);
90  combo->setCurrentIndex(currentIndex);
91 
92  return combo;
93 }
static QVector< Type > types()
Available types of interference items.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static Type type(const FormFactorItem *item)
Returns the enum type of the given item.
static Type type(const ItemWithParticles *item)
Returns the enum type of the given item.
static QVector< Type > assemblyTypes()
Available types of assembly items, sorted as expected in the UI (e.g. in combo box)
static UiInfo uiInfo(Type t)
UiInfo on the given type.
static void install(QObject *obj)

References ItemWithParticlesCatalog::assemblyTypes(), WheelEventEater::install(), FormFactorItemCatalog::type(), ItemWithParticlesCatalog::type(), FormFactorItemCatalog::types(), FormFactorItemCatalog::uiInfo(), and ItemWithParticlesCatalog::uiInfo().

Referenced by MesoCrystalForm().

Here is the call graph for this function:

◆ createBasisWidgets()

void MesoCrystalForm::createBasisWidgets ( )

Definition at line 108 of file MesoCrystalForm.cpp.

109 {
110  if (!m_item->basisParticle())
111  return;
112 
114  this, m_item->basisParticle(), false, m_ec, false));
115 }
QWidget * createWidgetForItemWithParticles(QWidget *parentWidget, ItemWithParticles *itemWithParticles, bool allowAbundance, SampleEditorController *ec, bool allowRemove=true)

References MesoCrystalItem::basisParticle(), LayerEditorUtils::createWidgetForItemWithParticles(), m_ec, m_item, and m_layout.

Referenced by MesoCrystalForm(), and SampleEditorController::setMesoCrystalBasis().

Here is the call graph for this function:

◆ enableStructureEditing()

void MesoCrystalForm::enableStructureEditing ( bool  b)

Definition at line 117 of file MesoCrystalForm.cpp.

118 {
119  if (m_removeAction)
120  m_removeAction->setVisible(b);
121 }

References m_removeAction.

◆ mesoCrystalItem()

MesoCrystalItem * MesoCrystalForm::mesoCrystalItem ( ) const

Definition at line 123 of file MesoCrystalForm.cpp.

124 {
125  return m_item;
126 }

References m_item.

Referenced by SampleEditorController::setMesoCrystalBasis().

◆ onBasisComboChanged()

void MesoCrystalForm::onBasisComboChanged ( )
private

Definition at line 95 of file MesoCrystalForm.cpp.

96 {
97  while (m_layout->rowCount() > m_rowOfBasisTypeCombo + 1)
98  m_layout->removeRow(m_rowOfBasisTypeCombo + 1);
99 
100  const auto currentData = m_basisCombo->currentData().toUInt();
101  if (currentData < 1000)
102  m_ec->setMesoCrystalBasis(this, static_cast<FormFactorItemCatalog::Type>(currentData));
103  else
105  static_cast<ItemWithParticlesCatalog::Type>(currentData - 1000));
106 }
void setMesoCrystalBasis(MesoCrystalForm *widget, ItemWithParticlesCatalog::Type type)

References m_basisCombo, m_ec, m_layout, m_rowOfBasisTypeCombo, and SampleEditorController::setMesoCrystalBasis().

Referenced by MesoCrystalForm().

Here is the call graph for this function:

Member Data Documentation

◆ m_basisCombo

QComboBox* MesoCrystalForm::m_basisCombo
private

Definition at line 46 of file MesoCrystalForm.h.

Referenced by MesoCrystalForm(), and onBasisComboChanged().

◆ m_ec

SampleEditorController* MesoCrystalForm::m_ec
private

Definition at line 45 of file MesoCrystalForm.h.

Referenced by createBasisWidgets(), and onBasisComboChanged().

◆ m_item

MesoCrystalItem* MesoCrystalForm::m_item
private

Definition at line 43 of file MesoCrystalForm.h.

Referenced by createBasisWidgets(), and mesoCrystalItem().

◆ m_layout

QFormLayout* MesoCrystalForm::m_layout
private

Definition at line 42 of file MesoCrystalForm.h.

Referenced by MesoCrystalForm(), createBasisWidgets(), and onBasisComboChanged().

◆ m_removeAction

QAction* MesoCrystalForm::m_removeAction = nullptr
private

Definition at line 44 of file MesoCrystalForm.h.

Referenced by MesoCrystalForm(), and enableStructureEditing().

◆ m_rowOfBasisTypeCombo

int MesoCrystalForm::m_rowOfBasisTypeCombo
private

Definition at line 47 of file MesoCrystalForm.h.

Referenced by MesoCrystalForm(), and onBasisComboChanged().


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