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

Description

Provides few helper functions for ColorMapPlot.

Functions

QCPColorGradient getGradient (const QString &gradientName)
 
QCPRange itemDataRange (const IntensityDataItem *item)
 Returns z-axis data range. More...
 
QCPRange itemDataZoom (const IntensityDataItem *item)
 Returns z-axis visible range (zoom). More...
 
QCPColorGradient itemGradient (const IntensityDataItem *item)
 
QCPRange itemXrange (const IntensityDataItem *item)
 Returns x-axis range. More...
 
QCPRange itemYrange (const IntensityDataItem *item)
 Returns y-axis range. More...
 
QCPRange itemZoomX (const IntensityDataItem *item)
 Returns x-axis vizible range (zoom). More...
 
QCPRange itemZoomY (const IntensityDataItem *item)
 Returns y-axis vizible range (zoom). More...
 
void setDefaultMargins (QCustomPlot *customPlot)
 Sets default margins for axes rectangle plot. More...
 
void setLogz (QCPAxis *axis, bool isLogz)
 
void setLogz (QCPColorScale *scale, bool isLogz)
 

Function Documentation

◆ getGradient()

QCPColorGradient GUI::View::RangeUtils::getGradient ( const QString &  gradientName)

Definition at line 64 of file RangeUtils.cpp.

65 {
66  static gradient_map_t gradient_map = createGradientMap();
67 
68  auto it = gradient_map.find(gradientName);
69  if (it == gradient_map.end())
70  throw Error("ColorMapHelper::getGradient() -> Error. No such gradient" + gradientName);
71  return QCPColorGradient(it.value());
72 }
QMap< QString, QCPColorGradient::GradientPreset > gradient_map_t
Definition: RangeUtils.cpp:20
Definition: Error.h:21

Referenced by itemGradient().

◆ itemDataRange()

QCPRange GUI::View::RangeUtils::itemDataRange ( const IntensityDataItem item)

Returns z-axis data range.

Definition at line 99 of file RangeUtils.cpp.

100 {
101  QPair<double, double> range = item->dataRange();
102  return QCPRange(range.first, range.second);
103 }
QPair< double, double > dataRange() const
Init zmin, zmax to match the intensity values range.

References IntensityDataItem::dataRange().

Here is the call graph for this function:

◆ itemDataZoom()

QCPRange GUI::View::RangeUtils::itemDataZoom ( const IntensityDataItem item)

Returns z-axis visible range (zoom).

Definition at line 105 of file RangeUtils.cpp.

106 {
107  return QCPRange(item->getLowerZ(), item->getUpperZ());
108 }
double getLowerZ() const
Returns lower and upper zoom ranges of z-axis.
double getUpperZ() const

References IntensityDataItem::getLowerZ(), and IntensityDataItem::getUpperZ().

Referenced by ColorMap::setDataRangeFromItem(), and ProjectionsPlot::updateAxesRange().

Here is the call graph for this function:

◆ itemGradient()

QCPColorGradient GUI::View::RangeUtils::itemGradient ( const IntensityDataItem item)

Definition at line 74 of file RangeUtils.cpp.

75 {
76  return getGradient(item->getGradientValue());
77 }
QString getGradientValue() const
QCPColorGradient getGradient(const QString &gradientName)
Definition: RangeUtils.cpp:64

References getGradient(), and IntensityDataItem::getGradientValue().

Referenced by ColorMap::onPropertyChanged(), and ColorMap::setColorScaleAppearanceFromItem().

Here is the call graph for this function:

◆ itemXrange()

QCPRange GUI::View::RangeUtils::itemXrange ( const IntensityDataItem item)

Returns x-axis range.

Definition at line 79 of file RangeUtils.cpp.

80 {
81  return qcpRange(item->xMin(), item->xMax(), item->xSize());
82 }
double xMin() const
Returns min and max range of x-axis as given by IntensityData.

