KDChartMeasure.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2005-2007 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KD Chart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
00016  ** accordance with the KD Chart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.kdab.net/kdchart for
00023  **   information about KD Chart Commercial License Agreements.
00024  **
00025  ** Contact info@kdab.net if any conditions of this
00026  ** licensing are not clear to you.
00027  **
00028  **********************************************************************/
00029 
00030 #ifndef KDCHARTMEASURE_H
00031 #define KDCHARTMEASURE_H
00032 
00033 #include <QDebug>
00034 #include <Qt>
00035 #include <QStack>
00036 #include "KDChartGlobal.h"
00037 #include "KDChartEnums.h"
00038 
00046 class QObject;
00047 class QPaintDevice;
00048 
00049 namespace KDChart {
00050 
00057 class KDCHART_EXPORT Measure
00058 {
00059 public:
00060     Measure();
00061     /*implicit*/ Measure( qreal value,
00062                           KDChartEnums::MeasureCalculationMode mode = KDChartEnums::MeasureCalculationModeAuto,
00063                           KDChartEnums::MeasureOrientation orientation = KDChartEnums::MeasureOrientationAuto );
00064     Measure( const Measure& );
00065     Measure &operator= ( const Measure& );
00066 
00067     void setValue( qreal val ){ mValue = val; }
00068     qreal value() const { return mValue; }
00069 
00070     void setCalculationMode( KDChartEnums::MeasureCalculationMode mode ){ mMode = mode; }
00071     KDChartEnums::MeasureCalculationMode calculationMode() const { return mMode; }
00072 
00078     void setRelativeMode( const QObject * area,
00079                           KDChartEnums::MeasureOrientation orientation )
00080     {
00081         mMode = KDChartEnums::MeasureCalculationModeRelative;
00082         mArea = area;
00083         mOrientation = orientation;
00084     }
00085 
00096     void setAbsoluteValue( qreal val )
00097     {
00098         mMode = KDChartEnums::MeasureCalculationModeAbsolute;
00099         mValue = val;
00100     }
00101 
00107     void setReferenceArea( const QObject * area ){ mArea = area; }
00112     const QObject * referenceArea() const { return mArea; }
00113 
00114     void setReferenceOrientation( KDChartEnums::MeasureOrientation orientation ){ mOrientation = orientation; }
00115     KDChartEnums::MeasureOrientation referenceOrientation() const { return mOrientation; }
00116 
00122     qreal calculatedValue( const QObject * autoArea, KDChartEnums::MeasureOrientation autoOrientation ) const;
00123     qreal calculatedValue( const QSizeF& autoSize, KDChartEnums::MeasureOrientation autoOrientation ) const;
00124     const QSizeF sizeOfArea( const QObject* area ) const;
00125 
00126     bool operator==( const Measure& ) const;
00127     bool operator!=( const Measure& other ) const { return !operator==(other); }
00128 
00129 private:
00130     qreal mValue;
00131     KDChartEnums::MeasureCalculationMode mMode;
00132     const QObject* mArea;
00133     KDChartEnums::MeasureOrientation mOrientation;
00134 }; // End of class Measure
00135 
00136 
00137 
00149 class GlobalMeasureScaling
00150 {
00151 public:
00152     static GlobalMeasureScaling* instance();
00153 
00154     GlobalMeasureScaling();
00155     virtual ~GlobalMeasureScaling();
00156 
00157 public:
00162     static void setFactors(qreal factorX, qreal factorY);
00163 
00170     static void resetFactors();
00171 
00175     static const QPair< qreal, qreal > currentFactors();
00176 
00180     static void setPaintDevice( QPaintDevice* paintDevice );
00181 
00185     static QPaintDevice* paintDevice();
00186 
00187 private:
00188     QStack< QPair< qreal, qreal > > mFactors;
00189     QPaintDevice* m_paintDevice;
00190 };
00191 
00192 }
00193 
00194 #if !defined(QT_NO_DEBUG_STREAM)
00195 KDCHART_EXPORT QDebug operator<<(QDebug, const KDChart::Measure& );
00196 #endif /* QT_NO_DEBUG_STREAM */
00197 
00198 #endif // KDCHARTMEASURE_H

Generated on Thu Mar 4 23:19:12 2010 for KD Chart 2 by  doxygen 1.5.4