I use my custom class (SliceViewRender) derived from vtkResliceImageViewer to show vtkImageData slice. I have called SetResliceModeToOblique and the crosshair can display exactly. I want to change the visibility of the crosshair cursor with the following code:
void SliceViewRender::slotSetCursorVisible(bool visible)
{
// vtkResliceCursorLineRepresentation* cursorLineRep = vtkResliceCursorLineRepresentation::SafeDownCast(GetResliceCursorWidget()->GetRepresentation());
vtkResliceCursorLineRepresentation* cursorLineRep = dynamic_cast<vtkResliceCursorLineRepresentation*>(GetResliceCursorWidget()->GetRepresentation());
// this->GetResliceCursorWidget()->GetResliceCursorRepresentation()->SetVisibility(visible);
// this->GetResliceCursorWidget()->GetResliceCursorRepresentation()->Modified();
cursorLineRep->GetResliceCursorActor()->SetVisibility(visible);
cursorLineRep->GetResliceCursorActor()->Modified();
GetRenderWindow()->Render();
}
I failed to hidden the cursor. If I use GetVisibility(), I can get the correct result(false). But the cursor is always visible. Is there anything wrong with my code?
My VTK version is 8.2.0. Thanks in advance.