BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentItem Class Referenceabstract

Description

Abstract base class for instrument-specific item classes.

Definition at line 41 of file InstrumentItems.h.

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

Public Member Functions

 InstrumentItem ()
 
virtual ~InstrumentItem ()=default
 
virtual bool alignedWith (const RealDataItem *item) const
 
BackgroundItembackgroundItem () const
 
SelectionDescriptor< BackgroundItem * > backgroundSelection () const
 
virtual BeamItembeamItem () const
 
virtual ICoordSystem * createCoordSystem () const =0
 
InstrumentItemcreateCopy () const
 Creates an exact copy; also ID is the same! More...
 
virtual QString defaultName () const =0
 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
 
virtual QString instrumentType () const =0
 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)
 
virtual std::vector< int > shape () const =0
 
virtual void updateToRealData (const RealDataItem *item)=0
 
 VECTOR_PROPERTY (analyzerDirection, AnalyzerDirection)
 
 VECTOR_PROPERTY (polarization, Polarization)
 
bool withPolarizerAnalyzer () const
 

Protected Member Functions

 InstrumentItem (const QString &modelType)
 
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

◆ InstrumentItem() [1/2]

InstrumentItem::InstrumentItem ( )

Definition at line 59 of file InstrumentItems.cpp.

61 {
62  m_id = QUuid::createUuid().toString();
63  m_analyzerEfficiency.init("Analyzer efficiency", "Efficiency of the polarization analysis", 0.0,
64  Unit::unitless, 4, RealLimits::limitless(), "efficiency");
65  m_analyzerTotalTransmission.init("Analyzer transmission",
66  "Total transmission of the polarization analysis", 1.0,
67  Unit::unitless, 4, RealLimits::nonnegative(), "transmission");
68  m_polarization.init("Polarization (Bloch vector)",
69  "Polarization of the beam, given as the Bloch vector", Unit::unitless,
70  "polarization");
71  m_analyzerDirection.init("Analyzer direction", "Direction of the polarization analysis",
72  Unit::unitless, "analyzerDirection");
73  m_backgroundItem.init<BackgroundItemCatalog>("Background", "", "background");
74 }
@ unitless
SelectionProperty< BackgroundItem * > m_backgroundItem
bool m_withPolarizerAnalyzer
void init(const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation)
Initialize by means of a catalog class and optional creation arguments.

References SelectionProperty< T >::init(), m_backgroundItem, m_id, and unitless.

Here is the call graph for this function:

◆ ~InstrumentItem()

virtual InstrumentItem::~InstrumentItem ( )
virtualdefault

◆ InstrumentItem() [2/2]

InstrumentItem::InstrumentItem ( const QString &  modelType)
explicitprotected

Member Function Documentation

◆ alignedWith()

bool InstrumentItem::alignedWith ( const RealDataItem item) const
virtual

Reimplemented in SpecularInstrumentItem.

Definition at line 129 of file InstrumentItems.cpp.

130 {
131  return shape() == item->shape();
132 }
virtual std::vector< int > shape() const =0
std::vector< int > shape() const
Returns the shape of underlying data item.

References RealDataItem::shape(), and shape().

Referenced by LinkInstrumentManager::onInstrumentChanged(), and SimulationView::validateSimulationSetup().

Here is the call graph for this function:

◆ backgroundItem()

BackgroundItem * InstrumentItem::backgroundItem ( ) const

Definition at line 119 of file InstrumentItems.cpp.

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

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

Here is the call graph for this function:

◆ backgroundSelection()

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

Definition at line 124 of file InstrumentItems.cpp.

125 {
126  return m_backgroundItem;
127 }

References m_backgroundItem.

Referenced by EnvironmentEditor::EnvironmentEditor(), and EnvironmentEditor::createBackgroundWidgets().

◆ beam()

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

Definition at line 145 of file InstrumentItems.cpp.

146 {
147  return dynamic_cast<T*>(m_beamItem.get());
148 }
std::unique_ptr< BeamItem > m_beamItem

References m_beamItem.

Referenced by SpecularInstrumentItem::createCoordSystem(), Instrument2DItem::createInstrument(), Instrument2DItem::createOffspecSimulation(), and Instrument2DItem::createScatteringSimulation().

◆ beamItem()

◆ createCoordSystem()

◆ createCopy()

InstrumentItem * InstrumentItem::createCopy ( ) const

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()

