Example #1
0
void caWaterfallPlot::myReplot()
{
#if QWT_VERSION >= 0x060100
    QwtPlotCanvas *canvas =  (QwtPlotCanvas *) plot->canvas();
    canvas->replot();
#else
    plot->canvas()->replot();
#endif
}
Example #2
0
// display
void caStripPlot::TimeOut()
{
    int c, j;
    double elapsedTime = 0.0;
    int delta = 0;
    double x0, x1, increment;
    int totalMissed = 0;

    int dataCountLimit = (int) (MULTFOROVERLAPPINGTIMES * HISTORY -1);

    if(!timerID) return;

    mutex.lock();

    // we need an exact time scale
    if(Start) {
        Start = false;
        ftime(&timeStart);
    }
    ftime(&timeNow);

    elapsedTime = ((double) timeNow.time + (double) timeNow.millitm / (double)1000) -
            ((double) timeStart.time + (double) timeStart.millitm / (double)1000);

    // change scale base in case of running time scale
    if(thisXaxisType == TimeScale) {
        timeData = INTERVAL + elapsedTime;
        setAxisScale(QwtPlot::xBottom, timeData - INTERVAL, timeData);
    }
    
    // replot in order to get the exact transformation of real coordinates to pixels
    if(thisXaxisType == TimeScale) {
        replot();
    } else {
#if QWT_VERSION >= 0x060100
        QwtPlotCanvas *canvas =  (QwtPlotCanvas *) this->canvas();
        canvas->replot();
#else
        canvas()->replot();
#endif
    }

    // we want to be sure that no pixels are missed, this is particularly important for ms windows
    // this is really not nice and time consuming, up to now no better solution
    for (int i = 2; i < dataCount; i++ ) {
        x0 = transform(QwtPlot::xBottom, rangeData[0][i-1].value);
        x1 = transform(QwtPlot::xBottom, rangeData[0][i].value);
        delta = (int) (x0+0.5) - (int) (x1+0.5) - 1;

        if(delta > 0 && x0 > 0 && x1 > 0 && delta < 20) {
            increment = (base[i-1].value - base[i].value)/ (double) (delta+1);
            //printf("===============> missed ticks=%d at=%d x0=%.1f x1=%.1f %d %d\n", delta, i, x0, x1, (int) (x0+0.5) , (int) (x1+0.5));
            totalMissed++;

            // insert missing time base data and adjust time holes
            if(thisXaxisType != TimeScale) {
                for(j = 0; j < delta; j++) {
                    base.insert(i, base[i]);
                    base.removeLast();
                }
                for(j = 1; j < delta+1; j++) {
                    base[j+i-1].value = base[i-1].value - increment * (double) j;
                }
            }

            // insert missing data and timebase
            for (c = 0; c < NumberOfCurves; c++ ) {
                for(j = 0; j < delta; j++) {
                    if(thisStyle[c] == FillUnder) {
                        fillData[c].insert(i, fillData[c][i]);
                        fillData[c].removeLast();
                    }
                    rangeData[c].insert(i, rangeData[c][i]);
                    rangeData[c].removeLast();
                }
                for(j = 1; j < delta+1; j++) {
                    rangeData[c][j+i-1].value = fillData[c][j+i-1].value = invTransform(QwtPlot::xBottom, (int) (x0+0.5)-j);
                }
            }

            if ((dataCount + delta) < dataCountLimit) dataCount = dataCount + delta;

        }
    }

    for (int c = 0; c < NumberOfCurves; c++ ) {

        if(thisStyle[c] == FillUnder) {
            fillcurve[c]->setSamples(fillData[c].toVector());
        }
        errorcurve[c]->setSamples(rangeData[c].toVector());
    }

    if(thisXaxisType == TimeScale) {
        replot();
    } else {
#if QWT_VERSION >= 0x060100
        QwtPlotCanvas *canvas =  (QwtPlotCanvas *) this->canvas();
        canvas->replot();
#else
        canvas()->replot();
#endif
    }
    timerCount=0;
    
    mutex.unlock();

}