From 5a20c90eeb531f57f97d79c73b81ff75e84676f1 Mon Sep 17 00:00:00 2001 From: Joachim Wuttke <j.wuttke@fz-juelich.de> Date: Wed, 5 Apr 2023 17:48:17 +0200 Subject: [PATCH] move further utils --- GUI/Model/Data/IntensityDataItem.cpp | 4 +- .../Tool => Support/Util}/DesignerHelper.cpp | 6 +- .../Tool => Support/Util}/DesignerHelper.h | 8 +-- .../Util/{ColorUtil.cpp => QCP_Util.cpp} | 56 ++++++++++++++- GUI/Support/Util/{ColorUtil.h => QCP_Util.h} | 22 ++++-- .../Tool => Support/Util}/StyleUtils.cpp | 6 +- GUI/{View/Tool => Support/Util}/StyleUtils.h | 8 +-- GUI/View/Fit/RunFitControlWidget.cpp | 2 +- GUI/View/Info/OverlayLabelWidget.cpp | 4 +- GUI/View/Info/ProjectLoadProblemDialog.cpp | 2 +- .../Instrument/InstrumentLibraryEditor.cpp | 2 +- GUI/View/Main/AboutDialog.cpp | 2 +- .../MaterialEditor/MaterialEditorDialog.cpp | 2 +- GUI/View/PlotSpecular/SpecularPlot.cpp | 6 +- GUI/View/PlotUtil/ColorMap.cpp | 5 +- GUI/View/PlotUtil/PlotConstants.h | 2 +- GUI/View/PlotUtil/RangeUtils.cpp | 72 ++++--------------- GUI/View/PlotUtil/RangeUtils.h | 9 --- GUI/View/PlotUtil/StatusLabel.cpp | 2 +- GUI/View/Projection/ProjectionsPlot.cpp | 5 +- GUI/View/SampleDesigner/ScriptPanel.cpp | 2 +- GUI/View/Toplevel/PythonScriptWidget.cpp | 4 +- 22 files changed, 120 insertions(+), 111 deletions(-) rename GUI/{View/Tool => Support/Util}/DesignerHelper.cpp (87%) rename GUI/{View/Tool => Support/Util}/DesignerHelper.h (80%) rename GUI/Support/Util/{ColorUtil.cpp => QCP_Util.cpp} (89%) rename GUI/Support/Util/{ColorUtil.h => QCP_Util.h} (58%) rename GUI/{View/Tool => Support/Util}/StyleUtils.cpp (96%) rename GUI/{View/Tool => Support/Util}/StyleUtils.h (87%) diff --git a/GUI/Model/Data/IntensityDataItem.cpp b/GUI/Model/Data/IntensityDataItem.cpp index 652b11b1ed0..94e91cc0f42 100644 --- a/GUI/Model/Data/IntensityDataItem.cpp +++ b/GUI/Model/Data/IntensityDataItem.cpp @@ -20,7 +20,7 @@ #include "GUI/Model/Device/AxisItems.h" #include "GUI/Model/Device/MaskUnitsConverter.h" #include "GUI/Support/IO/ImportDataInfo.h" -#include "GUI/Support/Util/ColorUtil.h" +#include "GUI/Support/Util/QCP_Util.h" #include "GUI/Support/Util/Error.h" #include <qcustomplot.h> @@ -37,7 +37,7 @@ const QString ProjectionContainer("ProjectionContainer"); } // namespace Tag -QCPColorGradient infernoGradient = GUI::ColorUtil::colorGradientInferno(); +QCPColorGradient infernoGradient = GUI::QCP_Util::colorGradientInferno(); // gradient map for colormaps const QMap<QString, QCPColorGradient::GradientPreset> gradient_map = { diff --git a/GUI/View/Tool/DesignerHelper.cpp b/GUI/Support/Util/DesignerHelper.cpp similarity index 87% rename from GUI/View/Tool/DesignerHelper.cpp rename to GUI/Support/Util/DesignerHelper.cpp index 854a5ccf7f4..792af00dd6c 100644 --- a/GUI/View/Tool/DesignerHelper.cpp +++ b/GUI/Support/Util/DesignerHelper.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Tool/DesignerHelper.cpp +//! @file GUI/Support/Util/DesignerHelper.cpp //! @brief Implements class DesignerHelper //! //! @homepage http://www.bornagainproject.org @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#include "GUI/View/Tool/DesignerHelper.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/DesignerHelper.h" +#include "GUI/Support/Util/StyleUtils.h" int DesignerHelper::getSectionFontSize() { diff --git a/GUI/View/Tool/DesignerHelper.h b/GUI/Support/Util/DesignerHelper.h similarity index 80% rename from GUI/View/Tool/DesignerHelper.h rename to GUI/Support/Util/DesignerHelper.h index 9c18831bb6e..8fab7b2010a 100644 --- a/GUI/View/Tool/DesignerHelper.h +++ b/GUI/Support/Util/DesignerHelper.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Tool/DesignerHelper.h +//! @file GUI/Support/Util/DesignerHelper.h //! @brief Defines class DesignerHelper //! //! @homepage http://www.bornagainproject.org @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H -#define BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H +#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_DESIGNERHELPER_H +#define BORNAGAIN_GUI_SUPPORT_UTIL_DESIGNERHELPER_H //! collection of static methods with SampleDesigner geometry settings class DesignerHelper { @@ -25,4 +25,4 @@ public: static int getPythonEditorFontSize(); }; -#endif // BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H +#endif // BORNAGAIN_GUI_SUPPORT_UTIL_DESIGNERHELPER_H diff --git a/GUI/Support/Util/ColorUtil.cpp b/GUI/Support/Util/QCP_Util.cpp similarity index 89% rename from GUI/Support/Util/ColorUtil.cpp rename to GUI/Support/Util/QCP_Util.cpp index 19c078fd84c..d059635ea13 100644 --- a/GUI/Support/Util/ColorUtil.cpp +++ b/GUI/Support/Util/QCP_Util.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Support/Util/ColorUtil.cpp +//! @file GUI/Support/Util/QCP_Util.cpp //! @brief Implements RangeUtils namespace //! //! @homepage http://www.bornagainproject.org @@ -12,12 +12,62 @@ // // ************************************************************************************************ -#include "GUI/Support/Util/ColorUtil.h" +#include "GUI/Support/Util/QCP_Util.h" +#include "GUI/Support/Util/StyleUtils.h" #include <qcustomplot.h> +namespace { + +QMargins defaultMargins(const QWidget& widget) +{ + auto base_size = GUI::Util::Style::SizeOfLetterM(&widget); + int left = static_cast<int>(base_size.width() * 6.0); + int top = static_cast<int>(base_size.height() * 1.5); + int right = static_cast<int>(base_size.width() * 1.2); + int bottom = static_cast<int>(base_size.height() * 4.5); + return QMargins(left, top, right, bottom); +} + +} // namespace + +void GUI::QCP_Util::setLogz(QCPColorScale* scale, bool isLogz) +{ + if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic) + scale->setDataScaleType(QCPAxis::stLogarithmic); + + else if (!isLogz && scale->dataScaleType() != QCPAxis::stLinear) + scale->setDataScaleType(QCPAxis::stLinear); + + setLogz(scale->axis(), isLogz); +} + +void GUI::QCP_Util::setLogz(QCPAxis* axis, bool isLogz) +{ + if (isLogz) { + axis->setNumberFormat("eb"); + axis->setNumberPrecision(0); + axis->setScaleType(QCPAxis::stLogarithmic); + QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTickerLog); + axis->setTicker(ticker); + } else { + axis->setNumberFormat("f"); + axis->setNumberPrecision(1); + axis->setScaleType(QCPAxis::stLinear); + QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTicker); + axis->setTicker(ticker); + } +} + +void GUI::QCP_Util::setDefaultMargins(QCustomPlot* customPlot) +{ + auto* axisRectangle = customPlot->axisRect(); + axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom); + axisRectangle->setMargins(defaultMargins(*customPlot)); +} + // colors taken and converted to int from // github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/_cm_listed.py -QCPColorGradient GUI::ColorUtil::colorGradientInferno() +QCPColorGradient GUI::QCP_Util::colorGradientInferno() { QCPColorGradient result; result.setColorStopAt(0.0 / 255.0, {0, 0, 3}); diff --git a/GUI/Support/Util/ColorUtil.h b/GUI/Support/Util/QCP_Util.h similarity index 58% rename from GUI/Support/Util/ColorUtil.h rename to GUI/Support/Util/QCP_Util.h index 6cb4cee1885..3de1ed89b8f 100644 --- a/GUI/Support/Util/ColorUtil.h +++ b/GUI/Support/Util/QCP_Util.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Support/Util/ColorUtil.h +//! @file GUI/Support/Util/QCP_Util.h //! @brief Defines namespace ColorUtil //! //! @homepage http://www.bornagainproject.org @@ -12,19 +12,29 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_COLORUTIL_H -#define BORNAGAIN_GUI_SUPPORT_UTIL_COLORUTIL_H +#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_QCP_UTIL_H +#define BORNAGAIN_GUI_SUPPORT_UTIL_QCP_UTIL_H #include <QList> +class QCPAxis; class QCPColorGradient; +class QCPColorScale; +class QCustomPlot; //! Provides few helper functions for ColorMapPlot. -namespace GUI::ColorUtil { +namespace GUI::QCP_Util { + +void setLogz(QCPColorScale* scale, bool isLogz); + +void setLogz(QCPAxis* axis, bool isLogz); + +//! Sets default margins for axes rectangle plot. +void setDefaultMargins(QCustomPlot* customPlot); QCPColorGradient colorGradientInferno(); -} // namespace GUI::ColorUtil +} // namespace GUI::QCP_Util -#endif // BORNAGAIN_GUI_SUPPORT_UTIL_COLORUTIL_H +#endif // BORNAGAIN_GUI_SUPPORT_UTIL_QCP_UTIL_H diff --git a/GUI/View/Tool/StyleUtils.cpp b/GUI/Support/Util/StyleUtils.cpp similarity index 96% rename from GUI/View/Tool/StyleUtils.cpp rename to GUI/Support/Util/StyleUtils.cpp index 03e4b50fa14..72c9eef780c 100644 --- a/GUI/View/Tool/StyleUtils.cpp +++ b/GUI/Support/Util/StyleUtils.cpp @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Tool/StyleUtils.cpp +//! @file GUI/Support/Util/StyleUtils.cpp //! @brief Defines GUI::StyleUtils namespace //! //! @homepage http://www.bornagainproject.org @@ -12,9 +12,9 @@ // // ************************************************************************************************ -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include "Base/Util/Assert.h" -#include "GUI/View/Tool/DesignerHelper.h" +#include "GUI/Support/Util/DesignerHelper.h" #include <QApplication> #include <QBoxLayout> #include <QDialog> diff --git a/GUI/View/Tool/StyleUtils.h b/GUI/Support/Util/StyleUtils.h similarity index 87% rename from GUI/View/Tool/StyleUtils.h rename to GUI/Support/Util/StyleUtils.h index 0daeba2bed7..06f607661ce 100644 --- a/GUI/View/Tool/StyleUtils.h +++ b/GUI/Support/Util/StyleUtils.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Tool/StyleUtils.h +//! @file GUI/Support/Util/StyleUtils.h //! @brief Defines GUI::StyleUtils namespace //! //! @homepage http://www.bornagainproject.org @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_VIEW_TOOL_STYLEUTILS_H -#define BORNAGAIN_GUI_VIEW_TOOL_STYLEUTILS_H +#ifndef BORNAGAIN_GUI_SUPPORT_UTIL_STYLEUTILS_H +#define BORNAGAIN_GUI_SUPPORT_UTIL_STYLEUTILS_H #include <QFont> #include <QString> @@ -48,4 +48,4 @@ int SystemPointSize(); } // namespace GUI::Util::Style -#endif // BORNAGAIN_GUI_VIEW_TOOL_STYLEUTILS_H +#endif // BORNAGAIN_GUI_SUPPORT_UTIL_STYLEUTILS_H diff --git a/GUI/View/Fit/RunFitControlWidget.cpp b/GUI/View/Fit/RunFitControlWidget.cpp index 0774c4fe930..6227399e102 100644 --- a/GUI/View/Fit/RunFitControlWidget.cpp +++ b/GUI/View/Fit/RunFitControlWidget.cpp @@ -17,7 +17,7 @@ #include "GUI/Model/Job/FitSuiteItem.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Info/CautionSign.h" -#include "GUI/View/Tool/DesignerHelper.h" +#include "GUI/Support/Util/DesignerHelper.h" #include "GUI/View/Tool/mainwindow_constants.h" #include <QHBoxLayout> #include <QLabel> diff --git a/GUI/View/Info/OverlayLabelWidget.cpp b/GUI/View/Info/OverlayLabelWidget.cpp index dc54d421ddc..f03a6c6c935 100644 --- a/GUI/View/Info/OverlayLabelWidget.cpp +++ b/GUI/View/Info/OverlayLabelWidget.cpp @@ -13,8 +13,8 @@ // ************************************************************************************************ #include "GUI/View/Info/OverlayLabelWidget.h" -#include "GUI/View/Tool/DesignerHelper.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/DesignerHelper.h" +#include "GUI/Support/Util/StyleUtils.h" #include <QPainter> OverlayLabelWidget::OverlayLabelWidget(QWidget* parent) diff --git a/GUI/View/Info/ProjectLoadProblemDialog.cpp b/GUI/View/Info/ProjectLoadProblemDialog.cpp index 3471e9b8280..981a2fe7227 100644 --- a/GUI/View/Info/ProjectLoadProblemDialog.cpp +++ b/GUI/View/Info/ProjectLoadProblemDialog.cpp @@ -14,7 +14,7 @@ #include "GUI/View/Info/ProjectLoadProblemDialog.h" #include "GUI/Support/Util/Path.h" -#include "GUI/View/Tool/DesignerHelper.h" +#include "GUI/Support/Util/DesignerHelper.h" #include <QGridLayout> #include <QLabel> #include <QListWidget> diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.cpp b/GUI/View/Instrument/InstrumentLibraryEditor.cpp index 16b1bf532d5..65740eaf465 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.cpp +++ b/GUI/View/Instrument/InstrumentLibraryEditor.cpp @@ -23,7 +23,7 @@ #include "GUI/View/Item/ItemViewOverlayButtons.h" #include "GUI/View/Tool/GroupBoxCollapser.h" #include "GUI/View/Tool/ItemDelegateForHTML.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include "ui_InstrumentLibraryEditor.h" #include <QAction> #include <QFormLayout> diff --git a/GUI/View/Main/AboutDialog.cpp b/GUI/View/Main/AboutDialog.cpp index 398c7a0788c..ca1c3c9226b 100644 --- a/GUI/View/Main/AboutDialog.cpp +++ b/GUI/View/Main/AboutDialog.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Main/AboutDialog.h" #include "GUI/Support/Util/CustomEventFilters.h" #include "GUI/Support/Util/Path.h" -#include "GUI/View/Tool/DesignerHelper.h" +#include "GUI/Support/Util/DesignerHelper.h" #include <QDate> #include <QLabel> #include <QPushButton> diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp index dee5da1c6d0..ef38d6fcf03 100644 --- a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp +++ b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp @@ -20,7 +20,7 @@ #include "GUI/Model/Sample/SampleItem.h" #include "GUI/View/MaterialEditor/MaterialEditorModel.h" #include "GUI/View/Numeric/NumberUtil.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include "GUI/View/Tool/mainwindow_constants.h" #include "GUI/View/Widget/StyledToolbar.h" #include "ui_MaterialEditorDialog.h" diff --git a/GUI/View/PlotSpecular/SpecularPlot.cpp b/GUI/View/PlotSpecular/SpecularPlot.cpp index 4ea958bbb41..876c0f89095 100644 --- a/GUI/View/PlotSpecular/SpecularPlot.cpp +++ b/GUI/View/PlotSpecular/SpecularPlot.cpp @@ -21,7 +21,7 @@ #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/PlotUtil/PlotConstants.h" #include "GUI/View/PlotUtil/PlotEventInfo.h" -#include "GUI/View/PlotUtil/RangeUtils.h" +#include "GUI/Support/Util/QCP_Util.h" #include "GUI/View/Tool/UpdateTimer.h" namespace { @@ -72,8 +72,8 @@ void SpecularPlot::setLog() { if (!currentSpecularDataItem()) return; - GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis, currentSpecularDataItem()->isLog()); - GUI::View::RangeUtils::setLogz(m_custom_plot->yAxis2, currentSpecularDataItem()->isLog()); + GUI::QCP_Util::setLogz(m_custom_plot->yAxis, currentSpecularDataItem()->isLog()); + GUI::QCP_Util::setLogz(m_custom_plot->yAxis2, currentSpecularDataItem()->isLog()); replot(); } diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index 02cb8c7d861..c6fb6aeac6c 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -21,6 +21,7 @@ #include "GUI/View/PlotUtil/PlotEventInfo.h" #include "GUI/View/PlotUtil/RangeUtils.h" #include "GUI/View/Tool/UpdateTimer.h" +#include "GUI/Support/Util/QCP_Util.h" #include <qcustomplot.h> namespace { @@ -101,7 +102,7 @@ void ColorMap::setLogz() return; bool logz = intensityItem()->isLog(); m_colorBarLayout->setMinimumSize(logz ? colorbar_width_logz : colorbar_width, 10); - GUI::View::RangeUtils::setLogz(m_colorScale, logz); + GUI::QCP_Util::setLogz(m_colorScale, logz); replot(); } @@ -292,7 +293,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::RangeUtils::setDefaultMargins(m_customPlot); + GUI::QCP_Util::setDefaultMargins(m_customPlot); } //! Sets initial state of ColorMap to match given intensity item. diff --git a/GUI/View/PlotUtil/PlotConstants.h b/GUI/View/PlotUtil/PlotConstants.h index 7150182f072..73706c7b6c8 100644 --- a/GUI/View/PlotUtil/PlotConstants.h +++ b/GUI/View/PlotUtil/PlotConstants.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTCONSTANTS_H #define BORNAGAIN_GUI_VIEW_PLOTUTIL_PLOTCONSTANTS_H -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include <QSize> namespace GUI::Constants { diff --git a/GUI/View/PlotUtil/RangeUtils.cpp b/GUI/View/PlotUtil/RangeUtils.cpp index 2fc925eb788..d24e5a56b03 100644 --- a/GUI/View/PlotUtil/RangeUtils.cpp +++ b/GUI/View/PlotUtil/RangeUtils.cpp @@ -17,7 +17,7 @@ #include "GUI/Model/Data/SpecularDataItem.h" #include "GUI/Model/Device/AxisItems.h" #include "GUI/Support/Util/Error.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include <qcustomplot.h> namespace { @@ -30,18 +30,9 @@ QCPRange qcpRange(double xmin, double xmax, int nbins) return QCPRange(xmin + dx / 2., xmax - dx / 2.); } -QMargins defaultMargins(const QWidget& widget) -{ - auto base_size = GUI::Util::Style::SizeOfLetterM(&widget); - int left = static_cast<int>(base_size.width() * 6.0); - int top = static_cast<int>(base_size.height() * 1.5); - int right = static_cast<int>(base_size.width() * 1.2); - int bottom = static_cast<int>(base_size.height() * 4.5); - return QMargins(left, top, right, bottom); -} - } // namespace + QCPRange GUI::View::RangeUtils::itemXrange(const IntensityDataItem* item) { return qcpRange(item->xMin(), item->xMax(), item->xSize()); @@ -73,39 +64,22 @@ QCPRange GUI::View::RangeUtils::itemDataZoom(const IntensityDataItem* item) return QCPRange(item->lowerZ(), item->upperZ()); } -void GUI::View::RangeUtils::setLogz(QCPColorScale* scale, bool isLogz) -{ - if (isLogz && scale->dataScaleType() != QCPAxis::stLogarithmic) - scale->setDataScaleType(QCPAxis::stLogarithmic); - - else if (!isLogz && scale->dataScaleType() != QCPAxis::stLinear) - scale->setDataScaleType(QCPAxis::stLinear); - - setLogz(scale->axis(), isLogz); -} - -void GUI::View::RangeUtils::setLogz(QCPAxis* axis, bool isLogz) +QList<AmplitudeAxisItem*> +GUI::View::RangeUtils::valueAxesFromSpecularItems(const QList<SpecularDataItem*>& items) { - if (isLogz) { - axis->setNumberFormat("eb"); - axis->setNumberPrecision(0); - axis->setScaleType(QCPAxis::stLogarithmic); - QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTickerLog); - axis->setTicker(ticker); - } else { - axis->setNumberFormat("f"); - axis->setNumberPrecision(1); - axis->setScaleType(QCPAxis::stLinear); - QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTicker); - axis->setTicker(ticker); - } + QList<AmplitudeAxisItem*> axes; + for (auto item : items) + axes.append(item->yAxisItem()); + return axes; } -void GUI::View::RangeUtils::setDefaultMargins(QCustomPlot* customPlot) +QList<AmplitudeAxisItem*> +GUI::View::RangeUtils::valueAxesFromIntensityItems(const QList<IntensityDataItem*>& items) { - auto* axisRectangle = customPlot->axisRect(); - axisRectangle->setAutoMargins(QCP::msTop | QCP::msBottom); - axisRectangle->setMargins(defaultMargins(*customPlot)); + QList<AmplitudeAxisItem*> axes; + for (auto item : items) + axes.append(item->zAxisItem()); + return axes; } double GUI::View::RangeUtils::commonMin(const QList<AmplitudeAxisItem*>& axes) @@ -148,21 +122,3 @@ void GUI::View::RangeUtils::setCommonRangeZ(QList<IntensityDataItem*> items) item->setUpperZ(range.upper); } } - -QList<AmplitudeAxisItem*> -GUI::View::RangeUtils::valueAxesFromSpecularItems(const QList<SpecularDataItem*>& items) -{ - QList<AmplitudeAxisItem*> axes; - for (auto item : items) - axes.append(item->yAxisItem()); - return axes; -} - -QList<AmplitudeAxisItem*> -GUI::View::RangeUtils::valueAxesFromIntensityItems(const QList<IntensityDataItem*>& items) -{ - QList<AmplitudeAxisItem*> axes; - for (auto item : items) - axes.append(item->zAxisItem()); - return axes; -} diff --git a/GUI/View/PlotUtil/RangeUtils.h b/GUI/View/PlotUtil/RangeUtils.h index 095106d170c..2a0bd6bcae1 100644 --- a/GUI/View/PlotUtil/RangeUtils.h +++ b/GUI/View/PlotUtil/RangeUtils.h @@ -20,9 +20,6 @@ class AmplitudeAxisItem; class IntensityDataItem; class SpecularDataItem; -class QCustomPlot; -class QCPAxis; -class QCPColorScale; class QCPRange; //! Provides few helper functions for ColorMapPlot. @@ -68,12 +65,6 @@ QList<AmplitudeAxisItem*> valueAxesFromSpecularItems(const QList<SpecularDataIte //! Gets Z axes from a list of intensity items. QList<AmplitudeAxisItem*> valueAxesFromIntensityItems(const QList<IntensityDataItem*>& items); -void setLogz(QCPColorScale* scale, bool isLogz); - -void setLogz(QCPAxis* axis, bool isLogz); - -//! Sets default margins for axes rectangle plot. -void setDefaultMargins(QCustomPlot* customPlot); } // namespace GUI::View::RangeUtils diff --git a/GUI/View/PlotUtil/StatusLabel.cpp b/GUI/View/PlotUtil/StatusLabel.cpp index 036b5e1b300..8c16b74bc6a 100644 --- a/GUI/View/PlotUtil/StatusLabel.cpp +++ b/GUI/View/PlotUtil/StatusLabel.cpp @@ -13,7 +13,7 @@ // ************************************************************************************************ #include "GUI/View/PlotUtil/StatusLabel.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/StyleUtils.h" #include <QColor> #include <QFont> #include <QPainter> diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp index 428b95fcf4c..db34dc85f4e 100644 --- a/GUI/View/Projection/ProjectionsPlot.cpp +++ b/GUI/View/Projection/ProjectionsPlot.cpp @@ -19,6 +19,7 @@ #include "GUI/Model/Data/ProjectionItems.h" #include "GUI/Model/Device/AxisItems.h" #include "GUI/Model/Device/MaskItems.h" +#include "GUI/Support/Util/QCP_Util.h" #include "GUI/View/PlotUtil/PlotConstants.h" #include "GUI/View/PlotUtil/RangeUtils.h" #include <boost/polymorphic_cast.hpp> @@ -44,7 +45,7 @@ ProjectionsPlot::ProjectionsPlot(GUI::ID::ProjectionType projectionType, QWidget m_customPlot->yAxis->setTickLabelFont( QFont(QFont().family(), GUI::Constants::plot_tick_label_size())); - GUI::View::RangeUtils::setDefaultMargins(m_customPlot); + GUI::QCP_Util::setDefaultMargins(m_customPlot); } void ProjectionsPlot::setIntensityItem(IntensityDataItem* intensityDataItem) @@ -287,7 +288,7 @@ void ProjectionsPlot::setInterpolate(bool isInterpolated) void ProjectionsPlot::setLogz(bool isLogz) { - GUI::View::RangeUtils::setLogz(m_customPlot->yAxis, isLogz); + GUI::QCP_Util::setLogz(m_customPlot->yAxis, isLogz); } void ProjectionsPlot::replot() diff --git a/GUI/View/SampleDesigner/ScriptPanel.cpp b/GUI/View/SampleDesigner/ScriptPanel.cpp index b371745cdb0..2eb35079505 100644 --- a/GUI/View/SampleDesigner/ScriptPanel.cpp +++ b/GUI/View/SampleDesigner/ScriptPanel.cpp @@ -17,7 +17,7 @@ #include "GUI/Model/ToCore/SampleToCore.h" #include "GUI/View/Info/CautionSign.h" #include "GUI/View/Info/PythonSyntaxHighlighter.h" -#include "GUI/View/Tool/DesignerHelper.h" +#include "GUI/Support/Util/DesignerHelper.h" #include "GUI/View/Tool/UpdateTimer.h" #include "Sample/Multilayer/MultiLayer.h" #include "Sim/Export/ExportToPython.h" diff --git a/GUI/View/Toplevel/PythonScriptWidget.cpp b/GUI/View/Toplevel/PythonScriptWidget.cpp index 6adb92ae52c..2e757f8a8d0 100644 --- a/GUI/View/Toplevel/PythonScriptWidget.cpp +++ b/GUI/View/Toplevel/PythonScriptWidget.cpp @@ -17,8 +17,8 @@ #include "GUI/Model/ToCore/SimulationToCore.h" #include "GUI/View/Info/CautionSign.h" #include "GUI/View/Info/PythonSyntaxHighlighter.h" -#include "GUI/View/Tool/DesignerHelper.h" -#include "GUI/View/Tool/StyleUtils.h" +#include "GUI/Support/Util/DesignerHelper.h" +#include "GUI/Support/Util/StyleUtils.h" #include "GUI/View/Widget/StyledToolbar.h" #include "Sim/Export/ExportToPython.h" #include "Sim/Simulation/ScatteringSimulation.h" -- GitLab