How to use vtkGenericRenderWindowInteractor
? What is it meant for (use-case)?
The documentation of vtkGenericRenderWindowInteractor
is light… Not sure to get when, why and how you need to use this…
Start from here: https://examples.vtk.org/site/Cxx/Interaction/MouseEvents/. All works fine. Now, replace vtkRenderWindowInteractor
with vtkGenericRenderWindowInteractor
:
>> git diff
diff --git a/MouseEvents.cxx b/MouseEvents.cxx
index ddba719..0b91b98 100644
--- a/MouseEvents.cxx
+++ b/MouseEvents.cxx
@@ -7,9 +7,11 @@
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
-#include <vtkRenderWindowInteractor.h>
+#include <vtkGenericRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSphereSource.h>
+#include <vtkCommand.h>
+#include <vtkCallbackCommand.h>
namespace {
@@ -46,6 +48,9 @@ vtkStandardNewMacro(customMouseInteractorStyle);
} // namespace
+void timerEventCallback(vtkObject *caller, unsigned long eventId, void *clientData, void *callData) {
+}
+
int main(int, char*[])
{
vtkNew<vtkNamedColors> colors;
@@ -70,7 +75,10 @@ int main(int, char*[])
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName("MouseEvents");
- vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
+ vtkNew<vtkGenericRenderWindowInteractor> renderWindowInteractor;
+ vtkSmartPointer<vtkCallbackCommand> timerEventCommand = vtkSmartPointer<vtkCallbackCommand>::New();
+ timerEventCommand->SetCallback(timerEventCallback);
+ renderWindowInteractor->AddObserver(vtkCommand::TimerEvent, timerEventCommand);
renderWindowInteractor->SetRenderWindow(renderWindow);
Looks like the windows pops up flashing and die immediately?!.. Tried to add timerEventCallback
like suggested in the doc (but without really understanding why ?!..): no improvement…
Didn’t find any example of use:
>> git remote -v
origin https://gitlab.kitware.com/vtk/vtk.git (fetch)
>> git grep vtkGenericRenderWindowInteractor
...
Doesn’t tell much…
How and when to use vtkGenericRenderWindowInteractor
? How to make the simple code above work with it?