1 /* 2 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 3 * 4 * This file is part of the KD Chart library. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef KCHARTMARKERATTRIBUTES_H 21 #define KCHARTMARKERATTRIBUTES_H 22 23 #include <QMetaType> 24 #include "KChartGlobal.h" 25 26 QT_BEGIN_NAMESPACE 27 class QColor; 28 class QSizeF; 29 class QPen; 30 class QPainterPath; 31 class QDebug; 32 template <typename T, typename K> class QMap; 33 QT_END_NAMESPACE 34 35 namespace KChart { 36 37 /** 38 * @brief A set of attributes controlling the appearance of data set markers 39 */ 40 class KCHART_EXPORT MarkerAttributes 41 { 42 public: 43 MarkerAttributes(); 44 MarkerAttributes( const MarkerAttributes& ); 45 MarkerAttributes &operator= ( const MarkerAttributes& ); 46 47 ~MarkerAttributes(); 48 49 enum MarkerStyle { NoMarker = 0, 50 MarkerCircle = 1, 51 MarkerSquare = 2, 52 MarkerDiamond = 3, 53 Marker1Pixel = 4, 54 Marker4Pixels = 5, 55 MarkerRing = 6, 56 MarkerCross = 7, 57 MarkerFastCross = 8, 58 MarkerArrowDown = 9, 59 MarkerArrowUp = 10, 60 MarkerArrowRight = 11, 61 MarkerArrowLeft = 12, 62 MarkerBowTie = 13, 63 MarkerHourGlass = 14, 64 MarkerStar = 15, 65 MarkerX = 16, 66 MarkerAsterisk = 17, 67 MarkerHorizontalBar = 18, 68 MarkerVerticalBar = 19, 69 PainterPathMarker = 255, 70 StartCustomMarkers = 256 }; 71 72 enum MarkerSizeMode { 73 /// the marker size is directly specified in pixels 74 AbsoluteSize = 0, 75 /// the marker size is specified in pixels, but scaled by the 76 /// painter's zoom level 77 AbsoluteSizeScaled = 1, 78 /// the marker size is relative to the diagram's min(width, height) 79 RelativeToDiagramWidthHeightMin = 2 }; 80 81 void setVisible( bool visible ); 82 bool isVisible() const; 83 84 typedef QMap<uint, uint> MarkerStylesMap; 85 void setMarkerStylesMap( const MarkerStylesMap & map ); 86 MarkerStylesMap markerStylesMap() const; 87 88 void setThreeD( bool value ); 89 bool threeD() const; 90 91 /** 92 * Set the marker-style to use. This could be either one of the 93 * predefined \a MarkerStyle or a custom one that has a value 94 * bigger or equal to StartCustomMarkers. 95 * 96 * Such a custom marker does then allow to fetch a custom pixmap 97 * for each point (value pair) from the model using the 98 * Qt::DecorationRole . 99 */ 100 void setMarkerStyle( uint style ); 101 uint markerStyle() const; 102 103 /** 104 * Normally you need to specify a valid QSizeF here, but for Legends you can 105 * use the invalid size QSizeF(), to enable automatic marker size calculation: 106 * 107 * For Markers shown in a Legend this means the marker size will be equal to 108 * the font height used for the labels that are shown next to the markers. 109 */ 110 void setMarkerSize( const QSizeF& size ); 111 QSizeF markerSize() const; 112 113 /** 114 * With this method you can change the way the actual marker size is 115 * calculated. 116 * 117 * By default, the marker size is absolute (equiv. to @a mode = AbsoluteSize) 118 * and specifies the size in pixels. 119 * 120 * In any other case, the size specified will be relative to what is 121 * specified in @a mode, e.g. the diagram's width. A marker width or 122 * height of 1.0 is then 100% of the diagram's width. 123 */ 124 void setMarkerSizeMode( MarkerSizeMode mode ); 125 MarkerSizeMode markerSizeMode() const; 126 127 void setMarkerColor( const QColor& color ); 128 QColor markerColor() const; 129 130 void setCustomMarkerPath( const QPainterPath& path ); 131 QPainterPath customMarkerPath() const; 132 133 void setPen( const QPen& pen ); 134 QPen pen() const; 135 136 bool operator==( const MarkerAttributes& ) const; 137 bool operator!=( const MarkerAttributes& ) const; 138 139 private: 140 KCHART_DECLARE_PRIVATE_BASE_VALUE( MarkerAttributes ) 141 }; // End of class MarkerAttributes 142 143 inline bool MarkerAttributes::operator!=( const MarkerAttributes & other ) const { return !operator==( other ); } 144 } 145 146 #ifndef QT_NO_DEBUG_STREAM 147 KCHART_EXPORT QDebug operator<<( QDebug, const KChart::MarkerAttributes & ); 148 #endif 149 150 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::MarkerAttributes ) 151 152 QT_BEGIN_NAMESPACE 153 Q_DECLARE_TYPEINFO( KChart::MarkerAttributes, Q_MOVABLE_TYPE ); 154 QT_END_NAMESPACE 155 156 Q_DECLARE_METATYPE( KChart::MarkerAttributes ) 157 158 #endif // KCHARTMARKERATTRIBUTES_H 159