KChart

KChartMarkerAttributes.h
1 /*
2  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef KCHARTMARKERATTRIBUTES_H
10 #define KCHARTMARKERATTRIBUTES_H
11 
12 #include <QMetaType>
13 #include "KChartGlobal.h"
14 
15 QT_BEGIN_NAMESPACE
16 class QColor;
17 class QSizeF;
18 class QPen;
19 class QPainterPath;
20 class QDebug;
21 template <typename T, typename K> class QMap;
22 QT_END_NAMESPACE
23 
24 namespace KChart {
25 
26  /**
27  * @brief A set of attributes controlling the appearance of data set markers
28  */
29  class KCHART_EXPORT MarkerAttributes
30  {
31  public:
34  MarkerAttributes &operator= ( const MarkerAttributes& );
35 
37 
38  enum MarkerStyle { NoMarker = 0,
39  MarkerCircle = 1,
40  MarkerSquare = 2,
41  MarkerDiamond = 3,
42  Marker1Pixel = 4,
43  Marker4Pixels = 5,
44  MarkerRing = 6,
45  MarkerCross = 7,
46  MarkerFastCross = 8,
47  MarkerArrowDown = 9,
48  MarkerArrowUp = 10,
49  MarkerArrowRight = 11,
50  MarkerArrowLeft = 12,
51  MarkerBowTie = 13,
52  MarkerHourGlass = 14,
53  MarkerStar = 15,
54  MarkerX = 16,
55  MarkerAsterisk = 17,
56  MarkerHorizontalBar = 18,
57  MarkerVerticalBar = 19,
58  PainterPathMarker = 255,
59  StartCustomMarkers = 256 };
60 
62  /// the marker size is directly specified in pixels
63  AbsoluteSize = 0,
64  /// the marker size is specified in pixels, but scaled by the
65  /// painter's zoom level
66  AbsoluteSizeScaled = 1,
67  /// the marker size is relative to the diagram's min(width, height)
68  RelativeToDiagramWidthHeightMin = 2 };
69 
70  void setVisible( bool visible );
71  bool isVisible() const;
72 
73  typedef QMap<uint, uint> MarkerStylesMap;
74  void setMarkerStylesMap( const MarkerStylesMap & map );
75  MarkerStylesMap markerStylesMap() const;
76 
77  void setThreeD( bool value );
78  bool threeD() const;
79 
80  /**
81  * Set the marker-style to use. This could be either one of the
82  * predefined \a MarkerStyle or a custom one that has a value
83  * bigger or equal to StartCustomMarkers.
84  *
85  * Such a custom marker does then allow to fetch a custom pixmap
86  * for each point (value pair) from the model using the
87  * Qt::DecorationRole .
88  */
89  void setMarkerStyle( uint style );
90  uint markerStyle() const;
91 
92  /**
93  * Normally you need to specify a valid QSizeF here, but for Legends you can
94  * use the invalid size QSizeF(), to enable automatic marker size calculation:
95  *
96  * For Markers shown in a Legend this means the marker size will be equal to
97  * the font height used for the labels that are shown next to the markers.
98  */
99  void setMarkerSize( const QSizeF& size );
100  QSizeF markerSize() const;
101 
102  /**
103  * With this method you can change the way the actual marker size is
104  * calculated.
105  *
106  * By default, the marker size is absolute (equiv. to @a mode = AbsoluteSize)
107  * and specifies the size in pixels.
108  *
109  * In any other case, the size specified will be relative to what is
110  * specified in @a mode, e.g. the diagram's width. A marker width or
111  * height of 1.0 is then 100% of the diagram's width.
112  */
113  void setMarkerSizeMode( MarkerSizeMode mode );
114  MarkerSizeMode markerSizeMode() const;
115 
116  void setMarkerColor( const QColor& color );
117  QColor markerColor() const;
118 
119  void setCustomMarkerPath( const QPainterPath& path );
120  QPainterPath customMarkerPath() const;
121 
122  void setPen( const QPen& pen );
123  QPen pen() const;
124 
125  bool operator==( const MarkerAttributes& ) const;
126  bool operator!=( const MarkerAttributes& ) const;
127 
128  private:
129  KCHART_DECLARE_PRIVATE_BASE_VALUE( MarkerAttributes )
130  }; // End of class MarkerAttributes
131 
132  inline bool MarkerAttributes::operator!=( const MarkerAttributes & other ) const { return !operator==( other ); }
133 }
134 
135 #ifndef QT_NO_DEBUG_STREAM
136 KCHART_EXPORT QDebug operator<<( QDebug, const KChart::MarkerAttributes & );
137 #endif
138 
139 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::MarkerAttributes )
140 
141 QT_BEGIN_NAMESPACE
142 Q_DECLARE_TYPEINFO( KChart::MarkerAttributes, Q_MOVABLE_TYPE );
143 QT_END_NAMESPACE
144 
145 Q_DECLARE_METATYPE( KChart::MarkerAttributes )
146 
147 #endif // KCHARTMARKERATTRIBUTES_H
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
A set of attributes controlling the appearance of data set markers.
Contains KChart macros.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:51:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.