File indexing completed on 2024-05-12 04:20:35
0001 /* 0002 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCHARTMARKERATTRIBUTES_H 0010 #define KCHARTMARKERATTRIBUTES_H 0011 0012 #include <QMetaType> 0013 #include "KChartGlobal.h" 0014 0015 QT_BEGIN_NAMESPACE 0016 class QColor; 0017 class QSizeF; 0018 class QPen; 0019 class QPainterPath; 0020 class QDebug; 0021 template <typename T, typename K> class QMap; 0022 QT_END_NAMESPACE 0023 0024 namespace KChart { 0025 0026 /** 0027 * @brief A set of attributes controlling the appearance of data set markers 0028 */ 0029 class KCHART_EXPORT MarkerAttributes 0030 { 0031 public: 0032 MarkerAttributes(); 0033 MarkerAttributes( const MarkerAttributes& ); 0034 MarkerAttributes &operator= ( const MarkerAttributes& ); 0035 0036 ~MarkerAttributes(); 0037 0038 enum MarkerStyle { NoMarker = 0, 0039 MarkerCircle = 1, 0040 MarkerSquare = 2, 0041 MarkerDiamond = 3, 0042 Marker1Pixel = 4, 0043 Marker4Pixels = 5, 0044 MarkerRing = 6, 0045 MarkerCross = 7, 0046 MarkerFastCross = 8, 0047 MarkerArrowDown = 9, 0048 MarkerArrowUp = 10, 0049 MarkerArrowRight = 11, 0050 MarkerArrowLeft = 12, 0051 MarkerBowTie = 13, 0052 MarkerHourGlass = 14, 0053 MarkerStar = 15, 0054 MarkerX = 16, 0055 MarkerAsterisk = 17, 0056 MarkerHorizontalBar = 18, 0057 MarkerVerticalBar = 19, 0058 PainterPathMarker = 255, 0059 StartCustomMarkers = 256 }; 0060 0061 enum MarkerSizeMode { 0062 /// the marker size is directly specified in pixels 0063 AbsoluteSize = 0, 0064 /// the marker size is specified in pixels, but scaled by the 0065 /// painter's zoom level 0066 AbsoluteSizeScaled = 1, 0067 /// the marker size is relative to the diagram's min(width, height) 0068 RelativeToDiagramWidthHeightMin = 2 }; 0069 0070 void setVisible( bool visible ); 0071 bool isVisible() const; 0072 0073 typedef QMap<uint, uint> MarkerStylesMap; 0074 void setMarkerStylesMap( const MarkerStylesMap & map ); 0075 MarkerStylesMap markerStylesMap() const; 0076 0077 void setThreeD( bool value ); 0078 bool threeD() const; 0079 0080 /** 0081 * Set the marker-style to use. This could be either one of the 0082 * predefined \a MarkerStyle or a custom one that has a value 0083 * bigger or equal to StartCustomMarkers. 0084 * 0085 * Such a custom marker does then allow to fetch a custom pixmap 0086 * for each point (value pair) from the model using the 0087 * Qt::DecorationRole . 0088 */ 0089 void setMarkerStyle( uint style ); 0090 uint markerStyle() const; 0091 0092 /** 0093 * Normally you need to specify a valid QSizeF here, but for Legends you can 0094 * use the invalid size QSizeF(), to enable automatic marker size calculation: 0095 * 0096 * For Markers shown in a Legend this means the marker size will be equal to 0097 * the font height used for the labels that are shown next to the markers. 0098 */ 0099 void setMarkerSize( const QSizeF& size ); 0100 QSizeF markerSize() const; 0101 0102 /** 0103 * With this method you can change the way the actual marker size is 0104 * calculated. 0105 * 0106 * By default, the marker size is absolute (equiv. to @a mode = AbsoluteSize) 0107 * and specifies the size in pixels. 0108 * 0109 * In any other case, the size specified will be relative to what is 0110 * specified in @a mode, e.g. the diagram's width. A marker width or 0111 * height of 1.0 is then 100% of the diagram's width. 0112 */ 0113 void setMarkerSizeMode( MarkerSizeMode mode ); 0114 MarkerSizeMode markerSizeMode() const; 0115 0116 void setMarkerColor( const QColor& color ); 0117 QColor markerColor() const; 0118 0119 void setCustomMarkerPath( const QPainterPath& path ); 0120 QPainterPath customMarkerPath() const; 0121 0122 void setPen( const QPen& pen ); 0123 QPen pen() const; 0124 0125 bool operator==( const MarkerAttributes& ) const; 0126 bool operator!=( const MarkerAttributes& ) const; 0127 0128 private: 0129 KCHART_DECLARE_PRIVATE_BASE_VALUE( MarkerAttributes ) 0130 }; // End of class MarkerAttributes 0131 0132 inline bool MarkerAttributes::operator!=( const MarkerAttributes & other ) const { return !operator==( other ); } 0133 } 0134 0135 #ifndef QT_NO_DEBUG_STREAM 0136 KCHART_EXPORT QDebug operator<<( QDebug, const KChart::MarkerAttributes & ); 0137 #endif 0138 0139 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::MarkerAttributes ) 0140 0141 QT_BEGIN_NAMESPACE 0142 Q_DECLARE_TYPEINFO( KChart::MarkerAttributes, Q_MOVABLE_TYPE ); 0143 QT_END_NAMESPACE 0144 0145 Q_DECLARE_METATYPE( KChart::MarkerAttributes ) 0146 0147 #endif // KCHARTMARKERATTRIBUTES_H