Example #1
0
def init(addon):
    if not bpy.data.objects.get("full_colorbar", None):
        return
    ColorbarPanel.addon = addon
    colorbar_files = glob.glob(op.join(mu.file_fol(), "color_maps", "*.npy"))
    if len(colorbar_files) == 0:
        return None
    files_names = [mu.namebase(fname).replace("_", "-") for fname in colorbar_files]
    colorbar_items = [(c, c, "", ind) for ind, c in enumerate(files_names)]
    bpy.types.Scene.colorbar_files = bpy.props.EnumProperty(
        items=colorbar_items, description="colormaps files", update=colormap_update
    )
    bpy.context.scene.colorbar_files = files_names[0]
    for space in mu.get_3d_spaces():
        if space.lock_object and space.lock_object.name == "full_colorbar":
            space.show_only_render = True
    register()
    ColorbarPanel.init = True
    bpy.context.scene.show_cb_in_render = False
    mu.select_hierarchy("colorbar_camera", False, False)
    if not ColorbarPanel.colorbar_updated:
        bpy.context.scene.colorbar_min = -1
        bpy.context.scene.colorbar_max = 1
        bpy.context.scene.colorbar_title = "MEG"
    bpy.context.scene.colorbar_files = "BuPu-YlOrRd"
    bpy.context.scene.colorbar_y = 0.18
    bpy.context.scene.colorbar_text_y = -1.53
Example #2
0
def init(addon):
    if not bpy.data.objects.get('full_colorbar', None):
        print("No full_colorbar object, Can't load the colorbar panel")
        return
    ColorbarPanel.addon = addon
    colorbar_files_fol = mu.make_dir(
        op.join(mu.get_parent_fol(mu.get_user_fol()), 'color_maps'))
    colorbar_files_code_fol = op.join(mu.get_resources_dir(), 'color_maps')
    colorbar_files_template = op.join(colorbar_files_fol, '*.npy')
    colorbar_files_code_template = op.join(colorbar_files_code_fol, '*.npy')
    # colorbar_files_template = op.join(mu.file_fol(), 'color_maps', '*.npy')
    colorbar_files = glob.glob(colorbar_files_template)
    colorbar_code_files = glob.glob(colorbar_files_code_template)
    extra_files = list(
        set([mu.namebase_with_ext(f) for f in colorbar_code_files]) -
        set([mu.namebase_with_ext(f) for f in colorbar_files]))
    for extra_file in extra_files:
        print('Coping missing cb file: {}'.format(
            mu.namebase_with_ext(extra_file)))
        shutil.copyfile(
            op.join(colorbar_files_code_fol, extra_file),
            op.join(colorbar_files_fol, mu.namebase_with_ext(extra_file)))
    if len(colorbar_files) == 0:
        print("No colorbar files ({}), Can't load the colorbar panel".format(
            colorbar_files_template))
        return None
    colorbar_files = glob.glob(colorbar_files_template)
    files_names = [mu.namebase(fname)
                   for fname in colorbar_files]  # .replace('_', '-')
    ColorbarPanel.maps_names = files_names
    colorbar_items = [(c, c, '', ind) for ind, c in enumerate(files_names)]
    bpy.types.Scene.colorbar_files = bpy.props.EnumProperty(
        items=colorbar_items,
        update=colormap_update,
        description='Selects the colorbar color palette.\n\nCurrent palette')
    if not colorbar_values_are_locked():
        bpy.context.scene.colorbar_files = files_names[0]
    else:
        load_colormap()
    for space in mu.get_3d_spaces():
        if space.lock_object and space.lock_object.name == 'full_colorbar':
            space.show_only_render = True
    register()
    ColorbarPanel.init = True
    bpy.context.scene.show_cb_in_render = False
    mu.select_hierarchy('colorbar_camera', False, False)
    if not ColorbarPanel.colorbar_updated and not colorbar_values_are_locked():
        ColorbarPanel.should_not_lock_values = True
        # bpy.context.scene.colorbar_min = -1
        # bpy.context.scene.colorbar_max = 1
        # bpy.context.scene.colorbar_title = '     MEG'
        bpy.context.scene.colorbar_y = 0.18
        bpy.context.scene.colorbar_text_y = -1.53
        bpy.context.scene.colorbar_prec = 2
        ColorbarPanel.should_not_lock_values = False
Example #3
0
def init(addon):
    if not bpy.data.objects.get('full_colorbar', None):
        print("No full_colorbar object, Can't load the colorbar panel")
        return
    ColorbarPanel.addon = addon
    colorbar_files_template = op.join(mu.get_resources_dir(), 'color_maps',
                                      '*.npy')
    # colorbar_files_template = op.join(mu.file_fol(), 'color_maps', '*.npy')
    colorbar_files = glob.glob(colorbar_files_template)
    if len(colorbar_files) == 0:
        print("No colorbar files ({}), Can't load the colorbar panel".format(
            colorbar_files_template))
        return None
    files_names = [
        mu.namebase(fname).replace('_', '-') for fname in colorbar_files
    ]
    ColorbarPanel.maps_names = files_names
    colorbar_items = [(c, c, '', ind) for ind, c in enumerate(files_names)]
    bpy.types.Scene.colorbar_files = bpy.props.EnumProperty(
        items=colorbar_items,
        description="colormaps files",
        update=colormap_update)
    if not colorbar_values_are_locked():
        bpy.context.scene.colorbar_files = files_names[0]
    else:
        load_colormap()
    for space in mu.get_3d_spaces():
        if space.lock_object and space.lock_object.name == 'full_colorbar':
            space.show_only_render = True
    register()
    ColorbarPanel.init = True
    bpy.context.scene.show_cb_in_render = False
    mu.select_hierarchy('colorbar_camera', False, False)
    if not ColorbarPanel.colorbar_updated and not colorbar_values_are_locked():
        # bpy.context.scene.colorbar_min = -1
        # bpy.context.scene.colorbar_max = 1
        # bpy.context.scene.colorbar_title = '     MEG'
        bpy.context.scene.colorbar_y = 0.18
        bpy.context.scene.colorbar_text_y = -1.53
        bpy.context.scene.colorbar_prec = 2
    if not colorbar_values_are_locked():
        if 'fMRI' in bpy.context.scene.colorbar_title:
            bpy.context.scene.colorbar_files = 'PuBu-RdOrYl'
        else:
            bpy.context.scene.colorbar_files = 'BuPu-YlOrRd'