QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskTickmarks.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_TICKMARKS_H
7#define QSK_TICKMARKS_H
8
9#include <QskIntervalF.h>
10#include <QVector>
11
12class QSK_EXPORT QskTickmarks
13{
14 Q_GADGET
15
16 Q_PROPERTY( QVector< qreal > majorTicks READ majorTicks WRITE setMajorTicks )
17 Q_PROPERTY( QVector< qreal > mediumTicks READ mediumTicks WRITE setMediumTicks )
18 Q_PROPERTY( QVector< qreal > minorTicks READ minorTicks WRITE setMinorTicks )
19
20 public:
21 enum TickType
22 {
23 MinorTick,
24 MediumTick,
25 MajorTick
26 };
27
28 Q_ENUM( TickType )
29
31 QskTickmarks( const QVector< qreal >& minorTicks,
32 const QVector< qreal >& mediumTicks, const QVector< qreal >& majorTicks );
33
35
36 bool operator==( const QskTickmarks& ) const noexcept;
37 bool operator!=( const QskTickmarks& ) const noexcept;
38
39 int tickCount() const noexcept;
40 Q_INVOKABLE int tickCount( TickType ) const noexcept;
41
42 QVector< qreal > ticks( TickType ) const noexcept;
43 void setTicks( TickType, const QVector< qreal >& );
44
45 void setMinorTicks( const QVector< qreal >& );
46 QVector< qreal > minorTicks() const noexcept;
47
48 void setMediumTicks( const QVector< qreal >& );
49 QVector< qreal > mediumTicks() const noexcept;
50
51 void setMajorTicks( const QVector< qreal >& );
52 QVector< qreal > majorTicks() const noexcept;
53
54 Q_INVOKABLE qreal tickAt( TickType, int index ) const;
55
56 void invert();
57 void reset();
58
59 QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
60
61 private:
62 QVector< qreal > m_ticks[ 3 ];
63};
64
65inline void QskTickmarks::setMinorTicks( const QVector< qreal >& ticks )
66{
67 setTicks( MinorTick, ticks );
68}
69
70inline QVector< qreal > QskTickmarks::minorTicks() const noexcept
71{
72 return ticks( MinorTick );
73}
74
75inline void QskTickmarks::setMediumTicks( const QVector< qreal >& ticks )
76{
77 setTicks( MediumTick, ticks );
78}
79
80inline QVector< qreal > QskTickmarks::mediumTicks() const noexcept
81{
82 return ticks( MediumTick );
83}
84
85inline void QskTickmarks::setMajorTicks( const QVector< qreal >& ticks )
86{
87 setTicks( MajorTick, ticks );
88}
89
90inline QVector< qreal > QskTickmarks::majorTicks() const noexcept
91{
92 return ticks( MajorTick );
93}
94
95inline bool QskTickmarks::operator!=(
96 const QskTickmarks& other ) const noexcept
97{
98 return !( *this == other );
99}
100
101Q_DECLARE_METATYPE( QskTickmarks )
102
103#ifndef QT_NO_DEBUG_STREAM
104
105QSK_EXPORT QDebug operator<<( QDebug, const QskTickmarks& );
106
107#endif
108
109#endif