KDChartCartesianCoordinatePlane.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 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 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 KDCHARTCARTESIANCOORDINATEPLANE_H
00024 #define KDCHARTCARTESIANCOORDINATEPLANE_H
00025 
00026 #include "KDChartAbstractCoordinatePlane.h"
00027 
00028 namespace KDChart {
00029 
00030     class Chart;
00031     class PaintContext;
00032     class AbstractDiagram;
00033     class CartesianAxis;
00034     class CartesianGrid;
00035 
00039     class KDCHART_EXPORT CartesianCoordinatePlane : public AbstractCoordinatePlane
00040     {
00041         Q_OBJECT
00042 
00043         Q_DISABLE_COPY( CartesianCoordinatePlane )
00044         KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( CartesianCoordinatePlane, Chart* )
00045 
00046     friend class CartesianAxis;
00047     friend class CartesianGrid;
00048 
00049     public:
00050         explicit CartesianCoordinatePlane ( Chart* parent = 0 );
00051         ~CartesianCoordinatePlane();
00052 
00053         void addDiagram ( AbstractDiagram* diagram );
00054 
00055         void setIsometricScaling ( bool onOff );
00056 
00057         bool doesIsometricScaling() const;
00058 
00059         const QPointF translate ( const QPointF& diagramPoint ) const;
00060 
00064         virtual double zoomFactorX() const;
00068         virtual double zoomFactorY() const;
00069 
00073         virtual void setZoomFactors( double factorX, double factorY );
00077         virtual void setZoomFactorX( double factor );
00081         virtual void setZoomFactorY( double factor );
00082 
00086         virtual QPointF zoomCenter() const;
00087 
00091         virtual void setZoomCenter( const QPointF& center );
00092 
00102         void setFixedDataCoordinateSpaceRelation( bool fixed );
00103         bool hasFixedDataCoordinateSpaceRelation() const;
00104 
00112         void setXAxisStartAtZero(bool fixedStart);
00113         bool xAxisStartAtZero() const;
00114 
00146         void setHorizontalRange( const QPair<qreal, qreal> & range );
00147 
00179         void setVerticalRange( const QPair<qreal, qreal> & range );
00180 
00188         QPair<qreal, qreal> horizontalRange() const;
00189 
00197         QPair<qreal, qreal> verticalRange() const;
00198 
00219         void setAutoAdjustHorizontalRangeToData( unsigned int percentEmpty = 67 );
00220 
00241         void setAutoAdjustVerticalRangeToData( unsigned int percentEmpty = 67  );
00242 
00253         unsigned int autoAdjustHorizontalRangeToData() const;
00254 
00265         unsigned int autoAdjustVerticalRangeToData() const;
00266 
00267 
00289         void setGridAttributes( Qt::Orientation orientation, const GridAttributes & );
00290 
00302         void resetGridAttributes( Qt::Orientation orientation );
00303 
00318         const GridAttributes gridAttributes( Qt::Orientation orientation ) const;
00319 
00332         bool hasOwnGridAttributes( Qt::Orientation orientation ) const;
00333 
00341         void setAutoAdjustGridToZoom( bool autoAdjust );
00342 
00348 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00349         const bool autoAdjustGridToZoom() const;
00350 #else
00351         bool autoAdjustGridToZoom() const;
00352 #endif
00353 
00354         AxesCalcMode axesCalcModeY() const;
00355         AxesCalcMode axesCalcModeX() const;
00356 
00358         void setAxesCalcModes( AxesCalcMode mode );
00360         void setAxesCalcModeY( AxesCalcMode mode );
00362         void setAxesCalcModeX( AxesCalcMode mode );
00363 
00365         virtual void paint( QPainter* );
00366 
00368         AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00369 
00374         QRectF visibleDataRange() const;
00375 
00380         QRectF logicalArea() const;
00381 
00389         QRectF diagramArea() const;
00390 
00396         QRectF visibleDiagramArea() const;
00397 
00404         void setHorizontalRangeReversed( bool reverse );
00405 
00409         bool isHorizontalRangeReversed() const;
00410 
00417         void setVerticalRangeReversed( bool reverse );
00418 
00422         bool isVerticalRangeReversed() const;
00423 
00427         void setGeometry( const QRect& r );
00428 
00429     public Q_SLOTS:
00438         void adjustRangesToData();
00439 
00444         void adjustHorizontalRangeToData();
00445 
00450         void adjustVerticalRangeToData();
00451 
00452 
00453     protected:
00454         QRectF getRawDataBoundingRectFromDiagrams() const;
00455         QRectF adjustedToMaxEmptyInnerPercentage(
00456                 const QRectF& r, unsigned int percentX, unsigned int percentY ) const;
00457         virtual QRectF calculateRawDataBoundingRect() const;
00458         virtual DataDimensionsList getDataDimensionsList() const;
00459         // the whole drawing area, includes diagrams and axes, but maybe smaller
00460         // than (width, height):
00461         virtual QRectF drawingArea() const;
00462         const QPointF translateBack( const QPointF& screenPoint ) const;
00463         void paintEvent ( QPaintEvent* );
00464         void layoutDiagrams();
00465         bool doneSetZoomFactorX( double factor );
00466         bool doneSetZoomFactorY( double factor );
00467         bool doneSetZoomCenter( const QPointF& center );
00468 
00469         void handleFixedDataCoordinateSpaceRelation( const QRectF& geometry );
00470 
00471     protected Q_SLOTS:
00472         void slotLayoutChanged( AbstractDiagram* );
00473 
00474     private:
00475         void setHasOwnGridAttributes(
00476             Qt::Orientation orientation, bool on );
00477     };
00478 
00479 }
00480 
00481 #endif