@geode/opengeodeweb-front 10.22.1 → 10.23.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 (39) hide show
  1. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +256 -0
  2. package/app/components/Viewer/Generic/Model/CornersOptions.vue +187 -0
  3. package/app/components/Viewer/Generic/Model/LinesOptions.vue +252 -0
  4. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +72 -132
  5. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +260 -0
  6. package/app/components/Viewer/Options/AttributeSelector.vue +15 -2
  7. package/app/components/Viewer/Options/ColoringTypeSelector.vue +53 -11
  8. package/app/stores/app.js +1 -0
  9. package/app/stores/hybrid_viewer.js +21 -2
  10. package/app/utils/default_styles/constants.js +57 -0
  11. package/app/utils/default_styles/index.js +54 -0
  12. package/app/utils/default_styles/meshes.js +185 -0
  13. package/app/utils/default_styles/models.js +192 -0
  14. package/internal/stores/data_style/model/blocks/color.js +6 -1
  15. package/internal/stores/data_style/model/blocks/index.js +60 -4
  16. package/internal/stores/data_style/model/blocks/polyhedron.js +144 -0
  17. package/internal/stores/data_style/model/blocks/vertex.js +141 -0
  18. package/internal/stores/data_style/model/color.js +119 -12
  19. package/internal/stores/data_style/model/common.js +18 -21
  20. package/internal/stores/data_style/model/corners/color.js +6 -1
  21. package/internal/stores/data_style/model/corners/index.js +48 -4
  22. package/internal/stores/data_style/model/corners/vertex.js +144 -0
  23. package/internal/stores/data_style/model/lines/color.js +6 -1
  24. package/internal/stores/data_style/model/lines/edge.js +138 -0
  25. package/internal/stores/data_style/model/lines/index.js +58 -4
  26. package/internal/stores/data_style/model/lines/vertex.js +138 -0
  27. package/internal/stores/data_style/model/selection.js +50 -29
  28. package/internal/stores/data_style/model/surfaces/color.js +11 -1
  29. package/internal/stores/data_style/model/surfaces/index.js +60 -4
  30. package/internal/stores/data_style/model/surfaces/polygon.js +144 -0
  31. package/internal/stores/data_style/model/surfaces/vertex.js +144 -0
  32. package/internal/stores/data_style/model/visibility.js +17 -4
  33. package/internal/stores/data_style/state.js +101 -21
  34. package/package.json +3 -3
  35. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +118 -0
  36. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +64 -0
  37. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +112 -0
  38. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +118 -0
  39. package/app/utils/default_styles.js +0 -327
@@ -1,6 +1,8 @@
1
1
  import { useDataStore } from "@ogw_front/stores/data";
2
2
  import { useModelSurfacesColor } from "./color";
3
3
  import { useModelSurfacesCommonStyle } from "./common";
4
+ import { useModelSurfacesPolygonAttribute } from "./polygon";
5
+ import { useModelSurfacesVertexAttribute } from "./vertex";
4
6
  import { useModelSurfacesVisibility } from "./visibility";
5
7
 
6
8
  async function setModelSurfacesDefaultStyle(_id) {
@@ -12,6 +14,8 @@ export function useModelSurfacesStyle() {
12
14
  const modelCommonStyle = useModelSurfacesCommonStyle();
13
15
  const modelVisibilityStyle = useModelSurfacesVisibility();
14
16
  const modelColorStyle = useModelSurfacesColor();
17
+ const modelSurfacesVertexAttribute = useModelSurfacesVertexAttribute();
18
+ const modelSurfacesPolygonAttribute = useModelSurfacesPolygonAttribute();
15
19
 
16
20
  async function applyModelSurfacesStyle(modelId) {
17
21
  const surfaces_ids = await dataStore.getSurfacesGeodeIds(modelId);
@@ -21,6 +25,7 @@ export function useModelSurfacesStyle() {
21
25
 
22
26
  const visibilityGroups = {};
23
27
  const colorGroups = {};
28
+ const attributeGroups = {};
24
29
 
25
30
  for (const surfaces_id of surfaces_ids) {
26
31
  const style = modelCommonStyle.modelSurfaceStyle(modelId, surfaces_id);
@@ -32,11 +37,34 @@ export function useModelSurfacesStyle() {
32
37
  visibilityGroups[visibility].push(surfaces_id);
33
38
 
34
39
  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, surfaces_ids: [] };
40
+ if (color_mode === "constant" || color_mode === "random") {
41
+ const color_key = color_mode === "random" ? "random" : JSON.stringify(style.color);
42
+ if (!colorGroups[color_key]) {
43
+ colorGroups[color_key] = { color_mode, color: style.color, surfaces_ids: [] };
44
+ }
45
+ colorGroups[color_key].surfaces_ids.push(surfaces_id);
46
+ } else {
47
+ const attributeTypeKey = `${color_mode}_attribute`;
48
+ const attributeStyle = style[attributeTypeKey] || {};
49
+ const { name } = attributeStyle;
50
+ if (name) {
51
+ const storedConfig =
52
+ (attributeStyle.storedConfigs && attributeStyle.storedConfigs[name]) || {};
53
+ const { minimum, maximum, colorMap } = storedConfig;
54
+ const attributeGroupKey = `${color_mode}_${name}_${colorMap}_${minimum}_${maximum}`;
55
+ if (!attributeGroups[attributeGroupKey]) {
56
+ attributeGroups[attributeGroupKey] = {
57
+ color_mode,
58
+ name,
59
+ minimum,
60
+ maximum,
61
+ colorMap,
62
+ surfaces_ids: [],
63
+ };
64
+ }
65
+ attributeGroups[attributeGroupKey].surfaces_ids.push(surfaces_id);
66
+ }
38
67
  }
39
- colorGroups[color_key].surfaces_ids.push(surfaces_id);
40
68
  }
41
69
 
42
70
  const promises = [
@@ -46,6 +74,32 @@ export function useModelSurfacesStyle() {
46
74
  ...Object.values(colorGroups).map(({ color_mode, color, surfaces_ids: ids }) =>
47
75
  modelColorStyle.setModelSurfacesColor(modelId, ids, color, color_mode),
48
76
  ),
77
+ ...Object.values(attributeGroups).flatMap(
78
+ ({ color_mode, name, minimum, maximum, colorMap, surfaces_ids: ids }) => {
79
+ const isVertex = color_mode === "vertex";
80
+ const attributeStyle = isVertex
81
+ ? modelSurfacesVertexAttribute
82
+ : modelSurfacesPolygonAttribute;
83
+ const setAttributeName = isVertex
84
+ ? attributeStyle.setModelSurfacesVertexAttributeName
85
+ : attributeStyle.setModelSurfacesPolygonAttributeName;
86
+ const setAttributeRange = isVertex
87
+ ? attributeStyle.setModelSurfacesVertexAttributeRange
88
+ : attributeStyle.setModelSurfacesPolygonAttributeRange;
89
+ const setAttributeColorMap = isVertex
90
+ ? attributeStyle.setModelSurfacesVertexAttributeColorMap
91
+ : attributeStyle.setModelSurfacesPolygonAttributeColorMap;
92
+
93
+ const list = [setAttributeName(modelId, ids, name)];
94
+ if (minimum !== undefined && maximum !== undefined) {
95
+ list.push(setAttributeRange(modelId, ids, minimum, maximum));
96
+ }
97
+ if (colorMap) {
98
+ list.push(setAttributeColorMap(modelId, ids, colorMap));
99
+ }
100
+ return list;
101
+ },
102
+ ),
49
103
  ];
50
104
 
51
105
  return Promise.all(promises);
@@ -57,5 +111,7 @@ export function useModelSurfacesStyle() {
57
111
  ...modelCommonStyle,
58
112
  ...modelVisibilityStyle,
59
113
  ...modelColorStyle,
114
+ ...modelSurfacesVertexAttribute,
115
+ ...modelSurfacesPolygonAttribute,
60
116
  };
61
117
  }
@@ -0,0 +1,144 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
+
4
+ // Local imports
5
+ import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
6
+ import { useDataStore } from "@ogw_front/stores/data";
7
+ import { useModelSurfacesCommonStyle } from "./common";
8
+ import { useViewerStore } from "@ogw_front/stores/viewer";
9
+
10
+ // Local constants
11
+ const schema = viewer_schemas.opengeodeweb_viewer.model.surfaces.attribute.polygon;
12
+
13
+ export function useModelSurfacesPolygonAttribute() {
14
+ const dataStore = useDataStore();
15
+ const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
16
+ const viewerStore = useViewerStore();
17
+
18
+ function modelSurfacesPolygonAttribute(modelId, surfaceId) {
19
+ return modelSurfacesCommonStyle.modelSurfaceStyle(modelId, surfaceId).polygon_attribute;
20
+ }
21
+
22
+ function modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name) {
23
+ const { storedConfigs } = modelSurfacesPolygonAttribute(modelId, surfaceId);
24
+ if (name && storedConfigs && name in storedConfigs) {
25
+ return storedConfigs[name];
26
+ }
27
+ return {
28
+ minimum: undefined,
29
+ maximum: undefined,
30
+ colorMap: undefined,
31
+ };
32
+ }
33
+
34
+ function mutateModelSurfacesPolygonStyle(modelId, surfaceIds, values) {
35
+ return modelSurfacesCommonStyle.mutateModelSurfacesStyle(modelId, surfaceIds, {
36
+ polygon_attribute: values,
37
+ });
38
+ }
39
+
40
+ function setModelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds, name, config) {
41
+ return mutateModelSurfacesPolygonStyle(modelId, surfaceIds, {
42
+ storedConfigs: {
43
+ [name]: config,
44
+ },
45
+ });
46
+ }
47
+
48
+ function modelSurfacesPolygonAttributeName(modelId, surfaceId) {
49
+ return modelSurfacesPolygonAttribute(modelId, surfaceId).name;
50
+ }
51
+
52
+ async function setModelSurfacesPolygonAttributeName(modelId, surfaceIds, name) {
53
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
54
+
55
+ const updates = { name };
56
+ const polygon = modelSurfacesPolygonAttribute(modelId, surfaceIds[0]);
57
+ if (!(name in polygon.storedConfigs)) {
58
+ updates.storedConfigs = {
59
+ [name]: {
60
+ minimum: undefined,
61
+ maximum: undefined,
62
+ colorMap: undefined,
63
+ },
64
+ };
65
+ }
66
+
67
+ const params = { id: modelId, block_ids: viewer_ids, name };
68
+ return viewerStore.request(
69
+ { schema: schema.name, params },
70
+ {
71
+ response_function: () => mutateModelSurfacesPolygonStyle(modelId, surfaceIds, updates),
72
+ },
73
+ );
74
+ }
75
+
76
+ function modelSurfacesPolygonAttributeRange(modelId, surfaceId) {
77
+ const name = modelSurfacesPolygonAttributeName(modelId, surfaceId);
78
+ const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name);
79
+ const { minimum, maximum } = storedConfig;
80
+ return [minimum, maximum];
81
+ }
82
+
83
+ async function setModelSurfacesPolygonAttributeRange(modelId, surfaceIds, minimum, maximum) {
84
+ const name = modelSurfacesPolygonAttributeName(modelId, surfaceIds[0]);
85
+ const colorMap = modelSurfacesPolygonAttributeColorMap(modelId, surfaceIds[0]);
86
+ const points = getRGBPointsFromPreset(colorMap);
87
+
88
+ if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
89
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
90
+ const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
91
+ return viewerStore.request(
92
+ { schema: schema.color_map, params },
93
+ {
94
+ response_function: () =>
95
+ setModelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds, name, {
96
+ minimum,
97
+ maximum,
98
+ }),
99
+ },
100
+ );
101
+ }
102
+ return setModelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds, name, {
103
+ minimum,
104
+ maximum,
105
+ });
106
+ }
107
+
108
+ function modelSurfacesPolygonAttributeColorMap(modelId, surfaceId) {
109
+ const name = modelSurfacesPolygonAttributeName(modelId, surfaceId);
110
+ const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name);
111
+ const { colorMap } = storedConfig;
112
+ return colorMap;
113
+ }
114
+
115
+ async function setModelSurfacesPolygonAttributeColorMap(modelId, surfaceIds, colorMap) {
116
+ const name = modelSurfacesPolygonAttributeName(modelId, surfaceIds[0]);
117
+ const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds[0], name);
118
+ const points = getRGBPointsFromPreset(colorMap);
119
+ const { minimum, maximum } = storedConfig;
120
+
121
+ if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
122
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
123
+ const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
124
+ return viewerStore.request(
125
+ { schema: schema.color_map, params },
126
+ {
127
+ response_function: () =>
128
+ setModelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds, name, { colorMap }),
129
+ },
130
+ );
131
+ }
132
+ return setModelSurfacesPolygonAttributeStoredConfig(modelId, surfaceIds, name, { colorMap });
133
+ }
134
+
135
+ return {
136
+ modelSurfacesPolygonAttributeName,
137
+ modelSurfacesPolygonAttributeRange,
138
+ modelSurfacesPolygonAttributeColorMap,
139
+ modelSurfacesPolygonAttributeStoredConfig,
140
+ setModelSurfacesPolygonAttributeName,
141
+ setModelSurfacesPolygonAttributeRange,
142
+ setModelSurfacesPolygonAttributeColorMap,
143
+ };
144
+ }
@@ -0,0 +1,144 @@
1
+ // Third party imports
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
+
4
+ // Local imports
5
+ import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
6
+ import { useDataStore } from "@ogw_front/stores/data";
7
+ import { useModelSurfacesCommonStyle } from "./common";
8
+ import { useViewerStore } from "@ogw_front/stores/viewer";
9
+
10
+ // Local constants
11
+ const schema = viewer_schemas.opengeodeweb_viewer.model.surfaces.attribute.vertex;
12
+
13
+ export function useModelSurfacesVertexAttribute() {
14
+ const dataStore = useDataStore();
15
+ const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
16
+ const viewerStore = useViewerStore();
17
+
18
+ function modelSurfacesVertexAttribute(modelId, surfaceId) {
19
+ return modelSurfacesCommonStyle.modelSurfaceStyle(modelId, surfaceId).vertex_attribute;
20
+ }
21
+
22
+ function modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name) {
23
+ const { storedConfigs } = modelSurfacesVertexAttribute(modelId, surfaceId);
24
+ if (name && storedConfigs && name in storedConfigs) {
25
+ return storedConfigs[name];
26
+ }
27
+ return {
28
+ minimum: undefined,
29
+ maximum: undefined,
30
+ colorMap: undefined,
31
+ };
32
+ }
33
+
34
+ function mutateModelSurfacesVertexStyle(modelId, surfaceIds, values) {
35
+ return modelSurfacesCommonStyle.mutateModelSurfacesStyle(modelId, surfaceIds, {
36
+ vertex_attribute: values,
37
+ });
38
+ }
39
+
40
+ function setModelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds, name, config) {
41
+ return mutateModelSurfacesVertexStyle(modelId, surfaceIds, {
42
+ storedConfigs: {
43
+ [name]: config,
44
+ },
45
+ });
46
+ }
47
+
48
+ function modelSurfacesVertexAttributeName(modelId, surfaceId) {
49
+ return modelSurfacesVertexAttribute(modelId, surfaceId).name;
50
+ }
51
+
52
+ async function setModelSurfacesVertexAttributeName(modelId, surfaceIds, name) {
53
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
54
+
55
+ const updates = { name };
56
+ const vertex = modelSurfacesVertexAttribute(modelId, surfaceIds[0]);
57
+ if (!(name in vertex.storedConfigs)) {
58
+ updates.storedConfigs = {
59
+ [name]: {
60
+ minimum: undefined,
61
+ maximum: undefined,
62
+ colorMap: undefined,
63
+ },
64
+ };
65
+ }
66
+
67
+ const params = { id: modelId, block_ids: viewer_ids, name };
68
+ return viewerStore.request(
69
+ { schema: schema.name, params },
70
+ {
71
+ response_function: () => mutateModelSurfacesVertexStyle(modelId, surfaceIds, updates),
72
+ },
73
+ );
74
+ }
75
+
76
+ function modelSurfacesVertexAttributeRange(modelId, surfaceId) {
77
+ const name = modelSurfacesVertexAttributeName(modelId, surfaceId);
78
+ const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name);
79
+ const { minimum, maximum } = storedConfig;
80
+ return [minimum, maximum];
81
+ }
82
+
83
+ async function setModelSurfacesVertexAttributeRange(modelId, surfaceIds, minimum, maximum) {
84
+ const name = modelSurfacesVertexAttributeName(modelId, surfaceIds[0]);
85
+ const colorMap = modelSurfacesVertexAttributeColorMap(modelId, surfaceIds[0]);
86
+ const points = getRGBPointsFromPreset(colorMap);
87
+
88
+ if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
89
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
90
+ const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
91
+ return viewerStore.request(
92
+ { schema: schema.color_map, params },
93
+ {
94
+ response_function: () =>
95
+ setModelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds, name, {
96
+ minimum,
97
+ maximum,
98
+ }),
99
+ },
100
+ );
101
+ }
102
+ return setModelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds, name, {
103
+ minimum,
104
+ maximum,
105
+ });
106
+ }
107
+
108
+ function modelSurfacesVertexAttributeColorMap(modelId, surfaceId) {
109
+ const name = modelSurfacesVertexAttributeName(modelId, surfaceId);
110
+ const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name);
111
+ const { colorMap } = storedConfig;
112
+ return colorMap;
113
+ }
114
+
115
+ async function setModelSurfacesVertexAttributeColorMap(modelId, surfaceIds, colorMap) {
116
+ const name = modelSurfacesVertexAttributeName(modelId, surfaceIds[0]);
117
+ const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds[0], name);
118
+ const points = getRGBPointsFromPreset(colorMap);
119
+ const { minimum, maximum } = storedConfig;
120
+
121
+ if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
122
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, surfaceIds);
123
+ const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
124
+ return viewerStore.request(
125
+ { schema: schema.color_map, params },
126
+ {
127
+ response_function: () =>
128
+ setModelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds, name, { colorMap }),
129
+ },
130
+ );
131
+ }
132
+ return setModelSurfacesVertexAttributeStoredConfig(modelId, surfaceIds, name, { colorMap });
133
+ }
134
+
135
+ return {
136
+ modelSurfacesVertexAttributeName,
137
+ modelSurfacesVertexAttributeRange,
138
+ modelSurfacesVertexAttributeColorMap,
139
+ modelSurfacesVertexAttributeStoredConfig,
140
+ setModelSurfacesVertexAttributeName,
141
+ setModelSurfacesVertexAttributeRange,
142
+ setModelSurfacesVertexAttributeColorMap,
143
+ };
144
+ }
@@ -1,8 +1,9 @@
1
- import { MESH_TYPES } from "@ogw_front/utils/default_styles";
1
+ import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
2
2
  import { useDataStore } from "@ogw_front/stores/data";
