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

Description

Definition at line 26 of file FitComparisonViewController.h.

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

Public Member Functions

 DiffItemController (const QString &data_type, QObject *parent)
 
 ~DiffItemController () override
 
DataItemdiffItem ()
 
JobItemjobItem ()
 
SessionModelmodel ()
 
void setJobItem (JobItem *job_item)
 
void subscribe ()
 
void unsubscribe ()
 
void updateDiffData ()
 

Private Attributes

JobItemm_current_item
 
DataItemm_diff_item
 
SessionModelm_private_model
 

Constructor & Destructor Documentation

◆ DiffItemController()

DiffItemController::DiffItemController ( const QString &  data_type,
QObject *  parent 
)

Definition at line 123 of file FitComparisonController.cpp.

124  : QObject(parent)
125  , m_current_item(nullptr)
126  , m_tempIntensityDataModel(new SessionModel("TempIntensityDataModel", this))
127  , m_diff_item(dynamic_cast<DataItem*>(m_tempIntensityDataModel->insertNewItem(data_type)))
128 {
129  ASSERT(m_diff_item);
130 }
Abstract base class for IntensityDataItem and SpecularDataItem. Owns one simulated data set of type D...
Definition: DataItem.h:34
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42

References m_diff_item.

◆ ~DiffItemController()

DiffItemController::~DiffItemController ( )
override

Definition at line 132 of file FitComparisonController.cpp.

133 {
134  unsubscribe();
135 }

References unsubscribe().

Here is the call graph for this function:

Member Function Documentation

◆ diffItem()

DataItem * DiffItemController::diffItem ( )
inline

Definition at line 34 of file FitComparisonViewController.h.

34 { return m_diff_item; }

References m_diff_item.

Referenced by FitComparison1DViewController::createDiffViewItem().

◆ jobItem()

JobItem* DiffItemController::jobItem ( )
inline

Definition at line 32 of file FitComparisonViewController.h.

32 { return m_current_item; }

References m_current_item.

◆ model()

SessionModel* DiffItemController::model ( )
inline

Definition at line 30 of file FitComparisonViewController.h.

30 { return m_private_model; }

References m_private_model.

Referenced by FitComparison1DViewController::createDiffViewItem().

◆ setJobItem()

void DiffItemController::setJobItem ( JobItem job_item)

Definition at line 128 of file FitComparisonViewController.cpp.

129 {
130  ASSERT(job_item);
131  if (m_current_item)
132  unsubscribe();
133  m_current_item = job_item;
134  subscribe();
135  updateDiffData();
136 }

References m_current_item, subscribe(), unsubscribe(), and updateDiffData().

Referenced by FitComparison1DViewController::setItem().

Here is the call graph for this function:

◆ subscribe()

void DiffItemController::subscribe ( )

Definition at line 167 of file FitComparisonController.cpp.

168 {
169  if (!m_current_item) {
170  ASSERT(false);
171  return;
172  }
173 
174  // on simulation data change
176  [=](Datafield*) { updateDiffData(); });
177 
178  // on diff item units change
179  connect(m_diff_item, &DataItem::axesUnitsChanged, this, [=](const ComboProperty&) {
181  });
182 }
Custom property to define list of string values with multiple selections. Intended for QVariant.
Definition: ComboProperty.h:25
void datafieldChanged(Datafield *data)
virtual void updateCoords(const InstrumentItem *instrument)=0
void axesUnitsChanged(const ComboProperty &units)
InstrumentItem * instrumentItem() const
Definition: JobItem.cpp:233
DataItem * dataItem()
Definition: JobItem.cpp:101

References DataItem::axesUnitsChanged(), DataItem::datafieldChanged(), JobItem::dataItem(), JobItem::instrumentItem(), m_current_item, m_diff_item, and DataItem::updateCoords().

Referenced by FitComparisonController2D::DiffItemController::setItem(), and setJobItem().

Here is the call graph for this function:

◆ unsubscribe()

void DiffItemController::unsubscribe ( )

Definition at line 184 of file FitComparisonController.cpp.

185 {
186  if (!m_current_item)
187  return;
188 
189  disconnect(m_current_item->dataItem(), nullptr, this, nullptr);
190  disconnect(m_diff_item, nullptr, this, nullptr);
191  m_current_item = nullptr;
192 }

References JobItem::dataItem(), m_current_item, and m_diff_item.

Referenced by ~DiffItemController(), FitComparison1DViewController::clear(), FitComparisonController2D::DiffItemController::setItem(), and setJobItem().

Here is the call graph for this function:

◆ updateDiffData()

void DiffItemController::updateDiffData ( )

Definition at line 147 of file FitComparisonController.cpp.

148 {
149  ASSERT(m_current_item);
150 
151  auto* sim_data = m_current_item->dataItem();
152  auto* real_data = m_current_item->realDataItem()->dataItem();
153  ASSERT(sim_data && real_data);
154 
155  if (!sim_data->getDatafield()) // job failed
156  return;
157 
159  DiffUtil::relativeDifferenceField(*sim_data->getDatafield(), *real_data->getDatafield()));
160 }
virtual void setDatafield(Datafield *data)=0
The given pointer becomes owned by this class!!
Definition: DataItem.cpp:20
RealDataItem * realDataItem()
Definition: JobItem.cpp:290
DataItem * dataItem()

References RealDataItem::dataItem(), JobItem::dataItem(), m_current_item, m_diff_item, JobItem::realDataItem(), and DataItem::setDatafield().

Referenced by FitComparisonController2D::DiffItemController::setItem(), setJobItem(), and FitComparison1DViewController::updateDiffData().

Here is the call graph for this function:

Member Data Documentation

◆ m_current_item

JobItem* DiffItemController::m_current_item
private

◆ m_diff_item

DataItem* DiffItemController::m_diff_item
private

◆ m_private_model

SessionModel* DiffItemController::m_private_model
private

Definition at line 40 of file FitComparisonViewController.h.

Referenced by model().


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