33 #include <QPushButton>
39 QString text = label->text();
40 const bool hasColon = text.indexOf(
":") > 0;
41 text = text.left(text.indexOf(
"["));
42 text = text.trimmed();
43 if (text.endsWith(
":"))
47 text +=
" [" + unit +
"]";
62 if (
auto* editor =
dynamic_cast<DoubleSpinBox*
>(label->buddy()))
82 bool vertically,
bool addSpacer)
85 for (
const auto& valueDescriptor : valueDescriptors) {
86 auto* editor =
new DoubleSpinBox(m_gridLayout->parentWidget(), valueDescriptor);
88 [=](
double newValue) { setNewValue(newValue, valueDescriptor); });
90 QString labeltext = valueDescriptor.label;
91 if (!vertically && !labeltext.endsWith(
":"))
93 auto* label =
new QLabel(labeltext, m_gridLayout->parentWidget());
94 label->setBuddy(editor);
98 m_gridLayout->addWidget(label, 0, col);
99 m_gridLayout->addWidget(editor, 1, col);
102 m_gridLayout->addWidget(label, 1, col++);
103 m_gridLayout->addWidget(editor, 1, col++);
107 m_gridLayout->addItem(
new QSpacerItem(0, 0, QSizePolicy::Expanding), 0, col);
115 valueDescriptors.size() > 1, addSpacer);
120 bool vertically,
bool addSpacer)
129 bool vertically,
bool addSpacer)
137 auto* l =
new QLabel(text);
190 if (
auto* particle =
dynamic_cast<ParticleItem*
>(itemWithParticles))
191 return new ParticleForm(parentWidget, particle, allowAbundance, ec, allowRemove);
201 auto* btn =
new QPushButton(
"Add particle", parentWidget);
203 auto* menu =
new QMenu(btn);
204 QMenu* menuForEntries = menu;
206 const auto group = [&](
const QString& title) { menuForEntries = menu->addMenu(title); };
208 group(
"Hard particles");
211 QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
212 a->setToolTip(ui.description);
213 QObject::connect(a, &QAction::triggered, [=]() { slotAddFormFactor(type); });
219 QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
220 a->setToolTip(ui.description);
221 QObject::connect(a, &QAction::triggered, [=]() { slotAddFormFactor(type); });
224 group(
"Particle assemblies");
225 for (
const auto type :
229 QAction* a = menuForEntries->addAction(QIcon(ui.iconPath), ui.menuEntry);
230 a->setToolTip(ui.description);
231 QObject::connect(a, &QAction::triggered, [=]() { slotAddParticle(type); });
241 static QList<QColor> colors = {QColor(230, 255, 213), QColor(194, 252, 240),
242 QColor(239, 228, 176), QColor(200, 191, 231),
243 QColor(253, 205, 193), QColor(224, 193, 253)};
QList< DoubleDescriptor > DoubleDescriptors
Defines class DoubleSpinBox.
Defines class LayerEditorUtils.
Defines classes LayerRoughnessItems.
Defines class MesoCrystalItem.
Defines class ParticleCompositionForm.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellForm.
Defines class ParticleCoreShellItem.
Defines class ParticleForm.
Defines class ParticleItem.
Defines Profile1DItem's classes.
Defines class VectorDescriptor.
Describes properties of a double value which are necessary to allow GUI representation,...
SpinBox for DoubleDescriptors, supporting units.
QString displayUnitAsString() const
The display unit as human readable string.
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static UiInfo uiInfo(Type t)
UiInfo on the given type.
DoubleDescriptor lateralCorrelationLength() const
DoubleDescriptor sigma() const
DoubleDescriptor hurst() const
Form for editing a particle composition.
Form for editing a core/shell particle.
Form for editing a particle.
virtual DoubleDescriptors valueDescriptors() const
virtual DoubleDescriptors valueDescriptors() const
virtual DoubleDescriptors rotationValues() const =0
Class to modify a sample from the layer oriented sample editor.
void setDouble(double newValue, DoubleDescriptor d)
Describes properties of a 3D vector, consisting of three double values.
QList< QColor > predefinedLayerColors()
QWidget * createWidgetForItemWithParticles(QWidget *parentWidget, ItemWithParticles *itemWithParticles, bool allowAbundance, SampleEditorController *ec, bool allowRemove=true)
DoubleDescriptors doubleDescriptorsOfItem(LayerBasicRoughnessItem *item)
void addMultiPropertyToGrid(QGridLayout *m_gridLayout, int firstCol, const DoubleDescriptors &valueDescriptors, SampleEditorController *ec, bool vertically, bool addSpacer)
Create DoubleSpinBoxes for the DoubeDescriptors and connect them to SampleEditorController::setDouble...
void addVectorToGrid(QGridLayout *m_gridLayout, int firstCol, const VectorDescriptor &v, SampleEditorController *ec, bool vertically, bool addSpacer)
Create DoubleSpinBoxes for the DoubeDescriptors and connect them to SampleEditorController::setDouble...
void updateLabelUnit(QLabel *label)
QPushButton * createAddParticleButton(QWidget *parentWidget, std::function< void(FormFactorItemCatalog::Type t)> slotAddFormFactor, std::function< void(ItemWithParticlesCatalog::Type t)> slotAddParticle)
QLabel * createBoldLabel(const QString &text)