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

Description

Definition at line 172 of file DistributionItems.h.

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

Public Member Functions

 DistributionTrapezoidItem ()
 
std::unique_ptr< IDistribution1D > createDistribution (double scale=1.0) const override
 
DoubleDescriptors distributionValues (bool withMean=true) const override
 
 DOUBLE_PROPERTY (center, Center)
 
 DOUBLE_PROPERTY (leftWidth, LeftWidth)
 
 DOUBLE_PROPERTY (middleWidth, MiddleWidth)
 
 DOUBLE_PROPERTY (rightWidth, RightWidth)
 
 DOUBLE_PROPERTY (sigmaFactor, SigmaFactor)
 
bool hasSigmaFactor () const
 
void initDistribution (double value) override
 
template<typename T >
bool is () const
 
RealLimits limits () const
 
void serialize (Streamer &s)
 Serialization of contents. More...
 
virtual void setLimits (const RealLimits &limits)
 
void setUnit (const variant< QString, Unit > &unit) override
 Set the unit of the distributed value. More...
 
 UINT_PROPERTY (numberOfSamples, NumberOfSamples)
 

Protected Member Functions

void addToSerialization (DoubleProperty *d)
 
void initSigmaFactor ()
 

Protected Attributes

RealLimits m_limits
 

Private Attributes

QVector< DoubleProperty * > m_serializationProperties
 

Constructor & Destructor Documentation

◆ DistributionTrapezoidItem()

DistributionTrapezoidItem::DistributionTrapezoidItem ( )

Definition at line 359 of file DistributionItems.cpp.

360 {
361  m_center.init("Center", "", 1.0, Unit::unitless, 3, RealLimits::limitless(), "center");
362  m_leftWidth.init("LeftWidth", "", 1.0, Unit::unitless, "left");
363  m_middleWidth.init("MiddleWidth", "", 1.0, Unit::unitless, "middle");
364  m_rightWidth.init("RightWidth", "", 1.0, Unit::unitless, "right");
365 
366  addToSerialization(&m_center);
367  addToSerialization(&m_leftWidth);
368  addToSerialization(&m_middleWidth);
369  addToSerialization(&m_rightWidth);
370 }
@ unitless
void addToSerialization(DoubleProperty *d)

References DistributionItem::addToSerialization(), and unitless.

Here is the call graph for this function:

Member Function Documentation

◆ addToSerialization()

◆ createDistribution()

std::unique_ptr< IDistribution1D > DistributionTrapezoidItem::createDistribution ( double  scale = 1.0) const
overridevirtual

Implements DistributionItem.

Definition at line 380 of file DistributionItems.cpp.

381 {
382  return std::make_unique<DistributionTrapezoid>(scale * center(), scale * leftWidth(),
383  scale * middleWidth(), scale * rightWidth());
384 }

◆ distributionValues()

DoubleDescriptors DistributionTrapezoidItem::distributionValues ( bool  withMean = true) const
overridevirtual

Implements DistributionItem.

Definition at line 397 of file DistributionItems.cpp.

398 {
399  return withMean ? DoubleDescriptors{center(), leftWidth(), middleWidth(), rightWidth()}
400  : DoubleDescriptors{leftWidth(), middleWidth(), rightWidth()};
401 }
QList< DoubleDescriptor > DoubleDescriptors

◆ DOUBLE_PROPERTY() [1/5]

DistributionTrapezoidItem::DOUBLE_PROPERTY ( center  ,
Center   
)

◆ DOUBLE_PROPERTY() [2/5]

DistributionTrapezoidItem::DOUBLE_PROPERTY ( leftWidth  ,
LeftWidth   
)

◆ DOUBLE_PROPERTY() [3/5]

DistributionTrapezoidItem::DOUBLE_PROPERTY ( middleWidth  ,
MiddleWidth   
)

◆ DOUBLE_PROPERTY() [4/5]

DistributionTrapezoidItem::DOUBLE_PROPERTY ( rightWidth  ,
RightWidth   
)

◆ DOUBLE_PROPERTY() [5/5]

DistributionItem::DOUBLE_PROPERTY ( sigmaFactor  ,
SigmaFactor   
)
inherited

