From 20c0a47c009e1f024239b118f608a34e96d04e5f Mon Sep 17 00:00:00 2001 From: "Adriano (daitarn)" Date: Wed, 28 Oct 2026 21:59:01 +0100 Subject: [PATCH 1/2] : visualizzatore immagine standard, tmfSaveBlob e tmfSvgToPngBlob Refs #122 Co-Authored-By: Claude Sonnet 5.5 --- .../flask_app/static/js/image_viewer.js | 433 ++++++++++++++++++ .../flask_app/static/js/save_image.js | 129 ++++-- .../flask_app/tests/js/test_image_viewer.js | 98 ++++ .../flask_app/tests/js/test_save_image.js | 83 +++- .../flask_app/tests/test_image_viewer_js.py | 35 ++ 5 files changed, 748 insertions(+), 30 deletions(-) create mode 100644 src/frontend/flask_app/static/js/image_viewer.js create mode 100644 src/frontend/flask_app/tests/js/test_image_viewer.js create mode 100644 src/frontend/flask_app/tests/test_image_viewer_js.py diff --git a/src/frontend/flask_app/static/js/image_viewer.js b/src/frontend/flask_app/static/js/image_viewer.js new file mode 100644 index 0000000..d43c5ed --- /dev/null +++ b/src/frontend/flask_app/static/js/image_viewer.js @@ -0,0 +1,433 @@ +/** + * image_viewer.js - #122: , il visualizzatore immagine standard di TieMeasureFlow. + * + * Cosa fa: Custom Element in JS puro (senza Alpine ne' Tailwind) con zoom -/+, Adatta, Salva, percentuale, + * Ctrl+rotella intorno al puntatore, pan col puntatore, overlay SVG a tratto costante ed etichette. + * Sostituisce le quattro implementazioni di zoom di prima (pannello operatore #115, wizard DXF #113 e #104, + * pagina camera #111). Light DOM, stile iniettato una volta nel ( + + +

Prova di <tmf-viewer>

+
+

Immagine 800x500 + overlay + etichette (box fisso, Adatta nel box)

+
+

fit-height, no-save: alto quanto l'immagine

+
+

Modo contenuto: svg (DXF) senza src

+ + +
+

Vuoto: barra nascosta

+
+
in corso...
+ + + + + + diff --git a/src/frontend/flask_app/tests/js/test_image_viewer.js b/src/frontend/flask_app/tests/js/test_image_viewer.js index aaacc24..cc4bb55 100644 --- a/src/frontend/flask_app/tests/js/test_image_viewer.js +++ b/src/frontend/flask_app/tests/js/test_image_viewer.js @@ -44,7 +44,8 @@ check('fitZoom: 0 con NaN, negativi, undefined', check('clampZoom: dentro i limiti resta uguale', near(M.clampZoom(1, 0.5), 1)); check('clampZoom: sotto fit*0.5 -> fit*0.5', near(M.clampZoom(0.01, 0.5), 0.25)); check('clampZoom: sopra 8 -> 8', near(M.clampZoom(20, 0.5), 8)); -check('clampZoom: fit sopra 8 alza il massimo a fit', near(M.clampZoom(20, 12), 12) && near(M.clampZoom(11, 12), 11)); +check('clampZoom: fit sopra 1 alza il massimo a fit*8 (DXF in mm, fit ~10)', near(M.clampZoom(20, 12), 20) && near(M.clampZoom(200, 12), 96) && near(M.clampZoom(11, 12), 11)); +check('clampZoom: con fit piccolo il massimo resta 8', near(M.clampZoom(20, 0.5), 8) && near(M.clampZoom(20, 1), 8) && near(M.clampZoom(100, 2), 16)); check('clampZoom: limiti esatti', near(M.clampZoom(0.25, 0.5), 0.25) && near(M.clampZoom(8, 0.5), 8)); // --- zoomAround ---