BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MaskEditorPropertyPanel Class Reference

Tool widget for MaskEditor. More...

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

Signals

void itemContextMenuRequest (const QPoint &point)
 

Public Member Functions

 MaskEditorPropertyPanel (QWidget *parent=nullptr)
 
QSize minimumSizeHint () const
 
void resetContext ()
 
QItemSelectionModel * selectionModel ()
 
void setMaskContext (SessionModel *model, const QModelIndex &maskContainerIndex, IntensityDataItem *intensityItem)
 
void setPanelHidden (bool value)
 Show/Hide panel. When panel is hidden, all property editors are disabled. More...
 
QSize sizeHint () const
 

Private Slots

void onCustomContextMenuRequested (const QPoint &point)
 
void onSelectionChanged (const QItemSelection &selected, const QItemSelection &)
 

Private Member Functions

void setup_MaskProperties (AccordionWidget *accordion)
 
void setup_MaskStack (AccordionWidget *accordion)
 
void setup_PlotProperties (AccordionWidget *accordion)
 

Private Attributes

AccordionWidgetm_accordion
 
IntensityDataItemm_intensityDataItem
 
QListView * m_listView
 
SessionModelm_maskModel
 
ComponentEditorm_maskPropertyEditor
 
ComponentEditorm_plotPropertyEditor
 
QModelIndex m_rootIndex
 

Detailed Description

Tool widget for MaskEditor.

Definition at line 32 of file MaskEditorPropertyPanel.h.

Constructor & Destructor Documentation

◆ MaskEditorPropertyPanel()

MaskEditorPropertyPanel::MaskEditorPropertyPanel ( QWidget *  parent = nullptr)

Definition at line 40 of file MaskEditorPropertyPanel.cpp.

41  : QWidget(parent)
42  , m_listView(new QListView)
46  , m_maskModel(nullptr)
47  , m_intensityDataItem(nullptr)
48 {
49  setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
50  setObjectName(QLatin1String("MaskEditorToolPanel"));
51 
52  m_listView->setContextMenuPolicy(Qt::CustomContextMenu);
53  connect(m_listView, &QListView::customContextMenuRequested, this,
55 
56  QVBoxLayout* mainLayout = new QVBoxLayout;
57  mainLayout->setContentsMargins(0, 0, 0, 0);
58  mainLayout->setSpacing(0);
59 
64 
65  mainLayout->addWidget(m_accordion);
66 
67  setLayout(mainLayout);
68 }
QAccordion base class.
ContentPane * getContentPane(uint index)
Get content pane.
Component editor for SessionItem.
void headerClicked()
Slot that is called when the header has been triggered.
void setup_MaskStack(AccordionWidget *accordion)
ComponentEditor * m_plotPropertyEditor
ComponentEditor * m_maskPropertyEditor
IntensityDataItem * m_intensityDataItem
void onCustomContextMenuRequested(const QPoint &point)
void setup_MaskProperties(AccordionWidget *accordion)
void setup_PlotProperties(AccordionWidget *accordion)

References AccordionWidget::getContentPane(), ContentPane::headerClicked(), m_accordion, m_listView, onCustomContextMenuRequested(), setup_MaskProperties(), setup_MaskStack(), and setup_PlotProperties().

Here is the call graph for this function:

Member Function Documentation

◆ itemContextMenuRequest

void MaskEditorPropertyPanel::itemContextMenuRequest ( const QPoint &  point)
signal

◆ minimumSizeHint()

QSize MaskEditorPropertyPanel::minimumSizeHint ( ) const

Definition at line 75 of file MaskEditorPropertyPanel.cpp.

76 {
77  return QSize(128, 128);
78 }

◆ onCustomContextMenuRequested

void MaskEditorPropertyPanel::onCustomContextMenuRequested ( const QPoint &  point)
privateslot

Definition at line 144 of file MaskEditorPropertyPanel.cpp.

145 {
146  emit itemContextMenuRequest(m_listView->mapToGlobal(point));
147 }
void itemContextMenuRequest(const QPoint &point)

References itemContextMenuRequest(), and m_listView.

Referenced by MaskEditorPropertyPanel().

◆ onSelectionChanged

void MaskEditorPropertyPanel::onSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &   
)
privateslot

Definition at line 135 of file MaskEditorPropertyPanel.cpp.

