@geode/opengeodeweb-front 10.44.0-rc.7 → 10.44.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build/server/utils/scripts.js +34 -23
- package/app/components/MissingFilesSelector.vue +30 -17
- package/app/components/ObjectSelector.vue +34 -23
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager_helpers/restore.ts +20 -11
- package/app/composables/use_overlapping_picker.ts +23 -37
- package/app/composables/virtual_tree_flatten.ts +66 -43
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/infra.ts +26 -21
- package/app/utils/color_picker.ts +18 -15
- package/internal/database/database.ts +47 -32
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
- package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +83 -39
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/edge.ts +88 -44
- package/internal/stores/data_style/model/lines/vertex.ts +88 -44
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
- package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
- package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
- package/internal/stores/hybrid_viewer/highlight.ts +70 -54
- package/internal/stores/hybrid_viewer/scene.ts +31 -25
- package/package.json +1 -1
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/scripts.ts +35 -30
|
@@ -118,12 +118,28 @@ interface UseModelSurfacesPolygonAttributeReturn {
|
|
|
118
118
|
) => Promise<void>;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
type ModelSurfacesPolygonAttributeGetters = Pick<
|
|
122
|
+
UseModelSurfacesPolygonAttributeReturn,
|
|
123
|
+
| "modelSurfacesPolygonAttributeStoredConfig"
|
|
124
|
+
| "modelSurfacesPolygonAttributeName"
|
|
125
|
+
| "modelSurfacesPolygonAttributeItem"
|
|
126
|
+
| "modelSurfacesPolygonAttributeRange"
|
|
127
|
+
| "modelSurfacesPolygonAttributeColorMap"
|
|
128
|
+
| "modelSurfacesPolygonAttributeNoDataColor"
|
|
129
|
+
| "modelSurfacesPolygonAttributeTimeStep"
|
|
130
|
+
> & {
|
|
131
|
+
modelSurfacesPolygonAttributeLastItem: (
|
|
132
|
+
modelId: string,
|
|
133
|
+
componentId: string | undefined,
|
|
134
|
+
name: string | undefined,
|
|
135
|
+
) => number;
|
|
136
|
+
};
|
|
137
|
+
|
|
121
138
|
// oxlint-disable-next-line max-lines-per-function
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
const viewerStore = useViewerStore();
|
|
139
|
+
function useModelSurfacesPolygonAttributeGetters(
|
|
140
|
+
modelSurfacesCommonStyle: ReturnType<typeof useModelSurfacesCommonStyle>,
|
|
141
|
+
): ModelSurfacesPolygonAttributeGetters {
|
|
142
|
+
const { attributeTimeStep } = useAttributeTimeStepStyle();
|
|
127
143
|
function modelSurfacesPolygonAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
128
144
|
return (
|
|
129
145
|
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.polygon shape is defined by the data style schema.
|
|
@@ -149,37 +165,6 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
149
165
|
no_data_color: DEFAULT_NO_DATA_COLOR,
|
|
150
166
|
};
|
|
151
167
|
}
|
|
152
|
-
async function mutateModelSurfacesPolygonStyle(
|
|
153
|
-
modelId: string,
|
|
154
|
-
surfaceIds: string[],
|
|
155
|
-
values: Record<string, unknown>,
|
|
156
|
-
): Promise<void> {
|
|
157
|
-
const tasks: Promise<void>[] = [
|
|
158
|
-
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
159
|
-
polygon: values,
|
|
160
|
-
}),
|
|
161
|
-
];
|
|
162
|
-
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
163
|
-
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
164
|
-
tasks.push(
|
|
165
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
166
|
-
polygon: values,
|
|
167
|
-
}),
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
await Promise.all(tasks);
|
|
171
|
-
}
|
|
172
|
-
async function setModelSurfacesPolygonAttributeStoredConfig(
|
|
173
|
-
modelId: string,
|
|
174
|
-
surfaceIds: string[],
|
|
175
|
-
name: string | undefined,
|
|
176
|
-
item: number | undefined,
|
|
177
|
-
config: Partial<AttributeStoredConfig>,
|
|
178
|
-
): Promise<void> {
|
|
179
|
-
await mutateModelSurfacesPolygonStyle(modelId, surfaceIds, {
|
|
180
|
-
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
168
|
function modelSurfacesPolygonAttributeName(
|
|
184
169
|
modelId: string,
|
|
185
170
|
surfaceId?: string,
|
|
@@ -243,6 +228,65 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
243
228
|
modelSurfacesPolygonAttribute(modelId, surfaceId).name,
|
|
244
229
|
);
|
|
245
230
|
}
|
|
231
|
+
return {
|
|
232
|
+
modelSurfacesPolygonAttributeStoredConfig,
|
|
233
|
+
modelSurfacesPolygonAttributeName,
|
|
234
|
+
modelSurfacesPolygonAttributeLastItem,
|
|
235
|
+
modelSurfacesPolygonAttributeItem,
|
|
236
|
+
modelSurfacesPolygonAttributeRange,
|
|
237
|
+
modelSurfacesPolygonAttributeColorMap,
|
|
238
|
+
modelSurfacesPolygonAttributeNoDataColor,
|
|
239
|
+
modelSurfacesPolygonAttributeTimeStep,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
244
|
+
function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeReturn {
|
|
245
|
+
const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
246
|
+
const dataStore = useDataStore();
|
|
247
|
+
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
248
|
+
const {
|
|
249
|
+
modelSurfacesPolygonAttributeStoredConfig,
|
|
250
|
+
modelSurfacesPolygonAttributeName,
|
|
251
|
+
modelSurfacesPolygonAttributeLastItem,
|
|
252
|
+
modelSurfacesPolygonAttributeItem,
|
|
253
|
+
modelSurfacesPolygonAttributeRange,
|
|
254
|
+
modelSurfacesPolygonAttributeColorMap,
|
|
255
|
+
modelSurfacesPolygonAttributeNoDataColor,
|
|
256
|
+
modelSurfacesPolygonAttributeTimeStep,
|
|
257
|
+
} = useModelSurfacesPolygonAttributeGetters(modelSurfacesCommonStyle);
|
|
258
|
+
const viewerStore = useViewerStore();
|
|
259
|
+
async function mutateModelSurfacesPolygonStyle(
|
|
260
|
+
modelId: string,
|
|
261
|
+
surfaceIds: string[],
|
|
262
|
+
values: Record<string, unknown>,
|
|
263
|
+
): Promise<void> {
|
|
264
|
+
const tasks: Promise<void>[] = [
|
|
265
|
+
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
266
|
+
polygon: values,
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
270
|
+
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
271
|
+
tasks.push(
|
|
272
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
273
|
+
polygon: values,
|
|
274
|
+
}),
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
await Promise.all(tasks);
|
|
278
|
+
}
|
|
279
|
+
async function setModelSurfacesPolygonAttributeStoredConfig(
|
|
280
|
+
modelId: string,
|
|
281
|
+
surfaceIds: string[],
|
|
282
|
+
name: string | undefined,
|
|
283
|
+
item: number | undefined,
|
|
284
|
+
config: Partial<AttributeStoredConfig>,
|
|
285
|
+
): Promise<void> {
|
|
286
|
+
await mutateModelSurfacesPolygonStyle(modelId, surfaceIds, {
|
|
287
|
+
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
288
|
+
});
|
|
289
|
+
}
|
|
246
290
|
async function setModelSurfacesPolygonAttribute(
|
|
247
291
|
modelId: string,
|
|
248
292
|
surfaceIds: string[],
|
|
@@ -112,12 +112,28 @@ interface UseModelSurfacesVertexAttributeReturn {
|
|
|
112
112
|
) => Promise<unknown>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
type ModelSurfacesVertexAttributeGetters = Pick<
|
|
116
|
+
UseModelSurfacesVertexAttributeReturn,
|
|
117
|
+
| "modelSurfacesVertexAttributeStoredConfig"
|
|
118
|
+
| "modelSurfacesVertexAttributeName"
|
|
119
|
+
| "modelSurfacesVertexAttributeItem"
|
|
120
|
+
| "modelSurfacesVertexAttributeRange"
|
|
121
|
+
| "modelSurfacesVertexAttributeColorMap"
|
|
122
|
+
| "modelSurfacesVertexAttributeNoDataColor"
|
|
123
|
+
| "modelSurfacesVertexAttributeTimeStep"
|
|
124
|
+
> & {
|
|
125
|
+
modelSurfacesVertexAttributeLastItem: (
|
|
126
|
+
modelId: string,
|
|
127
|
+
componentId: string | undefined,
|
|
128
|
+
name: string | undefined,
|
|
129
|
+
) => number;
|
|
130
|
+
};
|
|
131
|
+
|
|
115
132
|
// oxlint-disable-next-line max-lines-per-function
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
const viewerStore = useViewerStore();
|
|
133
|
+
function useModelSurfacesVertexAttributeGetters(
|
|
134
|
+
modelSurfacesCommonStyle: ReturnType<typeof useModelSurfacesCommonStyle>,
|
|
135
|
+
): ModelSurfacesVertexAttributeGetters {
|
|
136
|
+
const { attributeTimeStep } = useAttributeTimeStepStyle();
|
|
121
137
|
function modelSurfacesVertexAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
122
138
|
return (
|
|
123
139
|
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.vertex shape is defined by the data style schema.
|
|
@@ -143,37 +159,6 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
143
159
|
no_data_color: DEFAULT_NO_DATA_COLOR,
|
|
144
160
|
};
|
|
145
161
|
}
|
|
146
|
-
async function mutateModelSurfacesVertexStyle(
|
|
147
|
-
modelId: string,
|
|
148
|
-
surfaceIds: string[],
|
|
149
|
-
values: Record<string, unknown>,
|
|
150
|
-
): Promise<void> {
|
|
151
|
-
const tasks: Promise<void>[] = [
|
|
152
|
-
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
153
|
-
vertex: values,
|
|
154
|
-
}),
|
|
155
|
-
];
|
|
156
|
-
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
157
|
-
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
158
|
-
tasks.push(
|
|
159
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
160
|
-
vertex: values,
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
await Promise.all(tasks);
|
|
165
|
-
}
|
|
166
|
-
async function setModelSurfacesVertexAttributeStoredConfig(
|
|
167
|
-
modelId: string,
|
|
168
|
-
surfaceIds: string[],
|
|
169
|
-
name: string | undefined,
|
|
170
|
-
item: number | undefined,
|
|
171
|
-
config: Partial<AttributeStoredConfig>,
|
|
172
|
-
): Promise<void> {
|
|
173
|
-
await mutateModelSurfacesVertexStyle(modelId, surfaceIds, {
|
|
174
|
-
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
162
|
function modelSurfacesVertexAttributeName(
|
|
178
163
|
modelId: string,
|
|
179
164
|
surfaceId?: string,
|
|
@@ -234,6 +219,65 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
234
219
|
modelSurfacesVertexAttribute(modelId, surfaceId).name,
|
|
235
220
|
);
|
|
236
221
|
}
|
|
222
|
+
return {
|
|
223
|
+
modelSurfacesVertexAttributeStoredConfig,
|
|
224
|
+
modelSurfacesVertexAttributeName,
|
|
225
|
+
modelSurfacesVertexAttributeLastItem,
|
|
226
|
+
modelSurfacesVertexAttributeItem,
|
|
227
|
+
modelSurfacesVertexAttributeRange,
|
|
228
|
+
modelSurfacesVertexAttributeColorMap,
|
|
229
|
+
modelSurfacesVertexAttributeNoDataColor,
|
|
230
|
+
modelSurfacesVertexAttributeTimeStep,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
235
|
+
function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeReturn {
|
|
236
|
+
const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
237
|
+
const dataStore = useDataStore();
|
|
238
|
+
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
239
|
+
const {
|
|
240
|
+
modelSurfacesVertexAttributeStoredConfig,
|
|
241
|
+
modelSurfacesVertexAttributeName,
|
|
242
|
+
modelSurfacesVertexAttributeLastItem,
|
|
243
|
+
modelSurfacesVertexAttributeItem,
|
|
244
|
+
modelSurfacesVertexAttributeRange,
|
|
245
|
+
modelSurfacesVertexAttributeColorMap,
|
|
246
|
+
modelSurfacesVertexAttributeNoDataColor,
|
|
247
|
+
modelSurfacesVertexAttributeTimeStep,
|
|
248
|
+
} = useModelSurfacesVertexAttributeGetters(modelSurfacesCommonStyle);
|
|
249
|
+
const viewerStore = useViewerStore();
|
|
250
|
+
async function mutateModelSurfacesVertexStyle(
|
|
251
|
+
modelId: string,
|
|
252
|
+
surfaceIds: string[],
|
|
253
|
+
values: Record<string, unknown>,
|
|
254
|
+
): Promise<void> {
|
|
255
|
+
const tasks: Promise<void>[] = [
|
|
256
|
+
modelSurfacesCommonStyle.mutateModelSurfacesColoring(modelId, surfaceIds, {
|
|
257
|
+
vertex: values,
|
|
258
|
+
}),
|
|
259
|
+
];
|
|
260
|
+
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
261
|
+
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
262
|
+
tasks.push(
|
|
263
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
264
|
+
vertex: values,
|
|
265
|
+
}),
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
await Promise.all(tasks);
|
|
269
|
+
}
|
|
270
|
+
async function setModelSurfacesVertexAttributeStoredConfig(
|
|
271
|
+
modelId: string,
|
|
272
|
+
surfaceIds: string[],
|
|
273
|
+
name: string | undefined,
|
|
274
|
+
item: number | undefined,
|
|
275
|
+
config: Partial<AttributeStoredConfig>,
|
|
276
|
+
): Promise<void> {
|
|
277
|
+
await mutateModelSurfacesVertexStyle(modelId, surfaceIds, {
|
|
278
|
+
storedConfigs: { [name ?? ""]: { lastItem: item, [item ?? 0]: config } },
|
|
279
|
+
});
|
|
280
|
+
}
|
|
237
281
|
async function setModelSurfacesVertexAttribute(
|
|
238
282
|
modelId: string,
|
|
239
283
|
surfaceIds: string[],
|
|
@@ -42,15 +42,29 @@ async function getModelComponentsMap(
|
|
|
42
42
|
),
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const COMPONENT_TYPE_NAMES = ["Block", "Surface", "Line", "Corner"] as const;
|
|
46
|
+
type ComponentTypeName = (typeof COMPONENT_TYPE_NAMES)[number];
|
|
47
|
+
|
|
48
|
+
const DISPATCH_METHODS: Partial<Record<string, Record<ComponentTypeName, string>>> = {
|
|
49
|
+
Visibility: {
|
|
50
|
+
Block: "setModelBlocksVisibility",
|
|
51
|
+
Surface: "setModelSurfacesVisibility",
|
|
52
|
+
Line: "setModelLinesVisibility",
|
|
53
|
+
Corner: "setModelCornersVisibility",
|
|
54
|
+
},
|
|
55
|
+
Color: {
|
|
56
|
+
Block: "setModelBlocksColor",
|
|
57
|
+
Surface: "setModelSurfacesColor",
|
|
58
|
+
Line: "setModelLinesColor",
|
|
59
|
+
Corner: "setModelCornersColor",
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function groupIdsByComponentType(
|
|
47
64
|
componentIds: string[],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
): Promise<unknown[]> {
|
|
52
|
-
const { componentsMap } = await getModelComponentsMap(modelId);
|
|
53
|
-
const idsByComponent: { Block: string[]; Surface: string[]; Line: string[]; Corner: string[] } = {
|
|
65
|
+
componentsMap: Record<string, ModelComponent>,
|
|
66
|
+
): Record<ComponentTypeName, string[]> {
|
|
67
|
+
const idsByComponent: Record<ComponentTypeName, string[]> = {
|
|
54
68
|
Block: [],
|
|
55
69
|
Surface: [],
|
|
56
70
|
Line: [],
|
|
@@ -62,98 +76,34 @@ async function dispatchToComponentTypes(
|
|
|
62
76
|
(idsByComponent as Record<string, string[]>)[type]?.push(id);
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
callComponentStyleFunction(
|
|
81
|
-
componentStyleFunctions.Surface,
|
|
82
|
-
"setModelSurfacesVisibility",
|
|
83
|
-
modelId,
|
|
84
|
-
idsByComponent.Surface,
|
|
85
|
-
...args,
|
|
86
|
-
),
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
if (idsByComponent.Line.length > 0) {
|
|
90
|
-
promises.push(
|
|
91
|
-
callComponentStyleFunction(
|
|
92
|
-
componentStyleFunctions.Line,
|
|
93
|
-
"setModelLinesVisibility",
|
|
94
|
-
modelId,
|
|
95
|
-
idsByComponent.Line,
|
|
96
|
-
...args,
|
|
97
|
-
),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
if (idsByComponent.Corner.length > 0) {
|
|
101
|
-
promises.push(
|
|
102
|
-
callComponentStyleFunction(
|
|
103
|
-
componentStyleFunctions.Corner,
|
|
104
|
-
"setModelCornersVisibility",
|
|
105
|
-
modelId,
|
|
106
|
-
idsByComponent.Corner,
|
|
107
|
-
...args,
|
|
108
|
-
),
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
} else if (action === "Color") {
|
|
112
|
-
if (idsByComponent.Block.length > 0) {
|
|
113
|
-
promises.push(
|
|
114
|
-
callComponentStyleFunction(
|
|
115
|
-
componentStyleFunctions.Block,
|
|
116
|
-
"setModelBlocksColor",
|
|
117
|
-
modelId,
|
|
118
|
-
idsByComponent.Block,
|
|
119
|
-
...args,
|
|
120
|
-
),
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
if (idsByComponent.Surface.length > 0) {
|
|
124
|
-
promises.push(
|
|
125
|
-
callComponentStyleFunction(
|
|
126
|
-
componentStyleFunctions.Surface,
|
|
127
|
-
"setModelSurfacesColor",
|
|
128
|
-
modelId,
|
|
129
|
-
idsByComponent.Surface,
|
|
130
|
-
...args,
|
|
131
|
-
),
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
if (idsByComponent.Line.length > 0) {
|
|
135
|
-
promises.push(
|
|
136
|
-
callComponentStyleFunction(
|
|
137
|
-
componentStyleFunctions.Line,
|
|
138
|
-
"setModelLinesColor",
|
|
139
|
-
modelId,
|
|
140
|
-
idsByComponent.Line,
|
|
141
|
-
...args,
|
|
142
|
-
),
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
if (idsByComponent.Corner.length > 0) {
|
|
146
|
-
promises.push(
|
|
147
|
-
callComponentStyleFunction(
|
|
148
|
-
componentStyleFunctions.Corner,
|
|
149
|
-
"setModelCornersColor",
|
|
150
|
-
modelId,
|
|
151
|
-
idsByComponent.Corner,
|
|
152
|
-
...args,
|
|
153
|
-
),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
79
|
+
return idsByComponent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function dispatchToComponentTypes(
|
|
83
|
+
modelId: string,
|
|
84
|
+
componentIds: string[],
|
|
85
|
+
action: string,
|
|
86
|
+
{ componentStyleFunctions }: { componentStyleFunctions: ComponentStyleFunctions },
|
|
87
|
+
...args: unknown[]
|
|
88
|
+
): Promise<unknown[]> {
|
|
89
|
+
const { componentsMap } = await getModelComponentsMap(modelId);
|
|
90
|
+
const idsByComponent = groupIdsByComponentType(componentIds, componentsMap);
|
|
91
|
+
const methods = DISPATCH_METHODS[action];
|
|
92
|
+
if (methods === undefined) {
|
|
93
|
+
return [];
|
|
156
94
|
}
|
|
95
|
+
const promises = COMPONENT_TYPE_NAMES.filter((type) => idsByComponent[type].length > 0).map(
|
|
96
|
+
async (type) => {
|
|
97
|
+
const result = await callComponentStyleFunction(
|
|
98
|
+
componentStyleFunctions[type],
|
|
99
|
+
methods[type],
|
|
100
|
+
modelId,
|
|
101
|
+
idsByComponent[type],
|
|
102
|
+
...args,
|
|
103
|
+
);
|
|
104
|
+
return result;
|
|
105
|
+
},
|
|
106
|
+
);
|
|
157
107
|
return Promise.all(promises);
|
|
158
108
|
}
|
|
159
109
|
export { getModelComponentsMap, dispatchToComponentTypes };
|
|
@@ -10,6 +10,34 @@ import { useHybridViewerCore } from "./core";
|
|
|
10
10
|
import { useHybridViewerScene } from "./scene";
|
|
11
11
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
12
12
|
|
|
13
|
+
async function lookupModelName(modelId: string): Promise<string | undefined> {
|
|
14
|
+
const modelRecord = (await database.data?.get(modelId)) as { name?: string } | undefined;
|
|
15
|
+
return modelRecord?.name;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function lookupComponentInfo(
|
|
19
|
+
modelId: string,
|
|
20
|
+
geodeId: string | undefined,
|
|
21
|
+
): Promise<HoverComponentInfo | undefined> {
|
|
22
|
+
const modelComponentsTable = database.model_components;
|
|
23
|
+
if (geodeId === undefined || !modelComponentsTable) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const components = modelComponentsTable.where("[id+geode_id]");
|
|
27
|
+
const query = components.equals([modelId, geodeId] as IndexableType);
|
|
28
|
+
const component = (await query.first()) as
|
|
29
|
+
| { name?: string; geode_id?: string; type?: string }
|
|
30
|
+
| undefined;
|
|
31
|
+
if (!component) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
name: component.name ?? "",
|
|
36
|
+
id: component.geode_id ?? "",
|
|
37
|
+
type: component.type ?? "",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
13
41
|
// Shared via createSharedComposable (rather than merged into the parent hybridViewer store) so sibling slices, e.g. ruler.ts and viewport.ts, can read hover state/clearHoverHighlight/hoverHighlight directly without importing the parent store and creating a cycle. A Pinia store would work too but its $id/$patch/... properties would leak into the composed store's spread and collapse its inferred type.
|
|
14
42
|
const useHybridViewerHighlight = createSharedComposable(() => {
|
|
15
43
|
const is_hover_highlight = ref(false);
|
|
@@ -67,6 +95,47 @@ const useHybridViewerHighlight = createSharedComposable(() => {
|
|
|
67
95
|
.catch(() => undefined);
|
|
68
96
|
}
|
|
69
97
|
|
|
98
|
+
async function handleHoverResponse(
|
|
99
|
+
response: ViewerHighlightResponse,
|
|
100
|
+
relativeMousePosition: { x: number; y: number },
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
if (
|
|
103
|
+
!is_hover_highlight.value ||
|
|
104
|
+
response.id === undefined ||
|
|
105
|
+
response.picked_id === undefined ||
|
|
106
|
+
response.picked_id === -1
|
|
107
|
+
) {
|
|
108
|
+
clearHoverData();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const hoverKey = `${response.id}_${response.field_type}_${response.picked_id}`;
|
|
112
|
+
if (currentHoverId.value === hoverKey) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (hoverTimeoutRef.value) {
|
|
116
|
+
clearTimeout(hoverTimeoutRef.value);
|
|
117
|
+
hoverTimeoutRef.value = undefined;
|
|
118
|
+
}
|
|
119
|
+
hoverData.value = undefined;
|
|
120
|
+
currentHoverId.value = hoverKey;
|
|
121
|
+
const modelName = await lookupModelName(response.id);
|
|
122
|
+
const componentInfo = await lookupComponentInfo(response.id, response.geode_id);
|
|
123
|
+
const newHoverData: HoverData = {
|
|
124
|
+
modelId: response.id,
|
|
125
|
+
modelName,
|
|
126
|
+
blockName: response.geode_id,
|
|
127
|
+
pickedId: response.picked_id,
|
|
128
|
+
fieldType: response.field_type,
|
|
129
|
+
component: componentInfo,
|
|
130
|
+
attributes: response.attributes ?? {},
|
|
131
|
+
};
|
|
132
|
+
hoverTimeoutRef.value = setTimeout(() => {
|
|
133
|
+
hoverPosition.value = relativeMousePosition;
|
|
134
|
+
hoverData.value = newHoverData;
|
|
135
|
+
hoverTimeoutRef.value = undefined;
|
|
136
|
+
}, HOVER_TIMEOUT_MS);
|
|
137
|
+
}
|
|
138
|
+
|
|
70
139
|
const hoverHighlight = useDebounceFn((event: MouseEvent) => {
|
|
71
140
|
const { genericRenderWindow } = useHybridViewerCore();
|
|
72
141
|
const containerElement = genericRenderWindow.value?.getContainer();
|
|
@@ -81,60 +150,7 @@ const useHybridViewerHighlight = createSharedComposable(() => {
|
|
|
81
150
|
};
|
|
82
151
|
}
|
|
83
152
|
requestHoverHighlight(event, async (response) => {
|
|
84
|
-
|
|
85
|
-
!is_hover_highlight.value ||
|
|
86
|
-
response.id === undefined ||
|
|
87
|
-
response.picked_id === undefined ||
|
|
88
|
-
response.picked_id === -1
|
|
89
|
-
) {
|
|
90
|
-
clearHoverData();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const hoverKey = `${response.id}_${response.field_type}_${response.picked_id}`;
|
|
94
|
-
if (currentHoverId.value === hoverKey) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (hoverTimeoutRef.value) {
|
|
98
|
-
clearTimeout(hoverTimeoutRef.value);
|
|
99
|
-
hoverTimeoutRef.value = undefined;
|
|
100
|
-
}
|
|
101
|
-
hoverData.value = undefined;
|
|
102
|
-
currentHoverId.value = hoverKey;
|
|
103
|
-
let componentInfo: HoverComponentInfo | undefined = undefined;
|
|
104
|
-
let modelName: string | undefined = undefined;
|
|
105
|
-
const modelRecord = (await database.data?.get(response.id)) as { name?: string } | undefined;
|
|
106
|
-
if (modelRecord) {
|
|
107
|
-
modelName = modelRecord.name;
|
|
108
|
-
}
|
|
109
|
-
const modelComponentsTable = database.model_components;
|
|
110
|
-
if (response.geode_id !== undefined && modelComponentsTable) {
|
|
111
|
-
const components = modelComponentsTable.where("[id+geode_id]");
|
|
112
|
-
const query = components.equals([response.id, response.geode_id] as IndexableType);
|
|
113
|
-
const component = (await query.first()) as
|
|
114
|
-
| { name?: string; geode_id?: string; type?: string }
|
|
115
|
-
| undefined;
|
|
116
|
-
if (component) {
|
|
117
|
-
componentInfo = {
|
|
118
|
-
name: component.name ?? "",
|
|
119
|
-
id: component.geode_id ?? "",
|
|
120
|
-
type: component.type ?? "",
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const newHoverData: HoverData = {
|
|
125
|
-
modelId: response.id,
|
|
126
|
-
modelName,
|
|
127
|
-
blockName: response.geode_id,
|
|
128
|
-
pickedId: response.picked_id,
|
|
129
|
-
fieldType: response.field_type,
|
|
130
|
-
component: componentInfo,
|
|
131
|
-
attributes: response.attributes ?? {},
|
|
132
|
-
};
|
|
133
|
-
hoverTimeoutRef.value = setTimeout(() => {
|
|
134
|
-
hoverPosition.value = relativeMousePosition;
|
|
135
|
-
hoverData.value = newHoverData;
|
|
136
|
-
hoverTimeoutRef.value = undefined;
|
|
137
|
-
}, HOVER_TIMEOUT_MS);
|
|
153
|
+
await handleHoverResponse(response, relativeMousePosition);
|
|
138
154
|
});
|
|
139
155
|
}, HOVER_DEBOUNCE_MS);
|
|
140
156
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ACTOR_COLOR, RGB_MAX } from "./constants";
|
|
2
|
-
import type { HybridDb, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
2
|
+
import type { HybridDb, HybridDbEntry, vtkActor as VtkActorInstance, vtkCamera } from "./vtk_types";
|
|
3
3
|
import { requireRenderWindow, useHybridViewerCore } from "./core";
|
|
4
4
|
import viewer_schemas, {
|
|
5
5
|
type ViewerSetBackgroundColorParams,
|
|
@@ -40,6 +40,31 @@ function followZScaling(camera: vtkCamera, ratio: number): void {
|
|
|
40
40
|
camera.setPosition(positionX, positionY, positionZ + offset);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
async function fetchBinaryLightViewable(id: string): Promise<string | undefined> {
|
|
44
|
+
const dataStore = useDataStore();
|
|
45
|
+
const isViewable = await dataStore.isItemViewable(id);
|
|
46
|
+
if (!isViewable) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const value = await dataStore.item(id);
|
|
50
|
+
return value.binary_light_viewable;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function createHybridDbEntry(binaryLightViewable: string, zScale: number): HybridDbEntry {
|
|
54
|
+
const reader = vtkXMLPolyDataReader();
|
|
55
|
+
reader.parseAsArrayBuffer(base64ToArrayBuffer(binaryLightViewable));
|
|
56
|
+
const actor = vtkActor();
|
|
57
|
+
const mapper = vtkMapper();
|
|
58
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- vtk.js's algorithm interface types getOutputData as `any`; this reader always produces polydata.
|
|
59
|
+
const polydata = reader.getOutputData(0) as unknown as vtkPolyData;
|
|
60
|
+
mapper.setInputData(polydata);
|
|
61
|
+
const property = actor.getProperty();
|
|
62
|
+
property.setColor(ACTOR_COLOR);
|
|
63
|
+
actor.setMapper(mapper);
|
|
64
|
+
actor.setScale(1, 1, zScale);
|
|
65
|
+
return { actor, polydata, mapper };
|
|
66
|
+
}
|
|
67
|
+
|
|
43
68
|
// Shared via createSharedComposable (rather than merged into the parent hybridViewer store) so sibling slices, e.g. camera.ts and ruler.ts, can read hybridDb/setZScaling directly without importing the parent store and creating a cycle. A Pinia store would work too but its $id/$patch/... properties would leak into the composed store's spread and collapse its inferred type.
|
|
44
69
|
const useHybridViewerScene = createSharedComposable(() => {
|
|
45
70
|
const hybridDb = reactive<HybridDb>({});
|
|
@@ -50,42 +75,23 @@ const useHybridViewerScene = createSharedComposable(() => {
|
|
|
50
75
|
if (!genericRenderWindow.value) {
|
|
51
76
|
return;
|
|
52
77
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (!isViewable) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const value = await dataStore.item(id);
|
|
59
|
-
if (value.binary_light_viewable === undefined) {
|
|
78
|
+
const binaryLightViewable = await fetchBinaryLightViewable(id);
|
|
79
|
+
if (binaryLightViewable === undefined) {
|
|
60
80
|
return;
|
|
61
81
|
}
|
|
62
|
-
const reader = vtkXMLPolyDataReader();
|
|
63
|
-
reader.parseAsArrayBuffer(base64ToArrayBuffer(value.binary_light_viewable));
|
|
64
|
-
const actor = vtkActor();
|
|
65
|
-
const mapper = vtkMapper();
|
|
66
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- vtk.js's algorithm interface types getOutputData as `any`; this reader always produces polydata.
|
|
67
|
-
const polydata = reader.getOutputData(0) as unknown as vtkPolyData;
|
|
68
|
-
mapper.setInputData(polydata);
|
|
69
|
-
const property = actor.getProperty();
|
|
70
|
-
property.setColor(ACTOR_COLOR);
|
|
71
|
-
actor.setMapper(mapper);
|
|
72
82
|
// The scene z-scaling also applies to actors added after it was set
|
|
73
|
-
|
|
83
|
+
const entry = createHybridDbEntry(binaryLightViewable, zScale.value);
|
|
74
84
|
const renderer = genericRenderWindow.value.getRenderer();
|
|
75
85
|
// Replacing an actor keeps the camera where the user left it
|
|
76
86
|
const isFirst = !hybridDb[id] && renderer.getActors().length === 0;
|
|
77
87
|
if (hybridDb[id]) {
|
|
78
88
|
renderer.removeActor(hybridDb[id].actor);
|
|
79
89
|
}
|
|
80
|
-
renderer.addActor(actor);
|
|
90
|
+
renderer.addActor(entry.actor);
|
|
81
91
|
if (isFirst) {
|
|
82
92
|
renderer.resetCamera();
|
|
83
93
|
}
|
|
84
|
-
hybridDb[id] =
|
|
85
|
-
actor,
|
|
86
|
-
polydata,
|
|
87
|
-
mapper,
|
|
88
|
-
};
|
|
94
|
+
hybridDb[id] = entry;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
function removeItem(id: string): void {
|
package/package.json
CHANGED