Hello,
I am writing a real time plotting widget.
I need to trace 12 signals as fast as possible.The height space of the widget is subdivided in 12 pieces each of them hosts a signal.
At the moment It seems like the performances with qt3 are much better than thoose with Qt4. In Qt3 code I trace on a Pixmap and then I bitBlt to the visible area.
Some pieces of the Qt4 code follows:
Inside constructor i use a timer to call the method processSomeThing "as fast as possible":
connect(timer, SIGNAL(timeout()), this, SLOT(processSomeThing()));
timer->start(0);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(processSomeThing()));
timer->start(0);
To copy to clipboard, switch view to plain text mode
I use a bidimensional array to store data:
int points[12][640];
int points[12][640];
To copy to clipboard, switch view to plain text mode
Inside processSomeThing for each call I add 12 points and update current_x position (it wraps after the 640th point). After adding 12 points I call
repaint(current_x-1,0,1,400);
repaint(current_x-1,0,1,400);
To copy to clipboard, switch view to plain text mode
This calls paintEvent to retrace a 1x400 rectangle.
Inside paintEvent I trace 12 lines each of them starts from the previous value to the current values
for (i=0; i<ngraphs; i++)
{
prev_y = ((i+1)*y_space)-ampliAndClipValue(points[i][current_x-1]);
new_y = ((i+1)*y_space)-ampliAndClipValue(points[i][current_x]);
painter.drawLine(current_x-1,prev_y,current_x,new_y);
}
for (i=0; i<ngraphs; i++)
{
prev_y = ((i+1)*y_space)-ampliAndClipValue(points[i][current_x-1]);
new_y = ((i+1)*y_space)-ampliAndClipValue(points[i][current_x]);
painter.drawLine(current_x-1,prev_y,current_x,new_y);
}
To copy to clipboard, switch view to plain text mode
More in general I am asking what are the best optimisations for realtime plotting widgets (For examples polylines or so on) and why Qt3 code is faster then Qt4 one.
Thanks in advance
Bookmarks