[Qgis-developer] Rendering Real-Time Data in QGIS

Florian El Ahdab felahdab at gmail.com
Sun May 3 16:39:13 EDT 2009


Hi.

I am going to explain what I mean...

My CustomMapCanvasItem subclasses the MapCanvasItem class.
The constructor for my objects includes a call to MapCanvasItem(MapCanvas)
so as to initialize the parent class instance.
This call in turn executes a QGraphicsItem(0, MapCanvas->scene()) for the
same purpose and consequently adds the newly created item to the scene
(which is a private member of the MapCanvas).
Then, somehow, Qgis renders the scene using the QGraphicsScene and
QgraphicsView methods.

My point here is to say that since I add the Items to the scene, and since I
don't control how Qgis accesses those items after having added them (because
QGis uses the QGraphicsScene and View methods for the rendering), I can't
add any synchronization between Qgis thread and mine.
In short: since Qgis thread does not implement any synchronization for the
accesses to the QGraphicsItems/Scene/View, it is useless to try and
synchronize in my own thread.

I understand very well what you mean when you say that the graphics scene
must not be used concurrently without synchronization, but since Qgis code
does not synchronize, I don't see how I could in my own thread alone...

I hope I have made my point clear enough...
Maybe things do not take place at all like I think they do, because
apparently you find my question strange and I am not an expert in Qt inner
workings...

Although I know you are probably handling numerous other questions at the
same time, If you can find a few moments to look into mine further, I would
greatly appreciate it. If it is possible for you, maybe you could give me a
quick idea of how you would create a thread designed to move the items and
provide synchronization at the same time (explanations or pseudo code would
be great).

Thank you again for your help.

Florian

On Thu, Apr 30, 2009 at 12:46 PM, Martin Dobias <wonder.sk at gmail.com> wrote:

> On Wed, Apr 29, 2009 at 10:43 PM, Florian El Ahdab <felahdab at gmail.com>
> wrote:
> >
> > I understand very well your remarks about the synchronization. However,
> > since I am adding the items to the MapCanvas using the QGis API, and
> since
> > this API doesn't seem to provide any way to synchronize the access to the
> > items, I don't see how I could have the synchronization properly
> > implemented. I can add all the mutexes that I want in my code, the QGis
> API
> > won't synchronize...
> >
> > Did I miss something? Is there an implicit synchronization in the Qt API
> > regarding the QGraphicScene?
>
> I don't understand what do you mean by saying "QGis API won't
> synchronize" as QGIS API has nothing to do with it in this case.
>
> There is no implicit synchronization. You have to make sure that the
> graphics scene is not being used concurrently in more threads.
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090503/711ea7d7/attachment.html


More information about the Qgis-developer mailing list