Skip to content

Commit

Permalink
Merge pull request #399 from BradyAJohnston/dev-panel-node-setup
Browse files Browse the repository at this point in the history
add option to disable node tree on import
  • Loading branch information
BradyAJohnston authored Jan 5, 2024
2 parents 65229a9 + 3d3856a commit c62d3d6
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 20 deletions.
13 changes: 6 additions & 7 deletions molecularnodes/io/density.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import os
from ..blender import nodes, coll

bpy.types.Scene.MN_import_density_nodes = bpy.props.BoolProperty(
name = "Setup Nodes",
description = "Creating starting node tree for imported map.",
default = True
)
bpy.types.Scene.MN_import_density_invert = bpy.props.BoolProperty(
name = "Invert Data",
description = "Invert the values in the map. Low becomes high, high becomes low.",
Expand Down Expand Up @@ -304,9 +299,13 @@ def panel(layout, scene):

layout.separator()
layout.label(text = "Options", icon = "MODIFIER")
layout.prop(scene, "MN_import_density_style")

row = layout.row()
row.prop(scene, 'MN_import_node_setup', text = "")
col = row.column()
col.prop(scene, "MN_import_density_style")
col.enabled = scene.MN_import_node_setup

grid = layout.grid_flow()
grid.prop(scene, 'MN_import_density_nodes')
grid.prop(scene, 'MN_import_density_invert')
grid.prop(scene, 'MN_import_density_center')
5 changes: 5 additions & 0 deletions molecularnodes/io/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
name = 'Build Assembly',
default = False
)
bpy.types.Scene.MN_import_node_setup = bpy.props.BoolProperty(
name = "Setup Nodes",
default = True,
description = 'Create and set up a Geometry Nodes tree on import.'
)

class MolecularNodesObjectProperties(bpy.types.PropertyGroup):
subframes: bpy.props.IntProperty(
Expand Down
8 changes: 6 additions & 2 deletions molecularnodes/io/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def execute(self, context):
del_solvent=scene.MN_import_del_solvent,
style=scene.MN_import_style,
build_assembly=scene.MN_import_build_assembly,
setup_nodes=True
setup_nodes=scene.MN_import_node_setup

)

Expand All @@ -166,7 +166,11 @@ def panel(layout, scene):
row_import.prop(scene, 'MN_import_local_path')
layout.separator()
layout.label(text = "Options", icon = "MODIFIER")
layout.prop(scene, "MN_import_style")
row = layout.row()
row.prop(scene, 'MN_import_node_setup', text = "")
col = row.column()
col.prop(scene, "MN_import_style")
col.enabled = scene.MN_import_node_setup
grid = layout.grid_flow()
grid.prop(scene, 'MN_import_build_assembly')
grid.prop(scene, 'MN_import_centre', icon_value=0)
Expand Down
6 changes: 5 additions & 1 deletion molecularnodes/io/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ def panel(layout, scene):

layout.separator()
layout.label(text = "Options", icon = "MODIFIER")
layout.prop(scene, "MN_import_style")
row = layout.row()
row.prop(scene, 'MN_import_node_setup', text = "")
col = row.column()
col.prop(scene, "MN_import_style")
col.enabled = scene.MN_import_node_setup
layout.prop(scene, 'MN_md_selection')
row_frame = layout.row(heading = "Frames", align = True)
row_frame.prop(scene, 'MN_md_in_memory')
Expand Down
22 changes: 13 additions & 9 deletions molecularnodes/io/mda.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ def in_memory(
selection: str = "all",
name: str = "atoms",
custom_selections: Dict[str, str] = {},
node_setup : bool = True
):
"""
Display an `MDAnalysis.Universe` or
Expand All @@ -592,6 +593,8 @@ def in_memory(
{'name' : 'selection string'}
(default: {}).
Uses MDAnalysis selection syntax.
node_setup : bool
Whether to add the node tree for the atomgroup. Default: True
"""
if isinstance(atoms, mda.Universe):
atoms = atoms.select_atoms(selection)
Expand All @@ -602,7 +605,7 @@ def in_memory(
ag=atoms,
name=name,
style=style,
add_node_tree=False,
node_setup=False,
return_object=True,
)

Expand Down Expand Up @@ -643,11 +646,12 @@ def in_memory(
coll_frames.name
].exclude = True

nodes.create_starting_node_tree(
object=mol_object,
coll_frames=coll_frames,
style=style,
)
if node_setup:
nodes.create_starting_node_tree(
object=mol_object,
coll_frames=coll_frames,
style=style,
)

bpy.context.view_layer.objects.active = mol_object

Expand Down Expand Up @@ -699,7 +703,7 @@ def _process_atomgroup(
subframes = 0,
name="atoms",
style="vdw",
add_node_tree=True,
node_setup=True,
return_object=False,
):
"""
Expand All @@ -717,7 +721,7 @@ def _process_atomgroup(
The name of the atomgroup. Default: 'atoms'
style : str
The style of the atoms. Default: 'vdw'
add_node_tree : bool
node_setup : bool
Whether to add the node tree for the atomgroup. Default: True
return_object : bool
Whether to return the blender object or not. Default: False
Expand Down Expand Up @@ -766,7 +770,7 @@ def _process_atomgroup(

# for old import, the node tree is added all at once
# in the end of in_memory
if add_node_tree:
if node_setup:
nodes.create_starting_node_tree(
object=mol_object,
style=style,
Expand Down
9 changes: 8 additions & 1 deletion molecularnodes/io/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
default = True
)


def load(
pdb_code,
style = 'spheres',
Expand Down Expand Up @@ -133,6 +134,7 @@ def execute(self, context):
del_solvent=scene.MN_import_del_solvent,
style=scene.MN_import_style,
cache_dir=cache_dir,
setup_nodes=scene.MN_import_node_setup,
build_assembly = scene.MN_import_build_assembly
)

Expand All @@ -151,7 +153,12 @@ def panel(layout, scene):
layout.separator()
layout.label(text = "Options", icon = "MODIFIER")
options = layout.column(align = True)
options.prop(scene, "MN_import_style")
row = options.row()
row.prop(scene, 'MN_import_node_setup', text = "")
col = row.column()
col.prop(scene, "MN_import_style")
col.enabled = scene.MN_import_node_setup

options.separator()
row = options.row()
row.prop(scene, 'MN_cache', text="")
Expand Down

0 comments on commit c62d3d6

Please sign in to comment.