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