File indexing completed on 2025-01-26 03:34:13

0001 /*
0002     File                 : LollipopPlot.h
0003     Project              : LabPlot
0004     Description          : Lollipop Plot
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2023 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef LOLLIPOPPLOT_H
0011 #define LOLLIPOPPLOT_H
0012 
0013 #include "backend/worksheet/plots/cartesian/Plot.h"
0014 
0015 class AbstractColumn;
0016 class Line;
0017 class LollipopPlotPrivate;
0018 class Symbol;
0019 class Value;
0020 
0021 #ifdef SDK
0022 #include "labplot_export.h"
0023 class LABPLOT_EXPORT LollipopPlot : Plot {
0024 #else
0025 class LollipopPlot : public Plot {
0026 #endif
0027     Q_OBJECT
0028 
0029 public:
0030     explicit LollipopPlot(const QString&);
0031     ~LollipopPlot() override;
0032 
0033     QIcon icon() const override;
0034     static QIcon staticIcon();
0035     QMenu* createContextMenu() override;
0036 
0037     void save(QXmlStreamWriter*) const override;
0038     bool load(XmlStreamReader*, bool preview) override;
0039     void loadThemeConfig(const KConfig&) override;
0040 
0041     // general
0042     POINTER_D_ACCESSOR_DECL(const AbstractColumn, xColumn, XColumn)
0043     QString& xColumnPath() const;
0044     BASIC_D_ACCESSOR_DECL(QVector<const AbstractColumn*>, dataColumns, DataColumns)
0045     QVector<QString>& dataColumnPaths() const;
0046     BASIC_D_ACCESSOR_DECL(LollipopPlot::Orientation, orientation, Orientation)
0047     BASIC_D_ACCESSOR_DECL(double, widthFactor, WidthFactor)
0048 
0049     Line* lineAt(int) const;
0050     Symbol* symbolAt(int) const;
0051     Value* value() const;
0052 
0053     void retransform() override;
0054     void handleResize(double horizontalRatio, double verticalRatio, bool pageResize) override;
0055 
0056     double minimum(CartesianCoordinateSystem::Dimension) const override;
0057     double maximum(CartesianCoordinateSystem::Dimension) const override;
0058     bool hasData() const override;
0059     bool usingColumn(const Column*) const override;
0060     void updateColumnDependencies(const AbstractColumn*) override;
0061     QColor color() const override;
0062 
0063     typedef LollipopPlotPrivate Private;
0064 
0065 protected:
0066     LollipopPlot(const QString& name, LollipopPlotPrivate* dd);
0067 
0068 private:
0069     Q_DECLARE_PRIVATE(LollipopPlot)
0070     void init();
0071     void initActions();
0072     void initMenus();
0073 
0074     QAction* orientationHorizontalAction{nullptr};
0075     QAction* orientationVerticalAction{nullptr};
0076     QMenu* orientationMenu{nullptr};
0077 
0078 public Q_SLOTS:
0079     void recalc();
0080 
0081 private Q_SLOTS:
0082     // SLOTs for changes triggered via QActions in the context menu
0083     void orientationChangedSlot(QAction*);
0084     void dataColumnAboutToBeRemoved(const AbstractAspect*);
0085 
0086 Q_SIGNALS:
0087     // General-Tab
0088     void xColumnChanged(const AbstractColumn*);
0089     void dataColumnsChanged(const QVector<const AbstractColumn*>&);
0090     void orientationChanged(LollipopPlot::Orientation);
0091 };
0092 
0093 #endif