Exemplo n.º 1
0
void Plot::add() {
    Q_ASSERT(plotWidget && x && y && x->size()==y->size());
    setIntervals();
    for (int i = 0; i < intervals.size(); ++i) {
        QwtPlotCurve *curve = new QwtPlotCurve(yLegend);
        curve->setItemAttribute(QwtPlotItem::Legend, showLegend && i==0);
        plotWidget->addCurve(curve);

        if (type == Trace::Symbols) {
            curve->setStyle(QwtPlotCurve::NoCurve);
        }
        if (type == Trace::Symbols || type == Trace::Both) {
            Q_ASSERT(symbol);
            curve->setSymbol(symbol);
        }
        if (type == Trace::Line || type == Trace::Both) {
            curve->setPen(pen);
        }
        Interval iv = intervals[i];
        int numPoints = iv.second - iv.first + 1;
        if (numPoints <=0 )
        Q_ASSERT(numPoints > 0);
        curve->setSamples(x->data() + iv.first, y->data() + iv.first, numPoints);
    }

}
Exemplo n.º 2
0
void Plot::drawDots(QVector< QVector<struct numCluster> > data, double n, double k, int index, int size, int number)
{
    int j, l;
    QPolygonF points;
    QwtPlotCurve *curve;

    QwtSymbol *symbol;

    points.clear();
    curve = new QwtPlotCurve();//QString("y = norm%1(x)").arg(index));
    curve->setItemAttribute(QwtPlotItem::Legend, false);
    curve->setStyle( QwtPlotCurve::Dots );
    for (l = 0; l < data.size(); l++){
        if (data[l][number].cluster == index){
            // ПЕРЕДЕЛАТЬ если возможно!!! Нужно, чтобы он печатал сразу для всех кластеров одной л.п.
            if (index == 0 && data[l][number].number < n){
                points << QPointF(data[l][number].number, 1);
            }else if (index == size - 1 && data[l][number].number > n){
                points << QPointF(data[l][number].number, 1);
            }else{
                points << QPointF(data[l][number].number, func_normal(data[l][number].number,n,k));
            }

            //std::cout << index << "data = " << data[l][i].number << std::endl;
        }
    }
    curve->setSamples(points);
    switch (index % 5){
    case 0:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::yellow ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 1:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::green ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 2:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::cyan ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 3:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::magenta ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    case 4:
        symbol = new QwtSymbol( QwtSymbol::Ellipse,
                                QBrush( Qt::gray ), QPen( Qt::red, 1 ), QSize( 8, 8 ) );
        curve->setSymbol(symbol);
        break;
    default:
        break;
    }
    curve->attach(this);
    this->replot();
}