statistics: remove horizontal flag from bar chart items

This flag existed for historical reasons: The base of bar items
had no line and therefore the lines had to be draw differently
for horizontal (base to the left) and vertical (base on the bottom)
item.

This did not work properly and therefore has been removed. Thus,
the flag became pointless.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-07 14:39:53 +01:00 committed by Dirk Hohndel
parent 06a091643e
commit 91d371374b
3 changed files with 9 additions and 17 deletions

View file

@ -248,7 +248,7 @@ std::vector<BarSeries::SubItem> BarSeries::makeSubItems(std::vector<SubItemDesc>
for (auto &[v, dives, label]: items) { for (auto &[v, dives, label]: items) {
if (v > 0.0) { if (v > 0.0) {
bool selected = std::all_of(dives.begin(), dives.end(), [] (const dive *d) { return d->selected; }); bool selected = std::all_of(dives.begin(), dives.end(), [] (const dive *d) { return d->selected; });
res.push_back({ view.createChartItem<ChartBarItem>(ChartZValue::Series, barBorderWidth, horizontal), res.push_back({ view.createChartItem<ChartBarItem>(ChartZValue::Series, barBorderWidth),
std::move(dives), std::move(dives),
{}, from, from + v, bin_nr, selected }); {}, from, from + v, bin_nr, selected });
if (!label.empty()) if (!label.empty())

View file

@ -402,8 +402,8 @@ void ChartRectLineItem::render()
positionDirty = materialDirty = false; positionDirty = materialDirty = false;
} }
ChartBarItem::ChartBarItem(StatsView &v, ChartZValue z, double borderWidth, bool horizontal) : HideableChartItem(v, z), ChartBarItem::ChartBarItem(StatsView &v, ChartZValue z, double borderWidth) : HideableChartItem(v, z),
borderWidth(borderWidth), selected(false), horizontal(horizontal), borderWidth(borderWidth), selected(false),
positionDirty(false), colorDirty(false), selectedDirty(false) positionDirty(false), colorDirty(false), selectedDirty(false)
{ {
} }
@ -453,17 +453,10 @@ void ChartBarItem::render()
if (positionDirty) { if (positionDirty) {
node->node->setRect(rect); node->node->setRect(rect);
auto vertices = borderGeometry->vertexDataAsPoint2D(); auto vertices = borderGeometry->vertexDataAsPoint2D();
if (horizontal) { setPoint(vertices[0], rect.topLeft());
setPoint(vertices[0], rect.topLeft()); setPoint(vertices[1], rect.topRight());
setPoint(vertices[1], rect.topRight()); setPoint(vertices[2], rect.bottomRight());
setPoint(vertices[2], rect.bottomRight()); setPoint(vertices[3], rect.bottomLeft());
setPoint(vertices[3], rect.bottomLeft());
} else {
setPoint(vertices[0], rect.bottomLeft());
setPoint(vertices[1], rect.topLeft());
setPoint(vertices[2], rect.topRight());
setPoint(vertices[3], rect.bottomRight());
}
node->node->markDirty(QSGNode::DirtyGeometry); node->node->markDirty(QSGNode::DirtyGeometry);
borderNode->markDirty(QSGNode::DirtyGeometry); borderNode->markDirty(QSGNode::DirtyGeometry);
} }
@ -540,7 +533,7 @@ QRectF ChartBarItem::getRect() const
} }
ChartBoxItem::ChartBoxItem(StatsView &v, ChartZValue z, double borderWidth) : ChartBoxItem::ChartBoxItem(StatsView &v, ChartZValue z, double borderWidth) :
ChartBarItem(v, z, borderWidth, false) // Only support for vertical boxes ChartBarItem(v, z, borderWidth)
{ {
} }

View file

@ -145,7 +145,7 @@ public:
// A bar in a bar chart: a rectangle bordered by lines. // A bar in a bar chart: a rectangle bordered by lines.
class ChartBarItem : public HideableChartProxyItem<QSGRectangleNode> { class ChartBarItem : public HideableChartProxyItem<QSGRectangleNode> {
public: public:
ChartBarItem(StatsView &v, ChartZValue z, double borderWidth, bool horizontal); ChartBarItem(StatsView &v, ChartZValue z, double borderWidth);
~ChartBarItem(); ~ChartBarItem();
void setColor(QColor color, QColor borderColor); void setColor(QColor color, QColor borderColor);
void setRect(const QRectF &rect); void setRect(const QRectF &rect);
@ -157,7 +157,6 @@ protected:
double borderWidth; double borderWidth;
QRectF rect; QRectF rect;
bool selected; bool selected;
bool horizontal;
bool positionDirty; bool positionDirty;
bool colorDirty; bool colorDirty;
bool selectedDirty; bool selectedDirty;