24 #include "KDChartTernaryPointDiagram_p.h" 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.";
DataValueAttributes dataValueAttributes() const
Retrieve the DataValueAttributes specified globally.
Ternary coordinate plane.
Diagram attributes dealing with data value labels.
const QPointF TriangleBottomRight
AbstractCoordinatePlane * coordinatePlane() const
TernaryPoint defines a point within a ternary coordinate plane.
const qreal TriangleHeight
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
QPainter * painter() const
~TernaryPointDiagram() override
void setDatasetDimensionInternal(int dimension)
QBrush brush() const
Retrieve the brush to be used for painting datapoints globally.
const QPointF TriangleBottomLeft
virtual void paintMarker(QPainter *painter, const MarkerAttributes &markerAttributes, const QBrush &brush, const QPen &, const QPointF &point, const QSizeF &size)
Stores information about painting diagrams.
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
Base class for diagrams based on a ternary coordinate plane.
QPointF translate(const TernaryPoint &point)
QPen pen() const
Retrieve the pen to be used for painting datapoints globally.
static QPen scalePen(const QPen &pen)
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
const QPointF translate(const QPointF &diagramPoint) const override
Translate the given point in value space coordinates to a position in pixel space.