//Set scene, pixmap and get an image of the data
scene->addItem(pixmapItem);
view->setScene(scene);
setCentralWidget(view);
imageSrc = new ImageSource();
pixmapItem->setPixmap(*imageSrc->nextImage());
imagerectangle
= new QImage(27500,
250,
QImage::Format_ARGB32);
imagerectangle->fill(qRgba(0, 0, 0, 0));
// Set a Qpainter
rectangle
= new QPainter(imagerectangle
);
//Pen properties
QRectF rect
(5000,
100,
3000,
50);
lepen.setColor(Qt::red);
lepen.setWidth(10);
// TEST QWT: OK work -> a curve is displayed *****************************
xMap.setScaleInterval(0, 10000);
yMap.setScaleInterval(0, 250);
// Calculate values
double xval[10000];
double yval[10000];
for(int i=0; i<10000;i++)
{
xval[i] = i;
yval[i] = qSin(xval[i]) * qCos(2.0 * xval[i]) * 100 +101;
}
d_curves.
setPen(QColor(Qt
::yellow));
d_curves.
setRenderHint(QwtPlotItem::RenderAntialiased);
d_curves.setRawSamples(xval, yval, 10000);
const QRect &r
= contentsRect
();
xMap.setPaintInterval(r.left(), r.right());
yMap.setPaintInterval(r.top(), r.bottom());
d_curves.draw(rectangle, xMap, yMap, r);
d_curves.show();
// So far this is good ! ************************************************
// add a scale to the plot. DOES NOT WORK nothing is displayed ????????????
echelle->setBorderDistance(0);
echelle
->scaleDraw
()->setTickLength
(QwtScaleDiv::MajorTick,
100);
echelle
->scaleDraw
()->setTickLength
(QwtScaleDiv::MinorTick,
50);
rectangle
->setRenderHint
(QPainter::Antialiasing,
echelle
->testRenderHint
(QwtPlotItem::RenderAntialiased) );
echelle->setVisible(TRUE);
echelle->draw(rectangle,xMap,yMap,r);
echelle->show();
// what is wrong here ??????????????????????
// add to scene
scene
->addPixmap
(QPixmap::fromImage(*imagerectangle
));
//Set scene, pixmap and get an image of the data
scene = new QGraphicsScene(this);
pixmapItem = new QGraphicsPixmapItem();
scene->addItem(pixmapItem);
view = new QGraphicsView();
view->setScene(scene);
setCentralWidget(view);
imageSrc = new ImageSource();
pixmapItem->setPixmap(*imageSrc->nextImage());
QImage* imagerectangle;
imagerectangle = new QImage(27500,250,QImage::Format_ARGB32);
imagerectangle->fill(qRgba(0, 0, 0, 0));
// Set a Qpainter
QPainter* rectangle;
rectangle = new QPainter(imagerectangle);
//Pen properties
QPen lepen;
QRectF rect(5000,100,3000,50);
lepen.setColor(Qt::red);
lepen.setWidth(10);
// TEST QWT: OK work -> a curve is displayed *****************************
QwtPlotCurve d_curves;
QwtScaleMap xMap;
QwtScaleMap yMap;
xMap.setScaleInterval(0, 10000);
yMap.setScaleInterval(0, 250);
// Calculate values
double xval[10000];
double yval[10000];
for(int i=0; i<10000;i++)
{
xval[i] = i;
yval[i] = qSin(xval[i]) * qCos(2.0 * xval[i]) * 100 +101;
}
d_curves.setPen(QColor(Qt::yellow));
d_curves.setStyle(QwtPlotCurve::Lines);
d_curves.setRenderHint(QwtPlotItem::RenderAntialiased);
d_curves.setCurveAttribute(QwtPlotCurve::Fitted);
d_curves.setRawSamples(xval, yval, 10000);
const QRect &r = contentsRect();
xMap.setPaintInterval(r.left(), r.right());
yMap.setPaintInterval(r.top(), r.bottom());
d_curves.draw(rectangle, xMap, yMap, r);
d_curves.show();
// So far this is good ! ************************************************
// add a scale to the plot. DOES NOT WORK nothing is displayed ????????????
QwtPlotScaleItem* echelle;
echelle = new QwtPlotScaleItem();
echelle->setAlignment(QwtScaleDraw::TopScale);
echelle->setBorderDistance(0);
echelle->scaleDraw()->setTickLength(QwtScaleDiv::MajorTick,100);
echelle->scaleDraw()->setTickLength(QwtScaleDiv::MinorTick,50);
echelle->scaleDraw()->enableComponent(QwtAbstractScaleDraw::Labels,true);
rectangle->setRenderHint(QPainter::Antialiasing,
echelle->testRenderHint(QwtPlotItem::RenderAntialiased) );
echelle->setVisible(TRUE);
echelle->draw(rectangle,xMap,yMap,r);
echelle->show();
// what is wrong here ??????????????????????
// add to scene
scene->addPixmap(QPixmap::fromImage(*imagerectangle));
To copy to clipboard, switch view to plain text mode
Bookmarks