Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def _selection_path(filename):
"front_flip": False,
"output_format": "png",
"label_parts": False,
"label_sections": False,
"ao_mode": "ssao",
"keep_uploads": False,
}
Expand Down Expand Up @@ -301,6 +302,7 @@ def stream():
front_flip = bool(data.get("front_flip", False))
rotation_deg = float(data.get("rotation_deg", 0) or 0)
label_parts = bool(data.get("label_parts", False))
label_sections = bool(data.get("label_sections", False))
keep_uploads = bool(data.get("keep_uploads", False))
# "vertex" (fast: per-vertex baked AO, can look blocky on large
# flat panels) or "ssao" (default: screen-space AO computed
Expand All @@ -324,6 +326,7 @@ def stream():
"ao": ao_enabled, "ao_darkness": ao_darkness, "up_axis": up_axis,
"front_flip": front_flip, "rotation_deg": rotation_deg,
"output_format": output_format, "label_parts": label_parts,
"label_sections": label_sections,
"ao_mode": ao_mode, "keep_uploads": keep_uploads,
})

Expand Down Expand Up @@ -425,6 +428,7 @@ def stream():
bg_color=bg_color, line_color=line_color, scale_pct=scale_pct,
model_name=model_display_name,
part_numbers=(part_numbers if label_parts else None),
label_sections=label_sections,
)
yield _event("Done.", 1.0, done=True, image_url=f"/outputs/{out_name}")

Expand Down
19 changes: 15 additions & 4 deletions compositor.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,20 @@ def _draw_view(ax, result, bbox, line_color, bg_color="#FFFFFF",
# pixel regardless of where along the axis it actually is), so a
# cut position has no meaningful line to draw there at all —
# callers simply don't pass markers for those views.
for frac in (rib_marker_x_fracs or []):
for frac, num in (rib_marker_x_fracs or []):
x = xmin + frac * (xmax - xmin)
ax.plot([x, x], [ymin, ymax], linestyle=(0, (2, 4)), linewidth=0.5,
color=line_color, alpha=0.35, zorder=1, solid_capstyle="butt")
for frac in (rib_marker_y_fracs or []):
if num is not None:
ax.text(x, ymin + (ymax - ymin) * 0.02, f"S{num}", ha="center", va="top",
fontsize=18 * cs, family="DejaVu Sans", color=line_color, alpha=0.85, zorder=1)
for frac, num in (rib_marker_y_fracs or []):
y = ymin + frac * (ymax - ymin)
ax.plot([xmin, xmax], [y, y], linestyle=(0, (2, 4)), linewidth=0.5,
color=line_color, alpha=0.35, zorder=1, solid_capstyle="butt")
if num is not None:
ax.text(xmin + (xmax - xmin) * 0.01, y, f"S{num}", ha="left", va="center",
fontsize=18 * cs, family="DejaVu Sans", color=line_color, alpha=0.85, zorder=1)

outer_segs = [np.column_stack([c[:, 1], c[:, 0]]) for c in result["outer_contours"]]
if outer_segs:
Expand Down Expand Up @@ -258,7 +264,8 @@ def _draw_rib(ax, rib_segments, ppm, bbox, line_color, lw=1.0):
def compose_image(view_results, rib_sections, rib_ppm, output_path,
bg_color="#FFFFFF", line_color="#000000",
scale_pct=100, dpi_base=250,
model_name=None, show_chrome=True, part_numbers=None):
model_name=None, show_chrome=True, part_numbers=None,
label_sections=True):
"""view_results: dict of {view_name: render_view() result}, only for
views the user actually requested.
rib_sections: list of rib cuts, each a list of (p0,p1) segment pairs
Expand Down Expand Up @@ -424,7 +431,11 @@ def add_axes_px(x0, y0_top, wpx, hpx):
w_v, h_v = sizes[name]
ax = add_axes_px(x_cursor, y_cursor, w_v, view_row_h)
axis_kind, mirrored = _RIB_MARKER_AXIS.get(name, (None, False))
fracs_for_view = [(1 - f if mirrored else f) for f in rib_fracs] if axis_kind else []
fracs_for_view = (
[(1 - f if mirrored else f, (i + 1) if (show_chrome and label_sections) else None)
for i, f in enumerate(rib_fracs)]
if axis_kind else []
)
_draw_view(
ax, view_results[name], bboxes[name], line_color, bg_color,
label=(name.upper() if show_chrome else None),
Expand Down
21 changes: 21 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ <h1>Orthographic Template Generator</h1>
}

document.addEventListener('DOMContentLoaded', updateThemeToggleLabel);

function updateLabelSectionsState() {
var ribChecked = document.getElementById('rib_cb').checked;
var cb = document.getElementById('label_sections_cb');
if (!ribChecked) {
cb.checked = false;
cb.disabled = true;
} else {
cb.disabled = false;
}
}

document.addEventListener('DOMContentLoaded', updateLabelSectionsState);
</script>

<div class="section">
Expand Down Expand Up @@ -161,6 +174,9 @@ <h2>3. Views</h2>
<span id="rib_cuts_val">1</span>
<span style="color:#666;font-size:0.85em;">(1 = single cut at the midpoint. Higher = more evenly-spaced cuts)</span>
</div>
<div class="color_row" style="margin-top:6px;">
<label><input type="checkbox" id="label_sections_cb"> Number cross-section markers on views (S1, S2…)</label>
</div>

<h2 style="margin-top:20px;">3b. Orientation (only touch if the model loads facing the wrong way)</h2>
<div class="color_row">
Expand Down Expand Up @@ -285,6 +301,8 @@ <h2 style="margin-top:20px;">5. Detail &amp; Output</h2>
document.getElementById('rotation_deg_input').value = prefs.rotation_deg || 0;
document.getElementById('output_format_select').value = prefs.output_format || 'png';
document.getElementById('label_parts_cb').checked = !!prefs.label_parts;
document.getElementById('label_sections_cb').checked = !!prefs.label_sections;
updateLabelSectionsState();
document.getElementById('keep_uploads_cb').checked = !!prefs.keep_uploads;
}

Expand All @@ -293,6 +311,8 @@ <h2 style="margin-top:20px;">5. Detail &amp; Output</h2>
.then(prefs => applyGlobalPrefs(prefs))
.catch(() => {}); // non-fatal if this fails; controls just keep their defaults

document.getElementById('rib_cb').addEventListener('change', updateLabelSectionsState);

dropZone.addEventListener('click', () => fileInput.click());
dropZone.addEventListener('dragover', e => { e.preventDefault(); dropZone.classList.add('dragover'); });
dropZone.addEventListener('dragleave', () => dropZone.classList.remove('dragover'));
Expand Down Expand Up @@ -422,6 +442,7 @@ <h2 style="margin-top:20px;">5. Detail &amp; Output</h2>
rotation_deg: parseFloat(document.getElementById('rotation_deg_input').value) || 0,
output_format: document.getElementById('output_format_select').value,
label_parts: document.getElementById('label_parts_cb').checked,
label_sections: document.getElementById('label_sections_cb').checked,
keep_uploads: document.getElementById('keep_uploads_cb').checked,
};

Expand Down