Skip to content

Commit 930888b

Browse files
committed
fix unwrap / shape
1 parent cf1f005 commit 930888b

File tree

8 files changed

+67
-45
lines changed

8 files changed

+67
-45
lines changed

openglider/glider/parametric/glider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_geomentry_table(self) -> Table:
7979
for rib_no, p in enumerate(self.shape.baseline):
8080
table[1+rib_no, 3] = p[0]
8181
table[1+rib_no, 4] = p[1]
82-
table[1+rib_no, 5] = self.shape.baseline_pos
82+
table[1+rib_no, 5] = self.config.baseline_pct
8383

8484
last_angle = 0.
8585
for cell_no, angle in enumerate(self.get_arc_angles()):

openglider/glider/parametric/table/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def get_rib_sheet(self) -> Table:
9797
table.append_right(self.rib_modifiers.table)
9898
table.append_right(self.material_ribs.table)
9999

100-
for i in range(1, table.num_rows+1):
101-
table[i, 0] = str(i)
100+
for i in range(2, table.num_rows+1):
101+
table[i, 0] = f"rib {i-1}"
102102

103103
return table
104104

@@ -116,8 +116,8 @@ def get_cell_sheet(self) -> Table:
116116
table.append_right(self.attachment_points_cell.table)
117117
table.append_right(self.ballooning_modifiers.table)
118118

119-
for i in range(1, table.num_rows+1):
120-
table[i, 0] = str(i)
119+
for i in range(2, table.num_rows+1):
120+
table[i, 0] = f"cell {i-1}"
121121

122122
return table
123123

openglider/gui/wizzards/input/curves.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from openglider.utils.table import Table
2222

2323
from openglider.gui.app.main_window import MainWindow
24-
from openglider.vector.unit import Angle, Length, Percentage, Quantity
24+
from openglider.vector.unit import Angle, Length, Percentage
2525

2626
logger = logging.getLogger(__name__)
2727
# TODO: Show & change data: Area, Aspect ratio, Span, Tip Chord, Tip center
@@ -256,7 +256,10 @@ def add_curve(self) -> None:
256256
p1 = euklid.vector.Vector2D([1., 0.5])
257257
p2 = euklid.vector.Vector2D([2., 0.5])
258258
p3 = euklid.vector.Vector2D([self.shape.rib_no-1, 0.5])
259-
self.curve_list.add("unnamed", ShapeBSplineCurve([p1, p2, p3], shape=self.shape))
259+
self.curve_list.add(
260+
"unnamed",
261+
ShapeBSplineCurve([p1, p2, p3], shape=self.shape) # type: ignore
262+
)
260263
self.curve_list_selector.render()
261264
self.selection_changed()
262265

openglider/gui/wizzards/input/shape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ def normalize_span(self) -> bool:
284284
return self.input_scale.currentIndex() == 2
285285

286286
def update_zrot(self, value: bool=False) -> None:
287-
self.zrot = not self.zrot
288-
self.input_zrot.setChecked(self.zrot)
287+
self.settings.zrot = not self.settings.zrot
288+
self.input_zrot.setChecked(self.settings.zrot)
289289
self.changed.emit()
290290

291291
def update_shape(self, shape: ParametricShape) -> None:

openglider/plots/patterns.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import euklid
44
import string
55
import subprocess
6-
from typing import Any
6+
from typing import Any, Iterable
77
from pathlib import Path
88

99
import openglider.glider
@@ -206,7 +206,7 @@ def get_name(position: DiagonalSide, rib: Rib) -> str:
206206

207207
return f"{name}{layers_between[name]}"
208208

209-
def rename_straps(straps: list[DiagonalRib], prefix: str = ""):
209+
def rename_straps(straps: Iterable[DiagonalRib], prefix: str = "") -> None:
210210
straps = list(straps)
211211
straps.sort(key=lambda strap: abs(strap.get_average_x()))
212212
for strap in straps:

openglider/plots/sketches/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def get_all_plots(project: GliderProject) -> dict[str, ShapePlot]:
1414
design_lower.draw_cells()
1515
design_lower.draw_cells(left=True)
1616

17-
lineplan = LinePlan(project) #.draw_shape().draw_attachment_points()
17+
lineplan = LinePlan(project)
1818
lineplan.draw_cells()
1919
lineplan.draw_cells(left=True)
2020
lineplan.draw_attachment_points(add_text=False)

openglider/plots/sketches/shapeplot.py

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class ShapePlot:
7272
attachment_point_mark = marks.Cross(name="attachment_point", rotation=np.pi/4)
7373

7474
config: ShapePlotConfig | None = None
75+
7576
shapes: tuple[Shape, Shape] | None = None
77+
shapes_rot: tuple[Shape, Shape] | None = None
7678

