KChart

KChartCartesianCoordinatePlane.h
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTCARTESIANCOORDINATEPLANE_H
21 #define KCHARTCARTESIANCOORDINATEPLANE_H
22 
23 #include "KChartAbstractCoordinatePlane.h"
24 
25 namespace KChart {
26 
27  class Chart;
28  class PaintContext;
29  class AbstractDiagram;
30  class CartesianAxis;
31  class CartesianGrid;
32 
37  {
38  Q_OBJECT
39 
40  Q_DISABLE_COPY( CartesianCoordinatePlane )
41  KCHART_DECLARE_PRIVATE_DERIVED_PARENT( CartesianCoordinatePlane, Chart* )
42 
43  friend class CartesianAxis;
44  friend class CartesianGrid;
45 
46  public:
47  explicit CartesianCoordinatePlane ( Chart* parent = nullptr );
49 
50  void addDiagram ( AbstractDiagram* diagram ) override;
51 
57  void setIsometricScaling ( bool onOff );
58 
59  bool doesIsometricScaling() const;
60 
61  const QPointF translate ( const QPointF& diagramPoint ) const override;
62 
66  qreal zoomFactorX() const override;
70  qreal zoomFactorY() const override;
71 
75  void setZoomFactors( qreal factorX, qreal factorY ) override;
79  void setZoomFactorX( qreal factor ) override;
83  void setZoomFactorY( qreal factor ) override;
84 
88  QPointF zoomCenter() const override;
89 
93  void setZoomCenter( const QPointF& center ) override;
94 
104  void setFixedDataCoordinateSpaceRelation( bool fixed );
105  bool hasFixedDataCoordinateSpaceRelation() const;
106 
114  void setXAxisStartAtZero(bool fixedStart);
115  bool xAxisStartAtZero() const;
116 
152  void setHorizontalRange( const QPair<qreal, qreal> & range );
153 
189  void setVerticalRange( const QPair<qreal, qreal> & range );
190 
198  QPair<qreal, qreal> horizontalRange() const;
199 
207  QPair<qreal, qreal> verticalRange() const;
208 
229  void setAutoAdjustHorizontalRangeToData( unsigned int percentEmpty = 67 );
230 
251  void setAutoAdjustVerticalRangeToData( unsigned int percentEmpty = 67 );
252 
263  unsigned int autoAdjustHorizontalRangeToData() const;
264 
275  unsigned int autoAdjustVerticalRangeToData() const;
276 
277 
299  void setGridAttributes( Qt::Orientation orientation, const GridAttributes & );
300 
312  void resetGridAttributes( Qt::Orientation orientation );
313 
328  const GridAttributes gridAttributes( Qt::Orientation orientation ) const;
329 
342  bool hasOwnGridAttributes( Qt::Orientation orientation ) const;
343 
351  void setAutoAdjustGridToZoom( bool autoAdjust );
352 
358 #if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
359  const bool autoAdjustGridToZoom() const;
360 #else
361  bool autoAdjustGridToZoom() const;
362 #endif
363 
364  AxesCalcMode axesCalcModeY() const;
365  AxesCalcMode axesCalcModeX() const;
366 
368  void setAxesCalcModes( AxesCalcMode mode );
370  void setAxesCalcModeY( AxesCalcMode mode );
372  void setAxesCalcModeX( AxesCalcMode mode );
373 
375  void paint( QPainter* ) override;
376 
378  AbstractCoordinatePlane* sharedAxisMasterPlane( QPainter* p = nullptr ) override;
379 
384  QRectF visibleDataRange() const;
385 
390  QRectF logicalArea() const;
391 
399  QRectF diagramArea() const;
400 
406  QRectF visibleDiagramArea() const;
407 
414  void setHorizontalRangeReversed( bool reverse );
415 
419  bool isHorizontalRangeReversed() const;
420 
427  void setVerticalRangeReversed( bool reverse );
428 
432  bool isVerticalRangeReversed() const;
433 
437  void setGeometry( const QRect& r ) override;
438 
439  // reimplemented
440  Qt::Orientations expandingDirections() const override;
441 
442 
443  public Q_SLOTS:
452  void adjustRangesToData();
453 
458  void adjustHorizontalRangeToData();
459 
464  void adjustVerticalRangeToData();
465 
466  protected:
467  QRectF getRawDataBoundingRectFromDiagrams() const;
468  QRectF adjustedToMaxEmptyInnerPercentage(
469  const QRectF& r, unsigned int percentX, unsigned int percentY ) const;
470  virtual QRectF calculateRawDataBoundingRect() const;
471  DataDimensionsList getDataDimensionsList() const override;
472  // the whole drawing area, includes diagrams and axes, but maybe smaller
473  // than (width, height):
474  virtual QRectF drawingArea() const;
475  public:
476  const QPointF translateBack( const QPointF& screenPoint ) const;
477  protected:
478  void paintEvent ( QPaintEvent* );
479  void layoutDiagrams() override;
480  // the following three return true if the new value is different from the old
481  bool doneSetZoomFactorX( qreal factor );
482  bool doneSetZoomFactorY( qreal factor );
483  bool doneSetZoomCenter( const QPointF& center );
484 
485  void handleFixedDataCoordinateSpaceRelation( const QRectF& geometry );
486 
487  // reimplemented from QLayoutItem, via AbstractLayoutItem, AbstractArea, AbstractCoordinatePlane
488  bool hasHeightForWidth() const override;
489  int heightForWidth( int w ) const override;
490  QSize sizeHint() const override;
491 
492  protected Q_SLOTS:
493  void slotLayoutChanged( AbstractDiagram* );
494 
495  private:
496  void setHasOwnGridAttributes(
497  Qt::Orientation orientation, bool on );
498  };
499 
500 }
501 
502 #endif
AbstractDiagram defines the interface for diagram classes.
The class for cartesian axes.
Class for the grid in a cartesian plane.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
A set of attributes controlling the appearance of grids.
A chart with one or more diagrams.
Definition: KChartChart.h:95
Orientation
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Sep 23 2020 22:36:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.