BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RealDataPresenter Class Reference

Description

Presents imported data (RealDataItem) using stack of different widgets and combo box in the right top corner of ImportDataView, to switch between widgets.

Definition at line 26 of file RealDataPresenter.h.

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

Public Types

using factory_function_t = std::function< SessionItemWidget *()>
 

Public Member Functions

 RealDataPresenter (QWidget *parent=nullptr)
 
QList< QAction * > actionList () override
 
SessionItemcurrentItem ()
 
const SessionItemcurrentItem () const
 
void registerWidget (const QString &presentationType, factory_function_t)
 
void setItem (SessionItem *item) override
 
virtual void setPresentation (const QString &presentationType)
 Sets stack to show widget corresponding to given presentation. More...
 
void setToolbarVisible (bool value)
 

Protected Member Functions

QStringList activePresentationList (SessionItem *item) override
 Returns list of active presentations for given item. Active presentation is the one which is present in QComboBox selector and can be selected. For example, if JobItem is fittable, the list will contain "FitComparisonWidgetName". More...
 
void hideEvent (QHideEvent *) override
 
virtual QString itemPresentation () const
 Presentation which should be shown for current item. More...
 
virtual QStringList presentationList (SessionItem *item)
 Returns full list of presentations available for given item. More...
 
QString selectedPresentation () const
 Presentation selected in combo selector. More...
 
void showEvent (QShowEvent *) override
 
void subscribeToItem () override
 
virtual void unsubscribeFromItem ()
 

Private Slots

void onComboChanged (const QString &name)
 

Private Member Functions

void setSizeToCurrentWidget ()
 Resizes QStackedWidget to currently active page. More...
 

Private Attributes

QWidget * m_blankWidget
 
SessionItemControllerm_itemController
 
QMap< QString, SessionItemWidget * > m_presentationTypeToWidget
 
QStackedWidget * m_stackedWidget
 
ItemComboToolbarm_toolbar
 
IFactory< QString, SessionItemWidgetm_widgetFactory
 

Member Typedef Documentation

◆ factory_function_t

using ItemComboWidget::factory_function_t = std::function<SessionItemWidget*()>
inherited

Definition at line 42 of file ItemComboWidget.h.

Constructor & Destructor Documentation

◆ RealDataPresenter()

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

Definition at line 25 of file RealDataPresenter.cpp.

26  : ItemComboWidget(parent)
27 {
28  registerWidget("Heat Map", create_new<IntensityDataWidget>);
29  registerWidget("Projections", create_new<IntensityDataProjectionsWidget>);
30  registerWidget("Mask Editor", create_new<RealDataMaskWidget>);
31  registerWidget("Reflectometry (Graph only)", create_new<SpecularDataWidget>);
32  registerWidget("Reflectometry (Configuration)", create_new<SpecularDataImportWidget>);
33 }
ItemComboWidget(QWidget *parent=nullptr)
void registerWidget(const QString &presentationType, factory_function_t)

References ItemComboWidget::registerWidget().

Here is the call graph for this function:

Member Function Documentation

◆ actionList()

QList< QAction * > RealDataPresenter::actionList ( )
overridevirtual

Reimplemented from SessionItemWidget.

Definition at line 35 of file RealDataPresenter.cpp.

36 {
37  return QList<QAction*>();
38 }

◆ activePresentationList()

QStringList RealDataPresenter::activePresentationList ( SessionItem item)
overrideprotectedvirtual

Returns list of active presentations for given item. Active presentation is the one which is present in QComboBox selector and can be selected. For example, if JobItem is fittable, the list will contain "FitComparisonWidgetName".

Reimplemented from ItemComboWidget.

Definition at line 40 of file RealDataPresenter.cpp.

41 {
42  auto* const realDataItem = dynamic_cast<RealDataItem*>(item);
43  ASSERT(realDataItem);
44 
45  QStringList result;
46  if (realDataItem->isIntensityData())
47  result << "Heat Map"
48  << "Projections"
49  << "Mask Editor";
50  else if (realDataItem->isSpecularData()) {
51  if (realDataItem->dataLoader() != nullptr)
52  result << "Reflectometry (Configuration)";
53  result << "Reflectometry (Graph only)";
54  } else
55  throw Error("Error in RealDataPresenter::activePresentationList: unsupported data type");
56  return result;
57 }
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33

References Error.

◆ currentItem() [1/2]

◆ currentItem() [2/2]

const SessionItem * SessionItemWidget::currentItem ( ) const
inherited

Definition at line 46 of file SessionItemWidget.cpp.

47 {
48  return m_itemController->currentItem();
49 }
SessionItemController * m_itemController

References SessionItemController::currentItem(), and SessionItemWidget::m_itemController.

Here is the call graph for this function:

