Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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-2006 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 
00048 namespace KDChart {
00049 
00056 class KDCHART_EXPORT Measure
00057 {
00058 public:
00059     Measure();
00060     /*implicit*/ Measure( qreal value,
00061                           KDChartEnums::MeasureCalculationMode mode = KDChartEnums::MeasureCalculationModeAuto,
00062                           KDChartEnums::MeasureOrientation orientation = KDChartEnums::MeasureOrientationAuto );
00063     Measure( const Measure& );
00064     Measure &operator= ( const Measure& );
00065 
00066     void setValue( qreal val ){ mValue = val; }
00067     qreal value() const { return mValue; }
00068 
00069     void setCalculationMode( KDChartEnums::MeasureCalculationMode mode ){ mMode = mode; }
00070     KDChartEnums::MeasureCalculationMode calculationMode() const { return mMode; }
00071 
00077     void setRelativeMode( const QObject * area,
00078                           KDChartEnums::MeasureOrientation orientation )
00079     {
00080         mMode = KDChartEnums::MeasureCalculationModeRelative;
00081         mArea = area;
00082         mOrientation = orientation;
00083     }
00084 
00095     void setAbsoluteValue( qreal val )
00096     {
00097         mMode = KDChartEnums::MeasureCalculationModeAbsolute;
00098         mValue = val;
00099     }
00100 
00106     void setReferenceArea( const QObject * area ){ mArea = area; }
00111     const QObject * referenceArea() const { return mArea; }
00112 
00113     void setReferenceOrientation( KDChartEnums::MeasureOrientation orientation ){ mOrientation = orientation; }
00114     KDChartEnums::MeasureOrientation referenceOrientation() const { return mOrientation; }
00115 
00121     qreal calculatedValue( const QObject * autoArea, KDChartEnums::MeasureOrientation autoOrientation ) const;
00122     qreal calculatedValue( const QSizeF& autoSize, KDChartEnums::MeasureOrientation autoOrientation ) const;
00123     const QSizeF sizeOfArea( const QObject* area ) const;
00124 
00125     bool operator==( const Measure& ) const;
00126     bool operator!=( const Measure& other ) const { return !operator==(other); }
00127 
00128 private:
00129     qreal mValue;
00130     KDChartEnums::MeasureCalculationMode mMode;
00131     const QObject* mArea;
00132     KDChartEnums::MeasureOrientation mOrientation;
00133 }; // End of class Measure
00134 
00135 
00136 
00148 class GlobalMeasureScaling
00149 {
00150 public:
00151     static GlobalMeasureScaling* instance();
00152 
00153     GlobalMeasureScaling();
00154     virtual ~GlobalMeasureScaling();
00155 
00156 public:
00161     static void setFactors(qreal factorX, qreal factorY);
00162 
00169     static void resetFactors();
00170 
00174     static const QPair< qreal, qreal > currentFactors();
00175 
00176 private:
00177     QStack< QPair< qreal, qreal > > mFactors;
00178 };
00179 
00180 }
00181 
00182 #if !defined(QT_NO_DEBUG_STREAM)
00183 KDCHART_EXPORT QDebug operator<<(QDebug, const KDChart::Measure& );
00184 #endif /* QT_NO_DEBUG_STREAM */
00185 
00186 #endif // KDCHARTMEASURE_H

Generated on Thu May 10 11:06:25 2007 for KD Chart 2 by doxygen 1.3.6