KD Chart 2: KDChart::Measure class Reference

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

# KDChart::Measure Class Reference

`#include <KDChartMeasure>`

Collaboration diagram for KDChart::Measure:

[legend]
List of all members.

## Detailed Description

Measure is used to specify all relative and/or absolute measures in KDChart, e.g. font sizes.

Definition at line 56 of file KDChartMeasure.h.

## Public Member Functions
qreal | calculatedValue (const QSizeF &autoSize, KDChartEnums::MeasureOrientation autoOrientation) const
qreal | calculatedValue (const QObject *autoArea, KDChartEnums::MeasureOrientation autoOrientation) const
| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g.
KDChartEnums::MeasureCalculationMode | calculationMode () const
| Measure (const Measure &)
| Measure (qreal value, KDChartEnums::MeasureCalculationMode mode=KDChartEnums::MeasureCalculationModeAuto, KDChartEnums::MeasureOrientation orientation=KDChartEnums::MeasureOrientationAuto)
| Measure ()
bool | operator!= (const Measure &other) const
Measure & | operator= (const Measure &)
bool | operator== (const Measure &) const
const QObject * | referenceArea () const
| The returned reference area will either be derived from AbstractArea or be derived from QWidget.
KDChartEnums::MeasureOrientation | referenceOrientation () const
void | setAbsoluteValue (qreal val)
| This is a convenience method for specifying a value, with implicitely setting the calculation mode to MeasureCalculationModeAbsolute.
void | setCalculationMode (KDChartEnums::MeasureCalculationMode mode)
void | setReferenceArea (const QObject *area)
| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g.
void | setReferenceOrientation (KDChartEnums::MeasureOrientation orientation)
void | setRelativeMode (const QObject *area, KDChartEnums::MeasureOrientation orientation)
| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g.
void | setValue (qreal val)
const QSizeF | sizeOfArea (const QObject *area) const
qreal | value () const

## Constructor & Destructor Documentation

KDChart::Measure::Measure | ( |  | ) |

| Definition at line 41 of file KDChartMeasure.cpp.
    00042   : mValue( 0.0 ),
    00043     mMode(  KDChartEnums::MeasureCalculationModeAuto ),
    00044     mArea(  0 ),
    00045     mOrientation( KDChartEnums::MeasureOrientationAuto )
    00046 {
    00047     // this bloc left empty intentionally
    00048 }

KDChart::Measure::Measure | ( | qreal | value,
|  | KDChartEnums::MeasureCalculationMode | mode = KDChartEnums::MeasureCalculationModeAuto,
|  | KDChartEnums::MeasureOrientation | orientation = KDChartEnums::MeasureOrientationAuto
| ) |

| Definition at line 50 of file KDChartMeasure.cpp.
    00053   : mValue( value ),
    00054     mMode(  mode ),
    00055     mArea(  0 ),
    00056     mOrientation( orientation )
    00057 {
    00058     // this bloc left empty intentionally
    00059 }

KDChart::Measure::Measure | ( | const Measure & |  | ) |

| Definition at line 61 of file KDChartMeasure.cpp.
    00062   : mValue( r.value() ),
    00063     mMode(  r.calculationMode() ),
    00064     mArea(  r.referenceArea() ),
    00065     mOrientation( r.referenceOrientation() )
    00066 {
    00067     // this bloc left empty intentionally
    00068 }

## Member Function Documentation

qreal KDChart::Measure::calculatedValue | ( | const QSizeF & | autoSize,
|  | KDChartEnums::MeasureOrientation | autoOrientation
| ) | const

