KDChartAbstractCoordinatePlane.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2011 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.txt 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 KDCHARTABSTRACTCOORDINATEPLANE_H
00024 #define KDCHARTABSTRACTCOORDINATEPLANE_H
00025 
00026 #include <QObject>
00027 #include <QList>
00028 
00029 #include "KDChartAbstractArea.h"
00030 #include "KDChartAbstractDiagram.h"
00031 #include "KDChartEnums.h"
00032 
00033 namespace KDChart {
00034 
00035     class Chart;
00036     class GridAttributes;
00037     class DataDimension;
00038 
00039     typedef QList<DataDimension> DataDimensionsList;
00040 
00044     class KDCHART_EXPORT AbstractCoordinatePlane : public AbstractArea
00045     {
00046         Q_OBJECT
00047 
00048         Q_DISABLE_COPY( AbstractCoordinatePlane )
00049         KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( AbstractCoordinatePlane, Chart* )
00050 
00051     friend class AbstractGrid;
00052 
00053     public:
00054         enum AxesCalcMode { Linear, Logarithmic };
00055 
00056     protected:
00057         explicit AbstractCoordinatePlane ( Chart* parent = 0 );
00058 
00059     public:
00060         virtual ~AbstractCoordinatePlane();
00061 
00068         virtual void addDiagram ( AbstractDiagram* diagram );
00069 
00087         virtual void replaceDiagram ( AbstractDiagram* diagram, AbstractDiagram* oldDiagram = 0 );
00088 
00097         virtual void takeDiagram( AbstractDiagram* diagram );
00098 
00102         AbstractDiagram* diagram();
00103 
00107         AbstractDiagramList diagrams();
00108 
00112         ConstAbstractDiagramList diagrams() const;
00113 
00117         virtual void layoutDiagrams() = 0;
00118 
00125         virtual const QPointF translate ( const QPointF& diagramPoint ) const = 0;
00126 
00128         virtual QSize minimumSizeHint() const;
00130         virtual QSizePolicy sizePolicy() const;
00131 
00135         bool isRubberBandZoomingEnabled() const;
00136 
00140         void setRubberBandZoomingEnabled( bool enable );
00141 
00146         virtual double zoomFactorX() const { return 1.0; }
00147 
00152         virtual double zoomFactorY() const { return 1.0; }
00153 
00158         virtual void setZoomFactors( double factorX, double factorY ) { Q_UNUSED( factorX ); Q_UNUSED( factorY ); }
00159 
00165         virtual void setZoomFactorX( double  factor ) { Q_UNUSED( factor ); }
00166 
00172         virtual void setZoomFactorY( double factor ) { Q_UNUSED( factor ); }
00173 
00178         virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
00179 
00185         virtual void setZoomCenter( const QPointF& center ) { Q_UNUSED( center ); }
00186 
00198         void setGlobalGridAttributes( const GridAttributes & );
00199 
00205         GridAttributes globalGridAttributes() const;
00206 
00225         DataDimensionsList gridDimensionsList();
00226 
00234         void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
00235 
00251         AbstractCoordinatePlane * referenceCoordinatePlane() const;
00252 
00253         virtual AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00254 
00255 
00257         virtual bool isEmpty() const;
00259         virtual Qt::Orientations expandingDirections() const;
00261         virtual QSize maximumSize() const;
00263         virtual QSize minimumSize() const;
00265         virtual QSize sizeHint() const;
00272         virtual void setGeometry( const QRect& r );
00274         virtual QRect geometry() const;
00275 
00276         virtual void mousePressEvent( QMouseEvent* event );
00277         virtual void mouseDoubleClickEvent( QMouseEvent* event );
00278         virtual void mouseMoveEvent( QMouseEvent* event );
00279         virtual void mouseReleaseEvent( QMouseEvent* event );
00280 
00284         void setParent( Chart* parent );
00285         Chart* parent();
00286         const Chart* parent() const;
00287 
00293 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00294         const bool isVisiblePoint( const QPointF& point ) const;
00295 #else
00296         bool isVisiblePoint( const QPointF& point ) const;
00297 #endif
00298 
00299     public Q_SLOTS:
00303         void update();
00307         void relayout();
00311         void layoutPlanes();
00315         void setGridNeedsRecalculate();
00316 
00317     Q_SIGNALS:
00319         void destroyedCoordinatePlane( AbstractCoordinatePlane* );
00320 
00322         void needUpdate();
00323 
00325         void needRelayout();
00326 
00328         void needLayoutPlanes();
00329 
00331         void propertiesChanged();
00332 
00338         void geometryChanged( QRect, QRect );
00339 
00340     private:
00341     Q_SIGNALS:
00342         // Emitted from inside the setGeometry()
00343         // This is connected via QueuedConnection to the geometryChanged() Signal
00344         // that users can connect to safely then.
00345         void internal_geometryChanged( QRect, QRect );
00346 
00347     protected:
00348         virtual DataDimensionsList getDataDimensionsList() const = 0;
00349 
00350         //KDCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
00351     };
00352 
00369     class DataDimension{
00370     public:
00371         DataDimension()
00372             : start(         1.0 )
00373             , end(          10.0 )
00374             , isCalculated( false )
00375             , calcMode( AbstractCoordinatePlane::Linear )
00376             , sequence( KDChartEnums::GranularitySequence_10_20 )
00377             , stepWidth(    1.0 )
00378             , subStepWidth( 0.0 )
00379         {}
00380         DataDimension( qreal start_,
00381                        qreal end_,
00382                        bool isCalculated_,
00383                        AbstractCoordinatePlane::AxesCalcMode calcMode_,
00384                        KDChartEnums::GranularitySequence sequence_,
00385                        qreal stepWidth_=0.0,
00386                        qreal subStepWidth_=0.0 )
00387             : start(        start_ )
00388             , end(          end_ )
00389             , isCalculated( isCalculated_ )
00390             , calcMode(     calcMode_ )
00391             , sequence(     sequence_ )
00392             , stepWidth(    stepWidth_ )
00393             , subStepWidth( subStepWidth_ )
00394         {}
00402         qreal distance() const
00403         {
00404             return end-start;
00405         }
00406 
00407         bool operator==( const DataDimension& r ) const
00408         {
00409             return
00410                 (start        == r.start) &&
00411                 (end          == r.end) &&
00412                 (sequence     == r.sequence) &&
00413                 (isCalculated == r.isCalculated) &&
00414                 (calcMode     == r.calcMode) &&
00415                 (stepWidth    == r.stepWidth) &&
00416                 (subStepWidth    == r.subStepWidth);
00417         }
00418 
00419         bool operator!=( const DataDimension& other ) const
00420         { return !operator==( other ); }
00421 
00422 
00423         qreal start;
00424         qreal end;
00425         bool  isCalculated;
00426         AbstractCoordinatePlane::AxesCalcMode calcMode;
00427         KDChartEnums::GranularitySequence sequence;
00428         qreal stepWidth;
00429         qreal subStepWidth;
00430     };
00431 
00432 #if !defined(QT_NO_DEBUG_STREAM)
00433     QDebug operator<<( QDebug stream, const DataDimension& r );
00434 #endif
00435 
00436 }
00437 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/