Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions PyReconstruct/modules/datatypes/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def createZtrace(
self,
obj_name : str,
cross_sectioned : bool = True,
z_points : list = [],
z_points : list = None,
ztrace_color : tuple = (0, 0, 0),
log_event=True
):
Expand All @@ -945,7 +945,16 @@ def createZtrace(
ztrace_color (tuple): color of ztrace to display in field
log_event (bool): True if event should be logged
"""
if not z_points: # append name with "_zlen" if creating from obj
# A fresh list per call: a shared mutable default would let the points
# generated for one object leak into the next from-object ztrace.
if z_points is None:
z_points = []

# Decide this once, before the from-object branch below fills z_points:
# the alignment choice at the end must not see the filled list.
from_object = not z_points

if from_object: # append name with "_zlen" if creating from obj
ztrace_name = f"{obj_name}_zlen"
else: # use tracing_trace name
ztrace_name = obj_name
Expand All @@ -956,7 +965,7 @@ def createZtrace(
del(self.ztraces[ztrace_name])
if log_event: self.addLog(ztrace_name, None, "Updated ztrace")

if not z_points: # generate points from already traced object if non provided
if from_object: # generate points from already traced object if non provided

## If create on midpoints, make one point per section

Expand Down Expand Up @@ -998,7 +1007,7 @@ def createZtrace(
)

## Assign alignement to ztrace
if not z_points: # use obj alignment
if from_object: # use obj alignment
alignment = self.getAttr(obj_name, "alignment")
else: # use current alignment
alignment = self.alignment
Expand Down
Loading