25 #include <QFormLayout>
32 , m_listView(new QListView)
34 , m_maskModel(nullptr)
35 , m_intensityDataItem(nullptr)
36 , m_currentMaskItem(nullptr)
37 , m_inhibitSelectionChange(false)
39 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
40 setObjectName(QLatin1String(
"MaskEditorToolPanel"));
41 setAttribute(Qt::WA_StyledBackground,
true);
42 setProperty(
"stylable",
true);
44 m_listView->setContextMenuPolicy(Qt::CustomContextMenu);
45 connect(
m_listView, &QListView::customContextMenuRequested,
this,
48 auto* mainLayout =
new QVBoxLayout;
49 mainLayout->setContentsMargins(0, 0, 0, 0);
50 mainLayout->setSpacing(8);
53 auto* plotPropertiesGroup =
new QGroupBox(
"Plot properties",
this);
54 auto* plotPropertiesLayout =
new QVBoxLayout(plotPropertiesGroup);
55 plotPropertiesLayout->setContentsMargins(0, 0, 0, 0);
61 auto* maskStackGroup =
new QGroupBox(
"Mask stack",
this);
62 auto* maskStackLayout =
new QVBoxLayout(maskStackGroup);
63 maskStackLayout->setContentsMargins(0, 0, 0, 0);
64 m_listView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
69 auto* maskPropertiesGroup =
new QGroupBox(
"Mask properties",
this);
70 maskPropertiesGroup->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
75 mainLayout->addWidget(plotPropertiesGroup);
76 mainLayout->addWidget(maskStackGroup);
77 mainLayout->addWidget(maskPropertiesGroup);
78 mainLayout->addSpacerItem(
79 new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding));
81 setLayout(mainLayout);
86 return QSize(128, 128);
91 return QSize(128, 128);
95 const QModelIndex& maskContainerIndex,
103 m_listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
107 connect(
m_listView->selectionModel(), &QItemSelectionModel::selectionChanged,
this,
142 if (!indexes.empty())
150 const QItemSelection&)
155 if (!selected.empty())
186 const auto maskValueGetter = [=] {
return maskItem->
maskValue(); };
187 const auto maskValueSetter = [=](
bool b) { maskItem->setMaskValue(b); };
191 const auto visibilityValueGetter = [=] {
return maskItem->isVisibleValue(); };
192 const auto visibilityValueSetter = [=](
bool b) {
194 maskItem->setIsVisibleValue(b);
202 connect(edit, &QLineEdit::textEdited, [=](
const QString& t) { maskItem->setMaskName(t); });
211 }
else if (
auto* c =
dynamic_cast<EllipseItem*
>(maskItem)) {
226 spinBox->setBaseValue(d.
get());
228 [=](
double newValue) { d.
set(newValue); });
231 [=](
const QString&) { spinBox->updateValue(); },
this);
237 function<
void(
bool)> setter)
240 checkBox->setChecked(getter());
241 connect(checkBox, &QCheckBox::stateChanged, [=]() { setter(checkBox->isChecked()); });
245 [=](
const QString&) {
246 QSignalBlocker b(checkBox);
247 checkBox->setChecked(getter());
Defines class DoubleSpinBox.
Defines class GroupBoxCollapser.
Defines class IntensityDataItem.
Defines namespace GUI::Util::Layout.
Defines class MaskEditorPropertyPanel.
Defines MaskItems classes.
Defines class SessionModel.
Describes properties of a double value which are necessary to allow GUI representation,...
QString label
A label text (short, no trailing colon)
function< void(double)> set
function to set the value
function< double()> get
function to get the current value
SpinBox for DoubleDescriptors, supporting units.
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
void addMaskSpinBox(DoubleDescriptor d)
Add a spinbox to edit a mask's double value.
void setPanelHidden(bool hidden)
Show/Hide panel. When panel is hidden, all property editors are disabled.
IntensityDataPropertyWidget * m_plotPropertyEditor
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &)
QSize minimumSizeHint() const override
void addMaskCheckBox(const QString &title, function< bool()> getter, function< void(bool)> setter)
Add a checkbox to edit a mask's boolean value.
bool m_inhibitSelectionChange
SessionModel * m_maskModel
void itemContextMenuRequest(const QPoint &point)
IntensityDataItem * m_intensityDataItem
void setMaskContext(SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
void onCustomContextMenuRequested(const QPoint &point)
MaskItem * m_currentMaskItem
the mask item whose properties shall be edited
QItemSelectionModel * selectionModel()
QSize sizeHint() const override
void createMaskEditorUI()
Creates the UI to edit the current mask's properties.
MaskEditorPropertyPanel(QWidget *parent=nullptr)
MaskItem * maskItemForIndex(const QModelIndex &index)
Return the mask item for the given index. nullptr if index invalid or not pointing to a mask item.
void setCurrentMaskItem(MaskItem *maskItem)
Set the current mask and creates the UI to edit the mask's properties.
QFormLayout * m_maskPropertiesLayout
A base class for all mask items.
void unsubscribe(const void *caller)
Cancels all subscriptions of given caller.
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
SessionItem * itemForIndex(const QModelIndex &index) const
void clearLayout(QLayout *layout, bool deleteWidgets=true)
Removes content from box layout.