mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
statistics: add notion of Z-value to chart items
The chart items were drawn in order of creation. To control this, add a notion of Z-value. In contrast to QGraphicsScene, make this a small integer value. To controll order of drawing, a plain QSGNode is created for every possible Z-Value and items are added to these nodes. Thus, items are rendered by Z-value and if the Z-value is equal by order of creation. Likewise split the list of chart-items into Z-values, so that items can be quickly unregistered: The items that will be removed individually will usuall be part of Z-levels with only few items (e.g. legend, infobox). Z-levels with many items (notably the series) will always be fully rebuilt. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
785d5189f6
commit
e1c0cace95
7 changed files with 82 additions and 31 deletions
|
|
@ -19,7 +19,6 @@ struct StatsVariable;
|
|||
|
||||
class QGraphicsLineItem;
|
||||
class QGraphicsSimpleTextItem;
|
||||
class QSGImageNode;
|
||||
class StatsSeries;
|
||||
class CategoryAxis;
|
||||
class ChartItem;
|
||||
|
|
@ -29,8 +28,10 @@ class StatsAxis;
|
|||
class StatsGrid;
|
||||
class Legend;
|
||||
class QSGTexture;
|
||||
class RootNode; // Internal implementation detail
|
||||
|
||||
enum class ChartSubType : int;
|
||||
enum class ChartZValue : int;
|
||||
enum class StatsOperation : int;
|
||||
|
||||
struct regression_data {
|
||||
|
|
@ -50,7 +51,8 @@ public:
|
|||
void plot(const StatsState &state);
|
||||
QQuickWindow *w() const; // Make window available to items
|
||||
QSizeF size() const;
|
||||
void addQSGNode(QSGNode *node, int z); // Must only be called in render thread!
|
||||
void addQSGNode(QSGNode *node, ChartZValue z); // Must only be called in render thread!
|
||||
void registerChartItem(ChartItem *item);
|
||||
void unregisterChartItem(const ChartItem *item);
|
||||
template <typename T, class... Args>
|
||||
std::unique_ptr<T> createChartItem(Args&&... args);
|
||||
|
|
@ -165,7 +167,6 @@ private:
|
|||
std::vector<RegressionLine> regressionLines;
|
||||
std::vector<HistogramMarker> histogramMarkers;
|
||||
std::unique_ptr<QGraphicsSimpleTextItem> title;
|
||||
std::vector<ChartItem *> items; // Attention: currently, items are not automatically removed on destruction!
|
||||
StatsSeries *highlightedSeries;
|
||||
StatsAxis *xAxis, *yAxis;
|
||||
Legend *draggedItem;
|
||||
|
|
@ -176,7 +177,7 @@ private:
|
|||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
QSGImageNode *rootNode;
|
||||
RootNode *rootNode;
|
||||
};
|
||||
|
||||
// This implementation detail must be known to users of the class.
|
||||
|
|
@ -185,7 +186,7 @@ template <typename T, class... Args>
|
|||
std::unique_ptr<T> StatsView::createChartItem(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<T> res(new T(*this, std::forward<Args>(args)...));
|
||||
items.push_back(res.get());
|
||||
registerChartItem(res.get());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue