KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartCartesianCoordinatePlane.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDCHARTCARTESIANCOORDINATEPLANE_H
24 #define KDCHARTCARTESIANCOORDINATEPLANE_H
25 
27 
28 namespace KDChart {
29 
30  class Chart;
31  class PaintContext;
32  class AbstractDiagram;
33  class CartesianAxis;
34  class CartesianGrid;
35 
39  class KDCHART_EXPORT CartesianCoordinatePlane : public AbstractCoordinatePlane
40  {
41  Q_OBJECT
42 
43  Q_DISABLE_COPY( CartesianCoordinatePlane )
45 
46  friend class CartesianAxis;
47  friend class CartesianGrid;
48 
49  public:
50  explicit CartesianCoordinatePlane ( Chart* parent = 0 );
52 
53  void addDiagram ( AbstractDiagram* diagram );
54 
60  void setIsometricScaling ( bool onOff );
61 
62  bool doesIsometricScaling() const;
63 
64  const QPointF translate ( const QPointF& diagramPoint ) const;
65 
69  virtual qreal zoomFactorX() const;
73  virtual qreal zoomFactorY() const;
74 
78  virtual void setZoomFactors( qreal factorX, qreal factorY );
82  virtual void setZoomFactorX( qreal factor );
86  virtual void setZoomFactorY( qreal factor );
87 
91  virtual QPointF zoomCenter() const;
92 
96  virtual void setZoomCenter( const QPointF& center );
97 
107  void setFixedDataCoordinateSpaceRelation( bool fixed );
108  bool hasFixedDataCoordinateSpaceRelation() const;
109 
117  void setXAxisStartAtZero(bool fixedStart);
118  bool xAxisStartAtZero() const;
119 
151  void setHorizontalRange( const QPair<qreal, qreal> & range );
152 
184  void setVerticalRange( const QPair<qreal, qreal> & range );
185 
193  QPair<qreal, qreal> horizontalRange() const;
194 
202  QPair<qreal, qreal> verticalRange() const;
203 
224  void setAutoAdjustHorizontalRangeToData( unsigned int percentEmpty = 67 );
225 
246  void setAutoAdjustVerticalRangeToData( unsigned int percentEmpty = 67 );
247 
258  unsigned int autoAdjustHorizontalRangeToData() const;
259 
270  unsigned int autoAdjustVerticalRangeToData() const;
271 
272 
294  void setGridAttributes( Qt::Orientation orientation, const GridAttributes & );
295 
307  void resetGridAttributes( Qt::Orientation orientation );
308 
323  const GridAttributes gridAttributes( Qt::Orientation orientation ) const;
324 
337  bool hasOwnGridAttributes( Qt::Orientation orientation ) const;
338 
346  void setAutoAdjustGridToZoom( bool autoAdjust );
347 
353 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
354  const bool autoAdjustGridToZoom() const;
355 #else
356  bool autoAdjustGridToZoom() const;
357 #endif
358 
359  AxesCalcMode axesCalcModeY() const;
360  AxesCalcMode axesCalcModeX() const;
361 
363  void setAxesCalcModes( AxesCalcMode mode );
365  void setAxesCalcModeY( AxesCalcMode mode );
367  void setAxesCalcModeX( AxesCalcMode mode );
368 
370  virtual void paint( QPainter* );
371 
373  AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = 0 );
374 
379  QRectF visibleDataRange() const;
380 
385  QRectF logicalArea() const;
386 
394  QRectF diagramArea() const;
395 
401  QRectF visibleDiagramArea() const;
402 
409  void setHorizontalRangeReversed( bool reverse );
410 
414  bool isHorizontalRangeReversed() const;
415 
422  void setVerticalRangeReversed( bool reverse );
423 
427  bool isVerticalRangeReversed() const;
428 
432  void setGeometry( const QRect& r );
433 
434  // reimplemented
435  Qt::Orientations expandingDirections() const;
436 
437 
438  public Q_SLOTS:
447  void adjustRangesToData();
448 
453  void adjustHorizontalRangeToData();
454 
459  void adjustVerticalRangeToData();
460 
461  protected:
462  QRectF getRawDataBoundingRectFromDiagrams() const;
463  QRectF adjustedToMaxEmptyInnerPercentage(
464  const QRectF& r, unsigned int percentX, unsigned int percentY ) const;
465  virtual QRectF calculateRawDataBoundingRect() const;
466  virtual DataDimensionsList getDataDimensionsList() const;
467  // the whole drawing area, includes diagrams and axes, but maybe smaller
468  // than (width, height):
469  virtual QRectF drawingArea() const;
470  public:
471  const QPointF translateBack( const QPointF& screenPoint ) const;
472  protected:
473  void paintEvent ( QPaintEvent* );
474  void layoutDiagrams();
475  // the following three return true if the new value is different from the old
476  bool doneSetZoomFactorX( qreal factor );
477  bool doneSetZoomFactorY( qreal factor );
478  bool doneSetZoomCenter( const QPointF& center );
479 
480  void handleFixedDataCoordinateSpaceRelation( const QRectF& geometry );
481 
482  // reimplemented from QLayoutItem, via AbstractLayoutItem, AbstractArea, AbstractCoordinatePlane
483  bool hasHeightForWidth() const;
484  int heightForWidth( int w ) const;
485  QSize sizeHint() const;
486 
487  protected Q_SLOTS:
488  void slotLayoutChanged( AbstractDiagram* );
489 
490  private:
491  void setHasOwnGridAttributes(
492  Qt::Orientation orientation, bool on );
493  };
494 
495 }
496 
497 #endif

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