KD Chart 2: KDChartAbstractCoordinatePlane.h Source File

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

# KDChartAbstractCoordinatePlane.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 KDCHARTABSTRCOORDINATEPLANE_H
    00027 #define KDCHARTABSTRCOORDINATEPLANE_H
    00028
    00029 #include <QObject>
    00030 #include <QList>
    00031
    00032 #include "KDChartAbstractArea.h"
    00033 #include "KDChartAbstractDiagram.h"
    00034 #include "KDChartEnums.h"
    00035
    00036 namespace KDChart {
    00037
    00038     class Chart;
    00039     class GridAttributes;
    00040     class DataDimension;
    00041
    00042     typedef QList<DataDimension> DataDimensionsList;
    00043
    00044
    00045     class KDCHART_EXPORT AbstractCoordinatePlane : public AbstractArea
    00046     {
    00047         Q_OBJECT
    00048
    00049         Q_DISABLE_COPY( AbstractCoordinatePlane )
    00050         KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( AbstractCoordinatePlane, Chart* )
    00051
    00052     friend class AbstractGrid;
    00053
    00054     public:
    00055         enum AxesCalcMode { Linear, Logarithmic };
    00056
    00057     protected:
    00058         explicit AbstractCoordinatePlane ( Chart* parent = 0 );
    00059
    00060     public:
    00061         virtual ~AbstractCoordinatePlane();
    00062
    00069         virtual void addDiagram ( AbstractDiagram* diagram );
    00070
    00088         virtual void replaceDiagram ( AbstractDiagram* diagram, AbstractDiagram* oldDiagram = 0 );
    00089
    00098         virtual void takeDiagram( AbstractDiagram* diagram );
    00099
    00103         AbstractDiagram* diagram();
    00104
    00108         AbstractDiagramList diagrams();
    00109
    00113         ConstAbstractDiagramList diagrams() const;
    00114
    00118         virtual void layoutDiagrams() = 0;
    00119
    00126         virtual const QPointF translate ( const QPointF& diagramPoint ) const = 0;
    00127
    00129         virtual QSize minimumSizeHint() const;
    00131         virtual QSizePolicy sizePolicy() const;
    00132
    00137         virtual double zoomFactorX() const { return 1.0; }
    00138
    00143         virtual double zoomFactorY() const { return 1.0; }
    00144
    00149         virtual void setZoomFactorX( double /* factor */ ) {}
    00150
    00155         virtual void setZoomFactorY( double /* factor */ ) {}
    00156
    00161         virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
    00162
    00168         virtual void setZoomCenter( QPointF /* center */ ) {}
    00169
    00181         void setGlobalGridAttributes( const GridAttributes & );
    00182
    00188         GridAttributes globalGridAttributes() const;
    00189
    00208         DataDimensionsList gridDimensionsList();
    00209
    00217         void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
    00218
    00234         AbstractCoordinatePlane * referenceCoordinatePlane() const;
    00235
    00237         virtual bool isEmpty() const;
    00239         virtual Qt::Orientations expandingDirections() const;
    00241         virtual QSize maximumSize() const;
    00243         virtual QSize minimumSize() const;
    00245         virtual QSize sizeHint() const;
    00252         virtual void setGeometry( const QRect& r );
    00254         virtual QRect geometry() const;
    00255
    00257         void mousePressEvent( QMouseEvent* event );
    00258
    00262         void setParent( Chart* parent );
    00263         Chart* parent();
    00264         const Chart* parent() const;
    00265
    00271         const bool isVisiblePoint( const QPointF& point ) const;
    00272
    00273     public Q_SLOTS:
    00277         void update();
    00281         void relayout();
    00285         void layoutPlanes();
    00289         void setGridNeedsRecalculate();
    00290
    00291     Q_SIGNALS:
    00293         void destroyedCoordinatePlane( AbstractCoordinatePlane* );
    00294
    00296         void needUpdate();
    00297
    00299         void needRelayout();
    00300
    00302         void needLayoutPlanes();
    00303
    00305         void propertiesChanged();
    00306
    00307     protected:
    00308         virtual DataDimensionsList getDataDimensionsList() const = 0;
    00309
    00310         //KDCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
    00311     };
    00312
    00329     class DataDimension{
    00330     public:
    00331         DataDimension()
    00332             : start(         1.0 )
    00333             , end(          10.0 )
    00334             , isCalculated( false )
    00335             , calcMode( AbstractCoordinatePlane::Linear )
    00336             , sequence( KDChartEnums::GranularitySequence_10_20 )
    00337             , stepWidth(    1.0 )
    00338             , subStepWidth( 0.0 )
    00339         {}
    00340         DataDimension( qreal start_,
    00341                        qreal end_,
    00342                        bool isCalculated_,
    00343                        AbstractCoordinatePlane::AxesCalcMode calcMode_,
    00344                        KDChartEnums::GranularitySequence sequence_,
    00345                        qreal stepWidth_=0.0,
    00346                        qreal subStepWidth_=0.0 )
    00347             : start(        start_ )
    00348             , end(          end_ )
    00349             , isCalculated( isCalculated_ )
    00350             , calcMode(     calcMode_ )
    00351             , sequence(     sequence_ )
    00352             , stepWidth(    stepWidth_ )
    00353             , subStepWidth( subStepWidth_ )
    00354         {}
    00362         qreal distance() const
    00363         {
    00364             return end-start;
    00365         }
    00366
    00367         bool operator==( const DataDimension& r ) const
    00368         {
    00369             return
    00370                 (start        == r.start) &&
    00371                 (end          == r.end) &&
    00372                 (sequence     == r.sequence) &&
    00373                 (isCalculated == r.isCalculated) &&
    00374                 (calcMode     == r.calcMode) &&
    00375                 (stepWidth    == r.stepWidth) &&
    00376                 (subStepWidth    == r.subStepWidth);
    00377         }
    00378
    00379         bool operator!=( const DataDimension& other ) const
    00380         { return !operator==( other ); }
    00381
    00382         qreal start;
    00383         qreal end;
    00384         bool  isCalculated;
    00385         AbstractCoordinatePlane::AxesCalcMode calcMode;
    00386         KDChartEnums::GranularitySequence sequence;
    00387         qreal stepWidth;
    00388         qreal subStepWidth;
    00389     };
    00390
    00391 }
    00392
    00393 #endif