KD Chart 2  [rev.2.7]
KDChartMeasure.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDCHARTMEASURE_H
24 #define KDCHARTMEASURE_H
25 
26 #include <QDebug>
27 #include <Qt>
28 #include <QStack>
29 #include "KDChartGlobal.h"
30 #include "KDChartEnums.h"
31 
38 QT_BEGIN_NAMESPACE
39 class QObject;
40 class QPaintDevice;
41 QT_END_NAMESPACE
42 
43 namespace KDChart {
44 
51 class KDCHART_EXPORT Measure
52 {
53 public:
54  Measure();
55  /*implicit*/ Measure( qreal value,
58  Measure( const Measure& );
59  Measure &operator= ( const Measure& );
60 
61  void setValue( qreal val ) { mValue = val; }
62  qreal value() const { return mValue; }
63 
66 
71  void setRelativeMode( const QObject * area,
73  {
75  mArea = area;
76  mOrientation = orientation;
77  }
78 
89  void setAbsoluteValue( qreal val )
90  {
92  mValue = val;
93  }
94 
99  void setReferenceArea( const QObject * area ) { mArea = area; }
104  const QObject * referenceArea() const { return mArea; }
105 
106  void setReferenceOrientation( KDChartEnums::MeasureOrientation orientation ) { mOrientation = orientation; }
108 
113  qreal calculatedValue( const QObject * autoArea, KDChartEnums::MeasureOrientation autoOrientation ) const;
114  qreal calculatedValue( const QSizeF& autoSize, KDChartEnums::MeasureOrientation autoOrientation ) const;
115  const QSizeF sizeOfArea( const QObject* area ) const;
116 
117  bool operator==( const Measure& ) const;
118  bool operator!=( const Measure& other ) const { return !operator==(other); }
119 
120 private:
121  qreal mValue;
123  const QObject* mArea;
125 }; // End of class Measure
126 
127 
128 
141 {
142 public:
143  static GlobalMeasureScaling* instance();
144 
146  virtual ~GlobalMeasureScaling();
147 
148 public:
153  static void setFactors(qreal factorX, qreal factorY);
154 
159  static void resetFactors();
160 
164  static const QPair< qreal, qreal > currentFactors();
165 
169  static void setPaintDevice( QPaintDevice* paintDevice );
170 
174  static QPaintDevice* paintDevice();
175 
176 private:
177  QStack< QPair< qreal, qreal > > mFactors;
178  QPaintDevice* m_paintDevice;
179 };
180 
181 }
182 
183 #if !defined(QT_NO_DEBUG_STREAM)
184 KDCHART_EXPORT QDebug operator<<(QDebug, const KDChart::Measure& );
185 #endif /* QT_NO_DEBUG_STREAM */
186 
187 #endif // KDCHARTMEASURE_H
MeasureOrientation
Measure orientation mode: the way how the absolute value of a KDChart::Measure is determined during K...
Definition: KDChartEnums.h:290
bool operator==(const Span &s1, const Span &s2)
void setReferenceOrientation(KDChartEnums::MeasureOrientation orientation)
Auxiliary class used by the KDChart::Measure and KDChart::Chart class.
Definition of global enums.
bool operator!=(const Measure &other) const
KDChartEnums::MeasureOrientation referenceOrientation() const
const QObject * referenceArea() const
The returned reference area will be derived from AbstractArea or QWidget or both. ...
void setAbsoluteValue(qreal val)
This is a convenience method for specifying a value, implicitly setting the calculation mode to Measu...
void setValue(qreal val)
void setReferenceArea(const QObject *area)
The reference area must either be derived from AbstractArea or from QWidget, so it can also be derive...
MeasureCalculationMode
Measure calculation mode: the way how the absolute value of a KDChart::Measure is determined during K...
Definition: KDChartEnums.h:222
void setRelativeMode(const QObject *area, KDChartEnums::MeasureOrientation orientation)
The reference area must either be derived from AbstractArea or from QWidget, so it can also be derive...
KDChartEnums::MeasureCalculationMode calculationMode() const
Measure is used to specify relative and absolute sizes in KDChart, e.g.
Class only listed here to document inheritance of some KDChart classes.
QDebug operator<<(QDebug stream, const DataDimension &r)
void setCalculationMode(KDChartEnums::MeasureCalculationMode mode)
qreal value() const

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/