00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef KDCHARTCARTESIANCOORDINATEPLANE_H
00027 #define KDCHARTCARTESIANCOORDINATEPLANE_H
00028
00029 #include "KDChartAbstractCoordinatePlane.h"
00030
00031 namespace KDChart {
00032
00033 class Chart;
00034 class PaintContext;
00035 class AbstractDiagram;
00036 class CartesianAxis;
00037 class CartesianGrid;
00038
00042 class KDCHART_EXPORT CartesianCoordinatePlane : public AbstractCoordinatePlane
00043 {
00044 Q_OBJECT
00045
00046 Q_DISABLE_COPY( CartesianCoordinatePlane )
00047 KDCHART_DECLARE_PRIVATE_DERIVED_PARENT( CartesianCoordinatePlane, Chart* )
00048
00049 friend class CartesianAxis;
00050 friend class CartesianGrid;
00051
00052 public:
00053 explicit CartesianCoordinatePlane ( Chart* parent = 0 );
00054 ~CartesianCoordinatePlane();
00055
00056 void addDiagram ( AbstractDiagram* diagram );
00057
00058 void setIsometricScaling ( bool onOff );
00059
00060 bool doesIsometricScaling() const;
00061
00062 const QPointF translate ( const QPointF& diagramPoint ) const;
00063
00067 virtual double zoomFactorX() const;
00071 virtual double zoomFactorY() const;
00072
00076 virtual void setZoomFactors( double factorX, double factorY );
00080 virtual void setZoomFactorX( double factor );
00084 virtual void setZoomFactorY( double factor );
00085
00089 virtual QPointF zoomCenter() const;
00090
00094 virtual void setZoomCenter( const QPointF& center );
00095
00105 void setFixedDataCoordinateSpaceRelation( bool fixed );
00106 bool hasFixedDataCoordinateSpaceRelation() const;
00107
00108
00140 void setHorizontalRange( const QPair<qreal, qreal> & range );
00141
00173 void setVerticalRange( const QPair<qreal, qreal> & range );
00174
00182 QPair<qreal, qreal> horizontalRange() const;
00183
00191 QPair<qreal, qreal> verticalRange() const;
00192
00213 void setAutoAdjustHorizontalRangeToData( unsigned int percentEmpty = 67 );
00214
00235 void setAutoAdjustVerticalRangeToData( unsigned int percentEmpty = 67 );
00236
00247 unsigned int autoAdjustHorizontalRangeToData() const;
00248
00259 unsigned int autoAdjustVerticalRangeToData() const;
00260
00261
00283 void setGridAttributes( Qt::Orientation orientation, const GridAttributes & );
00284
00296 void resetGridAttributes( Qt::Orientation orientation );
00297
00312 const GridAttributes gridAttributes( Qt::Orientation orientation ) const;
00313
00326 bool hasOwnGridAttributes( Qt::Orientation orientation ) const;
00327
00335 void setAutoAdjustGridToZoom( bool autoAdjust );
00336
00342 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00343 const bool autoAdjustGridToZoom() const;
00344 #else
00345 bool autoAdjustGridToZoom() const;
00346 #endif
00347
00348 AxesCalcMode axesCalcModeY() const;
00349 AxesCalcMode axesCalcModeX() const;
00350
00352 void setAxesCalcModes( AxesCalcMode mode );
00354 void setAxesCalcModeY( AxesCalcMode mode );
00356 void setAxesCalcModeX( AxesCalcMode mode );
00357
00359 virtual void paint( QPainter* );
00360
00362 AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
00363
00368 QRectF visibleDataRange() const;
00369
00374 QRectF logicalArea() const;
00375
00383 QRectF diagramArea() const;
00384
00390 QRectF visibleDiagramArea() const;
00391
00398 void setHorizontalRangeReversed( bool reverse );
00399
00403 bool isHorizontalRangeReversed() const;
00404
00411 void setVerticalRangeReversed( bool reverse );
00412
00416 bool isVerticalRangeReversed() const;
00417
00421 void setGeometry( const QRect& r );
00422
00423 public Q_SLOTS:
00432 void adjustRangesToData();
00433
00438 void adjustHorizontalRangeToData();
00439
00444 void adjustVerticalRangeToData();
00445
00446
00447 protected:
00448 QRectF getRawDataBoundingRectFromDiagrams() const;
00449 QRectF adjustedToMaxEmptyInnerPercentage(
00450 const QRectF& r, unsigned int percentX, unsigned int percentY ) const;
00451 virtual QRectF calculateRawDataBoundingRect() const;
00452 virtual DataDimensionsList getDataDimensionsList() const;
00453
00454
00455 virtual QRectF drawingArea() const;
00456 const QPointF translateBack( const QPointF& screenPoint ) const;
00457 void paintEvent ( QPaintEvent* );
00458 void layoutDiagrams();
00459 bool doneSetZoomFactorX( double factor );
00460 bool doneSetZoomFactorY( double factor );
00461 bool doneSetZoomCenter( const QPointF& center );
00462
00463 void handleFixedDataCoordinateSpaceRelation( const QRectF& geometry );
00464
00465 protected Q_SLOTS:
00466 void slotLayoutChanged( AbstractDiagram* );
00467
00468 private:
00469 void setHasOwnGridAttributes(
00470 Qt::Orientation orientation, bool on );
00471 };
00472
00473 }
00474
00475 #endif