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

Description

Definition at line 111 of file InstrumentItems.h.

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

Public Member Functions

 SpecularInstrumentItem ()
 
bool alignedWith (const RealDataItem *item) const override
 
BackgroundItembackgroundItem () const
 
SelectionDescriptor< BackgroundItem * > backgroundSelection () const
 
SpecularBeamItembeamItem () const override
 
ICoordSystem * createCoordSystem () const override
 
InstrumentItemcreateCopy () const
 Creates an exact copy; also ID is the same! More...
 
QString defaultName () const override
 The default user visible name when creating an instrument. More...
 
QString description () const
 
 DOUBLE_PROPERTY (analyzerTotalTransmission, AnalyzerTotalTransmission)
 
QString id () const
 
virtual void importMasks (const MaskContainerItem *)
 
QString instrumentName () const
 
QString instrumentType () const override
 The type as how to show it on the UI. Do not use for type checking or similar! More...
 
template<typename T >
bool is () const
 
virtual void serialize (Streamer &s)
 
template<typename T >
T * setBackgroundType ()
 
void setDescription (const QString &description)
 
void setId (const QString &id)
 
void setInstrumentName (const QString &instrumentName)
 
void setWithPolarizerAnalyzer (bool with)
 
std::vector< int > shape () const override
 
void updateToRealData (const RealDataItem *item) override
 
 VECTOR_PROPERTY (analyzerDirection, AnalyzerDirection)
 
 VECTOR_PROPERTY (polarization, Polarization)
 
bool withPolarizerAnalyzer () const
 

Protected Member Functions

template<typename T >
T * beam () const
 

Protected Attributes

SelectionProperty< BackgroundItem * > m_backgroundItem
 
std::unique_ptr< BeamItemm_beamItem
 
QString m_description
 
QString m_id
 
QString m_name
 
bool m_withPolarizerAnalyzer
 

Constructor & Destructor Documentation

◆ SpecularInstrumentItem()

SpecularInstrumentItem::SpecularInstrumentItem ( )

Definition at line 169 of file InstrumentItems.cpp.

170 {
171  m_beamItem.reset(new SpecularBeamItem(this));
172 }
std::unique_ptr< BeamItem > m_beamItem

References InstrumentItem::m_beamItem.

Member Function Documentation

◆ alignedWith()

bool SpecularInstrumentItem::alignedWith ( const RealDataItem item) const
overridevirtual

Reimplemented from InstrumentItem.

Definition at line 195 of file InstrumentItems.cpp.

196 {
197  const QString native_units = item->nativeDataUnits();
198  if (native_units == "nbins") {
200  && shape() == item->shape();
201  }
202 
203  if (!beamItem()->inclinationAngleItem()->pointwiseAlphaAxisSelected())
204  return false;
205 
206  const auto* axisItem =
207  dynamic_cast<const PointwiseAxisItem*>(beamItem()->inclinationAngleItem()->alphaAxis());
208  ASSERT(axisItem);
209 
210  if (axisItem->getUnitsLabel() != native_units)
211  return false;
212 
213  const auto* instrumentAxis = axisItem->axis();
214  if (!instrumentAxis)
215  return false;
216 
217  if (!item->hasNativeData())
218  return false;
219 
220  const auto& native_axis = item->nativeDatafield()->axis(0);
221  return *instrumentAxis == native_axis;
222 }
Item for non-uniform axis with specified coordinates.
QString nativeDataUnits() const
std::vector< int > shape() const
Returns the shape of underlying data item.
bool hasNativeData() const
const Datafield * nativeDatafield() const
bool uniformAlphaAxisSelected() const
True if uniform axis is selected.
BasicAxisItem * alphaAxis() const
The currently selected axis.
SpecularBeamInclinationItem * inclinationAngleItem() const override
Definition: BeamItems.cpp:151
SpecularBeamItem * beamItem() const override
std::vector< int > shape() const override

References SpecularBeamInclinationItem::alphaAxis(), beamItem(), RealDataItem::hasNativeData(), SpecularBeamItem::inclinationAngleItem(), RealDataItem::nativeDatafield(), RealDataItem::nativeDataUnits(), RealDataItem::shape(), shape(), and SpecularBeamInclinationItem::uniformAlphaAxisSelected().

Here is the call graph for this function:

◆ backgroundItem()

BackgroundItem * InstrumentItem::backgroundItem ( ) const
inherited

Definition at line 119 of file InstrumentItems.cpp.

120 {
121  return m_backgroundItem.get();
122 }
SelectionProperty< BackgroundItem * > m_backgroundItem
T get() const
Direct access to the stored pointer.

References SelectionProperty< T >::get(), and InstrumentItem::m_backgroundItem.

Here is the call graph for this function:

◆ backgroundSelection()

SelectionDescriptor< BackgroundItem * > InstrumentItem::backgroundSelection ( ) const
inherited

◆ beam()

template<typename T >
T * InstrumentItem::beam
protectedinherited

