BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Model::JobFunctions Namespace Reference

Description

Contains set of functions to extend JobModel functionality. Handles setup of JobItem in fitting context.

Functions

void copyRealDataItem (JobItem *jobItem, const RealDataItem *realDataItem)
 Copy RealDataItem to jobItem intended for fitting. More...
 
void initDataView (JobItem *job_item)
 Initializes Data1DViewItem and assigns it to the passed JobItem. More...
 
void setupJobItemForFit (JobItem *jobItem, const RealDataItem *realDataItem)
 Setups JobItem for fit. More...
 
void setupJobItemInstrument (JobItem *jobItem, const InstrumentItem *from)
 Properly copies instrument into job item. More...
 
void setupJobItemOutput (JobItem *jobItem)
 Setup items intended for storing results of the job. More...
 

Function Documentation

◆ copyRealDataItem()

void GUI::Model::JobFunctions::copyRealDataItem ( JobItem jobItem,
const RealDataItem realDataItem 
)

Copy RealDataItem to jobItem intended for fitting.

Definition at line 163 of file JobFunctions.cpp.

164 {
165  if (!realDataItem)
166  return;
167 
168  RealDataItem* realDataItemCopy = jobItem->copyRealDataIntoJob(realDataItem);
169  ASSERT(realDataItemCopy);
170 
171  realDataItemCopy->dataItem()->setDatafield(realDataItem->dataItem()->getDatafield()->clone());
172 
173  // adapting the name to job name
174  realDataItemCopy->dataItem()->setFileName(
176 
177  // #baimport ++ copy members of realDataItem?
178 
179  if (!realDataItem->hasNativeData())
180  return;
181 
182  realDataItemCopy->setNativeDatafield(realDataItem->nativeDatafield()->clone());
183  realDataItemCopy->nativeData()->setFileName(
185 }
virtual void setDatafield(Datafield *data)=0
The given pointer becomes owned by this class!!
Definition: DataItem.cpp:20
Datafield * getDatafield()
Definition: DataItem.h:41
void setFileName(const QString &filename)
Definition: DataItem.cpp:46
QString jobName() const
Definition: JobItem.cpp:84
RealDataItem * copyRealDataIntoJob(const RealDataItem *real_data)
Definition: JobItem.cpp:295
QString getIdentifier() const
Definition: JobItem.cpp:73
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33
void setNativeDatafield(Datafield *data)
takes ownership of data
bool hasNativeData() const
DataItem * nativeData()
const Datafield * nativeDatafield() const
DataItem * dataItem()
QString jobReferenceFileName(const QString &itemName)
Constructs the name of the file with reference data.
QString jobNativeDataFileName(const QString &id)

References JobItem::copyRealDataIntoJob(), RealDataItem::dataItem(), DataItem::getDatafield(), JobItem::getIdentifier(), RealDataItem::hasNativeData(), JobItem::jobName(), GUI::Model::FilenameUtils::jobNativeDataFileName(), GUI::Model::FilenameUtils::jobReferenceFileName(), RealDataItem::nativeData(), RealDataItem::nativeDatafield(), DataItem::setDatafield(), DataItem::setFileName(), and RealDataItem::setNativeDatafield().

Referenced by setupJobItemForFit().

Here is the call graph for this function:

◆ initDataView()

void GUI::Model::JobFunctions::initDataView ( JobItem job_item)

Initializes Data1DViewItem and assigns it to the passed JobItem.

Definition at line 98 of file JobFunctions.cpp.

99 {
100  ASSERT(job_item && job_item->isValidForFitting());
101  ASSERT(job_item->instrumentItem() && job_item->instrumentItem()->is<SpecularInstrumentItem>());
102  ASSERT(!job_item->dataItemView());
103 
104  auto* view_item = job_item->createDataViewItem();
105 
106  auto* property_container = view_item->createPropertyContainerItem();
107 
108  property_container->addItem(job_item->realDataItem()->dataItem());
109  property_container->addItem(job_item->dataItem());
110 
111  // also triggers Data1DViewItem::setAxesRangeToData and
112  // GUI::Model::DataViewUtils::updateAxesTitle by setting new value of P_AXES_UNITS.
113  auto* converter = job_item->instrumentItem()->createCoordSystem();
114  view_item->setAxesUnits(GUI::Model::JobItemUtils::availableUnits(*converter));
115 }
DataPropertyContainer * createPropertyContainerItem()
void addItem(DataItem *data_item)
bool is() const
virtual ICoordSystem * createCoordSystem() const =0
Data1DViewItem * dataItemView()
Definition: JobItem.cpp:305
InstrumentItem * instrumentItem() const
Definition: JobItem.cpp:233
DataItem * dataItem()
Definition: JobItem.cpp:101
RealDataItem * realDataItem()
Definition: JobItem.cpp:290
bool isValidForFitting()
Definition: JobItem.cpp:154
Data1DViewItem * createDataViewItem()
Definition: JobItem.cpp:315
ComboProperty availableUnits(const ICoordSystem &converter)

References DataPropertyContainer::addItem(), GUI::Model::JobItemUtils::availableUnits(), InstrumentItem::createCoordSystem(), JobItem::createDataViewItem(), Data1DViewItem::createPropertyContainerItem(), RealDataItem::dataItem(), JobItem::dataItem(), JobItem::dataItemView(), JobItem::instrumentItem(), InstrumentItem::is(), JobItem::isValidForFitting(), and JobItem::realDataItem().

Referenced by setupJobItemForFit().

Here is the call graph for this function:

◆ setupJobItemForFit()

void GUI::Model::JobFunctions::setupJobItemForFit ( JobItem jobItem,
const RealDataItem realDataItem 
)

Setups JobItem for fit.

Definition at line 146 of file JobFunctions.cpp.

148 {
149  ASSERT(jobItem->instrumentItem());
150 
151  copyRealDataItem(jobItem, realDataItem);
152  processInstrumentLink(jobItem);
153  copyMasksToInstrument(jobItem);
154 
155  if (jobItem->instrumentItem()->is<GISASInstrumentItem>())
156  cropRealData(jobItem);
157  if (jobItem->instrumentItem()->is<SpecularInstrumentItem>())
158  initDataView(jobItem);
159 
160  createFitContainers(jobItem);
161 }
void copyRealDataItem(JobItem *jobItem, const RealDataItem *realDataItem)
Copy RealDataItem to jobItem intended for fitting.
void initDataView(JobItem *job_item)
Initializes Data1DViewItem and assigns it to the passed JobItem.

References copyRealDataItem(), initDataView(), JobItem::instrumentItem(), and InstrumentItem::is().

Referenced by JobModel::addJob().

Here is the call graph for this function:

◆ setupJobItemInstrument()

void GUI::Model::JobFunctions::setupJobItemInstrument ( JobItem jobItem,
const InstrumentItem from 
)

Properly copies instrument into job item.

Definition at line 117 of file JobFunctions.cpp.

118 {
119  auto* copiedInstrument = jobItem->copyInstrumentIntoJob(from);
120  copiedInstrument->setInstrumentName(copiedInstrument->instrumentType() + " instrument");
121  copiedInstrument->setId(QUuid::createUuid().toString());
122  jobItem->setInstrumentName(from->instrumentName());
123 }
QString instrumentName() const
void setInstrumentName(const QString &instrumentName)
void setInstrumentName(const QString &name)
Definition: JobItem.cpp:330
InstrumentItem * copyInstrumentIntoJob(const InstrumentItem *instrument)
Definition: JobItem.cpp:245
QString toString(const QModelIndex &index)
Provides string representation of index data.

References JobItem::copyInstrumentIntoJob(), InstrumentItem::instrumentName(), InstrumentItem::setInstrumentName(), JobItem::setInstrumentName(), and GUI::View::PropertyEditorFactory::toString().

Referenced by JobModel::addJob().

Here is the call graph for this function:

◆ setupJobItemOutput()

void GUI::Model::JobFunctions::setupJobItemOutput ( JobItem jobItem)

Setup items intended for storing results of the job.

Definition at line 127 of file JobFunctions.cpp.

128 {
129  const bool isSpecularInstrument = jobItem->instrumentItem()->is<SpecularInstrumentItem>();
130  const bool isIntensityInstrument = jobItem->instrumentItem()->is<GISASInstrumentItem>()
131  || jobItem->instrumentItem()->is<OffspecInstrumentItem>()
132  || jobItem->instrumentItem()->is<DepthProbeInstrumentItem>();
133 
134  ASSERT(isSpecularInstrument || isIntensityInstrument);
135 
136  if (isSpecularInstrument)
137  jobItem->setDataType<SpecularDataItem>();
138  else if (isIntensityInstrument)
139  jobItem->setDataType<IntensityDataItem>();
140  else
141  ASSERT(0);
142 }
T * setDataType()
Definition: JobItem.h:171

References JobItem::instrumentItem(), InstrumentItem::is(), and JobItem::setDataType().

Referenced by JobModel::addJob().

Here is the call graph for this function: