diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2f98c7a1..02e7884b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12,8 +12,10 @@ "axios": "^1.7.2", "echarts": "^5.6.0", "javascript-color-gradient": "^2.5.0", + "jspdf": "^4.2.0", "jszip": "^3.10.1", "lorem-ipsum": "^2.0.8", + "papaparse": "^5.5.3", "pinia": "^3.0.1", "pinia-plugin-persistedstate": "^4.4.1", "plotly.js-dist": "^3.1.0", @@ -33,6 +35,7 @@ "@quasar/quasar-app-extension-qmarkdown": "^2.0.5", "@types/javascript-color-gradient": "^2.4.2", "@types/node": "^20.5.9", + "@types/papaparse": "^5.5.2", "@types/plotly.js": "^3.0.3", "@types/three": "^0.179.0", "@vue/eslint-config-prettier": "^10.1.0", @@ -118,6 +121,15 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.28.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", + "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/types": { "version": "7.27.7", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.7.tgz", @@ -1945,6 +1957,22 @@ "@types/node": "*" } }, + "node_modules/@types/pako": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/pako/-/pako-2.0.4.tgz", + "integrity": "sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==", + "license": "MIT" + }, + "node_modules/@types/papaparse": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.5.2.tgz", + "integrity": "sha512-gFnFp/JMzLHCwRf7tQHrNnfhN4eYBVYYI897CGX4MY1tzY9l2aLkVyx2IlKZ/SAqDbB3I1AOZW5gTMGGsqWliA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/plotly.js": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/plotly.js/-/plotly.js-3.0.3.tgz", @@ -1959,6 +1987,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/raf": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz", + "integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==", + "license": "MIT", + "optional": true + }, "node_modules/@types/range-parser": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", @@ -2012,6 +2047,13 @@ "meshoptimizer": "~0.22.0" } }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "license": "MIT", + "optional": true + }, "node_modules/@types/webxr": { "version": "0.5.22", "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.22.tgz", @@ -3072,6 +3114,16 @@ "license": "Apache-2.0", "optional": true }, + "node_modules/base64-arraybuffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", + "integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -3404,6 +3456,26 @@ ], "license": "CC-BY-4.0" }, + "node_modules/canvg": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz", + "integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==", + "license": "MIT", + "optional": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@types/raf": "^3.4.0", + "core-js": "^3.8.3", + "raf": "^3.4.1", + "regenerator-runtime": "^0.13.7", + "rgbcolor": "^1.0.1", + "stackblur-canvas": "^2.0.0", + "svg-pathdata": "^6.0.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -3771,6 +3843,18 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/core-js": { + "version": "3.48.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.48.0.tgz", + "integrity": "sha512-zpEHTy1fjTMZCKLHUZoVeylt9XrzaIN2rbPXEt0k+q7JE5CkCZdo6bNq55bn24a69CH7ErAVLKijxJja4fw+UQ==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -3819,6 +3903,16 @@ "node": ">= 8" } }, + "node_modules/css-line-break": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz", + "integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==", + "license": "MIT", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -3984,6 +4078,16 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dompurify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.1.tgz", + "integrity": "sha512-qkdCKzLNtrgPFP1Vo+98FRzJnBRGe4ffyCea9IwHB1fyxPOeNTHpLKYGd4Uk9xvNoH0ZoOjwZxNptyMwqrId1Q==", + "license": "(MPL-2.0 OR Apache-2.0)", + "optional": true, + "optionalDependencies": { + "@types/trusted-types": "^2.0.7" + } + }, "node_modules/dot-case": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", @@ -4848,6 +4952,23 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-png": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/fast-png/-/fast-png-6.4.0.tgz", + "integrity": "sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==", + "license": "MIT", + "dependencies": { + "@types/pako": "^2.0.3", + "iobuffer": "^5.3.2", + "pako": "^2.1.0" + } + }, + "node_modules/fast-png/node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "license": "(MIT AND Zlib)" + }, "node_modules/fast-uri": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz", @@ -4895,7 +5016,6 @@ "version": "0.8.2", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", "integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==", - "dev": true, "license": "MIT" }, "node_modules/file-entry-cache": { @@ -5383,6 +5503,20 @@ "node": "^14.13.1 || >=16.0.0" } }, + "node_modules/html2canvas": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz", + "integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==", + "license": "MIT", + "optional": true, + "dependencies": { + "css-line-break": "^2.1.0", + "text-segmentation": "^1.0.3" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -5514,6 +5648,12 @@ "node": ">=18" } }, + "node_modules/iobuffer": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/iobuffer/-/iobuffer-5.4.0.tgz", + "integrity": "sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==", + "license": "MIT" + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -5895,6 +6035,23 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jspdf": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/jspdf/-/jspdf-4.2.0.tgz", + "integrity": "sha512-hR/hnRevAXXlrjeqU5oahOE+Ln9ORJUB5brLHHqH67A+RBQZuFr5GkbI9XQI8OUFSEezKegsi45QRpc4bGj75Q==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.28.6", + "fast-png": "^6.2.0", + "fflate": "^0.8.1" + }, + "optionalDependencies": { + "canvg": "^3.0.11", + "core-js": "^3.6.0", + "dompurify": "^3.3.1", + "html2canvas": "^1.0.0-rc.5" + } + }, "node_modules/jszip": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", @@ -6829,6 +6986,12 @@ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "license": "(MIT AND Zlib)" }, + "node_modules/papaparse": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.5.3.tgz", + "integrity": "sha512-5QvjGxYVjxO59MGU2lHVYpRWBBtKHnlIAcSe1uNFCkkptUh63NFRj0FJQm7nR67puEruUci/ZkjmEFrjCAyP4A==", + "license": "MIT" + }, "node_modules/param-case": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", @@ -6938,6 +7101,13 @@ "integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==", "license": "MIT" }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", + "license": "MIT", + "optional": true + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -7243,6 +7413,16 @@ ], "license": "MIT" }, + "node_modules/raf": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", + "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", + "license": "MIT", + "optional": true, + "dependencies": { + "performance-now": "^2.1.0" + } + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -7391,6 +7571,13 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "license": "MIT", + "optional": true + }, "node_modules/relateurl": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", @@ -7470,6 +7657,16 @@ "integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==", "license": "MIT" }, + "node_modules/rgbcolor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz", + "integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==", + "license": "MIT OR SEE LICENSE IN FEEL-FREE.md", + "optional": true, + "engines": { + "node": ">= 0.8.15" + } + }, "node_modules/rollup": { "version": "4.44.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.44.1.tgz", @@ -8354,6 +8551,16 @@ "node": ">=16" } }, + "node_modules/stackblur-canvas": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz", + "integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.1.14" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -8497,6 +8704,16 @@ "node": ">=8" } }, + "node_modules/svg-pathdata": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz", + "integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/sync-child-process": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/sync-child-process/-/sync-child-process-1.0.2.tgz", @@ -8692,6 +8909,16 @@ "b4a": "^1.6.4" } }, + "node_modules/text-segmentation": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz", + "integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==", + "license": "MIT", + "optional": true, + "dependencies": { + "utrie": "^1.0.2" + } + }, "node_modules/three": { "version": "0.179.1", "resolved": "https://registry.npmjs.org/three/-/three-0.179.1.tgz", @@ -9142,6 +9369,16 @@ "node": ">= 0.4.0" } }, + "node_modules/utrie": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz", + "integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==", + "license": "MIT", + "optional": true, + "dependencies": { + "base64-arraybuffer": "^1.0.2" + } + }, "node_modules/uuid": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index bdaae333..52d7cc8c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -18,8 +18,10 @@ "axios": "^1.7.2", "echarts": "^5.6.0", "javascript-color-gradient": "^2.5.0", + "jspdf": "^4.2.0", "jszip": "^3.10.1", "lorem-ipsum": "^2.0.8", + "papaparse": "^5.5.3", "pinia": "^3.0.1", "pinia-plugin-persistedstate": "^4.4.1", "plotly.js-dist": "^3.1.0", @@ -39,6 +41,7 @@ "@quasar/quasar-app-extension-qmarkdown": "^2.0.5", "@types/javascript-color-gradient": "^2.4.2", "@types/node": "^20.5.9", + "@types/papaparse": "^5.5.2", "@types/plotly.js": "^3.0.3", "@types/three": "^0.179.0", "@vue/eslint-config-prettier": "^10.1.0", diff --git a/frontend/src/components/AppHeader.vue b/frontend/src/components/AppHeader.vue index e8199f2e..7d514836 100644 --- a/frontend/src/components/AppHeader.vue +++ b/frontend/src/components/AppHeader.vue @@ -4,17 +4,46 @@

