KD Chart 2: KDChart::Position class Reference

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

# KDChart::Position Class Reference

`#include <KDChartPosition.h>`

Collaboration diagram for KDChart::Position:

[legend]
List of all members.

## Detailed Description

Defines a position, using compass terminology.

Using KDChartPosition you can specify one of nine pre-defined, logical points (see the `static` `const` getter methods below), in a similar way, as you would use a compass to navigate on a map.

Often you will declare a `Position` together with the RelativePosition class, to specify a logical point, which then will be used to layout your chart at runtime, e.g. for specifying the location of a floating Legend box.

For comparing a Position's value with a switch() statement, you can use numeric values defined in KDChartEnums, like this:

    switch( yourPosition().value() ) {
        case KDChartEnums::PositionNorthWest:
            // your code ...
            break;
        case KDChartEnums::PositionNorth:
            // your code ...
            break;
    }

See also:
  RelativePosition, KDChartEnums::PositionValue

Definition at line 75 of file KDChartPosition.h.

## Public Types
enum | Option { IncludeCenter = 0, ExcludeCenter = 1 }
## Public Member Functions
bool | isCorner () const
bool | isEastSide () const
bool | isFloating () const
bool | isNorthSide () const
bool | isPole () const
bool | isSouthSide () const
bool | isUnknown () const
bool | isWestSide () const
const char * | name () const
| Returns a non-translated string in English language, corresponding to this Position.
bool | operator!= (int) const
bool | operator!= (const Position &) const
bool | operator== (int) const
bool | operator== (const Position &) const
| Position (KDChartEnums::PositionValue value)
| Constructor.
| Position ()
| Default constructor.
QString | printableName () const
| Returns a translated string, corresponding to this Position.
KDChartEnums::PositionValue | value () const
| Returns an integer value corresponding to this Position.
## Static Public Member Functions
Position | fromName (const QByteArray &name)
Position | fromName (const char *name)
QList< QByteArray > | names (Options options=IncludeCenter)
| Returns a list of all string, corresponding to the pre-defined positions.
QStringList | printableNames (Options options=IncludeCenter)
| Returns a list of all translated string, corresponding to the pre-defined positions.
## Static Public Attributes
const Position & | Center = staticPositionCenter
const Position & | East = staticPositionEast
const Position & | Floating = staticPositionFloating
const Position & | North = staticPositionNorth
const Position & | NorthEast = staticPositionNorthEast
const Position & | NorthWest = staticPositionNorthWest
const Position & | South = staticPositionSouth
const Position & | SouthEast = staticPositionSouthEast
const Position & | SouthWest = staticPositionSouthWest
const Position & | Unknown = staticPositionUnknown
const Position & | West = staticPositionWest

## Member Enumeration Documentation

enum KDChart::Position::Option

  | Enumeration values:
  IncludeCenter |
  ExcludeCenter |
Definition at line 113 of file KDChartPosition.h.
    00113 { IncludeCenter=0, ExcludeCenter=1 };

## Constructor & Destructor Documentation

Position::Position | ( |  | ) |

| Default constructor. Creates a new Position, defaulting it to Position::Unknown. Definition at line 100 of file KDChartPosition.cpp. Referenced by fromName(), and printableNames().
    00101     : m_value( KDChartEnums::PositionUnknown )
    00102 {
    00103
    00104 }

Position::Position | ( | KDChartEnums::PositionValue | value | ) |

  | Constructor. Creates a new Position, defaulting it to the respective value. Valid values ranging from zero (unknown value) to 10. If invalid value is passed, a Position::Unknown is created. Note: Normally there is no need to call this constructor, but you would rather use one of the nine pre-defined, static values, e.g. like this:
       * const KDChart::Position myPosition = KDChart::Position::NorthEast;
       *
Definition at line 124 of file KDChartPosition.cpp.
    00125     : m_value( value )
    00126 {
    00127
    00128 }

## Member Function Documentation

