Exemplo n.º 1
0
def show_axial():
    if bpy.types.Scene.in_camera_view and bpy.data.objects.get("Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'axial':
            bpy.data.objects["Camera_empty"].rotation_euler = [np.pi / 2, 0.0, np.pi]
            bpy.context.scene.current_view = 'axial'
            bpy.context.scene.current_view_flip = 0
        else:
            if bpy.context.scene.current_view_flip == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [np.pi / 2, 0.0, np.pi]
            else:
                # print('in ShowAxial else')
                bpy.data.objects["Camera_empty"].rotation_euler = [-np.pi / 2, 0.0, np.pi]
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip
        ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
    else:
        mu.get_view3d_region().view_perspective = 'ORTHO'
        # todo: first term is always False...
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'axial':
            mu.get_view3d_region().view_rotation = AXIAL_SUPERIOR # [1, 0, 0, 0]
            bpy.context.scene.current_view = 'axial'
            bpy.context.scene.current_view_flip = 0
        else:
            mu.rotate_view3d(AXIAL_SUPERIOR) if bpy.context.scene.current_view_flip else mu.rotate_view3d(AXIAL_INFERIOR)
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip
        ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
Exemplo n.º 2
0
def show_coronal(show_frontal=False):
    if show_frontal:
        mu.rotate_view3d(CORONAL_ANTERIOR)
        bpy.context.scene.current_view = 'coronal'
        bpy.context.scene.current_view_flip = 0
        return

    if bpy.types.Scene.in_camera_view and bpy.data.objects.get("Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'coronal':
            bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, np.pi]
            bpy.context.scene.current_view = 'coronal'
            bpy.context.scene.current_view_flip = 0
        else:
            if bpy.context.scene.current_view_flip == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, np.pi]
            else:
                # print('in ShowCoronal else')
                bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, 0.0]
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip
        ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
    else:
        mu.get_view3d_region().view_perspective = 'ORTHO'
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'coronal':
            mu.rotate_view3d(CORONAL_ANTERIOR)
            bpy.context.scene.current_view = 'coronal'
            bpy.context.scene.current_view_flip = False
        else:
            mu.rotate_view3d(CORONAL_ANTERIOR) if bpy.context.scene.current_view_flip else mu.rotate_view3d(CORONAL_POSTERIOR)
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip
        ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
Exemplo n.º 3
0
def show_sagital():
    if bpy.types.Scene.in_camera_view and bpy.data.objects.get("Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'sagittal':
            bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, np.pi / 2]
            bpy.context.scene.current_view = 'sagittal'
            bpy.context.scene.current_view_flip = 0
        else:
            if bpy.context.scene.current_view_flip == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, np.pi / 2]
            else:
                # print('in ShowSagittal else')
                bpy.data.objects["Camera_empty"].rotation_euler = [0.0, 0.0, -np.pi / 2]
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip
            # ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
    else:
        mu.get_view3d_region().view_perspective = 'ORTHO'
        if mu.get_time_from_event(mu.get_time_obj()) > 2 or bpy.context.scene.current_view != 'sagittal':
            mu.rotate_view3d(SAGITTAL_LEFT)
            bpy.context.scene.current_view = 'sagittal'
            bpy.context.scene.current_view_flip = False
        else:
            mu.rotate_view3d(SAGITTAL_LEFT) if bpy.context.scene.current_view_flip else mu.rotate_view3d(SAGITTAL_RIGHT)
            bpy.context.scene.current_view_flip = not bpy.context.scene.current_view_flip

    # view_all()
    # zoom(-1)
    ShowHideObjectsPanel.time_of_view_selection = mu.get_time_obj()
