@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.
- package/{server → .build/server}/utils/app_config.js +10 -9
- package/{server → .build/server}/utils/cleanup.js +31 -17
- package/{server → .build/server}/utils/cloud.js +1 -4
- package/{server → .build/server}/utils/microservices.js +21 -9
- package/{server → .build/server}/utils/path.js +4 -4
- package/{server → .build/server}/utils/scripts.js +9 -9
- package/.build/server/utils/server_config.js +51 -0
- package/.build/server/utils/stream.js +6 -0
- package/{server → .build/server}/utils/ws_client.js +18 -3
- package/{shared → .build/shared}/scripts.js +10 -10
- package/.build/shared/utils/call_raw.js +31 -0
- package/{shared → .build/shared}/utils/call_schema.js +2 -2
- package/.build/shared/utils/fetch_raw.js +52 -0
- package/{shared → .build/shared}/utils/fetch_schema.js +2 -2
- package/{shared → .build/shared}/utils/file.js +3 -1
- package/{shared → .build/shared}/utils/response_handlers/load.js +10 -7
- package/{shared → .build/shared}/utils/validate_schema.js +1 -1
- package/app/components/ActionButton.vue +6 -6
- package/app/components/CameraManager/List.vue +5 -5
- package/app/components/CameraManager/Saver.vue +3 -5
- package/app/components/CameraManager.vue +6 -4
- package/app/components/CameraOrientation.vue +12 -12
- package/app/components/ClippingPlaneCard.vue +4 -2
- package/app/components/ClippingPlanes.vue +8 -8
- package/app/components/CrsSelector.vue +9 -10
- package/app/components/DeleteDialog.vue +4 -2
- package/app/components/DragAndDrop.vue +10 -12
- package/app/components/DragAndDropInternal/DragAndDropInline.vue +4 -2
- package/app/components/ExtensionSelector.vue +4 -4
- package/app/components/FeedBack/ErrorBanner.vue +3 -1
- package/app/components/FeedBack/Snackers.vue +4 -3
- package/app/components/FileSelector.vue +10 -8
- package/app/components/FileUploader.vue +11 -11
- package/app/components/GlassCard.vue +1 -1
- package/app/components/HybridRenderingView.vue +7 -5
- package/app/components/HybridViewerTooltip.vue +7 -7
- package/app/components/Launcher.vue +1 -1
- package/app/components/Loading/EcoMessages.vue +9 -3
- package/app/components/Loading.vue +2 -2
- package/app/components/MissingFilesSelector.vue +12 -10
- package/app/components/ObjectSelector.vue +10 -9
- package/app/components/PackagesVersions.vue +6 -5
- package/app/components/Recaptcha.vue +3 -3
- package/app/components/RemoteRenderingView.vue +6 -7
- package/app/components/Ruler.vue +3 -3
- package/app/components/Screenshot.vue +6 -6
- package/app/components/SearchBar.vue +4 -2
- package/app/components/ShrinkFilter.vue +7 -7
- package/app/components/Step.vue +6 -5
- package/app/components/Stepper.vue +4 -3
- package/app/components/ToolPanel.vue +6 -3
- package/app/components/ViewToolbar.vue +25 -28
- package/app/components/Viewer/ContextMenu/CenterButton.vue +7 -5
- package/app/components/Viewer/ContextMenu/CircularItems.vue +3 -3
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +22 -19
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -8
- package/app/components/Viewer/ContextMenu/InfoCard.vue +11 -12
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +13 -17
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -16
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +8 -12
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +11 -15
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +11 -15
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +53 -23
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +1 -3
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +67 -38
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +31 -15
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +2 -3
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +6 -6
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +69 -38
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +64 -46
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +13 -9
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +5 -5
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +10 -10
- package/app/components/Viewer/ObjectTree/Box.vue +6 -4
- package/app/components/Viewer/ObjectTree/Layout.vue +23 -21
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +14 -14
- package/app/components/Viewer/ObjectTree/Views/{ModelCollections.vue → ModelTree.vue} +59 -24
- package/app/components/Viewer/Options/AttributeColorBar.vue +4 -2
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +4 -2
- package/app/components/Viewer/Options/AttributeSelector.vue +7 -9
- package/app/components/Viewer/Options/ColorMapList.vue +15 -13
- package/app/components/Viewer/Options/ColorMapPicker.vue +4 -4
- package/app/components/Viewer/Options/ColorPicker.vue +223 -41
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +16 -16
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +7 -5
- package/app/components/Viewer/Options/OptionsSection.vue +1 -1
- package/app/components/Viewer/Options/TextureItem.vue +8 -6
- package/app/components/Viewer/Options/TexturesSelector.vue +1 -1
- package/app/components/Viewer/OverlappingObjectsPicker.vue +8 -9
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +2 -6
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +12 -16
- package/app/components/Viewer/Surface/PolygonsOptions.vue +12 -16
- package/app/components/Viewer/Ui.vue +2 -2
- package/app/components/Wrapper.vue +1 -4
- package/app/components/ZScaling.vue +5 -3
- package/app/components/csv-preview/CsvPreviewer.vue +38 -37
- package/app/components/csv-preview/CsvSettings.vue +6 -4
- package/app/components/csv-preview/CsvTable.vue +1 -1
- package/app/composables/batch_style.ts +5 -6
- package/app/composables/clipping_planes_widget.ts +73 -181
- package/app/composables/clipping_planes_widget_entries.ts +189 -0
- package/app/composables/copy_to_clipboard.ts +7 -0
- package/app/composables/global_attribute_style.ts +163 -83
- package/app/composables/hover_highlight.ts +46 -14
- package/app/composables/model_collections.ts +26 -13
- package/app/composables/model_components.ts +26 -13
- package/app/composables/project_manager.ts +76 -19
- package/app/composables/responsive_middle_truncate.ts +13 -13
- package/app/composables/stepper_tree.ts +34 -11
- package/app/composables/tree_filter.ts +66 -44
- package/app/composables/tree_keyboard_nav.ts +25 -11
- package/app/composables/tree_scroll.ts +44 -14
- package/app/composables/use_adaptive_styles.ts +66 -23
- package/app/composables/use_overlapping_picker.ts +66 -16
- package/app/composables/use_quick_colormap.ts +16 -5
- package/app/composables/virtual_tree.ts +75 -43
- package/app/composables/vtk_implicit_plane_widget.d.ts +2 -0
- package/app/plugins/auto_store_register.ts +2 -7
- package/app/plugins/click_outside_ignore_snackbars.client.ts +39 -0
- package/app/stores/app.ts +57 -192
- package/app/stores/app_helpers/extension.ts +179 -0
- package/app/stores/back.ts +37 -21
- package/app/stores/camera_manager.ts +22 -20
- package/app/stores/cloud.ts +17 -13
- package/app/stores/data.ts +88 -47
- package/app/stores/data_helpers/collections.ts +36 -38
- package/app/stores/data_helpers/mesh.ts +45 -36
- package/app/stores/data_style.ts +50 -28
- package/app/stores/feedback.ts +6 -6
- package/app/stores/hybrid_viewer.ts +41 -52
- package/app/stores/infra.ts +39 -37
- package/app/stores/menu.ts +23 -14
- package/app/stores/treeview.ts +72 -42
- package/app/stores/viewer.ts +39 -27
- package/app/utils/attributes.ts +3 -3
- package/app/utils/clipping_planes.ts +111 -14
- package/app/utils/color_picker.ts +57 -0
- package/app/utils/colormap.ts +58 -35
- package/app/utils/default_styles/index.ts +2 -2
- package/app/utils/default_styles/meshes.ts +107 -13
- package/app/utils/default_styles/models.ts +83 -14
- package/app/utils/extension.ts +47 -20
- package/app/utils/import_workflow.ts +21 -13
- package/app/utils/name_cleaner.ts +1 -1
- package/app/utils/string.ts +1 -1
- package/app/utils/treeview.ts +2 -2
- package/internal/database/base_database.ts +7 -3
- package/internal/database/database.ts +36 -26
- package/internal/database/extended_database.ts +1 -1
- package/internal/stores/data_style/mesh/cells/cell.ts +70 -34
- package/internal/stores/data_style/mesh/cells/color.ts +12 -6
- package/internal/stores/data_style/mesh/cells/common.ts +18 -8
- package/internal/stores/data_style/mesh/cells/index.ts +122 -42
- package/internal/stores/data_style/mesh/cells/textures.ts +12 -6
- package/internal/stores/data_style/mesh/cells/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/cells/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/color.ts +12 -6
- package/internal/stores/data_style/mesh/edges/common.ts +14 -6
- package/internal/stores/data_style/mesh/edges/edge.ts +71 -39
- package/internal/stores/data_style/mesh/edges/index.ts +117 -42
- package/internal/stores/data_style/mesh/edges/vertex.ts +76 -39
- package/internal/stores/data_style/mesh/edges/visibility.ts +15 -4
- package/internal/stores/data_style/mesh/edges/width.ts +12 -4
- package/internal/stores/data_style/mesh/index.ts +30 -11
- package/internal/stores/data_style/mesh/points/color.ts +12 -6
- package/internal/stores/data_style/mesh/points/common.ts +21 -8
- package/internal/stores/data_style/mesh/points/index.ts +101 -50
- package/internal/stores/data_style/mesh/points/size.ts +12 -4
- package/internal/stores/data_style/mesh/points/vertex.ts +75 -34
- package/internal/stores/data_style/mesh/points/visibility.ts +17 -7
- package/internal/stores/data_style/mesh/polygons/color.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/common.ts +23 -6
- package/internal/stores/data_style/mesh/polygons/index.ts +130 -70
- package/internal/stores/data_style/mesh/polygons/polygon.ts +77 -43
- package/internal/stores/data_style/mesh/polygons/textures.ts +12 -6
- package/internal/stores/data_style/mesh/polygons/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polygons/visibility.ts +16 -6
- package/internal/stores/data_style/mesh/polyhedra/color.ts +12 -6
- package/internal/stores/data_style/mesh/polyhedra/common.ts +14 -6
- package/internal/stores/data_style/mesh/polyhedra/index.ts +115 -56
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +80 -39
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +79 -39
- package/internal/stores/data_style/mesh/polyhedra/visibility.ts +16 -6
- package/internal/stores/data_style/model/blocks/color.ts +43 -13
- package/internal/stores/data_style/model/blocks/common.ts +21 -6
- package/internal/stores/data_style/model/blocks/index.ts +89 -59
- package/internal/stores/data_style/model/blocks/polyhedron.ts +101 -44
- package/internal/stores/data_style/model/blocks/vertex.ts +107 -42
- package/internal/stores/data_style/model/blocks/visibility.ts +17 -4
- package/internal/stores/data_style/model/color.ts +171 -83
- package/internal/stores/data_style/model/common.ts +70 -21
- package/internal/stores/data_style/model/corners/color.ts +43 -11
- package/internal/stores/data_style/model/corners/common.ts +25 -6
- package/internal/stores/data_style/model/corners/index.ts +66 -41
- package/internal/stores/data_style/model/corners/vertex.ts +105 -74
- package/internal/stores/data_style/model/corners/visibility.ts +19 -4
- package/internal/stores/data_style/model/edges/common.ts +12 -4
- package/internal/stores/data_style/model/edges/index.ts +2 -1
- package/internal/stores/data_style/model/edges/visibility.ts +24 -7
- package/internal/stores/data_style/model/index.ts +24 -11
- package/internal/stores/data_style/model/lines/color.ts +41 -11
- package/internal/stores/data_style/model/lines/common.ts +17 -6
- package/internal/stores/data_style/model/lines/edge.ts +105 -42
- package/internal/stores/data_style/model/lines/index.ts +86 -59
- package/internal/stores/data_style/model/lines/vertex.ts +105 -42
- package/internal/stores/data_style/model/lines/visibility.ts +17 -4
- package/internal/stores/data_style/model/points/common.ts +8 -4
- package/internal/stores/data_style/model/points/index.ts +10 -3
- package/internal/stores/data_style/model/points/size.ts +12 -4
- package/internal/stores/data_style/model/points/visibility.ts +16 -6
- package/internal/stores/data_style/model/selection.ts +80 -58
- package/internal/stores/data_style/model/surfaces/color.ts +41 -11
- package/internal/stores/data_style/model/surfaces/common.ts +23 -6
- package/internal/stores/data_style/model/surfaces/index.ts +89 -59
- package/internal/stores/data_style/model/surfaces/polygon.ts +107 -67
- package/internal/stores/data_style/model/surfaces/vertex.ts +111 -67
- package/internal/stores/data_style/model/surfaces/visibility.ts +18 -5
- package/internal/stores/data_style/model/visibility.ts +82 -20
- package/internal/stores/data_style/state.ts +77 -65
- package/internal/stores/hybrid_viewer/brightness.ts +49 -31
- package/internal/stores/hybrid_viewer/camera.ts +191 -177
- package/internal/stores/hybrid_viewer/camera_animation.ts +11 -10
- package/internal/stores/hybrid_viewer/core.ts +64 -0
- package/internal/stores/hybrid_viewer/filters.ts +10 -16
- package/internal/stores/hybrid_viewer/highlight.ts +91 -130
- package/internal/stores/hybrid_viewer/ruler.ts +24 -15
- package/internal/stores/hybrid_viewer/scene.ts +96 -117
- package/internal/stores/hybrid_viewer/viewport.ts +74 -65
- package/internal/stores/hybrid_viewer/vtk_types.ts +13 -29
- package/internal/utils/api_fetch.ts +54 -23
- package/internal/utils/upload_file.ts +74 -53
- package/internal/utils/viewer_call.ts +22 -13
- package/internal/utils/ws_client.ts +24 -13
- package/nuxt.config.ts +58 -1
- package/package.json +20 -8
- package/server/api/cloud/extensions/run.post.ts +6 -10
- package/server/api/local/app/project_folder_path.post.ts +4 -4
- package/server/api/local/app/run_back.post.ts +5 -7
- package/server/api/local/app/run_viewer.post.ts +5 -7
- package/server/api/local/extensions/kill.post.ts +4 -3
- package/server/api/local/extensions/run.post.ts +7 -10
- package/server/api/local/extensions/upload.put.ts +44 -54
- package/server/api/microservice/app/get_is_app_ready.get.ts +4 -5
- package/server/api/microservice/app/set_app_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_back_base_url.post.ts +5 -6
- package/server/api/microservice/app/set_is_app_ready.post.ts +5 -6
- package/server/api/microservice/app/set_viewer_base_url.post.ts +5 -6
- package/server/api/microservice/extensions/download.post.ts +5 -4
- package/server/api/serverless/run_cloud.post.ts +53 -11
- package/server/utils/app_config.ts +29 -22
- package/server/utils/cleanup.ts +60 -30
- package/server/utils/cloud.ts +9 -8
- package/server/utils/extension.ts +23 -9
- package/server/utils/microservices.ts +33 -24
- package/server/utils/path.ts +4 -4
- package/server/utils/scripts.ts +26 -23
- package/server/utils/server.ts +2 -2
- package/server/utils/server_config.ts +41 -27
- package/server/utils/stream.ts +6 -0
- package/server/utils/ws_client.ts +42 -8
- package/shared/scripts.ts +15 -10
- package/shared/utils/call_raw.ts +23 -16
- package/shared/utils/call_schema.ts +5 -8
- package/shared/utils/fetch_raw.ts +87 -47
- package/shared/utils/fetch_schema.ts +6 -9
- package/shared/utils/file.ts +8 -2
- package/shared/utils/response_handlers/load.ts +26 -11
- package/shared/utils/types.ts +9 -9
- package/shared/utils/validate_schema.ts +1 -1
- package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +0 -276
- package/server/types/vendor.d.ts +0 -64
- package/server/utils/server_config.js +0 -43
- package/shared/utils/call_raw.js +0 -30
- package/shared/utils/fetch_raw.js +0 -40
- /package/{opengeodeweb_front_schemas.js → .build/opengeodeweb_front_schemas.js} +0 -0
- /package/{server → .build/server}/utils/server.js +0 -0
- /package/{shared → .build/shared}/app_mode.js +0 -0
- /package/{shared → .build/shared}/utils/parse_boolean.js +0 -0
- /package/{shared → .build/shared}/utils/types.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable eslint/max-lines
|
|
1
2
|
import type { StyleValues } from "@ogw_internal/stores/data_style/types.js";
|
|
2
3
|
import { dispatchToComponentTypes } from "./visibility";
|
|
3
4
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -5,7 +6,7 @@ import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
|
5
6
|
import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
|
|
6
7
|
|
|
7
8
|
// The four per-component-type style composables (Surface/Line/Block/Corner) each expose a different, large set of methods (color, visibility, per-attribute-kind getters/setters...). This module only cares about looking a handful of them up dynamically by name (built into ATTRIBUTE_FUNCTIONS below), so a precise structural type for componentStyleFunctions isn't worth modelling here; `any` keeps the dynamic dispatch table honest about that.
|
|
8
|
-
//
|
|
9
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
10
|
type ComponentStyleFunctions = Record<"Surface" | "Line" | "Block" | "Corner", any>;
|
|
10
11
|
|
|
11
12
|
interface AttributeAccessors {
|
|
@@ -17,92 +18,163 @@ interface AttributeAccessors {
|
|
|
17
18
|
setColorMap: (modelId: string, componentIds: string[], colorMap: string) => unknown;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
// The signatures below describe just the per-attribute-kind methods this module reads off each dynamically-typed composable (see the `any` in ComponentStyleFunctions above). `attributeFn` narrows one such method to its known signature so every downstream read/call is a real, checked type instead of `any`.
|
|
22
|
+
type AttributeNameFn = (modelId: string, componentId: string) => string | undefined;
|
|
23
|
+
type SetAttributeNameFn = (modelId: string, componentIds: string[], name: string) => unknown;
|
|
24
|
+
type AttributeRangeFn = (
|
|
25
|
+
modelId: string,
|
|
26
|
+
componentId: string,
|
|
27
|
+
) => [number | undefined, number | undefined];
|
|
28
|
+
type SetAttributeRangeFn = (
|
|
29
|
+
modelId: string,
|
|
30
|
+
componentIds: string[],
|
|
31
|
+
minimum: number,
|
|
32
|
+
maximum: number,
|
|
33
|
+
) => unknown;
|
|
34
|
+
type AttributeColorMapFn = (modelId: string, componentId: string) => string | undefined;
|
|
35
|
+
type SetAttributeColorMapFn = (
|
|
36
|
+
modelId: string,
|
|
37
|
+
componentIds: string[],
|
|
38
|
+
colorMap: string,
|
|
39
|
+
) => unknown;
|
|
40
|
+
type DynamicStyleFunctions = Record<string, unknown>;
|
|
41
|
+
|
|
42
|
+
// oxlint-disable-next-line no-unnecessary-type-parameters -- Signature narrows a dynamically-looked-up method to its known call signature; see comment above.
|
|
43
|
+
function attributeFn<Signature>(method: unknown): Signature {
|
|
44
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- narrowing a dynamically-looked-up method to its known call signature; see comment above.
|
|
45
|
+
return method as Signature;
|
|
46
|
+
}
|
|
47
|
+
|
|
20
48
|
// oxlint-disable-next-line max-lines-per-function
|
|
21
|
-
function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
49
|
+
function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions): {
|
|
50
|
+
getModelColor: (modelId: string) => unknown;
|
|
51
|
+
getModelActiveColoring: (modelId: string) => unknown;
|
|
52
|
+
getModelComponentColor: (modelId: string, componentId: string) => unknown;
|
|
53
|
+
getModelComponentEffectiveColor: (modelId: string, componentId: string, type: string) => unknown;
|
|
54
|
+
getModelComponentActiveColoring: (modelId: string, componentId: string) => unknown;
|
|
55
|
+
modelComponentTypeColor: (modelId: string, type: string) => unknown;
|
|
56
|
+
getModelComponentTypeActiveColoring: (modelId: string, type: string) => unknown;
|
|
57
|
+
setModelComponentTypeColor: (modelId: string, type: string, color: unknown) => Promise<void>;
|
|
58
|
+
setModelComponentTypeActiveColoring: (
|
|
59
|
+
modelId: string,
|
|
60
|
+
type: string,
|
|
61
|
+
activeColoring: string,
|
|
62
|
+
) => Promise<void>;
|
|
63
|
+
setModelComponentActiveColoring: (
|
|
64
|
+
modelId: string,
|
|
65
|
+
componentId: string,
|
|
66
|
+
activeColoring: string,
|
|
67
|
+
) => Promise<void>;
|
|
68
|
+
setModelComponentsColor: (
|
|
69
|
+
modelId: string,
|
|
70
|
+
componentIds: string[],
|
|
71
|
+
color: unknown,
|
|
72
|
+
activeColoring?: string,
|
|
73
|
+
) => Promise<unknown[]>;
|
|
74
|
+
} {
|
|
22
75
|
const dataStore = useDataStore();
|
|
23
76
|
const dataStyleState = useDataStyleState();
|
|
24
77
|
const modelCommonStyle = useModelCommonStyle();
|
|
25
|
-
|
|
78
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- componentStyleFunctions is a dynamic dispatch table typed any by design; see ComponentStyleFunctions comment above.
|
|
79
|
+
const Surface = componentStyleFunctions.Surface as DynamicStyleFunctions;
|
|
80
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- componentStyleFunctions is a dynamic dispatch table typed any by design; see ComponentStyleFunctions comment above.
|
|
81
|
+
const Line = componentStyleFunctions.Line as DynamicStyleFunctions;
|
|
82
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- componentStyleFunctions is a dynamic dispatch table typed any by design; see ComponentStyleFunctions comment above.
|
|
83
|
+
const Block = componentStyleFunctions.Block as DynamicStyleFunctions;
|
|
84
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- componentStyleFunctions is a dynamic dispatch table typed any by design; see ComponentStyleFunctions comment above.
|
|
85
|
+
const Corner = componentStyleFunctions.Corner as DynamicStyleFunctions;
|
|
26
86
|
const ATTRIBUTE_FUNCTIONS: Record<string, Record<string, AttributeAccessors>> = {
|
|
27
87
|
Surface: {
|
|
28
88
|
vertex: {
|
|
29
|
-
getName: Surface.modelSurfacesVertexAttributeName,
|
|
30
|
-
setName: Surface.setModelSurfacesVertexAttributeName,
|
|
31
|
-
getRange: Surface.modelSurfacesVertexAttributeRange,
|
|
32
|
-
setRange: Surface.setModelSurfacesVertexAttributeRange,
|
|
33
|
-
getColorMap: Surface.modelSurfacesVertexAttributeColorMap,
|
|
34
|
-
setColorMap:
|
|
89
|
+
getName: attributeFn<AttributeNameFn>(Surface.modelSurfacesVertexAttributeName),
|
|
90
|
+
setName: attributeFn<SetAttributeNameFn>(Surface.setModelSurfacesVertexAttributeName),
|
|
91
|
+
getRange: attributeFn<AttributeRangeFn>(Surface.modelSurfacesVertexAttributeRange),
|
|
92
|
+
setRange: attributeFn<SetAttributeRangeFn>(Surface.setModelSurfacesVertexAttributeRange),
|
|
93
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Surface.modelSurfacesVertexAttributeColorMap),
|
|
94
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(
|
|
95
|
+
Surface.setModelSurfacesVertexAttributeColorMap,
|
|
96
|
+
),
|
|
35
97
|
},
|
|
36
98
|
polygon: {
|
|
37
|
-
getName: Surface.modelSurfacesPolygonAttributeName,
|
|
38
|
-
setName: Surface.setModelSurfacesPolygonAttributeName,
|
|
39
|
-
getRange: Surface.modelSurfacesPolygonAttributeRange,
|
|
40
|
-
setRange: Surface.setModelSurfacesPolygonAttributeRange,
|
|
41
|
-
getColorMap:
|
|
42
|
-
|
|
99
|
+
getName: attributeFn<AttributeNameFn>(Surface.modelSurfacesPolygonAttributeName),
|
|
100
|
+
setName: attributeFn<SetAttributeNameFn>(Surface.setModelSurfacesPolygonAttributeName),
|
|
101
|
+
getRange: attributeFn<AttributeRangeFn>(Surface.modelSurfacesPolygonAttributeRange),
|
|
102
|
+
setRange: attributeFn<SetAttributeRangeFn>(Surface.setModelSurfacesPolygonAttributeRange),
|
|
103
|
+
getColorMap: attributeFn<AttributeColorMapFn>(
|
|
104
|
+
Surface.modelSurfacesPolygonAttributeColorMap,
|
|
105
|
+
),
|
|
106
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(
|
|
107
|
+
Surface.setModelSurfacesPolygonAttributeColorMap,
|
|
108
|
+
),
|
|
43
109
|
},
|
|
44
110
|
},
|
|
45
111
|
Line: {
|
|
46
112
|
vertex: {
|
|
47
|
-
getName: Line.modelLinesVertexAttributeName,
|
|
48
|
-
setName: Line.setModelLinesVertexAttributeName,
|
|
49
|
-
getRange: Line.modelLinesVertexAttributeRange,
|
|
50
|
-
setRange: Line.setModelLinesVertexAttributeRange,
|
|
51
|
-
getColorMap: Line.modelLinesVertexAttributeColorMap,
|
|
52
|
-
setColorMap: Line.setModelLinesVertexAttributeColorMap,
|
|
113
|
+
getName: attributeFn<AttributeNameFn>(Line.modelLinesVertexAttributeName),
|
|
114
|
+
setName: attributeFn<SetAttributeNameFn>(Line.setModelLinesVertexAttributeName),
|
|
115
|
+
getRange: attributeFn<AttributeRangeFn>(Line.modelLinesVertexAttributeRange),
|
|
116
|
+
setRange: attributeFn<SetAttributeRangeFn>(Line.setModelLinesVertexAttributeRange),
|
|
117
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Line.modelLinesVertexAttributeColorMap),
|
|
118
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(Line.setModelLinesVertexAttributeColorMap),
|
|
53
119
|
},
|
|
54
120
|
edge: {
|
|
55
|
-
getName: Line.modelLinesEdgeAttributeName,
|
|
56
|
-
setName: Line.setModelLinesEdgeAttributeName,
|
|
57
|
-
getRange: Line.modelLinesEdgeAttributeRange,
|
|
58
|
-
setRange: Line.setModelLinesEdgeAttributeRange,
|
|
59
|
-
getColorMap: Line.modelLinesEdgeAttributeColorMap,
|
|
60
|
-
setColorMap: Line.setModelLinesEdgeAttributeColorMap,
|
|
121
|
+
getName: attributeFn<AttributeNameFn>(Line.modelLinesEdgeAttributeName),
|
|
122
|
+
setName: attributeFn<SetAttributeNameFn>(Line.setModelLinesEdgeAttributeName),
|
|
123
|
+
getRange: attributeFn<AttributeRangeFn>(Line.modelLinesEdgeAttributeRange),
|
|
124
|
+
setRange: attributeFn<SetAttributeRangeFn>(Line.setModelLinesEdgeAttributeRange),
|
|
125
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Line.modelLinesEdgeAttributeColorMap),
|
|
126
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(Line.setModelLinesEdgeAttributeColorMap),
|
|
61
127
|
},
|
|
62
128
|
},
|
|
63
129
|
Block: {
|
|
64
130
|
vertex: {
|
|
65
|
-
getName: Block.modelBlocksVertexAttributeName,
|
|
66
|
-
setName: Block.setModelBlocksVertexAttributeName,
|
|
67
|
-
getRange: Block.modelBlocksVertexAttributeRange,
|
|
68
|
-
setRange: Block.setModelBlocksVertexAttributeRange,
|
|
69
|
-
getColorMap: Block.modelBlocksVertexAttributeColorMap,
|
|
70
|
-
setColorMap:
|
|
131
|
+
getName: attributeFn<AttributeNameFn>(Block.modelBlocksVertexAttributeName),
|
|
132
|
+
setName: attributeFn<SetAttributeNameFn>(Block.setModelBlocksVertexAttributeName),
|
|
133
|
+
getRange: attributeFn<AttributeRangeFn>(Block.modelBlocksVertexAttributeRange),
|
|
134
|
+
setRange: attributeFn<SetAttributeRangeFn>(Block.setModelBlocksVertexAttributeRange),
|
|
135
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Block.modelBlocksVertexAttributeColorMap),
|
|
136
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(
|
|
137
|
+
Block.setModelBlocksVertexAttributeColorMap,
|
|
138
|
+
),
|
|
71
139
|
},
|
|
72
140
|
polyhedron: {
|
|
73
|
-
getName: Block.modelBlocksPolyhedronAttributeName,
|
|
74
|
-
setName: Block.setModelBlocksPolyhedronAttributeName,
|
|
75
|
-
getRange: Block.modelBlocksPolyhedronAttributeRange,
|
|
76
|
-
setRange: Block.setModelBlocksPolyhedronAttributeRange,
|
|
77
|
-
getColorMap: Block.modelBlocksPolyhedronAttributeColorMap,
|
|
78
|
-
setColorMap:
|
|
141
|
+
getName: attributeFn<AttributeNameFn>(Block.modelBlocksPolyhedronAttributeName),
|
|
142
|
+
setName: attributeFn<SetAttributeNameFn>(Block.setModelBlocksPolyhedronAttributeName),
|
|
143
|
+
getRange: attributeFn<AttributeRangeFn>(Block.modelBlocksPolyhedronAttributeRange),
|
|
144
|
+
setRange: attributeFn<SetAttributeRangeFn>(Block.setModelBlocksPolyhedronAttributeRange),
|
|
145
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Block.modelBlocksPolyhedronAttributeColorMap),
|
|
146
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(
|
|
147
|
+
Block.setModelBlocksPolyhedronAttributeColorMap,
|
|
148
|
+
),
|
|
79
149
|
},
|
|
80
150
|
},
|
|
81
151
|
Corner: {
|
|
82
152
|
vertex: {
|
|
83
|
-
getName: Corner.modelCornersVertexAttributeName,
|
|
84
|
-
setName: Corner.setModelCornersVertexAttributeName,
|
|
85
|
-
getRange: Corner.modelCornersVertexAttributeRange,
|
|
86
|
-
setRange: Corner.setModelCornersVertexAttributeRange,
|
|
87
|
-
getColorMap: Corner.modelCornersVertexAttributeColorMap,
|
|
88
|
-
setColorMap:
|
|
153
|
+
getName: attributeFn<AttributeNameFn>(Corner.modelCornersVertexAttributeName),
|
|
154
|
+
setName: attributeFn<SetAttributeNameFn>(Corner.setModelCornersVertexAttributeName),
|
|
155
|
+
getRange: attributeFn<AttributeRangeFn>(Corner.modelCornersVertexAttributeRange),
|
|
156
|
+
setRange: attributeFn<SetAttributeRangeFn>(Corner.setModelCornersVertexAttributeRange),
|
|
157
|
+
getColorMap: attributeFn<AttributeColorMapFn>(Corner.modelCornersVertexAttributeColorMap),
|
|
158
|
+
setColorMap: attributeFn<SetAttributeColorMapFn>(
|
|
159
|
+
Corner.setModelCornersVertexAttributeColorMap,
|
|
160
|
+
),
|
|
89
161
|
},
|
|
90
162
|
},
|
|
91
163
|
};
|
|
92
164
|
function getModelComponentColor(modelId: string, componentId: string): unknown {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
165
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
166
|
+
const coloring = dataStyleState.getComponentStyle(modelId, componentId).coloring as StyleValues;
|
|
167
|
+
return coloring.constant;
|
|
96
168
|
}
|
|
97
169
|
function modelComponentTypeColor(modelId: string, type: string): unknown {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
170
|
+
const groupStyle = dataStyleState.getModelComponentTypeStyle(modelId, type);
|
|
171
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
172
|
+
const groupColoring = groupStyle.coloring as StyleValues;
|
|
173
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- style values are stored as loosely-typed StyleValues records; see StyleValues definition.
|
|
174
|
+
const typeStyle = dataStyleState.getStyle(modelId)[`${type.toLowerCase()}s`] as StyleValues;
|
|
175
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
176
|
+
const typeColoring = typeStyle.coloring as StyleValues;
|
|
177
|
+
return groupColoring.constant ?? typeColoring.constant;
|
|
106
178
|
}
|
|
107
179
|
function getModelComponentEffectiveColor(
|
|
108
180
|
modelId: string,
|
|
@@ -116,33 +188,33 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
116
188
|
return modelComponentTypeColor(modelId, type);
|
|
117
189
|
}
|
|
118
190
|
function getModelComponentActiveColoring(modelId: string, componentId: string): unknown {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
191
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
192
|
+
const coloring = dataStyleState.getComponentStyle(modelId, componentId).coloring as StyleValues;
|
|
193
|
+
return coloring.active;
|
|
122
194
|
}
|
|
123
195
|
function getModelComponentTypeActiveColoring(modelId: string, type: string): unknown {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
196
|
+
const groupStyle = dataStyleState.getModelComponentTypeStyle(modelId, type);
|
|
197
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
198
|
+
const groupColoring = groupStyle.coloring as StyleValues;
|
|
199
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- style values are stored as loosely-typed StyleValues records; see StyleValues definition.
|
|
200
|
+
const typeStyle = dataStyleState.getStyle(modelId)[`${type.toLowerCase()}s`] as StyleValues;
|
|
201
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
202
|
+
const typeColoring = typeStyle.coloring as StyleValues;
|
|
203
|
+
return groupColoring.active ?? typeColoring.active;
|
|
132
204
|
}
|
|
133
205
|
async function setModelComponentsColor(
|
|
134
206
|
modelId: string,
|
|
135
207
|
componentIds: string[],
|
|
136
208
|
color: unknown,
|
|
137
209
|
activeColoring = "constant",
|
|
138
|
-
) {
|
|
210
|
+
): Promise<unknown[]> {
|
|
139
211
|
await modelCommonStyle.mutateComponentStyles(modelId, componentIds, {
|
|
140
212
|
coloring: {
|
|
141
213
|
constant: color,
|
|
142
214
|
active: activeColoring,
|
|
143
215
|
},
|
|
144
216
|
});
|
|
145
|
-
return
|
|
217
|
+
return dispatchToComponentTypes(
|
|
146
218
|
modelId,
|
|
147
219
|
componentIds,
|
|
148
220
|
"Color",
|
|
@@ -153,7 +225,11 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
153
225
|
activeColoring,
|
|
154
226
|
);
|
|
155
227
|
}
|
|
156
|
-
async function setModelComponentTypeColor(
|
|
228
|
+
async function setModelComponentTypeColor(
|
|
229
|
+
modelId: string,
|
|
230
|
+
type: string,
|
|
231
|
+
color: unknown,
|
|
232
|
+
): Promise<void> {
|
|
157
233
|
await modelCommonStyle.mutateModelComponentTypeStyle(modelId, type, {
|
|
158
234
|
coloring: {
|
|
159
235
|
constant: color,
|
|
@@ -170,7 +246,7 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
170
246
|
modelId: string,
|
|
171
247
|
type: string,
|
|
172
248
|
activeColoring: string,
|
|
173
|
-
) {
|
|
249
|
+
): Promise<void> {
|
|
174
250
|
await modelCommonStyle.mutateModelComponentTypeStyle(modelId, type, {
|
|
175
251
|
coloring: {
|
|
176
252
|
active: activeColoring,
|
|
@@ -189,17 +265,24 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
189
265
|
active: activeColoring,
|
|
190
266
|
},
|
|
191
267
|
});
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
268
|
+
const attributeFunctions = ATTRIBUTE_FUNCTIONS[type]?.[activeColoring];
|
|
269
|
+
if (attributeFunctions === undefined) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const { getName, setName, getRange, setRange, getColorMap, setColorMap } = attributeFunctions;
|
|
273
|
+
const [firstId] = idsForType;
|
|
274
|
+
if (firstId === undefined) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const name = getName(modelId, firstId);
|
|
278
|
+
if (name !== undefined && name !== "") {
|
|
196
279
|
await setName(modelId, idsForType, name);
|
|
197
|
-
const [minimum, maximum] = getRange(modelId,
|
|
280
|
+
const [minimum, maximum] = getRange(modelId, firstId);
|
|
198
281
|
if (minimum !== undefined && maximum !== undefined) {
|
|
199
282
|
await setRange(modelId, idsForType, minimum, maximum);
|
|
200
283
|
}
|
|
201
|
-
const colorMap = getColorMap(modelId,
|
|
202
|
-
if (colorMap) {
|
|
284
|
+
const colorMap = getColorMap(modelId, firstId);
|
|
285
|
+
if (colorMap !== undefined && colorMap !== "") {
|
|
203
286
|
await setColorMap(modelId, idsForType, colorMap);
|
|
204
287
|
}
|
|
205
288
|
}
|
|
@@ -208,7 +291,7 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
208
291
|
modelId: string,
|
|
209
292
|
componentId: string,
|
|
210
293
|
activeColoring: string,
|
|
211
|
-
) {
|
|
294
|
+
): Promise<void> {
|
|
212
295
|
await modelCommonStyle.mutateComponentStyle(modelId, componentId, {
|
|
213
296
|
coloring: {
|
|
214
297
|
active: activeColoring,
|
|
@@ -222,25 +305,30 @@ function useModelColorStyle(componentStyleFunctions: ComponentStyleFunctions) {
|
|
|
222
305
|
if (type === undefined) {
|
|
223
306
|
return;
|
|
224
307
|
}
|
|
225
|
-
const
|
|
226
|
-
|
|
308
|
+
const attributeFunctions = ATTRIBUTE_FUNCTIONS[type]?.[activeColoring];
|
|
309
|
+
if (attributeFunctions === undefined) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const { getName, setName, getRange, setRange, getColorMap, setColorMap } = attributeFunctions;
|
|
227
313
|
const name = getName(modelId, componentId);
|
|
228
|
-
if (name) {
|
|
314
|
+
if (name !== undefined && name !== "") {
|
|
229
315
|
await setName(modelId, [componentId], name);
|
|
230
316
|
const [minimum, maximum] = getRange(modelId, componentId);
|
|
231
317
|
if (minimum !== undefined && maximum !== undefined) {
|
|
232
318
|
await setRange(modelId, [componentId], minimum, maximum);
|
|
233
319
|
}
|
|
234
320
|
const colorMap = getColorMap(modelId, componentId);
|
|
235
|
-
if (colorMap) {
|
|
321
|
+
if (colorMap !== undefined && colorMap !== "") {
|
|
236
322
|
await setColorMap(modelId, [componentId], colorMap);
|
|
237
323
|
}
|
|
238
324
|
}
|
|
239
325
|
}
|
|
240
326
|
function getModelColor(modelId: string): unknown {
|
|
327
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
241
328
|
return (dataStyleState.getStyle(modelId).coloring as StyleValues).constant;
|
|
242
329
|
}
|
|
243
330
|
function getModelActiveColoring(modelId: string): unknown {
|
|
331
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring shape is defined by the data style schema.
|
|
244
332
|
return (dataStyleState.getStyle(modelId).coloring as StyleValues).active;
|
|
245
333
|
}
|
|
246
334
|
return {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
// oxlint-disable eslint/sort-imports
|
|
1
|
+
import type { Dexie, Table } from "dexie";
|
|
3
2
|
import type {
|
|
4
3
|
ModelComponentStyle,
|
|
5
4
|
ModelComponentTypeStyle,
|
|
6
5
|
StyleValues,
|
|
7
6
|
} from "@ogw_internal/stores/data_style/types.js";
|
|
8
7
|
import type { JsonRpcSchema } from "@ogw_shared/utils/types.js";
|
|
9
|
-
import type { Dexie, Table } from "dexie";
|
|
10
8
|
import { database } from "@ogw_internal/database/database";
|
|
11
9
|
import merge from "lodash/merge";
|
|
12
10
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -24,20 +22,62 @@ interface ComponentStyleUpdate {
|
|
|
24
22
|
values: StyleValues;
|
|
25
23
|
}
|
|
26
24
|
|
|
25
|
+
interface UseModelCommonStyleReturn {
|
|
26
|
+
mutateComponentStyle: (
|
|
27
|
+
id_model: string,
|
|
28
|
+
id_component: string,
|
|
29
|
+
values: StyleValues,
|
|
30
|
+
) => Promise<unknown>;
|
|
31
|
+
mutateModelComponentTypeStyle: (
|
|
32
|
+
id_model: string,
|
|
33
|
+
type: string,
|
|
34
|
+
values: StyleValues,
|
|
35
|
+
) => Promise<void>;
|
|
36
|
+
mutateComponentStyles: (
|
|
37
|
+
id_model: string,
|
|
38
|
+
id_components: string[],
|
|
39
|
+
values: StyleValues,
|
|
40
|
+
) => Promise<void>;
|
|
41
|
+
bulkMutateComponentStylesPerComponent: (
|
|
42
|
+
id_model: string,
|
|
43
|
+
component_updates: ComponentStyleUpdate[],
|
|
44
|
+
) => Promise<void>;
|
|
45
|
+
setModelTypeColor: (
|
|
46
|
+
id: string,
|
|
47
|
+
component_ids: string[],
|
|
48
|
+
color: unknown,
|
|
49
|
+
schema: JsonRpcSchema,
|
|
50
|
+
activeColoring?: string,
|
|
51
|
+
collectionId?: string,
|
|
52
|
+
) => Promise<unknown>;
|
|
53
|
+
setModelTypeVisibility: (
|
|
54
|
+
id: string,
|
|
55
|
+
component_ids: string[],
|
|
56
|
+
visibility: boolean | undefined,
|
|
57
|
+
schema: JsonRpcSchema,
|
|
58
|
+
) => Promise<unknown>;
|
|
59
|
+
}
|
|
60
|
+
|
|
27
61
|
// oxlint-disable-next-line max-lines-per-function
|
|
28
|
-
export function useModelCommonStyle() {
|
|
62
|
+
export function useModelCommonStyle(): UseModelCommonStyleReturn {
|
|
29
63
|
const dataStore = useDataStore();
|
|
30
64
|
const viewerStore = useViewerStore();
|
|
31
65
|
const dataStyleState = useDataStyleState();
|
|
32
66
|
const model_component_datastyle_db =
|
|
67
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
33
68
|
database.model_component_datastyle as unknown as ComponentTable;
|
|
34
69
|
const model_component_type_datastyle_db =
|
|
70
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
35
71
|
database.model_component_type_datastyle as unknown as ComponentTypeTable;
|
|
36
72
|
|
|
37
|
-
async function mutateComponentStyle(
|
|
73
|
+
async function mutateComponentStyle(
|
|
74
|
+
id_model: string,
|
|
75
|
+
id_component: string,
|
|
76
|
+
values: StyleValues,
|
|
77
|
+
): Promise<unknown> {
|
|
38
78
|
dataStyleState.updateComponentStyleCache(id_model, id_component, values);
|
|
39
79
|
const key: [string, string] = [id_model, id_component];
|
|
40
|
-
const entry: ModelComponentStyle = (await model_component_datastyle_db.get(key))
|
|
80
|
+
const entry: ModelComponentStyle = (await model_component_datastyle_db.get(key)) ?? {
|
|
41
81
|
id_model,
|
|
42
82
|
id_component,
|
|
43
83
|
};
|
|
@@ -49,8 +89,9 @@ export function useModelCommonStyle() {
|
|
|
49
89
|
id_model: string,
|
|
50
90
|
type: string,
|
|
51
91
|
values: StyleValues,
|
|
52
|
-
) {
|
|
92
|
+
): Promise<void> {
|
|
53
93
|
dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
|
|
94
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
54
95
|
await (database as unknown as Dexie).transaction(
|
|
55
96
|
"rw",
|
|
56
97
|
model_component_type_datastyle_db,
|
|
@@ -58,7 +99,7 @@ export function useModelCommonStyle() {
|
|
|
58
99
|
const key: [string, string] = [id_model, type];
|
|
59
100
|
const entry: ModelComponentTypeStyle = (await model_component_type_datastyle_db.get(
|
|
60
101
|
key,
|
|
61
|
-
))
|
|
102
|
+
)) ?? {
|
|
62
103
|
id_model,
|
|
63
104
|
type,
|
|
64
105
|
};
|
|
@@ -72,8 +113,9 @@ export function useModelCommonStyle() {
|
|
|
72
113
|
id_model: string,
|
|
73
114
|
id_components: string[],
|
|
74
115
|
values: StyleValues,
|
|
75
|
-
) {
|
|
116
|
+
): Promise<void> {
|
|
76
117
|
dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
|
|
118
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
77
119
|
await (database as unknown as Dexie).transaction(
|
|
78
120
|
"rw",
|
|
79
121
|
model_component_datastyle_db,
|
|
@@ -84,7 +126,7 @@ export function useModelCommonStyle() {
|
|
|
84
126
|
]);
|
|
85
127
|
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
86
128
|
const updates = id_components.map((id_component, index) => {
|
|
87
|
-
const style: ModelComponentStyle = existing[index]
|
|
129
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
88
130
|
merge(style, values);
|
|
89
131
|
return toRaw(style);
|
|
90
132
|
});
|
|
@@ -97,8 +139,9 @@ export function useModelCommonStyle() {
|
|
|
97
139
|
async function bulkMutateComponentStylesPerComponent(
|
|
98
140
|
id_model: string,
|
|
99
141
|
component_updates: ComponentStyleUpdate[],
|
|
100
|
-
) {
|
|
142
|
+
): Promise<void> {
|
|
101
143
|
dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
|
|
144
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
|
|
102
145
|
await (database as unknown as Dexie).transaction(
|
|
103
146
|
"rw",
|
|
104
147
|
model_component_datastyle_db,
|
|
@@ -109,7 +152,7 @@ export function useModelCommonStyle() {
|
|
|
109
152
|
]);
|
|
110
153
|
const existing = await model_component_datastyle_db.bulkGet(keys);
|
|
111
154
|
const updates = component_updates.map(({ id_component, values }, index) => {
|
|
112
|
-
const style: ModelComponentStyle = existing[index]
|
|
155
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
113
156
|
merge(style, values);
|
|
114
157
|
return toRaw(style);
|
|
115
158
|
});
|
|
@@ -124,20 +167,22 @@ export function useModelCommonStyle() {
|
|
|
124
167
|
color: unknown,
|
|
125
168
|
schema: JsonRpcSchema,
|
|
126
169
|
activeColoring = "constant",
|
|
127
|
-
|
|
170
|
+
collectionId?: string,
|
|
171
|
+
): Promise<unknown> {
|
|
128
172
|
if (!component_ids?.length) {
|
|
129
|
-
return;
|
|
173
|
+
return undefined;
|
|
130
174
|
}
|
|
131
175
|
|
|
132
176
|
const viewer_ids = await dataStore.getMeshComponentsViewerIds(id, component_ids);
|
|
133
177
|
if (!viewer_ids?.length) {
|
|
134
|
-
return;
|
|
178
|
+
return undefined;
|
|
135
179
|
}
|
|
136
180
|
|
|
137
181
|
const params: Record<string, unknown> = {
|
|
138
182
|
id,
|
|
139
183
|
block_ids: viewer_ids,
|
|
140
184
|
color_mode: activeColoring,
|
|
185
|
+
collection_id: collectionId,
|
|
141
186
|
};
|
|
142
187
|
if (activeColoring === "constant") {
|
|
143
188
|
await mutateComponentStyles(id, component_ids, {
|
|
@@ -152,6 +197,7 @@ export function useModelCommonStyle() {
|
|
|
152
197
|
{ schema, params },
|
|
153
198
|
{
|
|
154
199
|
response_function: async (response: unknown) => {
|
|
200
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- response shape is defined by the color-set schema.
|
|
155
201
|
const colors = response as { geode_id: string; color: unknown }[] | undefined;
|
|
156
202
|
if (activeColoring === "constant") {
|
|
157
203
|
await mutateComponentStyles(id, component_ids, {
|
|
@@ -162,7 +208,7 @@ export function useModelCommonStyle() {
|
|
|
162
208
|
return;
|
|
163
209
|
}
|
|
164
210
|
|
|
165
|
-
if (
|
|
211
|
+
if (colors === undefined || colors.length === 0) {
|
|
166
212
|
return;
|
|
167
213
|
}
|
|
168
214
|
|
|
@@ -187,22 +233,25 @@ export function useModelCommonStyle() {
|
|
|
187
233
|
component_ids: string[],
|
|
188
234
|
visibility: boolean | undefined,
|
|
189
235
|
schema: JsonRpcSchema,
|
|
190
|
-
) {
|
|
236
|
+
): Promise<unknown> {
|
|
191
237
|
if (!component_ids?.length) {
|
|
192
|
-
return;
|
|
238
|
+
return undefined;
|
|
193
239
|
}
|
|
194
240
|
|
|
195
241
|
const viewer_ids = await dataStore.getMeshComponentsViewerIds(id, component_ids);
|
|
196
242
|
if (!viewer_ids?.length) {
|
|
197
|
-
return;
|
|
243
|
+
return undefined;
|
|
198
244
|
}
|
|
199
245
|
const params = { id, block_ids: viewer_ids, visibility };
|
|
200
|
-
|
|
246
|
+
const result = await viewerStore.request(
|
|
201
247
|
{ schema, params },
|
|
202
248
|
{
|
|
203
|
-
response_function: () =>
|
|
249
|
+
response_function: async () => {
|
|
250
|
+
await mutateComponentStyles(id, component_ids, { visibility });
|
|
251
|
+
},
|
|
204
252
|
},
|
|
205
253
|
);
|
|
254
|
+
return result;
|
|
206
255
|
}
|
|
207
256
|
|
|
208
257
|
return {
|