137 {
138  if (!selected.empty())
139  m_maskPropertyEditor->setItem(m_maskModel->itemForIndex(selected.indexes().front()));
140  else
141  m_maskPropertyEditor->setItem(nullptr);
142 }
void setItem(SessionItem *item)
SessionItem * itemForIndex(const QModelIndex &index) const

References SessionModel::itemForIndex(), m_maskModel, m_maskPropertyEditor, and ComponentEditor::setItem().

Referenced by setMaskContext().

Here is the call graph for this function:

◆ resetContext()

void MaskEditorPropertyPanel::resetContext ( )

Definition at line 99 of file MaskEditorPropertyPanel.cpp.

100 {
101  m_maskModel = nullptr;
102  m_rootIndex = {};
103  m_intensityDataItem = nullptr;
104  m_listView->setModel(nullptr);
105  m_maskPropertyEditor->setItem(nullptr);
106  m_plotPropertyEditor->setItem(nullptr);
107 }

References m_intensityDataItem, m_listView, m_maskModel, m_maskPropertyEditor, m_plotPropertyEditor, m_rootIndex, and ComponentEditor::setItem().

Referenced by MaskEditor::resetContext().

Here is the call graph for this function:

◆ selectionModel()

QItemSelectionModel * MaskEditorPropertyPanel::selectionModel ( )

Definition at line 109 of file MaskEditorPropertyPanel.cpp.

110 {
112  return m_listView->selectionModel();
113 }
#define ASSERT(condition)
Definition: Assert.h:31

References ASSERT, and m_listView.

Referenced by MaskEditor::setMaskContext(), and setPanelHidden().

◆ setMaskContext()

void MaskEditorPropertyPanel::setMaskContext ( SessionModel model,
const QModelIndex &  maskContainerIndex,
IntensityDataItem intensityItem 
)

Definition at line 80 of file MaskEditorPropertyPanel.cpp.

83 {
84  m_maskModel = model;
85  m_rootIndex = maskContainerIndex;
86  m_intensityDataItem = intensityItem;
87 
88  m_listView->setModel(m_maskModel);
89  m_listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
90 
91  m_listView->setRootIndex(m_rootIndex);
92 
93  connect(m_listView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
94  &MaskEditorPropertyPanel::onSelectionChanged, Qt::UniqueConnection);
95 
97 }
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &)

References m_intensityDataItem, m_listView, m_maskModel, m_plotPropertyEditor, m_rootIndex, onSelectionChanged(), and ComponentEditor::setItem().

Referenced by MaskEditor::setMaskContext().

Here is the call graph for this function:

◆ setPanelHidden()

void MaskEditorPropertyPanel::setPanelHidden ( bool  value)

Show/Hide panel. When panel is hidden, all property editors are disabled.

Definition at line 116 of file MaskEditorPropertyPanel.cpp.

117 {
118  this->setHidden(value);
119 
120  if (!m_rootIndex.isValid())
121  return;
122 
123  if (value) {
124  m_maskPropertyEditor->setItem(nullptr);
125  m_plotPropertyEditor->setItem(nullptr);
126  } else {
127  QModelIndexList indexes = selectionModel()->selectedIndexes();
128  if (!indexes.empty())
130 
132  }
133 }
QItemSelectionModel * selectionModel()

References SessionModel::itemForIndex(), m_intensityDataItem, m_maskModel, m_maskPropertyEditor, m_plotPropertyEditor, m_rootIndex, selectionModel(), and ComponentEditor::setItem().

Referenced by MaskEditor::MaskEditor(), and MaskEditor::onPropertyPanelRequest().

Here is the call graph for this function:

◆ setup_MaskProperties()

void MaskEditorPropertyPanel::setup_MaskProperties ( AccordionWidget accordion)
private

Definition at line 179 of file MaskEditorPropertyPanel.cpp.

180 {
181  ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Mask properties"));
182  cp->setMaximumHeight(600);
183  cp->setHeaderTooltip("Property editor for currently selected mask.");
184  cp->setContainerFrameStyle(QFrame::Plain);
185  QFrame* contentFrame = cp->getContentFrame();
186 
187  QVBoxLayout* layout = new QVBoxLayout();
188  layout->setContentsMargins(0, 0, 0, 0);
189  layout->addWidget(new EnvelopWidget(m_maskPropertyEditor));
190  contentFrame->setLayout(layout);
191 }
int addContentPane(QString header)
Add a new content Pane.
Content Pane class.
Definition: ContentPane.h:75
void setHeaderTooltip(QString tooltip)
Set header tooltip.
Definition: ContentPane.cpp:92
QFrame * getContentFrame()
Get the content frame of the content pane.
Definition: ContentPane.cpp:53
void setMaximumHeight(int maxHeight)
Set the maximum height of the content pane container.
Definition: ContentPane.cpp:72
void setContainerFrameStyle(int style)
Set the container frame style.
Widget to cheat Accordion to resize correctly.

