Actually I want to have 3D view by default in center.
TRY:1 Python
in the Script repository we are having this code.
# Center the 3D view on the scene¶
layoutManager = slicer.app.layoutManager()
threeDWidget = layoutManager.threeDWidget(0)
threeDView = threeDWidget.threeDView()
threeDView.resetFocalPoint()
But this is rotating 3D object when we are clicking (Eye button) visible - invisible from segment table.
TRY:2 Python
by pressing center 3D button programmatically.
# Center 3D View
slicer.app.layoutManager().threeDWidget(0).threeDController().BarWidget.CenterButton_Header.click()
This code by pressing center 3D button has solved the issue of rotation in python files.
TRY:1 Cpp
As we know segment table’s show 3D eye code is in the Cpp for that I have done.
//Center 3D View
PythonQt::init();
PythonQtObjectPtr openBrowserContext = PythonQt::self()->getMainModule();
openBrowserContext.evalScript(QString(
"from slicer.util import * \n"
"mainWindow = slicer.util.mainWindow()\n"
"print('Segment table visible button')\n"
"slicer.app.layoutManager().threeDWidget(0).threeDController().BarWidget.CenterButton_Header.click()\n"));
This code makes 3D object in the center but when we are frequently pressing segment table’s eye button it rotates the 3D object in CW.
Can you please share any better approach for this issue.
Reason:
- its very annoying to press center 3D button all the time. So that’s way when I am loading or showing 3D object it should come to center.
Thank you.