KChart

KChartAbstractGrid.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 KCHARTABSTRACTGRID_H
21 #define KCHARTABSTRACTGRID_H
22 
23 #include <QPair>
24 
25 #include "KChartAbstractCoordinatePlane.h"
26 #include "KChartGridAttributes.h"
27 #include "KChartAbstractDiagram.h"
28 #include "KChartCartesianAxis.h"
29 
30 namespace KChart {
31 
32  class PaintContext;
33 
34 
45  {
46  public:
47  virtual ~AbstractGrid();
48  protected:
49  AbstractGrid ();
50 
51 
52  public:
59 
70  virtual void drawGrid( PaintContext* context ) = 0;
71 
78  void setNeedRecalculate();
79 
86  static bool isBoundariesValid(const QRectF& r );
87 
94  static bool isBoundariesValid(const QPair<QPointF,QPointF>& b );
95 
103  static bool isBoundariesValid(const DataDimensionsList& l );
104 
108  static bool isValueValid(const qreal& r );
109 
114  static void adjustLowerUpperRange(
115  qreal& start, qreal& end,
116  qreal stepWidth,
117  bool adjustLower, bool adjustUpper );
118 
126  const DataDimension& dim,
127  bool adjustLower, bool adjustUpper );
128 
129  GridAttributes gridAttributes;
130 
131  protected:
132  DataDimensionsList mDataDimensions;
133  AbstractCoordinatePlane* mPlane;
134 
135  private:
150  virtual DataDimensionsList calculateGrid( const DataDimensionsList& rawDataDimensions ) const = 0;
151  DataDimensionsList mCachedRawDataDimensions;
152  };
153 
154 }
155 
156 #endif
Helper class for one dimension of data, e.g.
void setNeedRecalculate()
Causes grid to be recalculated upon the next call of updateData().
static bool isBoundariesValid(const QRectF &r)
Checks whether both coordinates of r are valid according to isValueValid.
static const DataDimension adjustedLowerUpperRange(const DataDimension &dim, bool adjustLower, bool adjustUpper)
Adjusts dim so that dim.start and/or dim.end are a multiple of dim.stepWidth.
Stores information about painting diagrams.
virtual void drawGrid(PaintContext *context)=0
Doing the actual drawing.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
DataDimensionsList updateData(AbstractCoordinatePlane *plane)
Returns the cached result of data calculation.
static void adjustLowerUpperRange(qreal &start, qreal &end, qreal stepWidth, bool adjustLower, bool adjustUpper)
Adjusts start and/or end so that they are a multiple of stepWidth.
A set of attributes controlling the appearance of grids.
static bool isValueValid(const qreal &r)
Checks if r is neither NaN nor infinity.
Global namespace.
Abstract base class for grid classes: cartesian, polar, ...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.