##// END OF EJS Templates
Handles log scales for y-axis and color scale
Alexandre Leroux -
r928:42fd5c9b7ed8
parent child
Show More
@@ -17,7 +17,7 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
17
17
18 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
18 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
19 /// non-time data
19 /// non-time data
20 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
20 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis, QCPAxis::ScaleType scaleType)
21 {
21 {
22 if (isTimeAxis) {
22 if (isTimeAxis) {
23 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
23 auto dateTicker = QSharedPointer<QCPAxisTickerDateTime>::create();
@@ -26,6 +26,9 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis)
26
26
27 return dateTicker;
27 return dateTicker;
28 }
28 }
29 else if (scaleType == QCPAxis::stLogarithmic) {
30 return QSharedPointer<QCPAxisTickerLog>::create();
31 }
29 else {
32 else {
30 // default ticker
33 // default ticker
31 return QSharedPointer<QCPAxisTicker>::create();
34 return QSharedPointer<QCPAxisTicker>::create();
@@ -46,9 +49,14 void setAxisProperties(QCPAxis &axis, const Unit &unit,
46
49
47 // scale type
50 // scale type
48 axis.setScaleType(scaleType);
51 axis.setScaleType(scaleType);
52 if (scaleType == QCPAxis::stLogarithmic) {
53 // Scientific notation
54 axis.setNumberPrecision(0);
55 axis.setNumberFormat("eb");
56 }
49
57
50 // ticker (depending on the type of unit)
58 // ticker (depending on the type of unit)
51 axis.setTicker(axisTicker(unit.m_TimeUnit));
59 axis.setTicker(axisTicker(unit.m_TimeUnit, scaleType));
52 }
60 }
53
61
54 /**
62 /**
@@ -99,7 +107,7 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries
99 dataSeries.unlock();
107 dataSeries.unlock();
100
108
101 setAxisProperties(*plot.xAxis, xAxisUnit);
109 setAxisProperties(*plot.xAxis, xAxisUnit);
102 setAxisProperties(*plot.yAxis, yAxisUnit);
110 setAxisProperties(*plot.yAxis, yAxisUnit, QCPAxis::stLogarithmic);
103
111
104 // Displays color scale in plot
112 // Displays color scale in plot
105 plot.plotLayout()->insertRow(0);
113 plot.plotLayout()->insertRow(0);
@@ -114,8 +122,7 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries
114 }
122 }
115
123
116 // Set color scale properties
124 // Set color scale properties
117 colorScale.setLabel(valuesUnit.m_Name);
125 setAxisProperties(*colorScale.axis(), valuesUnit, QCPAxis::stLogarithmic);
118 colorScale.setDataScaleType(QCPAxis::stLogarithmic); // Logarithmic scale
119 }
126 }
120 };
127 };
121
128
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now