Exemplo n.º 1
0
void MainWindow::on_paintValuesCB_toggled( bool checked )
{
    const int colCount = m_lines->model()->columnCount();
    for ( int iColumn = 0; iColumn<colCount; ++iColumn ) {
        DataValueAttributes a = m_lines->dataValueAttributes( iColumn );
        a.setVisible( true );

        TextAttributes ta = a.textAttributes();
        ta.setRotation( 0 );
        ta.setFont( QFont( "Comic", 10 ) );
        ta.setPen( m_lines->brush( iColumn ).color() );
        ta.setVisible( checked );

        a.setTextAttributes( ta );
        m_lines->setDataValueAttributes( iColumn, a);
    }
}
Exemplo n.º 2
0
void markPeak(Plotter* p, const QModelIndex& peak, quint64 cost, const KColorScheme& scheme)
{
    QBrush brush = p->model()->data(peak, DatasetBrushRole).value<QBrush>();

    QColor outline = brush.color();
    QColor foreground = scheme.foreground().color();
    QBrush background = scheme.background();

    DataValueAttributes dataAttributes = p->dataValueAttributes(peak);
    dataAttributes.setDataLabel(prettyCost(cost));
    dataAttributes.setVisible(true);
    dataAttributes.setShowRepetitiveDataLabels(true);
    dataAttributes.setShowOverlappingDataLabels(false);

    FrameAttributes frameAttrs = dataAttributes.frameAttributes();
    QPen framePen(outline);
    framePen.setWidth(2);
    frameAttrs.setPen(framePen);
    frameAttrs.setVisible(true);
    dataAttributes.setFrameAttributes(frameAttrs);

    MarkerAttributes a = dataAttributes.markerAttributes();
    a.setMarkerSize(QSizeF(7, 7));
    a.setPen(outline);
    a.setMarkerStyle(KChart::MarkerAttributes::MarkerDiamond);
    a.setVisible(true);
    dataAttributes.setMarkerAttributes(a);

    TextAttributes txtAttrs = dataAttributes.textAttributes();
    txtAttrs.setPen(foreground);
    txtAttrs.setFontSize(Measure(12));
    dataAttributes.setTextAttributes(txtAttrs);

    BackgroundAttributes bkgAtt = dataAttributes.backgroundAttributes();

    bkgAtt.setBrush(background);
    bkgAtt.setVisible(true);
    dataAttributes.setBackgroundAttributes(bkgAtt);

    p->setDataValueAttributes(peak, dataAttributes);
}
Exemplo n.º 3
0
// since DataValue markers have no relative sizing mode we need to scale them for printing
void MainWindow::paintMarkers( bool checked, const QSize& printSize )
{
    MarkerAttributes::MarkerStylesMap map;
    map.insert( 0, MarkerAttributes::MarkerSquare );
    map.insert( 1, MarkerAttributes::MarkerCircle );
    map.insert( 2, MarkerAttributes::MarkerRing );
    map.insert( 3, MarkerAttributes::MarkerCross );
    map.insert( 4, MarkerAttributes::MarkerDiamond );

    // next: Specify column- / cell-specific attributes!
    const int colCount = m_lines->model()->columnCount();
    for ( int iColumn = 0; iColumn<colCount; ++iColumn ) {
        DataValueAttributes dva = m_lines->dataValueAttributes( iColumn );
        dva.setVisible( true );
        MarkerAttributes ma( dva.markerAttributes() );

    switch ( markersStyleCB->currentIndex() ) {
        case 0:
                   ma.setMarkerStyle( MarkerAttributes::MarkerSquare );
                   break;
        case 1:
                   // Column-specific attributes
                   ma.setMarkerStyle( map.value( iColumn ) );
                   break;
        case 2:
                   ma.setMarkerStyle( MarkerAttributes::MarkerCircle );
                   break;
        case 3:
                   ma.setMarkerStyle( MarkerAttributes::MarkerDiamond );
                   break;
        case 4:
                   ma.setMarkerStyle( MarkerAttributes::Marker1Pixel );
                   break;
        case 5:
                   ma.setMarkerStyle( MarkerAttributes::Marker4Pixels );
                   break;
        case 6:
                   ma.setMarkerStyle( MarkerAttributes::MarkerRing );
                   break;
        case 7:
                   ma.setMarkerStyle( MarkerAttributes::MarkerCross );
                   break;
        case 8:
                   ma.setMarkerStyle( MarkerAttributes::MarkerFastCross );
                   break;
        default:
            Q_ASSERT( false );
    }
    ma.setVisible( checked );

        qreal factorWidth = printSize.isValid() ? ( printSize.width() / m_chart->rect().width() ) : 1.0f;
        qreal factorHeight = printSize.isValid() ? ( printSize.height() / m_chart->rect().height() ) : 1.0f;
        ma.setMarkerSize( QSize( markersWidthSB->value() * factorWidth, markersHeightSB->value() * factorHeight ) );

        dva.setMarkerAttributes( ma );
        m_lines->setDataValueAttributes( iColumn, dva );

    // make a special one for certain values
    DataValueAttributes yellowAttributes( dva );
    MarkerAttributes yellowMarker( yellowAttributes.markerAttributes() );
    yellowMarker.setMarkerColor( Qt::yellow );
    yellowAttributes.setMarkerAttributes( yellowMarker );

    const int rowCount = m_lines->model()->rowCount();
        for ( int j=0; j< rowCount; ++j ) {
            QModelIndex index = m_lines->model()->index( j, iColumn, QModelIndex() );
            QBrush brush = m_lines->model()->headerData( iColumn, Qt::Vertical, DatasetBrushRole ).value<QBrush>();
            qreal value = m_lines->model()->data( index ).toReal();
            /* Set a specific color - marker for a specific value */
            if ( value == 13 ) {
                m_lines->setDataValueAttributes( index, yellowAttributes );
            }
        }
    }
}