File indexing completed on 2023-05-30 09:13:19

0001 /*
0002  *  Copyright 2014  Sebastian Gottfried <sebastiangottfried@web.de>
0003  *
0004  *  This library is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU Lesser General Public
0006  *  License as published by the Free Software Foundation; either
0007  *  version 2.1 of the License, or (at your option) version 3, or any
0008  *  later version accepted by the membership of KDE e.V. (or its
0009  *  successor approved by the membership of KDE e.V.), which shall
0010  *  act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  *  This library is distributed in the hope that it will be useful,
0013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  *  Lesser General Public License for more details.
0016  *
0017  *  You should have received a copy of the GNU Lesser General Public
0018  */
0019 
0020 #ifndef DIMENSION_H
0021 #define DIMENSION_H
0022 
0023 #include <QObject>
0024 
0025 #include <QColor>
0026 
0027 class Dimension : public QObject
0028 {
0029 Q_OBJECT
0030 public:
0031     enum MarkerStyle
0032     {
0033         MarkerStyleNone,
0034         MarkerStyleRound,
0035         MarkerStyleCross
0036     };
0037     Q_ENUMS(MarkerStyle)
0038     enum LineStyle
0039     {
0040         LineStyleNone,
0041         LineStyleSolid,
0042         LineStyleDash
0043     };
0044     Q_ENUMS(LineStyle)
0045 
0046     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
0047     Q_PROPERTY(int dataColumn READ dataColumn WRITE setDataColumn NOTIFY dataColumnChanged)
0048     Q_PROPERTY(qreal minimumValue READ minimumValue WRITE setMinimumValue NOTIFY minimumValueChanged)
0049     Q_PROPERTY(qreal maximumValue READ maximumValue WRITE setMaximumValue NOTIFY maximumValueChanged)
0050     Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
0051     Q_PROPERTY(int precision READ precision WRITE setPrecision NOTIFY precisionChanged)
0052     Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY unitChanged)
0053     Q_PROPERTY(qreal unitFactor READ unitFactor WRITE setUnitFactor NOTIFY unitFactorChanged)
0054     Q_PROPERTY(MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle NOTIFY markerStyleChanged)
0055     Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle NOTIFY lineStyleChanged)
0056 
0057     explicit Dimension(QObject* parent = nullptr);
0058     QColor color() const;
0059     void setColor(const QColor& color);
0060     int dataColumn() const;
0061     void setDataColumn(int dataColumn);
0062     qreal minimumValue() const;
0063     void setMinimumValue(qreal minimumValue);
0064     qreal maximumValue() const;
0065     void setMaximumValue(qreal maximumValue);
0066     QString label() const;
0067     void setLabel(const QString& label);
0068     int precision() const;
0069     void setPrecision(int precision);
0070     QString unit() const;
0071     void setUnit(const QString& unit);
0072     qreal unitFactor() const;
0073     void setUnitFactor(qreal unitFactor);
0074     MarkerStyle markerStyle() const;
0075     void setMarkerStyle(MarkerStyle markerstyle);
0076     LineStyle lineStyle() const;
0077     void setLineStyle(LineStyle lineStyle);
0078     Q_INVOKABLE QString formatValue(qreal value);
0079 
0080 Q_SIGNALS:
0081     void colorChanged();
0082     void dataColumnChanged();
0083     void minimumValueChanged();
0084     void maximumValueChanged();
0085     void labelChanged();
0086     void precisionChanged();
0087     void unitChanged();
0088     void unitFactorChanged();
0089     void updated();
0090     void markerStyleChanged();
0091     void lineStyleChanged();
0092 private:
0093     QColor m_color;
0094     int m_dataColumn;
0095     qreal m_minimumValue;
0096     qreal m_maximumValue;
0097     QString m_label;
0098     int m_precision;
0099     QString m_unit;
0100     qreal m_unitFactor;
0101     MarkerStyle m_markerStyle;
0102     LineStyle m_lineStyle;
0103 };
0104 
0105 #endif // DIMENSION_H