Does VTK offer some kind of key value variables saving functionality?

Does VTK offer any kind of key value variable save and load functionality between run sessions? Like loading the render where you left last time? Usually called preferences. Saving settings is main target.

No, VTK does not provide any way of saving or restoring an object’s properties.

However, there are at least two packages that provide part of what you are looking for: the tvtk module of mayavi, and the Python extensions for Paraview.

I also thought about making object properties into a built-in feature of the wrappers but I kind of dropped the ball on the idea. Really, it would be best if every VTK object actually used a key/value map to store its properties, but that would require a major rewrite.

Edit: what I wrote above might have missed the main point of what you were asking, which is whether settings can be saved to a file. As far as I know, VTK doesn’t provide this functionality, either. If you use Qt, you can use QSettings, and if you don’t use Qt, you can try saving your settings in a json file.

VTK has scene exporter/importer class pairs that can save a subset of actor properties in standard GLTF, VRML, and OBJ formats.

You can improve these classes to save/restore any properties that you would like to preserve. Among these, GLTF is the best candidate to be extended, as it is the most flexible and the modern.

If you mean just saving application preferences, then look elsewhere. This is an application framework feature and not in the scope of a visualization toolkit.

1 Like

Qt QSettings is the way I am going to achieve my goal. Thanks @dgobbi.

I use VTK 8.2.0. I can NOT find vtkGLTFExporter.h in the library. Is there any setting in CMake before building VTK? Thanks in advance.

Gltf import/export was added after 8.2 was released. You need to use a more recent VTK version.

1 Like

Thanks!