[vtkusers] timer events
Charl P. Botha
c.p.botha at its.tudelft.nl
Tue Apr 1 07:58:46 EST 2003
Hi Nico,
Let's keep this on the list, as other people might also find it useful.
BTW, your mailer is being VERY naughty with line-wrapping.
On Tue, 2003-04-01 at 14:36, Nico Vermaas wrote:
> What I have is 2 applications that communicate with each other:
>
> (1) a GUI that is made with Delphi (for Linux). I use that GUI to
> change settings like colors, dimensions and it has some buttons with
> predefined views. Later I will be adding different kind of predefined
> visualisations. These settings are then transferred to a second app by
> means of a simple ascii file.
>
> (2) A C++/VTK applications where the user can interact using the
> standard vtk interactors. This app reads the settings from the ascii
> file I mentioned and adjusts the visualisations accordingly. Actually
> it checks if that ascii file exists and if it does it calls an update
> function. There is also some data written back to the ascii file (cam
> positions) which are read in by the (1) again.
>
> But... when I change anything in (1) the visualisations in (2) will not
> be updated untill I switch to (2) and do something there (because
> myUpdate is triggered by the modified event). Or when I invalidate
> part of the window of (1) by dragging another window over it.
>
> What I want is that myUpdate is triggered in (2) whenever I change a
> setting in (1). So I thought that I could let a timer check for the
> existence of that ascii file. But I can't get the bloody timer to
> start ticking.
I.e. you want to use a hammer as a figure-saw. :) This is not what that
timer is for. The timer in the interactor is used by certain interactor
styles to do their work. It is not there for you to play with.
The Right Way(tm) to do what you want to do would be to integrate VTK
with your Kylix application. This comes down to setting the WindowId of
the RenderWindow to the WindowId (handle, whatever) of a window in your
Kylix application. Have a look at some of the VTK to widget set glue
code, e.g. http://cpbotha.net/vtkFlRenderWindowInteractor.html
If you REALLY want to do it by polling a text file (ugh) then create a
VTK application with an extra thread that consists of a select() loop on
your file. This extra thread can then notify the VTK logic in your
primary thread when something changes. Alternatively, you could create
a VTK/some widget set (e.g. FLTK, QT) application that polls the file in
its idle loop. The simple VTK event loop doesn't support an idle event
itself.
HTH,
Charl
--
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/
More information about the vtkusers
mailing list