Spaces:
Sleeping
Sleeping
Commit ·
7caaba9
1
Parent(s): b379193
Default travel width to 1/4 of filament width, travel opacity to 0.2
Browse filesTravel tubes now default to a quarter of the filament width (which
tracks the layer height) and 20% opacity, so traverse moves recede
behind the printed path. The layer-height sync keeps the 1/4 ratio.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- app.py +17 -15
- gcode_viewer.py +2 -2
app.py
CHANGED
|
@@ -1024,12 +1024,12 @@ def render_toolpath(
|
|
| 1024 |
shape1_path: str | None,
|
| 1025 |
shape2_path: str | None,
|
| 1026 |
shape3_path: str | None,
|
| 1027 |
-
travel_opacity: float = 0.
|
| 1028 |
print_opacity: float = 1.0,
|
| 1029 |
travel_color: str = "#969696",
|
| 1030 |
print_color: str = "#ff7f0e",
|
| 1031 |
print_width: float = 0.8,
|
| 1032 |
-
travel_width: float = 0.
|
| 1033 |
tube: bool = True,
|
| 1034 |
) -> tuple[Any, str, dict]:
|
| 1035 |
if source == GCODE_SOURCE_UPLOAD:
|
|
@@ -1721,7 +1721,7 @@ def build_demo() -> gr.Blocks:
|
|
| 1721 |
label="Travel (G0) opacity",
|
| 1722 |
minimum=0.0,
|
| 1723 |
maximum=1.0,
|
| 1724 |
-
value=0.
|
| 1725 |
step=0.05,
|
| 1726 |
min_width=150,
|
| 1727 |
)
|
|
@@ -1751,9 +1751,9 @@ def build_demo() -> gr.Blocks:
|
|
| 1751 |
with gr.Row(visible=False) as width_row:
|
| 1752 |
travel_width_slider = gr.Slider(
|
| 1753 |
label="Travel width (mm)",
|
| 1754 |
-
minimum=0.
|
| 1755 |
maximum=1.2,
|
| 1756 |
-
value=0.
|
| 1757 |
step=0.05,
|
| 1758 |
min_width=150,
|
| 1759 |
)
|
|
@@ -1803,18 +1803,20 @@ def build_demo() -> gr.Blocks:
|
|
| 1803 |
inputs=[render_mode] + render_inputs,
|
| 1804 |
outputs=[toolpath_plot, toolpath_status, parsed_state],
|
| 1805 |
)
|
| 1806 |
-
# Keep the filament and travel width sliders in sync with the
|
| 1807 |
-
#
|
| 1808 |
-
#
|
|
|
|
| 1809 |
def sync_width_sliders(v: float):
|
| 1810 |
height = float(v or 0.8)
|
| 1811 |
-
|
| 1812 |
-
|
| 1813 |
-
|
| 1814 |
-
|
| 1815 |
-
|
| 1816 |
-
)
|
| 1817 |
-
|
|
|
|
| 1818 |
|
| 1819 |
layer_height.change(
|
| 1820 |
fn=sync_width_sliders,
|
|
|
|
| 1024 |
shape1_path: str | None,
|
| 1025 |
shape2_path: str | None,
|
| 1026 |
shape3_path: str | None,
|
| 1027 |
+
travel_opacity: float = 0.2,
|
| 1028 |
print_opacity: float = 1.0,
|
| 1029 |
travel_color: str = "#969696",
|
| 1030 |
print_color: str = "#ff7f0e",
|
| 1031 |
print_width: float = 0.8,
|
| 1032 |
+
travel_width: float = 0.2,
|
| 1033 |
tube: bool = True,
|
| 1034 |
) -> tuple[Any, str, dict]:
|
| 1035 |
if source == GCODE_SOURCE_UPLOAD:
|
|
|
|
| 1721 |
label="Travel (G0) opacity",
|
| 1722 |
minimum=0.0,
|
| 1723 |
maximum=1.0,
|
| 1724 |
+
value=0.2,
|
| 1725 |
step=0.05,
|
| 1726 |
min_width=150,
|
| 1727 |
)
|
|
|
|
| 1751 |
with gr.Row(visible=False) as width_row:
|
| 1752 |
travel_width_slider = gr.Slider(
|
| 1753 |
label="Travel width (mm)",
|
| 1754 |
+
minimum=0.05,
|
| 1755 |
maximum=1.2,
|
| 1756 |
+
value=0.2,
|
| 1757 |
step=0.05,
|
| 1758 |
min_width=150,
|
| 1759 |
)
|
|
|
|
| 1803 |
inputs=[render_mode] + render_inputs,
|
| 1804 |
outputs=[toolpath_plot, toolpath_status, parsed_state],
|
| 1805 |
)
|
| 1806 |
+
# Keep the filament and travel width sliders in sync with the Layer
|
| 1807 |
+
# Height chosen on the slicing tab: filament width equals the layer
|
| 1808 |
+
# height, travel width is a quarter of it, both capped 50% above the
|
| 1809 |
+
# layer height.
|
| 1810 |
def sync_width_sliders(v: float):
|
| 1811 |
height = float(v or 0.8)
|
| 1812 |
+
travel = height / 4
|
| 1813 |
+
print_update = gr.update(
|
| 1814 |
+
value=height, minimum=min(0.1, height), maximum=height * 1.5
|
| 1815 |
+
)
|
| 1816 |
+
travel_update = gr.update(
|
| 1817 |
+
value=travel, minimum=min(0.05, travel), maximum=height * 1.5
|
| 1818 |
+
)
|
| 1819 |
+
return print_update, travel_update
|
| 1820 |
|
| 1821 |
layer_height.change(
|
| 1822 |
fn=sync_width_sliders,
|
gcode_viewer.py
CHANGED
|
@@ -383,12 +383,12 @@ def _segments_to_xyz(
|
|
| 383 |
|
| 384 |
def build_toolpath_figure(
|
| 385 |
parsed: dict,
|
| 386 |
-
travel_opacity: float = 0.
|
| 387 |
print_opacity: float = 1.0,
|
| 388 |
travel_color: str = "#969696",
|
| 389 |
print_color: str = "#1f77b4",
|
| 390 |
print_width: float = 0.8,
|
| 391 |
-
travel_width: float = 0.
|
| 392 |
tube: bool = True,
|
| 393 |
) -> go.Figure:
|
| 394 |
moves = parsed.get("moves") or []
|
|
|
|
| 383 |
|
| 384 |
def build_toolpath_figure(
|
| 385 |
parsed: dict,
|
| 386 |
+
travel_opacity: float = 0.2,
|
| 387 |
print_opacity: float = 1.0,
|
| 388 |
travel_color: str = "#969696",
|
| 389 |
print_color: str = "#1f77b4",
|
| 390 |
print_width: float = 0.8,
|
| 391 |
+
travel_width: float = 0.2,
|
| 392 |
tube: bool = True,
|
| 393 |
) -> go.Figure:
|
| 394 |
moves = parsed.get("moves") or []
|