KD Chart 2  [rev.2.7]
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
KDChart::Position Class Reference

Defines a position, using compass terminology. More...

#include <KDChartPosition.h>

Collaboration diagram for KDChart::Position:
Collaboration graph
[legend]

Public Types

enum  Option {
  IncludeCenter = 0x1,
  IncludeFloating = 0x2
}
 

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. More...
 
bool operator!= (const Position &) const
 
bool operator!= (int) const
 
bool operator== (const Position &) const
 
bool operator== (int) const
 
 Position ()
 Default constructor. More...
 
 Position (KDChartEnums::PositionValue value)
 Constructor. More...
 
QString printableName () const
 Returns a translated string, corresponding to this Position. More...
 
KDChartEnums::PositionValue value () const
 Returns an integer value corresponding to this Position. More...
 

Static Public Member Functions

static Position fromName (const char *name)
 
static Position fromName (const QByteArray &name)
 
static QList< QByteArray > names (Options options=Options(IncludeCenter|IncludeFloating))
 Returns a list of all string, corresponding to the pre-defined positions. More...
 
static QStringList printableNames (Options options=Options(IncludeCenter|IncludeFloating))
 Returns a list of all translated string, corresponding to the pre-defined positions. More...
 

Static Public Attributes

static const PositionCenter = staticPositionCenter
 
static const PositionEast = staticPositionEast
 
static const PositionFloating = staticPositionFloating
 
static const PositionNorth = staticPositionNorth
 
static const PositionNorthEast = staticPositionNorthEast
 
static const PositionNorthWest = staticPositionNorthWest
 
static const PositionSouth = staticPositionSouth
 
static const PositionSouthEast = staticPositionSouthEast
 
static const PositionSouthWest = staticPositionSouthWest
 
static const PositionUnknown = staticPositionUnknown
 
static const PositionWest = staticPositionWest
 

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.

For each piece (slice/bar, etc.) of a chart for example, you can specify the position of the value labels. Figure 1 illustrates which cardinal points refer to which points on a pie or bar chart, resp. In the graphic, "N" stands for North, "S" for South, etc.

position-alignments.png
Figure 1: Different interpretations of KDChart::Position within KDChart
Note
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.

Member Enumeration Documentation

Enumerator
IncludeCenter 
IncludeFloating 

Definition at line 114 of file KDChartPosition.h.

Constructor & Destructor Documentation

Position::Position ( )

Default constructor.

Creates a new Position, defaulting it to Position::Unknown.

Definition at line 93 of file KDChartPosition.cpp.

References value().

Referenced by fromName().

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 117 of file KDChartPosition.cpp.

Member Function Documentation

Position Position::fromName ( const char *  name)
static

Definition at line 230 of file KDChartPosition.cpp.

References Position().

Referenced by fromName().

Position Position::fromName ( const QByteArray &  name)
static

Definition at line 238 of file KDChartPosition.cpp.

References fromName().

bool Position::isCorner ( ) const

Definition at line 161 of file KDChartPosition.cpp.

References value().

bool Position::isEastSide ( ) const

Definition at line 148 of file KDChartPosition.cpp.

References value().

bool Position::isFloating ( ) const

Definition at line 174 of file KDChartPosition.cpp.

References value().

Referenced by KDChart::Chart::reLayoutFloatingLegends().

bool Position::isNorthSide ( ) const

Definition at line 142 of file KDChartPosition.cpp.

References value().

bool Position::isPole ( ) const

Definition at line 168 of file KDChartPosition.cpp.

References value().

bool Position::isSouthSide ( ) const

Definition at line 154 of file KDChartPosition.cpp.

References value().

bool Position::isUnknown ( ) const

Definition at line 131 of file KDChartPosition.cpp.

References value().

bool Position::isWestSide ( ) const

Definition at line 136 of file KDChartPosition.cpp.

References value().

const char * Position::name ( ) const

Returns a non-translated string in English language, corresponding to this Position.

Definition at line 182 of file KDChartPosition.cpp.

Referenced by operator<<().

QList< QByteArray > Position::names ( Options  options = Options(IncludeCenter | IncludeFloating))
static

Returns a list of all string, corresponding to the pre-defined positions.

Parameters
optionsif set to ExcludeCenter, the returned list does not contain the Center position.

Definition at line 203 of file KDChartPosition.cpp.

References IncludeCenter, and IncludeFloating.

bool KDChart::Position::operator!= ( const Position other) const

Definition at line 138 of file KDChartPosition.h.

References KDGantt::operator==().

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

Definition at line 139 of file KDChartPosition.h.

References KDGantt::operator==().

bool Position::operator== ( const Position r) const

Definition at line 242 of file KDChartPosition.cpp.

References value().

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

Definition at line 248 of file KDChartPosition.cpp.

References value().

QString Position::printableName ( ) const

Returns a translated string, corresponding to this Position.

Definition at line 190 of file KDChartPosition.cpp.

Referenced by printableNames().

QStringList Position::printableNames ( Options  options = Options(IncludeCenter | IncludeFloating))
static

Returns a list of all translated string, corresponding to the pre-defined positions.

Parameters
optionsif set to ExcludeCenter, the returned list does not contain the Center position.

Definition at line 220 of file KDChartPosition.cpp.

References IncludeCenter, IncludeFloating, and printableName().

KDChartEnums::PositionValue Position::value ( ) const

Member Data Documentation

const Position & Position::Center = staticPositionCenter
static
const Position & Position::East = staticPositionEast
static
const Position & Position::Floating = staticPositionFloating
static
const Position & Position::North = staticPositionNorth
static
const Position & Position::NorthEast = staticPositionNorthEast
static
const Position & Position::NorthWest = staticPositionNorthWest
static
const Position & Position::South = staticPositionSouth
static
const Position & Position::SouthEast = staticPositionSouthEast
static
const Position & Position::SouthWest = staticPositionSouthWest
static
const Position & Position::Unknown = staticPositionUnknown
static
const Position & Position::West = staticPositionWest
static

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

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/