BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ColorMapUtils Namespace Reference

Provides few helper functions for ColorMapPlot. More...

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)
 

Detailed Description

Provides few helper functions for ColorMapPlot.

Function Documentation

◆ getGradient()

QCPColorGradient ColorMapUtils::getGradient ( const QString &  gradientName)

Definition at line 64 of file ColorMapUtils.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 GUIHelpers::Error("ColorMapHelper::getGradient() -> Error. No such gradient"
71  + gradientName);
72  }
73  return QCPColorGradient(it.value());
74 }
QMap< QString, QCPColorGradient::GradientPreset > gradient_map_t

Referenced by itemGradient(), IntensityDataCanvas::onPropertyChanged(), and ModelView::ColorMapPlotController::ColorMapPlotControllerImpl::update_gradient().

◆ itemDataRange()

QCPRange ColorMapUtils::itemDataRange ( const IntensityDataItem item)

Returns z-axis data range.

Definition at line 101 of file ColorMapUtils.cpp.

102 {
103  QPair<double, double> range = item->dataRange();
104  return QCPRange(range.first, range.second);
105 }
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 ColorMapUtils::itemDataZoom ( const IntensityDataItem item)

Returns z-axis visible range (zoom).

Definition at line 107 of file ColorMapUtils.cpp.

108 {
109  return QCPRange(item->getLowerZ(), item->getUpperZ());
110 }
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 ColorMapUtils::itemGradient ( const IntensityDataItem item)

Definition at line 76 of file ColorMapUtils.cpp.

77 {
78  return getGradient(item->getGradient());
79 }
QString getGradient() const
QCPColorGradient getGradient(const QString &gradientName)

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

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

Here is the call graph for this function:

◆ itemXrange()

QCPRange ColorMapUtils::itemXrange ( const IntensityDataItem item)

Returns x-axis range.

Definition at line 81 of file ColorMapUtils.cpp.

82 {
83  return qcpRange(item->getXmin(), item->getXmax(), item->getNbinsX());
84 }
double getXmin() const
returns min and max range of x-axis as given by IntensityData
double getXmax() const

References IntensityDataItem::getNbinsX(), IntensityDataItem::getXmax(), and IntensityDataItem::getXmin().

Referenced by ColorMap::setAxesRangeFromItem().

Here is the call graph for this function:

◆ itemYrange()

QCPRange ColorMapUtils::itemYrange ( const IntensityDataItem item)

Returns y-axis range.

Definition at line 91 of file ColorMapUtils.cpp.

92 {
93  return qcpRange(item->getYmin(), item->getYmax(), item->getNbinsY());
94 }
double getYmax() const
double getYmin() const
returns min and max range of y-axis as given by IntensityData

References IntensityDataItem::getNbinsY(), IntensityDataItem::getYmax(), and IntensityDataItem::getYmin().

Referenced by ColorMap::setAxesRangeFromItem().

Here is the call graph for this function:

◆ itemZoomX()

QCPRange ColorMapUtils::itemZoomX ( const IntensityDataItem item)

Returns x-axis vizible range (zoom).

Definition at line 86 of file ColorMapUtils.cpp.

87 {
88  return QCPRange(item->getLowerX(), item->getUpperX());
89 }
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 ColorMapUtils::itemZoomY ( const IntensityDataItem item)

Returns y-axis vizible range (zoom).

Definition at line 96 of file ColorMapUtils.cpp.

97 {
98  return QCPRange(item->getLowerY(), item->getUpperY());
99 }
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 ColorMapUtils::setDefaultMargins ( QCustomPlot *  customPlot)

Sets default margins for axes rectangle plot.

Definition at line 140 of file ColorMapUtils.cpp.

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

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

◆ setLogz() [1/2]

void ColorMapUtils::setLogz ( QCPAxis *  axis,
bool  isLogz 
)

Definition at line 123 of file ColorMapUtils.cpp.

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

◆ setLogz() [2/2]

void ColorMapUtils::setLogz ( QCPColorScale *  scale,
bool  isLogz 
)

Definition at line 112 of file ColorMapUtils.cpp.

113 {
114  if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic)
115  scale->setDataScaleType(QCPAxis::stLogarithmic);
116 
117  else if (!isLogz && scale->dataScaleType() != QCPAxis::stLinear)
118  scale->setDataScaleType(QCPAxis::stLinear);
119 
120  setLogz(scale->axis(), isLogz);
121 }
void setLogz(QCPColorScale *scale, bool isLogz)

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