| Definition at line 83 of file KDChartMeasure.cpp. References sizeOfArea(), and value().
    00085 {
    00086     if( mMode == KDChartEnums::MeasureCalculationModeAbsolute ){
    00087         return mValue;
    00088     }else{
    00089         qreal value = 0.0;
    00090         const QObject theAutoArea;
    00091         const QObject* autoArea = &theAutoArea;
    00092         const QObject* area = mArea ? mArea : autoArea;
    00093         KDChartEnums::MeasureOrientation orientation = mOrientation;
    00094         switch( mMode ){
    00095             case KDChartEnums::MeasureCalculationModeAuto:
    00096                 area = autoArea;
    00097                 orientation = autoOrientation;
    00098                 break;
    00099             case KDChartEnums::MeasureCalculationModeAutoArea:
    00100                 area = autoArea;
    00101                 break;
    00102             case KDChartEnums::MeasureCalculationModeAutoOrientation:
    00103                 orientation = autoOrientation;
    00104                 break;
    00105             case KDChartEnums::MeasureCalculationModeAbsolute: // fall through intended
    00106             case KDChartEnums::MeasureCalculationModeRelative:
    00107                 break;
    00108         }
    00109         if( area ){
    00110             QSizeF size;
    00111             if( area == autoArea )
    00112                 size = autoSize;
    00113             else
    00114                 size = sizeOfArea( area );
    00115             //qDebug() << "size" << size;
    00116             qreal referenceValue;
    00117             switch( orientation ){
    00118                 case KDChartEnums::MeasureOrientationAuto: // fall through intended
    00119                 case KDChartEnums::MeasureOrientationMinimum:
    00120                     referenceValue = qMin( size.width(), size.height() );
    00121                     break;
    00122                 case KDChartEnums::MeasureOrientationMaximum:
    00123                     referenceValue = qMax( size.width(), size.height() );
    00124                     break;
    00125                 case KDChartEnums::MeasureOrientationHorizontal:
    00126                     referenceValue = size.width();
    00127                     break;
    00128                 case KDChartEnums::MeasureOrientationVertical:
    00129                     referenceValue = size.height();
    00130                     break;
    00131             }
    00132             value = mValue / 1000.0 * referenceValue;
    00133         }
    00134         return value;
    00135     }
    00136 }

qreal KDChart::Measure::calculatedValue | ( | const QObject * | autoArea,
|  | KDChartEnums::MeasureOrientation | autoOrientation
| ) | const

| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g. it could be derived from AbstractAreaWidget too. Definition at line 139 of file KDChartMeasure.cpp. References sizeOfArea().
    00141 {
    00142     return calculatedValue( sizeOfArea( autoArea ), autoOrientation);
    00143 }

KDChartEnums::MeasureCalculationMode KDChart::Measure::calculationMode | ( |  | ) | const

| Definition at line 70 of file KDChartMeasure.h. Referenced by operator<<(), operator=(), and operator==().
    00070 { return mMode; }

bool KDChart::Measure::operator!= | ( | const Measure & | other | ) | const

| Definition at line 126 of file KDChartMeasure.h.
    00126 { return !operator==(other); }

Measure & KDChart::Measure::operator= | ( | const Measure & |  | ) |

| Definition at line 70 of file KDChartMeasure.cpp. References calculationMode(), referenceArea(), referenceOrientation(), and value().
    00071 {
    00072     if( this != &r ){
    00073         mValue = r.value();
    00074         mMode  = r.calculationMode();
    00075         mArea  = r.referenceArea();
    00076         mOrientation = r.referenceOrientation();
    00077     }
    00078
    00079     return *this;
    00080 }

bool KDChart::Measure::operator== | ( | const Measure & |  | ) | const

| Definition at line 177 of file KDChartMeasure.cpp. References calculationMode(), referenceArea(), referenceOrientation(), and value().
    00178 {
    00179     return( mValue == r.value() &&
    00180             mMode  == r.calculationMode() &&
    00181             mArea  == r.referenceArea() &&
    00182             mOrientation == r.referenceOrientation() );
    00183 }

const QObject* KDChart::Measure::referenceArea | ( |  | ) | const

| The returned reference area will either be derived from AbstractArea or be derived from QWidget. Definition at line 111 of file KDChartMeasure.h. Referenced by operator<<(), operator=(), and operator==().
    00111 { return mArea; }

KDChartEnums::MeasureOrientation KDChart::Measure::referenceOrientation | ( |  | ) | const

| Definition at line 114 of file KDChartMeasure.h. Referenced by operator<<(), operator=(), and operator==().
    00114 { return mOrientation; }

