I’ve already posted my issue here.
VTK developers asked me to move it here.
Lets assume I’m developing a DICOM viewer using volume rendering in VTK.
To integrate QML with VTK, we have QQuickVTKItem
.
Two main concepts of it are initializeVTK
and dispatch_async
.
In initializeVTK
we are supposed to create vtkObject
, which would store our data (like renderer, rendererWindow, etc)
In dispatch_async
we are supposed to perform operations on that data. And dispatch_async
is the only place where we could do them. As I notices, read-only operations can be done everywhere, but performing modifying operations without wrapping them into dispatch_async
causes strange things.
So, for example, I need to read DICOM directory and render DICOM stored there.
We can read parse directory outside of dispatch_async
, but when we’ve created and initialized
vtkDICOMReader
it should be passed to a next steps:
- setting properties of
vtkVolume
(color and piecewise functions) - setting mapper
- calling
renderer->AddVolume()
andrenderer->ResetCamera()
(code sample is available by link above. These calls occurs in SceneVtkData::AddDataSet
)
But these steps could take amount of time, and must be placed inside dispatch_async
.
But dispatch_async
is not async. Its more like std::launch::deferred
option in std::async
arguments. Its just a delayed callback which runs synchroniosly and blocks all Qt UI.
The same thing with any other computations which manipulates with the object returned from QQuickVTKItem::initializeVTK()
.
Is there a way to make it truly async?
The main issue I want to solve is UI blocking.
Its so strange that some operation running inside one QQuickVTKItem
blocks all other controls which are not related to this item. For example, buttons, sliders, etc.
Would be glad to see any help.