References IntensityDataItem::xMax(), IntensityDataItem::xMin(), and IntensityDataItem::xSize().

Referenced by ColorMap::setAxesRangeFromItem().

Here is the call graph for this function:

◆ itemYrange()

QCPRange GUI::View::RangeUtils::itemYrange ( const IntensityDataItem item)

Returns y-axis range.

Definition at line 89 of file RangeUtils.cpp.

90 {
91  return qcpRange(item->yMin(), item->yMax(), item->ySize());
92 }
double yMin() const
Returns min and max range of y-axis as given by IntensityData.

References IntensityDataItem::yMax(), IntensityDataItem::yMin(), and IntensityDataItem::ySize().

Referenced by ColorMap::setAxesRangeFromItem().

Here is the call graph for this function:

◆ itemZoomX()

QCPRange GUI::View::RangeUtils::itemZoomX ( const IntensityDataItem item)

Returns x-axis vizible range (zoom).

Definition at line 84 of file RangeUtils.cpp.

85 {
86  return QCPRange(item->getLowerX(), item->getUpperX());
87 }
double getUpperX() const
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.

References IntensityDataItem::getLowerX(), and IntensityDataItem::getUpperX().

Referenced by ColorMap::onAxisPropertyChanged(), and ProjectionsPlot::updateAxesRange().

Here is the call graph for this function:

◆ itemZoomY()

QCPRange GUI::View::RangeUtils::itemZoomY ( const IntensityDataItem item)

Returns y-axis vizible range (zoom).

Definition at line 94 of file RangeUtils.cpp.

95 {
96  return QCPRange(item->getLowerY(), item->getUpperY());
97 }
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
double getUpperY() const

References IntensityDataItem::getLowerY(), and IntensityDataItem::getUpperY().

Referenced by ColorMap::onAxisPropertyChanged(), and ProjectionsPlot::updateAxesRange().

Here is the call graph for this function:

◆ setDefaultMargins()

void GUI::View::RangeUtils::setDefaultMargins ( QCustomPlot *  customPlot)

Sets default margins for axes rectangle plot.

Definition at line 138 of file RangeUtils.cpp.

139 {
140  auto* axisRectangle = customPlot->axisRect();
141  axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom);
142  axisRectangle->setMargins(defaultMargins(*customPlot));
143 }

Referenced by ProjectionsPlot::ProjectionsPlot(), and ColorMap::setFixedColorMapMargins().

◆ setLogz() [1/2]

void GUI::View::RangeUtils::setLogz ( QCPAxis *  axis,
bool  isLogz 
)

Definition at line 121 of file RangeUtils.cpp.

122 {
123  if (isLogz) {
124  axis->setNumberFormat("eb");
125  axis->setNumberPrecision(0);
126  axis->setScaleType(QCPAxis::stLogarithmic);
127  QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTickerLog);
128  axis->setTicker(ticker);
129  } else {
130  axis->setNumberFormat("f");
131  axis->setNumberPrecision(0);
132  axis->setScaleType(QCPAxis::stLinear);
133  QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTicker);
134  axis->setTicker(ticker);
135  }
136 }

◆ setLogz() [2/2]

void GUI::View::RangeUtils::setLogz ( QCPColorScale *  scale,
bool  isLogz 
)

Definition at line 110 of file RangeUtils.cpp.

111 {
112  if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic)
113  scale->setDataScaleType(QCPAxis::stLogarithmic);
114 
115  else if (!isLogz && scale->dataScaleType() != QCPAxis::stLinear)
116  scale->setDataScaleType(QCPAxis::stLinear);
117 
118  setLogz(scale->axis(), isLogz);
119 }
void setLogz(QCPColorScale *scale, bool isLogz)
Definition: RangeUtils.cpp:110

Referenced by Plot1D::setLog(), SpecularPlot::setLog(), ProjectionsPlot::setLogz(), and ColorMap::setLogz().