About changing mouse cursor

I want to change shape of mouse cursor when mouse crosses MPR linesCapture
I’ve added function in the vtkMRMLSliceIntersectionWidget.cxx to check crossing with MPR lines.
But how can I change cursor in that time? I think I have to add setCursor to the qMRMLSliceView.cxx.
How can I send event from the vtkMRML to the qMRML? Is there anything sample doing such an action?

Thanks.

Just I found a way to do it. Hope it will help everyone who wants to implement similar logic.
// Sender
vtkMRMLSliceIntersectionWidget::MyFunc()
{
crosshairNode->InvokeEvent(vtkMRMLCrosshairNode::MyEvent, nullptr);
}

// Handler
void qMRMLSliceControllerWidgetPrivate::setAndObserveCrosshairNode()
{
this->qvtkReconnect(nullptr, crosshairNode, vtkMRMLCrosshairNode::MyEvent,
q, SLOT(MyHandler()));
}

It is great that you are adding this feature. We have created the slice intersection widget to allow exactly this and also to make it easier to customize the behavior (e.g., drag-and-drop slice intersection line to move/rotate slice intersection instead of Shift+MouseMove and Ctrl+Alt+Left-click-and-drag).

To change the mouse cursor, please update the displayable manager’s GetMouseCursor() method. Since the crosshair is already a widget, all you need to do is to ask the widget what is the desired cursor shape, similarly how it is done in markups displayable manager.

1 Like

Hello Andras,
Thanks for your reply.
Just I was become known there already exists virtual function named GetMouseCursor().
vtkMRMLAbstractDisplayableManager and his child class vtkMRMLMarkupsDisplayableManager have this function.
Also vtkMRMLAbstractWidget and his child class vtkSlicerMarkupsWidget have that one.
I added logging function in the above all GetMouseCursor() and found only vtkMRMLAbstractDisplayableManager’s GetMouseCursor() is working.
I think displayable manager’s GetMouseCursor() should call its widget’s GetMouseCursor() then my logic is able to work.
Unfortunately vtkMRMLAbstractDisplayableManager does not have widget member as vtkMRMLMarkupsDisplayableManager has LastActiveWidget.
So currently there’s no way to call widget’s GetMouseCursor() from the displayable manager.

vtkMRMLCrosshairDisplayableManager has the SliceIntersectionWidget widget. You can ask that widget what cursor shape it wants and set that in the renderer, similarly how it is done in markups.

1 Like

I added GetMouseCursor() on the vtkMRMLCrosshairDisplayableManager and let it to call vtkMRMLSliceIntersectionWidget::GetMouseCursor() and it’s working.
But really mouse cursor isn’t changed despite of GetMouseCursor() returns VTK_CURSOR_CROSSHAIR.
I think somewhere it hooks mouse cursor.
Anyway thanks for your answer and I have learned some event handlings more.
I have more issues and will ask you.