File indexing completed on 2024-05-12 15:54:19
0001 /* 0002 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KD Chart library. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef KCHARTRULERATTRIBUTES_H 0021 #define KCHARTRULERATTRIBUTES_H 0022 0023 #include <QMetaType> 0024 #include "KChartGlobal.h" 0025 #include "KChartEnums.h" 0026 0027 QT_BEGIN_NAMESPACE 0028 class QPen; 0029 QT_END_NAMESPACE 0030 0031 namespace KChart { 0032 0033 /** 0034 * @brief A set of attributes controlling the appearance of axis rulers 0035 */ 0036 class KCHART_EXPORT RulerAttributes 0037 { 0038 public: 0039 RulerAttributes(); 0040 RulerAttributes( const RulerAttributes& ); 0041 RulerAttributes &operator= ( const RulerAttributes& ); 0042 0043 ~RulerAttributes(); 0044 0045 /** 0046 * Sets the pen used to draw the tick marks 0047 */ 0048 void setTickMarkPen( const QPen& pen ); 0049 QPen tickMarkPen() const; 0050 0051 /** 0052 * Sets the pen used to draw major tick marks 0053 */ 0054 void setMajorTickMarkPen( const QPen& pen ); 0055 bool majorTickMarkPenIsSet() const; 0056 QPen majorTickMarkPen() const; 0057 0058 /** 0059 * Sets the pen used to draw minor tick marks 0060 */ 0061 void setMinorTickMarkPen( const QPen& pen ); 0062 bool minorTickMarkPenIsSet() const; 0063 QPen minorTickMarkPen() const; 0064 0065 /** 0066 * Sets the pen used to draw the tick mark at a specific value 0067 * 0068 * Note: This will not paint a tick mark at the specified value 0069 * if it wasn't already drawn before. 0070 */ 0071 void setTickMarkPen( qreal value, const QPen& pen ); 0072 QPen tickMarkPen( qreal value ) const; 0073 typedef QMap<qreal, QPen> TickMarkerPensMap; 0074 TickMarkerPensMap tickMarkPens() const; 0075 0076 bool hasTickMarkPenAt( qreal value) const; 0077 0078 /** 0079 * Color setter method provided for convenience 0080 */ 0081 void setTickMarkColor( const QColor& color ); 0082 QColor tickMarkColor() const; 0083 0084 /** 0085 * Shows or hides minor tick marks 0086 */ 0087 void setShowMinorTickMarks( bool show ); 0088 bool showMinorTickMarks() const; 0089 0090 /** 0091 * Set the ruler line pen to @p pen 0092 */ 0093 void setRulerLinePen(const QPen &pen); 0094 /** @return the ruler line pen 0095 */ 0096 QPen rulerLinePen() const; 0097 0098 void setShowRulerLine( bool show ); 0099 bool showRulerLine() const; 0100 0101 /** 0102 * Shows or hides major tick marks 0103 */ 0104 void setShowMajorTickMarks( bool show ); 0105 bool showMajorTickMarks() const; 0106 0107 /** 0108 * Sets the length of major tick marks 0109 */ 0110 void setMajorTickMarkLength( int length ); 0111 int majorTickMarkLength() const; 0112 bool majorTickMarkLengthIsSet() const; 0113 0114 /** 0115 * Sets the length of minor tick marks 0116 */ 0117 void setMinorTickMarkLength( int length ); 0118 int minorTickMarkLength() const; 0119 bool minorTickMarkLengthIsSet() const; 0120 0121 /** 0122 * Set margin that should be used between the labels and the ticks. By 0123 * default the value is -1, which means that half of the label's font 0124 * height/width should be used as margin. 0125 */ 0126 void setLabelMargin(int margin); 0127 int labelMargin() const; 0128 0129 /** 0130 * Shows or hides the first tick. This is usually where the axes cross. 0131 * The tick itself may be obscured by the other axis, but the label will be visible. 0132 */ 0133 void setShowFirstTick( bool show ); 0134 bool showFirstTick() const; 0135 0136 bool operator==( const RulerAttributes& ) const; 0137 inline bool operator!=( const RulerAttributes& other ) const { return !operator==(other); } 0138 0139 private: 0140 KCHART_DECLARE_PRIVATE_BASE_VALUE( RulerAttributes ) 0141 }; // End of class RulerAttributes 0142 0143 } 0144 0145 #if !defined(QT_NO_DEBUG_STREAM) 0146 KCHART_EXPORT QDebug operator<<(QDebug, const KChart::RulerAttributes& ); 0147 #endif /* QT_NO_DEBUG_STREAM */ 0148 0149 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::RulerAttributes ) 0150 0151 QT_BEGIN_NAMESPACE 0152 Q_DECLARE_TYPEINFO( KChart::RulerAttributes, Q_MOVABLE_TYPE ); 0153 QT_END_NAMESPACE 0154 0155 Q_DECLARE_METATYPE( KChart::RulerAttributes ) 0156 0157 #endif // KCHARTRULERATTRIBUTES_H