 |
KD Chart 2
[rev.2.7]
|
Go to the documentation of this file.
24 #include "KDChartTernaryLineDiagram_p.h"
37 #include "KDChartPainterSaver_p.h"
43 TernaryLineDiagram::Private::Private()
48 TernaryLineDiagram::TernaryLineDiagram (
QWidget* parent,
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.";
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
QPointF translate(const TernaryPoint &point)
~TernaryLineDiagram() override
A set of attributes controlling the appearance of data set markers.
const QPointF TriangleBottomLeft
@ DataValueLabelAttributesRole
static QPen scalePen(const QPen &pen)
QPen pen() const
Retrieve the pen to be used for painting datapoints globally.
AbstractCoordinatePlane * coordinatePlane() const
const QPointF TriangleBottomRight
void setMarkerStyle(uint style)
Set the marker-style to use.
void setDatasetDimensionInternal(int dimension)
Stores information about painting diagrams.
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
QPainter * painter() const
Base class for diagrams based on a ternary coordinate plane.
virtual void paintMarker(QPainter *painter, const MarkerAttributes &markerAttributes, const QBrush &brush, const QPen &, const QPointF &point, const QSizeF &size)
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
DataValueAttributes dataValueAttributes() const
Retrieve the DataValueAttributes specified globally.
TernaryPoint defines a point within a ternary coordinate plane.
void setVisible(bool visible)
void setMarkerAttributes(const MarkerAttributes &a)
Set the marker attributes to use for the data values.
Declaring the class KDChart::DataValueAttributes.
void setDefaultForRole(int role, const QVariant &value)
Define the default value for a certain role.
const QPointF translate(const QPointF &diagramPoint) const override
Translate the given point in value space coordinates to a position in pixel space.
void setVisible(bool visible)
Set whether data value labels should be displayed.
Diagram attributes dealing with data value labels.
const qreal TriangleHeight
Ternary coordinate plane.
QBrush brush() const
Retrieve the brush to be used for painting datapoints globally.