##// END OF EJS Templates
Tooltip for spectrograms (4)...
Alexandre Leroux -
r1068:e3aea966fca1
parent child
Show More
@@ -16,6 +16,9 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz");
16 16 /// Format for datetimes on a axis
17 17 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
18 18
19 const auto NUMBER_FORMAT = 'g';
20 const auto NUMBER_PRECISION = 9;
21
19 22 /// Generates the appropriate ticker for an axis, depending on whether the axis displays time or
20 23 /// non-time data
21 24 QSharedPointer<QCPAxisTicker> axisTicker(bool isTimeAxis, QCPAxis::ScaleType scaleType)
@@ -151,7 +154,7 QString formatValue(double value, const QCPAxis &axis)
151 154 return DateUtils::dateTime(value, axisTicker->dateTimeSpec()).toString(DATETIME_FORMAT);
152 155 }
153 156 else {
154 return QString::number(value);
157 return QString::number(value, NUMBER_FORMAT, NUMBER_PRECISION);
155 158 }
156 159 }
157 160
@@ -29,6 +29,8 const auto SHOW_AXIS_ICON_PATH = QStringLiteral(":/icones/up.png");
29 29 /// Tooltip format for graphs
30 30 const auto GRAPH_TOOLTIP_FORMAT = QStringLiteral("key: %1\nvalue: %2");
31 31
32 /// Tooltip format for colormaps
33 const auto COLORMAP_TOOLTIP_FORMAT = QStringLiteral("x: %1\ny: %2\nvalue: %3");
32 34
33 35 /// Offset used to shift the tooltip of the mouse
34 36 const auto TOOLTIP_OFFSET = QPoint{20, 20};
@@ -274,6 +276,10 void VisualizationGraphRenderingDelegate::onMouseMove(QMouseEvent *event) noexce
274 276 auto yCellIndex = colorMapCellIndex(*colorMap, y, false);
275 277 auto value = colorMap->data()->cell(xCellIndex, yCellIndex);
276 278
279 // Sets tooltips
280 tooltip = COLORMAP_TOOLTIP_FORMAT.arg(formatValue(x, *colorMap->keyAxis()),
281 formatValue(y, *colorMap->valueAxis()),
282 formatValue(value, *colorMap->colorScale()->axis()));
277 283 }
278 284
279 285 if (!tooltip.isEmpty()) {
General Comments 0
You need to be logged in to leave comments. Login now