# KDChartLineDiagram.h

Go to the documentation of this file.

    00001 /* -*- Mode: C++ -*-
    00002    KDChart - a multi-platform charting engine
    00003    */
    00004
    00005 /****************************************************************************
    00006  ** Copyright (C) 2005-2006 Klarälvdalens Datakonsult AB.  All rights reserved.
    00007  **
    00008  ** This file is part of the KD Chart library.
    00009  **
    00010  ** This file may be distributed and/or modified under the terms of the
    00011  ** GNU General Public License version 2 as published by the Free Software
    00012  ** Foundation and appearing in the file LICENSE.GPL included in the
    00013  ** packaging of this file.
    00014  **
    00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
    00016  ** accordance with the KD Chart Commercial License Agreement provided with
    00017  ** the Software.
    00018  **
    00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    00021  **
    00022  ** See http://www.kdab.net/kdchart for
    00023  **   information about KD Chart Commercial License Agreements.
    00024  **
    00025  ** Contact info@kdab.net if any conditions of this
    00026  ** licensing are not clear to you.
    00027  **
    00028  **********************************************************************/
    00029
    00030 #ifndef KDCHARTLINEDIAGRAM_H
    00031 #define KDCHARTLINEDIAGRAM_H
    00032
    00033 #include "KDChartAbstractCartesianDiagram.h"
    00034 #include "KDChartLineAttributes.h"
    00035
    00036 class QPainter;
    00037 class QPolygonF;
    00038
    00039 namespace KDChart {
    00040
    00041     class ThreeDLineAttributes;
    00042
    00043 class KDCHART_EXPORT LineDiagram : public AbstractCartesianDiagram
    00044 {
    00045     Q_OBJECT
    00046
    00047     Q_DISABLE_COPY( LineDiagram )
    00048 //    KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( LineDiagram, CartesianCoordinatePlane * )
    00049     KDCHART_DECLARE_DERIVED_DIAGRAM( LineDiagram, CartesianCoordinatePlane )
    00050
    00051 public:
    00052     LineDiagram( QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 );
    00053     virtual ~LineDiagram();
    00054
    00055     virtual LineDiagram * clone() const;
    00056
    00060     bool compare( const LineDiagram* other )const;
    00061
    00062     enum LineType {
    00063         Normal =  0,
    00064         Stacked = 1,
    00065         Percent = 2
    00066     };
    00067
    00068
    00069     void setType( const LineType type );
    00070     LineType type() const;
    00071
    00072     void setLineAttributes( const LineAttributes & a );
    00073     void setLineAttributes( int column, const LineAttributes & a );
    00074     void setLineAttributes( const QModelIndex & index, const LineAttributes & a );
    00075     void resetLineAttributes( int column );
    00076     void resetLineAttributes( const QModelIndex & index );
    00077     LineAttributes lineAttributes() const;
    00078     LineAttributes lineAttributes( int column ) const;
    00079     LineAttributes lineAttributes( const QModelIndex & index ) const;
    00080
    00081     void setThreeDLineAttributes( const ThreeDLineAttributes & a );
    00082     void setThreeDLineAttributes( int column, const ThreeDLineAttributes & a );
    00083     void setThreeDLineAttributes( const QModelIndex & index,
    00084                                   const ThreeDLineAttributes & a );
    00085
    00086     //FIXME(khz): big TODO(khz): add a lot of reset...Attributes() methods to all
    00087     // appropriate places, for 2.1 (that is: after we have release 2.0.2)  :-)
    00088
    00089     ThreeDLineAttributes threeDLineAttributes() const;
    00090     ThreeDLineAttributes threeDLineAttributes( int column ) const;
    00091     ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const;
    00092
    00093     // implement AbstractCartesianDiagram
    00094     /* reimpl */
    00095     const int numberOfAbscissaSegments () const;
    00096     /* reimpl */
    00097     const int numberOfOrdinateSegments () const;
    00098
    00099 protected:
    00100     void paint ( PaintContext* paintContext );
    00101
    00102 public:
    00103     void resize ( const QSizeF& area );
    00104
    00105 protected:
    00106     double valueForCellTesting( int row, int column,
    00107                                 bool& bOK,
    00108                                 bool showHiddenCellsAsInvalid = false ) const;
    00109     LineAttributes::MissingValuesPolicy getCellValues(
    00110         int row, int column,
    00111         bool shiftCountedXValuesByHalfSection,
    00112         double& valueX, double& valueY ) const;
    00113
    00114     virtual double threeDItemDepth( const QModelIndex & index ) const;
    00115     virtual double threeDItemDepth( int column ) const;
    00117     virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
    00118     void paintEvent ( QPaintEvent* );
    00119     void resizeEvent ( QResizeEvent* );
    00120
    00121 private:
    00122     void paintPolyline( PaintContext* ctx,
    00123                         const QBrush& brush, const QPen& pen,
    00124                         const QPolygonF& points ) const;
    00125     const QPointF project( QPointF point, QPointF maxLimits, double z, const QModelIndex& index ) const;
    00126     void paintThreeDLines( PaintContext* painter,const QModelIndex& index,
    00127                            const QPointF& from, const QPointF& to, const double depth );
    00128     void paintAreas( PaintContext* painter, const QModelIndex& index,
    00129                      const QPolygonF& area, const uint transparency );
    00130     void paintAreas( PaintContext* ctx, const QModelIndex& index,
    00131                      const QList<QPolygonF>& areas, const uint transparency );
    00132 }; // End of class KDChartLineDiagram
    00133
    00134 }
    00135
    00136 #endif // KDCHARTLINEDIAGRAM_H