@geode/opengeodeweb-front 10.34.0-rc.8 → 10.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/{server → .build/server}/utils/app_config.js +10 -9
  2. package/{server → .build/server}/utils/cleanup.js +31 -17
  3. package/{server → .build/server}/utils/cloud.js +1 -4
  4. package/{server → .build/server}/utils/microservices.js +21 -9
  5. package/{server → .build/server}/utils/path.js +4 -4
  6. package/{server → .build/server}/utils/scripts.js +9 -9
  7. package/.build/server/utils/server_config.js +51 -0
  8. package/.build/server/utils/stream.js +6 -0
  9. package/{server → .build/server}/utils/ws_client.js +18 -3
  10. package/{shared → .build/shared}/scripts.js +10 -10
  11. package/.build/shared/utils/call_raw.js +31 -0
  12. package/{shared → .build/shared}/utils/call_schema.js +2 -2
  13. package/.build/shared/utils/fetch_raw.js +52 -0
  14. package/{shared → .build/shared}/utils/fetch_schema.js +2 -2
  15. package/{shared → .build/shared}/utils/file.js +3 -1
  16. package/{shared → .build/shared}/utils/response_handlers/load.js +10 -7
  17. package/{shared → .build/shared}/utils/validate_schema.js +1 -1
  18. package/app/components/ActionButton.vue +6 -6
  19. package/app/components/CameraManager/List.vue +5 -5
  20. package/app/components/CameraManager/Saver.vue +3 -5
  21. package/app/components/CameraManager.vue +6 -4
  22. package/app/components/CameraOrientation.vue +12 -12
  23. package/app/components/ClippingPlaneCard.vue +4 -2
  24. package/app/components/ClippingPlanes.vue +8 -8
  25. package/app/components/CrsSelector.vue +9 -10
  26. package/app/components/DeleteDialog.vue +4 -2
  27. package/app/components/DragAndDrop.vue +10 -12
  28. package/app/components/DragAndDropInternal/DragAndDropInline.vue +4 -2
  29. package/app/components/ExtensionSelector.vue +4 -4
  30. package/app/components/FeedBack/ErrorBanner.vue +3 -1
  31. package/app/components/FeedBack/Snackers.vue +4 -3
  32. package/app/components/FileSelector.vue +10 -8
  33. package/app/components/FileUploader.vue +11 -11
  34. package/app/components/GlassCard.vue +1 -1
  35. package/app/components/HybridRenderingView.vue +7 -5
  36. package/app/components/HybridViewerTooltip.vue +7 -7
  37. package/app/components/Launcher.vue +1 -1
  38. package/app/components/Loading/EcoMessages.vue +9 -3
  39. package/app/components/Loading.vue +2 -2
  40. package/app/components/MissingFilesSelector.vue +12 -10
  41. package/app/components/ObjectSelector.vue +10 -9
  42. package/app/components/PackagesVersions.vue +6 -5
  43. package/app/components/Recaptcha.vue +3 -3
  44. package/app/components/RemoteRenderingView.vue +6 -7
  45. package/app/components/Ruler.vue +3 -3
  46. package/app/components/Screenshot.vue +6 -6
  47. package/app/components/SearchBar.vue +4 -2
  48. package/app/components/ShrinkFilter.vue +7 -7
  49. package/app/components/Step.vue +6 -5
  50. package/app/components/Stepper.vue +4 -3
  51. package/app/components/ToolPanel.vue +6 -3
  52. package/app/components/ViewToolbar.vue +25 -28
  53. package/app/components/Viewer/ContextMenu/CenterButton.vue +7 -5
  54. package/app/components/Viewer/ContextMenu/CircularItems.vue +3 -3
  55. package/app/components/Viewer/ContextMenu/ContextMenu.vue +22 -19
  56. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -8
  57. package/app/components/Viewer/ContextMenu/InfoCard.vue +11 -12
  58. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +13 -17
  59. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +11 -15
  60. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -16
  61. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +8 -12
  62. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +11 -15
  63. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +11 -15
  64. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +67 -38
  65. package/app/components/Viewer/Generic/Model/CornersOptions.vue +53 -23
  66. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +1 -3
  67. package/app/components/Viewer/Generic/Model/LinesOptions.vue +67 -38
  68. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +31 -15
  69. package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +2 -3
  70. package/app/components/Viewer/Generic/Model/PointsOptions.vue +6 -6
  71. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +69 -38
  72. package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +64 -46
  73. package/app/components/Viewer/ObjectTree/Base/Controls.vue +5 -5
  74. package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +13 -9
  75. package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +5 -5
  76. package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +10 -10
  77. package/app/components/Viewer/ObjectTree/Box.vue +6 -4
  78. package/app/components/Viewer/ObjectTree/Layout.vue +23 -21
  79. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +14 -14
  80. package/app/components/Viewer/ObjectTree/Views/{ModelCollections.vue → ModelTree.vue} +59 -24
  81. package/app/components/Viewer/Options/AttributeColorBar.vue +4 -2
  82. package/app/components/Viewer/Options/AttributeRangeSelector.vue +4 -2
  83. package/app/components/Viewer/Options/AttributeSelector.vue +7 -9
  84. package/app/components/Viewer/Options/ColorMapList.vue +15 -13
  85. package/app/components/Viewer/Options/ColorMapPicker.vue +4 -4
  86. package/app/components/Viewer/Options/ColorPicker.vue +223 -41
  87. package/app/components/Viewer/Options/ColoringTypeSelector.vue +16 -16
  88. package/app/components/Viewer/Options/ColormapQuickPicker.vue +7 -5
  89. package/app/components/Viewer/Options/OptionsSection.vue +1 -1
  90. package/app/components/Viewer/Options/TextureItem.vue +8 -6
  91. package/app/components/Viewer/Options/TexturesSelector.vue +1 -1
  92. package/app/components/Viewer/OverlappingObjectsPicker.vue +8 -9
  93. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +2 -6
  94. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +12 -16
  95. package/app/components/Viewer/Surface/PolygonsOptions.vue +12 -16
  96. package/app/components/Viewer/Ui.vue +2 -2
  97. package/app/components/Wrapper.vue +1 -4
  98. package/app/components/ZScaling.vue +5 -3
  99. package/app/components/csv-preview/CsvPreviewer.vue +38 -37
  100. package/app/components/csv-preview/CsvSettings.vue +6 -4
  101. package/app/components/csv-preview/CsvTable.vue +1 -1
  102. package/app/composables/batch_style.ts +5 -6
  103. package/app/composables/clipping_planes_widget.ts +73 -181
  104. package/app/composables/clipping_planes_widget_entries.ts +189 -0
  105. package/app/composables/copy_to_clipboard.ts +7 -0
  106. package/app/composables/global_attribute_style.ts +163 -83
  107. package/app/composables/hover_highlight.ts +46 -14
  108. package/app/composables/model_collections.ts +26 -13
  109. package/app/composables/model_components.ts +26 -13
  110. package/app/composables/project_manager.ts +76 -19
  111. package/app/composables/responsive_middle_truncate.ts +13 -13
  112. package/app/composables/stepper_tree.ts +34 -11
  113. package/app/composables/tree_filter.ts +66 -44
  114. package/app/composables/tree_keyboard_nav.ts +25 -11
  115. package/app/composables/tree_scroll.ts +44 -14
  116. package/app/composables/use_adaptive_styles.ts +66 -23
  117. package/app/composables/use_overlapping_picker.ts +66 -16
  118. package/app/composables/use_quick_colormap.ts +16 -5
  119. package/app/composables/virtual_tree.ts +75 -43
  120. package/app/composables/vtk_implicit_plane_widget.d.ts +2 -0
  121. package/app/plugins/auto_store_register.ts +2 -7
  122. package/app/plugins/click_outside_ignore_snackbars.client.ts +39 -0
  123. package/app/stores/app.ts +57 -192
  124. package/app/stores/app_helpers/extension.ts +179 -0
  125. package/app/stores/back.ts +37 -21
  126. package/app/stores/camera_manager.ts +22 -20
  127. package/app/stores/cloud.ts +17 -13
  128. package/app/stores/data.ts +88 -47
  129. package/app/stores/data_helpers/collections.ts +36 -38
  130. package/app/stores/data_helpers/mesh.ts +45 -36
  131. package/app/stores/data_style.ts +50 -28
  132. package/app/stores/feedback.ts +6 -6
  133. package/app/stores/hybrid_viewer.ts +41 -52
  134. package/app/stores/infra.ts +39 -37
  135. package/app/stores/menu.ts +23 -14
  136. package/app/stores/treeview.ts +72 -42
  137. package/app/stores/viewer.ts +39 -27
  138. package/app/utils/attributes.ts +3 -3
  139. package/app/utils/clipping_planes.ts +111 -14
  140. package/app/utils/color_picker.ts +57 -0
  141. package/app/utils/colormap.ts +58 -35
  142. package/app/utils/default_styles/index.ts +2 -2
  143. package/app/utils/default_styles/meshes.ts +107 -13
  144. package/app/utils/default_styles/models.ts +83 -14
  145. package/app/utils/extension.ts +47 -20
  146. package/app/utils/import_workflow.ts +21 -13
  147. package/app/utils/name_cleaner.ts +1 -1
  148. package/app/utils/string.ts +1 -1
  149. package/app/utils/treeview.ts +2 -2
  150. package/internal/database/base_database.ts +7 -3
  151. package/internal/database/database.ts +36 -26
  152. package/internal/database/extended_database.ts +1 -1
  153. package/internal/stores/data_style/mesh/cells/cell.ts +70 -34
  154. package/internal/stores/data_style/mesh/cells/color.ts +12 -6
  155. package/internal/stores/data_style/mesh/cells/common.ts +18 -8
  156. package/internal/stores/data_style/mesh/cells/index.ts +122 -42
  157. package/internal/stores/data_style/mesh/cells/textures.ts +12 -6
  158. package/internal/stores/data_style/mesh/cells/vertex.ts +75 -34
  159. package/internal/stores/data_style/mesh/cells/visibility.ts +15 -4
  160. package/internal/stores/data_style/mesh/edges/color.ts +12 -6
  161. package/internal/stores/data_style/mesh/edges/common.ts +14 -6
  162. package/internal/stores/data_style/mesh/edges/edge.ts +71 -39
  163. package/internal/stores/data_style/mesh/edges/index.ts +117 -42
  164. package/internal/stores/data_style/mesh/edges/vertex.ts +76 -39
  165. package/internal/stores/data_style/mesh/edges/visibility.ts +15 -4
  166. package/internal/stores/data_style/mesh/edges/width.ts +12 -4
  167. package/internal/stores/data_style/mesh/index.ts +30 -11
  168. package/internal/stores/data_style/mesh/points/color.ts +12 -6
  169. package/internal/stores/data_style/mesh/points/common.ts +21 -8
  170. package/internal/stores/data_style/mesh/points/index.ts +101 -50
  171. package/internal/stores/data_style/mesh/points/size.ts +12 -4
  172. package/internal/stores/data_style/mesh/points/vertex.ts +75 -34
  173. package/internal/stores/data_style/mesh/points/visibility.ts +17 -7
  174. package/internal/stores/data_style/mesh/polygons/color.ts +12 -6
  175. package/internal/stores/data_style/mesh/polygons/common.ts +23 -6
  176. package/internal/stores/data_style/mesh/polygons/index.ts +130 -70
  177. package/internal/stores/data_style/mesh/polygons/polygon.ts +77 -43
  178. package/internal/stores/data_style/mesh/polygons/textures.ts +12 -6
  179. package/internal/stores/data_style/mesh/polygons/vertex.ts +79 -39
  180. package/internal/stores/data_style/mesh/polygons/visibility.ts +16 -6
  181. package/internal/stores/data_style/mesh/polyhedra/color.ts +12 -6
  182. package/internal/stores/data_style/mesh/polyhedra/common.ts +14 -6
  183. package/internal/stores/data_style/mesh/polyhedra/index.ts +115 -56
  184. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +80 -39
  185. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +79 -39
  186. package/internal/stores/data_style/mesh/polyhedra/visibility.ts +16 -6
  187. package/internal/stores/data_style/model/blocks/color.ts +43 -13
  188. package/internal/stores/data_style/model/blocks/common.ts +21 -6
  189. package/internal/stores/data_style/model/blocks/index.ts +89 -59
  190. package/internal/stores/data_style/model/blocks/polyhedron.ts +101 -44
  191. package/internal/stores/data_style/model/blocks/vertex.ts +107 -42
  192. package/internal/stores/data_style/model/blocks/visibility.ts +17 -4
  193. package/internal/stores/data_style/model/color.ts +171 -83
  194. package/internal/stores/data_style/model/common.ts +70 -21
  195. package/internal/stores/data_style/model/corners/color.ts +43 -11
  196. package/internal/stores/data_style/model/corners/common.ts +25 -6
  197. package/internal/stores/data_style/model/corners/index.ts +66 -41
  198. package/internal/stores/data_style/model/corners/vertex.ts +105 -74
  199. package/internal/stores/data_style/model/corners/visibility.ts +19 -4
  200. package/internal/stores/data_style/model/edges/common.ts +12 -4
  201. package/internal/stores/data_style/model/edges/index.ts +2 -1
  202. package/internal/stores/data_style/model/edges/visibility.ts +24 -7
  203. package/internal/stores/data_style/model/index.ts +24 -11
  204. package/internal/stores/data_style/model/lines/color.ts +41 -11
  205. package/internal/stores/data_style/model/lines/common.ts +17 -6
  206. package/internal/stores/data_style/model/lines/edge.ts +105 -42
  207. package/internal/stores/data_style/model/lines/index.ts +86 -59
  208. package/internal/stores/data_style/model/lines/vertex.ts +105 -42
  209. package/internal/stores/data_style/model/lines/visibility.ts +17 -4
  210. package/internal/stores/data_style/model/points/common.ts +8 -4
  211. package/internal/stores/data_style/model/points/index.ts +10 -3
  212. package/internal/stores/data_style/model/points/size.ts +12 -4
  213. package/internal/stores/data_style/model/points/visibility.ts +16 -6
  214. package/internal/stores/data_style/model/selection.ts +80 -58
  215. package/internal/stores/data_style/model/surfaces/color.ts +41 -11
  216. package/internal/stores/data_style/model/surfaces/common.ts +23 -6
  217. package/internal/stores/data_style/model/surfaces/index.ts +89 -59
  218. package/internal/stores/data_style/model/surfaces/polygon.ts +107 -67
  219. package/internal/stores/data_style/model/surfaces/vertex.ts +111 -67
  220. package/internal/stores/data_style/model/surfaces/visibility.ts +18 -5
  221. package/internal/stores/data_style/model/visibility.ts +82 -20
  222. package/internal/stores/data_style/state.ts +77 -65
  223. package/internal/stores/hybrid_viewer/brightness.ts +49 -31
  224. package/internal/stores/hybrid_viewer/camera.ts +191 -177
  225. package/internal/stores/hybrid_viewer/camera_animation.ts +11 -10
  226. package/internal/stores/hybrid_viewer/core.ts +64 -0
  227. package/internal/stores/hybrid_viewer/filters.ts +10 -16
  228. package/internal/stores/hybrid_viewer/highlight.ts +91 -130
  229. package/internal/stores/hybrid_viewer/ruler.ts +24 -15
  230. package/internal/stores/hybrid_viewer/scene.ts +96 -117
  231. package/internal/stores/hybrid_viewer/viewport.ts +74 -65
  232. package/internal/stores/hybrid_viewer/vtk_types.ts +13 -29
  233. package/internal/utils/api_fetch.ts +54 -23
  234. package/internal/utils/upload_file.ts +74 -53
  235. package/internal/utils/viewer_call.ts +22 -13
  236. package/internal/utils/ws_client.ts +24 -13
  237. package/nuxt.config.ts +58 -1
  238. package/package.json +20 -8
  239. package/server/api/cloud/extensions/run.post.ts +6 -10
  240. package/server/api/local/app/project_folder_path.post.ts +4 -4
  241. package/server/api/local/app/run_back.post.ts +5 -7
  242. package/server/api/local/app/run_viewer.post.ts +5 -7
  243. package/server/api/local/extensions/kill.post.ts +4 -3
  244. package/server/api/local/extensions/run.post.ts +7 -10
  245. package/server/api/local/extensions/upload.put.ts +44 -54
  246. package/server/api/microservice/app/get_is_app_ready.get.ts +4 -5
  247. package/server/api/microservice/app/set_app_base_url.post.ts +5 -6
  248. package/server/api/microservice/app/set_back_base_url.post.ts +5 -6
  249. package/server/api/microservice/app/set_is_app_ready.post.ts +5 -6
  250. package/server/api/microservice/app/set_viewer_base_url.post.ts +5 -6
  251. package/server/api/microservice/extensions/download.post.ts +5 -4
  252. package/server/api/serverless/run_cloud.post.ts +53 -11
  253. package/server/utils/app_config.ts +29 -22
  254. package/server/utils/cleanup.ts +60 -30
  255. package/server/utils/cloud.ts +9 -8
  256. package/server/utils/extension.ts +23 -9
  257. package/server/utils/microservices.ts +33 -24
  258. package/server/utils/path.ts +4 -4
  259. package/server/utils/scripts.ts +26 -23
  260. package/server/utils/server.ts +2 -2
  261. package/server/utils/server_config.ts +41 -27
  262. package/server/utils/stream.ts +6 -0
  263. package/server/utils/ws_client.ts +42 -8
  264. package/shared/scripts.ts +15 -10
  265. package/shared/utils/call_raw.ts +23 -16
  266. package/shared/utils/call_schema.ts +5 -8
  267. package/shared/utils/fetch_raw.ts +87 -47
  268. package/shared/utils/fetch_schema.ts +6 -9
  269. package/shared/utils/file.ts +8 -2
  270. package/shared/utils/response_handlers/load.ts +26 -11
  271. package/shared/utils/types.ts +9 -9
  272. package/shared/utils/validate_schema.ts +1 -1
  273. package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +0 -276
  274. package/server/types/vendor.d.ts +0 -64
  275. package/server/utils/server_config.js +0 -43
  276. package/shared/utils/call_raw.js +0 -30
  277. package/shared/utils/fetch_raw.js +0 -40
  278. /package/{opengeodeweb_front_schemas.js → .build/opengeodeweb_front_schemas.js} +0 -0
  279. /package/{server → .build/server}/utils/server.js +0 -0
  280. /package/{shared → .build/shared}/app_mode.js +0 -0
  281. /package/{shared → .build/shared}/utils/parse_boolean.js +0 -0
  282. /package/{shared → .build/shared}/utils/types.js +0 -0