virtual QString InstrumentItem::defaultName ( ) const
pure virtual

The default user visible name when creating an instrument.

Implemented in OffspecInstrumentItem, GISASInstrumentItem, DepthProbeInstrumentItem, and SpecularInstrumentItem.

◆ description()

QString InstrumentItem::description ( ) const

Definition at line 104 of file InstrumentItems.cpp.

105 {
106  return m_description;
107 }

References m_description.

Referenced by setDescription().

◆ DOUBLE_PROPERTY()

InstrumentItem::DOUBLE_PROPERTY ( analyzerTotalTransmission  ,
AnalyzerTotalTransmission   
)

◆ id()

QString InstrumentItem::id ( ) const

Definition at line 84 of file InstrumentItems.cpp.

85 {
86  return m_id;
87 }

References m_id.

Referenced by RealDataItem::linkToInstrument(), LinkInstrumentManager::onInstrumentChanged(), and setId().

◆ importMasks()

virtual void InstrumentItem::importMasks ( const MaskContainerItem )
inlinevirtual

Reimplemented in Instrument2DItem.

Definition at line 78 of file InstrumentItems.h.

78 {}

◆ instrumentName()

◆ instrumentType()

virtual QString InstrumentItem::instrumentType ( ) const
pure virtual

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

Implemented in OffspecInstrumentItem, GISASInstrumentItem, DepthProbeInstrumentItem, and SpecularInstrumentItem.

◆ is()

◆ serialize()

void InstrumentItem::serialize ( Streamer s)
virtual

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 }
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(), m_backgroundItem, m_beamItem, m_description, m_id, m_name, m_withPolarizerAnalyzer, Serialize::rwClass(), Serialize::rwProperty(), and Serialize::rwValue().

Here is the call graph for this function:

◆ setBackgroundType()

template<typename T >
T * InstrumentItem::setBackgroundType

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(), m_backgroundItem, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ setDescription()

void InstrumentItem::setDescription ( const QString &  description)

Definition at line 109 of file InstrumentItems.cpp.

110 {
112 }
QString description() const

References description(), and m_description.

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

Here is the call graph for this function:

◆ setId()

void InstrumentItem::setId ( const QString &  id)

Definition at line 89 of file InstrumentItems.cpp.

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

References id(), and m_id.

Referenced by InstrumentCollection::insertCopy().

Here is the call graph for this function:

◆ setInstrumentName()

void InstrumentItem::setInstrumentName ( const QString &  instrumentName)

Definition at line 94 of file InstrumentItems.cpp.

95 {
97 }
QString instrumentName() const

References instrumentName(), and 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)

Definition at line 139 of file InstrumentItems.cpp.

140 {
142 }

References m_withPolarizerAnalyzer.

Referenced by PolarizationAnalysisEditor::PolarizationAnalysisEditor().

◆ shape()

virtual std::vector<int> InstrumentItem::shape ( ) const
pure virtual

◆ updateToRealData()

virtual void InstrumentItem::updateToRealData ( const RealDataItem item)
pure virtual

◆ VECTOR_PROPERTY() [1/2]

InstrumentItem::VECTOR_PROPERTY ( analyzerDirection  ,
AnalyzerDirection   
)

◆ VECTOR_PROPERTY() [2/2]

InstrumentItem::VECTOR_PROPERTY ( polarization  ,
Polarization   
)

◆ withPolarizerAnalyzer()

bool InstrumentItem::withPolarizerAnalyzer ( ) const

Member Data Documentation

◆ m_backgroundItem

SelectionProperty<BackgroundItem*> InstrumentItem::m_backgroundItem
protected

◆ m_beamItem

◆ m_description

QString InstrumentItem::m_description
protected

Definition at line 104 of file InstrumentItems.h.

Referenced by description(), serialize(), and setDescription().

◆ m_id

QString InstrumentItem::m_id
protected

Definition at line 102 of file InstrumentItems.h.

Referenced by InstrumentItem(), id(), serialize(), and setId().

◆ m_name

QString InstrumentItem::m_name
protected

Definition at line 103 of file InstrumentItems.h.

Referenced by instrumentName(), serialize(), and setInstrumentName().

◆ m_withPolarizerAnalyzer

bool InstrumentItem::m_withPolarizerAnalyzer
protected

Definition at line 105 of file InstrumentItems.h.

Referenced by serialize(), setWithPolarizerAnalyzer(), and withPolarizerAnalyzer().


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