Exemplo n.º 4
0
def show_coronal(show_frontal=False):
    if show_frontal:
        bpy.types.Scene.current_view = 'coronal'
        bpy.types.Scene.current_view_direction = 0
        return

    if bpy.types.Scene.in_camera_view and bpy.data.objects.get(
            "Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'coronal':
            bpy.data.objects["Camera_empty"].rotation_euler = [
                0.0, 0.0, 3.1415927410125732
            ]
            bpy.types.Scene.current_view = 'coronal'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    0.0, 0.0, 3.1415927410125732
                ]
            else:
                # print('in ShowCoronal else')
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    0.0, 0.0, 0.0
                ]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction
        bpy.types.Scene.time_of_view_selection = mu.get_time_obj()
    else:
        bpy.data.screens['Neuro'].areas[1].spaces[
            0].region_3d.view_perspective = 'ORTHO'
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'coronal':
            bpy.data.screens['Neuro'].areas[1].spaces[
                0].region_3d.view_rotation = [
                    0.7071068286895752, 0.7071068286895752, -0.0, -0.0
                ]
            bpy.types.Scene.current_view = 'coronal'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [
                        0.7071068286895752, 0.7071068286895752, -0.0, -0.0
                    ]
            else:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [
                        0, 0, 0.7071068286895752, 0.7071068286895752
                    ]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction
        bpy.types.Scene.time_of_view_selection = mu.get_time_obj()
Exemplo n.º 5
0
def show_sagital():
    if bpy.types.Scene.in_camera_view and bpy.data.objects.get(
            "Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'saggital':
            bpy.data.objects["Camera_empty"].rotation_euler = [
                0.0, 0.0, 1.5707963705062866
            ]
            bpy.types.Scene.current_view = 'saggital'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    0.0, 0.0, 1.5707963705062866
                ]
            else:
                # print('in ShowSaggital else')
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    0.0, 0.0, -1.5707963705062866
                ]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction
            # bpy.types.Scene.time_of_view_selection = mu.get_time_obj()
    else:
        bpy.data.screens['Neuro'].areas[1].spaces[
            0].region_3d.view_perspective = 'ORTHO'
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'saggital':
            bpy.data.screens['Neuro'].areas[1].spaces[
                0].region_3d.view_rotation = [0.5, 0.5, -0.5, -0.5]
            bpy.types.Scene.current_view = 'saggital'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [0.5, 0.5, -0.5, -0.5]
            else:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [0.5, 0.5, 0.5, 0.5]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction

    # view_all()
    # zoom(-1)
    bpy.types.Scene.time_of_view_selection = mu.get_time_obj()
Exemplo n.º 6
0
def show_axial():
    if bpy.types.Scene.in_camera_view and bpy.data.objects.get(
            "Camera_empty") is not None:
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'axial':
            bpy.data.objects["Camera_empty"].rotation_euler = [
                1.5707963705062866, 0.0, 3.1415927410125732
            ]
            bpy.types.Scene.current_view = 'axial'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    1.5707963705062866, 0.0, 3.1415927410125732
                ]
            else:
                # print('in ShowAxial else')
                bpy.data.objects["Camera_empty"].rotation_euler = [
                    -1.5707963705062866, 0.0, 3.1415927410125732
                ]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction
        bpy.types.Scene.time_of_view_selection = mu.get_time_obj()
    else:
        bpy.data.screens['Neuro'].areas[1].spaces[
            0].region_3d.view_perspective = 'ORTHO'
        if mu.get_time_from_event(mu.get_time_obj(
        )) > 2 or bpy.types.Scene.current_view != 'axial':
            bpy.data.screens['Neuro'].areas[1].spaces[
                0].region_3d.view_rotation = [1, 0, 0, 0]
            bpy.types.Scene.current_view = 'axial'
            bpy.types.Scene.current_view_direction = 0
        else:
            if bpy.types.Scene.current_view_direction == 1:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [1, 0, 0, 0]
            else:
                bpy.data.screens['Neuro'].areas[1].spaces[
                    0].region_3d.view_rotation = [0, 1, 0, 0]
            bpy.types.Scene.current_view_direction = not bpy.types.Scene.current_view_direction
        bpy.types.Scene.time_of_view_selection = mu.get_time_obj()