@geode/opengeodeweb-front 10.13.2 → 10.14.0-rc.1

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 (42) hide show
  1. package/app/components/Viewer/ContextMenuItem.vue +2 -1
  2. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +10 -2
  3. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +129 -52
  4. package/app/components/Viewer/Generic/Model/PointsOptions.vue +10 -2
  5. package/app/components/Viewer/ObjectTree/Layout.vue +6 -2
  6. package/app/components/Viewer/ObjectTree/Views/ModelComponents.vue +12 -8
  7. package/app/components/Viewer/Options/OptionsSection.vue +74 -0
  8. package/app/stores/data.js +2 -2
  9. package/app/stores/data_style.js +11 -2
  10. package/app/stores/menu.js +3 -0
  11. package/app/utils/default_styles.js +10 -1
  12. package/app/utils/import_workflow.js +3 -3
  13. package/internal/database/base_database.js +2 -0
  14. package/internal/database/database.js +1 -0
  15. package/internal/database/tables/model_component_type_datastyle.js +4 -0
  16. package/internal/stores/data_style/model/blocks/color.js +8 -34
  17. package/internal/stores/data_style/model/blocks/common.js +5 -3
  18. package/internal/stores/data_style/model/blocks/index.js +31 -33
  19. package/internal/stores/data_style/model/blocks/visibility.js +9 -36
  20. package/internal/stores/data_style/model/color.js +97 -0
  21. package/internal/stores/data_style/model/common.js +132 -0
  22. package/internal/stores/data_style/model/corners/color.js +8 -32
  23. package/internal/stores/data_style/model/corners/common.js +5 -3
  24. package/internal/stores/data_style/model/corners/index.js +31 -38
  25. package/internal/stores/data_style/model/corners/visibility.js +8 -32
  26. package/internal/stores/data_style/model/index.js +50 -202
  27. package/internal/stores/data_style/model/lines/color.js +8 -36
  28. package/internal/stores/data_style/model/lines/common.js +5 -3
  29. package/internal/stores/data_style/model/lines/index.js +30 -31
  30. package/internal/stores/data_style/model/lines/visibility.js +9 -36
  31. package/internal/stores/data_style/model/selection.js +83 -0
  32. package/internal/stores/data_style/model/surfaces/color.js +8 -32
  33. package/internal/stores/data_style/model/surfaces/common.js +5 -3
  34. package/internal/stores/data_style/model/surfaces/index.js +30 -33
  35. package/internal/stores/data_style/model/surfaces/visibility.js +9 -34
  36. package/internal/stores/data_style/model/visibility.js +186 -0
  37. package/internal/stores/data_style/state.js +24 -31
  38. package/package.json +3 -3
  39. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +11 -2
  40. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +11 -2
  41. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +11 -2
  42. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +11 -2
@@ -1,54 +1,52 @@
1
- // Local imports
2
1
  import { useDataStore } from "@ogw_front/stores/data";
3
- import { useModelBlocksColorStyle } from "./color";
2
+ import { useModelBlocksColor } from "./color";
4
3
  import { useModelBlocksCommonStyle } from "./common";
5
- import { useModelBlocksVisibilityStyle } from "./visibility";
4
+ import { useModelBlocksVisibility } from "./visibility";
5
+
6
6
  async function setModelBlocksDefaultStyle(_id) {
7
7
  // Placeholder
8
8
  }
9
9
 
