24 #include "KDChartTernaryLineDiagram_p.h"
37 #include "KDChartPainterSaver_p.h"
39 using namespace KDChart;
43 TernaryLineDiagram::Private::Private()
48 TernaryLineDiagram::TernaryLineDiagram (
QWidget* parent,
63 qVariantFromValue( dataValueAttributes ) );
70 void TernaryLineDiagram::init()
81 d->reverseMapper.clear();
83 d->paint( paintContext );
85 if ( model() == 0 )
return;
87 QPainter* p = paintContext->
painter();
99 d->forgetAlreadyPaintedDataValues();
101 int columnCount = model()->columnCount( rootIndex() );
105 int numrows = model()->rowCount( rootIndex() );
106 for (
int row = 0; row < numrows; row++ )
109 QModelIndex base = model()->index( row, column );
110 if ( ! model()->data( base ).isNull() )
113 p->setBrush(
brush( base ) );
116 x = qMax( model()->data( model()->index( row, column, rootIndex() ) ).toReal(),
118 y = qMax( model()->data( model()->index( row, column+1, rootIndex() ) ).toReal(),
120 z = qMax( model()->data( model()->index( row, column+2, rootIndex() ) ).toReal(),
123 qreal total = x + y + z;
124 if ( fabs( total ) > 3 * std::numeric_limits<qreal>::epsilon() ) {
126 QPointF diagramLocation =
translate( tPunkt );
127 QPointF widgetLocation = plane->
translate( diagramLocation );
130 p->drawLine( start, widgetLocation );
132 paintMarker( p, model()->index( row, column, rootIndex() ), widgetLocation );
133 start = widgetLocation;
136 QString text = tr(
"(%1, %2, %3)" )
137 .arg( x * 100, 0,
'f', 0 )
138 .arg( y * 100, 0,
'f', 0 )
139 .arg( z * 100, 0,
'f', 0 );
140 d->paintDataValueText( p, attrs, widgetLocation,
true, text,
true );
143 qDebug() <<
"TernaryPointDiagram::paint: data point x/y/z:"
144 << x <<
"/" << y <<
"/" << z <<
"ignored, unusable.";