7779
def __init__(self, project: GliderProject, drawing: Layout | None=None):
7880
super().__init__()
@@ -84,37 +86,46 @@ def __init__(self, project: GliderProject, drawing: Layout | None=None):
8486
self.reference_area = self.glider_2d.shape.area
8587
self.reference_span = self.glider_2d.shape.span
8688

87-
def _get_shapes(self, config: ShapePlotConfig, force: bool=False) -> tuple[Shape, Shape]:
88-
if force or self.config is None or self.shapes is None or config.apply_zrot != self.config.apply_zrot:
89-
if config.apply_zrot:
90-
zrot = [rib.zrot for rib in self.glider_3d.ribs]
89+
def _get_shapes(self, config: ShapePlotConfig | None = None, force: bool=False) -> tuple[Shape, Shape]:
90+
if config is None:
91+
if self.config is not None:
92+
config = self.config
9193
else:
92-
zrot = None
93-
shape_r = self.glider_2d.shape.get_half_shape(zrot=zrot)
94-
shape_l = shape_r.copy().scale(x=-1)
95-
self.shapes = (shape_r, shape_l)
94+
config = ShapePlotConfig()
95+
96+
if config.apply_zrot:
97+
if force or self.shapes_rot is None:
98+
zrot = [rib.zrot for rib in self.glider_3d.ribs]
99+
shape_r = self.glider_2d.shape.get_half_shape(zrot=zrot)
100+
shape_l = shape_r.copy().scale(x=-1)
101+
self.shapes_rot = (shape_r, shape_l)
102+
103+
return self.shapes_rot
96104

97-
return self.shapes
105+
else:
106+
if force or self.shapes is None:
107+
shape_r = self.glider_2d.shape.get_half_shape(zrot=None)
108+
shape_l = shape_r.copy().scale(x=-1)
109+
self.shapes = (shape_r, shape_l)
98110

111+
return self.shapes
99112

100113
def redraw(self, config: ShapePlotConfig, force: bool=False) -> Layout:
101-
shapes = self._get_shapes(config, force)
102-
103114
if config != self.config or force:
115+
self.config = config
104116
self.drawing = Layout()
105117

106118
for layer_name, show_layer in config.view_layers().items():
107119
if show_layer:
108120
f = getattr(self, f"draw_{layer_name}")
109-
f(shapes, left=True)
110-
f(shapes, left=False)
121+
f(left=True)
122+
f(left=False)
111123

112124
if config.scale_area:
113125
self.drawing.scale(math.sqrt(config.scale_area/self.reference_area))
114126
elif config.scale_span:
115127
self.drawing.scale(config.scale_span/self.reference_span)
116128

117-
self.config = config
118129

119130
return self.drawing
120131

@@ -140,13 +151,14 @@ def _get_cell_range(self, left_side: bool) -> range:
140151

141152
return range(start, end)
142153

