KChart

KChartMeasure.h
Go to the documentation of this file.
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 KCHARTMEASURE_H
21 #define KCHARTMEASURE_H
22 
23 #include <QDebug>
24 #include <Qt>
25 #include <QStack>
26 #include "KChartGlobal.h"
27 #include "KChartEnums.h"
28 
35 QT_BEGIN_NAMESPACE
36 class QObject;
37 class QPaintDevice;
38 QT_END_NAMESPACE
39 
40 namespace KChart {
41 
48 class KCHART_EXPORT Measure
49 {
50 public:
51  Measure();
52  /*implicit*/ Measure( qreal value,
53  KChartEnums::MeasureCalculationMode mode = KChartEnums::MeasureCalculationModeAuto,
54  KChartEnums::MeasureOrientation orientation = KChartEnums::MeasureOrientationAuto );
55  Measure( const Measure& );
56  Measure &operator= ( const Measure& );
57 
58  void setValue( qreal val ) { mValue = val; }
59  qreal value() const { return mValue; }
60 
61  void setCalculationMode( KChartEnums::MeasureCalculationMode mode ) { mMode = mode; }
62  KChartEnums::MeasureCalculationMode calculationMode() const { return mMode; }
63 
68  void setRelativeMode( const QObject * area,
70  {
71  mMode = KChartEnums::MeasureCalculationModeRelative;
72  mArea = area;
73  mOrientation = orientation;
74  }
75 
86  void setAbsoluteValue( qreal val )
87  {
88  mMode = KChartEnums::MeasureCalculationModeAbsolute;
89  mValue = val;
90  }
91 
96  void setReferenceArea( const QObject * area ) { mArea = area; }
101  const QObject * referenceArea() const { return mArea; }
102 
103  void setReferenceOrientation( KChartEnums::MeasureOrientation orientation ) { mOrientation = orientation; }
104  KChartEnums::MeasureOrientation referenceOrientation() const { return mOrientation; }
105 
110  qreal calculatedValue( const QObject * autoArea, KChartEnums::MeasureOrientation autoOrientation ) const;
111  qreal calculatedValue( const QSizeF& autoSize, KChartEnums::MeasureOrientation autoOrientation ) const;
112  const QSizeF sizeOfArea( const QObject* area ) const;
113 
114  bool operator==( const Measure& ) const;
115  bool operator!=( const Measure& other ) const { return !operator==(other); }
116 
117 private:
118  qreal mValue;
120  const QObject* mArea;
121  KChartEnums::MeasureOrientation mOrientation;
122 }; // End of class Measure
123 
124 
125 
138 {
139 public:
140  static GlobalMeasureScaling* instance();
141 
143  virtual ~GlobalMeasureScaling();
144 
145 public:
150  static void setFactors(qreal factorX, qreal factorY);
151 
156  static void resetFactors();
157 
161  static const QPair< qreal, qreal > currentFactors();
162 
166  static void setPaintDevice( QPaintDevice* paintDevice );
167 
171  static QPaintDevice* paintDevice();
172 
173 private:
175  QPaintDevice* m_paintDevice;
176 };
177 
178 }
179 
180 #if !defined(QT_NO_DEBUG_STREAM)
181 KCHART_EXPORT QDebug operator<<(QDebug, const KChart::Measure& );
182 #endif /* QT_NO_DEBUG_STREAM */
183 
184 #endif // KCHARTMEASURE_H
Auxiliary class used by the KChart::Measure and KChart::Chart class.
MeasureCalculationMode
Measure calculation mode: the way how the absolute value of a KChart::Measure is determined during KC...
Definition: KChartEnums.h:219
void setRelativeMode(const QObject *area, KChartEnums::MeasureOrientation orientation)
The reference area must either be derived from AbstractArea or from QWidget, so it can also be derive...
Definition: KChartMeasure.h:68
const QObject * referenceArea() const
The returned reference area will be derived from AbstractArea or QWidget or both. ...
Class only listed here to document inheritance of some KChart classes.
Contains KChart macros.
MeasureOrientation
Measure orientation mode: the way how the absolute value of a KChart::Measure is determined during KC...
Definition: KChartEnums.h:287
void setAbsoluteValue(qreal val)
This is a convenience method for specifying a value, implicitly setting the calculation mode to Measu...
Definition: KChartMeasure.h:86
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
Definition of global enums.
Global namespace.
Measure is used to specify relative and absolute sizes in KChart, e.g.
Definition: KChartMeasure.h:48
void setReferenceArea(const QObject *area)
The reference area must either be derived from AbstractArea or from QWidget, so it can also be derive...
Definition: KChartMeasure.h:96
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 22:42:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.