@geode/opengeodeweb-front 10.7.0 → 10.8.0-rc.2

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 (89) hide show
  1. package/app/components/ObjectSelector.vue +0 -2
  2. package/app/components/Viewer/BreadCrumb.vue +6 -1
  3. package/app/components/Viewer/TreeComponent.vue +8 -9
  4. package/app/stores/app.js +1 -0
  5. package/app/stores/data.js +16 -3
  6. package/app/stores/data_style.js +28 -25
  7. package/app/stores/hybrid_viewer.js +0 -1
  8. package/app/utils/extension.js +1 -1
  9. package/app/utils/file_import_workflow.js +1 -0
  10. package/app/utils/local/cleanup.js +5 -1
  11. package/app/utils/local/microservices.js +1 -13
  12. package/app/utils/local/path.js +20 -1
  13. package/internal/database/base_database.js +22 -0
  14. package/internal/database/database.js +5 -20
  15. package/internal/database/extended_database.js +3 -10
  16. package/internal/database/tables/data_style.js +4 -0
  17. package/internal/database/tables/model_component_datastyle.js +4 -0
  18. package/internal/stores/data_style/mesh/cells/cell.js +12 -39
  19. package/internal/stores/data_style/mesh/cells/color.js +4 -4
  20. package/internal/stores/data_style/mesh/cells/common.js +19 -3
  21. package/internal/stores/data_style/mesh/cells/index.js +16 -10
  22. package/internal/stores/data_style/mesh/cells/textures.js +4 -4
  23. package/internal/stores/data_style/mesh/cells/vertex.js +35 -42
  24. package/internal/stores/data_style/mesh/cells/visibility.js +1 -4
  25. package/internal/stores/data_style/mesh/edges/color.js +4 -4
  26. package/internal/stores/data_style/mesh/edges/common.js +12 -3
  27. package/internal/stores/data_style/mesh/edges/edge.js +40 -40
  28. package/internal/stores/data_style/mesh/edges/index.js +18 -19
  29. package/internal/stores/data_style/mesh/edges/vertex.js +37 -44
  30. package/internal/stores/data_style/mesh/edges/visibility.js +1 -5
  31. package/internal/stores/data_style/mesh/edges/width.js +1 -5
  32. package/internal/stores/data_style/mesh/index.js +32 -5
  33. package/internal/stores/data_style/mesh/points/color.js +4 -4
  34. package/internal/stores/data_style/mesh/points/common.js +12 -3
  35. package/internal/stores/data_style/mesh/points/index.js +34 -32
  36. package/internal/stores/data_style/mesh/points/size.js +1 -4
  37. package/internal/stores/data_style/mesh/points/vertex.js +79 -65
  38. package/internal/stores/data_style/mesh/points/visibility.js +1 -4
  39. package/internal/stores/data_style/mesh/polygons/color.js +4 -4
  40. package/internal/stores/data_style/mesh/polygons/common.js +12 -3
  41. package/internal/stores/data_style/mesh/polygons/index.js +35 -24
  42. package/internal/stores/data_style/mesh/polygons/polygon.js +40 -34
  43. package/internal/stores/data_style/mesh/polygons/textures.js +4 -4
  44. package/internal/stores/data_style/mesh/polygons/vertex.js +35 -42
  45. package/internal/stores/data_style/mesh/polygons/visibility.js +4 -4
  46. package/internal/stores/data_style/mesh/polyhedra/color.js +4 -4
  47. package/internal/stores/data_style/mesh/polyhedra/common.js +12 -3
  48. package/internal/stores/data_style/mesh/polyhedra/index.js +21 -11
  49. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +80 -60
  50. package/internal/stores/data_style/mesh/polyhedra/vertex.js +79 -65
  51. package/internal/stores/data_style/mesh/polyhedra/visibility.js +4 -4
  52. package/internal/stores/data_style/model/blocks/color.js +17 -29
  53. package/internal/stores/data_style/model/blocks/common.js +14 -4
  54. package/internal/stores/data_style/model/blocks/index.js +38 -8
  55. package/internal/stores/data_style/model/blocks/visibility.js +19 -30
  56. package/internal/stores/data_style/model/corners/color.js +16 -29
  57. package/internal/stores/data_style/model/corners/common.js +14 -4
  58. package/internal/stores/data_style/model/corners/index.js +42 -8
  59. package/internal/stores/data_style/model/corners/visibility.js +16 -29
  60. package/internal/stores/data_style/model/edges/common.js +8 -1
  61. package/internal/stores/data_style/model/edges/index.js +2 -5
  62. package/internal/stores/data_style/model/edges/visibility.js +7 -5
  63. package/internal/stores/data_style/model/index.js +102 -133
  64. package/internal/stores/data_style/model/lines/color.js +20 -29
  65. package/internal/stores/data_style/model/lines/common.js +14 -4
  66. package/internal/stores/data_style/model/lines/index.js +35 -6
  67. package/internal/stores/data_style/model/lines/visibility.js +19 -29
  68. package/internal/stores/data_style/model/points/common.js +7 -0
  69. package/internal/stores/data_style/model/points/size.js +1 -4
  70. package/internal/stores/data_style/model/points/visibility.js +4 -4
  71. package/internal/stores/data_style/model/surfaces/color.js +16 -29
  72. package/internal/stores/data_style/model/surfaces/common.js +14 -4
  73. package/internal/stores/data_style/model/surfaces/index.js +37 -6
  74. package/internal/stores/data_style/model/surfaces/visibility.js +17 -29
  75. package/internal/stores/data_style/state.js +126 -5
  76. package/internal/utils/viewer_call.js +1 -1
  77. package/package.json +3 -3
  78. package/server/api/extensions/run.post.js +8 -1
  79. package/tests/integration/microservices/back/requirements.txt +7 -0
  80. package/tests/integration/microservices/viewer/requirements.txt +7 -0
  81. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +3 -1
  82. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +10 -0
  83. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +10 -0
  84. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +9 -0
  85. package/tests/integration/stores/data_style/model/index.nuxt.test.js +9 -0
  86. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +10 -0
  87. package/tests/integration/stores/data_style/model/points.nuxt.test.js +10 -0
  88. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +10 -0
  89. package/tests/unit/plugins/project_load.nuxt.test.js +13 -6
