KDChartAbstractCoordinatePlane.h

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2007 Klaralvdalens 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 
00047     class KDCHART_EXPORT AbstractCoordinatePlane : public AbstractArea
00048     {
00049         Q_OBJECT
00050 
00051         Q_DISABLE_COPY( AbstractCoordinatePlane )
00052         KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( AbstractCoordinatePlane, Chart* )
00053 
00054     friend class AbstractGrid;
00055 
00056     public:
00057         enum AxesCalcMode { Linear, Logarithmic };
00058 
00059     protected:
00060         explicit AbstractCoordinatePlane ( Chart* parent = 0 );
00061 
00062     public:
00063         virtual ~AbstractCoordinatePlane();
00064 
00071         virtual void addDiagram ( AbstractDiagram* diagram );
00072 
00090         virtual void replaceDiagram ( AbstractDiagram* diagram, AbstractDiagram* oldDiagram = 0 );
00091 
00100         virtual void takeDiagram( AbstractDiagram* diagram );
00101 
00105         AbstractDiagram* diagram();
00106 
00110         AbstractDiagramList diagrams();
00111 
00115         ConstAbstractDiagramList diagrams() const;
00116 
00120         virtual void layoutDiagrams() = 0;
00121 
00128         virtual const QPointF translate ( const QPointF& diagramPoint ) const = 0;
00129 
00131         virtual QSize minimumSizeHint() const;
00133         virtual QSizePolicy sizePolicy() const;
00134 
00138         bool isRubberBandZoomingEnabled() const;
00139 
00143         void setRubberBandZoomingEnabled( bool enable );
00144 
00149         virtual double zoomFactorX() const { return 1.0; }
00150 
00155         virtual double zoomFactorY() const { return 1.0; }
00156 
00162         virtual void setZoomFactorX( double  factor ) { Q_UNUSED( factor ); }
00163 
00169         virtual void setZoomFactorY( double factor ) { Q_UNUSED( factor ); }
00170 
00175         virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
00176 
00182         virtual void setZoomCenter( const QPointF& center ) { Q_UNUSED( center ); }
00183 
00195         void setGlobalGridAttributes( const GridAttributes & );
00196 
00202         GridAttributes globalGridAttributes() const;
00203 
00222         DataDimensionsList gridDimensionsList();
00223 
00231         void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
00232 
00248         AbstractCoordinatePlane * referenceCoordinatePlane() const;
00249 
00250         virtual AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00251 
00252 
00254         virtual bool isEmpty() const;
00256         virtual Qt::Orientations expandingDirections() const;
00258         virtual QSize maximumSize() const;
00260         virtual QSize minimumSize() const;
00262         virtual QSize sizeHint() const;
00269         virtual void setGeometry( const QRect& r );
00271         virtual QRect geometry() const;
00272 
00273         void mousePressEvent( QMouseEvent* event );
00274         void mouseDoubleClickEvent( QMouseEvent* event );
00275         void mouseMoveEvent( QMouseEvent* event );
00276         void mouseReleaseEvent( QMouseEvent* event );
00277 
00281         void setParent( Chart* parent );
00282         Chart* parent();
00283         const Chart* parent() const;
00284 
00290         const bool isVisiblePoint( const QPointF& point ) const;
00291 
00292     public Q_SLOTS:
00296         void update();
00300         void relayout();
00304         void layoutPlanes();
00308         void setGridNeedsRecalculate();
00309 
00310     Q_SIGNALS:
00312         void destroyedCoordinatePlane( AbstractCoordinatePlane* );
00313 
00315         void needUpdate();
00316 
00318         void needRelayout();
00319 
00321         void needLayoutPlanes();
00322 
00324         void propertiesChanged();
00325 
00326     protected:
00327         virtual DataDimensionsList getDataDimensionsList() const = 0;
00328 
00329         //KDCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
00330     };
00331 
00348     class DataDimension{
00349     public:
00350         DataDimension()
00351             : start(         1.0 )
00352             , end(          10.0 )
00353             , isCalculated( false )
00354             , calcMode( AbstractCoordinatePlane::Linear )
00355             , sequence( KDChartEnums::GranularitySequence_10_20 )
00356             , stepWidth(    1.0 )
00357             , subStepWidth( 0.0 )
00358         {}
00359         DataDimension( qreal start_,
00360                        qreal end_,
00361                        bool isCalculated_,
00362                        AbstractCoordinatePlane::AxesCalcMode calcMode_,
00363                        KDChartEnums::GranularitySequence sequence_,
00364                        qreal stepWidth_=0.0,
00365                        qreal subStepWidth_=0.0 )
00366             : start(        start_ )
00367             , end(          end_ )
00368             , isCalculated( isCalculated_ )
00369             , calcMode(     calcMode_ )
00370             , sequence(     sequence_ )
00371             , stepWidth(    stepWidth_ )
00372             , subStepWidth( subStepWidth_ )
00373         {}
00381         qreal distance() const
00382         {
00383             return end-start;
00384         }
00385 
00386         bool operator==( const DataDimension& r ) const
00387         {
00388             return
00389                 (start        == r.start) &&
00390                 (end          == r.end) &&
00391                 (sequence     == r.sequence) &&
00392                 (isCalculated == r.isCalculated) &&
00393                 (calcMode     == r.calcMode) &&
00394                 (stepWidth    == r.stepWidth) &&
00395                 (subStepWidth    == r.subStepWidth);
00396         }
00397 
00398         bool operator!=( const DataDimension& other ) const
00399         { return !operator==( other ); }
00400 
00401 
00402         qreal start;
00403         qreal end;
00404         bool  isCalculated;
00405         AbstractCoordinatePlane::AxesCalcMode calcMode;
00406         KDChartEnums::GranularitySequence sequence;
00407         qreal stepWidth;
00408         qreal subStepWidth;
00409     };
00410 
00411 #if !defined(QT_NO_DEBUG_STREAM)
00412     QDebug operator<<( QDebug stream, const DataDimension& r );
00413 #endif
00414 
00415 }
00416 #endif

Generated on Mon Sep 17 16:16:49 2007 for KD Chart 2 by  doxygen 1.5.1