How to rotate OrthogonalSlicesDeg in slices?

在插件中,我用Ctrl + Alt + Left-click-and-drag在不同的Slice里找到了一个合适vector, 我想移动这个vector, 想了很多方法都不理想, 其中包括:rotateOrthogonalSlicesDeg, 可是这个方法,只能在一个Slice里面旋转,当我改变Slice后,原来那个slice的角度就归零了…谁有好的方法帮我?

In my plug-in, I used Ctrl + Alt + Left-click-and-drag to find a suitable vector(include position and angle) from different slices. I wanted to move this vector’s position and keep its angle, I had try to some methods, but not ideal, for example: rotateOrthogonalSlicesDeg, but this method can only be rotated in a slice, when I change the angle in another slice, the angle of the previous slice reset…Who has a good way to help me?

@lassoan@Juicy@jamesobutler @jcfr @pieper

我的具体思路是: 通过Ctrl + Alt + Left-click-and-drag的方法, 找到一个矢量, 返回并保存这个矢量的位置和在三个slice(RAS) 角度, 利用rotateOrthogonalSlicesDeg 找回这个视图,

My specific idea is: Find a vector by Ctrl + Alt + Left-click-and-drag from slices, return and save the position of this vector and the angle of the three slices (RAS), use the rotateOrthogonalSlicesDeg to retrieve this vector views (sense) or move this vector’s position and succeed its angle…

好吧…我自己解决了这个问题…贡献我的代码:
From:setSlicePositionAndOrientation

  def orthoReset(PIP,nor,ax):

    RNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSliceNodeRed")
    YNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSliceNodeYellow")
    GNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSliceNodeGreen")
    # Rslice
    RNode.SetSliceToRASByNTP(-nor[0][0],-nor[0][1],-nor[0][2], 
                             -ax[0][0],-ax[0][1],-ax[0][2], 
                             PIP[0], PIP[1], PIP[2], 0)

    YNode.SetSliceToRASByNTP(-nor[2][0],-nor[2][1],-nor[2][2], 
                             -ax[2][0],-ax[2][1],-ax[2][2], 
                             PIP[0], PIP[1], PIP[2], 0)

    GNode.SetSliceToRASByNTP(-nor[1][0],-nor[1][1],-nor[1][2], 
                             -ax[1][0],-ax[1][1],-ax[1][2], 
                             PIP[0], PIP[1], PIP[2], 0)
    return True

其中, ax和nor通过GetSliceToRAS获取,其中ax为第一列, nor为第三列,比如:

    axialSliceToRas = axialNode.GetSliceToRAS()
    axR = [
        axialSliceToRas.GetElement(0, 0),
        axialSliceToRas.GetElement(1, 0),
        axialSliceToRas.GetElement(2, 0),
    ]
    norR = [
        axialSliceToRas.GetElement(0, 2),
        axialSliceToRas.GetElement(1, 2),
        axialSliceToRas.GetElement(2, 2),
    ]
    x1 = [
        axialSliceToRas.GetElement(0, 3),
        axialSliceToRas.GetElement(1, 3),
        axialSliceToRas.GetElement(2, 3),
    ]

From:getPlaneIntersectionPoint