KD Chart 2  [rev.2.5]
KDChartCartesianCoordinatePlane.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2012 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 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 
00060         void setIsometricScaling ( bool onOff );
00061 
00062         bool doesIsometricScaling() const;
00063 
00064         const QPointF translate ( const QPointF& diagramPoint ) const;
00065 
00069         virtual qreal zoomFactorX() const;
00073         virtual qreal zoomFactorY() const;
00074 
00078         virtual void setZoomFactors( qreal factorX, qreal factorY );
00082         virtual void setZoomFactorX( qreal factor );
00086         virtual void setZoomFactorY( qreal factor );
00087 
00091         virtual QPointF zoomCenter() const;
00092 
00096         virtual void setZoomCenter( const QPointF& center );
00097 
00107         void setFixedDataCoordinateSpaceRelation( bool fixed );
00108         bool hasFixedDataCoordinateSpaceRelation() const;
00109 
00117         void setXAxisStartAtZero(bool fixedStart);
00118         bool xAxisStartAtZero() const;
00119 
00151         void setHorizontalRange( const QPair<qreal, qreal> & range );
00152 
00184         void setVerticalRange( const QPair<qreal, qreal> & range );
00185 
00193         QPair<qreal, qreal> horizontalRange() const;
00194 
00202         QPair<qreal, qreal> verticalRange() const;
00203 
00224         void setAutoAdjustHorizontalRangeToData( unsigned int percentEmpty = 67 );
00225 
00246         void setAutoAdjustVerticalRangeToData( unsigned int percentEmpty = 67 );
00247 
00258         unsigned int autoAdjustHorizontalRangeToData() const;
00259 
00270         unsigned int autoAdjustVerticalRangeToData() const;
00271 
00272 
00294         void setGridAttributes( Qt::Orientation orientation, const GridAttributes & );
00295 
00307         void resetGridAttributes( Qt::Orientation orientation );
00308 
00323         const GridAttributes gridAttributes( Qt::Orientation orientation ) const;
00324 
00337         bool hasOwnGridAttributes( Qt::Orientation orientation ) const;
00338 
00346         void setAutoAdjustGridToZoom( bool autoAdjust );
00347 
00353 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00354         const bool autoAdjustGridToZoom() const;
00355 #else
00356         bool autoAdjustGridToZoom() const;
00357 #endif
00358 
00359         AxesCalcMode axesCalcModeY() const;
00360         AxesCalcMode axesCalcModeX() const;
00361 
00363         void setAxesCalcModes( AxesCalcMode mode );
00365         void setAxesCalcModeY( AxesCalcMode mode );
00367         void setAxesCalcModeX( AxesCalcMode mode );
00368 
00370         virtual void paint( QPainter* );
00371 
00373         AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00374 
00379         QRectF visibleDataRange() const;
00380 
00385         QRectF logicalArea() const;
00386 
00394         QRectF diagramArea() const;
00395 
00401         QRectF visibleDiagramArea() const;
00402 
00409         void setHorizontalRangeReversed( bool reverse );
00410 
00414         bool isHorizontalRangeReversed() const;
00415 
00422         void setVerticalRangeReversed( bool reverse );
00423 
00427         bool isVerticalRangeReversed() const;
00428 
00432         void setGeometry( const QRect& r );
00433 
00434         // reimp
00435         QSize minimumSize() const;
00436         // reimp
00437         Qt::Orientations expandingDirections() const;
00438 
00439     public Q_SLOTS:
00448         void adjustRangesToData();
00449 
00454         void adjustHorizontalRangeToData();
00455 
00460         void adjustVerticalRangeToData();
00461 
00462 
00463     protected:
00464         QRectF getRawDataBoundingRectFromDiagrams() const;
00465         QRectF adjustedToMaxEmptyInnerPercentage(
00466                 const QRectF& r, unsigned int percentX, unsigned int percentY ) const;
00467         virtual QRectF calculateRawDataBoundingRect() const;
00468         virtual DataDimensionsList getDataDimensionsList() const;
00469         // the whole drawing area, includes diagrams and axes, but maybe smaller
00470         // than (width, height):
00471         virtual QRectF drawingArea() const;
00472     public:
00473         const QPointF translateBack( const QPointF& screenPoint ) const;
00474     protected:
00475         void paintEvent ( QPaintEvent* );
00476         void layoutDiagrams();
00477         // the following three return true if the new value is different from the old
00478         bool doneSetZoomFactorX( qreal factor );
00479         bool doneSetZoomFactorY( qreal factor );
00480         bool doneSetZoomCenter( const QPointF& center );
00481 
00482         void handleFixedDataCoordinateSpaceRelation( const QRectF& geometry );
00483 
00484         // reimplemented from QLayoutItem, via AbstractLayoutItem, AbstractArea, AbstractCoordinatePlane
00485         bool hasHeightForWidth() const;
00486         int heightForWidth( int w ) const;
00487 
00488     protected Q_SLOTS:
00489         void slotLayoutChanged( AbstractDiagram* );
00490 
00491     private:
00492         void setHasOwnGridAttributes(
00493             Qt::Orientation orientation, bool on );
00494     };
00495 
00496 }
00497 
00498 #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/