◆ hideEvent()

void SessionItemWidget::hideEvent ( QHideEvent *  )
overrideprotectedinherited

Definition at line 56 of file SessionItemWidget.cpp.

57 {
59 }
void unsubscribe()
Fully unsubscribes the parent from listening item's signals. Controller stays active to track item de...

References SessionItemWidget::m_itemController, and SessionItemController::unsubscribe().

Here is the call graph for this function:

◆ itemPresentation()

QString ItemComboWidget::itemPresentation ( ) const
protectedvirtualinherited

Presentation which should be shown for current item.

Reimplemented in JobResultsPresenter.

Definition at line 115 of file ItemComboWidget.cpp.

116 {
117  return selectedPresentation();
118 }
QString selectedPresentation() const
Presentation selected in combo selector.

References ItemComboWidget::selectedPresentation().

Referenced by ItemComboWidget::setItem(), and ItemComboWidget::subscribeToItem().

Here is the call graph for this function:

◆ onComboChanged

void ItemComboWidget::onComboChanged ( const QString &  name)
privateslotinherited

Definition at line 134 of file ItemComboWidget.cpp.

135 {
137 }
virtual void setPresentation(const QString &presentationType)
Sets stack to show widget corresponding to given presentation.

References ItemComboWidget::selectedPresentation(), and ItemComboWidget::setPresentation().

Referenced by ItemComboWidget::ItemComboWidget().

Here is the call graph for this function:

◆ presentationList()

QStringList ItemComboWidget::presentationList ( SessionItem item)
protectedvirtualinherited

Returns full list of presentations available for given item.

Reimplemented in JobResultsPresenter.

Definition at line 108 of file ItemComboWidget.cpp.

109 {
110  return activePresentationList(item);
111 }
virtual QStringList activePresentationList(SessionItem *item)
Returns list of active presentations for given item. Active presentation is the one which is present ...

References ItemComboWidget::activePresentationList().

Referenced by ItemComboWidget::subscribeToItem().

Here is the call graph for this function:

◆ registerWidget()

void ItemComboWidget::registerWidget ( const QString &  presentationType,
factory_function_t  f 
)
inherited

Definition at line 44 of file ItemComboWidget.cpp.

45 {
46  m_widgetFactory.registerItem(presentationType, f);
47 }
IFactory< QString, SessionItemWidget > m_widgetFactory

References ItemComboWidget::m_widgetFactory.

Referenced by JobResultsPresenter::JobResultsPresenter(), and RealDataPresenter().

◆ selectedPresentation()

QString ItemComboWidget::selectedPresentation ( ) const
protectedinherited

Presentation selected in combo selector.

Definition at line 122 of file ItemComboWidget.cpp.

123 {
124  return m_toolbar->currentPresentation();
125 }
QString currentPresentation() const
ItemComboToolbar * m_toolbar

References ItemComboToolbar::currentPresentation(), and ItemComboWidget::m_toolbar.

Referenced by ItemComboWidget::itemPresentation(), JobResultsPresenter::itemPresentation(), and ItemComboWidget::onComboChanged().

Here is the call graph for this function:

◆ setItem()

void ItemComboWidget::setItem ( SessionItem item)
overridevirtualinherited

Reimplemented from SessionItemWidget.

Reimplemented in JobResultsPresenter.

Definition at line 88 of file ItemComboWidget.cpp.

89 {
90  if (!item)
91  m_stackedWidget->setCurrentWidget(m_blankWidget);
93  setToolbarVisible(item && !itemPresentation().isEmpty());
94 }
QWidget * m_blankWidget
QStackedWidget * m_stackedWidget
virtual QString itemPresentation() const
Presentation which should be shown for current item.
void setToolbarVisible(bool value)
virtual void setItem(SessionItem *item)

References ItemComboWidget::itemPresentation(), ItemComboWidget::m_blankWidget, ItemComboWidget::m_stackedWidget, SessionItemWidget::setItem(), and ItemComboWidget::setToolbarVisible().

Referenced by JobResultsPresenter::setItem().

Here is the call graph for this function:

◆ setPresentation()

void ItemComboWidget::setPresentation ( const QString &  presentationType)
virtualinherited

Sets stack to show widget corresponding to given presentation.

Reimplemented in JobResultsPresenter.

Definition at line 50 of file ItemComboWidget.cpp.

