the visibility of the cursor in vtkResliceImageViewer

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.

vtk_image_view

You can change the property of the centerlines of the the cursor actor.

for (int i = 0 ; i < 3 ; i++) {
  auto prop = this->GetResliceCursorWidget()->GetResliceCursorRepresentation()->GetResliceCursorActor()->GetCenterlineProperty(i);
  prop->SetOpacity(0.0);
}

This solution worked for me

It’s a good idea. Thank you :grinning: