24 #include "KDChartTernaryLineDiagram_p.h" 37 #include "KDChartPainterSaver_p.h" 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.";
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
DataValueAttributes dataValueAttributes() const
Retrieve the DataValueAttributes specified globally.
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
Ternary coordinate plane.
void setVisible(bool visible)
void setVisible(bool visible)
Set whether data value labels should be displayed.
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
Declaring the class KDChart::DataValueAttributes.
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
QPainter * painter() const
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
void setMarkerAttributes(const MarkerAttributes &a)
Set the marker attributes to use for the data values.
~TernaryLineDiagram() override
void setDatasetDimensionInternal(int dimension)
void setDefaultForRole(int role, const QVariant &value)
Define the default value for a certain role.
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)
void setMarkerStyle(uint style)
Set the marker-style to use.
Stores information about painting diagrams.
Base class for diagrams based on a ternary coordinate plane.
QPointF translate(const TernaryPoint &point)
A set of attributes controlling the appearance of data set markers.
QPen pen() const
Retrieve the pen to be used for painting datapoints globally.
static QPen scalePen(const QPen &pen)
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.