Warning, file /frameworks/kquickcharts/src/scenegraph/PieChartMaterial.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * This file is part of KQuickCharts 0003 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef PIECHARTMATERIAL_H 0009 #define PIECHARTMATERIAL_H 0010 0011 #include <QColor> 0012 #include <QSGMaterial> 0013 #include <QSGMaterialShader> 0014 0015 #include "SDFShader.h" 0016 0017 class PieChartMaterial : public QSGMaterial 0018 { 0019 public: 0020 PieChartMaterial(); 0021 ~PieChartMaterial(); 0022 0023 QSGMaterialType *type() const override; 0024 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; 0025 0026 QVector2D aspectRatio() const; 0027 float innerRadius() const; 0028 float outerRadius() const; 0029 QColor backgroundColor() const; 0030 bool smoothEnds() const; 0031 float fromAngle() const; 0032 float toAngle() const; 0033 0034 QList<QVector2D> segments() const; 0035 QList<QVector4D> colors() const; 0036 0037 void setAspectRatio(const QVector2D &aspect); 0038 void setInnerRadius(float radius); 0039 void setOuterRadius(float radius); 0040 void setBackgroundColor(const QColor &color); 0041 void setSmoothEnds(bool smooth); 0042 void setFromAngle(float angle); 0043 void setToAngle(float angle); 0044 0045 void setSegments(const QList<QVector2D> &triangles); 0046 void setColors(const QList<QVector4D> &colors); 0047 0048 private: 0049 QVector2D m_aspectRatio; 0050 float m_innerRadius = 0.0f; 0051 float m_outerRadius = 0.0f; 0052 QColor m_backgroundColor; 0053 bool m_smoothEnds = false; 0054 float m_fromAngle = 0.0; 0055 float m_toAngle = 6.28318; // 2 * pi 0056 0057 QList<QVector2D> m_segments; 0058 QList<QVector4D> m_colors; 0059 }; 0060 0061 class PieChartShader : public SDFShader 0062 { 0063 public: 0064 PieChartShader(); 0065 ~PieChartShader(); 0066 0067 bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; 0068 }; 0069 0070 #endif // PIECHARTMATERIAL_H