PDA

View Full Version : Graphics Help



Thoosle
23rd September 2008, 00:39
I'm working on an app to chart some numerical data from an experiment and I want to implement a line drawing tool. This in itself is easy. Currently I've implemented a line drawing tool where you enter line drawing mode then click on the chart to start the line then move the mouse to drag the line to it's other end point then click to fix the end point and end that line draw. My question has to do with how best to handle the mouse move after the first click but before the last click. After a new line draw is started each move of the mouse results in a new line being drawn. But I only want to see one line on the screen. So currently I update the entire screen upon each mouse move event. This results in the effect that I desire. I click and drag the line to it's second point and click to fix the line and only see the one line in the process. The problem is that it's very inefficient to redraw the entire screen on each mouse move event when I only need to update the area where the old/new line is. I'm looking for pointers on how best to only update the required screen area. Thanks!!

aamer4yu
23rd September 2008, 05:15
Are you using simple widget to draw ??
You may have a look at QGraphicsScene or Qwt (http://qwt.sourceforge.net/)

Thoosle
23rd September 2008, 14:27
thanks aamer4yu,

Yes, I'm drawing on a widget. One way that might work is to use QPixmap::grabWidget ( QWidget * widget, const QRect & rectangle ). On each mouse move event I might save the update area to a pixmap so that I can restore that part of the screen on the next mouse move event prior to drawing the new line. This would have the effect of updating/restoring only the affected screen area.