Ejemplo n.º 1
0
def filter_graph(context, d, condition, threshold, threshold_type, connections_type, stat=STAT_DIFF):
    mu.show_hide_hierarchy(False, PARENT_OBJ)
    masked_con_names = calc_masked_con_names(d, threshold, threshold_type, connections_type, condition, stat)
    parent_obj = bpy.data.objects[PARENT_OBJ]
    for con_name in d.con_names:
        cur_obj = bpy.data.objects.get(con_name)
        if cur_obj:
            cur_obj.hide = con_name not in masked_con_names
            cur_obj.hide_render = con_name not in masked_con_names
            if bpy.context.scene.selection_type == 'conds':
                cur_obj.select = not cur_obj.hide
    if parent_obj.animation_data is None:
        return
    now = time.time()
    fcurves_num = len(parent_obj.animation_data.action.fcurves)
    for fcurve_index, fcurve in enumerate(parent_obj.animation_data.action.fcurves):
        # mu.time_to_go(now, fcurve_index, fcurves_num, runs_num_to_print=10)
        con_name = mu.fcurve_name(fcurve)
        # cur_obj = bpy.data.objects[con_name]
        # cur_obj.hide = con_name not in masked_con_names
        # cur_obj.hide_render = con_name not in masked_con_names
        if bpy.context.scene.selection_type != 'conds':
            fcurve.hide = con_name not in masked_con_names
            fcurve.select = not fcurve.hide

    parent_obj.select = True
    mu.view_all_in_graph_editor(context)
Ejemplo n.º 2
0
def connections_show_vertices_update(self, context):
    vertices_obj = get_vertices_obj()
    if vertices_obj is not None:
        do_show = bpy.context.scene.connections_show_vertices
        mu.show_hide_hierarchy(do_show, vertices_obj)
        if do_show:
            _addon().filter_nodes(True)
Ejemplo n.º 3
0
def filter_graph(context,
                 d,
                 condition,
                 threshold,
                 threshold_type,
                 connections_type,
                 stat=STAT_DIFF):
    mu.show_hide_hierarchy(False, PARENT_OBJ)
    masked_con_names = calc_masked_con_names(d, threshold, threshold_type,
                                             connections_type, condition, stat)
    parent_obj = bpy.data.objects[PARENT_OBJ]
    for con_name in d.con_names:
        cur_obj = bpy.data.objects.get(con_name)
        if cur_obj:
            cur_obj.hide = con_name not in masked_con_names
            cur_obj.hide_render = con_name not in masked_con_names
            if bpy.context.scene.selection_type == 'conds':
                cur_obj.select = not cur_obj.hide
    if parent_obj.animation_data is None:
        return
    now = time.time()
    fcurves_num = len(parent_obj.animation_data.action.fcurves)
    for fcurve_index, fcurve in enumerate(
            parent_obj.animation_data.action.fcurves):
        # mu.time_to_go(now, fcurve_index, fcurves_num, runs_num_to_print=10)
        con_name = mu.get_fcurve_name(fcurve)
        # cur_obj = bpy.data.objects[con_name]
        # cur_obj.hide = con_name not in masked_con_names
        # cur_obj.hide_render = con_name not in masked_con_names
        if bpy.context.scene.selection_type != 'conds':
            fcurve.hide = con_name not in masked_con_names
            fcurve.select = not fcurve.hide

    parent_obj.select = True
    mu.view_all_in_graph_editor(context)
Ejemplo n.º 4
0
def thickness_arrows_update(self, context):
    if bpy.context.scene.cast_ray_source == 'inner':
        mu.show_hide_hierarchy(bpy.context.scene.thickness_arrows,
                               'thickness_arrows_from_inner',
                               also_parent=True,
                               select=False)
    else:
        mu.show_hide_hierarchy(bpy.context.scene.thickness_arrows,
                               'thickness_arrows_from_outer',
                               also_parent=True,
                               select=False)
