Skip to content

Commit 89120c2

Browse files
committed
Support material names containing -
This sanitizes material names in places where they need to be sanitized. Specifically, it fixes the issue for texture models in WPPF. Signed-off-by: Patrick Avery <[email protected]>
1 parent 3bb3f59 commit 89120c2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

hexrdgui/calibration/wppf_options_dialog.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@ def recursively_format_mat(mat, this_config, this_template):
13301330
texture_dict = tree_dict.setdefault('Texture', {})
13311331
for mat_name in self.textured_materials:
13321332
# Look for param names that match
1333-
prefix = f'{mat_name}_c_'
1333+
mat_name_sanitized = mat_name.replace('-', '_')
1334+
prefix = f'{mat_name_sanitized}_c_'
13341335
matching_names = [k for k in params if k.startswith(prefix)]
13351336
if not matching_names:
13361337
continue
@@ -1839,6 +1840,7 @@ def update_texture_model_gui(self):
18391840
self.ui.texture_ell_max.setValue(settings['ell_max'])
18401841

18411842
self.update_texture_model_enable_states()
1843+
self.update_texture_index_label()
18421844

18431845
def update_texture_model_enable_states(self):
18441846
# Determine whether we should disable the model texture
@@ -1976,7 +1978,7 @@ def polar_extent(self) -> list[float] | None:
19761978

19771979
@property
19781980
def varying_texture_params(self):
1979-
for mat_name in self.textured_materials:
1981+
for mat_name in self.textured_materials_sanitized:
19801982
prefix = f'{mat_name}_c_'
19811983
for param in self.params.values():
19821984
if param.name.startswith(prefix) and param.vary:
@@ -1989,7 +1991,10 @@ def varying_texture_and_non_texture_params(self):
19891991
if not self.varying_texture_params:
19901992
return False
19911993

1992-
prefixes = [f'{mat_name}_c_' for mat_name in self.textured_materials]
1994+
prefixes = [
1995+
f'{mat_name}_c_' for mat_name in
1996+
self.textured_materials_sanitized
1997+
]
19931998
for name, param in self.params.items():
19941999
if param.vary and not any(name.startswith(x) for x in prefixes):
19952000
return True
@@ -2228,6 +2233,10 @@ def textured_materials(self) -> list[str]:
22282233

22292234
return list(self.texture_model_kwargs)
22302235

2236+
@property
2237+
def textured_materials_sanitized(self) -> list[str]:
2238+
return [name.replace('-', '_') for name in self.textured_materials]
2239+
22312240
@property
22322241
def texture_model_kwargs(self) -> dict[str]:
22332242
return self.texture_settings['model_kwargs']

0 commit comments

Comments
 (0)