PDA

View Full Version : Thread and QGIS



Crashz83
28th October 2015, 10:19
Hello,

i'm currently working on a software that includes a mapping (using QGIS library). Mapping calculates every second different positions and makes a display on the map, resulting in monopolization of my main thread.
The problem being that my main thread should be used for other functions ...

I tried to use QProcess by creating two different programs (1 with the Carto, and 1 with the HMI) in an attempt to include the carto program in the other program, however, it is not possible to retrieve the widget carto ...

I would like to know if you have any idea how I could achieve this, it would save me from having a much too slow program.
Sorry if this is not clear and for my bad english.

For information, I develop on Ubuntu 14.04 and I use Qt 4.6.8.

Thank you in advance :)

jefftee
29th October 2015, 05:57
Not sure I understand the problem regarding "not possible to retrieve the widget carto"... When you use QProcess, it runs the programs with the arguments you specify in separate processes within the operating system. Your Qt app can then interact with the QProcess's by reading their stdout/stderr or even provide input to the external processes by writing to the QProcess using QProcess::write, which the external process can read as stdin...

Can you try to explain again what your problem is?

Crashz83
29th October 2015, 09:36
Hi, thank you for your answer.

My problem is that my main thread will draw all the time on the map and all other actions (ex : clicks boutton) will be slowed because of the frequency display.

jefftee
30th October 2015, 00:52
The drawing *must* be done on the main GUI thread, so you may have to adopt an approach where you update your data as frequently as you want, then have a QTimer that draws at some reasonable rate.

d_stranz
2nd November 2015, 18:16
If the map itself is static, and the only thing you are changing is the markers you display on it, then you are probably wasting a huge amount of CPU updating the map when you should only be updating the markers.

You could

1) Convert the map to a pixmap and only update it when the user moves / zooms / etc.
2) Display the markers in an overlay window
3) Don't redraw the map so frequently (as jefftee said). What's reasonable? Once every second? Twice a second? A good design should be able to handle that.