KDChartGridAttributes.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "KDChartGridAttributes.h"
00024
00025 #include <QPen>
00026 #include <QDebug>
00027
00028 #include <KDABLibFakes>
00029
00030 #define d d_func()
00031
00032 using namespace KDChart;
00033
00034 class GridAttributes::Private
00035 {
00036 friend class GridAttributes;
00037 public:
00038 Private();
00039 private:
00040 bool visible;
00041 KDChartEnums::GranularitySequence sequence;
00042 qreal stepWidth;
00043 qreal subStepWidth;
00044 bool adjustLower;
00045 bool adjustUpper;
00046 QPen pen;
00047 bool subVisible;
00048 QPen subPen;
00049 QPen zeroPen;
00050 };
00051
00052 GridAttributes::Private::Private()
00053 : visible( true ),
00054 sequence( KDChartEnums::GranularitySequence_10_20 ),
00055 stepWidth( 0.0 ),
00056 subStepWidth( 0.0 ),
00057 adjustLower( true ),
00058 adjustUpper( true ),
00059 pen( QColor(0xa0, 0xa0, 0xa0 ) ),
00060 subVisible( true ),
00061 subPen( QColor(0xd0, 0xd0, 0xd0 ) ),
00062 zeroPen( QColor( 0x00, 0x00, 0x80 ) )
00063 {
00064 pen.setCapStyle( Qt::FlatCap );
00065 subPen.setCapStyle( Qt::FlatCap );
00066 zeroPen.setCapStyle( Qt::FlatCap );
00067 }
00068
00069
00070 GridAttributes::GridAttributes()
00071 : _d( new Private() )
00072 {
00073
00074 }
00075
00076 GridAttributes::GridAttributes( const GridAttributes& r )
00077 : _d( new Private( *r.d ) )
00078 {
00079 }
00080
00081 GridAttributes & GridAttributes::operator=( const GridAttributes& r )
00082 {
00083 if( this == &r )
00084 return *this;
00085
00086 *d = *r.d;
00087
00088 return *this;
00089 }
00090
00091 GridAttributes::~GridAttributes()
00092 {
00093 delete _d; _d = 0;
00094 }
00095
00096
00097 bool GridAttributes::operator==( const GridAttributes& r ) const
00098 {
00099 return isGridVisible() == r.isGridVisible() &&
00100 gridGranularitySequence() == r.gridGranularitySequence() &&
00101 adjustLowerBoundToGrid() == r.adjustLowerBoundToGrid() &&
00102 adjustUpperBoundToGrid() == r.adjustUpperBoundToGrid() &&
00103 gridPen() == r.gridPen() &&
00104 isSubGridVisible() == r.isSubGridVisible() &&
00105 subGridPen() == r.subGridPen() &&
00106 zeroLinePen() == r.zeroLinePen();
00107 }
00108
00109
00110 void GridAttributes::setGridVisible( bool visible )
00111 {
00112 d->visible = visible;
00113 }
00114
00115 bool GridAttributes::isGridVisible() const
00116 {
00117 return d->visible;
00118 }
00119
00138 void GridAttributes::setGridStepWidth( qreal stepWidth )
00139 {
00140 d->stepWidth = stepWidth;
00141 }
00142
00149 qreal GridAttributes::gridStepWidth() const
00150 {
00151 return d->stepWidth;
00152 }
00153
00154
00169 void GridAttributes::setGridSubStepWidth( qreal subStepWidth )
00170 {
00171 d->subStepWidth = subStepWidth;
00172 }
00173
00180 qreal GridAttributes::gridSubStepWidth() const
00181 {
00182 return d->subStepWidth;
00183 }
00184
00202 void GridAttributes::setGridGranularitySequence( KDChartEnums::GranularitySequence sequence )
00203 {
00204 d->sequence = sequence;
00205 }
00206
00213 KDChartEnums::GranularitySequence GridAttributes::gridGranularitySequence() const
00214 {
00215 return d->sequence;
00216 }
00217
00218 void GridAttributes::setAdjustBoundsToGrid( bool adjustLower, bool adjustUpper )
00219 {
00220 d->adjustLower = adjustLower;
00221 d->adjustUpper = adjustUpper;
00222 }
00223 bool GridAttributes::adjustLowerBoundToGrid() const
00224 {
00225 return d->adjustLower;
00226 }
00227 bool GridAttributes::adjustUpperBoundToGrid() const
00228 {
00229 return d->adjustUpper;
00230 }
00231
00232 void GridAttributes::setGridPen( const QPen & pen )
00233 {
00234 d->pen = pen;
00235 d->pen.setCapStyle( Qt::FlatCap );
00236 }
00237
00238 QPen GridAttributes::gridPen() const
00239 {
00240 return d->pen;
00241 }
00242
00243 void GridAttributes::setSubGridVisible( bool visible )
00244 {
00245 d->subVisible = visible;
00246 }
00247
00248 bool GridAttributes::isSubGridVisible() const
00249 {
00250 return d->subVisible;
00251 }
00252
00253 void GridAttributes::setSubGridPen( const QPen & pen )
00254 {
00255 d->subPen = pen;
00256 d->subPen.setCapStyle( Qt::FlatCap );
00257 }
00258
00259 QPen GridAttributes::subGridPen() const
00260 {
00261 return d->subPen;
00262 }
00263
00264 void GridAttributes::setZeroLinePen( const QPen & pen )
00265 {
00266 d->zeroPen = pen;
00267 d->zeroPen.setCapStyle( Qt::FlatCap );
00268 }
00269
00270 QPen GridAttributes::zeroLinePen() const
00271 {
00272 return d->zeroPen;
00273 }
00274
00275 #if !defined(QT_NO_DEBUG_STREAM)
00276 QDebug operator<<(QDebug dbg, const KDChart::GridAttributes& a)
00277 {
00278 dbg << "KDChart::GridAttributes("
00279 << "visible="<<a.isGridVisible()
00280 << "subVisible="<<a.isSubGridVisible()
00281
00282 << "stepWidth=" << a.gridStepWidth()
00283 << "subStepWidth=" << a.gridSubStepWidth()
00284 << "pen="<<a.gridPen()
00285 << "subPen="<<a.subGridPen()
00286 << "zeroPen="<<a.zeroLinePen()
00287 << ")";
00288 return dbg;
00289 }
00290 #endif
00291