51 {
52  if (presentationType.isEmpty()) {
53  m_stackedWidget->setCurrentWidget(m_blankWidget);
54  setToolbarVisible(false);
55  return;
56  }
57 
58  if (!activePresentationList(currentItem()).contains(presentationType))
59  return;
60 
61  setToolbarVisible(true);
62  m_toolbar->setPresentation(presentationType);
63 
64  ASSERT(currentItem());
65 
66  SessionItemWidget* widget = m_presentationTypeToWidget[presentationType];
67 
68  if (!widget) {
69  widget = m_widgetFactory.createItemPtr(presentationType).release();
70  m_stackedWidget->addWidget(widget);
71  m_presentationTypeToWidget[presentationType] = widget;
72  }
73  ASSERT(widget);
74  widget->setItem(currentItem());
76  m_stackedWidget->setCurrentWidget(widget);
77  if (widget->isHidden())
78  widget->show();
79 
81 }
void setPresentation(const QString &name)
void setActionList(const QList< QAction * > &actionList)
Sets external actions to tool bar (previous actions will be removed).
QMap< QString, SessionItemWidget * > m_presentationTypeToWidget
void setSizeToCurrentWidget()
Resizes QStackedWidget to currently active page.
virtual QList< QAction * > actionList()

References SessionItemWidget::actionList(), ItemComboWidget::activePresentationList(), SessionItemWidget::currentItem(), ItemComboWidget::m_blankWidget, ItemComboWidget::m_presentationTypeToWidget, ItemComboWidget::m_stackedWidget, ItemComboWidget::m_toolbar, ItemComboWidget::m_widgetFactory, ItemComboToolbar::setActionList(), SessionItemWidget::setItem(), ItemComboToolbar::setPresentation(), ItemComboWidget::setSizeToCurrentWidget(), and ItemComboWidget::setToolbarVisible().

Referenced by ItemComboWidget::onComboChanged(), JobResultsPresenter::setPresentation(), and ItemComboWidget::subscribeToItem().

Here is the call graph for this function:

◆ setSizeToCurrentWidget()

void ItemComboWidget::setSizeToCurrentWidget ( )
privateinherited

Resizes QStackedWidget to currently active page.

Definition at line 141 of file ItemComboWidget.cpp.

142 {
143  for (int i = 0; i < m_stackedWidget->count(); ++i) {
144  // determine the vertical size policy
145  QSizePolicy::Policy policy = QSizePolicy::Ignored;
146  if (i == m_stackedWidget->currentIndex())
147  policy = QSizePolicy::Expanding;
148 
149  // update the size policy
150  auto* page = m_stackedWidget->widget(i);
151  page->setSizePolicy(policy, policy);
152  }
153 }

References ItemComboWidget::m_stackedWidget.

Referenced by ItemComboWidget::setPresentation().

◆ setToolbarVisible()

void ItemComboWidget::setToolbarVisible ( bool  value)
inherited

Definition at line 83 of file ItemComboWidget.cpp.

84 {
85  m_toolbar->setVisible(value);
86 }

References ItemComboWidget::m_toolbar.

Referenced by ItemComboWidget::ItemComboWidget(), ItemComboWidget::setItem(), and ItemComboWidget::setPresentation().

◆ showEvent()

void SessionItemWidget::showEvent ( QShowEvent *  )
overrideprotectedinherited

Definition at line 51 of file SessionItemWidget.cpp.

52 {
54 }
void subscribe()
Subscribe parent to item's signals.

References SessionItemWidget::m_itemController, and SessionItemController::subscribe().

Here is the call graph for this function:

◆ subscribeToItem()

void ItemComboWidget::subscribeToItem ( )
overrideprotectedvirtualinherited

Reimplemented from SessionItemWidget.

Definition at line 127 of file ItemComboWidget.cpp.

128 {
132 }
void setPresentationList(const QStringList &presentationList, const QStringList &activeList={})
virtual QStringList presentationList(SessionItem *item)
Returns full list of presentations available for given item.

References ItemComboWidget::activePresentationList(), SessionItemWidget::currentItem(), ItemComboWidget::itemPresentation(), ItemComboWidget::m_toolbar, ItemComboWidget::presentationList(), ItemComboWidget::setPresentation(), and ItemComboToolbar::setPresentationList().

Here is the call graph for this function:

◆ unsubscribeFromItem()

virtual void SessionItemWidget::unsubscribeFromItem ( )
inlineprotectedvirtualinherited

Member Data Documentation

◆ m_blankWidget

QWidget* ItemComboWidget::m_blankWidget
privateinherited

◆ m_itemController

◆ m_presentationTypeToWidget

QMap<QString, SessionItemWidget*> ItemComboWidget::m_presentationTypeToWidget
privateinherited

Definition at line 69 of file ItemComboWidget.h.

Referenced by ItemComboWidget::setPresentation().

◆ m_stackedWidget

QStackedWidget* ItemComboWidget::m_stackedWidget
privateinherited

◆ m_toolbar

◆ m_widgetFactory

IFactory<QString, SessionItemWidget> ItemComboWidget::m_widgetFactory
privateinherited

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