##// END OF EJS Templates
Creates method that computes thresholds of a SqpColorScale
Alexandre Leroux -
r1018:63f62cbba482
parent child
Show More
@@ -3,6 +3,10
3
3
4 #include <Visualization/qcustomplot.h>
4 #include <Visualization/qcustomplot.h>
5
5
6 #include <QLoggingCategory>
7
8 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpColorScale)
9
6 /**
10 /**
7 * @brief The SqpColorScale struct represents the color scale for some graphs (such as
11 * @brief The SqpColorScale struct represents the color scale for some graphs (such as
8 * spectrograms).
12 * spectrograms).
@@ -11,6 +15,8
11 * other useful properties for viewing in SciQlop
15 * other useful properties for viewing in SciQlop
12 */
16 */
13 struct SqpColorScale {
17 struct SqpColorScale {
18 static std::pair<double, double> computeThresholds(const SqpColorScale &scale);
19
14 explicit SqpColorScale(QCustomPlot &plot);
20 explicit SqpColorScale(QCustomPlot &plot);
15
21
16 /// QCustomPlot object representing the color scale.
22 /// QCustomPlot object representing the color scale.
@@ -1,5 +1,11
1 #include "Visualization/SqpColorScale.h"
1 #include "Visualization/SqpColorScale.h"
2
2
3 #include <Data/DataSeriesUtils.h>
4
5 #include <Visualization/QCPColorMapIterator.h>
6
7 Q_LOGGING_CATEGORY(LOG_SqpColorScale, "SqpColorScale")
8
3 namespace {
9 namespace {
4
10
5 const auto DEFAULT_GRADIENT_PRESET = QCPColorGradient::gpJet;
11 const auto DEFAULT_GRADIENT_PRESET = QCPColorGradient::gpJet;
@@ -7,6 +13,24 const auto DEFAULT_RANGE = QCPRange{1.0e3, 1.7e7};
7
13
8 } // namespace
14 } // namespace
9
15
16 std::pair<double, double> SqpColorScale::computeThresholds(const SqpColorScale &scale)
17 {
18 auto qcpScale = scale.m_Scale;
19
20 auto colorMaps = qcpScale->colorMaps();
21 if (colorMaps.size() != 1) {
22 return {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()};
23 }
24
25 // Computes thresholds
26 auto isLogarithmicScale = qcpScale->dataScaleType() == QCPAxis::stLogarithmic;
27 auto colorMapData = colorMaps.first()->data();
28 QCPColorMapIterator begin{colorMapData, true};
29 QCPColorMapIterator end{colorMapData, false};
30
31 return DataSeriesUtils::thresholds(begin, end, isLogarithmicScale);
32 }
33
10 SqpColorScale::SqpColorScale(QCustomPlot &plot)
34 SqpColorScale::SqpColorScale(QCustomPlot &plot)
11 : m_Scale{new QCPColorScale{&plot}},
35 : m_Scale{new QCPColorScale{&plot}},
12 m_AutomaticThreshold{false},
36 m_AutomaticThreshold{false},
General Comments 0
You need to be logged in to leave comments. Login now