BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
IAxis Class Referenceabstract

Description

Abstract base class for one-dimensional axes.

Definition at line 27 of file IAxis.h.

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

Public Member Functions

 IAxis (const IAxis &)=delete
 
 IAxis (std::string name)
 
virtual ~IAxis ()
 
std::string axisName () const
 Returns the label of the axis. More...
 
virtual Bin1D bin (size_t index) const =0
 retrieve a 1d bin for the given index More...
 
virtual std::vector< double > binBoundaries () const
 
virtual double binCenter (size_t index) const =0
 
virtual std::vector< double > binCenters () const
 
std::pair< double, double > bounds () const
 Returns lower and upper bound in a pair. first is lower, second is upper. More...
 
double center () const
 Returns midpoint of axis. More...
 
virtual void clip (double lower, double upper)
 Clips this axis to the given values. More...
 
void clip (std::pair< double, double > bounds)
 Convenience overload to clip this axis to the given values. bounds.first is lower, bounds.second is upper value. More...
 
virtual IAxisclone () const =0
 
virtual bool contains (double value) const
 Returns true if axis contains given point. More...
 
virtual size_t findClosestIndex (double value) const =0
 find bin index which is best match for given value More...
 
virtual double max () const =0
 Returns value of last point of axis. More...
 
virtual double min () const =0
 Returns value of first point of axis. More...
 
bool operator!= (const IAxis &right) const
 
bool operator== (const IAxis &right) const
 test for equality More...
 
virtual double operator[] (size_t index) const =0
 indexed accessor retrieves a sample More...
 
void setAxisName (std::string name)
 Sets the axis label. More...
 
virtual size_t size () const =0
 Returns the number of bins. More...
 
double span () const
 Returns distance from first to last point. More...
 

Protected Member Functions

virtual bool equals (const IAxis &other) const
 
virtual void print (std::ostream &ostr) const =0
 

Private Attributes

std::string m_name
 axis name More...
 

Friends

std::ostream & operator<< (std::ostream &ostr, const IAxis &m)
 

Constructor & Destructor Documentation

◆ IAxis() [1/2]

IAxis::IAxis ( std::string  name)
inline

Definition at line 29 of file IAxis.h.

30  : m_name(std::move(name))
31  {
32  }
std::string m_name
axis name
Definition: IAxis.h:103

◆ IAxis() [2/2]

IAxis::IAxis ( const IAxis )
delete

◆ ~IAxis()

IAxis::~IAxis ( )
virtualdefault

Member Function Documentation

◆ axisName()

std::string IAxis::axisName ( ) const
inline

◆ bin()

◆ binBoundaries()

std::vector< double > IAxis::binBoundaries ( ) const
virtual

Reimplemented in VariableBinAxis, PointwiseAxis, and FixedBinAxis.

Definition at line 30 of file IAxis.cpp.

31 {
32  throw std::runtime_error("IAxis::binBoundaries() -> Error. Not implemented.");
33 }

◆ binCenter()

virtual double IAxis::binCenter ( size_t  index) const
pure virtual

◆ binCenters()

std::vector< double > IAxis::binCenters ( ) const
virtual

Reimplemented in VariableBinAxis, PointwiseAxis, FixedBinAxis, and CustomBinAxis.

Definition at line 25 of file IAxis.cpp.

26 {
27  throw std::runtime_error("IAxis::binCenters() -> Error. Not implemented.");
28 }

Referenced by CoordSystem1D::createConvertedAxis(), and ReadWriteNumpyTXT::write1DRepresentation().

◆ bounds()

std::pair< double, double > IAxis::bounds ( ) const

Returns lower and upper bound in a pair. first is lower, second is upper.

Definition at line 50 of file IAxis.cpp.

51 {
52  return {min(), max()};
53 }
virtual double max() const =0
Returns value of last point of axis.
virtual double min() const =0
Returns value of first point of axis.

References max(), and min().

Referenced by clip().

Here is the call graph for this function:

◆ center()

double IAxis::center ( ) const

Returns midpoint of axis.

Definition at line 60 of file IAxis.cpp.

61 {
62  return (max() + min()) / 2;
63 }

References max(), and min().

Here is the call graph for this function:

◆ clip() [1/2]

