PDA

View Full Version : incremental 2d plotter with QGraphicsView



bingofuel
24th August 2009, 02:30
Hello.
I'm using QT 4.5 on GNU/Linux.
I'm trying to make a 2d plot Widget using QGraphicsView. I've done a few things in reference to this, always with a non-modificable QGraphicsItem, and everything goes well (it's really an excellet framework)
But when i tried to make an real-time incremental plotter i get lost, because i don't know how to modify the content of the QGraphicsItem in a correct way, I mean, that the GraphicsItem update at acceptable time.
I tried modifying the QPainterPath of the QGraphicsItem when a new point arrived, adding the point at the end.


QPainterPath painterpath= item.path();
painterpath.lineTo(newpoint);
item.setPath(painterpath);

but that is really expensive, and i suppouse a bad way to do it.
i took a look at QGraphicsItemAnimation but i couldn't see the way to do it, either.
i've already seen the qwt project but i think it hasn't a QGraphicsView implementation.


There are examples of something like that? How can i do it?


thanks!

bingofuel
25th August 2009, 06:03
I think i have half of the problem solved.
i connected the new point's arrival to the qGraphicsScene 's advance method and i've implemented a advance method in my QGraphicsPathItem according to an answer in stackoverflow, but now the problem, i think is here.



p.lineTo(a);
setPath(p);


when i set the path to the QGrapicsItem i think is copying all the path or drawing all the path everytime a new point is added. So is getting slower and slower.

is there a way to avoid the re-drawing and only update the new part?
maybe reimplementing the QGraphcisItem and the paintevent.
is it viable this?