Position Position::fromName | ( | const QByteArray & | name | ) | `[static]`

| Definition at line 243 of file KDChartPosition.cpp. References fromName().
    00243                                                      {
    00244     return fromName( name.data() );
    00245 }

Position Position::fromName | ( | const char * | name | ) | `[static]`

| Definition at line 235 of file KDChartPosition.cpp. References maxPositionValue, Position(), and staticPositionNames. Referenced by fromName().
    00236 {
    00237     for( int i=1; i<=maxPositionValue; ++i)
    00238         if ( !qstricmp( name, staticPositionNames[i] ) )
    00239             return Position(i);
    00240     return Position(0);
    00241 }

bool Position::isCorner | ( |  | ) | const

| Definition at line 168 of file KDChartPosition.cpp. References value().
    00169 {
    00170     return  m_value == Position::NorthWest.value() ||
    00171             m_value == Position::NorthEast.value() ||
    00172             m_value == Position::SouthEast.value() ||
    00173             m_value == Position::SouthWest.value();
    00174 }

bool Position::isEastSide | ( |  | ) | const

| Definition at line 155 of file KDChartPosition.cpp. References value().
    00156 {
    00157     return  m_value == Position::NorthEast.value() ||
    00158             m_value == Position::East.value() ||
    00159             m_value == Position::SouthEast.value();
    00160 }

bool Position::isFloating | ( |  | ) | const

| Definition at line 181 of file KDChartPosition.cpp. References value(). Referenced by KDChart::Chart::reLayoutFloatingLegends().
    00182 {
    00183     return  m_value == Position::Floating.value();
    00184 }

bool Position::isNorthSide | ( |  | ) | const

| Definition at line 149 of file KDChartPosition.cpp. References value().
    00150 {
    00151     return  m_value == Position::NorthWest.value() ||
    00152             m_value == Position::North.value() ||
    00153             m_value == Position::NorthEast.value();
    00154 }

bool Position::isPole | ( |  | ) | const

| Definition at line 175 of file KDChartPosition.cpp. References value().
    00176 {
    00177     return  m_value == Position::North.value() ||
    00178         m_value == Position::South.value();
    00179 }

bool Position::isSouthSide | ( |  | ) | const

| Definition at line 161 of file KDChartPosition.cpp. References value().
    00162 {
    00163     return  m_value == Position::SouthWest.value() ||
    00164             m_value == Position::South.value() ||
    00165             m_value == Position::SouthEast.value();
    00166 }

bool Position::isUnknown | ( |  | ) | const

| Definition at line 138 of file KDChartPosition.cpp. References value().
    00139 {
    00140     return  m_value == Position::Unknown.value();
    00141 }

bool Position::isWestSide | ( |  | ) | const

| Definition at line 143 of file KDChartPosition.cpp. References value().
    00144 {
    00145     return  m_value == Position::SouthWest.value() ||
    00146             m_value == Position::West.value() ||
    00147             m_value == Position::NorthWest.value();
    00148 }

const char * Position::name | ( |  | ) | const

| Returns a non-translated string in English language, corresponding to this Position. Definition at line 189 of file KDChartPosition.cpp. References staticPositionNames. Referenced by operator<<().
    00190 {
    00191     return staticPositionNames[m_value];
    00192 }

QList< QByteArray > Position::names | ( | Options | options = IncludeCenter | ) | `[static]`

  | Returns a list of all string, corresponding to the pre-defined positions. Parameters:
  options | if set to `ExcludeCenter`, the returned list does not contain the Center position.
Definition at line 210 of file KDChartPosition.cpp. References IncludeCenter, maxPositionValue, and staticPositionNames.
    00211 {
    00212     QList<QByteArray> list;
    00213     const int start = ( options & IncludeCenter ) ? 1 : 2;
    00214     for( int i=start; i<=maxPositionValue; ++i)
    00215         list.append( staticPositionNames[i] );
    00216     return list;
    00217 }

