2
KDChart - a multi-platform charting engine
5
/****************************************************************************
6
** Copyright (C) 2005-2007 Klarälvdalens Datakonsult AB. All rights reserved.
8
** This file is part of the KD Chart library.
10
** This file may be used under the terms of the GNU General Public
11
** License versions 2.0 or 3.0 as published by the Free Software
12
** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
13
** included in the packaging of this file. Alternatively you may (at
14
** your option) use any later version of the GNU General Public
15
** License if such license has been publicly approved by
16
** Klarälvdalens Datakonsult AB (or its successors, if any).
18
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
19
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
20
** A PARTICULAR PURPOSE. Klarälvdalens Datakonsult AB reserves all rights
21
** not expressly granted herein.
23
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26
**********************************************************************/
28
#ifndef KDCHARTMEASURE_H
29
#define KDCHARTMEASURE_H
34
#include "KDChartGlobal.h"
35
#include "KDChartEnums.h"
37
/** \file KDChartMeasure.h
38
* \brief Declaring the class KDChart::Measure.
50
* \class Measure KDChartMeasure.h KDChartMeasure
51
* \brief Measure is used to specify all relative and/or absolute measures in KDChart, e.g. font sizes.
55
class KDCHART_EXPORT Measure
59
/*implicit*/ Measure( qreal value,
60
KDChartEnums::MeasureCalculationMode mode = KDChartEnums::MeasureCalculationModeAuto,
61
KDChartEnums::MeasureOrientation orientation = KDChartEnums::MeasureOrientationAuto );
62
Measure( const Measure& );
63
Measure &operator= ( const Measure& );
65
void setValue( qreal val ){ mValue = val; }
66
qreal value() const { return mValue; }
68
void setCalculationMode( KDChartEnums::MeasureCalculationMode mode ){ mMode = mode; }
69
KDChartEnums::MeasureCalculationMode calculationMode() const { return mMode; }
72
* The reference area must either be derived from AbstractArea
73
* or be derived from QWidget, so e.g. it could be derived from
74
* AbstractAreaWidget too.
76
void setRelativeMode( const QObject * area,
77
KDChartEnums::MeasureOrientation orientation )
79
mMode = KDChartEnums::MeasureCalculationModeRelative;
81
mOrientation = orientation;
85
* \brief This is a convenience method for specifying a value,
86
* with implicitely setting the calculation mode to MeasureCalculationModeAbsolute
88
* Calling setAbsoluteValue( value ) is the same as calling
91
setCalculationMode( KDChartEnums::MeasureCalculationModeAbsolute );
94
void setAbsoluteValue( qreal val )
96
mMode = KDChartEnums::MeasureCalculationModeAbsolute;
101
* The reference area must either be derived from AbstractArea
102
* or be derived from QWidget, so e.g. it could be derived from
103
* AbstractAreaWidget too.
105
void setReferenceArea( const QObject * area ){ mArea = area; }
107
* The returned reference area will either be derived from AbstractArea
108
* or be derived from QWidget.
110
const QObject * referenceArea() const { return mArea; }
112
void setReferenceOrientation( KDChartEnums::MeasureOrientation orientation ){ mOrientation = orientation; }
113
KDChartEnums::MeasureOrientation referenceOrientation() const { return mOrientation; }
116
* The reference area must either be derived from AbstractArea
117
* or be derived from QWidget, so e.g. it could be derived from
118
* AbstractAreaWidget too.
120
qreal calculatedValue( const QObject * autoArea, KDChartEnums::MeasureOrientation autoOrientation ) const;
121
qreal calculatedValue( const QSizeF& autoSize, KDChartEnums::MeasureOrientation autoOrientation ) const;
122
const QSizeF sizeOfArea( const QObject* area ) const;
124
bool operator==( const Measure& ) const;
125
bool operator!=( const Measure& other ) const { return !operator==(other); }
129
KDChartEnums::MeasureCalculationMode mMode;
130
const QObject* mArea;
131
KDChartEnums::MeasureOrientation mOrientation;
132
}; // End of class Measure
137
* Auxiliary class used by the KDChart::Measure and KDChart::Chart class.
139
* Normally there should be no need to call any of these methods yourself.
141
* They are used by KDChart::Chart::paint( QPainter*, const QRect& )
142
* to adjust all of the relative Measures according to the target
145
* Default factors are (1.0, 1.0)
147
class GlobalMeasureScaling
150
static GlobalMeasureScaling* instance();
152
GlobalMeasureScaling();
153
virtual ~GlobalMeasureScaling();
157
* Set new factors to be used by all Measure objects from now on.
158
* Previous values will be stored.
160
static void setFactors(qreal factorX, qreal factorY);
163
* Reset factors to the values active before the previous call of
165
* This works on a stack, so recursive calls works fine, like:
166
* setFactors, setFactors, unserFactors, unsetFactors
168
static void resetFactors();
171
* Returns the currently active factors.
173
static const QPair< qreal, qreal > currentFactors();
176
* Sets the paint device usable for calculating fort metrics.
178
static void setPaintDevice( QPaintDevice* paintDevice );
181
* Returns the paint device usable for calculating fort metrics.
183
static QPaintDevice* paintDevice();
186
QStack< QPair< qreal, qreal > > mFactors;
187
QPaintDevice* m_paintDevice;
192
#if !defined(QT_NO_DEBUG_STREAM)
193
KDCHART_EXPORT QDebug operator<<(QDebug, const KDChart::Measure& );
194
#endif /* QT_NO_DEBUG_STREAM */
196
#endif // KDCHARTMEASURE_H