File indexing completed on 2024-12-15 04:02:31

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 KCHARTLEVEYJENNINGSAXIS_H
0010 #define KCHARTLEVEYJENNINGSAXIS_H
0011 
0012 #include <QList>
0013 
0014 #include "KChartCartesianAxis.h"
0015 
0016 #include "KChartLeveyJenningsGridAttributes.h"
0017 
0018 namespace KChart {
0019 
0020     class LeveyJenningsDiagram;
0021 
0022     /**
0023       * The class for levey jennings axes.
0024       *
0025       * For being useful, axes need to be assigned to a diagram, see
0026       * LeveyJenningsDiagram::addAxis and LeveyJenningsDiagram::takeAxis.
0027       *
0028       * \sa PolarAxis, AbstractCartesianDiagram
0029       */
0030     class KCHART_EXPORT LeveyJenningsAxis : public CartesianAxis
0031     {
0032         Q_OBJECT
0033 
0034         Q_DISABLE_COPY( LeveyJenningsAxis )
0035         KCHART_DECLARE_PRIVATE_DERIVED_PARENT( LeveyJenningsAxis, AbstractDiagram* )
0036 
0037     public:
0038         /**
0039           * C'tor of the class for levey jennings axes.
0040           *
0041           * \note If using a zero parent for the constructor, you need to call
0042           * your diagram's addAxis function to add your axis to the diagram.
0043           * Otherwise, there is no need to call addAxis, since the constructor
0044           * does that automatically for you, if you pass a diagram as parameter.
0045           *
0046           * \sa AbstractCartesianDiagram::addAxis
0047           */
0048         explicit LeveyJenningsAxis ( LeveyJenningsDiagram* diagram = nullptr );
0049         ~LeveyJenningsAxis() override;
0050 
0051         /**
0052           * @return The axis' type.
0053           */
0054         LeveyJenningsGridAttributes::GridType type() const;
0055 
0056         /**
0057           * Sets the type of the axis to \a type.
0058           * This method colors the label to the default color of the
0059           * respective type.
0060           * Please make sure to re-set the colors after calling this,
0061           * if you want them different.
0062           * Setting the type is only valid for axes located right or left
0063           * from the diagram. An axis on the bottom always shows the timeline.
0064           */
0065         void setType( LeveyJenningsGridAttributes::GridType type );
0066 
0067         Qt::DateFormat dateFormat() const;
0068         void setDateFormat( Qt::DateFormat format );
0069 
0070         /**
0071          * Returns true if both axes have the same settings.
0072          */
0073         bool compare( const LeveyJenningsAxis* other ) const;
0074 
0075         /** reimpl */
0076         void paintCtx( PaintContext* ) override;
0077 
0078     protected:
0079         virtual void paintAsOrdinate( PaintContext* );
0080 
0081         virtual void paintAsAbscissa( PaintContext* );
0082     };
0083 
0084     typedef QList<LeveyJenningsAxis*> LeveyJenningsAxisList;
0085 }
0086 
0087 #endif