NOT use shift, only use left mouse click && drag to browse the slice in each sliceWidge(Red ,green etc) separately
You can make left-click-and-drag set the slice intersection position by mapping the left-click-and-drag GUI event to “slice translate” widget event:
for viewName in slicer.app.layoutManager().sliceViewNames():
widget = slicer.app.layoutManager().sliceWidget(viewName).sliceView().displayableManagerByClassName("vtkMRMLCrosshairDisplayableManager").GetSliceIntersectionWidget()
widget.SetEventTranslationClickAndDrag(widget.WidgetStateIdle, vtk.vtkCommand.LeftButtonPressEvent, vtk.vtkEvent.NoModifier, widget.WidgetStateTranslate, widget.WidgetEventTranslateStart, widget.WidgetEventTranslateEnd)
If you want this behavior to be persistent then you can put this code snippet into your startup .slicerrc.py
file.
thx nice lassoan , but i want to browse the slice in current widge, for example, in red widget i want to browse the slice in it by mouse click and drag
So you want to browse (change slice offset) for the current widget with left mouse click and drag over the image data? Is there a reason you do not want to left mouse click and drag the slider at the top of the slice widget to change slice offset?
There are other ways to change slice offset of the current widget including:
- mouse scroll wheel while over the slice
- left/right arrow keys
- “f” and “b” keys
Are these inconvenient methods for you?
hi james , this is a habbit of some users, i want to keep it as it is before
Yes, there are so many other ways to browse slices that although it would not be hard adding one more method, it would be quite low on the priority list of Slicer core developers.
If you can work in C++ then you can implement a proper solution by adding a new state in the crosshair widget (we’ll be happy to review and merge it in the Slicer core if you send a pull request). Alternatively, you can implement a somewhat hacky solution in Python, by observing low-level view interaction events.