File indexing completed on 2024-06-09 04:18:28

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 KCHARTLINEDIAGRAM_P_H
0010 #define KCHARTLINEDIAGRAM_P_H
0011 
0012 //
0013 //  W A R N I N G
0014 //  -------------
0015 //
0016 // This file is not part of the KD Chart API.  It exists purely as an
0017 // implementation detail.  This header file may change from version to
0018 // version without notice, or even be removed.
0019 //
0020 // We mean it.
0021 //
0022 
0023 #include "KChartLineDiagram.h"
0024 
0025 #include <QPainterPath>
0026 
0027 #include "KChartThreeDLineAttributes.h"
0028 #include "KChartAbstractCartesianDiagram_p.h"
0029 #include "KChartCartesianDiagramDataCompressor_p.h"
0030 #include "KChartMath_p.h"
0031 
0032 
0033 namespace KChart {
0034 
0035     class PaintContext;
0036 
0037 /**
0038  * \internal
0039  */
0040     class Q_DECL_HIDDEN LineDiagram::Private : public AbstractCartesianDiagram::Private
0041     {
0042         friend class LineDiagram;
0043         friend class LineDiagramType;
0044 
0045     public:
0046         Private();
0047         Private( const Private& rhs );
0048         ~Private() override;
0049 
0050         LineDiagramType* implementor; // the current type
0051         LineDiagramType* normalDiagram;
0052         LineDiagramType* stackedDiagram;
0053         LineDiagramType* percentDiagram;
0054         bool centerDataPoints;
0055         bool reverseDatasetOrder;
0056     };
0057 
0058     KCHART_IMPL_DERIVED_DIAGRAM( LineDiagram, AbstractCartesianDiagram, CartesianCoordinatePlane )
0059 
0060     class LineDiagram::LineDiagramType
0061     {
0062     public:
0063         explicit LineDiagramType( LineDiagram* d )
0064             : m_private( d->d_func() )
0065         {
0066         }
0067         virtual ~LineDiagramType() {}
0068         virtual LineDiagram::LineType type() const = 0;
0069         virtual const QPair<QPointF,  QPointF> calculateDataBoundaries() const = 0;
0070         virtual void paint( PaintContext* ctx ) = 0;
0071         LineDiagram* diagram() const;
0072 
0073     protected:
0074         // make some elements of m_private available to derived classes:
0075         AttributesModel* attributesModel() const;
0076         QModelIndex attributesModelRootIndex() const;
0077         ReverseMapper& reverseMapper();
0078         CartesianDiagramDataCompressor& compressor() const;
0079 
0080         qreal interpolateMissingValue( const CartesianDiagramDataCompressor::CachePosition& pos ) const;
0081 
0082         int datasetDimension() const;
0083 
0084         qreal valueForCell( int row, int column ) const;
0085 
0086         LineDiagram::Private* m_private;
0087     };
0088 }
0089 
0090 #endif /* KCHARTLINEDIAGRAM_P_H */