@@ -19,6 +19,8 struct SqpColorScale { | |||
|
19 | 19 | |
|
20 | 20 | explicit SqpColorScale(QCustomPlot &plot); |
|
21 | 21 | |
|
22 | void updateDataRange() noexcept; | |
|
23 | ||
|
22 | 24 | /// QCustomPlot object representing the color scale. |
|
23 | 25 | /// @remarks The SqpColorScale instance has not the property on this pointer. The pointer must |
|
24 | 26 | /// remain valid throughout the existence of the SqpColorScale instance |
@@ -33,9 +33,28 std::pair<double, double> SqpColorScale::computeThresholds(const SqpColorScale & | |||
|
33 | 33 | |
|
34 | 34 | SqpColorScale::SqpColorScale(QCustomPlot &plot) |
|
35 | 35 | : m_Scale{new QCPColorScale{&plot}}, |
|
36 |
m_AutomaticThreshold{ |
|
|
36 | m_AutomaticThreshold{true}, | |
|
37 | 37 | m_GradientPreset{DEFAULT_GRADIENT_PRESET} |
|
38 | 38 | { |
|
39 | 39 | m_Scale->setGradient(m_GradientPreset); |
|
40 | 40 | m_Scale->setDataRange(DEFAULT_RANGE); |
|
41 | 41 | } |
|
42 | ||
|
43 | void SqpColorScale::updateDataRange() noexcept | |
|
44 | { | |
|
45 | // Updates data range only if mode is automatic | |
|
46 | if (!m_AutomaticThreshold) { | |
|
47 | return; | |
|
48 | } | |
|
49 | ||
|
50 | double minThreshold, maxThreshold; | |
|
51 | std::tie(minThreshold, maxThreshold) = computeThresholds(*this); | |
|
52 | if (std::isnan(minThreshold) || std::isnan(maxThreshold)) { | |
|
53 | qCCritical(LOG_SqpColorScale()) | |
|
54 | << "Can't update data range of color scale: thresholds computed are invalid"; | |
|
55 | return; | |
|
56 | } | |
|
57 | ||
|
58 | // Updates thresholds | |
|
59 | m_Scale->setDataRange({minThreshold, maxThreshold}); | |
|
60 | } |
General Comments 0
You need to be logged in to leave comments.
Login now