Hello, I'm new in this site, and I am not an expert programmer so, any help will be great for me 
I am creating a GUI, where in one graph, 6 signals are plotted, and in another graph, 6 other signals. example.png
So these signals come from a serial port, and I need to graph them in real time and send them in real time.
For now, I worry about the plotting part
What I thought at first, was replot every time a new sample arrived, but I think this would be inefficient and I do not know if having 12 signals with approximately 2500 samples each, finish making the program slow.
I was reading here, and found similar questions, I read the oscilloscope and real_time examples, but some parts do not become very clear to me.
Probably you are already tired of responding to them, but I really still have doubts.
I understand that:
- I need to use a QVector for append new sample.
- I need to set this samples to a QwtPlotCurve.
- I need to use QwtPlotDirectPainter::drawSeries for draw only the las sample.
Also need to use a QRect, but I dont understand well how this work.
In the real_time example, I think the most important art is at incrementalplot.cpp rigth?
but in the MainWindow.cpp file, never create and object of this class, only a randomplot object. I see that randomplot use the incrementalplot class and the method appendPoint (I think this is what I need), but I do not see the order in which the instructions are executed.
In the oscilloscope example, something similar is used at plot.cpp specifically Plot::updateCurve().
this, use a CurveData, that use a signaldata for append samples i think. (I think use a QVector for this rigth?).
and after, the same of real_time: QwtScaleMap, QRect and QwtPlotDirectPainter::drawSeries. but this differs in that it verifies if it can write in the array before doing it, and if it is not possible, it saves in a buffer. Is this correct? I was never use QReadWriteLock so i dont know how it work.
I have the same doubts as in the other example, I do not see the order in which the instructions are executed.
But the principal question is how can I use the QwtPlotDirectPainter::drawSeries, why need to use a canvasMap and how use the QRect. 
Maybe are so many questions and maybe are trivials but, for me is a little difficult to understand.
Any help will be greatly appreciated! 
I try with little examples using a qwtplot and 1 button, When I press the button, a new sample should be added:
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
i=0; c = 0;
ya = false;
graf->attach(ui->qwtPlot);
d_directPainter = new QwtPlotDirectPainter();
}
void MainWindow::on_pushButton_clicked()
{
dat.append(point);
graf->setSamples(dat);
xMap = ui->qwtPlot->canvasMap( graf->xAxis() );
yMap = ui->qwtPlot->canvasMap( graf->yAxis() );
r.moveCenter( center.toPoint() );
clipRect += r;
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries( graf, dat.size() - 2, dat.size() - 1 );
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
i=0; c = 0;
ya = false;
graf = new QwtPlotCurve("");
graf->attach(ui->qwtPlot);
d_directPainter = new QwtPlotDirectPainter();
}
void MainWindow::on_pushButton_clicked()
{
QPointF point = QPointF(c++,i);
dat.append(point);
graf->setSamples(dat);
xMap = ui->qwtPlot->canvasMap( graf->xAxis() );
yMap = ui->qwtPlot->canvasMap( graf->yAxis() );
const QPointF center =
QwtScaleMap::transform( xMap, yMap, point );
r.moveCenter( center.toPoint() );
clipRect += r;
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries( graf, dat.size() - 2, dat.size() - 1 );
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
}
To copy to clipboard, switch view to plain text mode
but this dont work. and try also:
void MainWindow::on_pushButton_clicked()
{
dat.append(point);
graf->setSamples(dat);
xMap = ui->qwtPlot->canvasMap( graf->xAxis() );
yMap = ui->qwtPlot->canvasMap( graf->yAxis() );
const QSize symbolSize
= graf
->symbol
()->size
();
QRect r
( 0,
0, symbolSize.
width() + 2, symbolSize.
height() + 2 );
clipRect
= QwtScaleMap::transform( xMap, yMap, br
).
toRect();
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries( graf, dat.size() - 2, dat.size() - 1 );
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
}
void MainWindow::on_pushButton_clicked()
{
QPointF point = QPointF(c++,i);
dat.append(point);
graf->setSamples(dat);
xMap = ui->qwtPlot->canvasMap( graf->xAxis() );
yMap = ui->qwtPlot->canvasMap( graf->yAxis() );
const QSize symbolSize = graf->symbol()->size();
QRect r( 0, 0, symbolSize.width() + 2, symbolSize.height() + 2 );
clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect();
d_directPainter->setClipRegion( clipRect );
d_directPainter->drawSeries( graf, dat.size() - 2, dat.size() - 1 );
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
}
To copy to clipboard, switch view to plain text mode
But doesn't work either.
Only with replot work for me 
dat.append(point);
graf->setSamples(dat);
graf->setSamples(datos);
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
ui->qwtPlot->replot();
QPointF point = QPointF(c++,i);
dat.append(point);
graf->setSamples(dat);
datos << QPointF(c++,i);
graf->setSamples(datos);
if(!ya) {i++; if(i==10)ya=true;}
else {i--; if(i==0)ya=false;}
ui->qwtPlot->replot();
To copy to clipboard, switch view to plain text mode
Thanks in advance, I hope someone can help me
Here an image of how my interface is going, any comments or suggestions are also welcome
gui.jpg
Bookmarks