KDChartLineDiagram.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD Chart library.
00005 **
00006 ** Licensees holding valid commercial KD Chart licenses may use this file in
00007 ** accordance with the KD Chart Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef KDCHARTLINEDIAGRAM_H
00024 #define KDCHARTLINEDIAGRAM_H
00025 
00026 #include "KDChartAbstractCartesianDiagram.h"
00027 #include "KDChartLineAttributes.h"
00028 #include "KDChartValueTrackerAttributes.h"
00029 
00030 class QPainter;
00031 class QPolygonF;
00032 
00033 namespace KDChart {
00034 
00035     class ThreeDLineAttributes;
00036 
00042 class KDCHART_EXPORT LineDiagram : public AbstractCartesianDiagram
00043 {
00044     Q_OBJECT
00045 
00046     Q_DISABLE_COPY( LineDiagram )
00047 //    KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( LineDiagram, CartesianCoordinatePlane * )
00048 
00049     KDCHART_DECLARE_DERIVED_DIAGRAM( LineDiagram, CartesianCoordinatePlane )
00050 
00051 
00052 public:
00053     class LineDiagramType;
00054     friend class LineDiagramType;
00055 
00056     explicit LineDiagram( QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 );
00057     virtual ~LineDiagram();
00058 
00059     virtual LineDiagram * clone() const;
00060 
00064     bool compare( const LineDiagram* other ) const;
00065 
00066     enum LineType {
00067         Normal =  0,
00068         Stacked = 1,
00069         Percent = 2
00070     };
00071 
00072 
00073     void setType( const LineType type );
00074     LineType type() const;
00075 
00082     void setCenterDataPoints( bool center );
00084     bool centerDataPoints() const;
00085 
00091     void setReverseDatasetOrder( bool reverse );
00093     bool reverseDatasetOrder() const;
00094 
00095     void setLineAttributes( const LineAttributes & a );
00096     void setLineAttributes( int column, const LineAttributes & a );
00097     void setLineAttributes( const QModelIndex & index, const LineAttributes & a );
00098     void resetLineAttributes( int column );
00099     void resetLineAttributes( const QModelIndex & index );
00100     LineAttributes lineAttributes() const;
00101     LineAttributes lineAttributes( int column ) const;
00102     LineAttributes lineAttributes( const QModelIndex & index ) const;
00103 
00104     void setThreeDLineAttributes( const ThreeDLineAttributes & a );
00105     void setThreeDLineAttributes( int column, const ThreeDLineAttributes & a );
00106     void setThreeDLineAttributes( const QModelIndex & index,
00107                                   const ThreeDLineAttributes & a );
00108 
00109     //FIXME(khz): big TODO(khz): add a lot of reset...Attributes() methods to all
00110     // appropriate places, for 2.1 (that is: after we have release 2.0.2)  :-)
00111 
00112     ThreeDLineAttributes threeDLineAttributes() const;
00113     ThreeDLineAttributes threeDLineAttributes( int column ) const;
00114     ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const;
00115 
00116     void setValueTrackerAttributes( const QModelIndex & index,
00117                                     const ValueTrackerAttributes & a );
00118     ValueTrackerAttributes valueTrackerAttributes( const QModelIndex & index ) const;
00119 
00120 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00121     // implement AbstractCartesianDiagram
00122     /* reimpl */
00123     const int numberOfAbscissaSegments () const;
00124     /* reimpl */
00125     const int numberOfOrdinateSegments () const;
00126 #else
00127     // implement AbstractCartesianDiagram
00128     /* reimpl */
00129     int numberOfAbscissaSegments () const;
00130     /* reimpl */
00131     int numberOfOrdinateSegments () const;
00132 #endif
00133 
00134 protected:
00135     void paint ( PaintContext* paintContext );
00136 
00137 public:
00138     void resize ( const QSizeF& area );
00139 
00140 protected:
00141     // FIXME what does that mean?
00142     double valueForCellTesting( int row, int column,
00143                                 bool& bOK,
00144                                 bool showHiddenCellsAsInvalid = false ) const;
00145     LineAttributes::MissingValuesPolicy getCellValues(
00146         int row, int column,
00147         bool shiftCountedXValuesByHalfSection,
00148         double& valueX, double& valueY ) const;
00149 
00150     virtual double threeDItemDepth( const QModelIndex & index ) const;
00151     virtual double threeDItemDepth( int column ) const;
00153     virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
00154     void paintEvent ( QPaintEvent* );
00155     void resizeEvent ( QResizeEvent* );
00156 }; // End of class KDChartLineDiagram
00157 
00158 }
00159 
00160 #endif // KDCHARTLINEDIAGRAM_H