bool KDChart::Position::operator!= | ( | int |  | ) | const

| Definition at line 132 of file KDChartPosition.h. References operator==().
    00132 { return !operator==( other ); }

bool KDChart::Position::operator!= | ( | const Position & |  | ) | const

| Definition at line 131 of file KDChartPosition.h. References operator==().
    00131 { return !operator==( other ); }

bool Position::operator== | ( | int |  | ) | const

| Definition at line 253 of file KDChartPosition.cpp. References value().
    00254 {
    00255     return ( value() == value_ );
    00256 }

bool Position::operator== | ( | const Position & |  | ) | const

| Definition at line 247 of file KDChartPosition.cpp. References value(). Referenced by operator!=().
    00248 {
    00249     return ( value() == r.value() );
    00250 }

QString Position::printableName | ( |  | ) | const

| Returns a translated string, corresponding to this Position. Definition at line 197 of file KDChartPosition.cpp. References staticPositionNames. Referenced by printableNames().
    00198 {
    00199     return tr(staticPositionNames[m_value]);
    00200 }

QStringList Position::printableNames | ( | Options | options = IncludeCenter | ) | `[static]`

  | Returns a list of all translated string, corresponding to the pre-defined positions. Parameters:
  options | if set to `ExcludeCenter`, the returned list does not contain the Center position.
Definition at line 226 of file KDChartPosition.cpp. References IncludeCenter, maxPositionValue, Position(), and printableName().
    00227 {
    00228     QStringList list;
    00229     const int start = ( options & IncludeCenter ) ? 1 : 2;
    00230     for( int i=start; i<=maxPositionValue; ++i)
    00231         list.append( Position(i).printableName() );
    00232     return list;
    00233 }

KDChartEnums::PositionValue Position::value | ( |  | ) | const

| Returns an integer value corresponding to this Position. Definition at line 133 of file KDChartPosition.cpp. Referenced by isCorner(), isEastSide(), isFloating(), isNorthSide(), isPole(), isSouthSide(), isUnknown(), isWestSide(), operator==(), KDChart::PolarDiagram::setShowDelimitersAtPosition(), KDChart::PolarDiagram::setShowLabelsAtPosition(), KDChart::PolarDiagram::showDelimitersAtPosition(), and KDChart::PolarDiagram::showLabelsAtPosition().
    00134 {
    00135     return static_cast<KDChartEnums::PositionValue>( m_value );
    00136 }

## Member Data Documentation

const Position & Position::Center = staticPositionCenter`[static]`

| Definition at line 85 of file KDChartPosition.cpp.

const Position & Position::East = staticPositionEast`[static]`

| Definition at line 89 of file KDChartPosition.cpp.

const Position & Position::Floating = staticPositionFloating`[static]`

| Definition at line 94 of file KDChartPosition.cpp.

const Position & Position::North = staticPositionNorth`[static]`

| Definition at line 87 of file KDChartPosition.cpp.

const Position & Position::NorthEast = staticPositionNorthEast`[static]`

| Definition at line 88 of file KDChartPosition.cpp.

const Position & Position::NorthWest = staticPositionNorthWest`[static]`

| Definition at line 86 of file KDChartPosition.cpp.

const Position & Position::South = staticPositionSouth`[static]`

| Definition at line 91 of file KDChartPosition.cpp.

const Position & Position::SouthEast = staticPositionSouthEast`[static]`

| Definition at line 90 of file KDChartPosition.cpp.

const Position & Position::SouthWest = staticPositionSouthWest`[static]`

| Definition at line 92 of file KDChartPosition.cpp.

const Position & Position::Unknown = staticPositionUnknown`[static]`

| Definition at line 84 of file KDChartPosition.cpp.

const Position & Position::West = staticPositionWest`[static]`

| Definition at line 93 of file KDChartPosition.cpp.

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

- KDChartPosition.h
- KDChartPosition.cpp