References AccordionWidget::addContentPane(), ContentPane::getContentFrame(), AccordionWidget::getContentPane(), m_maskPropertyEditor, ContentPane::setContainerFrameStyle(), ContentPane::setHeaderTooltip(), and ContentPane::setMaximumHeight().

Referenced by MaskEditorPropertyPanel().

Here is the call graph for this function:

◆ setup_MaskStack()

void MaskEditorPropertyPanel::setup_MaskStack ( AccordionWidget accordion)
private

Definition at line 164 of file MaskEditorPropertyPanel.cpp.

165 {
166  ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Mask stack"));
167  cp->setMaximumHeight(600);
168  cp->setHeaderTooltip("List of created masks representing mask stacking order.");
169  cp->setContainerFrameStyle(QFrame::Plain);
170  QFrame* contentFrame = cp->getContentFrame();
171 
172  QVBoxLayout* layout = new QVBoxLayout();
173  layout->setContentsMargins(0, 0, 0, 0);
174  layout->addWidget(m_listView);
175  layout->addWidget(new EnvelopWidget(m_listView));
176  contentFrame->setLayout(layout);
177 }

References AccordionWidget::addContentPane(), ContentPane::getContentFrame(), AccordionWidget::getContentPane(), m_listView, ContentPane::setContainerFrameStyle(), ContentPane::setHeaderTooltip(), and ContentPane::setMaximumHeight().

Referenced by MaskEditorPropertyPanel().

Here is the call graph for this function:

◆ setup_PlotProperties()

void MaskEditorPropertyPanel::setup_PlotProperties ( AccordionWidget accordion)
private

Definition at line 149 of file MaskEditorPropertyPanel.cpp.

150 {
151  ContentPane* cp = accordion->getContentPane(accordion->addContentPane("Plot properties"));
152  cp->setMaximumHeight(600);
153  cp->setHeaderTooltip("Plot properties editor");
154  cp->setContainerFrameStyle(QFrame::Plain);
155  QFrame* contentFrame = cp->getContentFrame();
156 
157  QVBoxLayout* layout = new QVBoxLayout();
158  layout->setContentsMargins(0, 0, 0, 0);
159  m_plotPropertyEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
160  layout->addWidget(new EnvelopWidget(m_plotPropertyEditor));
161  contentFrame->setLayout(layout);
162 }

References AccordionWidget::addContentPane(), ContentPane::getContentFrame(), AccordionWidget::getContentPane(), m_plotPropertyEditor, ContentPane::setContainerFrameStyle(), ContentPane::setHeaderTooltip(), and ContentPane::setMaximumHeight().

Referenced by MaskEditorPropertyPanel().

Here is the call graph for this function:

◆ sizeHint()

QSize MaskEditorPropertyPanel::sizeHint ( ) const

Definition at line 70 of file MaskEditorPropertyPanel.cpp.

71 {
72  return QSize(128, 128);
73 }

Member Data Documentation

◆ m_accordion

AccordionWidget* MaskEditorPropertyPanel::m_accordion
private

Definition at line 64 of file MaskEditorPropertyPanel.h.

Referenced by MaskEditorPropertyPanel().

◆ m_intensityDataItem

IntensityDataItem* MaskEditorPropertyPanel::m_intensityDataItem
private

Definition at line 67 of file MaskEditorPropertyPanel.h.

Referenced by resetContext(), setMaskContext(), and setPanelHidden().

◆ m_listView

QListView* MaskEditorPropertyPanel::m_listView
private

◆ m_maskModel

SessionModel* MaskEditorPropertyPanel::m_maskModel
private

◆ m_maskPropertyEditor

ComponentEditor* MaskEditorPropertyPanel::m_maskPropertyEditor
private

◆ m_plotPropertyEditor

ComponentEditor* MaskEditorPropertyPanel::m_plotPropertyEditor
private

◆ m_rootIndex

QModelIndex MaskEditorPropertyPanel::m_rootIndex
private

Definition at line 66 of file MaskEditorPropertyPanel.h.

Referenced by resetContext(), setMaskContext(), and setPanelHidden().


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