-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate out all UI / add-on related code (#755)
* initial refactor moving everything UI to it's own module * more refactoring * more refactoring * more refactoring * fix repeated tests of test_micrograph_loading * re-export template * fix doc building with assets * fix final asset references * fix add menu eppearing * fix reloading trajectories
- Loading branch information
1 parent
4840da3
commit 0276802
Showing
44 changed files
with
1,877 additions
and
1,940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pathlib import Path | ||
|
||
from .template import install, uninstall | ||
from . import data | ||
|
||
ASSET_DIR = Path(__file__).resolve().parent | ||
ADDON_DIR = ASSET_DIR.parent | ||
MN_DATA_FILE = ASSET_DIR / "MN_data_file_4.2.blend" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import shutil | ||
from pathlib import Path | ||
import bpy | ||
|
||
|
||
SUBFOLDER = "Molecular Nodes" | ||
|
||
|
||
def is_installed(): | ||
base_path = Path( | ||
bpy.utils.user_resource( | ||
"SCRIPTS", path=str(Path("startup") / "bl_app_templates_user"), create=False | ||
) | ||
) | ||
molecular_nodes_path = base_path / "Molecular Nodes" | ||
return molecular_nodes_path.exists() | ||
|
||
|
||
def install(): | ||
base_path = Path( | ||
bpy.utils.user_resource( | ||
"SCRIPTS", path=str(Path("startup") / "bl_app_templates_user"), create=True | ||
) | ||
) | ||
|
||
base_path.mkdir(parents=True, exist_ok=True) | ||
path_app_templates = base_path / SUBFOLDER | ||
path_app_templates.mkdir(parents=True, exist_ok=True) | ||
startup_file = Path(__file__).parent / "template/startup.blend" | ||
shutil.copy(startup_file, path_app_templates) | ||
bpy.utils.refresh_script_paths() | ||
|
||
|
||
def uninstall(): | ||
for folder in bpy.utils.app_template_paths(): | ||
path = Path(folder).absolute() / SUBFOLDER | ||
if "Molecular Nodes" not in str(path): | ||
continue | ||
|
||
if path.exists(): | ||
shutil.rmtree(path) | ||
bpy.utils.refresh_script_paths() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,9 @@ | ||
from . import molecule, trajectory | ||
from .base import EntityType, MolecularEntity | ||
from .density import MN_OT_Import_Map | ||
from .ensemble import CellPack, Ensemble, StarFile | ||
from .ensemble.ui import MN_OT_Import_Cell_Pack, MN_OT_Import_Star_File | ||
from .molecule import BCIF, CIF, PDB, SDF, Molecule | ||
from .molecule.pdb import PDB | ||
from .molecule.pdbx import BCIF, CIF | ||
from .molecule.sdf import SDF | ||
from .molecule.ui import fetch, load_local, parse | ||
from .molecule.io import fetch, load_local, parse | ||
from .trajectory import OXDNA, Trajectory | ||
from .trajectory.dna import MN_OT_Import_OxDNA_Trajectory | ||
|
||
CLASSES = ( | ||
[ | ||
MN_OT_Import_Cell_Pack, | ||
MN_OT_Import_Map, | ||
MN_OT_Import_OxDNA_Trajectory, | ||
MN_OT_Import_Star_File, | ||
] | ||
+ trajectory.CLASSES | ||
+ molecule.CLASSES | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .ui import MN_OT_Import_Map, load | ||
from .io import load | ||
from .mrc import MRC | ||
from .base import Density |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pathlib import Path | ||
from .mrc import MRC | ||
|
||
|
||
def load( | ||
file_path: str, | ||
name: str = "NewDensity", | ||
invert: bool = False, | ||
setup_nodes: bool = True, | ||
style: str = "density_surface", | ||
center: bool = False, | ||
overwrite: bool = False, | ||
): | ||
density = MRC( | ||
file_path=file_path, center=center, invert=invert, overwrite=overwrite | ||
) | ||
density.create_object( | ||
name=Path(file_path).name, setup_nodes=setup_nodes, style=style | ||
) | ||
return density |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .base import Ensemble | ||
from .cellpack import CellPack | ||
from .star import StarFile | ||
from .ui import load_cellpack, load_starfile | ||
from .io import load_cellpack, load_starfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from .star import StarFile | ||
from pathlib import Path | ||
from .cellpack import CellPack | ||
|
||
|
||
def load_starfile(file_path, node_setup=True, world_scale=0.01): | ||
ensemble = StarFile.from_starfile(file_path) | ||
ensemble.create_object( | ||
name=Path(file_path).name, node_setup=node_setup, world_scale=world_scale | ||
) | ||
|
||
return ensemble | ||
|
||
|
||
def load_cellpack( | ||
file_path, | ||
name="NewCellPackModel", | ||
node_setup=True, | ||
world_scale=0.01, | ||
fraction: float = 1, | ||
): | ||
ensemble = CellPack(file_path) | ||
ensemble.create_object( | ||
name=name, node_setup=node_setup, world_scale=world_scale, fraction=fraction | ||
) | ||
|
||
return ensemble |
Oops, something went wrong.