BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
FitSessionManager.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/FitWidgets/FitSessionManager.cpp
6 //! @brief Implements class FitSessionManager
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
21 
23  : QObject(parent), m_activeController(nullptr), m_jobMessagePanel(nullptr)
24 {
25 }
26 
28 {
29  m_jobMessagePanel = messagePanel;
30 }
31 
33 {
34  FitSessionController* result(nullptr);
35 
36  auto it = m_item_to_controller.find(item);
37  if (it == m_item_to_controller.end()) {
38  result = createController(item);
39  m_item_to_controller.insert(item, result);
40  } else {
41  result = it.value();
42  }
43 
45 
47  m_activeController = result;
48 
49  return result;
50 }
51 
53 {
56 
58 }
59 
61 {
62  jobItem->mapper()->setOnItemDestroy([this](SessionItem* item) { removeController(item); },
63  this);
64 
65  auto result = new FitSessionController(this);
66  result->setItem(jobItem);
67  return result;
68 }
69 
70 //! Removes manager for given jobItem
71 
73 {
74  auto it = m_item_to_controller.find(jobItem);
75  if (it == m_item_to_controller.end())
76  throw GUIHelpers::Error("FitActivityManager::removeFitSession() -> Error. "
77  "Can't find fit session");
78 
79  if (m_activeController == it.value())
80  m_activeController = nullptr;
81  delete it.value();
82  m_item_to_controller.erase(it);
83 }
Defines class FitLog.
Defines class FitSessionController.
Defines class FitSessionManager.
Defines class GUIHelpers functions.
Defines class JobItem.
Defines class JobMessagePanel.
void setMessagePanel(JobMessagePanel *messagePanel)
Definition: FitLog.cpp:20
Controls all activity related to the single fitting task for JobItem.
FitSessionManager(QObject *parent=nullptr)
JobMessagePanel * m_jobMessagePanel
FitSessionController * m_activeController
void removeController(SessionItem *jobItem)
Fit controller which is currently attached to jobMessagePanel.
FitSessionController * createController(JobItem *jobItem)
QMap< SessionItem *, FitSessionController * > m_item_to_controller
FitSessionController * sessionController(JobItem *item)
void setMessagePanel(JobMessagePanel *messagePanel)
The JobMessagePanel class shows log messages from FitActivityPanel at the bottom part of JobView.
void setOnItemDestroy(std::function< void(SessionItem *)> f, const void *caller=0)
Definition: ModelMapper.cpp:87
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.