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

0001 /*
0002     File                 : Value.h
0003     Project              : LabPlot
0004     Description          : Value
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2022-2023 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef VALUE_H
0011 #define VALUE_H
0012 
0013 #include "backend/core/AbstractAspect.h"
0014 #include "backend/lib/macros.h"
0015 
0016 class AbstractColumn;
0017 class ValuePrivate;
0018 class KConfigGroup;
0019 
0020 class Value : public AbstractAspect {
0021     Q_OBJECT
0022 
0023 public:
0024     enum Type { NoValues, BinEntries, CustomColumn };
0025     enum Position { Above, Under, Left, Right, Center };
0026 
0027     explicit Value(const QString& name);
0028     ~Value() override;
0029 
0030     void init(const KConfigGroup&);
0031     void draw(QPainter*, const QVector<QPointF>&, const QVector<QString>&);
0032 
0033     void save(QXmlStreamWriter*) const override;
0034     bool load(XmlStreamReader*, bool preview) override;
0035     void loadThemeConfig(const KConfigGroup&, const QColor&);
0036     void saveThemeConfig(KConfigGroup&) const;
0037 
0038     BASIC_D_ACCESSOR_DECL(Type, type, Type)
0039     POINTER_D_ACCESSOR_DECL(const AbstractColumn, column, Column)
0040     QString& columnPath() const;
0041     void setColumnPath(const QString&);
0042     BASIC_D_ACCESSOR_DECL(Position, position, Position)
0043     BASIC_D_ACCESSOR_DECL(bool, centerPositionAvailable, centerPositionAvailable)
0044     BASIC_D_ACCESSOR_DECL(double, distance, Distance)
0045     BASIC_D_ACCESSOR_DECL(double, rotationAngle, RotationAngle)
0046     BASIC_D_ACCESSOR_DECL(double, opacity, Opacity)
0047     BASIC_D_ACCESSOR_DECL(char, numericFormat, NumericFormat)
0048     BASIC_D_ACCESSOR_DECL(int, precision, Precision)
0049     CLASS_D_ACCESSOR_DECL(QString, dateTimeFormat, DateTimeFormat)
0050     CLASS_D_ACCESSOR_DECL(QString, prefix, Prefix)
0051     CLASS_D_ACCESSOR_DECL(QString, suffix, Suffix)
0052     CLASS_D_ACCESSOR_DECL(QColor, color, Color)
0053     CLASS_D_ACCESSOR_DECL(QFont, font, Font)
0054 
0055     typedef ValuePrivate Private;
0056 
0057 protected:
0058     ValuePrivate* const d_ptr;
0059 
0060 private:
0061     Q_DECLARE_PRIVATE(Value)
0062 
0063 private Q_SLOTS:
0064     void columnAboutToBeRemoved(const AbstractAspect*);
0065 
0066 Q_SIGNALS:
0067     void typeChanged(Value::Type);
0068     void columnChanged(const AbstractColumn*);
0069     void positionChanged(Value::Position);
0070     void distanceChanged(double);
0071     void rotationAngleChanged(double);
0072     void opacityChanged(double);
0073     void numericFormatChanged(char);
0074     void precisionChanged(int);
0075     void dateTimeFormatChanged(QString);
0076     void prefixChanged(QString);
0077     void suffixChanged(QString);
0078     void fontChanged(QFont);
0079     void colorChanged(QColor);
0080 
0081     void updateRequested();
0082     void updatePixmapRequested();
0083 };
0084 
0085 #endif