def drawunit_basic_blender(self, layout, nb_ob): mat = bpy.data.materials[nb_ob.name] row = layout.row(align=True) row.prop(mat, "diffuse_color", text="") row.prop(mat, "alpha", text="Transparency") try: pg_sc1 = bpy.types.LabelProperties pg_sc2 = bpy.types.BorderProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("LabelProperties") pg_sc2 = pg.bl_rna_get_subclass_py("BorderProperties") if isinstance(nb_ob, (pg_sc1, pg_sc2)): row.operator("nb.revert_label", icon='BACK', text="")
def execute(self, context): scn = bpy.context.scene nb = scn.nb split_path = self.data_path.split('.') nb_ob = scn.path_resolve('.'.join(split_path[:2])) nb_ov = scn.path_resolve('.'.join(split_path[:3])) item = scn.path_resolve(self.data_path) try: pg_sc1 = bpy.types.VoxelvolumeProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("VoxelvolumeProperties") if isinstance(nb_ob, pg_sc1): tex = bpy.data.textures[nb_ov.name] el_idx = nb_ov.labels.find(item.name) + 1 el = tex.color_ramp.elements[el_idx] el.color = item.colour else: mat = bpy.data.materials[item.name] rgb = mat.node_tree.nodes["RGB"] rgb.outputs[0].default_value = item.colour trans = mat.node_tree.nodes["Transparency"] trans.outputs[0].default_value = item.colour[3] return {"FINISHED"}
def drawunit_tri_material(self, layout, nb, nb_ob): """Change the material of a NeuroBlender object. ### Tracts and surfaces: - colourpicker - transparency A colour and transparency can be chosen directly from the NeuroBlender panel (many more options in the Properties window under the Materials tab). In CYCLES render mode, a default nodal material is created that mixes a diffuse and glossy shader. Roughness and mixing factors are available in NeuroBlender Advanced mode. In CYCLES render mode, a directional colour mode is available. For tracts, this colours the streamlines red-green-blue for tangent along the X-Y-Z (assumed RL-AP-SI) direction. For surfaces this colours the faces according to the normal pointing along X-Y-Z in teh same colour scheme. ### Voxelvolumes: For convenience, the most important texture properties are displayed in the NeuroBlender Base panel. - The interpolation method used for the voxel data [ADVANCED only]. - Intensity, contrast and saturation [ADVANCED only]. - Use Colorramp switch [ADVANCED only]. - Predefined colourmaps can be loaded and saved as Colourmap Preset (a colourmap management tool is available in the NeuroBlender Settings panel). On loading the colourmap, you can either choose to retain the range of the colour ramp, or reset the range to [0, 1]. - either a colourpicker or a colour ramp (default). ### A note on colour ramps and datarange: NeuroBlender surface and volume textures are saved in .png format and when loaded expanded to the range [0, 1]. The original datarange is saved when writing the textures. The corresponding values of the colour stops in the colour ramp are shown as a list of values beneath the ramp [ADVANCED only]. The full min-max datarange is shown when expanding the 'Info' triangle [ADVANCED only]. """ try: pg_sc = bpy.types.VoxelvolumeProperties except AttributeError: pg_sc = pg.bl_rna_get_subclass_py("VoxelvolumeProperties") if isinstance(nb_ob, pg_sc): self.drawunit_rendertype(layout, nb_ob) tex = bpy.data.textures[nb_ob.name] self.drawunit_texture(layout, tex, nb_ob) else: self.drawunit_material(layout, nb_ob)
def draw_advanced_L3(self, layout, data, item, index): row = layout.row(align=True) try: pg_sc1 = bpy.types.TractProperties pg_sc2 = bpy.types.SurfaceProperties pg_sc3 = bpy.types.VoxelvolumeProperties pg_sc4 = bpy.types.ScalarGroupProperties pg_sc5 = bpy.types.LabelGroupProperties pg_sc6 = bpy.types.BorderGroupProperties pg_sc7 = bpy.types.ScalarProperties pg_sc8 = bpy.types.LabelProperties pg_sc9 = bpy.types.BorderProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("TractProperties") pg_sc2 = pg.bl_rna_get_subclass_py("SurfaceProperties") pg_sc3 = pg.bl_rna_get_subclass_py("VoxelvolumeProperties") pg_sc4 = pg.bl_rna_get_subclass_py("ScalarGroupProperties") pg_sc5 = pg.bl_rna_get_subclass_py("LabelGroupProperties") pg_sc6 = pg.bl_rna_get_subclass_py("BorderGroupProperties") pg_sc7 = pg.bl_rna_get_subclass_py("ScalarProperties") pg_sc8 = pg.bl_rna_get_subclass_py("LabelProperties") pg_sc9 = pg.bl_rna_get_subclass_py("BorderProperties") col = row.column() col.alignment = "RIGHT" row1 = col.row(align=True) row1.alignment = "RIGHT" row1.enabled = False if not isinstance(data, pg_sc6): row1.prop(item, "value", text="", emboss=False) row1.prop(item, "colour", text="") # row1.prop(item, "colour_custom", text="") if isinstance(item, (pg_sc8, pg_sc9)): row.operator('nb.revert_label', icon='BACK', text="").data_path = item.path_from_id() if (isinstance(item, (pg_sc1, pg_sc2)) or (isinstance(item, pg_sc5) and not isinstance(data, pg_sc3))): row.operator('nb.attach_neurons', icon='CURVE_PATH', text="").data_path = item.path_from_id() col = row.column() col.alignment = "RIGHT" col.active = item.is_rendered col.prop(item, "is_rendered", text="", emboss=False, translate=False, icon='SCENE')
def drawunit_carver(self, layout, nb_ob): row = layout.row() row.operator("nb.import_carvers", icon='ZOOMIN', text="") row.prop(nb_ob, "carvers_enum", text="") row.operator("nb.nblist_ops", icon='ZOOMOUT', text="").action = 'REMOVE_CV' try: pg_sc = bpy.types.TractProperties except AttributeError: pg_sc = pg.bl_rna_get_subclass_py("TractProperties") row.enabled = not isinstance(nb_ob, pg_sc)
def get_items(self, context): scn = context.scene nb = scn.nb try: pg_sc1 = bpy.types.ScalarGroupProperties pg_sc2 = bpy.types.ScalarProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("ScalarGroupProperties") pg_sc2 = pg.bl_rna_get_subclass_py("ScalarProperties") split_path = self.data_path.split('.') group = scn.path_resolve('.'.join(split_path[:3])) item = scn.path_resolve(self.data_path) if isinstance(item, pg_sc1): items = group.scalars elif isinstance(item, pg_sc2): items = [item] else: items = [] return items
def drawunit_basic_cycles(self, layout, nb_ob): scn = bpy.context.scene nb = scn.nb mat = bpy.data.materials[nb_ob.name] colour = mat.node_tree.nodes["RGB"].outputs[0] trans = mat.node_tree.nodes["Transparency"].outputs[0] row = layout.row(align=True) row.prop(colour, "default_value", text="") row.prop(trans, "default_value", text="Transparency") try: pg_sc1 = bpy.types.LabelProperties pg_sc2 = bpy.types.BorderProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("LabelProperties") pg_sc2 = pg.bl_rna_get_subclass_py("BorderProperties") if isinstance(nb_ob, (pg_sc1, pg_sc2)): row.operator("nb.revert_label", icon='BACK', text="") if nb.settingprops.advanced: self.drawunit_basic_cycles_mix(layout, mat)
def draw_advanced_TS(self, layout, data, item, index): scn = bpy.context.scene row = layout.row(align=True) row.prop(item, "name", text="", emboss=False, translate=False, icon=item.icon) try: pg_sc1 = bpy.types.SurfaceProperties except AttributeError: pg_sc1 = pg.bl_rna_get_subclass_py("SurfaceProperties") split_path = item.path_from_id().split('.') nb_ob = scn.path_resolve('.'.join(split_path[:2])) if isinstance(nb_ob, pg_sc1): self.draw_surfops(row, item, is_unwrapped=True)
def drawunit_addopt(self, layout, nb, uilistlevel, data, obtype): if uilistlevel == "AN": operator = 'nb.animate_' + nb.animationtype layout.operator( operator, icon='ZOOMIN', text="" ) if nb.animationtype == 'camerapath': try: nb.presets[nb.index_presets] except IndexError: layout.enabled = False else: layout.enabled = True else: layout.enabled = True return if uilistlevel == "L2": try: pg_sc = bpy.types.VoxelvolumeProperties except AttributeError: pg_sc = pg.bl_rna_get_subclass_py("VoxelvolumeProperties") if isinstance(data, pg_sc): operator = "nb.import_voxelvolumes" # TODO: move vvol overlay func to import_overlays.py else: operator = "nb.import_overlays" else: operator = "nb.import_" + obtype layout.operator( operator, icon='ZOOMIN', text="" ).parentpath = data.path_from_id()