Re: [PyQt] QGraphicsScene background

2011-07-22 Thread Lee Harr

>> in long-running 
>> programs   
>>  
>> when many many items have been added, the 
>> scene 
>>  
>> starts to slow down.

> Did you checked the navigation pad example? It uses some tricks, e.g. by
> (optionally) using OpenGL and various transformations, that might be
> helpful for your issue, too.

Thanks Pete. I will take a deeper look at that example.

I am a bit worried at the start, though. Running that example
on my old laptop locked up the whole system (required a hard
reboot) and on my desktop it fails with OpenGL errors:

QGLShader: could not create shader 
Vertex shader for simpleShaderProg (MainVertexShader & 
PositionOnlyVertexShader) failed to compile
QGLShader: could not create shader 
Fragment shader for simpleShaderProg (MainFragmentShader & 
ShockingPinkSrcFragmentShader) failed to compile
QGLShaderProgram: could not create shader program 
Errors linking simple shader: "" 
QGLShader: could not create shader 
Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & 
UntransformedPositionVertexShader) failed to compile
QGLShader: could not create shader 
Fragment shader for blitShaderProg (MainFragmentShader & 
ImageSrcFragmentShader) failed to compile
QGLShaderProgram: could not create shader program 
Errors linking blit shader: "" 
QGLShader: could not create shader 
Warning: "" failed to compile! 


Commenting out the QGLWidget viewport allows the program
to run, but I'd be leery of using something in my application that
can fail so spectacularly.

  
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QGraphicsScene background

2011-07-22 Thread Hans-Peter Jansen
On Friday 22 July 2011, 21:04:44 Lee Harr wrote:
> I work on a turtle graphics application written using
> PyQt (pynguin.googlecode.com) and I am stuck on one
> particular feature that I would like to add.
>
> Right now, I am using QGraphicsScene and when the
> turtle draws, it uses QGraphicsItem based objects to
> show the results. Mostly QGraphicsPathItem,
> QGraphicsEllipseItem and QGraphicsSimpleTextItem.
>
> It works quite well, but in long-running programs
> when many many items have been added, the scene
> starts to slow down.
>
>
> Two options I have looked at are:
>
> Re-implementing drawBackground. I save a QPixmap as
> self.bg in my QGraphicsScene subclass, then do
> painter.drawPixmap(rect, self.bg, sourcerect)
> in drawBackground. It works, but when the zoom
> level is anything but 1:1 it gets very slow.
>
> The other way was to add a QGraphicsPixmapItem as
> the lowest item on the stack. That also seems like it
> might work, but again, as soon as the zoom level is
> anything but 1:1 the speed goes way down instantly.
>
>
> What I think I want to be able to do is to take
> all of those graphics items and flatten them down on
> to the background and then delete those items.
>
> Is there any way that an approach like this will
> be able to speed up the application (including the
> ability to zoom to arbitrary levels...)?
>
>
> Any suggestions greatly appreciated!

Did you checked the navigation pad example? It uses some tricks, e.g. by 
(optionally) using OpenGL and various transformations, that might be 
helpful for your issue, too.

Pete
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QGraphicsScene background

2011-07-22 Thread Lee Harr

I work on a turtle graphics application written using
PyQt (pynguin.googlecode.com) and I am stuck on one
particular feature that I would like to add.

Right now, I am using QGraphicsScene and when the
turtle draws, it uses QGraphicsItem based objects to
show the results. Mostly QGraphicsPathItem,
QGraphicsEllipseItem and QGraphicsSimpleTextItem.

It works quite well, but in long-running programs
when many many items have been added, the scene
starts to slow down.


Two options I have looked at are:

Re-implementing drawBackground. I save a QPixmap as
self.bg in my QGraphicsScene subclass, then do
painter.drawPixmap(rect, self.bg, sourcerect)
in drawBackground. It works, but when the zoom
level is anything but 1:1 it gets very slow.

The other way was to add a QGraphicsPixmapItem as
the lowest item on the stack. That also seems like it
might work, but again, as soon as the zoom level is
anything but 1:1 the speed goes way down instantly.


What I think I want to be able to do is to take
all of those graphics items and flatten them down on
to the background and then delete those items.

Is there any way that an approach like this will
be able to speed up the application (including the
ability to zoom to arbitrary levels...)?


Any suggestions greatly appreciated!

  
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt