File indexing completed on 2025-02-23 03:35:04

0001 /*
0002     File                 : LollipopPrivate.h
0003     Project              : LabPlot
0004     Description          : Lollipop Plot - private implementation
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2023 Alexander Semke <alexander.semke@web.de>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef BARPLOTPRIVATE_H
0012 #define BARPLOTPRIVATE_H
0013 
0014 #include "backend/worksheet/plots/cartesian/PlotPrivate.h"
0015 #include <QPen>
0016 
0017 class CartesianCoordinateSystem;
0018 class Line;
0019 class Symbol;
0020 class Value;
0021 class KConfigGroup;
0022 
0023 typedef QVector<QPointF> Points;
0024 
0025 class LollipopPlotPrivate : public PlotPrivate {
0026 public:
0027     explicit LollipopPlotPrivate(LollipopPlot*);
0028 
0029     void retransform() override;
0030     void recalc();
0031     virtual void recalcShapeAndBoundingRect() override;
0032     void updateValues();
0033     void updatePixmap();
0034 
0035     Line* addLine(const KConfigGroup&);
0036     Symbol* addSymbol(const KConfigGroup&);
0037     void addValue(const KConfigGroup&);
0038 
0039     LollipopPlot* const q;
0040 
0041     // General
0042     const AbstractColumn* xColumn{nullptr};
0043     QString xColumnPath;
0044     QVector<const AbstractColumn*> dataColumns;
0045     QVector<QString> dataColumnPaths;
0046     LollipopPlot::Orientation orientation{LollipopPlot::Orientation::Vertical};
0047     qreal opacity{1.0};
0048 
0049     double xMin{0.};
0050     double xMax{1.};
0051     double yMin{0.};
0052     double yMax{1.};
0053 
0054     QVector<Line*> lines;
0055     QVector<Symbol*> symbols;
0056     Value* value{nullptr};
0057 
0058 private:
0059     void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* widget = nullptr) override;
0060 
0061     void recalc(int);
0062     void verticalPlot(int);
0063     void horizontalPlot(int);
0064 
0065     void draw(QPainter*);
0066 
0067     QVector<QVector<QLineF>> m_barLines; // QVector<QLineF> contains the lines for each data column
0068     QVector<QVector<QPointF>> m_symbolPoints; // QVector<QPointF> contains the positions of symbols for each data column
0069 
0070     QVector<QPointF> m_valuesPoints;
0071     QVector<QPointF> m_valuesPointsLogical;
0072     QVector<QString> m_valuesStrings;
0073     QPainterPath m_valuesPath;
0074 
0075     double m_groupWidth{1.0}; // width of a bar group
0076     double m_groupGap{0.0}; // gap around a group of bars
0077 };
0078 
0079 #endif