29 #include <QPushButton>
35 class AddLayerWidget :
public QWidget {
41 auto* l =
new QHBoxLayout(
this);
42 l->setContentsMargins(0, 0, 0, 0);
43 auto* btn =
new QPushButton(
"Add layer",
this);
47 connect(btn, &QPushButton::clicked, [=]() { ec->
addLayer(layer); });
58 , m_sampleItem(sampleItem)
60 , m_useAngstrom(false)
63 setObjectName(
"MultiLayerForm");
64 setAttribute(Qt::WA_StyledBackground,
true);
68 auto* props =
new QGroupBox(
this);
69 props->setTitle(
"Sample");
73 auto* nameEdit =
new QLineEdit(props);
74 layouter.
addRow(
"Name:", nameEdit);
78 auto* descriptionEdit =
new QTextEdit(props);
79 descriptionEdit->setMinimumWidth(300);
80 descriptionEdit->setMaximumHeight(100);
81 descriptionEdit->setAcceptRichText(
false);
82 descriptionEdit->setTabChangesFocus(
true);
83 descriptionEdit->setPlainText(sampleItem->
description());
84 layouter.
addRow(
"Description:", descriptionEdit);
85 connect(descriptionEdit, &QTextEdit::textChanged,
95 collapser->addAction(showInRealSpaceAction);
99 for (
auto* layer : sampleItem->
layers()) {
100 m_layout->addWidget(
new AddLayerWidget(
this, layer,
m_ec));
103 m_layout->addWidget(
new AddLayerWidget(
this,
nullptr,
m_ec));
104 m_layout->setSizeConstraint(QLayout::SetMinimumSize);
118 const int rowInLayout = rowInMultiLayer * 2 + 1;
123 m_layout->insertWidget(rowInLayout,
new AddLayerWidget(
this, layerItem,
m_ec));
131 AddLayerWidget* al =
nullptr;
132 for (
int index = 0; index <
m_layout->count(); index++) {
133 if (
auto* w =
dynamic_cast<AddLayerWidget*
>(
m_layout->itemAt(index)->widget()))
134 if (w->m_layer == layerItem) {
141 for (
int index = 0; index <
m_layout->count(); index++) {
143 if (w->layerItem() == layerItem) {
151 const int rowInLayout = rowInMultiLayer * 2 + 1;
153 m_layout->insertWidget(rowInLayout, wl);
156 m_layout->insertWidget(rowInLayout, al);
164 AddLayerWidget* addLayerWidget =
nullptr;
165 for (
auto* c : findChildren<QWidget*>()) {
166 if (
auto* w =
dynamic_cast<AddLayerWidget*
>(c))
167 if (w->m_layer == layerItem)
170 if (
auto* w =
dynamic_cast<LayerForm*
>(c)) {
171 if (w->layerItem() == layerItem)
180 layerForm->setParent(
nullptr);
181 layerForm->deleteLater();
185 delete addLayerWidget;
190 for (
auto* c : findChildren<QWidget*>()) {
191 if (
auto* w =
dynamic_cast<LayerForm*
>(c))
207 for (
auto* c : findChildren<LayerForm*>())
208 c->updateLayerPositionDependentElements();
215 if (spinbox->
baseUnit() == valueUnit)
219 for (
auto* editor : findChildren<DoubleSpinBox*>()) {
244 for (
auto* label : findChildren<QLabel*>())
277 for (
auto* c : findChildren<QWidget*>())
278 if (
dynamic_cast<AddLayerWidget*
>(c))
284 while (w !=
nullptr &&
dynamic_cast<LayerForm*
>(w) ==
nullptr) {
285 const auto index =
m_layout->indexOf(w);
287 w =
m_layout->itemAt(index + 1)->widget();
Defines class ActionFactory.
Defines class DoubleSpinBox.
Defines class GroupBoxCollapser.
Defines class MultiLayerItem.
Defines class ParticleCompositionForm.
Defines class ParticleCoreShellForm.
Defines class ParticleForm.
Defines class ParticleLayoutForm.
Unit
Defines units, mainly to be able to convert between units.
static QAction * createShowInRealSpaceAction(QObject *parent, const QString &what, std::function< void()> slot=nullptr)
Create "show in RealSpace" action.
SpinBox for DoubleDescriptors, supporting units.
Unit baseUnit() const
Returns the unit of the contained DoubleDescriptor.
void setDisplayUnit(Unit displayUnit)
Set a display unit.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
QString sampleName() const
QVector< LayerItem * > layers() const
QString description() const
DoubleDescriptor crossCorrLength() const
VectorDescriptor externalFieldVector() const
Form for editing a particle composition.
Form for editing a core/shell particle.
Form for editing a particle.
Form for editing a particle layout.
Class to modify a sample from the layer oriented sample editor.
void addLayer(LayerItem *before)
void setSampleDescription(const QString &description)
void requestViewInRealSpace(SampleItem item)
void setSampleName(const QString &name)
void clearLayout(QLayout *layout, bool deleteWidgets=true)
Removes content from box layout.
void updateLabelUnit(QLabel *label)