Toggling Parallel Projection programmatically not updating the 3D viewer

When I set the parallel projection parameter of the 3D view in the Python Console, the camera updates, but the parallel projection button in the 3D viewer does not. If it’s toggled off using the button and turned on programmatically, it reverts back to off after scene interaction.

I tried calling slicer.app.processEvents() and triggering different events, but I don’t seem to be able to get this setting to update.

This can be replicated with the code below.

viewNode1 = slicer.mrmlScene.GetFirstNodeByName("View1")
camera1 = slicer.modules.cameras.logic().GetViewActiveCameraNode(viewNode1)
camera1.SetParallelProjection(0)
camera1.SetParallelProjection(1)

Camera parameters must be changed at MRML level (in the camera node). If you modify anything directly at lower level in VTK then the change will not be effective and will be undone when the camera node is modified. If this is not described in the camera node documentation then it would be great if you could submit a pull request that adds it. Thank you!

I’ve had another look and that you used the camera node method, so the update should work well. I’ll debug this.

1 Like