Skip to content

Commit 1ea839b

Browse files
committed
update shapeplot
1 parent 1ee95eb commit 1ea839b

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

openglider/plots/glider/cell.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ def draw_straight_line(
461461
cut_front_result: CutResult,
462462
cut_back_result: CutResult
463463
) -> euklid.vector.PolyLine2D | None:
464-
logger.warning(f"straight line {y} {start} {end}")
465464
if start > max(self.panel.cut_back.x_left, self.panel.cut_back.x_right):
466465
return None
467466
if end < min(self.panel.cut_front.x_left, self.panel.cut_front.x_right):

openglider/plots/sketches/shapeplot.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def _get_shapes(self, config: ShapePlotConfig | None = None, force: bool=False)
112112

113113
def redraw(self, config: ShapePlotConfig, force: bool=False) -> Layout:
114114
if config != self.config or force:
115+
if force:
116+
self._get_shapes(force=True)
115117
self.config = config
116118
self.drawing = Layout()
117119

@@ -225,6 +227,40 @@ def draw_grid(self, num: int=11, left: bool=False) -> ShapePlot:
225227
self.draw_cells(left=left)
226228
return self
227229

230+
def draw_en_marks(self):
231+
part = PlotPart()
232+
shapes = self._get_shapes()
233+
234+
front, back = shapes[1].ribs[0]
235+
236+
dist = abs(front[1]-back[1])
237+
238+
def baseline(pct):
239+
return euklid.vector.PolyLine2D(
240+
[shapes[0].get_point(rib, pct) for rib in self._get_rib_range(True)][::-1] +
241+
[shapes[1].get_point(rib, pct) for rib in self._get_rib_range(False)]
242+
)
243+
244+
collapse_side_50 = euklid.vector.PolyLine2D([
245+
euklid.vector.Vector2D((0, front[1])),
246+
euklid.vector.Vector2D((-dist, back[1]))
247+
])
248+
collapse_side_75 = euklid.vector.PolyLine2D([
249+
euklid.vector.Vector2D((0, back[1])),
250+
euklid.vector.Vector2D((dist, front[1]))
251+
])
252+
253+
part.layers["marks"] += [
254+
collapse_side_50,
255+
collapse_side_75,
256+
baseline(0.25),
257+
baseline(0.5)
258+
]
259+
260+
self.drawing.parts.append(part)
261+
262+
263+
228264
def _get_attachment_point_positions(self, left: bool=False) -> dict[str, euklid.vector.Vector2D]:
229265

230266
points = {}

0 commit comments

Comments
 (0)