mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: implement a simple information box
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>
This commit is contained in:
parent
907e6ff05d
commit
99f98ea6d4
3 changed files with 108 additions and 0 deletions
31
stats/informationbox.h
Normal file
31
stats/informationbox.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// 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
|
Loading…
Add table
Add a link
Reference in a new issue