KChart

KChartAbstractGrid.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHARTABSTRACTGRID_H
10#define KCHARTABSTRACTGRID_H
11
12#include <QPair>
13
14#include "KChartAbstractCoordinatePlane.h"
15#include "KChartGridAttributes.h"
16#include "KChartAbstractDiagram.h"
17#include "KChartCartesianAxis.h"
18
19namespace KChart {
20
21 class PaintContext;
22
23
24 /**
25 * \internal
26 *
27 * \brief Abstract base class for grid classes: cartesian, polar, ...
28 *
29 * The AbstractGrid interface is the base class used by
30 * AbstractCoordinatePlane, for calculating and for drawing
31 * the grid lines of the plane.
32 */
34 {
35 public:
36 virtual ~AbstractGrid();
37 protected:
38 AbstractGrid ();
39
40
41 public:
42 /** \brief Returns the cached result of data calculation.
43 *
44 * For this, all derived classes need to implement the
45 * pure-virtual calculateGrid() method.
46 */
48
49 /**
50 * Doing the actual drawing.
51 *
52 * Every derived class must implement this.
53 *
54 * \note When implementing drawGrid(): Before you start drawing,
55 * make sure to call updateData(), to get the data boundaries
56 * recalculated.
57 * For an example, see the implementation of CartesianGrid:drawGrid().
58 */
59 virtual void drawGrid( PaintContext* context ) = 0;
60
61 /**
62 * Causes grid to be recalculated upon the next call
63 * of updateData().
64 *
65 * \see calculateGrid
66 */
67 void setNeedRecalculate();
68
69 /**
70 * Checks whether both coordinates of r are valid according
71 * to isValueValid
72 *
73 * \see isValueValid
74 */
75 static bool isBoundariesValid(const QRectF& r );
76
77 /**
78 * Checks whether both coordinates of both points are valid
79 * according to isValueValid
80 *
81 * \see isValueValid
82 */
83 static bool isBoundariesValid(const QPair<QPointF,QPointF>& b );
84
85 /**
86 * Checks whether all start and end properties of every
87 * DataDimension in the list l are valid according to
88 * isValueValid().
89 *
90 * \see isValueValid
91 */
92 static bool isBoundariesValid(const DataDimensionsList& l );
93
94 /**
95 * Checks if r is neither NaN nor infinity.
96 */
97 static bool isValueValid(const qreal& r );
98
99 /**
100 * Adjusts \a start and/or \a end so that they are a multiple of
101 * \a stepWidth
102 */
103 static void adjustLowerUpperRange(
104 qreal& start, qreal& end,
105 qreal stepWidth,
106 bool adjustLower, bool adjustUpper );
107
108 /**
109 * Adjusts \a dim so that \c dim.start and/or \c dim.end are a multiple
110 * of \c dim.stepWidth.
111 *
112 * \see adjustLowerUpperRange
113 */
115 const DataDimension& dim,
116 bool adjustLower, bool adjustUpper );
117
118 GridAttributes gridAttributes;
119
120 protected:
121 DataDimensionsList mDataDimensions;
123
124 private:
125 /**
126 * \brief Calculates the grid start/end/step width values.
127 *
128 * Gets the raw data dimensions - e.g. the data model's boundaries,
129 * together with their isCalculated flags.
130 *
131 * Returns the calculated start/end values for the grid, and their
132 * respective step widths.
133 * If at least one of the step widths is Zero, all dimensions of
134 * the returned list are considered invalid!
135 *
136 * \note This function needs to be implemented by all derived classes,
137 * like CartesianGrid, PolarGrid, ...
138 */
139 virtual DataDimensionsList calculateGrid( const DataDimensionsList& rawDataDimensions ) const = 0;
140 DataDimensionsList mCachedRawDataDimensions;
141 };
142
143}
144
145#endif
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
Abstract base class for grid classes: cartesian, polar, ...
DataDimensionsList updateData(AbstractCoordinatePlane *plane)
Returns the cached result of data calculation.
virtual void drawGrid(PaintContext *context)=0
Doing the actual drawing.
static bool isValueValid(const qreal &r)
Checks if r is neither NaN nor infinity.
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.
void setNeedRecalculate()
Causes grid to be recalculated upon the next call of updateData().
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.
static bool isBoundariesValid(const QRectF &r)
Checks whether both coordinates of r are valid according to isValueValid.
Helper class for one dimension of data, e.g.
A set of attributes controlling the appearance of grids.
Stores information about painting diagrams.
Q_SCRIPTABLE Q_NOREPLY void start()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:03:49 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.