void KDChart::Measure::setAbsoluteValue | ( | qreal | val | ) |

| This is a convenience method for specifying a value, with implicitely setting the calculation mode to MeasureCalculationModeAbsolute. Calling setAbsoluteValue( value ) is the same as calling
        setValue( value );
        setCalculationMode( KDChartEnums::MeasureCalculationModeAbsolute );
Definition at line 95 of file KDChartMeasure.h.
    00096     {
    00097         mMode = KDChartEnums::MeasureCalculationModeAbsolute;
    00098         mValue = val;
    00099     }

void KDChart::Measure::setCalculationMode | ( | KDChartEnums::MeasureCalculationMode | mode | ) |

| Definition at line 69 of file KDChartMeasure.h.
    00069 { mMode = mode; }

void KDChart::Measure::setReferenceArea | ( | const QObject * | area | ) |

| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g. it could be derived from AbstractAreaWidget too. Definition at line 106 of file KDChartMeasure.h.
    00106 { mArea = area; }

void KDChart::Measure::setReferenceOrientation | ( | KDChartEnums::MeasureOrientation | orientation | ) |

| Definition at line 113 of file KDChartMeasure.h.
    00113 { mOrientation = orientation; }

void KDChart::Measure::setRelativeMode | ( | const QObject * | area,
|  | KDChartEnums::MeasureOrientation | orientation
| ) |

| The reference area must either be derived from AbstractArea or be derived from QWidget, so e.g. it could be derived from AbstractAreaWidget too. Definition at line 77 of file KDChartMeasure.h. Referenced by KDChart::Chart::addLegend().
    00079     {
    00080         mMode = KDChartEnums::MeasureCalculationModeRelative;
    00081         mArea = area;
    00082         mOrientation = orientation;
    00083     }

void KDChart::Measure::setValue | ( | qreal | val | ) |

| Definition at line 66 of file KDChartMeasure.h. Referenced by KDChart::Chart::addLegend(), and KDChart::CartesianAxis::titleTextAttributes().
    00066 { mValue = val; }

const QSizeF KDChart::Measure::sizeOfArea | ( | const QObject * | area | ) | const

| Definition at line 146 of file KDChartMeasure.cpp. Referenced by calculatedValue().
    00147 {
    00148     QSizeF size;
    00149     const AbstractArea* kdcArea = dynamic_cast<const AbstractArea*>(area);
    00150     if( kdcArea ){
    00151         size = kdcArea->geometry().size();
    00152         //qDebug() << "Measure::sizeOfArea() found kdcArea with size" << size;
    00153     }else{
    00154         const QWidget* widget = dynamic_cast<const QWidget*>(area);
    00155         if( widget ){
    00156             /* ATTENTION: Using the layout does not work: The Legend will never get the right size then!
    00157             const QLayout * layout = widget->layout();
    00158             if( layout ){
    00159                 size = layout->geometry().size();
    00160                 //qDebug() << "Measure::sizeOfArea() found widget with layout size" << size;
    00161             }else*/
    00162             {
    00163                 size = widget->geometry().size();
    00164                 //qDebug() << "Measure::sizeOfArea() found widget with size" << size;
    00165             }
    00166         }else if( mMode != KDChartEnums::MeasureCalculationModeAbsolute ){
    00167             size = QSizeF(1.0, 1.0);
    00168             //qDebug("Measure::sizeOfArea() got no valid area.");
    00169         }
    00170     }
    00171     const QPair< qreal, qreal > factors
    00172             = GlobalMeasureScaling::instance()->currentFactors();
    00173     return QSizeF(size.width() * factors.first, size.height() * factors.second);
    00174 }

qreal KDChart::Measure::value | ( |  | ) | const

| Definition at line 67 of file KDChartMeasure.h. Referenced by calculatedValue(), operator<<(), operator=(), operator==(), and KDChart::CartesianAxis::titleTextAttributes().
    00067 { return mValue; }

The documentation for this class was generated from the following files:

- KDChartMeasure.h
- KDChartMeasure.cpp