3
3
  import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
4
4
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
5
5
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
6
+ import { useModelSelection } from "./selection";
6
7
  import { useViewerStore } from "@ogw_front/stores/viewer";
7
8
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
8
9
 
@@ -11,7 +12,7 @@ const model_schemas = viewer_schemas.opengeodeweb_viewer.model;
11
12
  async function getModelComponentsMap(modelId) {
12
13
  const dataStore = useDataStore();
13
14
  const results = await Promise.all(
14
- MESH_TYPES.map(async (type) => {
15
+ MESH_COMPONENT_TYPES.map(async (type) => {
15
16
  const geodeIds = await dataStore.getMeshComponentGeodeIds(modelId, type);
16
17
  return geodeIds.map((geode_id) => ({ geode_id, type }));
17
18
  }),
@@ -143,8 +144,8 @@ function useModelVisibilityStyle(componentStyleFunctions) {
143
144
  }
144
145
 
145
146
  async function setModelComponentsVisibility(modelId, componentIds, visibility) {
146
- const typeIds = componentIds.filter((id) => MESH_TYPES.includes(id));
147
- const individualIds = componentIds.filter((id) => !MESH_TYPES.includes(id));
147
+ const typeIds = componentIds.filter((id) => MESH_COMPONENT_TYPES.includes(id));
148
+ const individualIds = componentIds.filter((id) => !MESH_COMPONENT_TYPES.includes(id));
148
149
 
149
150
  const promises = [];
150
151
  for (const typeId of typeIds) {
@@ -176,11 +177,23 @@ function useModelVisibilityStyle(componentStyleFunctions) {
176
177
  await setModelComponentsVisibility(modelId, idsForType, visibility);
177
178
  }
178
179
 
180
+ function modelComponentVisibility(modelId, componentId) {
181
+ const selection = useModelSelection(modelId, dataStyleState);
182
+ return selection.value.includes(componentId);
183
+ }
184
+
185
+ function modelComponentTypeVisibility(modelId, componentType) {
186
+ const selection = useModelSelection(modelId, dataStyleState);
187
+ return selection.value.includes(componentType);
188
+ }
189
+
179
190
  return {
180
191
  modelVisibility,
181
192
  setModelVisibility,
182
193
  setModelComponentsVisibility,
183
194
  setModelComponentTypeVisibility,
195
+ modelComponentVisibility,
196
+ modelComponentTypeVisibility,
184
197
  };
185
198
  }
186
199
 
@@ -3,7 +3,13 @@ import { liveQuery } from "dexie";
3
3
  import merge from "lodash/merge";
4
4
  import { useObservable } from "@vueuse/rxjs";
5
5
 
6
- export function useDataStyleState() {
6
+ let sharedState = undefined;
7
+
8
+ function getSharedState() {
9
+ if (sharedState) {
10
+ return sharedState;
11
+ }
12
+
7
13
  const data_style_db = database.data_style;
8
14
  const model_component_datastyle_db = database.model_component_datastyle;
9
15
  const model_component_type_datastyle_db = database.model_component_type_datastyle;
@@ -20,23 +26,6 @@ export function useDataStyleState() {
20
26
  { initialValue: {} },
21
27
  );
22
28
 
23
- const objectVisibility = computed(() => (id) => {
24
- if (styles.value[id]) {
25
- return styles.value[id].visibility;
26
- }
27
- return false;
28
- });
29
-
30
- const selectedObjects = computed(() => {
31
- const selection = [];
32
- for (const [id, value] of Object.entries(styles.value)) {
33
- if (value.visibility === true) {
34
- selection.push(id);
35
- }
36
- }
37
- return selection;
38
- });
39
-
40
29
  const modelComponentTypeStyles = useObservable(
41
30
  liveQuery(async () => {
42
31
  const all = await model_component_type_datastyle_db.toArray();
@@ -63,11 +52,104 @@ export function useDataStyleState() {
63
52
  { initialValue: {} },
64
53
  );
65
54
 
55
+ function updateComponentStyleCache(id_model, id_component, values) {
56
+ const key = `${id_model}_${id_component}`;
57
+ const current = componentStyles.value[key];
58
+ if (current) {
59
+ merge(current, values);
60
+ } else {
61
+ componentStyles.value[key] = merge({ id_model, id_component }, values);
62
+ }
63
+ }
64
+
65
+ function bulkUpdateComponentStyleCache(id_model, updates) {
66
+ const newVal = { ...componentStyles.value };
67
+ for (const { id_component, values } of updates) {
68
+ const key = `${id_model}_${id_component}`;
69
+ const current = newVal[key];
70
+ if (current) {
71
+ newVal[key] = merge({}, current, values);
72
+ } else {
73
+ newVal[key] = merge({ id_model, id_component }, values);
74
+ }
75
+ }
76
+ componentStyles.value = newVal;
77
+ }
78
+
79
+ function bulkUpdateComponentStylesCache(id_model, id_components, values) {
80
+ const newVal = { ...componentStyles.value };
81
+ for (const id_component of id_components) {
82
+ const key = `${id_model}_${id_component}`;
83
+ const current = newVal[key];
84
+ if (current) {
85
+ newVal[key] = merge({}, current, values);
86
+ } else {
87
+ newVal[key] = merge({ id_model, id_component }, values);
88
+ }
89
+ }
90
+ componentStyles.value = newVal;
91
+ }
92
+
93
+ function updateModelComponentTypeStyleCache(id_model, type, values) {
94
+ const key = `${id_model}_${type}`;
95
+ if (!modelComponentTypeStyles.value[key]) {
96
+ modelComponentTypeStyles.value[key] = { id_model, type };
97
+ }
98
+ merge(modelComponentTypeStyles.value[key], values);
99
+ }
100
+
101
+ function updateStyleCache(id, values) {
102
+ if (!styles.value[id]) {
103
+ styles.value[id] = { id };
104
+ }
105
+ merge(styles.value[id], values);
106
+ }
107
+
108
+ sharedState = {
109
+ styles,
110
+ modelComponentTypeStyles,
111
+ componentStyles,
112
+ updateComponentStyleCache,
113
+ bulkUpdateComponentStyleCache,
114
+ bulkUpdateComponentStylesCache,
115
+ updateModelComponentTypeStyleCache,
116
+ updateStyleCache,
117
+ };
118
+
119
+ return sharedState;
120
+ }
121
+
122
+ export function useDataStyleState() {
123
+ const data_style_db = database.data_style;
124
+ const model_component_datastyle_db = database.model_component_datastyle;
125
+ const model_component_type_datastyle_db = database.model_component_type_datastyle;
126
+
127
+ const state = getSharedState();
128
+ const { styles, modelComponentTypeStyles, componentStyles } = state;
129
+
130
+ const objectVisibility = computed(() => (id) => {
131
+ if (styles.value[id]) {
132
+ return styles.value[id].visibility;
133
+ }
134
+ return false;
135
+ });
136
+
137
+ const selectedObjects = computed(() => {
138
+ const selection = [];
139
+ for (const [id, value] of Object.entries(styles.value)) {
140
+ if (value.visibility === true) {
141
+ selection.push(id);
142
+ }
143
+ }
144
+ return selection;
145
+ });
146
+
66
147
  function getStyle(id) {
67
148
  return { ...toRaw(styles.value[id]) };
68
149
  }
69
150
 
70
151
  function mutateStyle(id, values) {
152
+ state.updateStyleCache(id, values);
71
153
  const style = getStyle(id);
72
154
  merge(style, values);
73
155
  return data_style_db.put(structuredClone({ id, ...toRaw(style) }));
@@ -92,13 +174,11 @@ export function useDataStyleState() {
92
174
  }
93
175
 
94
176
  return {
177
+ ...state,
95
178
  getStyle,
96
179
  getComponentStyle,
97
180
  getModelComponentTypeStyle,
98
181
  mutateStyle,
99
- styles,
100
- componentStyles,
101
- modelComponentTypeStyles,
102
182
  objectVisibility,
103
183
  selectedObjects,
104
184
  clear,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.22.1",
3
+ "version": "10.23.0-rc.2",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -34,8 +34,8 @@
34
34
  "build": ""
35
35
  },
36
36
  "dependencies": {
37
- "@geode/opengeodeweb-back": "latest",
38
- "@geode/opengeodeweb-viewer": "latest",
37
+ "@geode/opengeodeweb-back": "next",
38
+ "@geode/opengeodeweb-viewer": "next",
39
39
  "@google-cloud/run": "3.2.0",
40
40
  "@kitware/vtk.js": "33.3.0",
41
41
  "@mdi/font": "7.4.47",