Ejemplo n.º 5
0
def filter_graph(context,
                 d,
                 condition,
                 threshold,
                 threshold_type,
                 connections_type,
                 stat=STAT_DIFF):
    parent_obj_name = get_connections_parent_name()
    mu.show_hide_hierarchy(False, parent_obj_name)
    masked_con_names = calc_masked_con_names(d, threshold, threshold_type,
                                             connections_type, condition, stat)
    parent_obj = bpy.data.objects[parent_obj_name]
    bpy.context.scene.connections_num = min(len(masked_con_names),
                                            len(parent_obj.children) - 1)
    conn_show = 0
    selected_objects, selected_indices = [], []
    for con_ind, con_name in enumerate(d.con_names):
        cur_obj = bpy.data.objects.get(con_name)
        if cur_obj:
            if con_name in masked_con_names:
                selected_objects.append(cur_obj)
                selected_indices.append(con_ind)
                conn_show += 1
            cur_obj.hide = con_name not in masked_con_names
            cur_obj.hide_render = con_name not in masked_con_names
            if bpy.context.scene.selection_type == 'conds':
                cur_obj.select = not cur_obj.hide
    ConnectionsPanel.selected_objects = selected_objects
    ConnectionsPanel.selected_indices = selected_indices
    print('Showing {} connections after filtering'.format(conn_show))
    if conn_show > 0:
        bpy.context.scene.connections_min = np.min(
            d.con_values[selected_indices])
        bpy.context.scene.connections_max = np.max(
            d.con_values[selected_indices])
    if parent_obj.animation_data is None:
        return
    now = time.time()
    fcurves_num = len(parent_obj.animation_data.action.fcurves)
    for fcurve_index, fcurve in enumerate(
            parent_obj.animation_data.action.fcurves):
        # mu.time_to_go(now, fcurve_index, fcurves_num, runs_num_to_print=10)
        con_name = mu.get_fcurve_name(fcurve)
        # cur_obj = bpy.data.objects[con_name]
        # cur_obj.hide = con_name not in masked_con_names
        # cur_obj.hide_render = con_name not in masked_con_names
        if bpy.context.scene.selection_type != 'conds':
            fcurve.hide = con_name not in masked_con_names
            fcurve.select = not fcurve.hide

    parent_obj.select = True
    mu.view_all_in_graph_editor(context)
Ejemplo n.º 6
0
def connectivity_files_update(self, context):
    # if ConnectionsPanel.d == {} or ConnectionsPanel.d is None :
    load_connections_file()
    check_connections()
    for obj in bpy.data.objects['Functional maps'].children:
        if obj.name.startswith('connections'):
            val = obj.name == get_connections_parent_name()
            mu.show_hide_hierarchy(val, obj.name, True, False)
    data = ConnectionsPanel.d.con_values
    # data_max = np.percentile(data[ConnectionsPanel.selected_indices], 97)
    # data_min = np.percentile(data[ConnectionsPanel.selected_indices], 3)
    data_max = np.max(data[ConnectionsPanel.selected_indices])
    data_min = np.min(data[ConnectionsPanel.selected_indices])
    if np.sign(data_max) != np.sign(data_min):
        data_minmax = max(map(abs, [data_max, data_min]))
        data_max, data_min = data_minmax, -data_minmax
    ConnectionsPanel.data_minmax = (data_min, data_max)
Ejemplo n.º 7
0
def connectivity_files_update(self, context):
    # if ConnectionsPanel.d == {} or ConnectionsPanel.d is None :
    load_connections_file()
    check_connections()
    for obj in bpy.data.objects['Functional maps'].children:
        if obj.name.startswith('connections'):
            val = obj.name == get_connections_parent_name()
            mu.show_hide_hierarchy(val, obj.name, True, False)
    data = ConnectionsPanel.d.con_values
    # data_max = np.percentile(data[ConnectionsPanel.selected_indices], 97)
    # data_min = np.percentile(data[ConnectionsPanel.selected_indices], 3)
    if data.ndim == 3 and data.shape[2] == 2:
        data = np.diff(data, axis=2).squeeze()
    if len(ConnectionsPanel.selected_indices) > 0:
        data_max = np.nanmax(data[ConnectionsPanel.selected_indices])
        data_min = np.nanmin(data[ConnectionsPanel.selected_indices])
    else:
        data_max = np.nanmax(data)
        data_min = np.nanmin(data)
    if np.sign(data_max) != np.sign(
            data_min) and data_min != 0 and data_max != 0:
        data_minmax = max(map(abs, [data_max, data_min]))
        data_max, data_min = data_minmax, -data_minmax
    ConnectionsPanel.data_minmax = (data_min, data_max)
Ejemplo n.º 8
0
def show_cb_in_render(val=True):
    mu.show_hide_hierarchy(val, 'colorbar_camera', True, False)
    mu.show_hide_hierarchy(val, 'cCB_camera', True, False)
Ejemplo n.º 9
0
def show_cb_in_render(val=True):
    mu.show_hide_hierarchy(val, "colorbar_camera", True, False)
    mu.show_hide_hierarchy(val, "cCB_camera", True, False)
Ejemplo n.º 10
0
def thickness_arrows_update(self, context):
    mu.show_hide_hierarchy(bpy.context.scene.thickness_arrows,
                           'thickness_arrows',
                           also_parent=True,
                           select=False)