File indexing completed on 2025-01-26 03:34:15
0001 /* 0002 File : Symbol.h 0003 Project : LabPlot 0004 Description : Symbol 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2015-2020 Alexander Semke <alexander.semke@web.de> 0007 SPDX-FileCopyrightText: 2021 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef SYMBOL_H 0012 #define SYMBOL_H 0013 0014 #include "backend/core/AbstractAspect.h" 0015 #include "backend/lib/macros.h" 0016 #include <QPainterPath> 0017 0018 class SymbolPrivate; 0019 class KConfigGroup; 0020 class QPainter; 0021 0022 class Symbol : public AbstractAspect { 0023 Q_OBJECT 0024 0025 public: 0026 // order is fixed; append new symbols at the end and add to StyleOrder in Symbol.cpp 0027 enum class Style { 0028 NoSymbols, 0029 Circle, 0030 Square, 0031 EquilateralTriangle, 0032 RightTriangle, 0033 Bar, 0034 PeakedBar, 0035 SkewedBar, 0036 Diamond, 0037 Lozenge, 0038 Tie, 0039 TinyTie, 0040 Plus, 0041 Boomerang, 0042 SmallBoomerang, 0043 Star4, 0044 Star5, 0045 Line, 0046 Cross, 0047 Heart, 0048 Lightning, 0049 X, 0050 Asterisk, 0051 Tri, 0052 XPlus, 0053 TallPlus, 0054 LatinCross, 0055 DotPlus, 0056 Hash, 0057 SquareX, 0058 SquarePlus, 0059 SquareHalf, 0060 SquareDiag, 0061 SquareTriangle, 0062 CircleHalf, 0063 CircleDot, 0064 CircleX, 0065 CircleTri, 0066 Peace, 0067 Flower, 0068 Flower2, 0069 Flower3, 0070 Flower5, 0071 Flower6, 0072 Star, 0073 Star3, 0074 Star6, 0075 Pentagon, 0076 Hexagon, 0077 Latin, 0078 David, 0079 Home, 0080 Pin, 0081 Female, 0082 Male, 0083 Spade, 0084 Club, 0085 SquareDot, 0086 TriangleDot, 0087 TriangleHalf, 0088 TriangleLine 0089 }; 0090 Q_ENUM(Style) 0091 0092 static int stylesCount(); 0093 static QString styleName(Symbol::Style); 0094 static Symbol::Style indexToStyle(int); 0095 static QPainterPath stylePath(Symbol::Style); 0096 0097 explicit Symbol(const QString& name); 0098 ~Symbol() override; 0099 void init(const KConfigGroup&); 0100 0101 void draw(QPainter*, QPointF); 0102 void draw(QPainter*, const QVector<QPointF>&); 0103 0104 void save(QXmlStreamWriter*) const override; 0105 bool load(XmlStreamReader*, bool preview) override; 0106 void loadThemeConfig(const KConfigGroup&, const QColor&); 0107 void saveThemeConfig(const KConfigGroup&) const; 0108 0109 BASIC_D_ACCESSOR_DECL(Symbol::Style, style, Style) 0110 CLASS_D_ACCESSOR_DECL(QColor, color, Color) 0111 BASIC_D_ACCESSOR_DECL(qreal, opacity, Opacity) 0112 BASIC_D_ACCESSOR_DECL(qreal, rotationAngle, RotationAngle) 0113 BASIC_D_ACCESSOR_DECL(qreal, size, Size) 0114 CLASS_D_ACCESSOR_DECL(QBrush, brush, Brush) 0115 CLASS_D_ACCESSOR_DECL(QPen, pen, Pen) 0116 0117 typedef SymbolPrivate Private; 0118 0119 protected: 0120 SymbolPrivate* const d_ptr; 0121 0122 private: 0123 Q_DECLARE_PRIVATE(Symbol) 0124 0125 Q_SIGNALS: 0126 void styleChanged(Symbol::Style); 0127 void sizeChanged(qreal); 0128 void rotationAngleChanged(qreal); 0129 void opacityChanged(qreal); 0130 void brushChanged(QBrush); 0131 void penChanged(const QPen&); 0132 void colorChanged(const QColor&); 0133 0134 void updateRequested(); 0135 void updatePixmapRequested(); 0136 }; 0137 0138 #endif