KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
geotypes.h
1/**
2 * @brief Geographic type enumerations and string-conversion helpers for Qt geometry types.
3 */
4#ifndef GEOTYPES_H
5#define GEOTYPES_H
6
7#include <QList>
8#include <QRect>
9#include <QString>
10
11/**
12 * @brief Geographic namespace providing cardinal direction enumerations and geometry string helpers.
13 */
14namespace Geo {
15
16/**
17 * @brief Cardinal compass directions used by geographic coordinates.
18 */
20{
21 InvalidCardinalDirection = 0, ///< Sentinel value for uninitialized direction
22 North = 1, ///< North latitude hemisphere
23 East = 2, ///< East longitude hemisphere
24 South = 3, ///< South latitude hemisphere
25 West = 4 ///< West longitude hemisphere
26};
27
28/**
29 * @brief Format a QRect as a human-readable "x,y w,h" string.
30 * @param rect Rectangle to format
31 * @return String of the form "x,y W,H w,h W,H"
32 */
33static inline QString string(const QRect& rect)
34{
35 return QString("x,y %1,%2 w,h %3,%4").arg(rect.topLeft().x()).arg(rect.topLeft().y()).arg(rect.width()).arg(rect.height());
36}
37
38/**
39 * @brief Format a QSize as a human-readable "w,h" string.
40 * @param size Size to format
41 * @return String of the form "w,h W,H"
42 */
43static inline QString string(const QSize& size)
44{
45 return QString("w,h %1,%2").arg(size.width()).arg(size.height());
46}
47
48/**
49 * @brief Format an integer QPoint as a "x,y" string.
50 * @param point Point to format
51 * @return String of the form "x,y"
52 */
53static inline QString string(const QPoint& point)
54{
55 return QString("%1,%2").arg(point.x()).arg(point.y());
56}
57
58/**
59 * @brief Format a floating-point QPointF as a "x,y" string.
60 * @param point Point to format
61 * @return String of the form "x,y"
62 */
63static inline QString string(const QPointF& point)
64{
65 return QString("%1,%2").arg(point.x()).arg(point.y());
66}
67
68}
69
70#endif // GEOTYPES_H
Geographic type enumerations and string-conversion helpers for Qt geometry types.
Definition geotypes.h:14
static QString string(const QRect &rect)
Format a QRect as a human-readable "x,y w,h" string.
Definition geotypes.h:33
CardinalDirection
Cardinal compass directions used by geographic coordinates.
Definition geotypes.h:20
@ South
South latitude hemisphere.
Definition geotypes.h:24
@ East
East longitude hemisphere.
Definition geotypes.h:23
@ InvalidCardinalDirection
Sentinel value for uninitialized direction.
Definition geotypes.h:21
@ North
North latitude hemisphere.
Definition geotypes.h:22
@ West
West longitude hemisphere.
Definition geotypes.h:25