@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
@@ -7,6 +7,11 @@ import { useDataStyleStore } from "@ogw_front/stores/data_style";
7
7
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
8
8
  import { useTreeviewStore } from "@ogw_front/stores/treeview";
9
9
 
10
+ import BlocksOptions from "./BlocksOptions.vue";
11
+ import CornersOptions from "./CornersOptions.vue";
12
+ import LinesOptions from "./LinesOptions.vue";
13
+ import SurfacesOptions from "./SurfacesOptions.vue";
14
+
10
15
  const dataStyleStore = useDataStyleStore();
11
16
  const hybridViewerStore = useHybridViewerStore();
12
17
  const dataStore = useDataStore();
@@ -26,108 +31,58 @@ const { itemProps } = defineProps({
26
31
 
27
32
  const modelId = computed(() => itemProps.meta_data.modelId || itemProps.id);
28
33
  const componentId = computed(() => itemProps.meta_data.pickedComponentId);
29
- const selection = dataStyleStore.visibleMeshComponents(modelId.value);
34
+ const selection = computed(() => dataStyleStore.visibleMeshComponents(modelId.value).value || []);
30
35
  const componentType = ref(undefined);
31
36
 
32
- watchEffect(async () => {
33
- if (itemProps.meta_data.viewer_type === "model_component_type") {
34
- componentType.value = itemProps.meta_data.modelComponentType;
35
- } else if (componentId.value && modelId.value) {
36
- componentType.value = await dataStore.meshComponentType(modelId.value, componentId.value);
37
- } else {
37
+ watch(
38
+ () => [
39
+ modelId.value,
40
+ componentId.value,
41
+ itemProps.meta_data.viewer_type,
42
+ itemProps.meta_data.modelComponentType,
43
+ ],
44
+ async () => {
38
45
  componentType.value = undefined;
39
- }
40
- });
41
-
42
- const modelVisibility = computed({
43
- get: () => dataStyleStore.modelVisibility(modelId.value),
44
- set: async (newValue) => {
45
- await dataStyleStore.setModelVisibility(modelId.value, newValue);
46
- hybridViewerStore.remoteRender();
47
- },
48
- });
49
-
50
- const modelComponentTypeVisibility = computed({
51
- get: () => selection.value.includes(componentType.value),
52
- set: async (newValue) => {
53
- const targetTypes = getBatchComponentIds(componentType.value);
54
- const promises = targetTypes.map((type) =>
55
- dataStyleStore.setModelComponentTypeVisibility(modelId.value, type, newValue),
56
- );
57
- await Promise.all(promises);
58
- hybridViewerStore.remoteRender();
59
- },
60
- });
61
-
62
- const componentVisibility = computed({
63
- get: () => selection.value.includes(componentId.value),
64
- set: async (newValue) => {
65
- const targetIds = getBatchComponentIds(componentId.value);
66
- await dataStyleStore.setModelComponentsVisibility(modelId.value, targetIds, newValue);
67
- hybridViewerStore.remoteRender();
68
- },
69
- });
70
-
71
- const componentColor = computed({
72
- get: () =>
73
- componentId.value
74
- ? dataStyleStore.getModelComponentEffectiveColor(
75
- modelId.value,
76
- componentId.value,
77
- componentType.value,
78
- )
79
- : undefined,
80
- set: async (color) => {
81
- if (componentId.value) {
82
- const targetIds = getBatchComponentIds(componentId.value);
83
- await dataStyleStore.setModelComponentsColor(modelId.value, targetIds, color);
84
- hybridViewerStore.remoteRender();
85
- }
86
- },
87
- });
88
-
89
- const modelComponentTypeColor = computed({
90
- get: () =>
91
- componentType.value
92
- ? dataStyleStore.getModelComponentTypeColor(modelId.value, componentType.value)
93
- : undefined,
94
- set: async (color) => {
95
- if (componentType.value) {
96
- const targetTypes = getBatchComponentIds(componentType.value);
97
- const promises = targetTypes.map((type) =>
98
- dataStyleStore.setModelComponentTypeColor(modelId.value, type, color),
99
- );
100
- await Promise.all(promises);
101
- hybridViewerStore.remoteRender();
46
+ if (itemProps.meta_data.viewer_type === "model_component_type") {
47
+ componentType.value = itemProps.meta_data.modelComponentType;
48
+ } else if (componentId.value && modelId.value) {
49
+ const currentModelId = modelId.value;
50
+ const currentCompId = componentId.value;
51
+ const type = await dataStore.meshComponentType(currentModelId, currentCompId);
52
+ if (
53
+ modelId.value === currentModelId &&
54
+ componentId.value === currentCompId &&
55
+ itemProps.meta_data.viewer_type !== "model_component_type"
56
+ ) {
57
+ componentType.value = type;
58
+ }
102
59
  }
103
60
  },
104
- });
61
+ { immediate: true },
62
+ );
105
63
 
106
- const modelComponentTypeColorMode = computed({
107
- get: () => dataStyleStore.getModelComponentTypeColorMode(modelId.value, componentType.value),
108
- set: async (colorMode) => {
109
- if (componentType.value) {
110
- const targetTypes = getBatchComponentIds(componentType.value);
111
- const promises = targetTypes.map((type) =>
112
- dataStyleStore.setModelComponentTypeColorMode(modelId.value, type, colorMode),
113
- );
114
- await Promise.all(promises);
115
- hybridViewerStore.remoteRender();
64
+ const targetComponentIds = ref([]);
65
+ watch(
66
+ () => [modelId.value, componentType.value],
67
+ async () => {
68
+ targetComponentIds.value = [];
69
+ if (componentType.value && modelId.value) {
70
+ const currentModelId = modelId.value;
71
+ const currentType = componentType.value;
72
+ const ids = await dataStore.getMeshComponentGeodeIds(currentModelId, currentType);
73
+ if (modelId.value === currentModelId && componentType.value === currentType) {
74
+ targetComponentIds.value = ids;
75
+ }
116
76
  }
117
77
  },
118
- });
78
+ { immediate: true },
79
+ );
119
80
 
120
- const componentColorMode = computed({
121
- get: () => dataStyleStore.getModelComponentColorMode(modelId.value, componentId.value),
122
- set: async (colorMode) => {
123
- if (componentId.value) {
124
- const targetIds = getBatchComponentIds(componentId.value);
125
- const promises = targetIds.map((id) =>
126
- dataStyleStore.setModelComponentColorMode(modelId.value, id, colorMode),
127
- );
128
- await Promise.all(promises);
129
- hybridViewerStore.remoteRender();
130
- }
81
+ const modelVisibility = computed({
82
+ get: () => dataStyleStore.modelVisibility(modelId.value),
83
+ set: async (newValue) => {
84
+ await dataStyleStore.setModelVisibility(modelId.value, newValue);
85
+ hybridViewerStore.remoteRender();
131
86
  },
132
87
  });
133
88
 
@@ -136,10 +91,6 @@ const colorModes = [
136
91
  { title: "Random", value: "random" },
137
92
  ];
138
93
 
139
- const modelComponentTypeLabel = computed(() =>
140
- componentType.value ? `${componentType.value}s Options` : "",
141
- );
142
-
143
94
  const modelComponentsColorMode = ref("constant");
144
95
 
145
96
  const modelComponentsColor = computed({
@@ -198,41 +149,30 @@ watch(modelComponentsColorMode, async (colorMode) => {
198
149
  </template>
199
150
  </OptionsSection>
200
151
 
201
- <OptionsSection v-if="componentType" :title="modelComponentTypeLabel" class="mt-6">
202
- <VisibilitySwitch v-model="modelComponentTypeVisibility" />
203
- <v-label class="text-caption mb-1 mt-2">Color Mode</v-label>
204
- <v-select
205
- v-model="modelComponentTypeColorMode"
206
- :items="colorModes"
207
- density="compact"
208
- hide-details
209
- class="mb-3"
210
- variant="outlined"
211
- />
212
-
213
- <template v-if="modelComponentTypeColorMode === 'constant'">
214
- <v-label class="text-caption mb-1">Color</v-label>
215
- <ViewerOptionsColorPicker v-model="modelComponentTypeColor" />
216
- </template>
217
- </OptionsSection>
218
-
219
- <OptionsSection v-if="componentId" title="Component Options" class="mt-6">
220
- <VisibilitySwitch v-model="componentVisibility" />
221
- <v-label class="text-caption mb-1 mt-2">Color Mode</v-label>
222
- <v-select
223
- v-model="componentColorMode"
224
- :items="colorModes"
225
- density="compact"
226
- hide-details
227
- class="mb-3"
228
- variant="outlined"
229
- />
230
-
231
- <template v-if="componentColorMode === 'constant'">
232
- <v-label class="text-caption mb-1">Color</v-label>
233
- <ViewerOptionsColorPicker v-model="componentColor" />
234
- </template>
235
- </OptionsSection>
152
+ <BlocksOptions
153
+ v-if="componentType === 'Block'"
154
+ :modelId="modelId"
155
+ :blockId="componentId"
156
+ :targetBlockIds="targetComponentIds"
157
+ />
158
+ <SurfacesOptions
159
+ v-else-if="componentType === 'Surface'"
160
+ :modelId="modelId"
161
+ :surfaceId="componentId"
162
+ :targetSurfaceIds="targetComponentIds"
163
+ />
164
+ <LinesOptions
165
+ v-else-if="componentType === 'Line'"
166
+ :modelId="modelId"
167
+ :lineId="componentId"
168
+ :targetLineIds="targetComponentIds"
169
+ />
170
+ <CornersOptions
171
+ v-else-if="componentType === 'Corner'"
172
+ :modelId="modelId"
173
+ :cornerId="componentId"
174
+ :targetCornerIds="targetComponentIds"
175
+ />
236
176
  </v-sheet>
237
177
  </template>
238
178
 
@@ -0,0 +1,260 @@
1
+ <script setup>
2
+ import OptionsSection from "@ogw_front/components/Viewer/Options/OptionsSection.vue";
3
+ import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
4
+ import VisibilitySwitch from "@ogw_front/components/Viewer/Options/VisibilitySwitch.vue";
5
+ import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json";
6
+ import { useDataStyleStore } from "@ogw_front/stores/data_style";
7
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
8
+
9
+ const { modelId, surfaceId, targetSurfaceIds } = defineProps({
10
+ modelId: { type: String, required: true },
11
+ surfaceId: { type: String, default: undefined },
12
+ targetSurfaceIds: { type: Array, required: true },
13
+ });
14
+
15
+ const dataStyleStore = useDataStyleStore();
16
+ const hybridViewerStore = useHybridViewerStore();
17
+
18
+ // Visibility
19
+ const surfacesVisibility = computed({
20
+ get: () => dataStyleStore.modelComponentTypeVisibility(modelId, "Surface"),
21
+ set: async (newValue) => {
22
+ await dataStyleStore.setModelComponentTypeVisibility(modelId, "Surface", newValue);
23
+ hybridViewerStore.remoteRender();
24
+ },
25
+ });
26
+
27
+ const surfaceVisibility = computed({
28
+ get: () => dataStyleStore.modelSurfaceVisibility(modelId, surfaceId),
29
+ set: async (newValue) => {
30
+ await dataStyleStore.setModelSurfacesVisibility(modelId, [surfaceId], newValue);
31
+ hybridViewerStore.remoteRender();
32
+ },
33
+ });
34
+
35
+ // Color
36
+ const surfacesColor = computed({
37
+ get: () => dataStyleStore.modelComponentTypeColor(modelId, "Surface"),
38
+ set: async (color) => {
39
+ await dataStyleStore.setModelComponentTypeColor(modelId, "Surface", color);
40
+ hybridViewerStore.remoteRender();
41
+ },
42
+ });
43
+
44
+ const surfaceColor = computed({
45
+ get: () => dataStyleStore.modelSurfaceColor(modelId, surfaceId),
46
+ set: async (color) => {
47
+ if (surfaceId) {
48
+ await dataStyleStore.setModelSurfacesColor(modelId, [surfaceId], color);
49
+ hybridViewerStore.remoteRender();
50
+ }
51
+ },
52
+ });
53
+
54
+ const surfacesColorMode = computed({
55
+ get: () => dataStyleStore.getModelComponentTypeColorMode(modelId, "Surface"),
56
+ set: async (colorMode) => {
57
+ await dataStyleStore.setModelComponentTypeColorMode(modelId, "Surface", colorMode);
58
+ hybridViewerStore.remoteRender();
59
+ },
60
+ });
61
+
62
+ const surfaceColorMode = computed({
63
+ get: () => dataStyleStore.modelSurfaceColorMode(modelId, surfaceId),
64
+ set: async (colorMode) => {
65
+ if (surfaceId) {
66
+ await dataStyleStore.setModelComponentColorMode(modelId, surfaceId, colorMode);
67
+ hybridViewerStore.remoteRender();
68
+ }
69
+ },
70
+ });
71
+
72
+ // Group Attributes
73
+ const surfacesVertexAttributeName = computed({
74
+ get: () => dataStyleStore.modelSurfacesVertexAttributeName(modelId, targetSurfaceIds[0]),
75
+ set: async (newValue) => {
76
+ await dataStyleStore.setModelSurfacesVertexAttributeName(modelId, targetSurfaceIds, newValue);
77
+ hybridViewerStore.remoteRender();
78
+ },
79
+ });
80
+
81
+ const surfacesVertexAttributeRange = computed({
82
+ get: () => dataStyleStore.modelSurfacesVertexAttributeRange(modelId, targetSurfaceIds[0]),
83
+ set: async (newValue) => {
84
+ await dataStyleStore.setModelSurfacesVertexAttributeRange(
85
+ modelId,
86
+ targetSurfaceIds,
87
+ newValue[0],
88
+ newValue[1],
89
+ );
90
+ hybridViewerStore.remoteRender();
91
+ },
92
+ });
93
+
94
+ const surfacesVertexAttributeColorMap = computed({
95
+ get: () => dataStyleStore.modelSurfacesVertexAttributeColorMap(modelId, targetSurfaceIds[0]),
96
+ set: async (newValue) => {
97
+ await dataStyleStore.setModelSurfacesVertexAttributeColorMap(
98
+ modelId,
99
+ targetSurfaceIds,
100
+ newValue,
101
+ );
102
+ hybridViewerStore.remoteRender();
103
+ },
104
+ });
105
+
106
+ const surfacesPolygonAttributeName = computed({
107
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeName(modelId, targetSurfaceIds[0]),
108
+ set: async (newValue) => {
109
+ await dataStyleStore.setModelSurfacesPolygonAttributeName(modelId, targetSurfaceIds, newValue);
110
+ hybridViewerStore.remoteRender();
111
+ },
112
+ });
113
+
114
+ const surfacesPolygonAttributeRange = computed({
115
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeRange(modelId, targetSurfaceIds[0]),
116
+ set: async (newValue) => {
117
+ await dataStyleStore.setModelSurfacesPolygonAttributeRange(
118
+ modelId,
119
+ targetSurfaceIds,
120
+ newValue[0],
121
+ newValue[1],
122
+ );
123
+ hybridViewerStore.remoteRender();
124
+ },
125
+ });
126
+
127
+ const surfacesPolygonAttributeColorMap = computed({
128
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeColorMap(modelId, targetSurfaceIds[0]),
129
+ set: async (newValue) => {
130
+ await dataStyleStore.setModelSurfacesPolygonAttributeColorMap(
131
+ modelId,
132
+ targetSurfaceIds,
133
+ newValue,
134
+ );
135
+ hybridViewerStore.remoteRender();
136
+ },
137
+ });
138
+
139
+ // Individual Attributes
140
+ const vertexAttributeName = computed({
141
+ get: () => dataStyleStore.modelSurfacesVertexAttributeName(modelId, surfaceId),
142
+ set: async (newValue) => {
143
+ await dataStyleStore.setModelSurfacesVertexAttributeName(modelId, [surfaceId], newValue);
144
+ hybridViewerStore.remoteRender();
145
+ },
146
+ });
147
+
148
+ const vertexAttributeRange = computed({
149
+ get: () => dataStyleStore.modelSurfacesVertexAttributeRange(modelId, surfaceId),
150
+ set: async (newValue) => {
151
+ await dataStyleStore.setModelSurfacesVertexAttributeRange(
152
+ modelId,
153
+ [surfaceId],
154
+ newValue[0],
155
+ newValue[1],
156
+ );
157
+ hybridViewerStore.remoteRender();
158
+ },
159
+ });
160
+
161
+ const vertexAttributeColorMap = computed({
162
+ get: () => dataStyleStore.modelSurfacesVertexAttributeColorMap(modelId, surfaceId),
163
+ set: async (newValue) => {
164
+ await dataStyleStore.setModelSurfacesVertexAttributeColorMap(modelId, [surfaceId], newValue);
165
+ hybridViewerStore.remoteRender();
166
+ },
167
+ });
168
+
169
+ const polygonAttributeName = computed({
170
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeName(modelId, surfaceId),
171
+ set: async (newValue) => {
172
+ await dataStyleStore.setModelSurfacesPolygonAttributeName(modelId, [surfaceId], newValue);
173
+ hybridViewerStore.remoteRender();
174
+ },
175
+ });
176
+
177
+ const polygonAttributeRange = computed({
178
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeRange(modelId, surfaceId),
179
+ set: async (newValue) => {
180
+ await dataStyleStore.setModelSurfacesPolygonAttributeRange(
181
+ modelId,
182
+ [surfaceId],
183
+ newValue[0],
184
+ newValue[1],
185
+ );
186
+ hybridViewerStore.remoteRender();
187
+ },
188
+ });
189
+
190
+ const polygonAttributeColorMap = computed({
191
+ get: () => dataStyleStore.modelSurfacesPolygonAttributeColorMap(modelId, surfaceId),
192
+ set: async (newValue) => {
193
+ await dataStyleStore.setModelSurfacesPolygonAttributeColorMap(modelId, [surfaceId], newValue);
194
+ hybridViewerStore.remoteRender();
195
+ },
196
+ });
197
+
198
+ const capabilities = {
199
+ color: { available: true },
200
+ textures: { available: false },
201
+ vertex: { available: true },
202
+ edge: { available: false },
203
+ cell: { available: false },
204
+ polygon: { available: true },
205
+ polyhedron: { available: false },
206
+ };
207
+
208
+ const vertexSchema = back_schemas.opengeodeweb_back.model_component_vertex_attribute_names;
209
+ const polygonSchema = back_schemas.opengeodeweb_back.model_component_polygon_attribute_names;
210
+ </script>
211
+
212
+ <template>
213
+ <div>
214
+ <OptionsSection title="Surfaces Options" class="mt-6">
215
+ <VisibilitySwitch v-model="surfacesVisibility" />
216
+ <v-row class="mt-2 pa-0">
217
+ <v-col class="pa-0">
218
+ <ViewerOptionsColoringTypeSelector
219
+ :id="modelId"
220
+ :componentId="targetSurfaceIds[0]"
221
+ v-model:coloring_style_key="surfacesColorMode"
222
+ v-model:color="surfacesColor"
223
+ v-model:vertex_attribute_name="surfacesVertexAttributeName"
224
+ v-model:vertex_attribute_range="surfacesVertexAttributeRange"
225
+ v-model:vertex_attribute_color_map="surfacesVertexAttributeColorMap"
226
+ v-model:polygon_attribute_name="surfacesPolygonAttributeName"
227
+ v-model:polygon_attribute_range="surfacesPolygonAttributeRange"
228
+ v-model:polygon_attribute_color_map="surfacesPolygonAttributeColorMap"
229
+ :capabilities="capabilities"
230
+ :schemas="{ vertex: vertexSchema, polygon: polygonSchema }"
231
+ :allowRandom="true"
232
+ />
233
+ </v-col>
234
+ </v-row>
235
+ </OptionsSection>
236
+
237
+ <OptionsSection v-if="surfaceId" title="Component Options" class="mt-6">
238
+ <VisibilitySwitch v-model="surfaceVisibility" />
239
+ <v-row class="mt-2 pa-0">
240
+ <v-col class="pa-0">
241
+ <ViewerOptionsColoringTypeSelector
242
+ :id="modelId"
243
+ :componentId="surfaceId"
244
+ v-model:coloring_style_key="surfaceColorMode"
245
+ v-model:color="surfaceColor"
246
+ v-model:vertex_attribute_name="vertexAttributeName"
247
+ v-model:vertex_attribute_range="vertexAttributeRange"
248
+ v-model:vertex_attribute_color_map="vertexAttributeColorMap"
249
+ v-model:polygon_attribute_name="polygonAttributeName"
250
+ v-model:polygon_attribute_range="polygonAttributeRange"
251
+ v-model:polygon_attribute_color_map="polygonAttributeColorMap"
252
+ :capabilities="capabilities"
253
+ :schemas="{ vertex: vertexSchema, polygon: polygonSchema }"
254
+ :allowRandom="true"
255
+ />
256
+ </v-col>
257
+ </v-row>
258
+ </OptionsSection>
259
+ </div>
260
+ </template>
@@ -8,8 +8,9 @@ const name = defineModel("name", { type: String });
8
8
  const range = defineModel("range", { type: Array });
9
9
  const colorMap = defineModel("colorMap", { type: String });
10
10
 
11
- const { id, schema } = defineProps({
11
+ const { id, componentId, schema } = defineProps({
12
12
  id: { type: String, required: true },
13
+ componentId: { type: String, default: undefined },
13
14
  schema: { type: Object, required: true },
14
15
  });
15
16
 
@@ -49,7 +50,13 @@ function resetRange() {
49
50
  }
50
51
 
51
52
  function getAttributes() {
53
+ if (schema.properties?.component_id && componentId === undefined) {
54
+ return;
55
+ }
52
56
  const params = { id };
57
+ if (componentId !== undefined) {
58
+ params.component_id = componentId;
59
+ }
53
60
  backStore.request(
54
61
  { schema, params },
55
62
  {
@@ -65,7 +72,7 @@ onMounted(() => {
65
72
  });
66
73
 
67
74
  watch(
68
- () => [id, schema],
75
+ () => [id, componentId, schema],
69
76
  () => {
70
77
  getAttributes();
71
78
  },
@@ -86,6 +93,12 @@ watch(
86
93
  }
87
94
  },
88
95
  );
96
+
97
+ watch(name, (newName, oldName) => {
98
+ if (newName !== oldName) {
99
+ resetRange();
100
+ }
101
+ });
89
102
  </script>
90
103
 
91
104
  <template>
@@ -29,14 +29,36 @@ const polyhedron_attribute_name = defineModel("polyhedron_attribute_name");
29
29
  const polyhedron_attribute_range = defineModel("polyhedron_attribute_range");
30
30
  const polyhedron_attribute_color_map = defineModel("polyhedron_attribute_color_map");
31
31
 
32
- const { id, capabilities } = defineProps({
32
+ const {
33
+ id,
34
+ componentId,
35
+ capabilities,
36
+ schemas,
37
+ allowRandom = false,
38
+ } = defineProps({
33
39
  id: { type: String, required: true },
40
+ componentId: { type: String, default: undefined },
34
41
  capabilities: {
35
42
  type: Object,
36
43
  default: () => ({}),
37
44
  },
45
+ schemas: {
46
+ type: Object,
47
+ default: () => ({}),
48
+ },
49
+ allowRandom: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
38
53
  });
39
54
 
55
+ const vertexSchema = schemas.vertex || back_schemas.opengeodeweb_back.vertex_attribute_names;
56
+ const edgeSchema = schemas.edge || back_schemas.opengeodeweb_back.edge_attribute_names;
57
+ const cellSchema = schemas.cell || back_schemas.opengeodeweb_back.cell_attribute_names;
58
+ const polygonSchema = schemas.polygon || back_schemas.opengeodeweb_back.polygon_attribute_names;
59
+ const polyhedronSchema =
60
+ schemas.polyhedron || back_schemas.opengeodeweb_back.polyhedron_attribute_names;
61
+
40
62
  function isAvailable(key) {
41
63
  if (capabilities[key] && capabilities[key].available === false) {
42
64
  return false;
@@ -75,6 +97,7 @@ const has_polyhedra = computed(
75
97
  );
76
98
 
77
99
  const color_dict = { name: "Color", value: "color" };
100
+ const random_dict = { name: "Random color", value: "random" };
78
101
  const textures_dict = { name: "Textures", value: "textures" };
79
102
  const vertex_dict = { name: "Vertex attribute", value: "vertex" };
80
103
  const edge_dict = { name: "Edge attribute", value: "edge" };
@@ -88,6 +111,9 @@ const coloring_styles = computed(() => {
88
111
  const array = [];
89
112
  if (has_color.value) {
90
113
  array.push(color_dict);
114
+ if (allowRandom) {
115
+ array.push(random_dict);
116
+ }
91
117
  }
92
118
  if (has_textures.value) {
93
119
  array.push(textures_dict);
@@ -114,14 +140,25 @@ const coloring_styles = computed(() => {
114
140
  return { labels, values };
115
141
  });
116
142
 
117
- const coloring_style_label = ref(
118
- coloring_styles.value.labels[coloring_styles.value.values.indexOf(coloring_style_key.value)],
119
- );
143
+ const coloring_style_label = ref("");
120
144
 
121
145
  watch(coloring_style_label, (value) => {
122
- coloring_style_key.value =
123
- coloring_styles.value.values[coloring_styles.value.labels.indexOf(value)];
146
+ const index = coloring_styles.value.labels.indexOf(value);
147
+ if (index !== -1) {
148
+ coloring_style_key.value = coloring_styles.value.values[index];
149
+ }
124
150
  });
151
+
152
+ watch(
153
+ coloring_style_key,
154
+ (value) => {
155
+ const index = coloring_styles.value.values.indexOf(value);
156
+ if (index !== -1) {
157
+ coloring_style_label.value = coloring_styles.value.labels[index];
158
+ }
159
+ },
160
+ { immediate: true },
161
+ );
125
162
  </script>
126
163
  <template>
127
164
  <v-row justify="center" align="center">
@@ -155,7 +192,8 @@ watch(coloring_style_label, (value) => {
155
192
  v-model:range="vertex_attribute_range"
156
193
  v-model:colorMap="vertex_attribute_color_map"
157
194
  :id="id"
158
- :schema="back_schemas.opengeodeweb_back.vertex_attribute_names"
195
+ :componentId="componentId"
196
+ :schema="vertexSchema"
159
197
  />
160
198
  </template>
161
199
  <template v-if="coloring_style_key === edge_dict['value'] && hasColorMap('edge')">
@@ -164,7 +202,8 @@ watch(coloring_style_label, (value) => {
164
202
  v-model:range="edge_attribute_range"
165
203
  v-model:colorMap="edge_attribute_color_map"
166
204
  :id="id"
167
- :schema="back_schemas.opengeodeweb_back.edge_attribute_names"
205
+ :componentId="componentId"
206
+ :schema="edgeSchema"
168
207
  />
169
208
  </template>
170
209
  <template v-if="coloring_style_key === cell_dict['value'] && hasColorMap('cell')">
@@ -173,7 +212,8 @@ watch(coloring_style_label, (value) => {
173
212
  v-model:range="cell_attribute_range"
174
213
  v-model:colorMap="cell_attribute_color_map"
175
214
  :id="id"
176
- :schema="back_schemas.opengeodeweb_back.cell_attribute_names"
215
+ :componentId="componentId"
216
+ :schema="cellSchema"
177
217
  />
178
218
  </template>
179
219
  <template v-if="coloring_style_key === polygon_dict['value'] && hasColorMap('polygon')">
@@ -182,7 +222,8 @@ watch(coloring_style_label, (value) => {
182
222
  v-model:range="polygon_attribute_range"
183
223
  v-model:colorMap="polygon_attribute_color_map"
184
224
  :id="id"
185
- :schema="back_schemas.opengeodeweb_back.polygon_attribute_names"
225
+ :componentId="componentId"
226
+ :schema="polygonSchema"
186
227
  />
187
228
  </template>
188
229
  <template
@@ -193,7 +234,8 @@ watch(coloring_style_label, (value) => {
193
234
  v-model:range="polyhedron_attribute_range"
194
235
  v-model:colorMap="polyhedron_attribute_color_map"
195
236
  :id="id"
196
- :schema="back_schemas.opengeodeweb_back.polyhedron_attribute_names"
237
+ :componentId="componentId"
238
+ :schema="polyhedronSchema"
197
239
  />
198
240
  </template>
199
241
  </v-col>