//! Return plot widget, containing the observed plot canvas
QwtPlot *QwtPlotPicker::plot()
{
    QwtPlotCanvas *w = canvas();
    if ( w )
        return w->plot();

    return NULL;
}
//! Return plot widget, containing the observed plot canvas
QwtPlot *QwtPlotMagnifier::plot()
{
    QwtPlotCanvas *w = canvas();
    if ( w )
        return w->plot();

    return NULL;
}
SelectionMoveResizer::SelectionMoveResizer(QWidget *target)
	: QWidget(target->parentWidget())
{
	QwtPlotCanvas *canvas = qobject_cast<QwtPlotCanvas *>(target);
	if (canvas)
		setParent(canvas->plot()->parentWidget());

	init();
	add(target);
}
Exemple #4
0
void IncrementalPlot::appendData(double *x, double *y, int size) {
	if (d_data == NULL) d_data = new CurveData;

	if (d_curve == NULL) {
		d_curve = new QwtPlotCurve("Data");
		d_curve->setStyle(QwtPlotCurve::NoCurve);
		d_curve->setPaintAttribute(QwtPlotCurve::FilterPoints, true);
		const QColor &c = Qt::white;
		QwtSymbol *symbol = new QwtSymbol(QwtSymbol::Ellipse);
		symbol->setBrush(QBrush(c));
		symbol->setPen(QPen(c));
		symbol->setSize(QSize(6, 6));
		d_curve->setSymbol(symbol);
		d_curve->attach(this);
	}

	d_data->append(x, y, size);
	d_curve->setRawSamples(d_data->x(), d_data->y(), d_data->count());
#ifdef __GNUC__
#warning better use QwtData
#endif

	const bool cacheMode = qobject_cast<QwtPlotCanvas *>(canvas())->testPaintAttribute(QwtPlotCanvas::BackingStore);

#if QT_VERSION >= 0x040000 && defined(Q_WS_X11)
  // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
  // works on X11. This has an tremendous effect on the performance..

	canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
#endif

	QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>(canvas());
	plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
	QPainter painter;
	QwtScaleMap xMap = plotCanvas->plot()->canvasMap(d_curve->xAxis());
	QwtScaleMap yMap = plotCanvas->plot()->canvasMap(d_curve->yAxis());
	d_curve->drawSeries(&painter, xMap, yMap, (d_curve->paintRect(xMap, yMap)), d_curve->dataSize() - size, d_curve->dataSize() -1);
	plotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, cacheMode);

#if QT_VERSION >= 0x040000 && defined(Q_WS_X11)
	canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, false);
#endif
}