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 KDCHARTABSTRACTCOORDINATEPLANE_H
00027 #define KDCHARTABSTRACTCOORDINATEPLANE_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 
00161         virtual void setZoomFactors( double factorX, double factorY ) { Q_UNUSED( factorX ); Q_UNUSED( factorY ); }
00162 
00168         virtual void setZoomFactorX( double  factor ) { Q_UNUSED( factor ); }
00169 
00175         virtual void setZoomFactorY( double factor ) { Q_UNUSED( factor ); }
00176 
00181         virtual QPointF zoomCenter() const { return QPointF(0.0, 0.0); }
00182 
00188         virtual void setZoomCenter( const QPointF& center ) { Q_UNUSED( center ); }
00189 
00201         void setGlobalGridAttributes( const GridAttributes & );
00202 
00208         GridAttributes globalGridAttributes() const;
00209 
00228         DataDimensionsList gridDimensionsList();
00229 
00237         void setReferenceCoordinatePlane( AbstractCoordinatePlane * plane );
00238 
00254         AbstractCoordinatePlane * referenceCoordinatePlane() const;
00255 
00256         virtual AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00257 
00258 
00260         virtual bool isEmpty() const;
00262         virtual Qt::Orientations expandingDirections() const;
00264         virtual QSize maximumSize() const;
00266         virtual QSize minimumSize() const;
00268         virtual QSize sizeHint() const;
00275         virtual void setGeometry( const QRect& r );
00277         virtual QRect geometry() const;
00278 
00279         void mousePressEvent( QMouseEvent* event );
00280         void mouseDoubleClickEvent( QMouseEvent* event );
00281         void mouseMoveEvent( QMouseEvent* event );
00282         void mouseReleaseEvent( QMouseEvent* event );
00283 
00287         void setParent( Chart* parent );
00288         Chart* parent();
00289         const Chart* parent() const;
00290 
00296 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00297         const bool isVisiblePoint( const QPointF& point ) const;
00298 #else
00299         bool isVisiblePoint( const QPointF& point ) const;
00300 #endif
00301 
00302     public Q_SLOTS:
00306         void update();
00310         void relayout();
00314         void layoutPlanes();
00318         void setGridNeedsRecalculate();
00319 
00320     Q_SIGNALS:
00322         void destroyedCoordinatePlane( AbstractCoordinatePlane* );
00323 
00325         void needUpdate();
00326 
00328         void needRelayout();
00329 
00331         void needLayoutPlanes();
00332 
00334         void propertiesChanged();
00335 
00341         void geometryChanged( QRect, QRect );
00342 
00343     private:
00344     Q_SIGNALS:
00345         // Emitted from inside the setGeometry()
00346         // This is connected via QueuedConnection to the geometryChanged() Signal
00347         // that users can connect to safely then.
00348         void internal_geometryChanged( QRect, QRect );
00349 
00350     protected:
00351         virtual DataDimensionsList getDataDimensionsList() const = 0;
00352 
00353         //KDCHART_DECLARE_PRIVATE_DERIVED( AbstractCoordinatePlane )
00354     };
00355 
00372     class DataDimension{
00373     public:
00374         DataDimension()
00375             : start(         1.0 )
00376             , end(          10.0 )
00377             , isCalculated( false )
00378             , calcMode( AbstractCoordinatePlane::Linear )
00379             , sequence( KDChartEnums::GranularitySequence_10_20 )
00380             , stepWidth(    1.0 )
00381             , subStepWidth( 0.0 )
00382         {}
00383         DataDimension( qreal start_,
00384                        qreal end_,
00385                        bool isCalculated_,
00386                        AbstractCoordinatePlane::AxesCalcMode calcMode_,
00387                        KDChartEnums::GranularitySequence sequence_,
00388                        qreal stepWidth_=0.0,
00389                        qreal subStepWidth_=0.0 )
00390             : start(        start_ )
00391             , end(          end_ )
00392             , isCalculated( isCalculated_ )
00393             , calcMode(     calcMode_ )
00394             , sequence(     sequence_ )
00395             , stepWidth(    stepWidth_ )
00396             , subStepWidth( subStepWidth_ )
00397         {}
00405         qreal distance() const
00406         {
00407             return end-start;
00408         }
00409 
00410         bool operator==( const DataDimension& r ) const
00411         {
00412             return
00413                 (start        == r.start) &&
00414                 (end          == r.end) &&
00415                 (sequence     == r.sequence) &&
00416                 (isCalculated == r.isCalculated) &&
00417                 (calcMode     == r.calcMode) &&
00418                 (stepWidth    == r.stepWidth) &&
00419                 (subStepWidth    == r.subStepWidth);
00420         }
00421 
00422         bool operator!=( const DataDimension& other ) const
00423         { return !operator==( other ); }
00424 
00425 
00426         qreal start;
00427         qreal end;
00428         bool  isCalculated;
00429         AbstractCoordinatePlane::AxesCalcMode calcMode;
00430         KDChartEnums::GranularitySequence sequence;
00431         qreal stepWidth;
00432         qreal subStepWidth;
00433     };
00434 
00435 #if !defined(QT_NO_DEBUG_STREAM)
00436     QDebug operator<<( QDebug stream, const DataDimension& r );
00437 #endif
00438 
00439 }
00440 #endif

Generated on Thu Mar 4 23:19:09 2010 for KD Chart 2 by  doxygen 1.5.4