Skip to content

Commit

Permalink
sample index in project
Browse files Browse the repository at this point in the history
  • Loading branch information
andped10 committed Nov 4, 2024
1 parent 741c14a commit 2b91109
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/easyreflectometry/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(self):
self._q_max: float = None
self._q_resolution: int = None
self._current_model_index: int = None
self._current_assembly_index: int = None
self._current_layer_index: int = None

# Project flags
self._created = False
Expand Down Expand Up @@ -109,7 +111,33 @@ def current_model_index(self) -> Optional[int]:
def current_model_index(self, value: int) -> None:
if value < 0 or value >= len(self._models):
raise ValueError(f'Index {value} out of range')
self._current_model_index = value
if self._current_model_index != value:
self._current_model_index = value
self._current_assembly_index = 0
self._current_layer_index = 0

@property
def current_assembly_index(self) -> Optional[int]:
return self._current_assembly_index

@current_model_index.setter
def current_model_index(self, value: int) -> None:
if value < 0 or value >= len(self._models[self._current_model_index]):
raise ValueError(f'Index {value} out of range')
if self._current_assembly_index != value:
self._current_assembly_index = value
self._current_layer_index = 0

@property
def current_layer_index(self) -> Optional[int]:
return self._current_layer_index

@current_model_index.setter
def current_model_index(self, value: int) -> None:
if value < 0 or value >= len(self._models[self._current_model_index][self._current_assembly_index]):
raise ValueError(f'Index {value} out of range')
if self._current_layer_index != value:
self._current_layer_index = value

@property
def created(self) -> bool:
Expand Down

0 comments on commit 2b91109

Please sign in to comment.