KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartAbstractGrid.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#include "KDChartAbstractGrid.h"
12#include "KDChartPaintContext.h"
13
14#include <qglobal.h>
15
16#include <KDABLibFakes>
17
18using namespace KDChart;
19using namespace std;
20
21static qreal _trunc(qreal v)
22{
23 return ((v > 0.0) ? floor(v) : ceil(v));
24}
25
27{
28 // this block left empty intentionally
29}
30
32{
33 // this block left empty intentionally
34}
35
37{
38 mCachedRawDataDimensions.clear();
39}
40
42{
43 if (plane) {
44 const DataDimensionsList rawDataDimensions(plane->getDataDimensionsList());
45 // ### this could be dangerous because calculateGrid() looks at some data we are not checking
46 // for changes here.
47 if (mCachedRawDataDimensions.empty() || (rawDataDimensions != mCachedRawDataDimensions)) {
48 mCachedRawDataDimensions = rawDataDimensions;
49 mPlane = plane;
50 mDataDimensions = calculateGrid(rawDataDimensions);
51 }
52 }
53 return mDataDimensions;
54}
55
57{
58 return isBoundariesValid(qMakePair(r.topLeft(), r.bottomRight()));
59}
60
62{
63 return isValueValid(b.first.x()) && isValueValid(b.first.y()) && isValueValid(b.second.x()) && isValueValid(b.second.y());
64}
65
67{
68 for (int i = 0; i < l.size(); ++i)
69 if (!isValueValid(l.at(i).start) || !isValueValid(l.at(i).end))
70 return false;
71 return true;
72}
73
74bool AbstractGrid::isValueValid(const qreal &r)
75{
76 return !(ISNAN(r) || ISINF(r));
77}
78
80 qreal &start, qreal &end,
81 qreal stepWidth,
82 bool adjustLower, bool adjustUpper)
83{
84 const qreal startAdjust = (start >= 0.0) ? 0.0 : -1.0;
85 const qreal endAdjust = (end >= 0.0) ? 1.0 : 0.0;
86 if (adjustLower && !qFuzzyIsNull(fmod(start, stepWidth)))
87 start = stepWidth * (_trunc(start / stepWidth) + startAdjust);
88 if (adjustUpper && !qFuzzyIsNull(fmod(end, stepWidth)))
89 end = stepWidth * (_trunc(end / stepWidth) + endAdjust);
90}
91
93 const DataDimension &dim,
94 bool adjustLower, bool adjustUpper)
95{
96 DataDimension result(dim);
98 result.start, result.end,
99 result.stepWidth,
100 adjustLower, adjustUpper);
101 return result;
102}
static qreal _trunc(qreal v)
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
virtual DataDimensionsList getDataDimensionsList() const =0
DataDimensionsList updateData(AbstractCoordinatePlane *plane)
Returns the cached result of data calculation.
DataDimensionsList mDataDimensions
AbstractCoordinatePlane * mPlane
static bool isValueValid(const qreal &r)
static void adjustLowerUpperRange(qreal &start, qreal &end, qreal stepWidth, bool adjustLower, bool adjustUpper)
static const DataDimension adjustedLowerUpperRange(const DataDimension &dim, bool adjustLower, bool adjustUpper)
static bool isBoundariesValid(const QRectF &r)
Helper class for one dimension of data, e.g. for the rows in a data model, or for the labels of an ax...
const T & at(int i) const const
void clear()
bool empty() const const
int size() const const
QPointF bottomRight() const const
QPointF topLeft() const const

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Thu Apr 11 2024 00:04:50 for KD Chart API Documentation by doxygen 1.9.8