◆ beamItem()

SpecularBeamItem * SpecularInstrumentItem::beamItem ( ) const
overridevirtual

Reimplemented from InstrumentItem.

Definition at line 174 of file InstrumentItems.cpp.

175 {
176  return beam<SpecularBeamItem>();
177 }

Referenced by SpecularInstrumentEditor::SpecularInstrumentEditor(), alignedWith(), createCoordSystem(), shape(), and updateToRealData().

◆ createCoordSystem()

ICoordSystem * SpecularInstrumentItem::createCoordSystem ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 224 of file InstrumentItems.cpp.

225 {
226  std::unique_ptr<Beam> beam = beamItem()->createBeam();
227  auto* axis_item = beamItem()->inclinationAxis();
228  if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) {
229  if (!pointwise_axis->axis()) // workaround for loading project
230  return nullptr;
231  Coords native_units = GUI::Util::CoordName::coordFromName(pointwise_axis->getUnitsLabel());
232  return new AngularReflectometryCoordinates(beam->wavelength(), *pointwise_axis->axis(),
233  native_units);
234  }
235 
236  return new AngularReflectometryCoordinates(beam->wavelength(), *axis_item->createAxis(1.0),
237  Coords::DEGREES);
238 }
std::unique_ptr< Beam > createBeam() const
Definition: BeamItems.cpp:97
BasicAxisItem * inclinationAxis() const
Definition: BeamItems.cpp:156
Coords coordFromName(const QString &name)
Returns domain axes units type from their GUI name.
Definition: CoordName.cpp:46

References InstrumentItem::beam(), beamItem(), GUI::Util::CoordName::coordFromName(), BeamItem::createBeam(), and SpecularBeamItem::inclinationAxis().

Referenced by PointwiseAxisItem::createAxis(), and PointwiseAxisItem::updateIndicators().

Here is the call graph for this function:

◆ createCopy()

InstrumentItem * InstrumentItem::createCopy ( ) const
inherited

Creates an exact copy; also ID is the same!

Definition at line 76 of file InstrumentItems.cpp.

77 {
78  const auto type = InstrumentItemCatalog::type(this);
79  auto* copy = InstrumentItemCatalog::create(type);
80  GUI::Util::copyContents(this, copy);
81  return copy;
82 }
static Type type(const InstrumentItem *item)
Returns the enum type of the given item.
static InstrumentItem * create(Type type)
Creates the item of the given type.
void copyContents(const T *source, T *dest)
Definition: Backup.h:46

References GUI::Util::copyContents(), InstrumentItemCatalog::create(), and InstrumentItemCatalog::type().

Referenced by JobItem::copyInstrumentIntoJob(), and InstrumentCollection::insertCopy().

Here is the call graph for this function:

◆ defaultName()

QString SpecularInstrumentItem::defaultName ( ) const
overridevirtual

The default user visible name when creating an instrument.

Implements InstrumentItem.

Definition at line 245 of file InstrumentItems.cpp.

246 {
247  return "Specular";
248 }

◆ description()

QString InstrumentItem::description ( ) const
inherited

Definition at line 104 of file InstrumentItems.cpp.

105 {
106  return m_description;
107 }

References InstrumentItem::m_description.

Referenced by InstrumentItem::setDescription().

◆ DOUBLE_PROPERTY()

InstrumentItem::DOUBLE_PROPERTY ( analyzerTotalTransmission  ,
AnalyzerTotalTransmission   
)
inherited

◆ id()

QString InstrumentItem::id ( ) const
inherited

◆ importMasks()

virtual void InstrumentItem::importMasks ( const MaskContainerItem )
inlinevirtualinherited

Reimplemented in Instrument2DItem.

Definition at line 78 of file InstrumentItems.h.

78 {}

◆ instrumentName()

◆ instrumentType()

QString SpecularInstrumentItem::instrumentType ( ) const
overridevirtual

The type as how to show it on the UI. Do not use for type checking or similar!

Implements InstrumentItem.

Definition at line 240 of file InstrumentItems.cpp.

241 {
242  return "Specular";
243 }

◆ is()

◆ serialize()

void InstrumentItem::serialize ( Streamer s)
virtualinherited

Reimplemented in OffspecInstrumentItem, Instrument2DItem, and DepthProbeInstrumentItem.

Definition at line 150 of file InstrumentItems.cpp.

151 {
152  s.assertVersion(0);
153  Serialize::rwValue(s, "id", m_id);
154  Serialize::rwValue(s, "name", m_name);
155  Serialize::rwValue(s, "description", m_description);
157  Serialize::rwProperty(s, m_polarization);
158  Serialize::rwProperty(s, m_analyzerDirection);
159  Serialize::rwProperty(s, m_analyzerEfficiency);
160  Serialize::rwProperty(s, m_analyzerTotalTransmission);
161  Serialize::rwSelected<BackgroundItemCatalog>(s, m_backgroundItem);
162  Serialize::rwClass(s, "beam", *m_beamItem);
163 }
bool m_withPolarizerAnalyzer
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwProperty(Streamer &s, DoubleProperty &d)
void rwValue(Streamer &s, const QString &tag, bool &val)
Definition: Serialize.cpp:19
void rwClass(Streamer &s, const QString &tag, T &t)
Serializes an item from a class that provides the function void serialize(Streamer&).
Definition: Serialize.h:77

