KChart

KChartCartesianGrid.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 KCHARTCARTESIANGRID_H
10#define KCHARTCARTESIANGRID_H
11
12#include "KChartCartesianCoordinatePlane.h"
13#include "KChartAbstractGrid.h"
14
15namespace KChart {
16
17 class PaintContext;
18 class CartesianCoordinatePlane;
19
20 /**
21 * \internal
22 *
23 * \brief Class for the grid in a cartesian plane.
24 *
25 * The CartesianGrid interface is used
26 * for calculating and for drawing
27 * the horizontal grid lines, and the vertical grid lines
28 * of a cartesian coordinate plane.
29 */
31 {
32 public:
34 ~CartesianGrid() override;
35
36 int minimalSteps() const;
37 void setMinimalSteps(int minsteps);
38
39 int maximalSteps() const;
40 void setMaximalSteps(int maxsteps);
41
42 void drawGrid( PaintContext* context ) override;
43
44 private:
45 int m_minsteps;
46 int m_maxsteps;
47
48 DataDimensionsList calculateGrid(
49 const DataDimensionsList& rawDataDimensions ) const override;
50
51 /**
52 * Helper function called by calculateGrid() to calculate the grid of one dimension.
53 *
54 * Classes derived from CartesianGrid can overwrite calculateGridXY() if they need
55 * a special way of calculating the start or end or step width of their grid lines.
56 *
57 * \param adjustLower If true, the function adjusts the start value
58 * so it matches the position of a grid line, if false the start value is
59 * the raw data dimension start value.
60 * \param adjustUpper If true, the function adjusts the end value
61 * so it matches the position of a grid line, if false the end value is
62 * the raw data dimension end value.
63 */
64 virtual DataDimension calculateGridXY(
65 const DataDimension& rawDataDimension,
66 Qt::Orientation orientation,
67 bool adjustLower, bool adjustUpper ) const;
68
69 /**
70 * Helper function called by calculateGridXY().
71 *
72 * Classes derived from CartesianGrid can overwrite calculateStepWidth() if they need
73 * a way of calculating the step width, based upon given start/end values
74 * for their horizontal or vertical grid lines which is different from the default
75 * implementation.
76 *
77 * \note The CartesianGrid class tries to keep the displayed range as close to
78 * the raw data range as possible, so in most cases there should be no reason
79 * to change the default implementation: Using
80 * KChart::GridAttributes::setGridGranularitySequence() should be sufficient.
81 *
82 * \param start The raw start value of the data range.
83 * \param end The raw end value of the data range.
84 * \param granularities The list of allowed granularities.
85 * \param adjustLower If true, the function adjusts the start value
86 * so it matches the position of a grid line, if false the start value is
87 * left as it is, in any case the value is adjusted for internal calculation only.
88 * \param adjustUpper If true, the function adjusts the end value
89 * so it matches the position of a grid line, if false the end value is
90 * left as it is, in any case the value is adjusted for internal calculation only.
91 *
92 * \returns stepWidth: One of the values from the granularities
93 * list, optionally multiplied by a positive (or negative, resp.)
94 * power of ten. subStepWidth: The matching width for sub-grid lines.
95 */
96 virtual void calculateStepWidth(
97 qreal start, qreal end,
98 const QList<qreal>& granularities,
99 Qt::Orientation orientation,
100 qreal& stepWidth, qreal& subStepWidth,
101 bool adjustLower, bool adjustUpper ) const;
102 };
103
104}
105
106#endif
Abstract base class for grid classes: cartesian, polar, ...
Class for the grid in a cartesian plane.
void drawGrid(PaintContext *context) override
Doing the actual drawing.
Helper class for one dimension of data, e.g.
Stores information about painting diagrams.
Q_SCRIPTABLE Q_NOREPLY void start()
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.