@@ -1,7 +1,5 @@
1
- // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
-
4
- // Local imports
1
+ import { database } from "@ogw_internal/database/database";
2
+ import { liveQuery } from "dexie";
5
3
  import { useDataStore } from "@ogw_front/stores/data";
6
4
  import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
7
5
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
@@ -12,8 +10,8 @@ import { useModelLinesStyle } from "./lines";
12
10
  import { useModelPointsStyle } from "./points";
13
11
  import { useModelSurfacesStyle } from "./surfaces";
14
12
  import { useViewerStore } from "@ogw_front/stores/viewer";
13
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
15
14
 
16
- // Local constants
17
15
  const model_schemas = viewer_schemas.opengeodeweb_viewer.model;
18
16
 
19
17
  export function useModelStyle() {
@@ -31,158 +29,129 @@ export function useModelStyle() {
31
29
  function modelVisibility(id) {
32
30
  return dataStyleStateStore.getStyle(id).visibility;
33
31
  }
32
+
34
33
  function setModelVisibility(id, visibility) {
35
34
  return viewerStore.request(
36
35
  model_schemas.visibility,
37
36
  { id, visibility },
38
37
  {
39
- response_function: () => {
40
- dataStyleStateStore.getStyle(id).visibility = visibility;
41
- hybridViewerStore.setVisibility(id, visibility);
42
- console.log(setModelVisibility.name, { id }, modelVisibility(id));
38
+ response_function: async () => {
39
+ await hybridViewerStore.setVisibility(id, visibility);
40
+ await dataStyleStateStore.mutateStyle(id, { visibility });
41
+ return { id, visibility };
43
42
  },
44
43
  },
45
44
  );
46
45
  }
47
46
 
48
- function visibleMeshComponents(id) {
49
- const visible_mesh_components = ref([]);
50
- const styles = dataStyleStateStore.styles[id];
51
- if (!styles) {
52
- return visible_mesh_components;
53
- }
54
-
55
- for (const [corner_id, style] of Object.entries(styles.corners || {})) {
56
- if (style.visibility) {
57
- visible_mesh_components.value.push(corner_id);
58
- }
59
- }
60
-
61
- for (const [line_id, style] of Object.entries(styles.lines || {})) {
62
- if (style.visibility) {
63
- visible_mesh_components.value.push(line_id);
64
- }
65
- }
66
-
67
- for (const [surface_id, style] of Object.entries(styles.surfaces || {})) {
68
- if (style.visibility) {
69
- visible_mesh_components.value.push(surface_id);
70
- }
71
- }
72
-
73
- for (const [block_id, style] of Object.entries(styles.blocks || {})) {
74
- if (style.visibility) {
75
- visible_mesh_components.value.push(block_id);
76
- }
77
- }
78
-
79
- return visible_mesh_components;
80
- }
81
-
82
- function modelMeshComponentVisibility(id, component_type, component_id) {
83
- if (component_type === "Corner") {
84
- return modelCornersStyleStore.modelCornerVisibility(id, component_id);
85
- }
86
- if (component_type === "Line") {
87
- return modelLinesStyleStore.modelLineVisibility(id, component_id);
88
- }
89
- if (component_type === "Surface") {
90
- return modelSurfacesStyleStore.modelSurfaceVisibility(id, component_id);
91
- }
92
- if (component_type === "Block") {
93
- return modelBlocksStyleStore.modelBlockVisibility(id, component_id);
94
- }
95
- throw new Error(`Unknown model component_type: ${component_type}`);
96
- }
97
-
98
- function modelColor(id) {
99
- return dataStyleStateStore.getStyle(id).color;
100
- }
101
- function setModelColor(id, color) {
102
- return viewerStore.request(
103
- model_schemas.color,
104
- { id, color },
105
- {
106
- response_function: () => {
107
- dataStyleStateStore.styles[id].color = color;
108
- console.log(setModelColor.name, { id }, modelColor(id));
109
- },
47
+ function visibleMeshComponents(id_ref) {
48
+ const selection = ref([]);
49
+ watch(
50
+ () => (isRef(id_ref) ? id_ref.value : id_ref),
51
+ (newId, oldId, onCleanup) => {
52
+ if (!newId) {
53
+ return;
54
+ }
55
+ const observable = liveQuery(async () => {
56
+ const components = await database.model_components.where("id").equals(newId).toArray();
57
+ if (components.length === 0) {
58
+ return [];
59
+ }
60
+
61
+ const all_styles = await database.model_component_datastyle
62
+ .where("id_model")
63
+ .equals(newId)
64
+ .toArray();
65
+ const styles = {};
66
+ for (const style of all_styles) {
67
+ styles[style.id_component] = style;
68
+ }
69
+
70
+ const current_selection = [];
71
+ const meshTypes = new Set(["Corner", "Line", "Surface", "Block"]);
72
+ const componentsByType = {};
73
+ for (const component of components) {
74
+ if (meshTypes.has(component.type)) {
75
+ if (!componentsByType[component.type]) {
76
+ componentsByType[component.type] = [];
77
+ }
78
+ componentsByType[component.type].push(component.geode_id);
79
+ }
80
+ }
81
+
82
+ for (const [type, geode_ids] of Object.entries(componentsByType)) {
83
+ let all_visible = true;
84
+ for (const gid of geode_ids) {
85
+ const is_visible = styles[gid] === undefined ? true : styles[gid].visibility;
86
+ if (is_visible) {
87
+ current_selection.push(gid);
88
+ } else {
89
+ all_visible = false;
90
+ }
91
+ }
92
+ if (all_visible) {
93
+ current_selection.push(type);
94
+ }
95
+ }
96
+ return current_selection;
97
+ });
98
+
99
+ const subscription = observable.subscribe({
100
+ next: (val) => {
101
+ selection.value = val;
102
+ },
103
+ error: (err) => console.error(err),
104
+ });
105
+ onCleanup(() => subscription.unsubscribe());
110
106
  },
107
+ { immediate: true },
111
108
  );
112
- }
113
-
114
- async function setModelMeshComponentsVisibility(id, component_geode_ids, visibility) {
115
- const component_type = await dataStore.meshComponentType(id, component_geode_ids[0]);
116
- if (component_type === "Corner") {
117
- return modelCornersStyleStore.setModelCornersVisibility(id, component_geode_ids, visibility);
118
- }
119
- if (component_type === "Line") {
120
- return modelLinesStyleStore.setModelLinesVisibility(id, component_geode_ids, visibility);
121
- }
122
- if (component_type === "Surface") {
123
- return modelSurfacesStyleStore.setModelSurfacesVisibility(
124
- id,
125
- component_geode_ids,
126
- visibility,
127
- );
128
- }
129
- if (component_type === "Block") {
130
- return modelBlocksStyleStore.setModelBlocksVisibility(id, component_geode_ids, visibility);
131
- }
132
- throw new Error(`Unknown model component_type: ${component_type}`);
109
+ return selection;
133
110
  }
134
111
 
135
112
  function applyModelStyle(id) {
136
113
  const style = dataStyleStateStore.getStyle(id);
137
- const promise_array = [];
138
- for (const [key, value] of Object.entries(style)) {
139
- if (key === "visibility") {
140
- promise_array.push(setModelVisibility(id, value));
141
- } else if (key === "corners") {
142
- promise_array.push(modelCornersStyleStore.applyModelCornersStyle(id));
143
- } else if (key === "lines") {
144
- promise_array.push(modelLinesStyleStore.applyModelLinesStyle(id));
145
- } else if (key === "surfaces") {
146
- promise_array.push(modelSurfacesStyleStore.applyModelSurfacesStyle(id));
147
- } else if (key === "blocks") {
148
- promise_array.push(modelBlocksStyleStore.applyModelBlocksStyle(id));
149
- } else if (key === "points") {
150
- promise_array.push(modelPointsStyleStore.applyModelPointsStyle(id));
151
- } else if (key === "edges") {
152
- promise_array.push(modelEdgesStyleStore.applyModelEdgesStyle(id));
153
- } else {
154
- throw new Error(`Unknown model key: ${key}`);
155
- }
156
- }
157
- return Promise.all(promise_array);
114
+ const handlers = {
115
+ visibility: () => setModelVisibility(id, style.visibility),
116
+ corners: () => modelCornersStyleStore.applyModelCornersStyle(id),
117
+ lines: () => modelLinesStyleStore.applyModelLinesStyle(id),
118
+ surfaces: () => modelSurfacesStyleStore.applyModelSurfacesStyle(id),
119
+ blocks: () => modelBlocksStyleStore.applyModelBlocksStyle(id),
120
+ points: () => modelPointsStyleStore.applyModelPointsStyle(id),
121
+ edges: () => modelEdgesStyleStore.applyModelEdgesStyle(id),
122
+ };
123
+
124
+ const promises = Object.keys(style)
125
+ .filter((key) => handlers[key])
126
+ .map((key) => handlers[key]());
127
+
128
+ return Promise.all(promises);
158
129
  }
159
130
 
160
- async function setModelMeshComponentsDefaultStyle(id) {
161
- const item = await dataStore.item(id);
162
- const { mesh_components } = item;
163
- const promise_array = [];
164
- if ("Corner" in mesh_components) {
165
- promise_array.push(modelCornersStyleStore.setModelCornersDefaultStyle(id));
166
- }
167
- if ("Line" in mesh_components) {
168
- promise_array.push(modelLinesStyleStore.setModelLinesDefaultStyle(id));
169
- }
170
- if ("Surface" in mesh_components) {
171
- promise_array.push(modelSurfacesStyleStore.setModelSurfacesDefaultStyle(id));
172
- }
173
- if ("Block" in mesh_components) {
174
- promise_array.push(modelBlocksStyleStore.setModelBlocksDefaultStyle(id));
175
- }
176
- return promise_array;
131
+ function setModelMeshComponentsDefaultStyle(id) {
132
+ return dataStore.item(id).then((item) => {
133
+ if (!item) {
134
+ return [];
135
+ }
136
+ const { mesh_components } = item;
137
+ const handlers = {
138
+ Corner: () => modelCornersStyleStore.setModelCornersDefaultStyle(id),
139
+ Line: () => modelLinesStyleStore.setModelLinesDefaultStyle(id),
140
+ Surface: () => modelSurfacesStyleStore.setModelSurfacesDefaultStyle(id),
141
+ Block: () => modelBlocksStyleStore.setModelBlocksDefaultStyle(id),
142
+ };
143
+ return Promise.all(
144
+ Object.keys(mesh_components)
145
+ .filter((k) => handlers[k])
146
+ .map((k) => handlers[k]()),
147
+ );
148
+ });
177
149
  }
178
150
 
179
151
  return {
180
152
  modelVisibility,
181
153
  visibleMeshComponents,
182
- modelMeshComponentVisibility,
183
154
  setModelVisibility,
184
- setModelColor,
185
- setModelMeshComponentsVisibility,
186
155
  applyModelStyle,
187
156
  setModelMeshComponentsDefaultStyle,
188
157
  ...useModelBlocksStyle(),
@@ -13,41 +13,32 @@ export function useModelLinesColorStyle() {
13
13
  const dataStore = useDataStore();
14
14
  const viewerStore = useViewerStore();
15
15
  const modelLinesCommonStyle = useModelLinesCommonStyle();
16
+
16
17
  function modelLineColor(id, line_id) {
17
18
  return modelLinesCommonStyle.modelLineStyle(id, line_id).color;
18
19
  }
19
- function saveModelLineColor(id, line_id, color) {
20
- modelLinesCommonStyle.modelLineStyle(id, line_id).color = color;
21
- }
22
- async function setModelLinesColor(id, line_ids, color) {
20
+
21
+ function setModelLinesColor(id, line_ids, color) {
23
22
  if (!line_ids || line_ids.length === 0) {
24
- return;
25
- }
26
- const line_viewer_ids = await dataStore.getMeshComponentsViewerIds(id, line_ids);
27
- if (!line_viewer_ids || line_viewer_ids.length === 0) {
28
- console.warn("[setModelLinesColor] No viewer IDs found, skipping color request", {
29
- id,
30
- line_ids,
31
- });
32
- return;
23
+ return Promise.resolve();
33
24
  }
34
- return viewerStore.request(
35
- model_lines_schemas.color,
36
- { id, block_ids: line_viewer_ids, color },
37
- {
38
- response_function: () => {
39
- for (const line_id of line_ids) {
40
- saveModelLineColor(id, line_id, color);
41
- }
42
- console.log(
43
- setModelLinesColor.name,
44
- { id },
45
- { line_ids },
46
- JSON.stringify(modelLineColor(id, line_ids[0])),
47
- );
25
+ return dataStore.getMeshComponentsViewerIds(id, line_ids).then((line_viewer_ids) => {
26
+ if (!line_viewer_ids || line_viewer_ids.length === 0) {
27
+ return modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
28
+ color,
29
+ });
30
+ }
31
+ return viewerStore.request(
32
+ model_lines_schemas.color,
33
+ { id, block_ids: line_viewer_ids, color },
34
+ {
35
+ response_function: () =>
36
+ modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
37
+ color,
38
+ }),
48
39
  },
49
- },
50
- );
40
+ );
41
+ });
51
42
  }
52
43
 
53
44
  return {
@@ -1,3 +1,4 @@
1
+ import merge from "lodash/merge";
1
2
  import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
2
3
 
3
4
  export function useModelLinesCommonStyle() {
@@ -8,14 +9,23 @@ export function useModelLinesCommonStyle() {
8
9
  }
9
10
 
10
11
  function modelLineStyle(id, line_id) {
11
- if (!modelLinesStyle(id)[line_id]) {
12
- modelLinesStyle(id)[line_id] = {};
13
- }
14
- return modelLinesStyle(id)[line_id];
12
+ const groupStyle = modelLinesStyle(id);
13
+ const individualStyle = dataStyleStateStore.getComponentStyle(id, line_id);
14
+ return merge({}, groupStyle, individualStyle);
15
+ }
16
+
17
+ function mutateModelLinesStyle(id, line_ids, values) {
18
+ return dataStyleStateStore.mutateComponentStyles(id, line_ids, values);
19
+ }
20
+
21
+ function mutateModelLineStyle(id, line_id, values) {
22
+ return dataStyleStateStore.mutateComponentStyle(id, line_id, values);
15
23
  }
16
24
 
17
25
  return {
18
26
  modelLinesStyle,
19
27
  modelLineStyle,
28
+ mutateModelLinesStyle,
29
+ mutateModelLineStyle,
20
30
  };
21
31
  }
@@ -5,7 +5,7 @@ import { useModelLinesCommonStyle } from "./common";
5
5
  import { useModelLinesVisibilityStyle } from "./visibility";
6
6
 
7
7
  async function setModelLinesDefaultStyle(_id) {
8
- // Placeholder for oxlint
8
+ // Placeholder
9
9
  }
10
10
 
11
11
  export function useModelLinesStyle() {
@@ -15,12 +15,41 @@ export function useModelLinesStyle() {
15
15
  const modelLinesColorStyle = useModelLinesColorStyle();
16
16
 
17
17
  async function applyModelLinesStyle(id) {
18
- const style = modelLinesCommonStyle.modelLinesStyle(id);
19
18
  const line_ids = await dataStore.getLinesGeodeIds(id);
20
- return Promise.all([
21
- modelLinesVisibilityStyle.setModelLinesVisibility(id, line_ids, style.visibility),
22
- modelLinesColorStyle.setModelLinesColor(id, line_ids, style.color),
23
- ]);
19
+ if (line_ids.length === 0) {
20
+ return;
21
+ }
22
+
23
+ const visibilityGroups = {};
24
+ const colorGroups = {};
25
+
26
+ for (const line_id of line_ids) {
27
+ const style = modelLinesCommonStyle.modelLineStyle(id, line_id);
28
+
29
+ const vKey = String(style.visibility);
30
+ if (!visibilityGroups[vKey]) {
31
+ visibilityGroups[vKey] = [];
32
+ }
33
+ visibilityGroups[vKey].push(line_id);
34
+
35
+ const cKey = JSON.stringify(style.color);
36
+ if (!colorGroups[cKey]) {
37
+ colorGroups[cKey] = [];
38
+ }
39
+ colorGroups[cKey].push(line_id);
40
+ }
41
+
42
+ const promises = [];
43
+
44
+ for (const [vValue, ids] of Object.entries(visibilityGroups)) {
45
+ promises.push(modelLinesVisibilityStyle.setModelLinesVisibility(id, ids, vValue === "true"));
46
+ }
47
+
48
+ for (const [cValue, ids] of Object.entries(colorGroups)) {
49
+ promises.push(modelLinesColorStyle.setModelLinesColor(id, ids, JSON.parse(cValue)));
50
+ }
51
+
52
+ return Promise.all(promises);
24
53
  }
25
54
 
26
55
  return {
@@ -16,38 +16,28 @@ export function useModelLinesVisibilityStyle() {
16
16
  function modelLineVisibility(id, line_id) {
17
17
  return modelLinesCommonStyle.modelLineStyle(id, line_id).visibility;
18
18
  }
19
- function saveModelLineVisibility(id, line_id, visibility) {
20
- modelLinesCommonStyle.modelLineStyle(id, line_id).visibility = visibility;
21
- }
22
- async function setModelLinesVisibility(id, line_ids, visibility) {
19
+ function setModelLinesVisibility(id, line_ids, visibility) {
23
20
  if (!line_ids || line_ids.length === 0) {
24
- return;
25
- }
26
- const line_viewer_ids = await dataStore.getMeshComponentsViewerIds(id, line_ids);
27
- if (!line_viewer_ids || line_viewer_ids.length === 0) {
28
- console.warn("[setModelLinesVisibility] No viewer IDs found, skipping visibility request", {
29
- id,
30
- line_ids,
31
- });
32
- return;
21
+ return Promise.resolve();
33
22
  }
34
- return viewerStore.request(
35
- model_lines_schemas.visibility,
36
- { id, block_ids: line_viewer_ids, visibility },
37
- {
38
- response_function: () => {
39
- for (const line_id of line_ids) {
40
- saveModelLineVisibility(id, line_id, visibility);
41
- }
42
- console.log(
43
- setModelLinesVisibility.name,
44
- { id },
45
- { line_ids },
46
- modelLineVisibility(id, line_ids[0]),
47
- );
23
+
24
+ return dataStore.getMeshComponentsViewerIds(id, line_ids).then((line_viewer_ids) => {
25
+ if (!line_viewer_ids || line_viewer_ids.length === 0) {
26
+ return modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
27
+ visibility,
28
+ });
29
+ }
30
+ return viewerStore.request(
31
+ model_lines_schemas.visibility,
32
+ { id, block_ids: line_viewer_ids, visibility },
33
+ {
34
+ response_function: () =>
35
+ modelLinesCommonStyle.mutateModelLinesStyle(id, line_ids, {
36
+ visibility,
37
+ }),
48
38
  },
49
- },
50
- );
39
+ );
40
+ });
51
41
  }
52
42
 
53
43
  return {
@@ -3,11 +3,18 @@ import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
3
3
  export function useModelPointsCommonStyle() {
4
4
  const dataStyleStateStore = useDataStyleStateStore();
5
5
 
6
+ function mutateModelPointsStyle(id, values) {
7
+ return dataStyleStateStore.mutateStyle(id, {
8
+ points: values,
9
+ });
10
+ }
11
+
6
12
  function modelPointsStyle(id) {
7
13
  return dataStyleStateStore.getStyle(id).points;
8
14
  }
9
15
 
10
16
  return {
11
17
  modelPointsStyle,
18
+ mutateModelPointsStyle,
12
19
  };
13
20
  }
@@ -21,10 +21,7 @@ export function useModelPointsSizeStyle() {
21
21
  model_points_schemas.size,
22
22
  { id, size },
23
23
  {
24
- response_function: () => {
25
- modelPointsCommonStyle.modelPointsStyle(id).size = size;
26
- console.log(setModelPointsSize.name, { id }, modelPointsSize(id));
27
- },
24
+ response_function: () => modelPointsCommonStyle.mutateModelPointsStyle(id, { size }),
28
25
  },
29
26
  );
30
27
  }
@@ -21,10 +21,10 @@ export function useModelPointsVisibilityStyle() {
21
21
  model_points_schemas.visibility,
22
22
  { id, visibility },
23
23
  {
24
- response_function: () => {
25
- modelPointsCommonStyle.modelPointsStyle(id).visibility = visibility;
26
- console.log(setModelPointsVisibility.name, { id }, modelPointsVisibility(id));
27
- },
24
+ response_function: () =>
25
+ modelPointsCommonStyle.mutateModelPointsStyle(id, {
26
+ visibility,
27
+ }),
28
28
  },
29
29
  );
30
30
  }
@@ -13,41 +13,28 @@ export function useModelSurfacesColorStyle() {
13
13
  const dataStore = useDataStore();
14
14
  const viewerStore = useViewerStore();
15
15
  const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
16
+
16
17
  function modelSurfaceColor(id, surface_id) {
17
18
  return modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).color;
18
19
  }
19
- function saveModelSurfaceColor(id, surface_id, color) {
20
- modelSurfacesCommonStyle.modelSurfaceStyle(id, surface_id).color = color;
21
- }
22
- async function setModelSurfacesColor(id, surface_ids, color) {
20
+
21
+ function setModelSurfacesColor(id, surface_ids, color) {
23
22
  if (!surface_ids || surface_ids.length === 0) {
24
- return;
25
- }
26
- const surface_viewer_ids = await dataStore.getMeshComponentsViewerIds(id, surface_ids);
27
- if (!surface_viewer_ids || surface_viewer_ids.length === 0) {
28
- console.warn("[setModelSurfacesColor] No viewer IDs found, skipping color request", {
29
- id,
30
- surface_ids,
31
- });
32
- return;
23
+ return Promise.resolve();
33
24
  }
34
- return viewerStore.request(
35
- model_surfaces_schemas.color,
36
- { id, block_ids: surface_viewer_ids, color },
37
- {
38
- response_function: () => {
39
- for (const surface_id of surface_ids) {
40
- saveModelSurfaceColor(id, surface_id, color);
41
- }
42
- console.log(
43
- setModelSurfacesColor.name,
44
- { id },
45
- { surface_ids },
46
- JSON.stringify(modelSurfaceColor(id, surface_ids[0])),
47
- );
25
+ return dataStore.getMeshComponentsViewerIds(id, surface_ids).then((surface_viewer_ids) => {
26
+ if (!surface_viewer_ids || surface_viewer_ids.length === 0) {
27
+ return modelSurfacesCommonStyle.mutateModelSurfacesStyle(id, surface_ids, { color });
28
+ }
29
+ return viewerStore.request(
30
+ model_surfaces_schemas.color,
31
+ { id, block_ids: surface_viewer_ids, color },
32
+ {
33
+ response_function: () =>
34
+ modelSurfacesCommonStyle.mutateModelSurfacesStyle(id, surface_ids, { color }),
48
35
  },
49
- },
50
- );
36
+ );
37
+ });
51
38
  }
52
39
 
53
40
  return {
@@ -1,3 +1,4 @@
1
+ import merge from "lodash/merge";
1
2
  import { useDataStyleStateStore } from "@ogw_internal/stores/data_style/state";
2
3
 
3
4
  export function useModelSurfacesCommonStyle() {
@@ -8,14 +9,23 @@ export function useModelSurfacesCommonStyle() {
8
9
  }
9
10
 
10
11
  function modelSurfaceStyle(id, surface_id) {
11
- if (!modelSurfacesStyle(id)[surface_id]) {
12
- modelSurfacesStyle(id)[surface_id] = {};
13
- }
14
- return modelSurfacesStyle(id)[surface_id];
12
+ const groupStyle = modelSurfacesStyle(id);
13
+ const individualStyle = dataStyleStateStore.getComponentStyle(id, surface_id);
14
+ return merge({}, groupStyle, individualStyle);
15
+ }
16
+
17
+ function mutateModelSurfacesStyle(id, surface_ids, values) {
18
+ return dataStyleStateStore.mutateComponentStyles(id, surface_ids, values);
19
+ }
20
+
21
+ function mutateModelSurfaceStyle(id, surface_id, values) {
22
+ return dataStyleStateStore.mutateComponentStyle(id, surface_id, values);
15
23
  }
16
24
 
17
25
  return {
18
26
  modelSurfacesStyle,
19
27
  modelSurfaceStyle,
28
+ mutateModelSurfacesStyle,
29
+ mutateModelSurfaceStyle,
20
30
  };
21
31
  }