@@ -0,0 +1,57 @@
1
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
2
+
3
+ const RGB_MAX = 255;
4
+ const PERCENT_MAX = 100;
5
+
6
+ function parseComponent(val: string, max = RGB_MAX): number {
7
+ if (val.endsWith("%")) {
8
+ return (Number(val.slice(0, -1)) / PERCENT_MAX) * max;
9
+ }
10
+ return Number(val);
11
+ }
12
+
13
+ function parseColorString(colorText: string): RGBAColor | undefined {
14
+ if (colorText === "") {
15
+ return undefined;
16
+ }
17
+
18
+ const numbersMatch = colorText.match(/[\d.]+%?/gu);
19
+ if (!numbersMatch || (numbersMatch.length !== 3 && numbersMatch.length !== 4)) {
20
+ return undefined;
21
+ }
22
+
23
+ const [redText = "", greenText = "", blueText = "", alphaText] = numbersMatch;
24
+ const rawRed = parseComponent(redText);
25
+ const rawGreen = parseComponent(greenText);
26
+ const rawBlue = parseComponent(blueText);
27
+
28
+ const red = Math.min(RGB_MAX, Math.max(0, Math.round(rawRed)));
29
+ const green = Math.min(RGB_MAX, Math.max(0, Math.round(rawGreen)));
30
+ const blue = Math.min(RGB_MAX, Math.max(0, Math.round(rawBlue)));
31
+
32
+ let alpha = 1;
33
+ if (alphaText !== undefined) {
34
+ const rawAlpha = parseComponent(alphaText, 1);
35
+ const calculatedAlpha = rawAlpha > 1 ? rawAlpha / RGB_MAX : rawAlpha;
36
+ const roundedAlpha = Number(calculatedAlpha.toFixed(2));
37
+ alpha = Math.min(1, Math.max(0, roundedAlpha));
38
+ }
39
+
40
+ if (Number.isNaN(red) || Number.isNaN(green) || Number.isNaN(blue) || Number.isNaN(alpha)) {
41
+ return undefined;
42
+ }
43
+
44
+ return { red, green, blue, alpha };
45
+ }
46
+
47
+ function formatColorString(color: RGBAColor, mode: string): string {
48
+ const { red, green, blue, alpha } = color;
49
+ const roundRed = Math.round(red);
50
+ const roundGreen = Math.round(green);
51
+ const roundBlue = Math.round(blue);
52
+ return mode === "rgb"
53
+ ? `rgb(${roundRed}, ${roundGreen}, ${roundBlue})`
54
+ : `rgba(${roundRed}, ${roundGreen}, ${roundBlue}, ${alpha})`;
55
+ }
56
+
57
+ export { parseColorString, formatColorString };
@@ -3,46 +3,43 @@ import colormaps from "@ogw_front/assets/colormaps.json";
3
3
 
