24 #include "KDChartPlotter_p.h"
26 #include "KDChartAbstractGrid.h"
27 #include "KDChartPainterSaver_p.h"
29 #include <KDABLibFakes>
31 #include "KDChartNormalPlotter_p.h"
32 #include "KDChartPercentPlotter_p.h"
34 using namespace KDChart;
36 Plotter::Private::Private()
43 Plotter::Private::~Private()
46 delete percentPlotter;
62 d->normalPlotter =
new NormalPlotter(
this );
63 d->percentPlotter =
new PercentPlotter(
this );
64 d->implementor =
d->normalPlotter;
65 QObject* test =
d->implementor->plotterPrivate();
66 bool connection = connect(
this, SIGNAL(
boundariesChanged() ), test, SLOT( changedProperties() ) );
67 Q_ASSERT( connection );
68 Q_UNUSED( connection );
101 d->plotterCompressor.setModel( NULL );
105 d->compressor.setModel( NULL );
122 return d->implementor->useCompression();
129 d->implementor->setUseCompression( value );
132 d->compressor.setModel( NULL );
141 return d->plotterCompressor.maxSlopeChange();
146 d->plotterCompressor.setMaxSlopeChange( value );
151 return d->mergeRadiusPercentage;
156 if (
d->mergeRadiusPercentage != value )
158 d->mergeRadiusPercentage = value;
169 if (
d->implementor->type() ==
type ) {
173 Q_ASSERT_X (
false,
"setType()",
174 "This line chart type can only be used with two-dimensional data." );
179 d->implementor =
d->normalPlotter;
182 d->implementor =
d->percentPlotter;
185 Q_ASSERT_X(
false,
"Plotter::setType",
"unknown plotter subtype" );
188 d->implementor->plotterPrivate(), SLOT( changedProperties() ) );
189 Q_ASSERT( connection );
190 Q_UNUSED( connection );
193 Q_ASSERT(
d->implementor->type() ==
type );
205 return d->implementor->type();
240 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ),
250 d->attributesModel->resetData(
269 if ( attrs.isValid() )
279 return d->attributesModel->data(
309 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ), qVariantFromValue( la ),
328 if ( attrs.isValid() ) {
339 return d->attributesModel->data(
358 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ),
368 return d->attributesModel->data(
386 return d->implementor->calculateDataBoundaries();
392 QPainter painter ( viewport() );
395 ctx.
setRectangle ( QRectF ( 0, 0, width(), height() ) );
406 if ( ! plane )
return;
407 d->setCompressorResolution( size(), plane );
411 const PainterSaver p( ctx->
painter() );
412 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
418 d->implementor->paint( ctx );
428 d->plotterCompressor.cleanCache();
432 QAbstractItemView::resize( size.toSize() );
452 const qreal radius = std::sqrt( ( range.x() + range.width() ) * ( range.y() + range.height() ) );
456 d->plotterCompressor.setMergeRadius( radius *
d->mergeRadiusPercentage );
459 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
467 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)