File indexing completed on 2024-05-12 15:54:20
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 #include "KChartValueTrackerAttributes.h" 0021 #include "KChartMath_p.h" 0022 0023 #include <QPen> 0024 #include <QSizeF> 0025 #include <QBrush> 0026 0027 #define d d_func() 0028 0029 using namespace KChart; 0030 0031 class Q_DECL_HIDDEN ValueTrackerAttributes::Private 0032 { 0033 friend class ValueTrackerAttributes; 0034 public: 0035 Private(); 0036 private: 0037 QPen linePen; 0038 QPen markerPen; 0039 QBrush markerBrush; 0040 QBrush arrowBrush; 0041 QSizeF markerSize; 0042 bool enabled; 0043 QBrush areaBrush; 0044 Qt::Orientations orientations; 0045 }; 0046 0047 ValueTrackerAttributes::Private::Private() 0048 : linePen( QPen( QColor( 80, 80, 80, 200 ) ) ), 0049 markerSize( QSizeF( 6.0, 6.0 ) ), 0050 enabled( false ), 0051 areaBrush( QBrush() ), 0052 orientations(Qt::Vertical|Qt::Horizontal) 0053 { 0054 markerPen = linePen; 0055 arrowBrush = linePen.color(); 0056 } 0057 0058 0059 ValueTrackerAttributes::ValueTrackerAttributes() 0060 : _d( new Private() ) 0061 { 0062 } 0063 0064 ValueTrackerAttributes::ValueTrackerAttributes( const ValueTrackerAttributes& r ) 0065 : _d( new Private( *r.d ) ) 0066 { 0067 } 0068 0069 ValueTrackerAttributes & ValueTrackerAttributes::operator=( const ValueTrackerAttributes& r ) 0070 { 0071 if ( this == &r ) 0072 return *this; 0073 0074 *d = *r.d; 0075 0076 return *this; 0077 } 0078 0079 ValueTrackerAttributes::~ValueTrackerAttributes() 0080 { 0081 delete _d; _d = nullptr; 0082 } 0083 0084 0085 bool ValueTrackerAttributes::operator==( const ValueTrackerAttributes& r ) const 0086 { 0087 return ( linePen() == r.linePen() && 0088 markerPen() == r.markerPen() && 0089 markerBrush() == r.markerBrush() && 0090 arrowBrush() == r.arrowBrush() && 0091 areaBrush() == r.areaBrush() && 0092 markerSize() == r.markerSize() && 0093 isEnabled() == r.isEnabled() ); 0094 } 0095 0096 void ValueTrackerAttributes::setPen( const QPen& pen ) 0097 { 0098 d->linePen = pen; 0099 d->markerPen = pen; 0100 d->markerBrush = QBrush(); 0101 d->arrowBrush = pen.color(); 0102 } 0103 0104 QPen ValueTrackerAttributes::pen() const 0105 { 0106 return d->linePen; 0107 } 0108 0109 void ValueTrackerAttributes::setLinePen( const QPen &pen ) 0110 { 0111 d->linePen = pen; 0112 } 0113 0114 QPen ValueTrackerAttributes::linePen() const 0115 { 0116 return d->linePen; 0117 } 0118 0119 void ValueTrackerAttributes::setMarkerPen( const QPen &pen ) 0120 { 0121 d->markerPen = pen; 0122 } 0123 0124 QPen ValueTrackerAttributes::markerPen() const 0125 { 0126 return d->markerPen; 0127 } 0128 0129 void ValueTrackerAttributes::setMarkerBrush( const QBrush &brush ) 0130 { 0131 d->markerBrush = brush; 0132 } 0133 0134 QBrush ValueTrackerAttributes::markerBrush() const 0135 { 0136 return d->markerBrush; 0137 } 0138 0139 void ValueTrackerAttributes::setArrowBrush( const QBrush &brush ) 0140 { 0141 d->arrowBrush = brush; 0142 } 0143 0144 QBrush ValueTrackerAttributes::arrowBrush() const 0145 { 0146 return d->arrowBrush; 0147 } 0148 0149 void ValueTrackerAttributes::setAreaBrush( const QBrush& brush ) 0150 { 0151 d->areaBrush = brush; 0152 } 0153 0154 QBrush ValueTrackerAttributes::areaBrush() const 0155 { 0156 return d->areaBrush; 0157 } 0158 0159 void ValueTrackerAttributes::setMarkerSize( const QSizeF& size ) 0160 { 0161 d->markerSize = size; 0162 } 0163 0164 QSizeF ValueTrackerAttributes::markerSize() const 0165 { 0166 return d->markerSize; 0167 } 0168 0169 Qt::Orientations ValueTrackerAttributes::orientations() const 0170 { 0171 return d->orientations; 0172 } 0173 0174 void ValueTrackerAttributes::setOrientations( Qt::Orientations orientations ) 0175 { 0176 d->orientations = orientations; 0177 } 0178 0179 void ValueTrackerAttributes::setEnabled( bool enabled ) 0180 { 0181 d->enabled = enabled; 0182 } 0183 0184 bool ValueTrackerAttributes::isEnabled() const 0185 { 0186 return d->enabled; 0187 } 0188 0189 #if !defined(QT_NO_DEBUG_STREAM) 0190 QDebug operator<<(QDebug dbg, const KChart::ValueTrackerAttributes& va) 0191 { 0192 dbg << "KChart::ValueTrackerAttributes(" 0193 << "linePen="<<va.linePen() 0194 << "markerPen="<<va.markerPen() 0195 << "markerBrush="<<va.markerBrush() 0196 << "arrowBrush="<<va.arrowBrush() 0197 << "markerSize="<<va.markerSize() 0198 << "enabled="<<va.isEnabled() 0199 << ")"; 0200 return dbg; 0201 } 0202 #endif /* QT_NO_DEBUG_STREAM */