diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-01-02 10:25:04 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-01-02 11:04:03 -0800 |
commit | 3b26f6a767595012bfe561f790404719f8580746 (patch) | |
tree | edd5808be01c716b4fd34aa1b13cbc5459c5f1d4 | |
parent | fdde4c23ea570d3fdc25dd3a66019e4500c5982c (diff) | |
download | subsurface-3b26f6a767595012bfe561f790404719f8580746.tar.gz |
statistics: add a header file defining z-values
z-values determine the order in which objects on the chart are
painted. To reduce chaos, collect all z-values in a header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | stats/CMakeLists.txt | 1 | ||||
-rw-r--r-- | stats/legend.cpp | 8 | ||||
-rw-r--r-- | stats/zvalues.h | 17 |
3 files changed, 23 insertions, 3 deletions
diff --git a/stats/CMakeLists.txt b/stats/CMakeLists.txt index 11b091d1b..a03ff0c1a 100644 --- a/stats/CMakeLists.txt +++ b/stats/CMakeLists.txt @@ -11,6 +11,7 @@ set(SUBSURFACE_STATS_SRCS statscolors.cpp statsvariables.h statsvariables.cpp + zvalues.h ) source_group("Subsurface statistics sourcecode" FILES ${SUBSURFACE_STATS_SRCS}) diff --git a/stats/legend.cpp b/stats/legend.cpp index b532f483f..7418df9df 100644 --- a/stats/legend.cpp +++ b/stats/legend.cpp @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 #include "legend.h" #include "statscolors.h" +#include "zvalues.h" + #include <QFontMetrics> #include <QGraphicsSceneMouseEvent> #include <QGraphicsWidget> @@ -16,7 +18,7 @@ static const QColor legendBorderColor(Qt::black); Legend::Legend(QGraphicsWidget *chart, const std::vector<QString> &names) : QGraphicsRectItem(chart), chart(chart), displayedItems(0), width(0.0), height(0.0) { - setZValue(30.0); // On top of everything else. + setZValue(ZValues::legend); entries.reserve(names.size()); int idx = 0; for (const QString &name: names) @@ -42,10 +44,10 @@ Legend::Entry::Entry(const QString &name, int idx, int numBins, QGraphicsItem *p rect(new QGraphicsRectItem(parent)), text(new QGraphicsSimpleTextItem(name, parent)) { - rect->setZValue(30.0); + rect->setZValue(ZValues::legend); rect->setPen(QPen(legendBorderColor, legendBoxBorderSize)); rect->setBrush(QBrush(binColor(idx, numBins))); - text->setZValue(30.0); + text->setZValue(ZValues::legend); text->setBrush(QBrush(darkLabelColor)); } diff --git a/stats/zvalues.h b/stats/zvalues.h new file mode 100644 index 000000000..f4e7d6f09 --- /dev/null +++ b/stats/zvalues.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +// Defines the z-values of features in the chart view. +// Objects with higher z-values are painted on top of objects +// with smaller z-values. For the same z-value objects are +// drawn in order of addition to the graphics scene. +#ifndef ZVALUES_H + +struct ZValues { + static constexpr double axes = 0.0; + static constexpr double series = 11.0; + static constexpr double seriesLabels = 12.0; + static constexpr double chartFeatures = 13.0; // quartile markers and regression lines + static constexpr double informationBox = 14.0; + static constexpr double legend = 15.0; +}; + +#endif |