4
4
  import { newInstance as vtkColorTransferFunction } from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction";
5
5
 
6
- type ColormapPreset = (typeof colormaps)[number]["Children"][number];
6
+ interface ColormapPreset {
7
+ readonly Name: string;
8
+ readonly RGBPoints: readonly number[];
9
+ }
10
+
11
+ interface ColormapCategory {
12
+ readonly Name: string;
13
+ readonly Children: readonly ColormapPreset[];
14
+ }
15
+
16
+ const typedColormaps = colormaps as readonly ColormapCategory[];
7
17
 
8
18
  function getPresetByName(presetName: string): ColormapPreset | undefined {
9
- return colormaps
10
- .flatMap((category) => category.Children)
11
- .find((preset) => preset.Name === presetName);
19
+ return typedColormaps
20
+ .flatMap((category: ColormapCategory) => category.Children)
21
+ .find((preset: ColormapPreset) => preset.Name === presetName);
12
22
  }
13
23
 
14
- function getRGBPointsFromPreset(presetName: string): number[] {
24
+ function getRGBPointsFromPreset(presetName: string): readonly number[] {
15
25
  return getPresetByName(presetName)?.RGBPoints ?? [];
16
26
  }
17
27
 
18
- function getPresetsWithCurrentAtTop(presetName: string) {
28
+ function getPresetsWithCurrentAtTop(
29
+ presetName: string,
30
+ ): readonly (ColormapPreset | ColormapCategory)[] {
19
31
  const currentPreset = getPresetByName(presetName);
20
- return [currentPreset, ...colormaps].filter((preset): preset is NonNullable<typeof preset> =>
21
- Boolean(preset),
32
+ return [currentPreset, ...typedColormaps].filter(
33
+ (preset: ColormapPreset | ColormapCategory | undefined): preset is NonNullable<typeof preset> =>
34
+ Boolean(preset),
22
35
  );
23
36
  }
24
37
 
25
- function drawCanvasForPreset(
26
- presetName: string,
27
- canvas: HTMLCanvasElement | undefined | null,
28
- ): void {
29
- if (!canvas) {
30
- return;
31
- }
32
- const rgbPoints = getRGBPointsFromPreset(presetName);
33
- if (!rgbPoints || rgbPoints.length === 0) {
34
- return;
35
- }
36
- const ctx = canvas.getContext("2d");
37
- if (!ctx) {
38
- return;
39
- }
40
- const { height, width } = canvas;
41
- const lut = vtkColorTransferFunction();
42
-
43
- const LAST_POINT_OFFSET = 4;
44
- const THREE = 3;
38
+ const LAST_POINT_OFFSET = 4;
39
+ const THREE = 3;
45
40
 
41
+ function buildColorTable(rgbPoints: readonly number[], width: number): Float32Array {
42
+ const lut = vtkColorTransferFunction();
46
43
  for (let pointIdx = 0; pointIdx < rgbPoints.length; pointIdx += 4) {
47
44
  lut.addRGBPoint(
48
45
  rgbPoints[pointIdx] ?? 0,
@@ -51,13 +48,17 @@ function drawCanvasForPreset(
51
48
  rgbPoints[pointIdx + THREE] ?? 0,
52
49
  );
53
50
  }
54
- const table = lut.getUint8Table(
55
- rgbPoints[0] ?? 0,
56
- rgbPoints.at(-LAST_POINT_OFFSET) ?? 0,
57
- width,
58
- true,
59
- );
60
- const imageData = ctx.createImageData(width, height);
51
+ return lut.getUint8Table(rgbPoints[0] ?? 0, rgbPoints.at(-LAST_POINT_OFFSET) ?? 0, width, true);
52
+ }
53
+
54
+ function fillImageDataFromTable(
55
+ // ImageData can't satisfy prefer-readonly-parameter-types since lib.dom.d.ts types are inherently mutable, so this finding is left unfixed (same pattern as app/plugins/auto_store_register.ts).
56
+ imageData: ImageData,
57
+ // Float32Array's numeric index signature is inherently mutable and can't satisfy prefer-readonly-parameter-types, so this finding is left unfixed (same pattern as app/plugins/auto_store_register.ts).
58
+ table: Float32Array,
59
+ width: number,
60
+ height: number,
61
+ ): void {
61
62
  for (let xCoord = 0; xCoord < width; xCoord += 1) {
62
63
  const alpha = table[xCoord * 4 + THREE] ?? 0;
63
64
  const blue = table[xCoord * 4 + 2] ?? 0;
@@ -71,6 +72,28 @@ function drawCanvasForPreset(
71
72
  imageData.data[pixelIdx + THREE] = alpha;
72
73
  }
73
74
  }
75
+ }
76
+
77
+ function drawCanvasForPreset(
78
+ presetName: string,
79
+ // HTMLCanvasElement can't satisfy prefer-readonly-parameter-types since lib.dom.d.ts types are inherently mutable, so this finding is left unfixed (same pattern as app/plugins/auto_store_register.ts).
80
+ canvas: HTMLCanvasElement | undefined | null,
81
+ ): void {
82
+ if (!canvas) {
83
+ return;
84
+ }
85
+ const rgbPoints = getRGBPointsFromPreset(presetName);
86
+ if (rgbPoints.length === 0) {
87
+ return;
88
+ }
89
+ const ctx = canvas.getContext("2d");
90
+ if (!ctx) {
91
+ return;
92
+ }
93
+ const { height, width } = canvas;
94
+ const table = buildColorTable(rgbPoints, width);
95
+ const imageData = ctx.createImageData(width, height);
96
+ fillImageDataFromTable(imageData, table, width, height);
74
97
  ctx.putImageData(imageData, 0, 0);
75
98
  }
76
99
 
@@ -15,7 +15,7 @@ import {
15
15
  surfaceDefaultStyle,
16
16
  } from "./meshes";
17
17
 
18
- function default_styles() {
18
+ function default_styles(): Record<string, unknown> {
19
19
  return {
20
20
  BRep: brepDefaultStyle(),
21
21
  CrossSection: crossSectionDefaultStyle(),
@@ -45,7 +45,7 @@ function default_styles() {
45
45
  };
46
46
  }
47
47
 
48
- function getDefaultStyle(type: string) {
48
+ function getDefaultStyle(type: string): unknown {
49
49
  const styles: Record<string, unknown> = default_styles();
50
50
  return styles[type];
51
51
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ type AttributeConfig,
2
3
  CELLS_DEFAULT_COLOR,
3
4
  CELLS_DEFAULT_VISIBILITY,
4
5
  EDGES_DEFAULT_COLOR,
@@ -12,19 +13,112 @@ import {
12
13
  POLYGONS_DEFAULT_VISIBILITY,
13
14
  POLYHEDRA_DEFAULT_COLOR,
14
15
  POLYHEDRA_DEFAULT_VISIBILITY,
16
+ type RGBAColor,
15
17
  } from "./constants";
16
- // oxlint-disable-next-line eslint/no-duplicate-imports
17
- import type { AttributeConfig, RGBAColor } from "./constants";
18
18
 
19
19
  function emptyAttributeConfig(): AttributeConfig {
20
20
  return { name: undefined, storedConfigs: {} };
21
21
  }
22
22
 
23
+ interface MeshComponentColoring {
24
+ active: string;
25
+ constant: RGBAColor;
26
+ vertex: AttributeConfig;
27
+ }
28
+
29
+ interface MeshEdgesColoring extends MeshComponentColoring {
30
+ edge: AttributeConfig;
31
+ }
32
+
33
+ interface MeshCellsColoring extends MeshComponentColoring {
34
+ cell: AttributeConfig;
35
+ // oxlint-disable-next-line unicorn/no-null
36
+ textures: null;
37
+ }
38
+
39
+ interface MeshPolygonsColoring extends MeshComponentColoring {
40
+ // oxlint-disable-next-line unicorn/no-null
41
+ textures: null;
42
+ polygon: AttributeConfig;
43
+ }
44
+
45
+ interface MeshPolyhedraColoring extends MeshComponentColoring {
46
+ polyhedron: AttributeConfig;
47
+ }
48
+
49
+ interface MeshPointsStyle {
50
+ visibility: boolean;
51
+ coloring: MeshComponentColoring;
52
+ size: number;
53
+ }
54
+
55
+ interface MeshEdgesStyle {
56
+ visibility: boolean;
57
+ coloring: MeshEdgesColoring;
58
+ width: number;
59
+ }
60
+
61
+ interface MeshCellsStyle {
62
+ visibility: boolean;
63
+ coloring: MeshCellsColoring;
64
+ }
65
+
66
+ interface MeshPolygonsStyle {
67
+ visibility: boolean;
68
+ coloring: MeshPolygonsColoring;
69
+ }
70
+
71
+ interface MeshPolyhedraStyle {
72
+ visibility: boolean;
73
+ coloring: MeshPolyhedraColoring;
74
+ }
75
+
76
+ interface PointSetStyle {
77
+ visibility: boolean;
78
+ points: MeshPointsStyle;
79
+ }
80
+
81
+ interface EdgedCurveStyle {
82
+ visibility: boolean;
83
+ points: MeshPointsStyle;
84
+ edges: MeshEdgesStyle;
85
+ }
86
+
87
+ interface Grid2dStyle {
88
+ visibility: boolean;
89
+ points: MeshPointsStyle;
90
+ edges: MeshEdgesStyle;
91
+ cells: MeshCellsStyle;
92
+ }
93
+
94
+ interface Grid3dStyle {
95
+ visibility: boolean;
96
+ points: MeshPointsStyle;
97
+ edges: MeshEdgesStyle;
98
+ cells: MeshCellsStyle;
99
+ polyhedra: MeshPolyhedraStyle;
100
+ }
101
+
102
+ interface SurfaceStyle {
103
+ visibility: boolean;
104
+ points: MeshPointsStyle;
105
+ edges: MeshEdgesStyle;
106
+ polygons: MeshPolygonsStyle;
107
+ }
108
+
109
+ interface SolidStyle {
110
+ visibility: boolean;
111
+ points: MeshPointsStyle;
112
+ edges: MeshEdgesStyle;
113
+ polygons: MeshPolygonsStyle;
114
+ polyhedra: MeshPolyhedraStyle;
115
+ }
116
+
23
117
  function meshPointsDefaultStyle(
24
118
  visibility: boolean = POINTS_DEFAULT_VISIBILITY,
25
119
  size: number = POINTS_DEFAULT_SIZE,
26
120
  constant: RGBAColor = POINTS_DEFAULT_COLOR,
27
- ) {
121
+ ): MeshPointsStyle {
28
122
  return {
29
123
  visibility,
30
124
  coloring: {
@@ -40,7 +134,7 @@ function meshEdgesDefaultStyle(
40
134
  visibility: boolean = EDGES_DEFAULT_VISIBILITY,
41
135
  width: number = EDGES_DEFAULT_WIDTH,
42
136
  constant: RGBAColor = EDGES_DEFAULT_COLOR,
43
- ) {
137
+ ): MeshEdgesStyle {
44
138
  return {
45
139
  visibility,
46
140
  coloring: {
@@ -56,7 +150,7 @@ function meshEdgesDefaultStyle(
56
150
  function meshCellsDefaultStyle(
57
151
  visibility: boolean = CELLS_DEFAULT_VISIBILITY,
58
152
  constant: RGBAColor = CELLS_DEFAULT_COLOR,
59
- ) {
153
+ ): MeshCellsStyle {
60
154
  return {
61
155
  visibility,
62
156
  coloring: {
@@ -73,7 +167,7 @@ function meshCellsDefaultStyle(
73
167
  function meshPolygonsDefaultStyle(
74
168
  visibility: boolean = POLYGONS_DEFAULT_VISIBILITY,
75
169
  constant: RGBAColor = POLYGONS_DEFAULT_COLOR,
76
- ) {
170
+ ): MeshPolygonsStyle {
77
171
  return {
78
172
  visibility,
79
173
  coloring: {
@@ -90,7 +184,7 @@ function meshPolygonsDefaultStyle(
90
184
  function meshPolyhedraDefaultStyle(
91
185
  visibility: boolean = POLYHEDRA_DEFAULT_VISIBILITY,
92
186
  constant: RGBAColor = POLYHEDRA_DEFAULT_COLOR,
93
- ) {
187
+ ): MeshPolyhedraStyle {
94
188
  return {
95
189
  visibility,
96
190
  coloring: {
@@ -102,14 +196,14 @@ function meshPolyhedraDefaultStyle(
102
196
  };
103
197
  }
104
198
 
105
- function pointSetDefaultStyle() {
199
+ function pointSetDefaultStyle(): PointSetStyle {
106
200
  return {
107
201
  visibility: true,
108
202
  points: meshPointsDefaultStyle(),
109
203
  };
110
204
  }
111
205
 
112
- function edgedCurveDefaultStyle() {
206
+ function edgedCurveDefaultStyle(): EdgedCurveStyle {
113
207
  return {
114
208
  visibility: true,
115
209
  points: meshPointsDefaultStyle(),
@@ -117,7 +211,7 @@ function edgedCurveDefaultStyle() {
117
211
  };
118
212
  }
119
213
 
120
- function grid2dDefaultStyle() {
214
+ function grid2dDefaultStyle(): Grid2dStyle {
121
215
  return {
122
216
  visibility: true,
123
217
  points: meshPointsDefaultStyle(false),
@@ -126,7 +220,7 @@ function grid2dDefaultStyle() {
126
220
  };
127
221
  }
128
222
 
129
- function grid3dDefaultStyle() {
223
+ function grid3dDefaultStyle(): Grid3dStyle {
130
224
  return {
131
225
  visibility: true,
132
226
  points: meshPointsDefaultStyle(false),
@@ -136,7 +230,7 @@ function grid3dDefaultStyle() {
136
230
  };
137
231
  }
138
232
 
139
- function surfaceDefaultStyle() {
233
+ function surfaceDefaultStyle(): SurfaceStyle {
140
234
  return {
141
235
  visibility: true,
142
236
  points: meshPointsDefaultStyle(false),
@@ -145,7 +239,7 @@ function surfaceDefaultStyle() {
145
239
  };
146
240
  }
147
241
 
148
- function solidDefaultStyle() {
242
+ function solidDefaultStyle(): SolidStyle {
149
243
  return {
150
244
  visibility: true,
151
245
  points: meshPointsDefaultStyle(false),
@@ -1,4 +1,5 @@
1
1
  import {
2
+ type AttributeConfig,
2
3
  BLOCKS_DEFAULT_ACTIVE_COLORING,
3
4
  BLOCKS_DEFAULT_COLOR,
4
5
  BLOCKS_DEFAULT_VISIBILITY,
@@ -14,21 +15,89 @@ import {
14
15
  MODEL_DEFAULT_COLOR,
15
16
  POINTS_DEFAULT_SIZE,
16
17
  POINTS_DEFAULT_VISIBILITY,
18
+ type RGBAColor,
17
19
  SURFACES_DEFAULT_ACTIVE_COLORING,
18
20
  SURFACES_DEFAULT_COLOR,
19
21
  SURFACES_DEFAULT_VISIBILITY,
20
22
  } from "./constants";
21
- // oxlint-disable-next-line eslint/no-duplicate-imports
22
- import type { AttributeConfig, RGBAColor } from "./constants";
23
23
 
24
24
  function emptyAttributeConfig(): AttributeConfig {
25
25
  return { name: undefined, storedConfigs: {} };
26
26
  }
27
27
 
28
+ interface ModelComponentColoring {
29
+ active: string;
30
+ constant: RGBAColor;
31
+ vertex: AttributeConfig;
32
+ }
33
+
34
+ interface ModelLinesColoring extends ModelComponentColoring {
35
+ edge: AttributeConfig;
36
+ }
37
+
38
+ interface ModelSurfacesColoring extends ModelComponentColoring {
39
+ polygon: AttributeConfig;
40
+ }
41
+
42
+ interface ModelBlocksColoring extends ModelComponentColoring {
43
+ polyhedron: AttributeConfig;
44
+ }
45
+
46
+ interface ModelCornersStyle {
47
+ visibility: boolean;
48
+ coloring: ModelComponentColoring;
49
+ }
50
+
51
+ interface ModelLinesStyle {
52
+ visibility: boolean;
53
+ coloring: ModelLinesColoring;
54
+ }
55
+
56
+ interface ModelSurfacesStyle {
57
+ visibility: boolean;
58
+ coloring: ModelSurfacesColoring;
59
+ }
60
+
61
+ interface ModelBlocksStyle {
62
+ visibility: boolean;
63
+ coloring: ModelBlocksColoring;
64
+ }
65
+
66
+ interface ModelPointsStyle {
67
+ visibility: boolean;
68
+ size: number;
69
+ }
70
+
71
+ interface ModelEdgesStyle {
72
+ visibility: boolean;
73
+ width: number;
74
+ }
75
+
76
+ interface ModelWithBlocksStyle {
77
+ visibility: boolean;
78
+ coloring: { active: string; constant: RGBAColor };
79
+ corners: ModelCornersStyle;
80
+ lines: ModelLinesStyle;
81
+ surfaces: ModelSurfacesStyle;
82
+ blocks: ModelBlocksStyle;
83
+ points: ModelPointsStyle;
84
+ edges: ModelEdgesStyle;
85
+ }
86
+
87
+ interface ModelWithoutBlocksStyle {
88
+ visibility: boolean;
89
+ coloring: { active: string; constant: RGBAColor };
90
+ corners: ModelCornersStyle;
91
+ lines: ModelLinesStyle;
92
+ surfaces: ModelSurfacesStyle;
93
+ points: ModelPointsStyle;
94
+ edges: ModelEdgesStyle;
95
+ }
96
+
28
97
  function modelCornersDefaultStyle(
29
98
  visibility: boolean = CORNERS_DEFAULT_VISIBILITY,
30
99
  constant: RGBAColor = CORNERS_DEFAULT_COLOR,
31
- ) {
100
+ ): ModelCornersStyle {
32
101
  return {
33
102
  visibility,
34
103
  coloring: {
@@ -42,7 +111,7 @@ function modelCornersDefaultStyle(
42
111
  function modelLinesDefaultStyle(
43
112
  visibility: boolean = LINES_DEFAULT_VISIBILITY,
44
113
  constant: RGBAColor = LINES_DEFAULT_COLOR,
45
- ) {
114
+ ): ModelLinesStyle {
46
115
  return {
47
116
  visibility,
48
117
  coloring: {
@@ -57,7 +126,7 @@ function modelLinesDefaultStyle(
57
126
  function modelSurfacesDefaultStyle(
58
127
  visibility: boolean = SURFACES_DEFAULT_VISIBILITY,
59
128
  constant: RGBAColor = SURFACES_DEFAULT_COLOR,
60
- ) {
129
+ ): ModelSurfacesStyle {
61
130
  return {
62
131
  visibility,
63
132
  coloring: {
@@ -72,7 +141,7 @@ function modelSurfacesDefaultStyle(
72
141
  function modelBlocksDefaultStyle(
73
142
  visibility: boolean = BLOCKS_DEFAULT_VISIBILITY,
74
143
  constant: RGBAColor = BLOCKS_DEFAULT_COLOR,
75
- ) {
144
+ ): ModelBlocksStyle {
76
145
  return {
77
146
  visibility,
78
147
  coloring: {
@@ -87,14 +156,14 @@ function modelBlocksDefaultStyle(
87
156
  function modelPointsDefaultStyle(
88
157
  visibility: boolean = POINTS_DEFAULT_VISIBILITY,
89
158
  size: number = POINTS_DEFAULT_SIZE,
90
- ) {
159
+ ): ModelPointsStyle {
91
160
  return { visibility, size };
92
161
  }
93
162
 
94
163
  function modelEdgesDefaultStyle(
95
164
  visibility: boolean = EDGES_DEFAULT_VISIBILITY,
96
165
  width: number = EDGES_DEFAULT_WIDTH,
97
- ) {
166
+ ): ModelEdgesStyle {
98
167
  return { visibility, width };
99
168
  }
100
169
 
@@ -105,7 +174,7 @@ const DEFAULT_MODEL_COMPONENT_TYPE_STYLES = {
105
174
  Block: modelBlocksDefaultStyle(),
106
175
  };
107
176
 
108
- function brepDefaultStyle() {
177
+ function brepDefaultStyle(): ModelWithBlocksStyle {
109
178
  return {
110
179
  visibility: true,
111
180
  coloring: {
@@ -121,7 +190,7 @@ function brepDefaultStyle() {
121
190
  };
122
191
  }
123
192
 
124
- function crossSectionDefaultStyle() {
193
+ function crossSectionDefaultStyle(): ModelWithoutBlocksStyle {
125
194
  return {
126
195
  visibility: true,
127
196
  coloring: {
@@ -136,7 +205,7 @@ function crossSectionDefaultStyle() {
136
205
  };
137
206
  }
138
207
 
139
- function structuralModelDefaultStyle() {
208
+ function structuralModelDefaultStyle(): ModelWithBlocksStyle {
140
209
  return {
141
210
  visibility: true,
142
211
  coloring: {
@@ -152,7 +221,7 @@ function structuralModelDefaultStyle() {
152
221
  };
153
222
  }
154
223
 
155
- function sectionDefaultStyle() {
224
+ function sectionDefaultStyle(): ModelWithoutBlocksStyle {
156
225
  return {
157
226
  visibility: true,
158
227
  coloring: {
@@ -167,7 +236,7 @@ function sectionDefaultStyle() {
167
236
  };
168
237
  }
169
238
 
170
- function implicitCrossSectionDefaultStyle() {
239
+ function implicitCrossSectionDefaultStyle(): ModelWithoutBlocksStyle {
171
240
  return {
172
241
  visibility: true,
173
242
  coloring: {
@@ -182,7 +251,7 @@ function implicitCrossSectionDefaultStyle() {
182
251
  };
183
252
  }
184
253
 
185
- function implicitStructuralModelDefaultStyle() {
254
+ function implicitStructuralModelDefaultStyle(): ModelWithBlocksStyle {
186
255
  return {
187
256
  visibility: true,
188
257
  coloring: {