KD Chart 2: TernaryPoint.h File Reference

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# TernaryPoint.h File Reference

`#include <QtDebug>`
`#include <QPointF>`

Include dependency graph for TernaryPoint.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
class | TernaryPoint
| TernaryPoint defines a point within a ternary coordinate plane. More...
## Functions
QDebug | operator<< (QDebug stream, const TernaryPoint &point)
QPointF | translate (const TernaryPoint &)

## Function Documentation

QDebug operator<< | ( | QDebug | stream,
|  | const TernaryPoint & | point |
| ) |  |  |

Definition at line 75 of file TernaryPoint.cpp.

References TernaryPoint::a(), TernaryPoint::b(), TernaryPoint::c(), and TernaryPoint::isValid().

    00076 {
    00077     QString string;
    00078     QTextStream text( &string );
    00079     text << "[TernaryPoint: ";
    00080     if ( point.isValid() ) {
    00081         text.setFieldWidth( 2 );
    00082         text.setPadChar( QLatin1Char( '0' ) );
    00083         text << ( int ) ( point.a() * 100.0 ) << "%|"
    00084              << ( int ) ( point.b() * 100.0 ) << "%|"
    00085              << ( int ) ( point.c() * 100.0 ) << "%]";
    00086     } else {
    00087         text << "a=" << point.a() << " - b=" << point.b() << " - INVALID]";
    00088     }
    00089     stream << string;
    00090     return stream;
    00091 }

QPointF translate | ( | const TernaryPoint & |  | ) |

Definition at line 93 of file TernaryPoint.cpp.

References TernaryPoint::a(), AxisVector_C_A, TernaryPoint::b(), and TernaryPoint::isValid().

Referenced by KDChart::TernaryLineDiagram::paint(), and KDChart::TernaryPointDiagram::paint().

    00094 {
    00095     if ( point.isValid() ) {
    00096         // the position is calculated by
    00097         // - first moving along the B-C line to the function that b
    00098         //   selects
    00099         // - then traversing the selected function until we meet with
    00100         //   the function that A selects (which is a parallel of the B-C
    00101         //   line)
    00102         QPointF bPosition( 1.0 - point.b(), 0.0 );
    00103         QPointF aPosition( point.a() * AxisVector_C_A );
    00104         QPointF result( bPosition + aPosition );
    00105         return result;
    00106     } else {
    00107         qWarning() << "TernaryPoint::translate(TernaryPoint): cannot translate invalid ternary points:"
    00108                    << point;
    00109         return QPointF();
    00110     }
    00111 }