143-
def draw_design_lower(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlot:
144-
return self.draw_design(shapes, True, left)
154+
def draw_design_lower(self, left: bool=False) -> ShapePlot:
155+
return self.draw_design(True, left)
145156

146-
def draw_design_upper(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlot:
147-
return self.draw_design(shapes, False, left)
157+
def draw_design_upper(self, left: bool=False) -> ShapePlot:
158+
return self.draw_design(False, left)
148159

149-
def draw_design(self, shapes: tuple[Shape, Shape], lower: bool=True, left: bool=False) -> ShapePlot:
160+
def draw_design(self, lower: bool=True, left: bool=False) -> ShapePlot:
161+
shapes = self._get_shapes()
150162
shape = shapes[left]
151163

152164
panels = self.glider_2d.get_panels()
@@ -191,30 +203,32 @@ def get_cut_line(cut: PanelCut) -> euklid.vector.PolyLine2D:
191203

192204
return self
193205

194-
def draw_baseline(self, shapes: tuple[Shape, Shape], pct: float | None=None, left: bool=False) -> None:
206+
def draw_baseline(self, pct: float | None=None, left: bool=False) -> None:
207+
shapes = self._get_shapes()
195208
shape = shapes[left]
196209

197210
if pct is None:
198-
pct = self.glider_2d.shape.baseline_pos.si
211+
pct = self.glider_2d.config.baseline_pct.si
199212

200213
part = PlotPart()
201214

202215
line = euklid.vector.PolyLine2D([shape.get_point(rib, pct) for rib in self._get_rib_range(left)])
203216
part.layers["marks"].append(line)
204217
self.drawing.parts.append(part)
205218

206-
def draw_grid(self, shapes: tuple[Shape, Shape], num: int=11, left: bool=False) -> ShapePlot:
219+
def draw_grid(self, num: int=11, left: bool=False) -> ShapePlot:
207220
import numpy as np
208221

209222
for x in np.linspace(0, 1, num):
210223
self.draw_baseline(x, left=left)
211224

212-
self.draw_cells(shapes, left=left)
225+
self.draw_cells(left=left)
213226
return self
214227

215-
def _get_attachment_point_positions(self, shapes: tuple[Shape, Shape], left: bool=False) -> dict[str, euklid.vector.Vector2D]:
228+
def _get_attachment_point_positions(self, left: bool=False) -> dict[str, euklid.vector.Vector2D]:
216229

217230
points = {}
231+
shapes = self._get_shapes()
218232
shape = shapes[left]
219233

220234
for rib_no, rib in enumerate(self.glider_3d.ribs):
@@ -228,9 +242,9 @@ def _get_attachment_point_positions(self, shapes: tuple[Shape, Shape], left: boo
228242
return points
229243

230244

231-
def draw_attachment_points(self, shapes: tuple[Shape, Shape], add_text: bool=True, left: bool=False) -> None:
245+
def draw_attachment_points(self, add_text: bool=True, left: bool=False) -> None:
232246
part = PlotPart()
233-
points = self._get_attachment_point_positions(shapes, left=left)
247+
points = self._get_attachment_point_positions(left=left)
234248

235249
for name, p1 in points.items():
236250
p2 = p1 + euklid.vector.Vector2D([0.1, 0])
@@ -252,7 +266,8 @@ def draw_attachment_points(self, shapes: tuple[Shape, Shape], add_text: bool=Tru
252266

253267
self.drawing.parts.append(part)
254268

255-
def draw_cells(self, shapes: tuple[Shape, Shape], left: bool=False) -> None:
269+
def draw_cells(self, left: bool=False) -> None:
270+
shapes = self._get_shapes()
256271
shape = shapes[left]
257272

258273
cells = []
@@ -269,7 +284,8 @@ def draw_cells(self, shapes: tuple[Shape, Shape], left: bool=False) -> None:
269284
material_code="cell_numbers")
270285
)
271286

272-
def draw_cell_names(self, shapes: tuple[Shape, Shape], left: bool=False) -> None:
287+
def draw_cell_names(self, left: bool=False) -> None:
288+
shapes = self._get_shapes()
273289
shape = shapes[left]
274290
names = []
275291

@@ -287,7 +303,8 @@ def draw_cell_names(self, shapes: tuple[Shape, Shape], left: bool=False) -> None
287303
material_code="cell_numbers")
288304
)
289305

290-
def draw_rib_names(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlot:
306+
def draw_rib_names(self, left: bool=False) -> ShapePlot:
307+
shapes = self._get_shapes()
291308
shape = shapes[left]
292309
names = []
293310

@@ -312,7 +329,8 @@ def draw_rib_names(self, shapes: tuple[Shape, Shape], left: bool=False) -> Shape
312329
)
313330
return self
314331

315-
def draw_straps(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlot:
332+
def draw_straps(self, left: bool=False) -> ShapePlot:
333+
shapes = self._get_shapes()
316334
shape = shapes[left]
317335

318336
for cell_no in self._get_cell_range(left):
@@ -328,7 +346,8 @@ def draw_straps(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlo
328346

329347
return self
330348

331-
def draw_diagonals(self, shapes: tuple[Shape, Shape], left: bool=False) -> ShapePlot:
349+
def draw_diagonals(self, left: bool=False) -> ShapePlot:
350+
shapes = self._get_shapes()
332351
shape = shapes[left]
333352

334353
for cell_no in self._get_cell_range(left):
@@ -344,14 +363,14 @@ def draw_diagonals(self, shapes: tuple[Shape, Shape], left: bool=False) -> Shape
344363

345364
return self
346365

347-
def draw_lines(self, shapes: tuple[Shape, Shape], left: bool=True, add_text: bool=False) -> ShapePlot:
366+
def draw_lines(self, left: bool=True, add_text: bool=False) -> ShapePlot:
348367
#self.draw_design(lower=True)
349368
#self.draw_design(lower=True, left=True)
350369
#self.draw_attachment_points(True)
351370
#self.draw_attachment_points(True, left=True)
352371
lower = self.glider_3d.lineset.lower_attachment_points
353372

354-
attachment_point_positions = self._get_attachment_point_positions(shapes, left=False)
373+
attachment_point_positions = self._get_attachment_point_positions(left=False)
355374
all_nodes = {}
356375
for node in self.glider_3d.lineset.nodes:
357376
if node.node_type == node.NODE_TYPE.UPPER:
2.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)