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

Resides at the bottom of SampleView and displays a Python script. More...

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

Signals

void widgetHeightRequest (int)
 

Public Member Functions

 ScriptPanel (QWidget *parent=nullptr)
 
QSize minimumSizeHint () const
 
void setInstrumentModel (InstrumentModel *instrumentModel)
 
void setSampleModel (SampleModel *sampleModel)
 
QSize sizeHint () const
 

Protected Slots

void onExpandButtonClicked ()
 
void setContentVisible (bool editor_status, bool dock_notify=false)
 

Protected Member Functions

bool isContentVisible ()
 
void resizeEvent (QResizeEvent *event)
 

Protected Attributes

int m_cached_height
 
QStackedWidget * m_stackedWidget
 
InfoPanelToolBarm_toolBar
 

Private Attributes

PySampleWidgetm_pySampleWidget
 

Detailed Description

Resides at the bottom of SampleView and displays a Python script.

Definition at line 26 of file ScriptPanel.h.

Constructor & Destructor Documentation

◆ ScriptPanel()

ScriptPanel::ScriptPanel ( QWidget *  parent = nullptr)
explicit

Definition at line 21 of file ScriptPanel.cpp.

22  : InfoPanel(parent), m_pySampleWidget(new PySampleWidget(this))
23 {
24  setWindowTitle("Python Script");
25  setObjectName("ScriptPanel");
26 
28 
29  setContentVisible(false);
30  m_toolBar->hide();
31 }
QStackedWidget * m_stackedWidget
Definition: InfoPanel.h:49
void setContentVisible(bool editor_status, bool dock_notify=false)
Definition: InfoPanel.cpp:71
InfoPanel(QWidget *parent)
Definition: InfoPanel.cpp:27
InfoPanelToolBar * m_toolBar
Definition: InfoPanel.h:48
Displays Python script representing a MultiLayer at the bottom of SampleView.
PySampleWidget * m_pySampleWidget
Definition: ScriptPanel.h:36

References m_pySampleWidget, InfoPanel::m_stackedWidget, InfoPanel::m_toolBar, and InfoPanel::setContentVisible().

Here is the call graph for this function:

Member Function Documentation

◆ isContentVisible()

bool InfoPanel::isContentVisible ( )
protectedinherited

Definition at line 92 of file InfoPanel.cpp.

93 {
94  if (m_stackedWidget->currentWidget())
95  return m_stackedWidget->currentWidget()->isVisible();
96 
97  return false;
98 }

References InfoPanel::m_stackedWidget.

Referenced by InfoPanel::onExpandButtonClicked(), and InfoPanel::resizeEvent().

◆ minimumSizeHint()

QSize InfoPanel::minimumSizeHint ( ) const
inherited

Definition at line 61 of file InfoPanel.cpp.

62 {
63  return QSize(minimum_widget_height, minimum_widget_height);
64 }

◆ onExpandButtonClicked

void InfoPanel::onExpandButtonClicked ( )
protectedslotinherited

Definition at line 66 of file InfoPanel.cpp.

67 {
69 }
bool isContentVisible()
Definition: InfoPanel.cpp:92

References InfoPanel::isContentVisible(), and InfoPanel::setContentVisible().

Referenced by InfoPanel::InfoPanel().

Here is the call graph for this function:

◆ resizeEvent()

void InfoPanel::resizeEvent ( QResizeEvent *  event)
protectedinherited

Definition at line 100 of file InfoPanel.cpp.

101 {
102  // widget is schrinking in height
103  if (event->oldSize().height() > event->size().height()) {
104  if (event->size().height() <= minimum_height_before_collapse && isContentVisible())
105  setContentVisible(false);
106  }
107 
108  // widget is growing in height
109  if (event->oldSize().height() < event->size().height()) {
110  if (event->size().height() > minimum_height_before_collapse && !isContentVisible())
111  setContentVisible(true);
112  }
113 
114  QWidget::resizeEvent(event);
115 }

References InfoPanel::isContentVisible(), and InfoPanel::setContentVisible().

Here is the call graph for this function:

◆ setContentVisible

void InfoPanel::setContentVisible ( bool  editor_status,
bool  dock_notify = false 
)
protectedslotinherited

Definition at line 71 of file InfoPanel.cpp.

72 {
73  m_toolBar->setExpandStatus(editor_status);
74  if (editor_status) {
75  if (m_cached_height)
76  if (dock_notify)
78 
79  if (m_stackedWidget->currentWidget())
80  m_stackedWidget->currentWidget()->show();
81 
82  } else {
83  m_cached_height = (height() < minimum_height_before_collapse ? default_height : height());
84  if (m_stackedWidget->currentWidget())
85  m_stackedWidget->currentWidget()->hide();
86 
87  if (dock_notify)
88  emit widgetHeightRequest(minimum_widget_height);
89  }
90 }
void setExpandStatus(bool status)
void widgetHeightRequest(int)
int m_cached_height
Definition: InfoPanel.h:50

References InfoPanel::m_cached_height, InfoPanel::m_stackedWidget, InfoPanel::m_toolBar, InfoPanelToolBar::setExpandStatus(), and InfoPanel::widgetHeightRequest().

Referenced by JobMessagePanel::JobMessagePanel(), ScriptPanel(), InfoPanel::onExpandButtonClicked(), and InfoPanel::resizeEvent().

Here is the call graph for this function:

◆ setInstrumentModel()

void ScriptPanel::setInstrumentModel ( InstrumentModel instrumentModel)

Definition at line 38 of file ScriptPanel.cpp.

39 {
40  m_pySampleWidget->setInstrumentModel(instrumentModel);
41 }
void setInstrumentModel(InstrumentModel *instrumentModel)

References m_pySampleWidget, and PySampleWidget::setInstrumentModel().

Referenced by SampleView::createSubWindows().

Here is the call graph for this function:

◆ setSampleModel()

void ScriptPanel::setSampleModel ( SampleModel sampleModel)

Definition at line 33 of file ScriptPanel.cpp.

34 {
35  m_pySampleWidget->setSampleModel(sampleModel);
36 }
void setSampleModel(SampleModel *sampleModel)

References m_pySampleWidget, and PySampleWidget::setSampleModel().

Referenced by SampleView::createSubWindows().

Here is the call graph for this function:

◆ sizeHint()

QSize InfoPanel::sizeHint ( ) const
inherited

Definition at line 47 of file InfoPanel.cpp.

48 {
49  QSize result = m_toolBar->sizeHint();
50 
51  if (QWidget* widget = m_stackedWidget->currentWidget()) {
52  if (widget->isVisible())
53  result.setHeight(widget->height() + m_toolBar->height());
54  } else {
55  result.setHeight(m_toolBar->height());
56  }
57 
58  return result;
59 }

References InfoPanel::m_stackedWidget, and InfoPanel::m_toolBar.

◆ widgetHeightRequest

void InfoPanel::widgetHeightRequest ( int  )
signalinherited

Member Data Documentation

◆ m_cached_height

int InfoPanel::m_cached_height
protectedinherited

Definition at line 50 of file InfoPanel.h.

Referenced by InfoPanel::setContentVisible().

◆ m_pySampleWidget

PySampleWidget* ScriptPanel::m_pySampleWidget
private

Definition at line 36 of file ScriptPanel.h.

Referenced by ScriptPanel(), setInstrumentModel(), and setSampleModel().

◆ m_stackedWidget

QStackedWidget* InfoPanel::m_stackedWidget
protectedinherited

◆ m_toolBar

InfoPanelToolBar* InfoPanel::m_toolBar
protectedinherited

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