Skip to content

Commit 2135945

Browse files
committed
bugfix: as described in (#235) and another bug that deleted the comments field when Redo is applied
1 parent 83c793e commit 2135945

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

optiland/optic/optic_updater.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def set_thickness(self, value, surface_number):
7777
positions = positions - positions[1] # force surface 1 to be at zero
7878
for k, surface in enumerate(self.optic.surface_group.surfaces):
7979
surface.geometry.cs.z = be.array(positions[k])
80+
if surface_number < len(self.optic.surface_group.surfaces):
81+
self.optic.surface_group.surfaces[surface_number].thickness = value
8082

8183
def set_index(self, value: float, surface_number: int) -> None:
8284
"""Set the index of refraction of a surface.

optiland/surfaces/object_surface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def to_dict(self):
9999
"type": self.__class__.__name__,
100100
"geometry": self.geometry.to_dict(),
101101
"material_post": self.material_post.to_dict(),
102+
"comment": self.comment,
102103
}
103104

104105
@classmethod
@@ -114,4 +115,5 @@ def _from_dict(cls, data):
114115
"""
115116
geometry = BaseGeometry.from_dict(data["geometry"])
116117
material_post = BaseMaterial.from_dict(data["material_post"])
117-
return cls(geometry, material_post)
118+
comment = data.get("comment", "")
119+
return cls(geometry, material_post, comment=comment)

optiland/surfaces/paraxial_surface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def to_dict(self):
163163
"coating": self.coating.to_dict() if self.coating else None,
164164
"bsdf": self.bsdf.to_dict() if self.bsdf else None,
165165
"is_reflective": self.is_reflective,
166+
"comment": self.comment,
166167
}
167168

168169
@classmethod
@@ -196,4 +197,5 @@ def _from_dict(cls, data):
196197
coating,
197198
bsdf,
198199
data["is_reflective"],
200+
comment=data.get("comment", ""),
199201
)

optiland/surfaces/standard_surface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ def to_dict(self):
289289
"coating": self.coating.to_dict() if self.coating else None,
290290
"bsdf": self.bsdf.to_dict() if self.bsdf else None,
291291
"is_reflective": self.is_reflective,
292+
"comment": self.comment,
292293
}
293294

294295
@classmethod
@@ -341,4 +342,5 @@ def _from_dict(cls, data):
341342
coating,
342343
bsdf,
343344
data["is_reflective"],
345+
comment=data.get("comment", ""),
344346
)

optiland_gui/optiland_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def add_surface(self, index: int = -1):
623623
params = {
624624
"surface_type": "standard",
625625
"radius": float("inf"),
626-
"thickness": 5.0,
626+
"thickness": 0.0,
627627
"material": "Air",
628628
"comment": "New Surface",
629629
"index": optic_insert_idx,

0 commit comments

Comments
 (0)