From c2d8077d96b684e53f47a375f524f02b1d6cd9b1 Mon Sep 17 00:00:00 2001 From: Billy Huddleston Date: Thu, 18 Sep 2025 18:58:59 -0400 Subject: [PATCH] CAM: Fix CAM Sanity Report Fix base template substitution and improve tool/op formatting in sanity report, also update HTML/CSS and image handling. - Major HTML/CSS refactor for CAM Sanity Report template: - Rewrote HTMLTemplate.py with modern, responsive CSS, semantic HTML, and accessibility improvements. - Added CSS reset, responsive image handling, and improved table/list styling. - Introduced .heading-container and .top-link for right-aligned "Top" navigation links on all major sections and tool headers (hidden in print). - Updated all section and tool headers to use new navigation and layout. - Cleaned up legacy markup, removed inline styles, and standardized variable substitution using string.Template syntax (${key}, ${val}). - Updated base_template in HTMLTemplate.py to use string.Template syntax (${key}, ${val}) instead of %{key}, %{val} for correct variable substitution. - Enhanced image generation and embedding: - Updated ImageBuilder to support high-DPI (800x800) images and direct byte output for embedding. - All report images (base, stock, datum, tool) now use in-memory bytes for embedding when possible. - Tool images support a toggle for using toolbit thumbnails or fallback head-on renders. - ReportGenerator now embeds images as base64 when requested, with correct HTML tags. - Improved squawk, tool, and operation data formatting: - Squawk dates now use localized string formatting. - Tool diameter and feedrate now use .UserString for better display. - Spindle speed now formatted as integer with "rpm" suffix. - Operation feed and speed values also use .UserString and "rpm" formatting. - Fixed _format_bases in ReportGenerator.py to iterate over base_data.items() and pass {"key": key, "val": val} to the template, ensuring all bases are listed correctly. - General code cleanup and improved maintainability throughout the CAM Sanity reporting stack. --- src/Mod/CAM/Path/Main/Sanity/HTMLTemplate.py | 669 +++++++++++++----- src/Mod/CAM/Path/Main/Sanity/ImageBuilder.py | 155 ++-- .../CAM/Path/Main/Sanity/ReportGenerator.py | 42 +- src/Mod/CAM/Path/Main/Sanity/Sanity.py | 83 ++- 4 files changed, 700 insertions(+), 249 deletions(-) diff --git a/src/Mod/CAM/Path/Main/Sanity/HTMLTemplate.py b/src/Mod/CAM/Path/Main/Sanity/HTMLTemplate.py index bfddab0009..585d15d5c9 100644 --- a/src/Mod/CAM/Path/Main/Sanity/HTMLTemplate.py +++ b/src/Mod/CAM/Path/Main/Sanity/HTMLTemplate.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # *************************************************************************** # * Copyright (c) 2024 Ondsel * +# * Copyright (c) 2025 Billy Huddleston * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * @@ -33,304 +34,627 @@ html_template = Template( Setup Report for FreeCAD Job: Path Special +