◆ hasSigmaFactor()

bool DistributionItem::hasSigmaFactor ( ) const
inherited

Definition at line 45 of file DistributionItems.cpp.

46 {
47  return m_sigmaFactor.isInitialized();
48 }

Referenced by DistributionPlot::plot_multiple_values().

◆ initDistribution()

void DistributionTrapezoidItem::initDistribution ( double  value)
overridevirtual

Reimplemented from DistributionItem.

Definition at line 386 of file DistributionItems.cpp.

387 {
388  double width(0.1 * std::abs(value));
389  if (width == 0.0)
390  width = 0.1;
391  setCenter(value);
392  setLeftWidth(width);
393  setMiddleWidth(width);
394  setRightWidth(width);
395 }

◆ initSigmaFactor()

void DistributionItem::initSigmaFactor ( )
protectedinherited

Definition at line 34 of file DistributionItems.cpp.

35 {
36  m_sigmaFactor.init("Sigma factor", "", 2.0, Unit::unitless, "sigmaFactor");
37  addToSerialization(&m_sigmaFactor);
38 }

References DistributionItem::addToSerialization(), and unitless.

Referenced by DistributionCosineItem::DistributionCosineItem(), DistributionGaussianItem::DistributionGaussianItem(), DistributionLogNormalItem::DistributionLogNormalItem(), and DistributionLorentzItem::DistributionLorentzItem().

Here is the call graph for this function:

◆ is()

template<typename T >
bool DistributionItem::is ( ) const
inlineinherited

Definition at line 33 of file DistributionItems.h.

34  {
35  return dynamic_cast<const T*>(this) != nullptr;
36  }

Referenced by DistributionPlot::plot_distributions(), DistributionPlot::plot_multiple_values(), and DistributionPlot::plot_single_value().

◆ limits()

RealLimits DistributionItem::limits ( ) const
inherited

◆ serialize()

void DistributionItem::serialize ( Streamer s)
inherited

Serialization of contents.

Important: limits and a changed unit (with setUnit) will not be serialized here. They have to be set again by the owner of DistributionItem after reading it

Definition at line 50 of file DistributionItems.cpp.

51 {
52  s.assertVersion(0);
53  Serialize::rwProperty(s, m_numberOfSamples);
54 
55  for (auto* p : m_serializationProperties)
56  Serialize::rwProperty(s, *p);
57 
58  // m_limits and a changed unit (with setUnit) will not be serialized here. They have to be set
59  // again by the owner of DistributionItem after reading it
60 }
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)

References Streamer::assertVersion(), DistributionItem::m_serializationProperties, and Serialize::rwProperty().

Here is the call graph for this function:

◆ setLimits()

void DistributionItem::setLimits ( const RealLimits &  limits)
virtualinherited

Reimplemented in SymmetricResolutionItem.

Definition at line 29 of file DistributionItems.cpp.

30 {
31  m_limits = limits;
32 }
RealLimits limits() const

References DistributionItem::limits(), and DistributionItem::m_limits.

Referenced by BeamAzimuthalAngleItem::initDistribution(), BeamInclinationAngleItem::initDistribution(), BeamAzimuthalAngleItem::serialize(), BeamInclinationAngleItem::serialize(), BeamWavelengthItem::serialize(), SpecularBeamInclinationItem::serialize(), and SymmetricResolutionItem::setLimits().

Here is the call graph for this function:

◆ setUnit()

void DistributionTrapezoidItem::setUnit ( const variant< QString, Unit > &  unit)
overridevirtual

Set the unit of the distributed value.

Implements DistributionItem.

Definition at line 372 of file DistributionItems.cpp.

373 {
374  m_center.setUnit(unit);
375  m_leftWidth.setUnit(unit);
376  m_middleWidth.setUnit(unit);
377  m_rightWidth.setUnit(unit);
378 }

◆ UINT_PROPERTY()

DistributionItem::UINT_PROPERTY ( numberOfSamples  ,
NumberOfSamples   
)
inherited

Member Data Documentation

◆ m_limits

◆ m_serializationProperties

QVector<DoubleProperty*> DistributionItem::m_serializationProperties
privateinherited

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