From 549337039c85618ffbece2099d6feb88db71109e Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Sun, 19 Dec 2021 12:02:41 +0100
Subject: [PATCH] rename ColorMapUtils -> RangeUtils (also used by monochrome
 plots)

---
 GUI/View/PlotComparison/Plot1D.cpp            |  6 ++--
 GUI/View/PlotSpecular/SpecularPlot.cpp        |  6 ++--
 GUI/View/PlotUtil/ColorMap.cpp                | 20 ++++++-------
 .../{ColorMapUtils.cpp => RangeUtils.cpp}     | 28 +++++++++----------
 .../{ColorMapUtils.h => RangeUtils.h}         | 14 +++++-----
 GUI/View/Projection/ProjectionsPlot.cpp       | 12 ++++----
 6 files changed, 43 insertions(+), 43 deletions(-)
 rename GUI/View/PlotUtil/{ColorMapUtils.cpp => RangeUtils.cpp} (79%)
 rename GUI/View/PlotUtil/{ColorMapUtils.h => RangeUtils.h} (82%)

diff --git a/GUI/View/PlotComparison/Plot1D.cpp b/GUI/View/PlotComparison/Plot1D.cpp
index 5ee91dda000..e29130698a7 100644
--- a/GUI/View/PlotComparison/Plot1D.cpp
+++ b/GUI/View/PlotComparison/Plot1D.cpp
@@ -18,7 +18,7 @@
 #include "GUI/Model/Data/DataItem.h"
 #include "GUI/Model/Data/DataProperties.h"
 #include "GUI/Model/Data/DataPropertyContainer.h"
-#include "GUI/View/PlotUtil/ColorMapUtils.h"
+#include "GUI/View/PlotUtil/RangeUtils.h"
 #include "GUI/View/PlotUtil/PlotConstants.h"
 #include "GUI/View/PlotUtil/PlotEventInfo.h"
 #include "GUI/View/Tool/UpdateTimer.h"
@@ -68,8 +68,8 @@ PlotEventInfo Plot1D::eventInfo(double xpos, double ypos) const
 
 void Plot1D::setLog(bool log)
 {
-    GUI::View::ColorMapUtils::setLogz(m_custom_plot->yAxis, log);
-    GUI::View::ColorMapUtils::setLogz(m_custom_plot->yAxis2, log);
+    GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis, log);
+    GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis2, log);
 }
 
 void Plot1D::resetView()
diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp
index d85a20b59d4..cf3a3188c1a 100644
--- a/GUI/View/PlotSpecular/SpecularPlot.cpp
+++ b/GUI/View/PlotSpecular/SpecularPlot.cpp
@@ -15,7 +15,7 @@
 #include "GUI/View/PlotSpecular/SpecularPlot.h"
 #include "GUI/Model/Data/AxesItems.h"
 #include "GUI/Model/Data/SpecularDataItem.h"
-#include "GUI/View/PlotUtil/ColorMapUtils.h"
+#include "GUI/View/PlotUtil/RangeUtils.h"
 #include "GUI/View/PlotUtil/PlotConstants.h"
 #include "GUI/View/PlotUtil/PlotEventInfo.h"
 #include "GUI/View/Tool/UpdateTimer.h"
@@ -62,8 +62,8 @@ PlotEventInfo SpecularPlot::eventInfo(double xpos, double ypos) const
 
 void SpecularPlot::setLog(bool log)
 {
-    GUI::View::ColorMapUtils::setLogz(m_custom_plot->yAxis, log);
-    GUI::View::ColorMapUtils::setLogz(m_custom_plot->yAxis2, log);
+    GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis, log);
+    GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis2, log);
 }
 
 void SpecularPlot::resetView()
diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp
index 966fe3134c3..42bc0f5cdd1 100644
--- a/GUI/View/PlotUtil/ColorMap.cpp
+++ b/GUI/View/PlotUtil/ColorMap.cpp
@@ -15,7 +15,7 @@
 #include "GUI/View/PlotUtil/ColorMap.h"
 #include "GUI/Model/Data/AxesItems.h"
 #include "GUI/Model/Data/IntensityDataItem.h"
-#include "GUI/View/PlotUtil/ColorMapUtils.h"
+#include "GUI/View/PlotUtil/RangeUtils.h"
 #include "GUI/View/PlotUtil/PlotConstants.h"
 #include "GUI/View/PlotUtil/PlotEventInfo.h"
 #include "GUI/View/Tool/UpdateTimer.h"
