#include <KDChartPosition.h>
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; }
Definition at line 75 of file KDChartPosition.h.
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. | |
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 | |
static Position | fromName (const QByteArray &name) |
static Position | fromName (const char *name) |
static QList< QByteArray > | names (Options options=Options(IncludeCenter|IncludeFloating)) |
Returns a list of all string, corresponding to the pre-defined positions. | |
static QStringList | printableNames (Options options=Options(IncludeCenter|IncludeFloating)) |
Returns a list of all translated string, corresponding to the pre-defined positions. | |
Static Public Attributes | |
static const Position & | Center = staticPositionCenter |
static const Position & | East = staticPositionEast |
static const Position & | Floating = staticPositionFloating |
static const Position & | North = staticPositionNorth |
static const Position & | NorthEast = staticPositionNorthEast |
static const Position & | NorthWest = staticPositionNorthWest |
static const Position & | South = staticPositionSouth |
static const Position & | SouthEast = staticPositionSouthEast |
static const Position & | SouthWest = staticPositionSouthWest |
static const Position & | Unknown = staticPositionUnknown |
static const Position & | West = staticPositionWest |
Definition at line 114 of file KDChartPosition.h.
00114 { 00115 IncludeCenter = 0x1, 00116 IncludeFloating = 0x2 };
Position::Position | ( | ) |
Default constructor.
Creates a new Position, defaulting it to Position::Unknown.
Definition at line 100 of file KDChartPosition.cpp.
Referenced by fromName().
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.
* const KDChart::Position myPosition = KDChart::Position::NorthEast; *
Definition at line 124 of file KDChartPosition.cpp.
00125 : m_value( value ) 00126 { 00127 00128 }
Position Position::fromName | ( | const QByteArray & | name | ) | [static] |
Position Position::fromName | ( | const char * | name | ) | [static] |
Definition at line 237 of file KDChartPosition.cpp.
References maxPositionValue, Position(), and staticPositionNames.
Referenced by fromName().
00238 { 00239 for( int i=1; i<=maxPositionValue; ++i) 00240 if ( !qstricmp( name, staticPositionNames[i] ) ) 00241 return Position(i); 00242 return Position(0); 00243 }
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 = Options(IncludeCenter | IncludeFloating) |
) | [static] |
Returns a list of all string, corresponding to the pre-defined positions.
options | if set to ExcludeCenter , the returned list does not contain the Center position. |
Definition at line 210 of file KDChartPosition.cpp.
References IncludeCenter, IncludeFloating, maxPositionValue, and staticPositionNames.
00211 { 00212 QList<QByteArray> list; 00213 const int start = ( options & IncludeCenter ) ? 1 : 2; 00214 const int end = ( options & IncludeFloating ) ? maxPositionValue : maxPositionValue-1; 00215 for( int i=start; i<=end; ++i) 00216 list.append( staticPositionNames[i] ); 00217 return list; 00218 }
bool KDChart::Position::operator!= | ( | int | other | ) | const |
Definition at line 139 of file KDChartPosition.h.
References operator==().
00139 { return !operator==( other ); }
bool KDChart::Position::operator!= | ( | const Position & | other | ) | const |
Definition at line 138 of file KDChartPosition.h.
References KDGantt::operator==().
00138 { return !operator==( other ); }
bool Position::operator== | ( | int | value_ | ) | const |
Definition at line 255 of file KDChartPosition.cpp.
References value().
00256 { 00257 return ( value() == value_ ); 00258 }
bool Position::operator== | ( | const Position & | r | ) | const |
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 = Options(IncludeCenter | IncludeFloating) |
) | [static] |
Returns a list of all translated string, corresponding to the pre-defined positions.
options | if set to ExcludeCenter , the returned list does not contain the Center position. |
Definition at line 227 of file KDChartPosition.cpp.
References IncludeCenter, IncludeFloating, maxPositionValue, and printableName().
00228 { 00229 QStringList list; 00230 const int start = ( options & IncludeCenter ) ? 1 : 2; 00231 const int end = ( options & IncludeFloating ) ? maxPositionValue : maxPositionValue-1; 00232 for( int i=start; i<=end; ++i) 00233 list.append( Position(i).printableName() ); 00234 return list; 00235 }
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::TernaryAxis::setPosition(), KDChart::PolarDiagram::setShowDelimitersAtPosition(), KDChart::PolarDiagram::setShowLabelsAtPosition(), KDChart::PolarDiagram::showDelimitersAtPosition(), and KDChart::PolarDiagram::showLabelsAtPosition().
00134 { 00135 return static_cast<KDChartEnums::PositionValue>( m_value ); 00136 }
const Position & Position::Center = staticPositionCenter [static] |
Definition at line 101 of file KDChartPosition.h.
Referenced by KDChart::PolarDiagram::paint(), and KDChart::PositionPoints::point().
const Position & Position::East = staticPositionEast [static] |
const Position & Position::Floating = staticPositionFloating [static] |
Definition at line 111 of file KDChartPosition.h.
Referenced by KDChart::Legend::setFloatingPosition().
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] |
Definition at line 100 of file KDChartPosition.h.
Referenced by KDChart::RelativePosition::resetReferencePosition().
const Position & Position::West = staticPositionWest [static] |