[vtkusers] Subject- Observer and callbacks patterns
totte at dunescientific.com
Wed Jan 7 23:14:04 EST 2015
I wonder if someone have tips on a good approach on how to visualize a
complex 'subject' with vtk, without mixing in vtk code into client code?
What I'm looking for is how to efficiently separate the data (subject)
with the presentation, vtk (observer) so to say.
In my case, I'm having a model for a molecule (subject). My implemented
molecule model do not have any vtk code. It has all internal data for
atom positions, bond angles etc, and algorithms to translate, rotate and
I'm thinking of setting up a model where a "MoleculeObserver", contains
all vtk objects, allowing the molecule to be rendered.
The dataflow where the molecule updates the molecule observer seem
pretty straightforward. The observer will get updates when anything
subscribed to changes, resulting in a change in the vtk pipeline. And
the dataflow in the vtk pipeline seem to be really well defined.
But how to go the other way? Say I want a vtk user to be able to move or
rotate the molecule by the mouse? Then the coordinates of atoms, each
one having represented by its own actor and position, need to be
transferred to the molecule model from the moleculeobserver (vtk code).
How can one set that up?
Can it be achieved using callbacks?
Totte Karlsson, Ph.D.
Dune Scientific, LLC
425-296 1980 (office)
425-780 9648 (cell)
More information about the vtkusers