Skip to content

Commit

Permalink
added way to preserve state when recreating shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmockoocy committed Oct 23, 2024
1 parent 7f17a3e commit 567bc52
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions mxcubecore/HardwareObjects/SampleView.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def add_shape(self, shape):
shape.shapes_hw_object = self

def add_shape_from_mpos(
self, mpos_list, screen_coord, t, user_state: ShapeState = "SAVED"
self, mpos_list, screen_coord, t, state: ShapeState = "SAVED", user_state: ShapeState = "SAVED"
):
"""
Adds a shape of type <t>, with motor positions from mpos_list and
Expand All @@ -203,15 +203,15 @@ def add_shape_from_mpos(

if _cls:
shape = _cls(mpos_list, screen_coord)
# In case the shape is being recreated, we need to restore it.
shape.state = user_state
# In case the shape is being recreated, we need to restore it's state.
shape.state = state
shape.user_state = user_state

self.add_shape(shape)

return shape

def add_shape_from_refs(self, refs, t, user_state: ShapeState = "SAVED"):
def add_shape_from_refs(self, refs, t, state: ShapeState = "SAVED", user_state: ShapeState = "SAVED"):
"""
Adds a shape of type <t>, taking motor positions and screen positions
from reference points in refs.
Expand All @@ -226,7 +226,7 @@ def add_shape_from_refs(self, refs, t, user_state: ShapeState = "SAVED"):
mpos = [self.get_shape(refid).mpos() for refid in refs]
spos_list = [self.get_shape(refid).screen_coord for refid in refs]
spos = reduce((lambda x, y: tuple(x) + tuple(y)), spos_list, ())
shape = self.add_shape_from_mpos(mpos, spos, t, user_state)
shape = self.add_shape_from_mpos(mpos, spos, t, state, user_state)
shape.refs = refs

return shape
Expand Down
2 changes: 1 addition & 1 deletion mxcubecore/HardwareObjects/abstract/AbstractSampleView.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def add_shape(self, shape):

@abc.abstractmethod
def add_shape_from_mpos(
self, mpos_list, screen_cord, _type, user_state: ShapeState = "SAVED"
self, mpos_list, screen_cord, _type, state: ShapeState = "SAVED", user_state: ShapeState = "SAVED"
):
"""Add a shape of type <t>, with motor positions from mpos_list and
screen position screen_coord.
Expand Down

0 comments on commit 567bc52

Please sign in to comment.