{{ t("title") }}

-
Regrouping {{ totalWalls.unwrapOrNull() ?? 0 }} walls across {{ numberOfSources.unwrapOrNull() ?? 0 }} sources
+
+ A curated dataset of {{ totalWalls.unwrapOrNull() ?? 0 }} irregular stone masonry walls. +
- - - - + + + +
@@ -36,10 +65,10 @@

- Thanks to ENAC-IT4R for developing the web-based interfaces, visualization features and search capabilities. + Thanks to ENAC-IT4R for developing the web-based interfaces, visualization features and search capabilities.

- This work was financed by Swiss National Science Foundation (SNSF) grant as part of the ETH Domain’s ORD program. + This work was financed by Swiss National Science Foundation (SNSF) grant as part of the ETH Domain’s ORD program.

@@ -65,7 +94,6 @@ const showAcknowledgements = ref(false); const propertiesStore = usePropertiesStore() const totalWalls = useAsyncResultRef(propertiesStore.getColumnValues("Wall ID").chain(values => Result.ok(values.length))); -const numberOfSources = useAsyncResultRef(propertiesStore.getColumnValues("Reference").chain(values => Result.ok(new Set(values).size))); diff --git a/frontend/src/components/AppToolbar.vue b/frontend/src/components/AppToolbar.vue index 7d7ec61b..7e800bde 100644 --- a/frontend/src/components/AppToolbar.vue +++ b/frontend/src/components/AppToolbar.vue @@ -38,13 +38,10 @@ /> - - diff --git a/frontend/src/stores/settings.ts b/frontend/src/stores/settings.ts index 270b97f4..e7d331a6 100644 --- a/frontend/src/stores/settings.ts +++ b/frontend/src/stores/settings.ts @@ -14,7 +14,7 @@ export const useSettingsStore = defineStore('settings', () => { function initSettings(): Settings { if (settings.value != undefined) return settings.value; let settingsData: Settings = { - intro_shown: false, + intro_shown: true, theme: 'light', }; const settingsSaved = LocalStorage.getItem(APP_STORAGE_NAME); diff --git a/frontend/src/utils/colors.ts b/frontend/src/utils/colors.ts new file mode 100644 index 00000000..38d3ecd9 --- /dev/null +++ b/frontend/src/utils/colors.ts @@ -0,0 +1,27 @@ +export function hslToRgb(h: number, s: number, l: number): [number, number, number] { + s /= 100; + l /= 100; + const k = (n: number) => (n + h / 30) % 12; + const a = s * Math.min(l, 1 - l); + const f = (n: number) => + l - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1)); + + return [ + Math.round(255 * f(0)), + Math.round(255 * f(8)), + Math.round(255 * f(4)) + ]; +} + +export function hslStringToRgb(hsl: string): [number, number, number] { + const match = hsl.match(/hsl\(\s*(\d+),\s*(\d+)%,\s*(\d+)%\s*\)/); + if (!match || match.length !== 4) { + throw new Error('Invalid HSL color format'); + } + + const h = parseInt(match[1]!, 10); + const s = parseInt(match[2]!, 10); + const l = parseInt(match[3]!, 10); + + return hslToRgb(h, s, l); +} \ No newline at end of file diff --git a/frontend/src/utils/download.ts b/frontend/src/utils/download.ts index a8c24ca6..b142ec74 100644 --- a/frontend/src/utils/download.ts +++ b/frontend/src/utils/download.ts @@ -37,4 +37,17 @@ export async function downloadFilesAsZip(files: DownloadableFile[], zipFilename: a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); +} + +export function downloadStringAsFile(data: string, filename: string, mimeType: string) { + const blob = new Blob([data], { type: mimeType }); + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); } \ No newline at end of file diff --git a/frontend/src/utils/export.ts b/frontend/src/utils/export.ts new file mode 100644 index 00000000..3f487e73 --- /dev/null +++ b/frontend/src/utils/export.ts @@ -0,0 +1,72 @@ +import type { LineComputeTrace } from "src/models"; +import Papa from "papaparse"; +import jsPDF from "jspdf"; +import { hslStringToRgb } from "./colors"; + +export function lineComputeTracesToCSV(lines: LineComputeTrace[]) { + const data = lines.map(line => ({ + // inputs + start_x: line.params.startX, + start_y: line.params.startY, + end_x: line.params.endX, + end_y: line.params.endY, + real_length: line.params.realLength, + real_height: line.params.realHeight, + interface_weight: line.params.interfaceWeight, + boundary_margin: line.params.boundaryMargin, + + // results + lmt_type: line.result.lmt_type, + lmt_result: line.result.lmt_result, + total_length: line.result.total_length, + start_point_used_x: line.result.start_point_used[0], + start_point_used_y: line.result.start_point_used[1], + end_point_used_x: line.result.end_point_used[0], + end_point_used_y: line.result.end_point_used[1], + path: line.result.path_coordinates.pixel_coordinates.map(coord => `${coord[0]}_${coord[1]}`).join("|"), + })); + + return Papa.unparse(data, { + header: true, + }); +} + +export function lineComputeTracesToPDF(imageDataUrl: string | null, lines: LineComputeTrace[], extractResult: (line: LineComputeTrace) => number | null = line => line.result.lmt_result) { + const doc = new jsPDF({ + orientation: 'landscape', + }); + + const imgWidth = 150; + const xOffset = imgWidth + 20; // Image width + some padding + const indentedXOffset = xOffset + 5; // Further indent for details + + if (imageDataUrl) { + doc.addImage(imageDataUrl, 'PNG', 10, 10, imgWidth, 0); // Adjust dimensions as needed + } + + + lines.forEach((line, index) => { + let yPosition = 10 + (index) * (6 + 5 * 4 + 8); // Adjust spacing as needed + doc.setFontSize(12); + doc.text(`Line ${index + 1}:`, xOffset, yPosition); + + yPosition += 6; + + doc.setFillColor(...hslStringToRgb(line.color)); + doc.rect(xOffset, yPosition - 3, 3, 5 * 4, 'F'); + + doc.setFontSize(10); + + doc.text(`Start: (${line.params.startX}, ${line.params.startY})`, indentedXOffset, yPosition); + yPosition += 5; + doc.text(`End: (${line.params.endX}, ${line.params.endY})`, indentedXOffset, yPosition); + yPosition += 5; + doc.text(`LMT Type: ${line.result.lmt_type}`, indentedXOffset, yPosition); + yPosition += 5; + const result = extractResult(line); + doc.text(`LMT Result: ${result !== null ? result.toFixed(2) : 'N/A'}`, indentedXOffset, yPosition); + + }); + + return doc.save(`line_compute_results_${new Date().toISOString()}.pdf`); +} \ No newline at end of file diff --git a/frontend/src/utils/toImplementInUnwrapped.ts b/frontend/src/utils/toImplementInUnwrapped.ts deleted file mode 100644 index e69de29b..00000000