10
10
  export function useModelBlocksStyle() {
11
11
  const dataStore = useDataStore();
12
- const modelBlocksCommonStyle = useModelBlocksCommonStyle();
13
- const modelBlocksVisibilityStyle = useModelBlocksVisibilityStyle();
14
- const modelBlocksColorStyle = useModelBlocksColorStyle();
12
+ const modelCommonStyle = useModelBlocksCommonStyle();
13
+ const modelVisibilityStyle = useModelBlocksVisibility();
14
+ const modelColorStyle = useModelBlocksColor();
15
15
 
16
- async function applyModelBlocksStyle(id) {
17
- const block_ids = await dataStore.getBlocksGeodeIds(id);
18
- if (block_ids.length === 0) {
16
+ async function applyModelBlocksStyle(modelId) {
17
+ const blocks_ids = await dataStore.getBlocksGeodeIds(modelId);
18
+ if (!blocks_ids?.length) {
19
19
  return;
20
20
  }
21
21
 
22
22
  const visibilityGroups = {};
23
23
  const colorGroups = {};
24
24
 
25
- for (const block_id of block_ids) {
26
- const style = modelBlocksCommonStyle.modelBlockStyle(id, block_id);
25
+ for (const block_id of blocks_ids) {
26
+ const style = modelCommonStyle.modelBlockStyle(modelId, block_id);
27
27
 
28
- const vKey = String(style.visibility);
29
- if (!visibilityGroups[vKey]) {
30
- visibilityGroups[vKey] = [];
28
+ const visibility = String(style.visibility);
29
+ if (!visibilityGroups[visibility]) {
30
+ visibilityGroups[visibility] = [];
31
31
  }
32
- visibilityGroups[vKey].push(block_id);
32
+ visibilityGroups[visibility].push(block_id);
33
33
 
34
- const cKey = JSON.stringify(style.color);
35
- if (!colorGroups[cKey]) {
36
- colorGroups[cKey] = [];
34
+ const color_mode = style.color_mode || "constant";
35
+ const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
36
+ if (!colorGroups[color_key]) {
37
+ colorGroups[color_key] = { color_mode, color: style.color, blocks_ids: [] };
37
38
  }
38
- colorGroups[cKey].push(block_id);
39
+ colorGroups[color_key].blocks_ids.push(block_id);
39
40
  }
40
41
 
41
- const promises = [];
42
-
43
- for (const [vValue, ids] of Object.entries(visibilityGroups)) {
44
- promises.push(
45
- modelBlocksVisibilityStyle.setModelBlocksVisibility(id, ids, vValue === "true"),
46
- );
47
- }
48
-
49
- for (const [cValue, ids] of Object.entries(colorGroups)) {
50
- promises.push(modelBlocksColorStyle.setModelBlocksColor(id, ids, JSON.parse(cValue)));
51
- }
42
+ const promises = [
43
+ ...Object.entries(visibilityGroups).map(([visibility, ids]) =>
44
+ modelVisibilityStyle.setModelBlocksVisibility(modelId, ids, visibility === "true"),
45
+ ),
46
+ ...Object.values(colorGroups).map(({ color_mode, color, blocks_ids: ids }) =>
47
+ modelColorStyle.setModelBlocksColor(modelId, ids, color, color_mode),
48
+ ),
49
+ ];
52
50
 
53
51
  return Promise.all(promises);
54
52
  }
@@ -56,8 +54,8 @@ export function useModelBlocksStyle() {
56
54
  return {
57
55
  applyModelBlocksStyle,
58
56
  setModelBlocksDefaultStyle,
59
- ...modelBlocksCommonStyle,
60
- ...modelBlocksVisibilityStyle,
61
- ...modelBlocksColorStyle,
57
+ ...modelCommonStyle,
58
+ ...modelVisibilityStyle,
59
+ ...modelColorStyle,
62
60
  };
63
61
  }
@@ -1,47 +1,20 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
-
4
- // Local imports
5
- import { useDataStore } from "@ogw_front/stores/data";
6
1
  import { useModelBlocksCommonStyle } from "./common";
7
- import { useViewerStore } from "@ogw_front/stores/viewer";
2
+ import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
8
4
 
9
- // Local constants
10
- const model_blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks;
5
+ const schema = viewer_schemas.opengeodeweb_viewer.model.blocks.visibility;
11
6
 
12
- export function useModelBlocksVisibilityStyle() {
13
- const dataStore = useDataStore();
14
- const viewerStore = useViewerStore();
7
+ export function useModelBlocksVisibility() {
8
+ const modelCommonStyle = useModelCommonStyle();
15
9
  const modelBlocksCommonStyle = useModelBlocksCommonStyle();
16
10
 
17
11
  function modelBlockVisibility(id, block_id) {
18
- const style = modelBlocksCommonStyle.modelBlockStyle(id, block_id);
19
- return style.visibility ?? true;
12
+ return modelBlocksCommonStyle.modelBlockStyle(id, block_id).visibility;
20
13
  }
21
14
 
22
- function setModelBlocksVisibility(id, block_ids, visibility) {
23
- if (!block_ids || block_ids.length === 0) {
24
- return Promise.resolve();
25
- }
26
- return dataStore.getMeshComponentsViewerIds(id, block_ids).then((block_viewer_ids) => {
27
- if (!block_viewer_ids || block_viewer_ids.length === 0) {
28
- return modelBlocksCommonStyle.mutateModelBlocksStyle(id, block_ids, {
29
- visibility,
30
- });
31
- }
32
- return viewerStore.request(
33
- model_blocks_schemas.visibility,
34
- { id, block_ids: block_viewer_ids, visibility },
35
- {
36
- response_function: () =>
37
- modelBlocksCommonStyle.mutateModelBlocksStyle(id, block_ids, { visibility }),
38
- },
39
- );
40
- });
15
+ function setModelBlocksVisibility(modelId, blocks_ids, visibility) {
16
+ return modelCommonStyle.setModelTypeVisibility(modelId, blocks_ids, visibility, schema);
41
17
  }
42
18
 
43
- return {
44
- modelBlockVisibility,
45
- setModelBlocksVisibility,
46
- };
19
+ return { setModelBlocksVisibility, modelBlockVisibility };
47
20
  }
@@ -0,0 +1,97 @@
1
+ import { DEFAULT_MODEL_COMPONENT_TYPE_COLORS } from "@ogw_front/utils/default_styles";
2
+ import { dispatchToComponentTypes } from "./visibility";
3
+ import { useDataStore } from "@ogw_front/stores/data";
4
+ import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
5
+ import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
6
+
7
+ function useModelColorStyle(componentStyleFunctions) {
8
+ const dataStore = useDataStore();
9
+ const dataStyleState = useDataStyleState();
10
+ const modelCommonStyle = useModelCommonStyle();
11
+
12
+ function getModelComponentColor(modelId, componentId) {
13
+ return dataStyleState.getComponentStyle(modelId, componentId).color;
14
+ }
15
+
16
+ function getModelComponentEffectiveColor(modelId, componentId, type) {
17
+ const individualColor = getModelComponentColor(modelId, componentId);
18
+ if (individualColor !== undefined) {
19
+ return individualColor;
20
+ }
21
+ return getModelComponentTypeColor(modelId, type);
22
+ }
23
+
24
+ function getModelComponentColorMode(modelId, componentId) {
25
+ return dataStyleState.getComponentStyle(modelId, componentId).color_mode || "constant";
26
+ }
27
+
28
+ function getModelComponentTypeColor(modelId, type) {
29
+ return (
30
+ dataStyleState.getModelComponentTypeStyle(modelId, type).color ||
31
+ DEFAULT_MODEL_COMPONENT_TYPE_COLORS[type]
32
+ );
33
+ }
34
+
35
+ function getModelComponentTypeColorMode(modelId, type) {
36
+ return dataStyleState.getModelComponentTypeStyle(modelId, type).color_mode || "constant";
37
+ }
38
+
39
+ async function setModelComponentTypeColor(modelId, type, color) {
40
+ await modelCommonStyle.mutateModelComponentTypeStyle(modelId, type, {
41
+ color,
42
+ color_mode: "constant",
43
+ });
44
+ const idsForType = await dataStore.getMeshComponentGeodeIds(modelId, type);
45
+ if (idsForType.length === 0) {
46
+ return;
47
+ }
48
+ await setModelComponentsColor(modelId, idsForType, color);
49
+ }
50
+
51
+ async function setModelComponentTypeColorMode(modelId, type, color_mode) {
52
+ await modelCommonStyle.mutateModelComponentTypeStyle(modelId, type, { color_mode });
53
+ const idsForType = await dataStore.getMeshComponentGeodeIds(modelId, type);
54
+ if (idsForType.length === 0) {
55
+ return;
56
+ }
57
+
58
+ if (color_mode === "random") {
59
+ await setModelComponentsColor(modelId, idsForType, undefined, color_mode);
60
+ return;
61
+ }
62
+ await modelCommonStyle.mutateComponentStyles(modelId, idsForType, { color_mode });
63
+ }
64
+
65
+ async function setModelComponentColorMode(modelId, componentId, color_mode) {
66
+ await modelCommonStyle.mutateComponentStyle(modelId, componentId, { color_mode });
67
+ if (color_mode === "random") {
68
+ await setModelComponentsColor(modelId, [componentId], undefined, color_mode);
69
+ }
70
+ }
71
+
72
+ async function setModelComponentsColor(modelId, componentIds, color, color_mode = "constant") {
73
+ await modelCommonStyle.mutateComponentStyles(modelId, componentIds, { color, color_mode });
74
+ return await dispatchToComponentTypes(
75
+ modelId,
76
+ componentIds,
77
+ "Color",
78
+ { componentStyleFunctions },
79
+ color,
80
+ color_mode,
81
+ );
82
+ }
83
+
84
+ return {
85
+ getModelComponentColor,
86
+ getModelComponentEffectiveColor,
87
+ getModelComponentColorMode,
88
+ getModelComponentTypeColor,
89
+ getModelComponentTypeColorMode,
90
+ setModelComponentTypeColor,
91
+ setModelComponentTypeColorMode,
92
+ setModelComponentColorMode,
93
+ setModelComponentsColor,
94
+ };
95
+ }
96
+
97
+ export { useModelColorStyle };
@@ -0,0 +1,132 @@
1
+ import { database } from "@ogw_internal/database/database";
2
+ import merge from "lodash/merge";
3
+ import { useDataStore } from "@ogw_front/stores/data";
4
+ import { useViewerStore } from "@ogw_front/stores/viewer";
5
+
6
+ export function useModelCommonStyle() {
7
+ const dataStore = useDataStore();
8
+ const viewerStore = useViewerStore();
9
+
10
+ async function mutateComponentStyle(id_model, id_component, values) {
11
+ const table = database.model_component_datastyle;
12
+ const key = [id_model, id_component];
13
+ const entry = (await table.get(key)) || { id_model, id_component };
14
+ merge(entry, values);
15
+ return table.put(structuredClone(toRaw(entry)));
16
+ }
17
+
18
+ function mutateModelComponentTypeStyle(id_model, type, values) {
19
+ return database.transaction("rw", database.model_component_type_datastyle, async () => {
20
+ const table = database.model_component_type_datastyle;
21
+ const key = [id_model, type];
22
+ const entry = (await table.get(key)) || { id_model, type };
23
+ merge(entry, values);
24
+ return table.put(structuredClone(toRaw(entry)));
25
+ });
26
+ }
27
+
28
+ function mutateComponentStyles(id_model, id_components, values) {
29
+ return database.transaction("rw", database.model_component_datastyle, async () => {
30
+ const all_styles = await database.model_component_datastyle
31
+ .where("id_model")
32
+ .equals(id_model)
33
+ .toArray();
34
+
35
+ const style_map = {};
36
+ for (const style of all_styles) {
37
+ style_map[style.id_component] = style;
38
+ }
39
+
40
+ const updates = id_components.map((id_component) => {
41
+ const style = style_map[id_component] || { id_model, id_component };
42
+ merge(style, values);
43
+ return toRaw(style);
44
+ });
45
+
46
+ return database.model_component_datastyle.bulkPut(structuredClone(updates));
47
+ });
48
+ }
49
+
50
+ function bulkMutateComponentStylesPerComponent(id_model, component_updates) {
51
+ return database.transaction("rw", database.model_component_datastyle, async () => {
52
+ const component_ids = new Set(component_updates.map((update) => update.id_component));
53
+ const all_styles = await database.model_component_datastyle
54
+ .where("id_model")
55
+ .equals(id_model)
56
+ .and((style) => component_ids.has(style.id_component))
57
+ .toArray();
58
+ const style_map = Object.fromEntries(all_styles.map((style) => [style.id_component, style]));
59
+ const updates = component_updates.map(({ id_component, values }) => {
60
+ const style = style_map[id_component] || { id_model, id_component };
61
+ merge(style, values);
62
+ return toRaw(style);
63
+ });
64
+ return database.model_component_datastyle.bulkPut(structuredClone(updates));
65
+ });
66
+ }
67
+
68
+ async function setModelTypeColor(id, component_ids, color, schema, color_mode = "constant") {
69
+ if (!component_ids?.length) {
70
+ return;
71
+ }
72
+
73
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(id, component_ids);
74
+ if (!viewer_ids?.length) {
75
+ return;
76
+ }
77
+
78
+ const params = { id, block_ids: viewer_ids, color_mode };
79
+ if (color_mode === "constant" && color !== undefined) {
80
+ params.color = color;
81
+ }
82
+
83
+ return viewerStore.request(schema, params, {
84
+ response_function: async (colors) => {
85
+ if (color_mode === "constant" && color !== undefined) {
86
+ await mutateComponentStyles(id, component_ids, { color });
87
+ return;
88
+ }
89
+
90
+ if (!colors?.length) {
91
+ return;
92
+ }
93
+
94
+ await bulkMutateComponentStylesPerComponent(
95
+ id,
96
+ colors.map(({ geode_id, color: color_value }) => ({
97
+ id_component: geode_id,
98
+ values: { color: color_value },
99
+ })),
100
+ );
101
+ },
102
+ });
103
+ }
104
+
105
+ async function setModelTypeVisibility(id, component_ids, visibility, schema) {
106
+ if (!component_ids?.length) {
107
+ return;
108
+ }
109
+
110
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(id, component_ids);
111
+ if (!viewer_ids?.length) {
112
+ return;
113
+ }
114
+
115
+ return viewerStore.request(
116
+ schema,
117
+ { id, block_ids: viewer_ids, visibility },
118
+ {
119
+ response_function: () => mutateComponentStyles(id, component_ids, { visibility }),
120
+ },
121
+ );
122
+ }
123
+
124
+ return {
125
+ mutateComponentStyle,
126
+ mutateModelComponentTypeStyle,
127
+ mutateComponentStyles,
128
+ bulkMutateComponentStylesPerComponent,
129
+ setModelTypeColor,
130
+ setModelTypeVisibility,
131
+ };
132
+ }
@@ -1,44 +1,20 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
-
4
- // Local imports
5
- import { useDataStore } from "@ogw_front/stores/data";
1
+ import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
6
2
  import { useModelCornersCommonStyle } from "./common";
7
- import { useViewerStore } from "@ogw_front/stores/viewer";
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
8
4
 
9
- // Local constants
10
- const model_corners_schemas = viewer_schemas.opengeodeweb_viewer.model.corners;
5
+ const schema = viewer_schemas.opengeodeweb_viewer.model.corners.color;
11
6
 
12
- export function useModelCornersColorStyle() {
13
- const dataStore = useDataStore();
14
- const viewerStore = useViewerStore();
7
+ export function useModelCornersColor() {
8
+ const modelCommonStyle = useModelCommonStyle();
15
9
  const modelCornersCommonStyle = useModelCornersCommonStyle();
16
10
 
17
11
  function modelCornerColor(id, corner_id) {
18
12
  return modelCornersCommonStyle.modelCornerStyle(id, corner_id).color;
19
13
  }
20
14
 
21
- function setModelCornersColor(id, corner_ids, color) {
22
- if (!corner_ids || corner_ids.length === 0) {
23
- return Promise.resolve();
24
- }
25
- return dataStore.getMeshComponentsViewerIds(id, corner_ids).then((corner_viewer_ids) => {
26
- if (!corner_viewer_ids || corner_viewer_ids.length === 0) {
27
- return modelCornersCommonStyle.mutateModelCornersStyle(id, corner_ids, { color });
28
- }
29
- return viewerStore.request(
30
- model_corners_schemas.color,
31
- { id, block_ids: corner_viewer_ids, color },
32
- {
33
- response_function: () =>
34
- modelCornersCommonStyle.mutateModelCornersStyle(id, corner_ids, { color }),
35
- },
36
- );
37
- });
15
+ function setModelCornersColor(modelId, corners_ids, color, color_mode = "constant") {
16
+ return modelCommonStyle.setModelTypeColor(modelId, corners_ids, color, schema, color_mode);
38
17
  }
39
18
 
40
- return {
41
- modelCornerColor,
42
- setModelCornersColor,
43
- };
19
+ return { setModelCornersColor, modelCornerColor };
44
20
  }
@@ -1,8 +1,10 @@
1
1
  import merge from "lodash/merge";
2
2
  import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
3
+ import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
3
4
 
4
5
  export function useModelCornersCommonStyle() {
5
6
  const dataStyleState = useDataStyleState();
7
+ const modelCommonStyle = useModelCommonStyle();
6
8
 
7
9
  function modelCornersStyle(id) {
8
10
  return dataStyleState.getStyle(id).corners;
@@ -14,12 +16,12 @@ export function useModelCornersCommonStyle() {
14
16
  return merge({}, groupStyle, individualStyle);
15
17
  }
16
18
 
17
- function mutateModelCornersStyle(id, corner_ids, values) {
18
- return dataStyleState.mutateComponentStyles(id, corner_ids, values);
19
+ function mutateModelCornersStyle(id, corners_ids, values) {
20
+ return modelCommonStyle.mutateComponentStyles(id, corners_ids, values);
19
21
  }
20
22
 
21
23
  function mutateModelCornerStyle(id, corner_id, values) {
22
- return dataStyleState.mutateComponentStyle(id, corner_id, values);
24
+ return modelCommonStyle.mutateComponentStyle(id, corner_id, values);
23
25
  }
24
26
 
25
27
  return {
@@ -1,59 +1,52 @@
1
- // Local imports
2
1
  import { useDataStore } from "@ogw_front/stores/data";
3
- import { useModelCornersColorStyle } from "./color";
2
+ import { useModelCornersColor } from "./color";
4
3
  import { useModelCornersCommonStyle } from "./common";
5
- import { useModelCornersVisibilityStyle } from "./visibility";
4
+ import { useModelCornersVisibility } from "./visibility";
5
+
6
6
  async function setModelCornersDefaultStyle(_id) {
7
7
  // Placeholder
8
8
  }
9
9
 
10
10
  export function useModelCornersStyle() {
11
11
  const dataStore = useDataStore();
12
- const modelCornersCommonStyle = useModelCornersCommonStyle();
13
- const modelCornersVisibilityStyle = useModelCornersVisibilityStyle();
14
- const modelCornersColorStyle = useModelCornersColorStyle();
12
+ const modelCommonStyle = useModelCornersCommonStyle();
13
+ const modelVisibilityStyle = useModelCornersVisibility();
14
+ const modelColorStyle = useModelCornersColor();
15
15
 
16
- async function applyModelCornersStyle(id) {
17
- const corner_ids = await dataStore.getCornersGeodeIds(id);
18
- if (corner_ids.length === 0) {
16
+ async function applyModelCornersStyle(modelId) {
17
+ const corners_ids = await dataStore.getCornersGeodeIds(modelId);
18
+ if (!corners_ids?.length) {
19
19
  return;
20
20
  }
21
21
 
22
- // Group corners by their effective style to minimize RPC calls
23
22
  const visibilityGroups = {};
24
23
  const colorGroups = {};
25
24
 
26
- for (const corner_id of corner_ids) {
27
- const style = modelCornersCommonStyle.modelCornerStyle(id, corner_id);
25
+ for (const corner_id of corners_ids) {
26
+ const style = modelCommonStyle.modelCornerStyle(modelId, corner_id);
28
27
 
29
- // Group by visibility
30
- const vKey = String(style.visibility);
31
- if (!visibilityGroups[vKey]) {
32
- visibilityGroups[vKey] = [];
28
+ const visibility = String(style.visibility);
29
+ if (!visibilityGroups[visibility]) {
30
+ visibilityGroups[visibility] = [];
33
31
  }
34
- visibilityGroups[vKey].push(corner_id);
32
+ visibilityGroups[visibility].push(corner_id);
35
33
 
36
- // Group by color
37
- const cKey = JSON.stringify(style.color);
38
- if (!colorGroups[cKey]) {
39
- colorGroups[cKey] = [];
34
+ const color_mode = style.color_mode || "constant";
35
+ const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
36
+ if (!colorGroups[color_key]) {
37
+ colorGroups[color_key] = { color_mode, color: style.color, corners_ids: [] };
40
38
  }
41
- colorGroups[cKey].push(corner_id);
39
+ colorGroups[color_key].corners_ids.push(corner_id);
42
40
  }
43
41
 
44
- const promises = [];
45
-
46
- // Apply visibility groups
47
- for (const [vValue, ids] of Object.entries(visibilityGroups)) {
48
- promises.push(
49
- modelCornersVisibilityStyle.setModelCornersVisibility(id, ids, vValue === "true"),
50
- );
51
- }
52
-
53
- // Apply color groups
54
- for (const [cValue, ids] of Object.entries(colorGroups)) {
55
- promises.push(modelCornersColorStyle.setModelCornersColor(id, ids, JSON.parse(cValue)));
56
- }
42
+ const promises = [
43
+ ...Object.entries(visibilityGroups).map(([visibility, ids]) =>
44
+ modelVisibilityStyle.setModelCornersVisibility(modelId, ids, visibility === "true"),
45
+ ),
46
+ ...Object.values(colorGroups).map(({ color_mode, color, corners_ids: ids }) =>
47
+ modelColorStyle.setModelCornersColor(modelId, ids, color, color_mode),
48
+ ),
49
+ ];
57
50
 
58
51
  return Promise.all(promises);
59
52
  }
@@ -61,8 +54,8 @@ export function useModelCornersStyle() {
61
54
  return {
62
55
  applyModelCornersStyle,
63
56
  setModelCornersDefaultStyle,
64
- ...modelCornersCommonStyle,
65
- ...modelCornersVisibilityStyle,
66
- ...modelCornersColorStyle,
57
+ ...modelCommonStyle,
58
+ ...modelVisibilityStyle,
59
+ ...modelColorStyle,
67
60
  };
68
61
  }
@@ -1,44 +1,20 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
-
4
- // Local imports
5
- import { useDataStore } from "@ogw_front/stores/data";
1
+ import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
6
2
  import { useModelCornersCommonStyle } from "./common";
7
- import { useViewerStore } from "@ogw_front/stores/viewer";
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
8
4
 
9
- // Local constants
10
- const model_corners_schemas = viewer_schemas.opengeodeweb_viewer.model.corners;
5
+ const schema = viewer_schemas.opengeodeweb_viewer.model.corners.visibility;
11
6
 
12
- export function useModelCornersVisibilityStyle() {
13
- const dataStore = useDataStore();
14
- const viewerStore = useViewerStore();
7
+ export function useModelCornersVisibility() {
8
+ const modelCommonStyle = useModelCommonStyle();
15
9
  const modelCornersCommonStyle = useModelCornersCommonStyle();
16
10
 
17
11
  function modelCornerVisibility(id, corner_id) {
18
12
  return modelCornersCommonStyle.modelCornerStyle(id, corner_id).visibility;
19
13
  }
20
14
 
21
- function setModelCornersVisibility(id, corner_ids, visibility) {
22
- if (!corner_ids || corner_ids.length === 0) {
23
- return Promise.resolve();
24
- }
25
- return dataStore.getMeshComponentsViewerIds(id, corner_ids).then((corner_viewer_ids) => {
26
- if (!corner_viewer_ids || corner_viewer_ids.length === 0) {
27
- return modelCornersCommonStyle.mutateModelCornersStyle(id, corner_ids, { visibility });
28
- }
29
- return viewerStore.request(
30
- model_corners_schemas.visibility,
31
- { id, block_ids: corner_viewer_ids, visibility },
32
- {
33
- response_function: () =>
34
- modelCornersCommonStyle.mutateModelCornersStyle(id, corner_ids, { visibility }),
35
- },
36
- );
37
- });
15
+ function setModelCornersVisibility(modelId, corners_ids, visibility) {
16
+ return modelCommonStyle.setModelTypeVisibility(modelId, corners_ids, visibility, schema);
38
17
  }
39
18
 
40
- return {
41
- modelCornerVisibility,
42
- setModelCornersVisibility,
43
- };
19
+ return { setModelCornersVisibility, modelCornerVisibility };
44
20
  }