References Streamer::assertVersion(), InstrumentItem::m_backgroundItem, InstrumentItem::m_beamItem, InstrumentItem::m_description, InstrumentItem::m_id, InstrumentItem::m_name, InstrumentItem::m_withPolarizerAnalyzer, Serialize::rwClass(), Serialize::rwProperty(), and Serialize::rwValue().

Here is the call graph for this function:

◆ setBackgroundType()

template<typename T >
T * InstrumentItem::setBackgroundType
inherited

Definition at line 205 of file InstrumentItems.h.

206 {
207  m_backgroundItem.set<T>();
208  return dynamic_cast<T*>(m_backgroundItem.get());
209 }
void set(T t, bool callInitializer=false)
Directly set the new item.

References SelectionProperty< T >::get(), InstrumentItem::m_backgroundItem, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ setDescription()

void InstrumentItem::setDescription ( const QString &  description)
inherited

Definition at line 109 of file InstrumentItems.cpp.

110 {
112 }
QString description() const

References InstrumentItem::description(), and InstrumentItem::m_description.

Referenced by InstrumentView::onInstrumentdescriptionEdited(), and InstrumentsTreeModel::setData().

Here is the call graph for this function:

◆ setId()

void InstrumentItem::setId ( const QString &  id)
inherited

Definition at line 89 of file InstrumentItems.cpp.

90 {
91  m_id = id;
92 }
QString id() const

References InstrumentItem::id(), and InstrumentItem::m_id.

Referenced by InstrumentCollection::insertCopy().

Here is the call graph for this function:

◆ setInstrumentName()

void InstrumentItem::setInstrumentName ( const QString &  instrumentName)
inherited

Definition at line 94 of file InstrumentItems.cpp.

95 {
97 }
QString instrumentName() const

References InstrumentItem::instrumentName(), and InstrumentItem::m_name.

Referenced by InstrumentsEditController::addCopy(), InstrumentsTreeModel::setData(), InstrumentsEditController::setInstrumentName(), and GUI::Model::JobFunctions::setupJobItemInstrument().

Here is the call graph for this function:

◆ setWithPolarizerAnalyzer()

void InstrumentItem::setWithPolarizerAnalyzer ( bool  with)
inherited

◆ shape()

std::vector< int > SpecularInstrumentItem::shape ( ) const
overridevirtual

Implements InstrumentItem.

Definition at line 179 of file InstrumentItems.cpp.

180 {
181  auto* const axis_item = beamItem()->inclinationAxis();
182  return {axis_item->binCount()};
183 }
int binCount() const
Definition: AxesItems.cpp:26

References beamItem(), BasicAxisItem::binCount(), and SpecularBeamItem::inclinationAxis().

Referenced by alignedWith(), and updateToRealData().

Here is the call graph for this function:

◆ updateToRealData()

void SpecularInstrumentItem::updateToRealData ( const RealDataItem item)
overridevirtual

Implements InstrumentItem.

Definition at line 185 of file InstrumentItems.cpp.

186 {
187  if (shape().size() != item->shape().size())
188  throw Error("Error in SpecularInstrumentItem::updateToRealData: The type "
189  "of instrument is incompatible with passed data shape.");
190 
191  const auto& data = item->nativeDatafield()->axis(0);
192  beamItem()->updateToData(data, item->nativeDataUnits());
193 }
void updateToData(const IAxis &axis, QString units)
Definition: BeamItems.cpp:181

References beamItem(), Error, RealDataItem::nativeDatafield(), RealDataItem::nativeDataUnits(), RealDataItem::shape(), shape(), and SpecularBeamItem::updateToData().

Here is the call graph for this function:

◆ VECTOR_PROPERTY() [1/2]

InstrumentItem::VECTOR_PROPERTY ( analyzerDirection  ,
AnalyzerDirection   
)
inherited

◆ VECTOR_PROPERTY() [2/2]

InstrumentItem::VECTOR_PROPERTY ( polarization  ,
Polarization   
)
inherited

◆ withPolarizerAnalyzer()

bool InstrumentItem::withPolarizerAnalyzer ( ) const
inherited

Member Data Documentation

◆ m_backgroundItem

◆ m_beamItem

◆ m_description

QString InstrumentItem::m_description
protectedinherited

◆ m_id

QString InstrumentItem::m_id
protectedinherited

◆ m_name

QString InstrumentItem::m_name
protectedinherited

◆ m_withPolarizerAnalyzer

bool InstrumentItem::m_withPolarizerAnalyzer
protectedinherited

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