File indexing completed on 2024-12-15 04:02:36
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCHARTTERNARYAXIS_H 0010 #define KCHARTTERNARYAXIS_H 0011 0012 0013 #include <KChartAbstractAxis.h> 0014 #include <KChartPosition.h> 0015 #include <KChartTextAttributes.h> 0016 0017 class PrerenderedLabel; 0018 0019 namespace KChart { 0020 0021 class AbstractTernaryDiagram; 0022 0023 /** 0024 * The class for ternary axes 0025 */ 0026 class KCHART_EXPORT TernaryAxis : public AbstractAxis 0027 { 0028 Q_OBJECT 0029 0030 Q_DISABLE_COPY( TernaryAxis ) 0031 KCHART_DECLARE_PRIVATE_DERIVED_PARENT( TernaryAxis, AbstractDiagram* ) 0032 0033 public: 0034 explicit TernaryAxis ( AbstractTernaryDiagram* diagram = nullptr ); 0035 ~TernaryAxis() override; 0036 0037 void paintAll( QPainter &) override; 0038 void paint (QPainter *) override; 0039 void paintCtx (PaintContext *) override; 0040 0041 QRect geometry () const override; 0042 void setGeometry (const QRect &rect) override; 0043 0044 bool isEmpty () const override; 0045 QSize minimumSize () const override; 0046 QSize maximumSize () const override; 0047 QSize sizeHint () const override; 0048 Qt::Orientations expandingDirections () const override; 0049 0050 virtual const Position position () const; 0051 virtual void setPosition (Position p); 0052 0053 void setTitleText( const QString& text ); 0054 QString titleText() const; 0055 void setTitleTextAttributes( const TextAttributes &a ); 0056 TextAttributes titleTextAttributes() const; 0057 void resetTitleTextAttributes(); 0058 bool hasDefaultTitleTextAttributes() const; 0059 0060 QPair<QSizeF, QSizeF> requiredMargins() const; 0061 0062 private: 0063 void updatePrerenderedLabels(); 0064 // TODO, move class variables to private class 0065 QRect m_geometry; 0066 Position m_position; 0067 0068 QString m_title; 0069 TextAttributes m_titleAttributes; 0070 0071 // FIXME (Mirko): Move axis labels from grid to here, do not 0072 // expose them, just paint them. Use title text for text. Make 0073 // a function to allow the coordinate plane to calculate the 0074 // necessary margins, like this: 0075 PrerenderedLabel* m_label; 0076 PrerenderedLabel* m_fifty; 0077 }; 0078 0079 typedef QList<TernaryAxis*> TernaryAxisList; 0080 } 0081 0082 #endif