@@ -88,7 +88,7 @@ PlotEventInfo ColorMap::eventInfo(double xpos, double ypos) const
 void ColorMap::setLogz(bool logz)
 {
     m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10);
-    GUI::View::ColorMapUtils::setLogz(m_colorScale, logz);
+    GUI::View::RangeUtils::setLogz(m_colorScale, logz);
 }
 
 //! reset all axes min,max to initial value
@@ -111,7 +111,7 @@ void ColorMap::onPropertyChanged(const QString& property_name)
         return;
 
     if (IntensityDataItem::isGradientPropertyName(property_name)) {
-        m_colorMap->setGradient(GUI::View::ColorMapUtils::itemGradient(intensityItem()));
+        m_colorMap->setGradient(GUI::View::RangeUtils::itemGradient(intensityItem()));
         replot();
     } else if (IntensityDataItem::isInterpolatedPropertyName(property_name)) {
         m_colorMap->setInterpolate(intensityItem()->isInterpolated());
@@ -136,14 +136,14 @@ void ColorMap::onAxisPropertyChanged(const QString& axisName, const QString& pro
     if (IntensityDataItem::isXaxisPropertyName(axisName)) {
         if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
             setAxesRangeConnected(false);
-            m_customPlot->xAxis->setRange(GUI::View::ColorMapUtils::itemZoomX(intensityItem()));
+            m_customPlot->xAxis->setRange(GUI::View::RangeUtils::itemZoomX(intensityItem()));
             setAxesRangeConnected(true);
             replot();
         }
     } else if (IntensityDataItem::isYaxisPropertyName(axisName)) {
         if (BasicAxisItem::isBoundsPropertiesName(propertyName)) {
             setAxesRangeConnected(false);
-            m_customPlot->yAxis->setRange(GUI::View::ColorMapUtils::itemZoomY(intensityItem()));
+            m_customPlot->yAxis->setRange(GUI::View::RangeUtils::itemZoomY(intensityItem()));
             setAxesRangeConnected(true);
             replot();
         }
@@ -307,7 +307,7 @@ void ColorMap::setUpdateTimerConnected(bool isConnected)
 //! to make fixed margins for whole colormap (change in axes labels wont affect axes rectangle)
 void ColorMap::setFixedColorMapMargins()
 {
-    GUI::View::ColorMapUtils::setDefaultMargins(m_customPlot);
+    GUI::View::RangeUtils::setDefaultMargins(m_customPlot);
 }
 
 //! Sets initial state of ColorMap to match given intensity item.
@@ -337,8 +337,8 @@ void ColorMap::setAxesRangeFromItem(IntensityDataItem* item)
     m_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
     m_customPlot->axisRect()->setupFullAxesBox(true);
     m_colorMap->data()->setSize(item->getNbinsX(), item->getNbinsY());
-    m_colorMap->data()->setRange(GUI::View::ColorMapUtils::itemXrange(item),
-                                 GUI::View::ColorMapUtils::itemYrange(item));
+    m_colorMap->data()->setRange(GUI::View::RangeUtils::itemXrange(item),
+                                 GUI::View::RangeUtils::itemYrange(item));
 }
 
 //! Sets zoom range of X,Y axes as in intensity item.
@@ -392,7 +392,7 @@ void ColorMap::setDataFromItem(IntensityDataItem* item)
 void ColorMap::setColorScaleAppearanceFromItem(IntensityDataItem* item)
 {
     setColorScaleVisible(item->zAxisItem()->visibilityValue());
-    m_colorMap->setGradient(GUI::View::ColorMapUtils::itemGradient(intensityItem()));
+    m_colorMap->setGradient(GUI::View::RangeUtils::itemGradient(intensityItem()));
     m_colorMap->setInterpolate(intensityItem()->isInterpolated());
     // make sure the axis rect and color scale synchronize their bottom and top margins (so they
     // line up):
@@ -404,7 +404,7 @@ void ColorMap::setColorScaleAppearanceFromItem(IntensityDataItem* item)
 void ColorMap::setDataRangeFromItem(IntensityDataItem* item)
 {
     setDataRangeConnected(false);
-    m_colorMap->setDataRange(GUI::View::ColorMapUtils::itemDataZoom(item));
+    m_colorMap->setDataRange(GUI::View::RangeUtils::itemDataZoom(item));
     setLogz(item->isLogz());
     setDataRangeConnected(true);
 }
diff --git a/GUI/View/PlotUtil/ColorMapUtils.cpp b/GUI/View/PlotUtil/RangeUtils.cpp
similarity index 79%
rename from GUI/View/PlotUtil/ColorMapUtils.cpp
rename to GUI/View/PlotUtil/RangeUtils.cpp
index 64ad680ccb2..1300e4d216d 100644
--- a/GUI/View/PlotUtil/ColorMapUtils.cpp
+++ b/GUI/View/PlotUtil/RangeUtils.cpp
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/PlotUtil/ColorMapUtils.cpp
-//! @brief     Implements ColorMapUtils namespace
+//! @file      GUI/View/PlotUtil/RangeUtils.cpp
+//! @brief     Implements RangeUtils namespace
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "GUI/View/PlotUtil/ColorMapUtils.h"
+#include "GUI/View/PlotUtil/RangeUtils.h"
 #include "GUI/Model/Data/IntensityDataItem.h"
 #include "GUI/Util/Error.h"
 #include "GUI/View/Tool/StyleUtils.h"
@@ -61,7 +61,7 @@ QMargins defaultMargins(const QWidget& widget)
 
 } // namespace
 
-QCPColorGradient GUI::View::ColorMapUtils::getGradient(const QString& gradientName)
+QCPColorGradient GUI::View::RangeUtils::getGradient(const QString& gradientName)
 {
     static gradient_map_t gradient_map = createGradientMap();
 
@@ -71,43 +71,43 @@ QCPColorGradient GUI::View::ColorMapUtils::getGradient(const QString& gradientNa
     return QCPColorGradient(it.value());
 }
 
-QCPColorGradient GUI::View::ColorMapUtils::itemGradient(const IntensityDataItem* item)
+QCPColorGradient GUI::View::RangeUtils::itemGradient(const IntensityDataItem* item)
 {
     return getGradient(item->getGradientValue());
 }
 
-QCPRange GUI::View::ColorMapUtils::itemXrange(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemXrange(const IntensityDataItem* item)
 {
     return qcpRange(item->xMin(), item->xMax(), item->getNbinsX());
 }
 
-QCPRange GUI::View::ColorMapUtils::itemZoomX(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemZoomX(const IntensityDataItem* item)
 {
     return QCPRange(item->getLowerX(), item->getUpperX());
 }
 
-QCPRange GUI::View::ColorMapUtils::itemYrange(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemYrange(const IntensityDataItem* item)
 {
     return qcpRange(item->yMin(), item->yMax(), item->getNbinsY());
 }
 
-QCPRange GUI::View::ColorMapUtils::itemZoomY(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemZoomY(const IntensityDataItem* item)
 {
     return QCPRange(item->getLowerY(), item->getUpperY());
 }
 
-QCPRange GUI::View::ColorMapUtils::itemDataRange(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemDataRange(const IntensityDataItem* item)
 {
     QPair<double, double> range = item->dataRange();
     return QCPRange(range.first, range.second);
 }
 
-QCPRange GUI::View::ColorMapUtils::itemDataZoom(const IntensityDataItem* item)
+QCPRange GUI::View::RangeUtils::itemDataZoom(const IntensityDataItem* item)
 {
     return QCPRange(item->getLowerZ(), item->getUpperZ());
 }
 
-void GUI::View::ColorMapUtils::setLogz(QCPColorScale* scale, bool isLogz)
+void GUI::View::RangeUtils::setLogz(QCPColorScale* scale, bool isLogz)
 {
     if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic)
         scale->setDataScaleType(QCPAxis::stLogarithmic);
@@ -118,7 +118,7 @@ void GUI::View::ColorMapUtils::setLogz(QCPColorScale* scale, bool isLogz)
     setLogz(scale->axis(), isLogz);
 }
 
-void GUI::View::ColorMapUtils::setLogz(QCPAxis* axis, bool isLogz)
+void GUI::View::RangeUtils::setLogz(QCPAxis* axis, bool isLogz)
 {
     if (isLogz) {
         axis->setNumberFormat("eb");
@@ -135,7 +135,7 @@ void GUI::View::ColorMapUtils::setLogz(QCPAxis* axis, bool isLogz)
     }
 }
 
-void GUI::View::ColorMapUtils::setDefaultMargins(QCustomPlot* customPlot)
+void GUI::View::RangeUtils::setDefaultMargins(QCustomPlot* customPlot)
 {
     auto* axisRectangle = customPlot->axisRect();
     axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom);
diff --git a/GUI/View/PlotUtil/ColorMapUtils.h b/GUI/View/PlotUtil/RangeUtils.h
similarity index 82%
rename from GUI/View/PlotUtil/ColorMapUtils.h
rename to GUI/View/PlotUtil/RangeUtils.h
index f29d25701e2..9f76d45143f 100644
--- a/GUI/View/PlotUtil/ColorMapUtils.h
+++ b/GUI/View/PlotUtil/RangeUtils.h
@@ -2,8 +2,8 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/PlotUtil/ColorMapUtils.h
-//! @brief     Defines ColorMapUtils namespace
+//! @file      GUI/View/PlotUtil/RangeUtils.h
+//! @brief     Defines RangeUtils namespace
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -12,8 +12,8 @@
 //
 //  ************************************************************************************************
 
-#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_COLORMAPUTILS_H
-#define BORNAGAIN_GUI_VIEW_PLOTUTIL_COLORMAPUTILS_H
+#ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_RANGEUTILS_H
+#define BORNAGAIN_GUI_VIEW_PLOTUTIL_RANGEUTILS_H
 
 #include <QMap>
 #include <QMargins>
@@ -25,7 +25,7 @@ class ColorMap;
 
 //! Provides few helper functions for ColorMapPlot.
 
-namespace GUI::View::ColorMapUtils {
+namespace GUI::View::RangeUtils {
 
 QCPColorGradient getGradient(const QString& gradientName);
 QCPColorGradient itemGradient(const IntensityDataItem* item);
@@ -54,6 +54,6 @@ void setLogz(QCPAxis* axis, bool isLogz);
 //! Sets default margins for axes rectangle plot.
 void setDefaultMargins(QCustomPlot* customPlot);
 
-} // namespace GUI::View::ColorMapUtils
+} // namespace GUI::View::RangeUtils
 
-#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_COLORMAPUTILS_H
+#endif // BORNAGAIN_GUI_VIEW_PLOTUTIL_RANGEUTILS_H
diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp
index 1ee81498bed..c4216b7ccde 100644
--- a/GUI/View/Projection/ProjectionsPlot.cpp
+++ b/GUI/View/Projection/ProjectionsPlot.cpp
@@ -19,7 +19,7 @@
 #include "GUI/Model/Data/IntensityDataItem.h"
 #include "GUI/Model/Data/MaskItems.h"
 #include "GUI/Model/Data/ProjectionItems.h"
-#include "GUI/View/PlotUtil/ColorMapUtils.h"
+#include "GUI/View/PlotUtil/RangeUtils.h"
 #include "GUI/View/PlotUtil/PlotConstants.h"
 #include <qcustomplot.h>
 
@@ -45,7 +45,7 @@ ProjectionsPlot::ProjectionsPlot(QString projectionType, QWidget* parent)
     m_customPlot->yAxis->setTickLabelFont(
         QFont(QFont().family(), GUI::Constants::plot_tick_label_size()));
 
-    GUI::View::ColorMapUtils::setDefaultMargins(m_customPlot);
+    GUI::View::RangeUtils::setDefaultMargins(m_customPlot);
 }
 
 ProjectionsPlot::~ProjectionsPlot()
@@ -200,11 +200,11 @@ void ProjectionsPlot::updateProjections()
 void ProjectionsPlot::updateAxesRange()
 {
     if (isHorizontalType())
-        m_customPlot->xAxis->setRange(GUI::View::ColorMapUtils::itemZoomX(intensityItem()));
+        m_customPlot->xAxis->setRange(GUI::View::RangeUtils::itemZoomX(intensityItem()));
     else
-        m_customPlot->xAxis->setRange(GUI::View::ColorMapUtils::itemZoomY(intensityItem()));
+        m_customPlot->xAxis->setRange(GUI::View::RangeUtils::itemZoomY(intensityItem()));
 
-    m_customPlot->yAxis->setRange(GUI::View::ColorMapUtils::itemDataZoom(intensityItem()));
+    m_customPlot->yAxis->setRange(GUI::View::RangeUtils::itemDataZoom(intensityItem()));
 }
 
 void ProjectionsPlot::updateAxesTitle()
@@ -301,7 +301,7 @@ void ProjectionsPlot::setInterpolate(bool isInterpolated)
 
 void ProjectionsPlot::setLogz(bool isLogz)
 {
-    GUI::View::ColorMapUtils::setLogz(m_customPlot->yAxis, isLogz);
+    GUI::View::RangeUtils::setLogz(m_customPlot->yAxis, isLogz);
 }
 
 void ProjectionsPlot::replot()
-- 
GitLab