diff --git a/package.json b/package.json index 5ad48c9..18fb9bf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "iccery", "private": true, - "version": "0.1.13", + "version": "0.1.14", "type": "module", "scripts": { "tauri": "tauri" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d9ddbe1..44eab58 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iccery" -version = "0.1.13" +version = "0.1.14" description = "Modern Printer Profiling UI frontend for ArgyllCMS" authors = ["Gordon"] edition = "2021" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index d80a23c..37c8f59 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -102,6 +102,32 @@ pub async fn detect_instruments(app: AppHandle, state: State<'_, ProcessManager> state.spawn(app, "instlist".to_string(), binary, vec![], None).await } +pub fn resolve_profile_extension(cwd: &str, basename: &str) -> (String, std::path::PathBuf) { + let p_icc = std::path::Path::new(cwd).join(format!("{}.icc", basename)); + let p_icm = std::path::Path::new(cwd).join(format!("{}.icm", basename)); + + if p_icm.exists() && !p_icc.exists() { + ("icm".to_string(), p_icm) + } else if p_icc.exists() { + ("icc".to_string(), p_icc) + } else { + #[cfg(windows)] + { + ("icm".to_string(), p_icm) + } + #[cfg(not(windows))] + { + ("icc".to_string(), p_icc) + } + } +} + +#[tauri::command] +pub fn get_profile_path(cwd: String, basename: String) -> String { + let (_, path) = resolve_profile_extension(&cwd, &basename); + path.to_string_lossy().to_string() +} + #[tauri::command] pub async fn extract_gamut( app: AppHandle, @@ -110,18 +136,41 @@ pub async fn extract_gamut( ) -> Result<(), String> { let binary = resolve_binary(app.clone(), "iccgamut".to_string()).await?; let path = std::path::Path::new(&icc_path); - let basename = path.file_stem().unwrap().to_str().unwrap(); - let parent_dir = path.parent().map(|p| p.to_str().unwrap()).unwrap_or(""); + let basename = path.file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_else(|| "profile".to_string()); + let parent_dir = path.parent().map(|p| p.to_string_lossy().to_string()).unwrap_or_default(); - let mut args = vec!["-w".to_string()]; - if !parent_dir.is_empty() { - args.push("-d".to_string()); - args.push(parent_dir.to_string()); - } - args.push(icc_path.clone()); + // Auto-detect .icc vs .icm if the specified path does not exist directly + let resolved_path = if path.exists() { + icc_path.clone() + } else { + let alt = if icc_path.ends_with(".icc") { + icc_path.replace(".icc", ".icm") + } else if icc_path.ends_with(".icm") { + icc_path.replace(".icm", ".icc") + } else { + icc_path.clone() + }; + if std::path::Path::new(&alt).exists() { + alt + } else { + icc_path.clone() + } + }; + + let args = vec![ + "-v".to_string(), + "-d".to_string(), + "50.0".to_string(), + resolved_path, + ]; + let cwd = if parent_dir.is_empty() { + resolve_safe_cwd(&app, "").ok() + } else { + Some(parent_dir) + }; let id = format!("iccgamut_{}", basename); - state.spawn(app, id, binary, args, None).await + state.spawn(app, id, binary, args, cwd).await } #[derive(Debug, Deserialize, Serialize)] @@ -379,9 +428,24 @@ pub fn build_profcheck_args(config: &ProfcheckConfig) -> Vec { pub async fn run_profcheck( app: AppHandle, state: State<'_, ProcessManager>, - config: ProfcheckConfig, + mut config: ProfcheckConfig, ) -> Result<(), String> { let binary = resolve_binary(app.clone(), "profcheck".to_string()).await?; + + // Auto-detect .icc vs .icm if the specified icc_path does not exist directly + if !std::path::Path::new(&config.icc_path).exists() { + let alt = if config.icc_path.ends_with(".icc") { + config.icc_path.replace(".icc", ".icm") + } else if config.icc_path.ends_with(".icm") { + config.icc_path.replace(".icm", ".icc") + } else { + config.icc_path.clone() + }; + if std::path::Path::new(&alt).exists() { + config.icc_path = alt; + } + } + let args = build_profcheck_args(&config); let id = format!("profcheck_{}", config.ti3_path); let cwd = Some(resolve_safe_cwd(&app, &config.cwd)?); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 1c9e97b..5e3e6b6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -18,6 +18,7 @@ pub fn run() { commands::kill_process, commands::resolve_binary, commands::detect_instruments, + commands::get_profile_path, commands::extract_gamut, commands::run_targen, commands::run_printtarg, diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 518296f..bb059bd 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ICCery", - "version": "0.1.13", + "version": "0.1.14", "identifier": "com.gronod.iccery", "build": { "frontendDist": "../src" diff --git a/src/assets/sRGB.gam b/src/assets/sRGB.gam new file mode 100644 index 0000000..993c5b5 --- /dev/null +++ b/src/assets/sRGB.gam @@ -0,0 +1,1379 @@ +GAMUT + +DESCRIPTOR "Argyll Gamut surface poligon data" +ORIGINATOR "Argyll CMS gamut library" +CREATED "Tue Aug 25 10:22:46 2026" +COLOR_REP "LAB" +GAMUT_CENTER "50.000000 0.000000 0.000000" +CSPACE_WHITE "100.000000 -2.387816 -19.404026" +GAMUT_WHITE "99.998874 -2.387789 -19.403808" +CSPACE_BLACK "0.000000 0.000000 0.000000" +GAMUT_BLACK "0.000000 0.000000 0.000000" +CUSP_RED "53.237382 78.287871 62.148058" +CUSP_YELLOW "97.137321 -23.769791 84.721311" +CUSP_GREEN "87.733928 -87.887785 73.898355" +CUSP_CYAN "91.113320 -50.031832 -33.437063" +CUSP_BLUE "32.301170 77.838134 -126.416203" +CUSP_MAGENTA "60.323069 96.208467 -79.513768" +# First come the triangle verticy location + +NUMBER_OF_FIELDS 4 +BEGIN_DATA_FORMAT +VERTEX_NO LAB_L LAB_A LAB_B +END_DATA_FORMAT + +NUMBER_OF_SETS 448 +BEGIN_DATA +0 53.23738 78.28787 62.14806 +1 87.73393 -87.88779 73.89835 +2 32.30117 77.83813 -126.4162 +3 97.13732 -23.76979 84.72131 +4 60.32307 96.20847 -79.51377 +5 92.08525 -14.24625 81.54220 +6 53.35447 78.60413 50.79253 +7 83.87564 2.280649 76.53540 +8 80.69498 9.066293 74.66362 +9 77.59264 15.90655 72.88418 +10 57.93092 64.97051 63.46530 +11 58.76878 62.66166 63.75963 +12 53.57668 79.20211 36.15187 +13 89.34786 -74.05441 75.78451 +14 71.68937 29.56313 69.65578 +15 65.07949 45.92003 66.37764 +16 73.12190 26.16928 70.41736 +17 66.31765 42.76656 66.95748 +18 53.65394 79.40935 32.13248 +19 90.79613 -62.92803 77.46661 +20 91.08723 -60.81567 77.80354 +21 53.94195 80.17896 19.76368 +22 92.04631 -54.11558 78.91087 +23 54.05752 80.48649 15.59671 +24 92.39458 -51.77448 79.31196 +25 95.22381 -34.29738 82.55042 +26 54.46471 81.56421 3.147035 +27 55.15354 83.36736 -13.13741 +28 58.23555 91.15715 -58.67024 +29 56.25383 86.19822 -32.74892 +30 43.82204 44.39999 -107.3457 +31 88.00240 -84.44335 56.17783 +32 53.79934 90.68751 -90.31915 +33 52.74215 89.83989 -92.07732 +34 88.28748 -80.88480 41.84045 +35 91.11332 -50.03183 -33.43706 +36 50.66167 88.21685 -95.54287 +37 55.47044 15.53048 -88.43226 +38 70.25635 -15.11766 -65.05040 +39 88.51724 -78.08693 32.21627 +40 49.64029 87.44353 -97.24689 +41 50.24043 27.91848 -96.87445 +42 90.56657 -55.46975 -23.06920 +43 12.35755 45.69866 -74.21878 +44 13.42559 47.41983 -77.01411 +45 90.39594 -57.21271 -19.59352 +46 67.01897 -70.33719 59.14136 +47 89.11856 -71.03844 11.82216 +48 74.03954 -22.07350 -59.19191 +49 90.07208 -60.58426 -12.62126 +50 49.46805 -55.46731 46.63837 +51 64.65829 -3.983664 -73.81222 +52 75.93542 -25.44286 -56.27611 +53 62.76463 -0.333769 -76.80409 +54 5.923683 34.08038 -56.46335 +55 89.62939 -65.33530 -2.130596 +56 2.837725 19.48753 -41.27759 +57 15.14731 -26.38932 20.02350 +58 28.15269 -37.40803 31.45365 +59 17.84328 -28.67346 22.94881 +60 30.63103 -39.50779 33.21918 +61 85.42860 -41.27479 -41.88407 +62 2.264561 15.55144 -36.92225 +63 87.32555 -44.25171 -39.05084 +64 3.487739 23.76854 -45.40603 +65 35.09873 57.77819 45.86665 +66 26.18016 47.69382 36.88900 +67 9.565408 -19.61366 13.12312 +68 1.765340 12.12314 -32.33317 +69 24.64917 45.96270 35.11541 +70 99.99887 -2.368094 -19.42243 +71 0.00000 0.00000 0.00000 +72 73.84328 58.41718 -58.35473 +73 89.01410 21.35955 -35.43485 +74 90.53891 17.92010 -33.18221 +75 92.08034 14.49254 -30.91473 +76 77.62019 48.68730 -52.56424 +77 13.46979 33.32198 20.41046 +78 86.02128 28.25508 -39.88383 +79 11.79010 31.42273 17.96859 +80 0.976169 6.703653 -22.41022 +81 78.94902 45.34606 -50.54002 +82 97.40326 -21.64644 65.83800 +83 84.55614 31.70238 -42.07507 +84 97.87024 -17.99013 42.20060 +85 99.53319 -5.650714 -9.059997 +86 99.24797 -7.696724 -2.125014 +87 99.11290 -8.675347 1.345406 +88 98.62197 -12.28656 15.20945 +89 99.38806 -6.688337 -5.594113 +90 98.98277 -9.624138 4.816620 +91 98.73735 -11.43000 11.75069 +92 98.85759 -10.54257 8.286179 +93 98.39120 0.957317 -21.73439 +94 0.679866 4.668850 -17.05062 +95 1.282928 -2.661895 1.764970 +96 0.129513 0.889405 -3.341660 +97 6.734616 -13.97338 9.265051 +98 5.199688 21.73802 7.977318 +99 99.52551 -4.488846 -20.16416 +100 98.18088 -10.71721 -22.27412 +101 10.15105 -14.53865 -3.319695 +102 3.938488 17.17106 6.042395 +103 1.664400 -0.998752 2.350220 +104 9.951148 -16.30966 1.630954 +105 93.99286 -32.42990 -28.87434 +106 10.39826 -12.29228 -8.240623 +107 93.73185 -33.92167 -29.28710 +108 0.825811 4.714559 -10.87949 +109 9.796380 -17.65318 6.241842 +110 8.071554 -4.789824 -17.08635 +111 1.547389 -0.845764 -5.058574 +112 7.646280 28.27220 -11.70984 +113 7.710785 -7.269724 -12.26130 +114 4.531049 -8.243161 2.713690 +115 10.19545 29.79051 12.06211 +116 8.489888 -1.807740 -21.73665 +117 10.69333 -9.569632 -13.07176 +118 15.40892 -23.12967 8.665202 +119 2.591700 3.044100 3.772876 +120 5.703828 26.49037 -25.86414 +121 3.285427 6.068621 4.837187 +122 3.595860 1.268164 -18.47215 +123 6.203050 28.34728 -30.40435 +124 4.382828 20.02936 -5.422344 +125 1.438284 6.595400 -1.333755 +126 20.91115 -7.754914 26.97127 +127 20.27872 -11.23640 26.16018 +128 13.07359 -16.15192 -4.356306 +129 19.75035 24.39195 -61.99173 +130 20.43478 27.07432 -65.41167 +131 7.513566 -10.57730 10.46011 +132 5.081402 -4.463716 -10.68033 +133 5.377705 -2.428913 -15.78637 +134 21.61150 -4.222775 27.85812 +135 7.464250 30.09177 -28.31670 +136 23.48754 27.82838 -69.36887 +137 19.23150 -17.78240 24.79616 +138 30.72092 34.40688 -83.56651 +139 21.24832 7.098725 28.18333 +140 22.37545 -0.689668 28.81160 +141 28.48420 11.23173 -56.81067 +142 5.221417 14.44958 7.807366 +143 27.77366 37.12635 37.13350 +144 3.555104 17.20435 -12.53467 +145 19.39693 11.38805 26.46904 +146 47.69490 -47.30841 18.78004 +147 6.482617 18.55770 9.742288 +148 36.73982 11.47773 -65.27615 +149 4.202949 18.92348 -0.781149 +150 62.93561 -64.00783 42.28715 +151 31.67616 21.19027 38.39296 +152 65.12867 -65.33676 41.60032 +153 4.665997 -7.316435 -0.768194 +154 17.39142 22.45460 24.82553 +155 20.90425 -25.78611 6.307888 +156 30.74844 -38.00092 25.43964 +157 26.66549 -0.0907351 -41.71491 +158 13.91397 34.50998 3.577564 +159 20.33466 3.625928 27.01590 +160 4.068001 18.04872 2.700735 +161 15.90574 -20.09466 21.08254 +162 30.98258 -35.10897 14.50448 +163 35.98428 -37.59082 12.34234 +164 11.88289 -5.858106 16.57264 +165 10.67036 -13.02915 14.77963 +166 33.49846 -36.37075 13.41920 +167 32.29113 14.26994 38.16461 +168 47.73146 -1.699098 -60.36746 +169 30.09398 36.68870 39.02219 +170 26.37535 -26.46001 -0.308204 +171 28.98639 -30.35030 32.42729 +172 15.46523 8.927534 21.70760 +173 20.77851 -27.26990 10.70253 +174 45.39094 -0.217804 -59.91525 +175 17.88513 -0.883742 -32.12110 +176 14.74711 23.14890 21.53339 +177 72.35878 -60.47868 11.85376 +178 91.67496 -32.25284 -32.33429 +179 92.20045 -29.29361 -31.50100 +180 92.48407 -27.72691 -31.05153 +181 77.63971 34.10040 -52.78188 +182 83.30741 27.60819 -44.07625 +183 13.76159 34.10536 8.718749 +184 75.54892 35.67697 -56.03791 +185 43.72381 -36.17902 -2.844653 +186 76.39551 30.21868 -54.79453 +187 76.21464 20.90006 -55.22162 +188 13.64415 33.79146 13.43158 +189 78.87199 21.14692 -51.06609 +190 87.32002 15.09810 -38.13399 +191 67.26989 26.66099 -69.28892 +192 38.66394 62.86364 10.75828 +193 35.19656 58.04239 36.57309 +194 83.65310 20.03624 -43.67447 +195 90.66601 -12.51473 -33.53344 +196 66.21972 13.60448 -71.12634 +197 89.57944 -17.91095 -35.26060 +198 37.26335 61.33582 8.675190 +199 23.91933 -23.30291 -3.733546 +200 2.682365 13.39937 -13.90632 +201 98.13709 -14.63988 14.48116 +202 74.35996 -7.603405 -58.51742 +203 74.68159 15.36010 -57.70693 +204 37.13105 60.98447 13.13676 +205 35.71721 59.43591 11.05708 +206 75.17492 17.17678 -56.90661 +207 27.77639 49.62372 31.59393 +208 67.91145 44.21902 -68.02449 +209 65.35662 20.31670 -72.42599 +210 11.42291 6.317206 16.36066 +211 88.37362 9.567093 -36.62598 +212 3.319578 15.58691 -7.053573 +213 88.56494 -11.00468 -36.68412 +214 74.63991 -6.294046 -58.06294 +215 27.98927 50.19579 18.84953 +216 31.00037 -16.59208 34.74828 +217 65.71297 30.38908 -71.73081 +218 36.82309 60.16166 26.36287 +219 67.26234 49.39310 -68.98901 +220 88.19055 -12.81586 -37.28068 +221 74.59533 4.811492 -57.98787 +222 74.20986 3.198571 -58.61370 +223 16.10752 19.55477 23.06607 +224 37.41096 61.72633 4.231548 +225 13.31752 -13.69400 -9.151914 +226 26.39913 48.28369 21.36279 +227 87.86746 7.522807 -37.43259 +228 98.90170 -7.761468 -17.43958 +229 35.24765 62.42859 -36.12594 +230 31.75068 -3.266419 -42.71249 +231 28.01680 52.51032 -19.93533 +232 59.44113 -50.08606 6.299467 +233 33.94732 61.18875 -38.24646 +234 96.00062 -29.01119 61.31600 +235 88.10144 -1.914353 -37.23781 +236 94.56869 -35.07831 27.10537 +237 95.28485 -31.26178 31.65535 +238 23.35841 44.90028 17.21548 +239 2.266959 10.54665 -3.751327 +240 28.09646 50.48229 14.21560 +241 34.34219 60.15362 -23.87512 +242 37.29636 63.54341 -23.72363 +243 26.33149 50.38084 -17.82716 +244 95.98191 -27.88023 39.51939 +245 2.446838 11.78193 -8.392522 +246 13.92629 -8.181595 -18.46406 +247 94.87371 -33.59099 31.05815 +248 98.29312 -11.03405 -14.68680 +249 95.37605 -30.49052 28.28770 +250 94.77740 -35.63092 53.89733 +251 27.50338 51.19254 -11.10843 +252 98.45214 -9.864210 -18.14280 +253 29.98711 53.20877 2.465737 +254 28.53656 51.64811 0.250181 +255 32.13856 -0.522276 -46.54584 +256 48.32618 -40.06980 -0.680740 +257 11.85507 -0.428976 -26.77594 +258 9.504890 10.87540 13.86657 +259 93.81622 -39.51807 26.00116 +260 74.52452 -61.48449 10.94735 +261 97.70015 -14.30301 -11.90641 +262 31.55372 -13.38783 35.37864 +263 10.42073 2.579694 14.87232 +264 97.44691 -17.41806 6.142709 +265 97.55030 -15.43866 -8.437139 +266 94.36246 -38.06815 53.33448 +267 13.04887 34.71996 -13.88170 +268 12.75360 33.96459 -9.020249 +269 93.39587 -43.35149 42.52101 +270 33.25497 17.34379 39.19856 +271 8.715568 -5.149986 12.30012 +272 97.78216 -16.07696 10.30740 +273 20.20364 -5.467953 -28.48208 +274 97.40563 -16.54334 -4.963766 +275 26.61730 51.10743 -22.18650 +276 34.30220 62.06052 -42.18343 +277 91.00758 -56.66178 11.02375 +278 70.70544 -53.57729 -1.864092 +279 14.10349 35.00912 -1.521011 +280 30.98682 57.86378 -38.52871 +281 9.512529 -1.287457 13.50842 +282 93.32611 -43.99792 45.67200 +283 94.01887 -37.70669 19.16257 +284 13.60171 -11.02093 -13.85885 +285 97.27410 -16.40380 -12.56932 +286 8.043309 -8.267045 11.27282 +287 93.43482 -40.88541 14.67685 +288 93.77435 -38.83760 15.18622 +289 90.89224 -57.84543 14.48903 +290 97.26612 -17.61638 -1.488146 +291 92.20520 -50.48310 34.11207 +292 91.36553 -55.25143 22.38978 +293 93.03680 -42.60741 6.773126 +294 92.86103 -42.47785 -4.573553 +295 96.97734 -18.69401 -5.625079 +296 24.91315 48.95145 -20.10400 +297 93.22558 -41.81436 10.72090 +298 92.74040 -42.78198 -8.474425 +299 97.13171 -18.65765 1.989240 +300 91.12239 -56.93396 22.03022 +301 92.69355 -47.79108 41.53138 +302 92.89173 -41.39279 -11.95982 +303 93.21108 -38.50587 -18.91533 +304 97.00239 -19.66648 5.465989 +305 93.04862 -39.96704 -15.44071 +306 91.52506 -54.47515 26.16916 +307 33.23674 -12.70974 -31.45839 +308 34.01268 10.28814 39.10684 +309 33.49186 -3.503987 37.56308 +310 11.50229 33.18357 -16.37708 +311 29.30833 55.73847 -36.66815 +312 8.335318 7.298841 12.08963 +313 91.90437 -52.48325 33.67877 +314 24.12544 -21.15564 -8.183776 +315 96.86083 -9.866071 16.50597 +316 77.95635 -13.90732 70.77213 +317 9.421928 32.61559 -30.32216 +318 62.64612 -31.14253 57.93254 +319 60.40093 -39.80946 -16.46213 +320 48.42654 -15.59406 -42.63749 +321 6.404035 -0.402050 9.127567 +322 7.276775 3.402146 10.46652 +323 48.84672 -34.55524 -12.53862 +324 61.81548 -36.45738 56.97924 +325 59.94608 24.49026 60.21842 +326 6.558180 11.46464 9.646398 +327 61.42550 11.70671 60.16647 +328 48.14355 -45.40177 46.12738 +329 49.32816 -19.97056 48.49804 +330 69.33594 -43.88677 -19.45580 +331 48.82496 -22.91644 47.92431 +332 47.73441 19.14651 50.39953 +333 49.07231 31.10492 52.63467 +334 49.32683 15.43808 51.26434 +335 45.27055 19.94972 48.60077 +336 39.82562 28.05534 45.30432 +337 48.13794 -18.00573 -38.88927 +338 70.36580 -33.95143 -37.58748 +339 38.79589 25.27193 44.22368 +340 25.20039 -11.21379 -25.49234 +341 49.77231 -4.182637 49.95564 +342 31.38055 -33.09592 34.09503 +343 22.54416 -9.789864 -24.85476 +344 35.74211 -14.05042 -32.06197 +345 37.37400 28.84882 43.53951 +346 47.71964 34.51697 51.98748 +347 34.91799 -21.38088 -19.94736 +348 49.04452 -32.55371 -16.46482 +349 34.26401 -13.90936 37.41112 +350 38.45770 31.53684 44.66277 +351 70.14358 -36.02027 -33.99700 +352 37.41040 -22.57751 -20.67675 +353 49.71131 -26.14210 -28.10082 +354 24.35665 -18.85029 -12.59794 +355 24.89436 -13.85676 -21.26108 +356 49.47680 -28.34128 -24.24881 +357 22.22683 -12.49970 -20.56104 +358 24.61284 -16.41120 -16.95794 +359 35.44970 -16.55937 -28.07054 +360 21.07184 47.77452 -45.56465 +361 23.34524 51.15712 -51.13708 +362 35.17491 -19.00693 -24.03086 +363 87.06072 9.370494 7.187899 +364 88.52195 5.174662 12.87112 +365 90.12211 1.800273 14.97607 +366 87.61671 12.88924 -7.151265 +367 82.81879 9.180387 41.93159 +368 85.62945 13.62353 1.468319 +369 86.93636 8.570999 10.77074 +370 31.85722 61.79949 -59.60587 +371 89.33123 10.42784 -8.524011 +372 87.46891 11.96257 -3.571796 +373 85.49520 12.78818 5.074162 +374 88.76889 6.798596 5.741566 +375 85.76969 14.49072 -2.135386 +376 85.36696 11.98546 8.677448 +377 92.22258 1.787498 2.973154 +378 90.62339 5.158576 0.784580 +379 91.96858 0.0543591 10.04090 +380 80.27421 19.38626 17.09611 +381 79.28559 25.73400 0.430351 +382 86.81771 7.803842 14.34869 +383 91.73611 -1.550446 17.08429 +384 81.21472 24.81315 -8.495535 +385 91.21404 9.016163 -13.38990 +386 82.75019 8.740551 45.22326 +387 81.18401 12.15713 43.52679 +388 92.09286 0.905013 6.508738 +389 78.77087 22.82519 15.14776 +390 92.35770 2.700996 -0.561588 +391 79.58249 27.38259 -6.915997 +392 81.50122 14.12340 29.79385 +393 83.37224 25.16023 -20.83636 +394 85.91600 15.38956 -5.735542 +395 83.94803 16.21828 2.971552 +396 83.14824 11.27243 28.15276 +397 79.74100 28.25421 -10.57715 +398 71.32551 47.57174 -18.68964 +399 90.90744 7.026770 -6.313611 +400 81.54185 26.64941 -15.76232 +401 78.88980 23.50318 11.47322 +402 85.04753 22.73359 -22.24328 +403 93.96598 -0.651517 1.647721 +404 93.47278 -4.094151 15.70088 +405 70.07438 50.78030 -20.50606 +406 85.22966 23.78332 -25.80187 +407 83.55337 26.18182 -24.41524 +408 12.49315 37.63989 -40.46678 +409 93.11594 7.722502 -18.17200 +410 79.01517 24.21397 7.793819 +411 89.90427 0.315521 22.02200 +412 92.95320 6.659334 -14.66383 +413 81.59492 14.69861 26.24226 +414 69.07035 46.34499 2.218811 +415 78.65839 22.18071 18.80973 +416 94.70243 4.342196 -15.90200 +417 77.68103 28.39026 2.114921 +418 81.41337 13.58186 33.30720 +419 80.16523 18.74256 20.72951 +420 69.53654 48.42463 -9.213966 +421 87.93016 14.83435 -14.28997 +422 87.83105 0.527343 37.31729 +423 70.49374 43.77068 0.154891 +424 94.46153 -12.13477 41.60092 +425 69.85356 40.76189 19.17483 +426 65.82409 56.94787 -10.42383 +427 85.87591 1.556436 51.72802 +428 74.82919 24.13317 53.16703 +429 8.603005 16.24850 -42.11586 +430 76.36188 20.99314 51.57010 +431 68.79887 45.11718 9.878961 +432 69.96660 41.29868 15.38241 +433 63.04901 60.16254 2.151702 +434 72.28298 32.67149 33.56793 +435 63.53064 61.96164 -9.575327 +436 73.19295 46.96005 -27.89996 +437 62.77183 59.11453 10.03247 +438 20.37149 48.00729 -51.43156 +439 73.40029 47.90326 -31.55172 +440 72.06443 31.53639 44.02758 +441 68.34758 43.04775 25.12152 +442 70.90211 36.02996 31.97182 +443 62.64618 58.63630 13.97813 +444 70.82030 35.62091 35.58479 +445 63.48416 54.93669 23.14435 +446 62.42032 57.77172 21.84206 +447 64.73492 66.34472 -32.42670 +END_DATA + + +# And then come the triangles + +NUMBER_OF_FIELDS 3 +BEGIN_DATA_FORMAT +VERTEX_0 VERTEX_1 VERTEX_2 +END_DATA_FORMAT + +NUMBER_OF_SETS 892 +BEGIN_DATA +13 1 46 +6 0 65 +4 32 72 +32 33 72 +25 3 82 +70 93 99 +99 93 100 +95 71 103 +63 35 107 +97 67 109 +104 97 109 +96 71 111 +108 96 111 +97 104 114 +104 101 114 +79 98 115 +110 113 117 +113 106 117 +67 57 118 +109 67 118 +104 109 118 +103 71 119 +62 56 120 +68 62 120 +119 71 121 +80 94 122 +116 80 122 +110 116 122 +64 54 123 +56 64 123 +120 56 123 +71 96 125 +96 108 125 +121 71 125 +102 121 125 +101 104 128 +106 101 128 +43 54 129 +54 64 129 +44 43 130 +43 129 130 +97 114 131 +106 113 132 +94 108 132 +108 111 132 +110 122 133 +122 94 133 +94 132 133 +113 110 133 +132 113 133 +120 123 135 +2 44 136 +44 130 136 +130 129 136 +59 57 137 +30 2 138 +2 136 138 +136 129 141 +138 136 141 +121 102 142 +69 66 143 +68 120 144 +120 112 144 +112 124 144 +60 50 146 +102 98 147 +142 102 147 +37 41 148 +41 30 148 +30 138 148 +138 141 148 +124 98 149 +50 46 150 +146 50 150 +1 31 152 +46 1 152 +150 46 152 +31 34 152 +34 146 152 +146 150 152 +71 95 153 +111 71 153 +101 106 153 +114 101 153 +95 114 153 +132 111 153 +106 132 153 +77 69 154 +69 143 154 +143 151 154 +151 145 154 +58 60 156 +141 129 157 +115 98 158 +139 140 159 +140 134 159 +98 102 160 +149 98 160 +127 137 161 +57 67 161 +137 57 161 +59 58 162 +58 156 162 +60 146 163 +156 60 163 +126 127 164 +134 126 164 +159 134 164 +67 97 165 +97 131 165 +127 161 165 +164 127 165 +161 67 165 +162 156 166 +156 163 166 +139 145 167 +145 151 167 +51 53 168 +53 37 168 +66 65 169 +143 66 169 +151 143 169 +162 166 170 +166 163 170 +60 58 171 +58 59 171 +59 137 171 +145 139 172 +139 159 172 +57 59 173 +118 57 173 +155 118 173 +59 162 173 +162 170 173 +170 155 173 +37 148 174 +168 37 174 +62 68 175 +56 62 175 +98 79 176 +147 98 176 +79 77 176 +77 154 176 +39 47 177 +61 63 178 +63 107 178 +107 105 178 +61 178 179 +178 105 179 +105 100 180 +179 105 180 +83 81 181 +78 83 182 +79 115 183 +115 158 183 +81 76 184 +181 81 184 +170 163 185 +83 181 186 +181 184 186 +77 79 188 +79 183 188 +182 83 189 +83 186 189 +186 187 189 +74 73 190 +187 186 191 +23 21 192 +12 6 193 +6 65 193 +65 66 193 +73 78 194 +78 182 194 +182 189 194 +190 73 194 +100 93 195 +37 53 196 +61 179 197 +179 180 197 +180 100 197 +100 195 197 +52 61 197 +26 23 198 +23 192 198 +104 118 199 +118 155 199 +128 104 199 +155 170 199 +94 80 200 +108 94 200 +80 68 200 +68 144 200 +38 48 202 +194 189 203 +21 18 204 +192 21 204 +198 192 205 +192 204 205 +187 191 206 +191 203 206 +189 187 206 +203 189 206 +193 66 207 +184 76 208 +2 30 208 +186 184 208 +41 37 209 +191 41 209 +37 196 209 +196 203 209 +203 191 209 +75 74 211 +74 190 211 +124 149 212 +144 124 212 +51 38 214 +38 202 214 +202 48 214 +137 127 216 +171 137 216 +30 41 217 +41 191 217 +208 30 217 +191 186 217 +186 208 217 +18 12 218 +12 193 218 +204 18 218 +215 204 218 +193 207 218 +36 40 219 +33 36 219 +72 33 219 +76 72 219 +208 76 219 +40 2 219 +2 208 219 +48 52 220 +52 197 220 +197 195 220 +195 213 220 +213 214 220 +214 48 220 +196 53 221 +203 196 221 +53 51 222 +221 53 222 +51 214 222 +154 145 223 +145 172 223 +176 154 223 +27 26 224 +26 198 224 +106 128 225 +66 69 226 +207 66 226 +215 218 226 +218 207 226 +75 211 227 +190 194 227 +211 190 227 +194 203 227 +203 221 227 +28 29 229 +34 39 232 +146 34 232 +39 177 232 +25 82 234 +82 84 234 +195 93 235 +213 195 235 +221 222 235 +222 214 235 +93 75 235 +75 227 235 +214 213 235 +227 221 235 +183 158 238 +188 183 238 +215 226 238 +69 77 238 +226 69 238 +77 188 238 +102 125 239 +160 102 239 +149 160 239 +212 149 239 +125 108 239 +205 204 240 +204 215 240 +215 238 240 +29 27 242 +229 29 242 +241 229 242 +84 237 244 +200 144 245 +144 212 245 +108 200 245 +212 239 245 +239 108 245 +116 110 246 +110 117 246 +85 70 248 +70 228 248 +88 201 249 +84 88 249 +237 84 249 +236 247 249 +247 237 249 +24 25 250 +25 234 250 +234 84 250 +84 244 250 +27 224 251 +242 27 251 +231 241 251 +241 242 251 +243 231 251 +70 99 252 +228 70 252 +99 100 252 +100 248 252 +248 228 252 +198 205 253 +224 198 253 +205 240 253 +238 158 254 +240 238 254 +253 240 254 +251 224 254 +224 253 254 +148 141 255 +141 157 255 +157 230 255 +174 148 255 +230 174 255 +163 146 256 +185 163 256 +146 232 256 +68 80 257 +80 116 257 +175 68 257 +116 246 257 +172 210 258 +223 172 258 +147 176 258 +176 223 258 +247 236 259 +177 47 260 +85 248 261 +127 126 262 +216 127 262 +126 134 262 +159 164 263 +172 159 263 +210 172 263 +92 90 264 +91 92 264 +89 85 265 +85 261 265 +22 24 266 +24 250 266 +250 244 266 +112 267 268 +267 251 268 +244 237 269 +237 247 269 +247 259 269 +167 151 270 +88 91 272 +91 264 272 +201 88 272 +249 201 272 +157 175 273 +175 257 273 +257 246 273 +86 89 274 +89 265 274 +241 231 275 +231 243 275 +4 28 276 +28 229 276 +229 233 276 +32 4 276 +55 47 277 +55 49 278 +47 55 278 +256 232 278 +260 47 278 +232 177 278 +177 260 278 +98 124 279 +158 98 279 +124 112 279 +251 254 279 +254 158 279 +112 268 279 +268 251 279 +276 233 280 +263 164 281 +164 271 281 +13 19 282 +19 20 282 +20 22 282 +22 266 282 +266 244 282 +244 269 282 +259 236 283 +236 249 283 +249 272 283 +117 106 284 +106 225 284 +246 117 284 +100 105 285 +248 100 285 +261 248 285 +265 261 285 +164 165 286 +165 131 286 +114 95 286 +95 271 286 +131 114 286 +271 164 286 +287 283 288 +277 47 289 +87 86 290 +86 274 290 +31 1 291 +287 289 292 +55 277 293 +49 55 294 +55 293 294 +274 265 295 +265 285 295 +290 274 295 +243 251 296 +251 267 296 +275 243 296 +277 289 297 +289 287 297 +293 277 297 +287 288 297 +45 49 298 +49 294 298 +90 87 299 +87 290 299 +264 90 299 +290 295 299 +295 294 299 +47 39 300 +39 292 300 +289 47 300 +292 289 300 +1 13 301 +13 282 301 +282 269 301 +269 259 301 +259 291 301 +291 1 301 +45 298 302 +294 295 302 +298 294 302 +35 42 303 +107 35 303 +105 107 303 +285 105 303 +295 285 303 +272 264 304 +283 272 304 +288 283 304 +294 293 304 +299 294 304 +264 299 304 +297 288 304 +293 297 304 +42 45 305 +45 302 305 +303 42 305 +302 295 305 +295 303 305 +39 34 306 +259 283 306 +283 287 306 +287 292 306 +291 259 306 +292 39 306 +230 157 307 +157 273 307 +140 139 308 +139 167 308 +167 270 308 +134 140 309 +262 134 309 +140 308 309 +112 120 310 +120 135 310 +267 112 310 +296 267 310 +229 241 311 +241 275 311 +233 229 311 +280 233 311 +258 210 312 +210 263 312 +34 31 313 +31 291 313 +291 306 313 +306 34 313 +199 170 314 +128 199 314 +225 128 314 +88 84 315 +5 3 316 +7 5 316 +123 54 317 +135 123 317 +296 310 317 +310 135 317 +3 25 318 +316 3 318 +25 24 318 +24 22 318 +278 49 319 +256 278 319 +38 51 320 +51 168 320 +168 174 320 +174 230 320 +95 103 321 +271 95 321 +281 271 321 +103 119 321 +119 121 322 +321 119 322 +263 281 322 +281 321 322 +312 263 322 +121 312 322 +185 256 323 +256 319 323 +19 13 324 +13 46 324 +46 50 324 +20 19 324 +22 20 324 +318 22 324 +17 14 325 +142 147 326 +147 258 326 +121 142 326 +312 121 326 +258 312 326 +9 8 327 +16 9 327 +50 60 328 +324 50 328 +316 318 329 +42 35 330 +45 42 330 +49 45 330 +319 49 330 +318 324 331 +329 318 331 +324 328 331 +17 325 332 +15 17 333 +17 332 333 +14 16 334 +325 14 334 +16 327 334 +332 325 334 +308 270 335 +333 332 335 +332 334 335 +334 308 335 +333 335 336 +52 48 337 +48 38 337 +38 320 337 +61 52 338 +270 151 339 +335 270 339 +336 335 339 +307 273 340 +8 7 341 +327 8 341 +7 316 341 +316 329 341 +334 327 341 +309 308 341 +308 334 341 +60 171 342 +171 216 342 +328 60 342 +331 328 342 +273 246 343 +340 273 343 +230 307 344 +320 230 344 +337 320 344 +151 169 345 +339 151 345 +336 339 345 +11 15 346 +15 333 346 +333 336 346 +170 185 347 +314 170 347 +323 319 348 +262 309 349 +216 262 349 +329 331 349 +309 341 349 +341 329 349 +331 342 349 +342 216 349 +65 0 350 +336 345 350 +169 65 350 +345 169 350 +0 10 350 +346 336 350 +10 11 350 +11 346 350 +35 63 351 +330 35 351 +63 61 351 +61 338 351 +319 330 351 +185 323 352 +347 185 352 +323 348 352 +52 337 353 +338 52 353 +351 338 353 +284 225 354 +225 314 354 +314 347 354 +340 343 355 +348 319 356 +319 351 356 +351 353 356 +352 348 356 +353 352 356 +246 284 357 +343 246 357 +355 343 357 +354 347 358 +347 355 358 +284 354 358 +357 284 358 +355 357 358 +344 307 359 +337 344 359 +353 337 359 +307 340 359 +275 296 360 +311 275 360 +44 2 361 +280 311 361 +311 360 361 +347 352 362 +352 353 362 +353 359 362 +340 355 362 +359 340 362 +355 347 362 +33 32 370 +32 276 370 +36 33 370 +40 36 370 +2 40 370 +361 2 370 +276 280 370 +280 361 370 +366 371 372 +364 369 374 +369 363 374 +363 373 374 +373 368 374 +372 368 375 +363 369 376 +373 363 376 +368 372 378 +374 368 378 +377 374 378 +92 91 379 +365 364 379 +364 374 379 +364 365 382 +369 364 382 +376 369 382 +380 376 382 +7 8 386 +8 9 387 +386 8 387 +367 386 387 +90 92 388 +92 379 388 +374 377 388 +379 374 388 +89 86 390 +85 89 390 +377 378 390 +384 381 391 +366 372 394 +372 375 394 +375 381 394 +381 384 394 +368 373 395 +375 368 395 +381 375 395 +373 376 395 +384 391 397 +70 85 399 +372 371 399 +378 372 399 +371 385 399 +85 390 399 +390 378 399 +384 397 400 +376 380 401 +395 376 401 +380 389 401 +73 74 402 +74 75 402 +400 393 402 +86 87 403 +87 90 403 +90 388 403 +388 377 403 +377 390 403 +390 86 403 +88 315 404 +315 383 404 +91 88 404 +379 91 404 +365 379 404 +383 365 404 +78 73 406 +73 402 406 +83 78 407 +393 400 407 +78 406 407 +402 393 407 +406 402 407 +54 43 408 +43 360 408 +317 54 408 +296 317 408 +360 296 408 +75 93 409 +381 395 410 +395 401 410 +315 84 411 +383 315 411 +382 365 411 +396 382 411 +365 383 411 +399 385 412 +385 409 412 +409 93 412 +382 396 413 +396 392 413 +389 380 415 +93 70 416 +412 93 416 +70 399 416 +399 412 416 +391 381 417 +381 410 417 +367 387 418 +392 396 418 +396 367 418 +380 382 419 +382 413 419 +413 392 419 +415 380 419 +397 391 420 +398 397 420 +405 398 420 +371 366 421 +385 371 421 +402 75 421 +366 394 421 +394 384 421 +384 400 421 +400 402 421 +75 409 421 +409 385 421 +3 5 422 +367 396 422 +396 411 422 +391 417 423 +420 391 423 +414 420 423 +82 3 424 +3 422 424 +84 82 424 +411 84 424 +422 411 424 +401 389 425 +389 415 425 +27 29 426 +29 405 426 +405 420 426 +420 414 426 +5 7 427 +422 5 427 +7 386 427 +386 367 427 +367 422 427 +64 56 429 +129 64 429 +157 129 429 +56 175 429 +175 157 429 +9 16 430 +387 9 430 +16 14 430 +14 428 430 +418 387 430 +414 423 431 +423 417 431 +410 401 432 +401 425 432 +417 410 432 +431 417 432 +26 27 433 +426 414 433 +415 419 434 +419 392 434 +27 426 435 +426 433 435 +433 27 435 +397 398 436 +400 397 436 +398 405 436 +407 400 436 +23 26 437 +26 433 437 +414 431 437 +433 414 437 +43 44 438 +44 361 438 +360 43 438 +361 360 438 +28 4 439 +436 28 439 +4 72 439 +81 83 439 +83 407 439 +407 436 439 +72 76 439 +76 81 439 +17 15 440 +14 17 440 +428 14 440 +392 418 440 +434 392 440 +418 430 440 +430 428 440 +0 6 441 +6 12 441 +425 415 442 +415 434 442 +10 0 442 +0 441 442 +441 425 442 +11 10 442 +21 23 443 +23 437 443 +437 431 443 +434 440 444 +440 15 444 +15 11 444 +11 442 444 +442 434 444 +12 18 445 +432 425 445 +425 441 445 +441 12 445 +431 432 445 +18 21 446 +445 18 446 +21 443 446 +443 431 446 +431 445 446 +29 28 447 +405 29 447 +28 436 447 +436 405 447 +END_DATA diff --git a/src/js/colprof.js b/src/js/colprof.js index 7ef72bc..7fa57b6 100644 --- a/src/js/colprof.js +++ b/src/js/colprof.js @@ -1,6 +1,7 @@ const { invoke } = window.__TAURI__.core; const { listen } = window.__TAURI__.event; import { setStage4Result } from './profcheck.js'; +import { loadGamutMesh } from './gamut_viewer.js'; let chartreadBasename = ""; let chartreadCwd = ""; @@ -80,7 +81,7 @@ export function initColprof() { } }); - const unlistenExit = await listen("process:exit", (event) => { + const unlistenExit = await listen("process:exit", async (event) => { if (event.payload.id === processId) { unlistenStdout(); unlistenStderr(); @@ -90,11 +91,23 @@ export function initColprof() { if (event.payload.code === 0) { logPre.textContent += "\n[SUCCESS] colprof completed. Profile generated.\n"; - const iccFilename = `${basename}.icc`; - successInfo.textContent = `Profile: ${iccFilename} (${description})`; + + // Resolve real profile path (.icm on Windows, .icc on Unix) + let profilePath = cwd ? `${cwd}/${basename}.icc` : `${basename}.icc`; + try { + profilePath = await invoke("get_profile_path", { cwd, basename }); + } catch (e) { + console.warn("Could not query platform profile path:", e); + } + + const displayFilename = profilePath.split(/[\\/]/).pop() || `${basename}.icc`; + successInfo.textContent = `Profile: ${displayFilename} (${description})`; successCard.classList.remove("hidden"); setStage4Result(basename, cwd); + + // Automatically extract gamut mesh for 3D visualization + triggerGamutExtraction(basename, cwd, profilePath); } else { logPre.textContent += `\n[ERROR] colprof exited with code ${event.payload.code}.\n`; } @@ -116,6 +129,26 @@ export function initColprof() { } } +async function triggerGamutExtraction(basename, cwd, profilePath) { + try { + const processId = `iccgamut_${basename}`; + const unlistenExit = await listen("process:exit", (event) => { + if (event.payload.id === processId) { + unlistenExit(); + if (event.payload.code === 0) { + const sep = cwd.includes('\\') ? '\\' : '/'; + const gamFilePath = cwd ? `${cwd}${sep}${basename}.gam` : `${basename}.gam`; + loadGamutMesh(gamFilePath, 0x3b82f6); + } + } + }); + + await invoke("extract_gamut", { iccPath: profilePath }); + } catch (err) { + console.warn("Automated gamut extraction notice:", err); + } +} + function advanceToStage5() { const steps = document.querySelectorAll('.step'); const stages = document.querySelectorAll('.stage'); diff --git a/src/js/gamut_viewer.js b/src/js/gamut_viewer.js index dd23b78..230d8ce 100644 --- a/src/js/gamut_viewer.js +++ b/src/js/gamut_viewer.js @@ -2,40 +2,74 @@ const { invoke } = window.__TAURI__.core; const { listen } = window.__TAURI__.event; let scene, camera, renderer, controls; -let currentProfileMesh, sRgbMesh; +let currentProfileMesh = null; +let sRgbMesh = null; export async function initGamutViewer() { try { const container = document.getElementById('gamutViewerContainer'); if (!container || typeof THREE === 'undefined') return; + // Clear any existing contents if re-initialized + container.innerHTML = ""; + scene = new THREE.Scene(); scene.background = new THREE.Color(0x111116); - camera = new THREE.PerspectiveCamera(45, container.clientWidth / container.clientHeight, 1, 1000); - camera.position.set(150, 100, 150); + const width = container.clientWidth > 0 ? container.clientWidth : 500; + const height = container.clientHeight > 0 ? container.clientHeight : 360; - renderer = new THREE.WebGLRenderer({ antialias: true }); - renderer.setSize(container.clientWidth, container.clientHeight); + camera = new THREE.PerspectiveCamera(45, width / height, 1, 1000); + camera.position.set(150, 110, 150); + + renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); + renderer.setSize(width, height); + renderer.setPixelRatio(window.devicePixelRatio || 1); container.appendChild(renderer.domElement); if (typeof THREE.OrbitControls !== 'undefined') { controls = new THREE.OrbitControls(camera, renderer.domElement); controls.enableDamping = true; + controls.dampingFactor = 0.05; } // Add CIELAB orientation helpers (Axes: X=a*, Y=L*, Z=b*) - const axesHelper = new THREE.AxesHelper(80); + const axesHelper = new THREE.AxesHelper(100); scene.add(axesHelper); + // Add grid helper at L*=0 plane + const gridHelper = new THREE.GridHelper(200, 20, 0x444455, 0x222233); + gridHelper.position.y = 0; + scene.add(gridHelper); + // Lights - const ambientLight = new THREE.AmbientLight(0xffffff, 0.6); + const ambientLight = new THREE.AmbientLight(0xffffff, 0.7); scene.add(ambientLight); - const dirLight = new THREE.DirectionalLight(0xffffff, 0.8); - dirLight.position.set(100, 200, 100); - scene.add(dirLight); + const dirLight1 = new THREE.DirectionalLight(0xffffff, 0.8); + dirLight1.position.set(100, 200, 100); + scene.add(dirLight1); + const dirLight2 = new THREE.DirectionalLight(0xffffff, 0.4); + dirLight2.position.set(-100, -100, -100); + scene.add(dirLight2); + + // Handle viewport resize dynamically (e.g., when switching to Stage 5 tab) + const resizeObserver = new ResizeObserver((entries) => { + for (let entry of entries) { + const w = entry.contentRect.width; + const h = entry.contentRect.height; + if (w > 0 && h > 0 && renderer && camera) { + camera.aspect = w / h; + camera.updateProjectionMatrix(); + renderer.setSize(w, h); + } + } + }); + resizeObserver.observe(container); animate(); + + // Load bundled sRGB reference gamut wireframe on startup + loadSrgbReferenceGamut(); } catch (err) { console.warn("Gamut viewer initialization notice:", err); } @@ -74,42 +108,67 @@ function parseCGATS(text) { return points; } +function renderGamutFromText(text, color, isWireframe, previousMesh) { + if (!scene) return null; + + if (previousMesh) { + scene.remove(previousMesh); + if (previousMesh.geometry) previousMesh.geometry.dispose(); + if (previousMesh.material) previousMesh.material.dispose(); + } + + const points = parseCGATS(text); + if (points.length < 3) return null; + + const coords = []; + const vertices = new Float32Array(points.length * 3); + + points.forEach((pt, i) => { + coords.push(pt.a, pt.b); + vertices[i * 3] = pt.a; // X = a* + vertices[i * 3 + 1] = pt.L; // Y = L* + vertices[i * 3 + 2] = pt.b; // Z = b* + }); + + if (typeof Delaunator === 'undefined') return null; + const delaunay = new Delaunator(coords); + + const geometry = new THREE.BufferGeometry(); + geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); + geometry.setIndex(Array.from(delaunay.triangles)); + geometry.computeVertexNormals(); + + const material = new THREE.MeshLambertMaterial({ + color: color, + wireframe: isWireframe, + transparent: true, + opacity: isWireframe ? 0.35 : 0.75, + side: THREE.DoubleSide + }); + + const mesh = new THREE.Mesh(geometry, material); + scene.add(mesh); + return mesh; +} + +export async function loadSrgbReferenceGamut() { + try { + const response = await fetch('assets/sRGB.gam'); + if (response.ok) { + const text = await response.text(); + sRgbMesh = renderGamutFromText(text, 0x94a3b8, true, sRgbMesh); + } + } catch (e) { + console.warn("Could not load sRGB reference gamut:", e); + } +} + export async function loadGamutMesh(gamFilePath, color = 0x3b82f6, isWireframe = false) { try { const base64Data = await invoke('read_file_base64', { path: gamFilePath }); const text = atob(base64Data); - const points = parseCGATS(text); - if (points.length < 3) return null; - - const coords = []; - const vertices = new Float32Array(points.length * 3); - - points.forEach((pt, i) => { - coords.push(pt.a, pt.b); - vertices[i * 3] = pt.a; // X = a* - vertices[i * 3 + 1] = pt.L; // Y = L* - vertices[i * 3 + 2] = pt.b; // Z = b* - }); - - if (typeof Delaunator === 'undefined') return null; - const delaunay = new Delaunator(coords); - - const geometry = new THREE.BufferGeometry(); - geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3)); - geometry.setIndex(Array.from(delaunay.triangles)); - geometry.computeVertexNormals(); - - const material = new THREE.MeshLambertMaterial({ - color: color, - wireframe: isWireframe, - transparent: true, - opacity: isWireframe ? 0.4 : 0.75, - side: THREE.DoubleSide - }); - - const mesh = new THREE.Mesh(geometry, material); - scene.add(mesh); - return mesh; + currentProfileMesh = renderGamutFromText(text, color, isWireframe, currentProfileMesh); + return currentProfileMesh; } catch (e) { console.error("Failed to load gamut mesh:", e); return null; diff --git a/src/js/profcheck.js b/src/js/profcheck.js index b61e426..0b79861 100644 --- a/src/js/profcheck.js +++ b/src/js/profcheck.js @@ -1,5 +1,6 @@ const { invoke } = window.__TAURI__.core; const { listen } = window.__TAURI__.event; +import { loadGamutMesh } from './gamut_viewer.js'; let profileBasename = ""; let profileCwd = ""; @@ -30,7 +31,14 @@ export function initProfcheck() { const sep = cwd.includes('\\') ? '\\' : '/'; const ti3Path = cwd ? `${cwd}${sep}${basename}.ti3` : `${basename}.ti3`; - const iccPath = cwd ? `${cwd}${sep}${basename}.icc` : `${basename}.icc`; + + // Query platform-aware profile path (.icm on Windows, .icc on Unix) + let iccPath = cwd ? `${cwd}${sep}${basename}.icc` : `${basename}.icc`; + try { + iccPath = await invoke("get_profile_path", { cwd, basename }); + } catch (e) { + console.warn("Could not query platform profile path:", e); + } logPre.textContent = ""; logContainer.open = false; @@ -63,7 +71,7 @@ export function initProfcheck() { } }); - const unlistenExit = await listen("process:exit", (event) => { + const unlistenExit = await listen("process:exit", async (event) => { if (event.payload.id === processId) { unlistenStdout(); unlistenStderr(); @@ -73,6 +81,10 @@ export function initProfcheck() { if (event.payload.code === 0) { logPre.textContent += "\n[SUCCESS] profcheck verification finished.\n"; parseAndRenderReport(stdoutAccumulator); + + // Ensure gamut mesh is loaded into 3D viewer + const gamFilePath = cwd ? `${cwd}${sep}${basename}.gam` : `${basename}.gam`; + loadGamutMesh(gamFilePath, 0x3b82f6); } else { logPre.textContent += `\n[ERROR] profcheck exited with code ${event.payload.code}.\n`; }