Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

KDChartAbstractDiagram.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2006 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Chart library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Chart licenses may use this file in
00012  ** accordance with the KD Chart Commercial License Agreement provided with
00013  ** the Software.
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  ** See http://www.kdab.net/kdchart for
00019  **   information about KDChart Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 
00026 #ifndef KDCHARTABSTRACTDIAGRAM_H
00027 #define KDCHARTABSTRACTDIAGRAM_H
00028 
00029 #include <QList>
00030 #include <QRectF>
00031 #include <QAbstractItemView>
00032 
00033 #include "KDChartGlobal.h"
00034 #include "KDChartMarkerAttributes.h"
00035 
00036 
00037 namespace KDChart {
00038 
00039     class AbstractCoordinatePlane;
00040     class AttributesModel;
00041     class DataValueAttributes;
00042     class PaintContext;
00043 
00053     class KDCHART_EXPORT AbstractDiagram : public QAbstractItemView
00054     {
00055         Q_OBJECT
00056         Q_DISABLE_COPY( AbstractDiagram )
00057         KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC( AbstractDiagram )
00058 
00059     friend class AbstractCoordinatePlane;
00060     friend class CartesianCoordinatePlane;
00061     friend class PolarCoordinatePlane;
00062 
00063     protected:
00064         explicit inline AbstractDiagram(
00065             Private *p, QWidget* parent, AbstractCoordinatePlane* plane );
00066         explicit AbstractDiagram (
00067             QWidget* parent = 0, AbstractCoordinatePlane* plane = 0 );
00068     public:
00069         virtual ~AbstractDiagram();
00070 
00071 
00075         bool compare( const AbstractDiagram* other )const;
00076 
00077 
00092         const QPair<QPointF, QPointF> dataBoundaries() const;
00093 
00094         // protected: // FIXME: why should that be private? (Mirko)
00101         virtual void paint ( PaintContext* paintContext ) = 0;
00102 
00103     public:
00110         virtual void resize ( const QSizeF& area ) = 0;
00111 
00113         virtual void setModel ( QAbstractItemModel * model );
00114 
00143         virtual void setAttributesModel( AttributesModel* model );
00144 
00151         virtual bool usesExternalAttributesModel()const;
00152 
00163         virtual AttributesModel* attributesModel() const;
00164 
00167         virtual void setRootIndex ( const QModelIndex& idx );
00168 
00170         virtual QRect visualRect(const QModelIndex &index) const;
00172         virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
00174         virtual QModelIndex indexAt(const QPoint &point) const;
00176         virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
00178         virtual int horizontalOffset() const;
00180         virtual int verticalOffset() const;
00182         virtual bool isIndexHidden(const QModelIndex &index) const;
00184         virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
00186         virtual QRegion visualRegionForSelection(const QItemSelection &selection) const;
00188         virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
00190         virtual void doItemsLayout();
00191 
00198         AbstractCoordinatePlane* coordinatePlane() const;
00199 
00206         virtual void setCoordinatePlane( AbstractCoordinatePlane* plane );
00207 
00208 
00221         void setHidden( const QModelIndex & index, bool hidden );
00222 
00235         void setHidden( int column, bool hidden );
00236 
00248         void setHidden( bool hidden );
00249 
00256         bool isHidden() const;
00257 
00265         bool isHidden( int column ) const;
00266 
00274         bool isHidden( const QModelIndex & index ) const;
00275 
00276 
00282         void setDataValueAttributes( const QModelIndex & index,
00283                                      const DataValueAttributes & a );
00284 
00290         void setDataValueAttributes( int dataset, const DataValueAttributes & a );
00291 
00296         void setDataValueAttributes( const DataValueAttributes & a );
00297 
00304         DataValueAttributes dataValueAttributes() const;
00305 
00313         DataValueAttributes dataValueAttributes( int column ) const;
00314 
00322         DataValueAttributes dataValueAttributes( const QModelIndex & index ) const;
00323 
00329         void setPen( const QModelIndex& index, const QPen& pen );
00330 
00336         void setPen( int dataset, const QPen& pen );
00337 
00342         void setPen( const QPen& pen );
00343 
00350         QPen pen() const;
00358         QPen pen( int dataset ) const;
00365         QPen pen( const QModelIndex& index ) const;
00366 
00372         void setBrush( const QModelIndex& index, const QBrush& brush);
00373 
00379         void setBrush( int dataset, const QBrush& brush );
00380 
00385         void setBrush( const QBrush& brush);
00386 
00393         QBrush brush() const;
00401         QBrush brush( int dataset ) const;
00408         QBrush brush( const QModelIndex& index ) const;
00409 
00414         void setAllowOverlappingDataValueTexts( bool allow );
00415 
00419         bool allowOverlappingDataValueTexts() const;
00420 
00426         void setAntiAliasing( bool enabled );
00427 
00432         bool antiAliasing() const;
00433 
00440         void useDefaultColors();
00441 
00447         void useRainbowColors();
00448 
00454         void useSubduedColors();
00455 
00460         QStringList itemRowLabels() const;
00461 
00466         QStringList datasetLabels() const;
00467 
00477         QList<QBrush> datasetBrushes() const;
00478 
00488         QList<QPen> datasetPens() const;
00489 
00499         QList<MarkerAttributes> datasetMarkers() const;
00500 
00501 
00502         // configure the ordinate in percent mode - values 0 to 100
00503         void setPercentMode( bool percent );
00504         bool percentMode() const;
00505 
00506         virtual void paintMarker( QPainter* painter,
00507                                   const MarkerAttributes& markerAttributes,
00508                                   const QBrush& brush, const QPen&,
00509                                   const QPointF& point, const QSizeF& size );
00510 
00525         int datasetDimension() const;
00526 
00532         void setDatasetDimension( int dimension );
00533 
00534         void update() const;
00535 
00536         void paintMarker( QPainter* painter, const QModelIndex& index,
00537                           const QPointF& pos );
00538         void paintDataValueText( QPainter* painter, const QModelIndex& index,
00539                                  const QPointF& pos, double value );
00540 
00541     protected:
00542         virtual bool checkInvariants( bool justReturnTheStatus=false ) const;
00543         virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const = 0;
00544         void setDataBoundariesDirty() const;
00545         virtual void paintDataValueTexts( QPainter* painter );
00546         virtual void paintMarkers( QPainter* painter );
00547         void setAttributesModelRootIndex( const QModelIndex& );
00548         QModelIndex attributesModelRootIndex() const;
00549         QModelIndex columnToIndex( int column ) const;
00556         double valueForCell( int row, int column ) const;
00557 
00558     Q_SIGNALS:
00567         void layoutChanged( AbstractDiagram* );
00568 
00570         void modelsChanged();
00571 
00573         void dataHidden();
00574 
00576         void propertiesChanged();
00577 
00578     private:
00579         QString roundValues( double value, const int decimalPos,
00580                               const int decimalDigits ) const;
00581 
00582     };
00583 
00584     typedef QList<AbstractDiagram*> AbstractDiagramList;
00585     typedef QList<const AbstractDiagram*> ConstAbstractDiagramList;
00586 
00587 }
00588 
00589 #endif

Generated on Thu May 10 11:06:24 2007 for KD Chart 2 by doxygen 1.3.6