void IAxis::clip ( double  lower,
double  upper 
)
virtual

Clips this axis to the given values.

Reimplemented in VariableBinAxis, PointwiseAxis, FixedBinAxis, CustomBinAxis, and ConstKBinAxis.

Definition at line 35 of file IAxis.cpp.

36 {
37  throw std::runtime_error("IAxis::clip() -> Error. Not implemented.");
38 }

Referenced by IDetector::axesClippedToRegionOfInterest(), clip(), IDetector::createDetectorMap(), and Datafield::crop().

◆ clip() [2/2]

void IAxis::clip ( std::pair< double, double >  bounds)

Convenience overload to clip this axis to the given values. bounds.first is lower, bounds.second is upper value.

Definition at line 40 of file IAxis.cpp.

41 {
42  return clip(bounds.first, bounds.second);
43 }
std::pair< double, double > bounds() const
Returns lower and upper bound in a pair. first is lower, second is upper.
Definition: IAxis.cpp:50
virtual void clip(double lower, double upper)
Clips this axis to the given values.
Definition: IAxis.cpp:35

References bounds(), and clip().

Here is the call graph for this function:

◆ clone()

◆ contains()

bool IAxis::contains ( double  value) const
virtual

Returns true if axis contains given point.

Definition at line 45 of file IAxis.cpp.

46 {
47  return value >= min() && value < max();
48 }

References max(), and min().

Referenced by RectangularDetector::indexOfSpecular(), and SphericalDetector::indexOfSpecular().

Here is the call graph for this function:

◆ equals()

bool IAxis::equals ( const IAxis other) const
protectedvirtual

Reimplemented in VariableBinAxis, PointwiseAxis, FixedBinAxis, CustomBinAxis, and ConstKBinAxis.

Definition at line 20 of file IAxis.cpp.

21 {
22  return axisName() == other.axisName();
23 }
std::string axisName() const
Returns the label of the axis.
Definition: IAxis.h:61

References axisName().

Referenced by ConstKBinAxis::equals(), CustomBinAxis::equals(), FixedBinAxis::equals(), PointwiseAxis::equals(), VariableBinAxis::equals(), and operator==().

Here is the call graph for this function:

◆ findClosestIndex()

◆ max()

virtual double IAxis::max ( ) const
pure virtual

Returns value of last point of axis.

Implemented in VariableBinAxis, PointwiseAxis, and FixedBinAxis.

Referenced by bounds(), center(), contains(), DepthProbeSimulation::setBeamParameters(), and span().

◆ min()

virtual double IAxis::min ( ) const
pure virtual

◆ operator!=()

bool IAxis::operator!= ( const IAxis right) const
inline

Definition at line 90 of file IAxis.h.

90 { return !(*this == right); }

◆ operator==()

bool IAxis::operator== ( const IAxis right) const
inline

test for equality

Definition at line 89 of file IAxis.h.

89 { return equals(right); }
virtual bool equals(const IAxis &other) const
Definition: IAxis.cpp:20

References equals().

Here is the call graph for this function:

◆ operator[]()

virtual double IAxis::operator[] ( size_t  index) const
pure virtual

indexed accessor retrieves a sample

Implemented in VariableBinAxis, PointwiseAxis, and FixedBinAxis.

◆ print()

virtual void IAxis::print ( std::ostream &  ostr) const
protectedpure virtual

◆ setAxisName()

void IAxis::setAxisName ( std::string  name)
inline

Sets the axis label.

Definition at line 39 of file IAxis.h.

39 { m_name = name; }

References m_name.

◆ size()

◆ span()

double IAxis::span ( ) const

Returns distance from first to last point.

Definition at line 55 of file IAxis.cpp.

56 {
57  return max() - min();
58 }

References max(), and min().

Referenced by RectangularDetector::height(), and RectangularDetector::width().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  ostr,
const IAxis m 
)
friend

Definition at line 92 of file IAxis.h.

93  {
94  m.print(ostr);
95  return ostr;
96  }
virtual void print(std::ostream &ostr) const =0

Member Data Documentation

◆ m_name

std::string IAxis::m_name
private

axis name

Definition at line 103 of file IAxis.h.

Referenced by axisName(), and setAxisName().


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