mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
When the user hovers over features in the chart, they should be presented with more information. For example in bar charts on the dives the bar represents and the exact value that the bar represents, etc. The InformationBox is a simple QGraphicsWidget, which can be placed on top of QCharts and can show a number of arbitrary text lines. When placing the box on the chart, the code attempts to stay inside the plot area of the chart. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
31 lines
809 B
C++
31 lines
809 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
// A small box displaying statistics information, notably
|
|
// for a scatter-plot item or a bar in a bar chart.
|
|
#ifndef INFORMATION_BOX_H
|
|
#define INFORMATION_BOX_H
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <QGraphicsRectItem>
|
|
#include <QFont>
|
|
|
|
namespace QtCharts {
|
|
class QChart;
|
|
}
|
|
struct dive;
|
|
|
|
// Information window showing data of highlighted dive
|
|
struct InformationBox : QGraphicsRectItem {
|
|
InformationBox(QtCharts::QChart *chart);
|
|
void setText(const std::vector<QString> &text, QPointF pos);
|
|
void setPos(QPointF pos);
|
|
int recommendedMaxLines() const;
|
|
private:
|
|
QtCharts::QChart *chart;
|
|
QFont font; // For future specialization.
|
|
double width, height;
|
|
void addLine(const QString &s);
|
|
std::vector<std::unique_ptr<QGraphicsSimpleTextItem>> textItems;
|
|
};
|
|
|
|
#endif
|