24 #include "KDChartTernaryPointDiagram_p.h"
35 using namespace KDChart;
39 TernaryPointDiagram::Private::Private()
44 TernaryPointDiagram::TernaryPointDiagram (
QWidget* parent,
56 void TernaryPointDiagram::init()
58 d->reverseMapper.setDiagram(
this );
68 d->reverseMapper.clear();
70 d->paint( paintContext );
73 if ( model() == 0 )
return;
75 QPainter* p = paintContext->
painter();
88 d->forgetAlreadyPaintedDataValues();
90 int columnCount = model()->columnCount( rootIndex() );
93 int numrows = model()->rowCount( rootIndex() );
94 for (
int row = 0; row < numrows; row++ )
96 QModelIndex base = model()->index( row, column, rootIndex() );
98 if ( ! model()->data( base ).isNull() )
101 p->setBrush(
brush( base ) );
104 x = qMax( model()->data( model()->index( row, column+0, rootIndex() ) ).toReal(),
106 y = qMax( model()->data( model()->index( row, column+1, rootIndex() ) ).toReal(),
108 z = qMax( model()->data( model()->index( row, column+2, rootIndex() ) ).toReal(),
112 qreal total = x + y + z;
113 if ( fabs( total ) > 3 * std::numeric_limits<qreal>::epsilon() ) {
115 QPointF diagramLocation =
translate( tPunkt );
116 QPointF widgetLocation = plane->
translate( diagramLocation );
118 paintMarker( p, model()->index( row, column, rootIndex() ), widgetLocation );
119 QString text = tr(
"(%1, %2, %3)" )
120 .arg( x * 100, 0,
'f', 0 )
121 .arg( y * 100, 0,
'f', 0 )
122 .arg( z * 100, 0,
'f', 0 );
123 d->paintDataValueText( p, attrs, widgetLocation,
true, text,
true );
126 qDebug() <<
"TernaryPointDiagram::paint: data point x/y/z:"
127 << x <<
"/" << y <<
"/" << z <<
"ignored, unusable.";