From 28c50f2f5356545904dca4c6bf91f173bf98b648 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Tue, 27 Jan 2026 17:40:52 +0100 Subject: [PATCH 01/41] Initialize PR --- .../EdgedCurve/SpecificEdgesOptions.vue | 1 + .../Viewer/Generic/Mesh/CellsOptions.vue | 1 + .../Viewer/Generic/Mesh/EdgesOptions.vue | 2 + .../Viewer/Generic/Mesh/PointsOptions.vue | 1 + .../Viewer/Generic/Mesh/PolygonsOptions.vue | 3 + .../Viewer/Generic/Mesh/PolyhedraOptions.vue | 3 + .../Viewer/Options/AttributeColorBar.vue | 80 ++++++++ .../Viewer/Options/CellAttributeSelector.vue | 53 +++++- .../Viewer/Options/ColorMapList.vue | 175 ++++++++++++++++++ .../Viewer/Options/ColorMapPicker.vue | 160 ++++++++++++++++ .../Viewer/Options/ColoringTypeSelector.vue | 2 + .../Viewer/Options/EdgeAttributeSelector.vue | 79 ++++++-- .../Options/PolygonAttributeSelector.vue | 52 +++++- .../Options/PolyhedronAttributeSelector.vue | 65 +++++-- .../Options/VertexAttributeSelector.vue | 83 ++++++++- .../Viewer/PointSet/SpecificPointsOptions.vue | 1 + .../SpecificPolygonsOptions.vue | 1 + .../Viewer/Solid/SpecificPolyhedraOptions.vue | 1 + internal/stores/mesh/cells.js | 56 +++++- internal/stores/mesh/edges.js | 19 +- internal/stores/mesh/points.js | 19 +- internal/stores/mesh/polygons.js | 68 ++++++- internal/stores/mesh/polyhedra.js | 38 +++- 23 files changed, 901 insertions(+), 62 deletions(-) create mode 100644 app/components/Viewer/Options/AttributeColorBar.vue create mode 100644 app/components/Viewer/Options/ColorMapList.vue create mode 100644 app/components/Viewer/Options/ColorMapPicker.vue diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue index 922c8daa..239bd6e2 100644 --- a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -32,6 +32,7 @@ v-model:color="color" v-model:vertex_attribute="vertex_attribute" v-model:edge_attribute="edge_attribute" + mesh-type="edges" /> diff --git a/app/components/Viewer/Generic/Mesh/CellsOptions.vue b/app/components/Viewer/Generic/Mesh/CellsOptions.vue index 7eb4ef3a..2800db2f 100644 --- a/app/components/Viewer/Generic/Mesh/CellsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/CellsOptions.vue @@ -14,6 +14,7 @@ v-model:textures="textures" v-model:vertex_attribute="vertex_attribute" v-model:cell_attribute="cell_attribute" + mesh-type="cells" /> diff --git a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue index cd34ce97..9c3eebbc 100644 --- a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +++ b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue @@ -30,6 +30,8 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" + v-model:vertex_attribute="vertex_attribute" + mesh-type="edges" /> diff --git a/app/components/Viewer/Generic/Mesh/PointsOptions.vue b/app/components/Viewer/Generic/Mesh/PointsOptions.vue index dfc5b55f..ea61d0b1 100644 --- a/app/components/Viewer/Generic/Mesh/PointsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -31,6 +31,7 @@ v-model:coloring_style_key="coloring_style_key" v-model:color="color" v-model:vertex_attribute="vertex_attribute" + mesh-type="points" /> diff --git a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue index 90a8ec10..b47aff81 100644 --- a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue @@ -12,6 +12,9 @@ v-model:coloring_style_key="coloring_style_key" v-model:color="color" v-model:textures="textures" + v-model:vertex_attribute="vertex_attribute" + v-model:polygon_attribute="polygon_attribute" + mesh-type="polygons" /> diff --git a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue index 715cd40c..a6373068 100644 --- a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue @@ -11,6 +11,9 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" + v-model:vertex_attribute="vertex_attribute" + v-model:polyhedron_attribute="polyhedron_attribute" + mesh-type="polyhedra" /> diff --git a/app/components/Viewer/Options/AttributeColorBar.vue b/app/components/Viewer/Options/AttributeColorBar.vue new file mode 100644 index 00000000..f0de2e5f --- /dev/null +++ b/app/components/Viewer/Options/AttributeColorBar.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index cd0c3153..9276180e 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -1,15 +1,27 @@ + diff --git a/app/components/Viewer/Options/ColorMapList.vue b/app/components/Viewer/Options/ColorMapList.vue new file mode 100644 index 00000000..5b8c158e --- /dev/null +++ b/app/components/Viewer/Options/ColorMapList.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/app/components/Viewer/Options/ColorMapPicker.vue b/app/components/Viewer/Options/ColorMapPicker.vue new file mode 100644 index 00000000..f6006d8d --- /dev/null +++ b/app/components/Viewer/Options/ColorMapPicker.vue @@ -0,0 +1,160 @@ + + + + + diff --git a/app/components/Viewer/Options/ColoringTypeSelector.vue b/app/components/Viewer/Options/ColoringTypeSelector.vue index cc6acfce..2971f587 100644 --- a/app/components/Viewer/Options/ColoringTypeSelector.vue +++ b/app/components/Viewer/Options/ColoringTypeSelector.vue @@ -32,6 +32,7 @@ @@ -22,6 +26,7 @@ import { useDataStyleStore } from "@ogw_front/stores/data_style" import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer" import ViewerOptionsAttributeColorBar from "@ogw_front/components/Viewer/Options/AttributeColorBar" + import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap" const props = defineProps({ id: { type: String, required: true }, @@ -30,10 +35,20 @@ const model = defineModel() const polygon_attribute_name = ref("") const polygon_attribute_names = ref([]) + const polygon_attribute_metadata = ref({}) + + const selectedAttributeRange = computed(() => { + if (polygon_attribute_name.value && polygon_attribute_metadata.value[polygon_attribute_name.value]) { + return polygon_attribute_metadata.value[polygon_attribute_name.value] + } + return [0, 1] + }) + const polygon_attribute = reactive({ name: polygon_attribute_name.value, min: undefined, max: undefined, + colorMap: "Cool to Warm", }) const geodeStore = useGeodeStore() const dataStyleStore = useDataStyleStore() @@ -44,6 +59,9 @@ polygon_attribute_name.value = model.value.name polygon_attribute.min = model.value.min polygon_attribute.max = model.value.max + if (model.value.colorMap) { + polygon_attribute.colorMap = model.value.colorMap + } } }) @@ -53,7 +71,7 @@ }) watch( - () => [polygon_attribute.min, polygon_attribute.max], + () => [polygon_attribute.min, polygon_attribute.max, polygon_attribute.colorMap], () => { model.value = { ...polygon_attribute } }, @@ -70,6 +88,22 @@ } } + function onColorMapChange() { + if ( + polygon_attribute.min !== undefined && + polygon_attribute.max !== undefined && + polygon_attribute.colorMap + ) { + const points = getRGBPointsFromPreset( + polygon_attribute.colorMap, + polygon_attribute.min, + polygon_attribute.max, + ) + dataStyleStore.setMeshPolygonsPolygonColorMap(props.id, points) + hybridViewerStore.remoteRender() + } + } + onMounted(() => { getPolygonAttributes() }) @@ -83,6 +117,7 @@ { response_function: (response) => { polygon_attribute_names.value = response.polygon_attribute_names + polygon_attribute_metadata.value = response.polygon_attribute_metadata || {} }, }, ) diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index 49faa336..ef6f1fec 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -10,8 +10,12 @@ v-if="polyhedron_attribute_name" v-model:min="polyhedron_attribute.min" v-model:max="polyhedron_attribute.max" + v-model:colorMap="polyhedron_attribute.colorMap" + :auto-min="selectedAttributeRange[0]" + :auto-max="selectedAttributeRange[1]" @update:min="onScalarRangeChange" @update:max="onScalarRangeChange" + @update:colorMap="onColorMapChange" /> @@ -22,6 +26,7 @@ import { useDataStyleStore } from "@ogw_front/stores/data_style" import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer" import ViewerOptionsAttributeColorBar from "@ogw_front/components/Viewer/Options/AttributeColorBar" + import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap" const model = defineModel() const geodeStore = useGeodeStore() @@ -29,11 +34,20 @@ const hybridViewerStore = useHybridViewerStore() const polyhedron_attribute_name = ref("") + const polyhedron_attribute_metadata = ref({}) + + const selectedAttributeRange = computed(() => { + if (polyhedron_attribute_name.value && polyhedron_attribute_metadata.value[polyhedron_attribute_name.value]) { + return polyhedron_attribute_metadata.value[polyhedron_attribute_name.value] + } + return [0, 1] + }) const polyhedron_attribute = reactive({ name: polyhedron_attribute_name.value, min: undefined, max: undefined, + colorMap: "Cool to Warm", }) onMounted(() => { @@ -41,6 +55,9 @@ polyhedron_attribute_name.value = model.value.name polyhedron_attribute.min = model.value.min polyhedron_attribute.max = model.value.max + if (model.value.colorMap) { + polyhedron_attribute.colorMap = model.value.colorMap + } } }) @@ -50,12 +67,11 @@ }) watch( - () => [polyhedron_attribute.min, polyhedron_attribute.max], + () => [polyhedron_attribute.min, polyhedron_attribute.max, polyhedron_attribute.colorMap], () => { model.value = { ...polyhedron_attribute } }, ) - function onScalarRangeChange() { if ( polyhedron_attribute.min !== undefined && @@ -70,6 +86,22 @@ } } + function onColorMapChange() { + if ( + polyhedron_attribute.min !== undefined && + polyhedron_attribute.max !== undefined && + polyhedron_attribute.colorMap + ) { + const points = getRGBPointsFromPreset( + polyhedron_attribute.colorMap, + polyhedron_attribute.min, + polyhedron_attribute.max, + ) + dataStyleStore.setPolyhedraPolyhedraColorMap(props.id, points) + hybridViewerStore.remoteRender() + } + } + const props = defineProps({ id: { type: String, required: true }, }) @@ -87,6 +119,7 @@ { response_function: (response) => { polyhedron_attribute_names.value = response.polyhedron_attribute_names + polyhedron_attribute_metadata.value = response.polyhedron_attribute_metadata || {} }, }, ) diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index bf96838b..4446fb5e 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -10,8 +10,12 @@ v-if="vertex_attribute_name" v-model:min="vertex_attribute.min" v-model:max="vertex_attribute.max" + v-model:colorMap="vertex_attribute.colorMap" + :auto-min="selectedAttributeRange[0]" + :auto-max="selectedAttributeRange[1]" @update:min="onScalarRangeChange" @update:max="onScalarRangeChange" + @update:colorMap="onColorMapChange" /> @@ -22,6 +26,7 @@ import { useDataStyleStore } from "@ogw_front/stores/data_style" import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer" import ViewerOptionsAttributeColorBar from "@ogw_front/components/Viewer/Options/AttributeColorBar" + import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap" const geodeStore = useGeodeStore() const dataStyleStore = useDataStyleStore() @@ -36,11 +41,20 @@ const vertex_attribute_name = ref("") const vertex_attribute_names = ref([]) + const vertex_attribute_metadata = ref({}) + + const selectedAttributeRange = computed(() => { + if (vertex_attribute_name.value && vertex_attribute_metadata.value[vertex_attribute_name.value]) { + return vertex_attribute_metadata.value[vertex_attribute_name.value] + } + return [0, 1] + }) const vertex_attribute = reactive({ name: vertex_attribute_name.value, min: undefined, max: undefined, + colorMap: "Cool to Warm", }) onMounted(() => { @@ -48,6 +62,9 @@ vertex_attribute_name.value = model.value.name vertex_attribute.min = model.value.min vertex_attribute.max = model.value.max + if (model.value.colorMap) { + vertex_attribute.colorMap = model.value.colorMap + } } }) @@ -57,7 +74,7 @@ }) watch( - () => [vertex_attribute.min, vertex_attribute.max], + () => [vertex_attribute.min, vertex_attribute.max, vertex_attribute.colorMap], () => { model.value = { ...vertex_attribute } }, @@ -103,6 +120,32 @@ } } + function onColorMapChange() { + if ( + vertex_attribute.min !== undefined && + vertex_attribute.max !== undefined && + vertex_attribute.colorMap + ) { + const points = getRGBPointsFromPreset( + vertex_attribute.colorMap, + vertex_attribute.min, + vertex_attribute.max, + ) + if (props.meshType === "polygons") { + dataStyleStore.setMeshPolygonsVertexColorMap(props.id, points) + } else if (props.meshType === "cells") { + dataStyleStore.setMeshCellsVertexColorMap(props.id, points) + } else if (props.meshType === "edges") { + dataStyleStore.setMeshEdgesVertexColorMap(props.id, points) + } else if (props.meshType === "points") { + dataStyleStore.setMeshPointsVertexColorMap(props.id, points) + } else if (props.meshType === "polyhedra") { + dataStyleStore.setPolyhedraVertexColorMap(props.id, points) + } + hybridViewerStore.remoteRender() + } + } + onMounted(() => { getVertexAttributes() }) @@ -114,6 +157,7 @@ { response_function: (response) => { vertex_attribute_names.value = response.vertex_attribute_names + vertex_attribute_metadata.value = response.vertex_attribute_metadata || {} }, }, ) diff --git a/app/utils/colormap.js b/app/utils/colormap.js new file mode 100644 index 00000000..2a0f7744 --- /dev/null +++ b/app/utils/colormap.js @@ -0,0 +1,36 @@ +import vtkColorMaps from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps" + +export function getRGBPointsFromPreset(presetName, min, max) { + const preset = vtkColorMaps.getPresetByName(presetName) + if (!preset || !preset.RGBPoints) { + return [ + [min, 59, 76, 192], + [(min + max) / 2, 221, 221, 221], + [max, 180, 4, 38], + ] + } + return getRGBPointsFromPresetData(preset.RGBPoints, min, max) +} + +function getRGBPointsFromPresetData(rgbPoints, min, max) { + const points = [] + const presetMin = rgbPoints[0] + const presetMax = rgbPoints[rgbPoints.length - 4] + const presetRange = presetMax - presetMin + const targetRange = max - min + + for (let i = 0; i < rgbPoints.length; i += 4) { + const originalValue = rgbPoints[i] + const normalizedValue = presetRange !== 0 + ? (originalValue - presetMin) / presetRange + : 0 + const scaledValue = min + normalizedValue * targetRange + points.push([ + scaledValue, + Math.round(rgbPoints[i + 1] * 255), + Math.round(rgbPoints[i + 2] * 255), + Math.round(rgbPoints[i + 3] * 255), + ]) + } + return points +} diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 021658c1..d53f52de 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -142,25 +142,25 @@ export function useMeshCellsStyle() { ) } - function setMeshCellsCellScalarRange(id, minimum, maximum) { + function setMeshCellsVertexColorMap(id, points) { return viewerStore.request( - mesh_cells_schemas.cell_scalar_range, - { id, minimum, maximum }, + mesh_cells_schemas.vertex_color_map, + { id, points }, { response_function: () => { - console.log(setMeshCellsCellScalarRange.name, { id, minimum, maximum }) + console.log(setMeshCellsVertexColorMap.name, { id, points }) }, }, ) } - function setMeshCellsVertexScalarRange(id, minimum, maximum) { + function setMeshCellsCellColorMap(id, points) { return viewerStore.request( - mesh_cells_schemas.vertex_scalar_range, - { id, minimum, maximum }, + mesh_cells_schemas.cell_color_map, + { id, points }, { response_function: () => { - console.log(setMeshCellsVertexScalarRange.name, { id, minimum, maximum }) + console.log(setMeshCellsCellColorMap.name, { id, points }) }, }, ) @@ -222,6 +222,8 @@ export function useMeshCellsStyle() { setMeshCellsCellAttribute, setMeshCellsCellScalarRange, setMeshCellsVertexScalarRange, + setMeshCellsVertexColorMap, + setMeshCellsCellColorMap, applyMeshCellsStyle, } } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index af1ed3ac..35f6c4bf 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -158,6 +158,18 @@ export function useMeshEdgesStyle() { ) } + function setMeshEdgesVertexColorMap(id, points) { + return viewerStore.request( + mesh_edges_schemas.vertex_color_map, + { id, points }, + { + response_function: () => { + console.log(setMeshEdgesVertexColorMap.name, { id, points }) + }, + }, + ) + } + function applyMeshEdgesStyle(id) { const style = meshEdgesStyle(id) return Promise.all([ @@ -182,5 +194,6 @@ export function useMeshEdgesStyle() { setMeshEdgesVertexAttribute, setMeshEdgesEdgeAttribute, setMeshEdgesVertexScalarRange, + setMeshEdgesVertexColorMap, } } diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 584dfdb6..675907b9 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -133,6 +133,18 @@ export function useMeshPointsStyle() { ) } + function setMeshPointsVertexColorMap(id, points) { + return viewerStore.request( + mesh_points_schemas.vertex_color_map, + { id, points }, + { + response_function: () => { + console.log(setMeshPointsVertexColorMap.name, { id, points }) + }, + }, + ) + } + function applyMeshPointsStyle(id) { const style = meshPointsStyle(id) return Promise.all([ @@ -154,6 +166,7 @@ export function useMeshPointsStyle() { setMeshPointsVertexAttribute, setMeshPointsSize, setMeshPointsVertexScalarRange, + setMeshPointsVertexColorMap, applyMeshPointsStyle, } } diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 6f6c684d..d19087e6 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -154,36 +154,31 @@ export function useMeshPolygonsStyle() { ) } - function setMeshPolygonsPolygonScalarRange(id, minimum, maximum) { + function setMeshPolygonsVertexColorMap(id, points) { return viewerStore.request( - mesh_polygons_schemas.polygon_scalar_range, - { id, minimum, maximum }, + mesh_polygons_schemas.vertex_color_map, + { id, points }, { response_function: () => { - console.log( - setMeshPolygonsPolygonScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setMeshPolygonsVertexColorMap.name, { id, points }) }, }, ) } - function setMeshPolygonsVertexScalarRange(id, minimum, maximum) { + function setMeshPolygonsPolygonColorMap(id, points) { return viewerStore.request( - mesh_polygons_schemas.vertex_scalar_range, - { id, minimum, maximum }, + mesh_polygons_schemas.polygon_color_map, + { id, points }, { response_function: () => { - console.log( - setMeshPolygonsVertexScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setMeshPolygonsPolygonColorMap.name, { id, points }) }, }, ) } + function meshPolygonsActiveColoring(id) { return meshPolygonsStyle(id).coloring.active } @@ -240,6 +235,8 @@ export function useMeshPolygonsStyle() { setMeshPolygonsPolygonAttribute, setMeshPolygonsPolygonScalarRange, setMeshPolygonsVertexScalarRange, + setMeshPolygonsVertexColorMap, + setMeshPolygonsPolygonColorMap, applyMeshPolygonsStyle, } } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 5c330b74..a271264c 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -159,6 +159,48 @@ export function useMeshPolyhedraStyle() { ) } + function setPolyhedraVertexColorMap(id, points) { + return viewerStore.request( + mesh_polyhedra_schemas.vertex_color_map, + { id, points }, + { + response_function: () => { + console.log(setPolyhedraVertexColorMap.name, { id, points }) + }, + }, + ) + } + + function setPolyhedraPolyhedraColorMap(id, points) { + return viewerStore.request( + mesh_polyhedra_schemas.polyhedra_color_map, + { id, points }, + { + response_function: () => { + console.log(setPolyhedraPolyhedraColorMap.name, { id, points }) + }, + }, + ) + } + + function setMeshPolyhedraVisibility(id, visibility) { + const polyhedra_style = meshPolyhedraStyle(id) + return viewerStore.request( + mesh_polyhedra_schemas.visibility, + { id, visibility }, + { + response_function: () => { + polyhedra_style.visibility = visibility + console.log( + setMeshPolyhedraVisibility.name, + { id }, + meshPolyhedraVisibility(id), + ) + }, + }, + ) + } + function applyMeshPolyhedraStyle(id) { const style = meshPolyhedraStyle(id) return Promise.all([ @@ -180,6 +222,8 @@ export function useMeshPolyhedraStyle() { setPolyhedraVertexAttribute, setPolyhedraPolyhedronScalarRange, setPolyhedraVertexScalarRange, + setPolyhedraVertexColorMap, + setPolyhedraPolyhedraColorMap, setMeshPolyhedraVisibility, } } From 17ad156a697f4ffb4fa077daa52e99ecddda8e13 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Wed, 28 Jan 2026 16:20:42 +0100 Subject: [PATCH 03/41] Centralize actions --- .../Options/VertexAttributeSelector.vue | 246 +++++++----------- internal/stores/mesh/index.js | 64 +++++ 2 files changed, 164 insertions(+), 146 deletions(-) diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index 4446fb5e..da934c14 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -1,165 +1,119 @@ - - + + diff --git a/internal/stores/mesh/index.js b/internal/stores/mesh/index.js index b38d710c..813e5512 100644 --- a/internal/stores/mesh/index.js +++ b/internal/stores/mesh/index.js @@ -64,10 +64,74 @@ export default function useMeshStyle() { return Promise.all(promise_array) } + function setVertexScalarRange(id, meshType, minimum, maximum) { + switch (meshType) { + case "points": + return meshPointsStyleStore.setMeshPointsVertexScalarRange(id, minimum, maximum) + case "edges": + return meshEdgesStyleStore.setMeshEdgesVertexScalarRange(id, minimum, maximum) + case "cells": + return meshCellsStyleStore.setMeshCellsVertexScalarRange(id, minimum, maximum) + case "polygons": + return meshPolygonsStyleStore.setMeshPolygonsVertexScalarRange(id, minimum, maximum) + case "polyhedra": + return meshPolyhedraStyleStore.setPolyhedraVertexScalarRange(id, minimum, maximum) + default: + throw new Error("Unknown meshType for vertex scalar range: " + meshType) + } + } + + function setVertexColorMap(id, meshType, points) { + switch (meshType) { + case "points": + return meshPointsStyleStore.setMeshPointsVertexColorMap(id, points) + case "edges": + return meshEdgesStyleStore.setMeshEdgesVertexColorMap(id, points) + case "cells": + return meshCellsStyleStore.setMeshCellsVertexColorMap(id, points) + case "polygons": + return meshPolygonsStyleStore.setMeshPolygonsVertexColorMap(id, points) + case "polyhedra": + return meshPolyhedraStyleStore.setPolyhedraVertexColorMap(id, points) + default: + throw new Error("Unknown meshType for vertex color map: " + meshType) + } + } + + function setElementScalarRange(id, elementType, minimum, maximum) { + switch (elementType) { + case "cell": + return meshCellsStyleStore.setMeshCellsCellScalarRange(id, minimum, maximum) + case "polygon": + return meshPolygonsStyleStore.setMeshPolygonsPolygonScalarRange(id, minimum, maximum) + case "polyhedron": + return meshPolyhedraStyleStore.setPolyhedraPolyhedronScalarRange(id, minimum, maximum) + default: + throw new Error("Unknown elementType for scalar range: " + elementType) + } + } + + function setElementColorMap(id, elementType, points) { + switch (elementType) { + case "cell": + return meshCellsStyleStore.setMeshCellsCellColorMap(id, points) + case "polygon": + return meshPolygonsStyleStore.setMeshPolygonsPolygonColorMap(id, points) + case "polyhedron": + return meshPolyhedraStyleStore.setPolyhedraPolyhedraColorMap(id, points) + default: + throw new Error("Unknown elementType for color map: " + elementType) + } + } + return { meshVisibility, setMeshVisibility, applyMeshStyle, + setVertexScalarRange, + setVertexColorMap, + setElementScalarRange, + setElementColorMap, ...useMeshPointsStyle(), ...useMeshEdgesStyle(), ...useMeshCellsStyle(), From 99983b75f1bd2571e86d362066c89c00396bc6fb Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 29 Jan 2026 13:16:26 +0100 Subject: [PATCH 04/41] edit colormap logic and save state of attribut --- .../Viewer/Options/AttributeColorBar.vue | 14 +- .../Viewer/Options/CellAttributeSelector.vue | 142 ++++++--- .../Viewer/Options/EdgeAttributeSelector.vue | 156 ++++++---- .../Options/PolygonAttributeSelector.vue | 166 +++++++---- .../Options/PolyhedronAttributeSelector.vue | 156 ++++++---- .../Options/VertexAttributeSelector.vue | 277 +++++++++++------- app/stores/data_style.js | 16 +- app/utils/colormap.js | 37 +-- internal/stores/data_style_state.js | 27 +- 9 files changed, 652 insertions(+), 339 deletions(-) diff --git a/app/components/Viewer/Options/AttributeColorBar.vue b/app/components/Viewer/Options/AttributeColorBar.vue index 28216478..ad84f3d6 100644 --- a/app/components/Viewer/Options/AttributeColorBar.vue +++ b/app/components/Viewer/Options/AttributeColorBar.vue @@ -8,7 +8,10 @@ const min = defineModel("min", { type: Number }) const max = defineModel("max", { type: Number }) - const colorMap = defineModel("colorMap", { type: String, default: "Cool to Warm" }) + const colorMap = defineModel("colorMap", { + type: String, + default: "Cool to Warm", + }) const minValue = computed({ get: () => min.value ?? props.autoMin, @@ -29,15 +32,6 @@ if (max.value === undefined) max.value = props.autoMax }) - // Reset min/max when autoMin/autoMax change (attribute selection changed) - watch( - () => [props.autoMin, props.autoMax], - ([newAutoMin, newAutoMax]) => { - min.value = newAutoMin - max.value = newAutoMax - }, - ) - function reset() { min.value = props.autoMin max.value = props.autoMax diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index 0cbef22a..99121409 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -1,32 +1,13 @@ - - + diff --git a/app/components/Viewer/Options/EdgeAttributeSelector.vue b/app/components/Viewer/Options/EdgeAttributeSelector.vue index 6e84d20f..106e7eca 100644 --- a/app/components/Viewer/Options/EdgeAttributeSelector.vue +++ b/app/components/Viewer/Options/EdgeAttributeSelector.vue @@ -1,44 +1,13 @@ - - + diff --git a/app/components/Viewer/Options/PolygonAttributeSelector.vue b/app/components/Viewer/Options/PolygonAttributeSelector.vue index 1559f4fc..82bc68ef 100644 --- a/app/components/Viewer/Options/PolygonAttributeSelector.vue +++ b/app/components/Viewer/Options/PolygonAttributeSelector.vue @@ -1,32 +1,13 @@ - - + + diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index ef6f1fec..3bae5235 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -1,32 +1,17 @@ - - + diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index da934c14..5eb0363f 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -1,119 +1,194 @@ diff --git a/app/stores/data_style.js b/app/stores/data_style.js index 747a59ac..41d61462 100644 --- a/app/stores/data_style.js +++ b/app/stores/data_style.js @@ -46,7 +46,10 @@ export const useDataStyleStore = defineStore("dataStyle", () => { } const exportStores = () => { - return { styles: dataStyleState.styles } + return { + styles: dataStyleState.styles, + attributeSettings: dataStyleState.attributeSettings, + } } const importStores = (snapshot) => { @@ -57,8 +60,17 @@ export const useDataStyleStore = defineStore("dataStyle", () => { for (const [id, style] of Object.entries(stylesSnapshot)) { dataStyleState.styles[id] = style } + + const attributeSettingsSnapshot = snapshot.attributeSettings || {} + for (const key of Object.keys(dataStyleState.attributeSettings)) { + delete dataStyleState.attributeSettings[key] + } + for (const [key, settings] of Object.entries(attributeSettingsSnapshot)) { + dataStyleState.attributeSettings[key] = settings + } } + const applyAllStylesFromState = () => { const ids = Object.keys(dataStyleState.styles || {}) const promises = [] @@ -80,6 +92,8 @@ export const useDataStyleStore = defineStore("dataStyle", () => { getStyle: dataStyleState.getStyle, objectVisibility: dataStyleState.objectVisibility, selectedObjects: dataStyleState.selectedObjects, + getAttributeSettings: dataStyleState.getAttributeSettings, + setAttributeSettings: dataStyleState.setAttributeSettings, ...meshStyleStore, ...modelStyleStore, addDataStyle, diff --git a/app/utils/colormap.js b/app/utils/colormap.js index 2a0f7744..daa50352 100644 --- a/app/utils/colormap.js +++ b/app/utils/colormap.js @@ -1,35 +1,20 @@ import vtkColorMaps from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps" -export function getRGBPointsFromPreset(presetName, min, max) { - const preset = vtkColorMaps.getPresetByName(presetName) - if (!preset || !preset.RGBPoints) { - return [ - [min, 59, 76, 192], - [(min + max) / 2, 221, 221, 221], - [max, 180, 4, 38], - ] - } - return getRGBPointsFromPresetData(preset.RGBPoints, min, max) +export function getRGBPointsFromPreset(presetName) { + return vtkColorMaps.getPresetByName(presetName) } -function getRGBPointsFromPresetData(rgbPoints, min, max) { +export function convertRGBPointsToSchemaFormat(flatRGBPoints) { + if (!flatRGBPoints || !Array.isArray(flatRGBPoints)) { + return [] + } const points = [] - const presetMin = rgbPoints[0] - const presetMax = rgbPoints[rgbPoints.length - 4] - const presetRange = presetMax - presetMin - const targetRange = max - min - - for (let i = 0; i < rgbPoints.length; i += 4) { - const originalValue = rgbPoints[i] - const normalizedValue = presetRange !== 0 - ? (originalValue - presetMin) / presetRange - : 0 - const scaledValue = min + normalizedValue * targetRange + for (let i = 0; i < flatRGBPoints.length; i += 4) { points.push([ - scaledValue, - Math.round(rgbPoints[i + 1] * 255), - Math.round(rgbPoints[i + 2] * 255), - Math.round(rgbPoints[i + 3] * 255), + flatRGBPoints[i], + flatRGBPoints[i + 1] * 255, + flatRGBPoints[i + 2] * 255, + flatRGBPoints[i + 3] * 255, ]) } return points diff --git a/internal/stores/data_style_state.js b/internal/stores/data_style_state.js index 3b5dd49d..978d49d1 100644 --- a/internal/stores/data_style_state.js +++ b/internal/stores/data_style_state.js @@ -1,8 +1,12 @@ import { reactive, computed } from "vue" +const DEFAULT_COLOR_MAP = "Cool to Warm" + export const useDataStyleStateStore = defineStore("dataStyleState", () => { const styles = reactive({}) + const attributeSettings = reactive({}) + const objectVisibility = computed(() => (id) => { if (styles[id]) { return styles[id].visibility @@ -23,5 +27,26 @@ export const useDataStyleStateStore = defineStore("dataStyleState", () => { return styles[id] } - return { getStyle, styles, objectVisibility, selectedObjects } + function getAttributeSettings(meshId, attributeType, attributeName) { + const key = `${meshId}:${attributeType}:${attributeName}` + return attributeSettings[key] || null + } + function setAttributeSettings(meshId, attributeType, attributeName, settings) { + const key = `${meshId}:${attributeType}:${attributeName}` + attributeSettings[key] = { + min: settings.min, + max: settings.max, + colorMap: settings.colorMap || DEFAULT_COLOR_MAP, + } + } + + return { + getStyle, + styles, + objectVisibility, + selectedObjects, + attributeSettings, + getAttributeSettings, + setAttributeSettings, + } }) From b3f2127283a3a9c6f3fb28168d7b3189ba95b461 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 29 Jan 2026 14:05:30 +0100 Subject: [PATCH 05/41] rm useless imports --- .../Viewer/Options/ColorMapList.vue | 119 +++---- .../Viewer/Options/ColorMapPicker.vue | 295 +++++++++--------- 2 files changed, 212 insertions(+), 202 deletions(-) diff --git a/app/components/Viewer/Options/ColorMapList.vue b/app/components/Viewer/Options/ColorMapList.vue index 5b8c158e..e1961ed9 100644 --- a/app/components/Viewer/Options/ColorMapList.vue +++ b/app/components/Viewer/Options/ColorMapList.vue @@ -1,60 +1,4 @@ - - + From 490a35fa732ea2a7b8772b12c4f8bc92621eb11e Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 29 Jan 2026 14:34:02 +0100 Subject: [PATCH 06/41] edit components --- .../EdgedCurve/SpecificEdgesOptions.vue | 85 ++++++----- .../Viewer/Generic/Mesh/CellsOptions.vue | 45 +++--- .../Viewer/Generic/Mesh/EdgesOptions.vue | 83 ++++++----- .../Viewer/Generic/Mesh/PointsOptions.vue | 83 ++++++----- .../Viewer/Generic/Mesh/PolygonsOptions.vue | 45 +++--- .../Viewer/Generic/Mesh/PolyhedraOptions.vue | 43 +++--- .../Viewer/Options/ColoringTypeSelector.vue | 133 +++++++++--------- .../Viewer/PointSet/SpecificPointsOptions.vue | 83 ++++++----- .../SpecificPolygonsOptions.vue | 45 +++--- .../Viewer/Solid/SpecificPolyhedraOptions.vue | 43 +++--- 10 files changed, 339 insertions(+), 349 deletions(-) diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue index 239bd6e2..77c2fb5f 100644 --- a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -1,46 +1,3 @@ - - + diff --git a/app/components/Viewer/Generic/Mesh/CellsOptions.vue b/app/components/Viewer/Generic/Mesh/CellsOptions.vue index 2800db2f..862e054c 100644 --- a/app/components/Viewer/Generic/Mesh/CellsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/CellsOptions.vue @@ -1,26 +1,3 @@ - - + diff --git a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue index 9c3eebbc..64cadef5 100644 --- a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +++ b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue @@ -1,45 +1,3 @@ - - + diff --git a/app/components/Viewer/Generic/Mesh/PointsOptions.vue b/app/components/Viewer/Generic/Mesh/PointsOptions.vue index ea61d0b1..8374252d 100644 --- a/app/components/Viewer/Generic/Mesh/PointsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -1,45 +1,3 @@ - - + diff --git a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue index b47aff81..6cf5f186 100644 --- a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue @@ -1,26 +1,3 @@ - - + diff --git a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue index a6373068..4f2e4a89 100644 --- a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue @@ -1,25 +1,3 @@ - - + diff --git a/app/components/Viewer/Options/ColoringTypeSelector.vue b/app/components/Viewer/Options/ColoringTypeSelector.vue index 2971f587..19898e3a 100644 --- a/app/components/Viewer/Options/ColoringTypeSelector.vue +++ b/app/components/Viewer/Options/ColoringTypeSelector.vue @@ -1,70 +1,3 @@ - - + diff --git a/app/components/Viewer/PointSet/SpecificPointsOptions.vue b/app/components/Viewer/PointSet/SpecificPointsOptions.vue index 5bce67e5..68237370 100644 --- a/app/components/Viewer/PointSet/SpecificPointsOptions.vue +++ b/app/components/Viewer/PointSet/SpecificPointsOptions.vue @@ -1,45 +1,3 @@ - - + diff --git a/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue b/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue index 225caa10..2292253e 100644 --- a/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +++ b/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue @@ -1,26 +1,3 @@ - - + diff --git a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue index a8760641..bb5b54cd 100644 --- a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +++ b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue @@ -1,25 +1,3 @@ - - + From 4fb4d636fe980c006b0bcddad8be4e70e943c2e0 Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Thu, 29 Jan 2026 13:39:49 +0000 Subject: [PATCH 07/41] Apply prepare changes --- app/stores/data_style.js | 1 - internal/stores/data_style_state.js | 7 ++- internal/stores/mesh/cells.js | 12 ++++- internal/stores/mesh/edges.js | 6 ++- internal/stores/mesh/index.js | 48 +++++++++++++++---- internal/stores/mesh/points.js | 9 ++-- internal/stores/mesh/polygons.js | 19 ++++---- internal/stores/mesh/polyhedra.js | 18 +++---- .../microservices/back/requirements.txt | 1 - .../microservices/viewer/requirements.txt | 1 - 10 files changed, 86 insertions(+), 36 deletions(-) diff --git a/app/stores/data_style.js b/app/stores/data_style.js index 41d61462..54c55f5b 100644 --- a/app/stores/data_style.js +++ b/app/stores/data_style.js @@ -70,7 +70,6 @@ export const useDataStyleStore = defineStore("dataStyle", () => { } } - const applyAllStylesFromState = () => { const ids = Object.keys(dataStyleState.styles || {}) const promises = [] diff --git a/internal/stores/data_style_state.js b/internal/stores/data_style_state.js index 978d49d1..c0320cd0 100644 --- a/internal/stores/data_style_state.js +++ b/internal/stores/data_style_state.js @@ -31,7 +31,12 @@ export const useDataStyleStateStore = defineStore("dataStyleState", () => { const key = `${meshId}:${attributeType}:${attributeName}` return attributeSettings[key] || null } - function setAttributeSettings(meshId, attributeType, attributeName, settings) { + function setAttributeSettings( + meshId, + attributeType, + attributeName, + settings, + ) { const key = `${meshId}:${attributeType}:${attributeName}` attributeSettings[key] = { min: settings.min, diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index d53f52de..8d24be73 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -124,7 +124,11 @@ export function useMeshCellsStyle() { { id, minimum, maximum }, { response_function: () => { - console.log(setMeshCellsCellScalarRange.name, { id, minimum, maximum }) + console.log(setMeshCellsCellScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) @@ -136,7 +140,11 @@ export function useMeshCellsStyle() { { id, minimum, maximum }, { response_function: () => { - console.log(setMeshCellsVertexScalarRange.name, { id, minimum, maximum }) + console.log(setMeshCellsVertexScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 35f6c4bf..df379940 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -152,7 +152,11 @@ export function useMeshEdgesStyle() { { id, minimum, maximum }, { response_function: () => { - console.log(setMeshEdgesVertexScalarRange.name, { id, minimum, maximum }) + console.log(setMeshEdgesVertexScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) diff --git a/internal/stores/mesh/index.js b/internal/stores/mesh/index.js index 813e5512..775c4aa8 100644 --- a/internal/stores/mesh/index.js +++ b/internal/stores/mesh/index.js @@ -67,15 +67,35 @@ export default function useMeshStyle() { function setVertexScalarRange(id, meshType, minimum, maximum) { switch (meshType) { case "points": - return meshPointsStyleStore.setMeshPointsVertexScalarRange(id, minimum, maximum) + return meshPointsStyleStore.setMeshPointsVertexScalarRange( + id, + minimum, + maximum, + ) case "edges": - return meshEdgesStyleStore.setMeshEdgesVertexScalarRange(id, minimum, maximum) + return meshEdgesStyleStore.setMeshEdgesVertexScalarRange( + id, + minimum, + maximum, + ) case "cells": - return meshCellsStyleStore.setMeshCellsVertexScalarRange(id, minimum, maximum) + return meshCellsStyleStore.setMeshCellsVertexScalarRange( + id, + minimum, + maximum, + ) case "polygons": - return meshPolygonsStyleStore.setMeshPolygonsVertexScalarRange(id, minimum, maximum) + return meshPolygonsStyleStore.setMeshPolygonsVertexScalarRange( + id, + minimum, + maximum, + ) case "polyhedra": - return meshPolyhedraStyleStore.setPolyhedraVertexScalarRange(id, minimum, maximum) + return meshPolyhedraStyleStore.setPolyhedraVertexScalarRange( + id, + minimum, + maximum, + ) default: throw new Error("Unknown meshType for vertex scalar range: " + meshType) } @@ -101,11 +121,23 @@ export default function useMeshStyle() { function setElementScalarRange(id, elementType, minimum, maximum) { switch (elementType) { case "cell": - return meshCellsStyleStore.setMeshCellsCellScalarRange(id, minimum, maximum) + return meshCellsStyleStore.setMeshCellsCellScalarRange( + id, + minimum, + maximum, + ) case "polygon": - return meshPolygonsStyleStore.setMeshPolygonsPolygonScalarRange(id, minimum, maximum) + return meshPolygonsStyleStore.setMeshPolygonsPolygonScalarRange( + id, + minimum, + maximum, + ) case "polyhedron": - return meshPolyhedraStyleStore.setPolyhedraPolyhedronScalarRange(id, minimum, maximum) + return meshPolyhedraStyleStore.setPolyhedraPolyhedronScalarRange( + id, + minimum, + maximum, + ) default: throw new Error("Unknown elementType for scalar range: " + elementType) } diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 675907b9..90ce3eba 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -124,10 +124,11 @@ export function useMeshPointsStyle() { { id, minimum, maximum }, { response_function: () => { - console.log( - setMeshPointsVertexScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setMeshPointsVertexScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index d19087e6..ad92f239 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -130,10 +130,11 @@ export function useMeshPolygonsStyle() { { id, minimum, maximum }, { response_function: () => { - console.log( - setMeshPolygonsPolygonScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setMeshPolygonsPolygonScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) @@ -145,10 +146,11 @@ export function useMeshPolygonsStyle() { { id, minimum, maximum }, { response_function: () => { - console.log( - setMeshPolygonsVertexScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setMeshPolygonsVertexScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) @@ -178,7 +180,6 @@ export function useMeshPolygonsStyle() { ) } - function meshPolygonsActiveColoring(id) { return meshPolygonsStyle(id).coloring.active } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index a271264c..260e2492 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -135,10 +135,11 @@ export function useMeshPolyhedraStyle() { { id, minimum, maximum }, { response_function: () => { - console.log( - setPolyhedraPolyhedronScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setPolyhedraPolyhedronScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) @@ -150,10 +151,11 @@ export function useMeshPolyhedraStyle() { { id, minimum, maximum }, { response_function: () => { - console.log( - setPolyhedraVertexScalarRange.name, - { id, minimum, maximum }, - ) + console.log(setPolyhedraVertexScalarRange.name, { + id, + minimum, + maximum, + }) }, }, ) diff --git a/tests/integration/microservices/back/requirements.txt b/tests/integration/microservices/back/requirements.txt index ecc4fc94..bd3a3ef5 100644 --- a/tests/integration/microservices/back/requirements.txt +++ b/tests/integration/microservices/back/requirements.txt @@ -5,4 +5,3 @@ # pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in # -opengeodeweb-back==6.*,>=6.0.0 diff --git a/tests/integration/microservices/viewer/requirements.txt b/tests/integration/microservices/viewer/requirements.txt index 39137326..4d097394 100644 --- a/tests/integration/microservices/viewer/requirements.txt +++ b/tests/integration/microservices/viewer/requirements.txt @@ -5,4 +5,3 @@ # pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in # -opengeodeweb-viewer==1.*,>=1.15.0 From 8f5df62dfd1a951e5d4f62ecf8f54086e38a67a8 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Mon, 2 Feb 2026 11:46:34 +0100 Subject: [PATCH 08/41] fix logic and design --- .../Viewer/Generic/Mesh/PointsOptions.vue | 7 ++ .../Viewer/Generic/Mesh/PolygonsOptions.vue | 14 +++ .../Viewer/Generic/Mesh/PolyhedraOptions.vue | 14 +++ .../Viewer/Options/CellAttributeSelector.vue | 28 ++++-- .../Viewer/Options/ColorMapList.vue | 87 +++++++++++++++---- .../Viewer/Options/ColorMapPicker.vue | 19 ++-- .../Viewer/Options/EdgeAttributeSelector.vue | 29 +++++-- .../Options/PolygonAttributeSelector.vue | 36 +++++--- .../Options/PolyhedronAttributeSelector.vue | 29 +++++-- .../Options/VertexAttributeSelector.vue | 37 +++++--- app/utils/colormap.js | 23 +++-- internal/stores/mesh/cells.js | 32 +++++-- internal/stores/mesh/edges.js | 16 +++- internal/stores/mesh/index.js | 60 ++++++++++--- internal/stores/mesh/points.js | 16 +++- internal/stores/mesh/polygons.js | 32 +++++-- internal/stores/mesh/polyhedra.js | 32 +++++-- 17 files changed, 403 insertions(+), 108 deletions(-) diff --git a/app/components/Viewer/Generic/Mesh/PointsOptions.vue b/app/components/Viewer/Generic/Mesh/PointsOptions.vue index 8374252d..fd5bc1cc 100644 --- a/app/components/Viewer/Generic/Mesh/PointsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -44,6 +44,13 @@ hybridViewerStore.remoteRender() }, }) + const vertex_attribute = computed({ + get: () => dataStyleStore.meshPointsVertexAttribute(id.value), + set: (newValue) => { + dataStyleStore.setMeshPointsVertexAttribute(id.value, newValue) + hybridViewerStore.remoteRender() + }, + }) diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index fe1389d6..937c42da 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -9,14 +9,34 @@ id: { type: String, required: true }, }) - const model = defineModel() const geodeStore = useGeodeStore() const dataStyleStore = useDataStyleStore() const hybridViewerStore = useHybridViewerStore() - const polyhedron_attribute_name = ref("") const polyhedron_attribute_names = ref([]) + const storePolyhedronAttribute = computed(() => { + return dataStyleStore.meshPolyhedraPolyhedronAttribute?.(props.id) || {} + }) + + const polyhedron_attribute_name = computed({ + get: () => storePolyhedronAttribute.value?.name || "", + set: (newName) => { + if (newName) { + dataStyleStore.setMeshPolyhedraPolyhedronAttributeName( + props.id, + newName, + ) + const attribute = polyhedron_attribute_names.value.find( + (attr) => attr.attribute_name === newName, + ) + if (attribute) { + onScalarRangeChange(attribute.min_value, attribute.max_value) + } + } + }, + }) + const selectedAttributeRange = computed(() => { const attribute = polyhedron_attribute_names.value.find( (attr) => attr.attribute_name === polyhedron_attribute_name.value, @@ -27,112 +47,43 @@ return [0, 1] }) - const polyhedron_attribute = reactive({ - name: "", - minimum: undefined, - maximum: undefined, - colorMap: "Cool to Warm", + const minimum = computed({ + get: () => storePolyhedronAttribute.value?.minimum, + set: (value) => + onScalarRangeChange(value, storePolyhedronAttribute.value?.maximum), }) - onMounted(() => { - if (model.value != null && model.value.name) { - polyhedron_attribute_name.value = model.value.name - loadSettingsForAttribute(model.value.name) - } + const maximum = computed({ + get: () => storePolyhedronAttribute.value?.maximum, + set: (value) => + onScalarRangeChange(storePolyhedronAttribute.value?.minimum, value), }) - watch(polyhedron_attribute_name, (newName, oldName) => { - if ( - oldName && - polyhedron_attribute.minimum !== undefined && - polyhedron_attribute.maximum !== undefined - ) { - dataStyleStore.setAttributeSettings(props.id, "polyhedron", oldName, { - minimum: polyhedron_attribute.minimum, - maximum: polyhedron_attribute.maximum, - colorMap: polyhedron_attribute.colorMap, - }) - } - polyhedron_attribute.name = newName - if (newName) { - loadSettingsForAttribute(newName) - } - model.value = { ...polyhedron_attribute } + const colorMap = computed({ + get: () => storePolyhedronAttribute.value?.colorMap || "Cool to Warm", + set: (value) => onColorMapChange(value), }) - function loadSettingsForAttribute(attributeName) { - const cached = dataStyleStore.getAttributeSettings( - props.id, - "polyhedron", - attributeName, - ) - if (cached) { - polyhedron_attribute.minimum = cached.minimum - polyhedron_attribute.maximum = cached.maximum - polyhedron_attribute.colorMap = cached.colorMap - } else { - const attribute = polyhedron_attribute_names.value.find( - (attr) => attr.attribute_name === attributeName, - ) - polyhedron_attribute.minimum = attribute ? attribute.min_value : 0 - polyhedron_attribute.maximum = attribute ? attribute.max_value : 1 - polyhedron_attribute.colorMap = "Cool to Warm" - } - // Apply the loaded settings to the viewer - nextTick(() => { - onScalarRangeChange() - onColorMapChange() - }) - } - - watch( - () => [ - polyhedron_attribute.minimum, - polyhedron_attribute.maximum, - polyhedron_attribute.colorMap, - ], - () => { - model.value = { ...polyhedron_attribute } - if (polyhedron_attribute.name) { - dataStyleStore.setAttributeSettings( - props.id, - "polyhedron", - polyhedron_attribute.name, - { - minimum: polyhedron_attribute.minimum, - maximum: polyhedron_attribute.maximum, - colorMap: polyhedron_attribute.colorMap, - }, - ) - } - }, - ) - - function onScalarRangeChange() { - if ( - polyhedron_attribute.minimum !== undefined && - polyhedron_attribute.maximum !== undefined - ) { + function onScalarRangeChange(min, max) { + if (min !== undefined && max !== undefined) { dataStyleStore.setMeshPolyhedraPolyhedronAttributeRange( props.id, - polyhedron_attribute.minimum, - polyhedron_attribute.maximum, + min, + max, ) - onColorMapChange() + onColorMapChange(colorMap.value, min, max) } } - function onColorMapChange() { - if ( - polyhedron_attribute.minimum !== undefined && - polyhedron_attribute.maximum !== undefined && - polyhedron_attribute.colorMap - ) { + function onColorMapChange(newColorMap, min, max) { + min = min ?? minimum.value + max = max ?? maximum.value + if (min !== undefined && max !== undefined && newColorMap) { dataStyleStore.setMeshPolyhedraPolyhedronAttributeColorMap( props.id, - polyhedron_attribute.colorMap, - polyhedron_attribute.minimum, - polyhedron_attribute.maximum, + newColorMap, + min, + max, ) hybridViewerStore.remoteRender() } @@ -166,13 +117,10 @@ /> diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index 14810e64..d2dced8f 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -9,16 +9,36 @@ const dataStyleStore = useDataStyleStore() const hybridViewerStore = useHybridViewerStore() - const model = defineModel() - const props = defineProps({ id: { type: String, required: true }, meshType: { type: String, default: "polygons" }, }) - const vertex_attribute_name = ref("") + const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1) + const vertex_attribute_names = ref([]) + const storeVertexAttribute = computed(() => { + const methodName = `mesh${capitalize(props.meshType)}VertexAttribute` + return dataStyleStore[methodName]?.(props.id) || {} + }) + + const vertex_attribute_name = computed({ + get: () => storeVertexAttribute.value?.name || "", + set: (newName) => { + if (newName) { + const methodName = `setMesh${capitalize(props.meshType)}VertexAttributeName` + dataStyleStore[methodName](props.id, newName) + const attribute = vertex_attribute_names.value.find( + (attr) => attr.attribute_name === newName, + ) + if (attribute) { + onScalarRangeChange(attribute.min_value, attribute.max_value) + } + } + }, + }) + const selectedAttributeRange = computed(() => { const attribute = vertex_attribute_names.value.find( (attr) => attr.attribute_name === vertex_attribute_name.value, @@ -29,121 +49,37 @@ return [0, 1] }) - const vertex_attribute = reactive({ - name: "", - minimum: undefined, - maximum: undefined, - colorMap: "Cool to Warm", + const minimum = computed({ + get: () => storeVertexAttribute.value?.minimum, + set: (value) => + onScalarRangeChange(value, storeVertexAttribute.value?.maximum), }) - onMounted(() => { - if (model.value != null && model.value.name) { - vertex_attribute_name.value = model.value.name - loadSettingsForAttribute(model.value.name) - } + const maximum = computed({ + get: () => storeVertexAttribute.value?.maximum, + set: (value) => + onScalarRangeChange(storeVertexAttribute.value?.minimum, value), }) - watch(vertex_attribute_name, (newName, oldName) => { - if ( - oldName && - vertex_attribute.minimum !== undefined && - vertex_attribute.maximum !== undefined - ) { - dataStyleStore.setAttributeSettings(props.id, "vertex", oldName, { - minimum: vertex_attribute.minimum, - maximum: vertex_attribute.maximum, - colorMap: vertex_attribute.colorMap, - }) - } - - vertex_attribute.name = newName - - if (newName) { - loadSettingsForAttribute(newName) - } - - model.value = { ...vertex_attribute } + const colorMap = computed({ + get: () => storeVertexAttribute.value?.colorMap || "Cool to Warm", + set: (value) => onColorMapChange(value), }) - function loadSettingsForAttribute(attributeName) { - const cached = dataStyleStore.getAttributeSettings( - props.id, - "vertex", - attributeName, - ) - if (cached) { - vertex_attribute.minimum = cached.minimum - vertex_attribute.maximum = cached.maximum - vertex_attribute.colorMap = cached.colorMap - } else { - const attribute = vertex_attribute_names.value.find( - (attr) => attr.attribute_name === attributeName, - ) - vertex_attribute.minimum = attribute ? attribute.min_value : 0 - vertex_attribute.maximum = attribute ? attribute.max_value : 1 - vertex_attribute.colorMap = "Cool to Warm" - } - nextTick(() => { - onScalarRangeChange() - onColorMapChange() - }) - } - - watch( - () => [ - vertex_attribute.minimum, - vertex_attribute.maximum, - vertex_attribute.colorMap, - ], - () => { - model.value = { ...vertex_attribute } - if (vertex_attribute.name) { - dataStyleStore.setAttributeSettings( - props.id, - "vertex", - vertex_attribute.name, - { - minimum: vertex_attribute.minimum, - maximum: vertex_attribute.maximum, - colorMap: vertex_attribute.colorMap, - }, - ) - } - }, - ) - - function onScalarRangeChange() { - if ( - vertex_attribute.minimum !== undefined && - vertex_attribute.maximum !== undefined - ) { - const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1) + function onScalarRangeChange(min, max) { + if (min !== undefined && max !== undefined) { const methodName = `setMesh${capitalize(props.meshType)}VertexAttributeRange` - dataStyleStore[methodName]( - props.id, - vertex_attribute.minimum, - vertex_attribute.maximum, - ) - onColorMapChange() + dataStyleStore[methodName](props.id, min, max) + onColorMapChange(colorMap.value, min, max) } } - function onColorMapChange() { - if ( - vertex_attribute.minimum !== undefined && - vertex_attribute.maximum !== undefined && - vertex_attribute.colorMap - ) { - const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1) - const methodName = `setMesh${capitalize( - props.meshType, - )}VertexAttributeColorMap` - dataStyleStore[methodName]( - props.id, - vertex_attribute.colorMap, - vertex_attribute.minimum, - vertex_attribute.maximum, - ) + function onColorMapChange(newColorMap, min, max) { + min = min ?? minimum.value + max = max ?? maximum.value + if (min !== undefined && max !== undefined && newColorMap) { + const methodName = `setMesh${capitalize(props.meshType)}VertexAttributeColorMap` + dataStyleStore[methodName](props.id, newColorMap, min, max) hybridViewerStore.remoteRender() } } @@ -176,13 +112,10 @@ /> diff --git a/app/stores/data_style.js b/app/stores/data_style.js index 15f1e1e6..9b92e8ba 100644 --- a/app/stores/data_style.js +++ b/app/stores/data_style.js @@ -59,35 +59,6 @@ export const useDataStyleStore = defineStore("dataStyle", () => { for (const [id, style] of Object.entries(stylesSnapshot)) { dataStyleState.styles[id] = style } - - const attributeSettingsSnapshot = snapshot.attributeSettings || {} - for (const [key, settings] of Object.entries(attributeSettingsSnapshot)) { - const [meshId, attributeType, attributeName] = key.split(":") - if (dataStyleState.styles[meshId]) { - if (!dataStyleState.styles[meshId].attributes) { - dataStyleState.styles[meshId].attributes = {} - } - // Migration: min/max to minimum/maximum - const migratedSettings = { ...settings } - if ( - migratedSettings.min !== undefined && - migratedSettings.minimum === undefined - ) { - migratedSettings.minimum = migratedSettings.min - delete migratedSettings.min - } - if ( - migratedSettings.max !== undefined && - migratedSettings.maximum === undefined - ) { - migratedSettings.maximum = migratedSettings.max - delete migratedSettings.max - } - dataStyleState.styles[meshId].attributes[ - `${attributeType}:${attributeName}` - ] = migratedSettings - } - } } const applyAllStylesFromState = () => { @@ -111,8 +82,6 @@ export const useDataStyleStore = defineStore("dataStyle", () => { getStyle: dataStyleState.getStyle, objectVisibility: dataStyleState.objectVisibility, selectedObjects: dataStyleState.selectedObjects, - getAttributeSettings: dataStyleState.getAttributeSettings, - setAttributeSettings: dataStyleState.setAttributeSettings, ...meshStyleStore, ...modelStyleStore, addDataStyle, diff --git a/internal/stores/data_style_state.js b/internal/stores/data_style_state.js index 96388ef5..d8d594fb 100644 --- a/internal/stores/data_style_state.js +++ b/internal/stores/data_style_state.js @@ -1,7 +1,5 @@ import { reactive, computed } from "vue" -const DEFAULT_COLOR_MAP = "Cool to Warm" - export const useDataStyleStateStore = defineStore("dataStyleState", () => { const styles = reactive({}) @@ -25,33 +23,10 @@ export const useDataStyleStateStore = defineStore("dataStyleState", () => { return styles[id] } - function getAttributeSettings(meshId, attributeType, attributeName) { - const key = `${attributeType}:${attributeName}` - return styles[meshId]?.attributes?.[key] || null - } - function setAttributeSettings( - meshId, - attributeType, - attributeName, - settings, - ) { - const key = `${attributeType}:${attributeName}` - if (!styles[meshId].attributes) { - styles[meshId].attributes = {} - } - styles[meshId].attributes[key] = { - minimum: settings.minimum, - maximum: settings.maximum, - colorMap: settings.colorMap || DEFAULT_COLOR_MAP, - } - } - return { getStyle, styles, objectVisibility, selectedObjects, - getAttributeSettings, - setAttributeSettings, } }) diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 71b3242a..1945887d 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -127,10 +127,11 @@ export function useMeshCellsStyle() { const vertex = meshCellsStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshCellsVertexAttributeColorMap(id, points, minimum, maximum) { + function setMeshCellsVertexAttributeColorMap(id, colorMapName, minimum, maximum) { const coloring_style = meshCellsStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_cells_schemas.attribute.vertex.color_map, @@ -140,8 +141,8 @@ export function useMeshCellsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } - coloring_style.vertex.colorMap = points - console.log(setMeshCellsVertexAttributeColorMap.name, { id, points }) + coloring_style.vertex.colorMap = colorMapName + console.log(setMeshCellsVertexAttributeColorMap.name, { id, colorMapName }) }, }, ) @@ -198,10 +199,11 @@ export function useMeshCellsStyle() { const cell = meshCellsStyle(id).coloring.cell return cell ? cell.colorMap : null } - function setMeshCellsCellAttributeColorMap(id, points, minimum, maximum) { + function setMeshCellsCellAttributeColorMap(id, colorMapName, minimum, maximum) { const coloring_style = meshCellsStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_cells_schemas.attribute.cell.color_map, @@ -211,8 +213,8 @@ export function useMeshCellsStyle() { if (!coloring_style.cell) { coloring_style.cell = {} } - coloring_style.cell.colorMap = points - console.log(setMeshCellsCellAttributeColorMap.name, { id, points }) + coloring_style.cell.colorMap = colorMapName + console.log(setMeshCellsCellAttributeColorMap.name, { id, colorMapName }) }, }, ) @@ -237,13 +239,35 @@ export function useMeshCellsStyle() { } return setMeshCellsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex && coloring.vertex.name) { - return setMeshCellsVertexAttributeName(id, coloring.vertex.name) + if (coloring.vertex === null) { + throw new Error("Vertex attribute not set") + } + if (coloring.vertex.name) { + return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshCellsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshCellsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } return Promise.resolve() } else if (type === "cell") { - if (coloring.cell && coloring.cell.name) { - return setMeshCellsCellAttributeName(id, coloring.cell.name) + if (coloring.cell === null) { + throw new Error("Cell attribute not set") + } + if (coloring.cell.name) { + return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { + if (coloring.cell.minimum !== undefined && coloring.cell.maximum !== undefined) { + return setMeshCellsCellAttributeRange(id, coloring.cell.minimum, coloring.cell.maximum).then(() => { + if (coloring.cell.colorMap) { + return setMeshCellsCellAttributeColorMap(id, coloring.cell.colorMap, coloring.cell.minimum, coloring.cell.maximum) + } + }) + } + }) } return Promise.resolve() } else { @@ -251,42 +275,14 @@ export function useMeshCellsStyle() { } } + + function applyMeshCellsStyle(id) { const style = meshCellsStyle(id) - const promises = [ + return Promise.all([ setMeshCellsVisibility(id, style.visibility), setMeshCellsActiveColoring(id, style.coloring.active), - ] - - if (style.coloring.active === "vertex" && style.coloring.vertex) { - const { name, min, max, colorMap } = style.coloring.vertex - if (name) { - promises.push(setMeshCellsVertexAttributeName(id, name)) - } - if (min !== undefined && max !== undefined) { - promises.push(setMeshCellsVertexAttributeRange(id, min, max)) - if (colorMap) { - promises.push( - setMeshCellsVertexAttributeColorMap(id, colorMap, min, max), - ) - } - } - } else if (style.coloring.active === "cell" && style.coloring.cell) { - const { name, min, max, colorMap } = style.coloring.cell - if (name) { - promises.push(setMeshCellsCellAttributeName(id, name)) - } - if (min !== undefined && max !== undefined) { - promises.push(setMeshCellsCellAttributeRange(id, min, max)) - if (colorMap) { - promises.push( - setMeshCellsCellAttributeColorMap(id, colorMap, min, max), - ) - } - } - } - - return Promise.all(promises) + ]) } return { diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index a232e6ba..5dafb1c8 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -51,13 +51,35 @@ export function useMeshEdgesStyle() { if (type === "color") { return setMeshEdgesColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex && coloring.vertex.name) { - return setMeshEdgesVertexAttributeName(id, coloring.vertex.name) + if (coloring.vertex === null) { + throw new Error("Vertex attribute not set") + } + if (coloring.vertex.name) { + return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshEdgesVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshEdgesVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } return Promise.resolve() } else if (type === "edge") { - if (coloring.edge && coloring.edge.name) { - return setMeshEdgesEdgeAttributeName(id, coloring.edge.name) + if (coloring.edge === null) { + throw new Error("Edge attribute not set") + } + if (coloring.edge.name) { + return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { + if (coloring.edge.minimum !== undefined && coloring.edge.maximum !== undefined) { + return setMeshEdgesEdgeAttributeRange(id, coloring.edge.minimum, coloring.edge.maximum).then(() => { + if (coloring.edge.colorMap) { + return setMeshEdgesEdgeAttributeColorMap(id, coloring.edge.colorMap, coloring.edge.minimum, coloring.edge.maximum) + } + }) + } + }) } return Promise.resolve() } else { @@ -154,10 +176,11 @@ export function useMeshEdgesStyle() { const vertex = meshEdgesStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshEdgesVertexAttributeColorMap(id, points, minimum, maximum) { + function setMeshEdgesVertexAttributeColorMap(id, colorMapName, minimum, maximum) { const coloring_style = meshEdgesStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_edges_schemas.attribute.vertex.color_map, @@ -167,8 +190,8 @@ export function useMeshEdgesStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } - coloring_style.vertex.colorMap = points - console.log(setMeshEdgesVertexAttributeColorMap.name, { id, points }) + coloring_style.vertex.colorMap = colorMapName + console.log(setMeshEdgesVertexAttributeColorMap.name, { id, colorMapName }) }, }, ) @@ -234,17 +257,18 @@ export function useMeshEdgesStyle() { const edge = meshEdgesStyle(id).coloring.edge return edge ? edge.colorMap : null } - function setMeshEdgesEdgeAttributeColorMap(id, points, minimum, maximum) { + function setMeshEdgesEdgeAttributeColorMap(id, colorMapName, minimum, maximum) { const coloring_style = meshEdgesStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } if (!mesh_edges_schemas.edge_color_map) { console.warn("setMeshEdgesEdgeAttributeColorMap: RPC not available") if (!coloring_style.edge) { coloring_style.edge = {} } - coloring_style.edge.colorMap = points + coloring_style.edge.colorMap = colorMapName return Promise.resolve() } return viewerStore.request( @@ -255,8 +279,8 @@ export function useMeshEdgesStyle() { if (!coloring_style.edge) { coloring_style.edge = {} } - coloring_style.edge.colorMap = points - console.log(setMeshEdgesEdgeAttributeColorMap.name, { id, points }) + coloring_style.edge.colorMap = colorMapName + console.log(setMeshEdgesEdgeAttributeColorMap.name, { id, colorMapName }) }, }, ) @@ -264,41 +288,11 @@ export function useMeshEdgesStyle() { function applyMeshEdgesStyle(id) { const style = meshEdgesStyle(id) - const promises = [ + return Promise.all([ setMeshEdgesVisibility(id, style.visibility), setMeshEdgesActiveColoring(id, style.coloring.active), setMeshEdgesWidth(id, style.width), - ] - - if (style.coloring.active === "vertex" && style.coloring.vertex) { - const { name, minimum, maximum, colorMap } = style.coloring.vertex - if (name) { - promises.push(setMeshEdgesVertexAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push(setMeshEdgesVertexAttributeRange(id, minimum, maximum)) - if (colorMap) { - promises.push( - setMeshEdgesVertexAttributeColorMap(id, colorMap, minimum, maximum), - ) - } - } - } else if (style.coloring.active === "edge" && style.coloring.edge) { - const { name, minimum, maximum, colorMap } = style.coloring.edge - if (name) { - promises.push(setMeshEdgesEdgeAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push(setMeshEdgesEdgeAttributeRange(id, minimum, maximum)) - if (colorMap) { - promises.push( - setMeshEdgesEdgeAttributeColorMap(id, colorMap, minimum, maximum), - ) - } - } - } - - return Promise.all(promises) + ]) } return { diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 9db1c85d..06eec220 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -52,8 +52,19 @@ export function useMeshPointsStyle() { if (type === "color") { return setMeshPointsColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex && coloring.vertex.name) { - return setMeshPointsVertexAttributeName(id, coloring.vertex.name) + if (coloring.vertex === null) { + throw new Error("Vertex attribute not set") + } + if (coloring.vertex.name) { + return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPointsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPointsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } return Promise.resolve() } else { @@ -132,10 +143,11 @@ export function useMeshPointsStyle() { const vertex = meshPointsStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshPointsVertexAttributeColorMap(id, points, minimum, maximum) { + function setMeshPointsVertexAttributeColorMap(id, colorMapName, minimum, maximum) { const coloring_style = meshPointsStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_points_schemas.attribute.vertex.color_map, @@ -145,8 +157,8 @@ export function useMeshPointsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } - coloring_style.vertex.colorMap = points - console.log(setMeshPointsVertexAttributeColorMap.name, { id, points }) + coloring_style.vertex.colorMap = colorMapName + console.log(setMeshPointsVertexAttributeColorMap.name, { id, colorMapName }) }, }, ) @@ -170,33 +182,11 @@ export function useMeshPointsStyle() { function applyMeshPointsStyle(id) { const style = meshPointsStyle(id) - const promises = [ + return Promise.all([ setMeshPointsVisibility(id, style.visibility), setMeshPointsActiveColoring(id, style.coloring.active), setMeshPointsSize(id, style.size), - ] - - if (style.coloring.active === "vertex" && style.coloring.vertex) { - const { name, minimum, maximum, colorMap } = style.coloring.vertex - if (name) { - promises.push(setMeshPointsVertexAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push(setMeshPointsVertexAttributeRange(id, minimum, maximum)) - if (colorMap) { - promises.push( - setMeshPointsVertexAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ), - ) - } - } - } - - return Promise.all(promises) + ]) } return { diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index f8cf0f88..063dbe02 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -137,13 +137,14 @@ export function useMeshPolygonsStyle() { } function setMeshPolygonsVertexAttributeColorMap( id, - points, + colorMapName, minimum, maximum, ) { const coloring_style = meshPolygonsStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_polygons_schemas.attribute.vertex.color_map, @@ -153,10 +154,10 @@ export function useMeshPolygonsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } - coloring_style.vertex.colorMap = points + coloring_style.vertex.colorMap = colorMapName console.log(setMeshPolygonsVertexAttributeColorMap.name, { id, - points, + colorMapName, }) }, }, @@ -220,13 +221,14 @@ export function useMeshPolygonsStyle() { } function setMeshPolygonsPolygonAttributeColorMap( id, - points, + colorMapName, minimum, maximum, ) { const coloring_style = meshPolygonsStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_polygons_schemas.attribute.polygon.color_map, @@ -236,10 +238,10 @@ export function useMeshPolygonsStyle() { if (!coloring_style.polygon) { coloring_style.polygon = {} } - coloring_style.polygon.colorMap = points + coloring_style.polygon.colorMap = colorMapName console.log(setMeshPolygonsPolygonAttributeColorMap.name, { id, - points, + colorMapName, }) }, }, @@ -265,13 +267,35 @@ export function useMeshPolygonsStyle() { } return setMeshPolygonsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex && coloring.vertex.name) { - return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name) + if (coloring.vertex === null) { + throw new Error("Vertex attribute not set") + } + if (coloring.vertex.name) { + return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPolygonsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolygonsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } return Promise.resolve() } else if (type === "polygon") { - if (coloring.polygon && coloring.polygon.name) { - return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name) + if (coloring.polygon === null) { + throw new Error("Polygon attribute not set") + } + if (coloring.polygon.name) { + return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name).then(() => { + if (coloring.polygon.minimum !== undefined && coloring.polygon.maximum !== undefined) { + return setMeshPolygonsPolygonAttributeRange(id, coloring.polygon.minimum, coloring.polygon.maximum).then(() => { + if (coloring.polygon.colorMap) { + return setMeshPolygonsPolygonAttributeColorMap(id, coloring.polygon.colorMap, coloring.polygon.minimum, coloring.polygon.maximum) + } + }) + } + }) } return Promise.resolve() } else { @@ -281,50 +305,10 @@ export function useMeshPolygonsStyle() { function applyMeshPolygonsStyle(id) { const style = meshPolygonsStyle(id) - const promises = [ + return Promise.all([ setMeshPolygonsVisibility(id, style.visibility), setMeshPolygonsActiveColoring(id, style.coloring.active), - ] - - if (style.coloring.active === "vertex" && style.coloring.vertex) { - const { name, minimum, maximum, colorMap } = style.coloring.vertex - if (name) { - promises.push(setMeshPolygonsVertexAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push(setMeshPolygonsVertexAttributeRange(id, minimum, maximum)) - if (colorMap) { - promises.push( - setMeshPolygonsVertexAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ), - ) - } - } - } else if (style.coloring.active === "polygon" && style.coloring.polygon) { - const { name, minimum, maximum, colorMap } = style.coloring.polygon - if (name) { - promises.push(setMeshPolygonsPolygonAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push(setMeshPolygonsPolygonScalarRange(id, minimum, maximum)) - if (colorMap) { - promises.push( - setMeshPolygonsPolygonColorMap(id, colorMap, minimum, maximum), - ) - } - } - } else if ( - style.coloring.active === "textures" && - style.coloring.textures - ) { - promises.push(setMeshPolygonsTextures(id, style.coloring.textures)) - } - - return Promise.all(promises) + ]) } return { diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 7e5f7abd..438e913c 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -51,13 +51,35 @@ export function useMeshPolyhedraStyle() { if (type === "color") { return setMeshPolyhedraColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex) { - return setMeshPolyhedraVertexAttribute(id, coloring.vertex) + if (coloring.vertex === null) { + throw new Error("Vertex attribute not set") + } + if (coloring.vertex.name) { + return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPolyhedraVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolyhedraVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } return Promise.resolve() } else if (type === "polyhedron") { - if (coloring.polyhedron) { - return setMeshPolyhedraPolyhedronAttribute(id, coloring.polyhedron) + if (coloring.polyhedron === null) { + throw new Error("Polyhedron attribute not set") + } + if (coloring.polyhedron.name) { + return setMeshPolyhedraPolyhedronAttributeName(id, coloring.polyhedron.name).then(() => { + if (coloring.polyhedron.minimum !== undefined && coloring.polyhedron.maximum !== undefined) { + return setMeshPolyhedraPolyhedronAttributeRange(id, coloring.polyhedron.minimum, coloring.polyhedron.maximum).then(() => { + if (coloring.polyhedron.colorMap) { + return setMeshPolyhedraPolyhedronAttributeColorMap(id, coloring.polyhedron.colorMap, coloring.polyhedron.minimum, coloring.polyhedron.maximum) + } + }) + } + }) } return Promise.resolve() } else { @@ -143,13 +165,14 @@ export function useMeshPolyhedraStyle() { } function setMeshPolyhedraVertexAttributeColorMap( id, - points, + colorMapName, minimum, maximum, ) { const coloring_style = meshPolyhedraStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_polyhedra_schemas.attribute.vertex.color_map, @@ -159,10 +182,10 @@ export function useMeshPolyhedraStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } - coloring_style.vertex.colorMap = points + coloring_style.vertex.colorMap = colorMapName console.log(setMeshPolyhedraVertexAttributeColorMap.name, { id, - points, + colorMapName, }) }, }, @@ -233,13 +256,14 @@ export function useMeshPolyhedraStyle() { } function setMeshPolyhedraPolyhedronAttributeColorMap( id, - points, + colorMapName, minimum, maximum, ) { const coloring_style = meshPolyhedraStyle(id).coloring - if (typeof points === "string") { - points = getRGBPointsFromPreset(points) + let points = colorMapName + if (typeof colorMapName === "string") { + points = getRGBPointsFromPreset(colorMapName) } return viewerStore.request( mesh_polyhedra_schemas.attribute.polyhedron.color_map, @@ -249,10 +273,10 @@ export function useMeshPolyhedraStyle() { if (!coloring_style.polyhedron) { coloring_style.polyhedron = {} } - coloring_style.polyhedron.colorMap = points + coloring_style.polyhedron.colorMap = colorMapName console.log(setMeshPolyhedraPolyhedronAttributeColorMap.name, { id, - points, + colorMapName, }) }, }, @@ -261,52 +285,10 @@ export function useMeshPolyhedraStyle() { function applyMeshPolyhedraStyle(id) { const style = meshPolyhedraStyle(id) - const promises = [ + return Promise.all([ setMeshPolyhedraVisibility(id, style.visibility), setMeshPolyhedraActiveColoring(id, style.coloring.active), - ] - - if (style.coloring.active === "vertex" && style.coloring.vertex) { - const { name, minimum, maximum, colorMap } = style.coloring.vertex - if (name) { - promises.push(setMeshPolyhedraVertexAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push( - setMeshPolyhedraVertexAttributeRange(id, minimum, maximum), - ) - if (colorMap) { - promises.push( - setMeshPolyhedraVertexAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ), - ) - } - } - } else if ( - style.coloring.active === "polyhedron" && - style.coloring.polyhedron - ) { - const { name, minimum, maximum, colorMap } = style.coloring.polyhedron - if (name) { - promises.push(setMeshPolyhedraPolyhedronAttributeName(id, name)) - } - if (minimum !== undefined && maximum !== undefined) { - promises.push( - setMeshPolyhedraPolyhedronScalarRange(id, minimum, maximum), - ) - if (colorMap) { - promises.push( - setMeshPolyhedraPolyhedronColorMap(id, colorMap, minimum, maximum), - ) - } - } - } - - return Promise.all(promises) + ]) } return { From 4a5d2223fe1d1434f63a518c218ccf1242e04175 Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Wed, 4 Feb 2026 11:08:31 +0000 Subject: [PATCH 28/41] Apply prepare changes --- internal/stores/mesh/cells.js | 90 ++++++++++++++++++++++--------- internal/stores/mesh/edges.js | 88 ++++++++++++++++++++++-------- internal/stores/mesh/points.js | 44 +++++++++++---- internal/stores/mesh/polygons.js | 46 +++++++++++++--- internal/stores/mesh/polyhedra.js | 46 +++++++++++++--- 5 files changed, 241 insertions(+), 73 deletions(-) diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 1945887d..622e985f 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -127,7 +127,12 @@ export function useMeshCellsStyle() { const vertex = meshCellsStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshCellsVertexAttributeColorMap(id, colorMapName, minimum, maximum) { + function setMeshCellsVertexAttributeColorMap( + id, + colorMapName, + minimum, + maximum, + ) { const coloring_style = meshCellsStyle(id).coloring let points = colorMapName if (typeof colorMapName === "string") { @@ -142,7 +147,10 @@ export function useMeshCellsStyle() { coloring_style.vertex = {} } coloring_style.vertex.colorMap = colorMapName - console.log(setMeshCellsVertexAttributeColorMap.name, { id, colorMapName }) + console.log(setMeshCellsVertexAttributeColorMap.name, { + id, + colorMapName, + }) }, }, ) @@ -199,7 +207,12 @@ export function useMeshCellsStyle() { const cell = meshCellsStyle(id).coloring.cell return cell ? cell.colorMap : null } - function setMeshCellsCellAttributeColorMap(id, colorMapName, minimum, maximum) { + function setMeshCellsCellAttributeColorMap( + id, + colorMapName, + minimum, + maximum, + ) { const coloring_style = meshCellsStyle(id).coloring let points = colorMapName if (typeof colorMapName === "string") { @@ -214,7 +227,10 @@ export function useMeshCellsStyle() { coloring_style.cell = {} } coloring_style.cell.colorMap = colorMapName - console.log(setMeshCellsCellAttributeColorMap.name, { id, colorMapName }) + console.log(setMeshCellsCellAttributeColorMap.name, { + id, + colorMapName, + }) }, }, ) @@ -243,15 +259,29 @@ export function useMeshCellsStyle() { throw new Error("Vertex attribute not set") } if (coloring.vertex.name) { - return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshCellsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshCellsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshCellsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshCellsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } return Promise.resolve() } else if (type === "cell") { @@ -259,15 +289,29 @@ export function useMeshCellsStyle() { throw new Error("Cell attribute not set") } if (coloring.cell.name) { - return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { - if (coloring.cell.minimum !== undefined && coloring.cell.maximum !== undefined) { - return setMeshCellsCellAttributeRange(id, coloring.cell.minimum, coloring.cell.maximum).then(() => { - if (coloring.cell.colorMap) { - return setMeshCellsCellAttributeColorMap(id, coloring.cell.colorMap, coloring.cell.minimum, coloring.cell.maximum) - } - }) - } - }) + return setMeshCellsCellAttributeName(id, coloring.cell.name).then( + () => { + if ( + coloring.cell.minimum !== undefined && + coloring.cell.maximum !== undefined + ) { + return setMeshCellsCellAttributeRange( + id, + coloring.cell.minimum, + coloring.cell.maximum, + ).then(() => { + if (coloring.cell.colorMap) { + return setMeshCellsCellAttributeColorMap( + id, + coloring.cell.colorMap, + coloring.cell.minimum, + coloring.cell.maximum, + ) + } + }) + } + }, + ) } return Promise.resolve() } else { @@ -275,8 +319,6 @@ export function useMeshCellsStyle() { } } - - function applyMeshCellsStyle(id) { const style = meshCellsStyle(id) return Promise.all([ diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 5dafb1c8..23bc176e 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -55,15 +55,29 @@ export function useMeshEdgesStyle() { throw new Error("Vertex attribute not set") } if (coloring.vertex.name) { - return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshEdgesVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshEdgesVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshEdgesVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshEdgesVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } return Promise.resolve() } else if (type === "edge") { @@ -71,15 +85,29 @@ export function useMeshEdgesStyle() { throw new Error("Edge attribute not set") } if (coloring.edge.name) { - return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { - if (coloring.edge.minimum !== undefined && coloring.edge.maximum !== undefined) { - return setMeshEdgesEdgeAttributeRange(id, coloring.edge.minimum, coloring.edge.maximum).then(() => { - if (coloring.edge.colorMap) { - return setMeshEdgesEdgeAttributeColorMap(id, coloring.edge.colorMap, coloring.edge.minimum, coloring.edge.maximum) - } - }) - } - }) + return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then( + () => { + if ( + coloring.edge.minimum !== undefined && + coloring.edge.maximum !== undefined + ) { + return setMeshEdgesEdgeAttributeRange( + id, + coloring.edge.minimum, + coloring.edge.maximum, + ).then(() => { + if (coloring.edge.colorMap) { + return setMeshEdgesEdgeAttributeColorMap( + id, + coloring.edge.colorMap, + coloring.edge.minimum, + coloring.edge.maximum, + ) + } + }) + } + }, + ) } return Promise.resolve() } else { @@ -176,7 +204,12 @@ export function useMeshEdgesStyle() { const vertex = meshEdgesStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshEdgesVertexAttributeColorMap(id, colorMapName, minimum, maximum) { + function setMeshEdgesVertexAttributeColorMap( + id, + colorMapName, + minimum, + maximum, + ) { const coloring_style = meshEdgesStyle(id).coloring let points = colorMapName if (typeof colorMapName === "string") { @@ -191,7 +224,10 @@ export function useMeshEdgesStyle() { coloring_style.vertex = {} } coloring_style.vertex.colorMap = colorMapName - console.log(setMeshEdgesVertexAttributeColorMap.name, { id, colorMapName }) + console.log(setMeshEdgesVertexAttributeColorMap.name, { + id, + colorMapName, + }) }, }, ) @@ -257,7 +293,12 @@ export function useMeshEdgesStyle() { const edge = meshEdgesStyle(id).coloring.edge return edge ? edge.colorMap : null } - function setMeshEdgesEdgeAttributeColorMap(id, colorMapName, minimum, maximum) { + function setMeshEdgesEdgeAttributeColorMap( + id, + colorMapName, + minimum, + maximum, + ) { const coloring_style = meshEdgesStyle(id).coloring let points = colorMapName if (typeof colorMapName === "string") { @@ -280,7 +321,10 @@ export function useMeshEdgesStyle() { coloring_style.edge = {} } coloring_style.edge.colorMap = colorMapName - console.log(setMeshEdgesEdgeAttributeColorMap.name, { id, colorMapName }) + console.log(setMeshEdgesEdgeAttributeColorMap.name, { + id, + colorMapName, + }) }, }, ) diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 06eec220..b9e1a47d 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -56,15 +56,29 @@ export function useMeshPointsStyle() { throw new Error("Vertex attribute not set") } if (coloring.vertex.name) { - return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPointsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPointsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPointsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPointsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } return Promise.resolve() } else { @@ -143,7 +157,12 @@ export function useMeshPointsStyle() { const vertex = meshPointsStyle(id).coloring.vertex return vertex ? vertex.colorMap : null } - function setMeshPointsVertexAttributeColorMap(id, colorMapName, minimum, maximum) { + function setMeshPointsVertexAttributeColorMap( + id, + colorMapName, + minimum, + maximum, + ) { const coloring_style = meshPointsStyle(id).coloring let points = colorMapName if (typeof colorMapName === "string") { @@ -158,7 +177,10 @@ export function useMeshPointsStyle() { coloring_style.vertex = {} } coloring_style.vertex.colorMap = colorMapName - console.log(setMeshPointsVertexAttributeColorMap.name, { id, colorMapName }) + console.log(setMeshPointsVertexAttributeColorMap.name, { + id, + colorMapName, + }) }, }, ) diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 063dbe02..e8346b76 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -271,11 +271,26 @@ export function useMeshPolygonsStyle() { throw new Error("Vertex attribute not set") } if (coloring.vertex.name) { - return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolygonsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + return setMeshPolygonsVertexAttributeName( + id, + coloring.vertex.name, + ).then(() => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPolygonsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { if (coloring.vertex.colorMap) { - return setMeshPolygonsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + return setMeshPolygonsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) } }) } @@ -287,11 +302,26 @@ export function useMeshPolygonsStyle() { throw new Error("Polygon attribute not set") } if (coloring.polygon.name) { - return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name).then(() => { - if (coloring.polygon.minimum !== undefined && coloring.polygon.maximum !== undefined) { - return setMeshPolygonsPolygonAttributeRange(id, coloring.polygon.minimum, coloring.polygon.maximum).then(() => { + return setMeshPolygonsPolygonAttributeName( + id, + coloring.polygon.name, + ).then(() => { + if ( + coloring.polygon.minimum !== undefined && + coloring.polygon.maximum !== undefined + ) { + return setMeshPolygonsPolygonAttributeRange( + id, + coloring.polygon.minimum, + coloring.polygon.maximum, + ).then(() => { if (coloring.polygon.colorMap) { - return setMeshPolygonsPolygonAttributeColorMap(id, coloring.polygon.colorMap, coloring.polygon.minimum, coloring.polygon.maximum) + return setMeshPolygonsPolygonAttributeColorMap( + id, + coloring.polygon.colorMap, + coloring.polygon.minimum, + coloring.polygon.maximum, + ) } }) } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 438e913c..a55d482b 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -55,11 +55,26 @@ export function useMeshPolyhedraStyle() { throw new Error("Vertex attribute not set") } if (coloring.vertex.name) { - return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolyhedraVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + return setMeshPolyhedraVertexAttributeName( + id, + coloring.vertex.name, + ).then(() => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPolyhedraVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { if (coloring.vertex.colorMap) { - return setMeshPolyhedraVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + return setMeshPolyhedraVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) } }) } @@ -71,11 +86,26 @@ export function useMeshPolyhedraStyle() { throw new Error("Polyhedron attribute not set") } if (coloring.polyhedron.name) { - return setMeshPolyhedraPolyhedronAttributeName(id, coloring.polyhedron.name).then(() => { - if (coloring.polyhedron.minimum !== undefined && coloring.polyhedron.maximum !== undefined) { - return setMeshPolyhedraPolyhedronAttributeRange(id, coloring.polyhedron.minimum, coloring.polyhedron.maximum).then(() => { + return setMeshPolyhedraPolyhedronAttributeName( + id, + coloring.polyhedron.name, + ).then(() => { + if ( + coloring.polyhedron.minimum !== undefined && + coloring.polyhedron.maximum !== undefined + ) { + return setMeshPolyhedraPolyhedronAttributeRange( + id, + coloring.polyhedron.minimum, + coloring.polyhedron.maximum, + ).then(() => { if (coloring.polyhedron.colorMap) { - return setMeshPolyhedraPolyhedronAttributeColorMap(id, coloring.polyhedron.colorMap, coloring.polyhedron.minimum, coloring.polyhedron.maximum) + return setMeshPolyhedraPolyhedronAttributeColorMap( + id, + coloring.polyhedron.colorMap, + coloring.polyhedron.minimum, + coloring.polyhedron.maximum, + ) } }) } From 483be6bbeb3c0b5805ffc748cbca449133c30b3a Mon Sep 17 00:00:00 2001 From: SpliiT Date: Wed, 4 Feb 2026 14:02:06 +0100 Subject: [PATCH 29/41] fix comments --- .../Options/VertexAttributeSelector.vue | 2 +- app/utils/default_styles.js | 18 +++---- internal/stores/mesh/cells.js | 49 ++++++++----------- internal/stores/mesh/edges.js | 46 ++++++++--------- internal/stores/mesh/points.js | 23 ++++----- internal/stores/mesh/polygons.js | 46 ++++++++--------- internal/stores/mesh/polyhedra.js | 46 ++++++++--------- internal/stores/model/index.js | 2 - 8 files changed, 101 insertions(+), 131 deletions(-) diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index d2dced8f..d7af4267 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -11,7 +11,7 @@ const props = defineProps({ id: { type: String, required: true }, - meshType: { type: String, default: "polygons" }, + meshType: { type: String, required: true }, }) const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1) diff --git a/app/utils/default_styles.js b/app/utils/default_styles.js index 09942b26..94bb24da 100644 --- a/app/utils/default_styles.js +++ b/app/utils/default_styles.js @@ -32,7 +32,7 @@ const meshPointsDefaultStyle = ( coloring: { active: "color", color, - vertex: null, + vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, }, size, } @@ -48,8 +48,8 @@ const meshEdgesDefaultStyle = ( coloring: { active: "color", color, - edge: null, - vertex: null, + edge: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, }, width, } @@ -63,10 +63,10 @@ const meshCellsDefaultStyle = ( visibility, coloring: { active: "color", - cell: null, + cell: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, color, textures: null, - vertex: null, + vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, }, } } @@ -81,8 +81,8 @@ const meshPolygonsDefaultStyle = ( active: "color", color, textures: null, - polygon: null, - vertex: null, + polygon: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, }, } } @@ -96,8 +96,8 @@ const meshPolyhedraDefaultStyle = ( coloring: { active: "color", color, - polyhedron: null, - vertex: null, + polyhedron: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, }, } } diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 1945887d..55e7bb9a 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -155,8 +155,7 @@ export function useMeshCellsStyle() { return setMeshCellsCellAttributeName(id, cell_attribute.name) } function meshCellsCellAttributeName(id) { - const cell = meshCellsStyle(id).coloring.cell - return cell ? cell.name : "" + return meshCellsStyle(id).coloring.cell?.name ?? "" } function setMeshCellsCellAttributeName(id, name) { const coloring_style = meshCellsStyle(id).coloring @@ -239,37 +238,31 @@ export function useMeshCellsStyle() { } return setMeshCellsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex === null) { + if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - if (coloring.vertex.name) { - return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshCellsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshCellsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshCellsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshCellsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } else if (type === "cell") { - if (coloring.cell === null) { + if (coloring.cell.name === undefined) { throw new Error("Cell attribute not set") } - if (coloring.cell.name) { - return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { - if (coloring.cell.minimum !== undefined && coloring.cell.maximum !== undefined) { - return setMeshCellsCellAttributeRange(id, coloring.cell.minimum, coloring.cell.maximum).then(() => { - if (coloring.cell.colorMap) { - return setMeshCellsCellAttributeColorMap(id, coloring.cell.colorMap, coloring.cell.minimum, coloring.cell.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { + if (coloring.cell.minimum !== undefined && coloring.cell.maximum !== undefined) { + return setMeshCellsCellAttributeRange(id, coloring.cell.minimum, coloring.cell.maximum).then(() => { + if (coloring.cell.colorMap) { + return setMeshCellsCellAttributeColorMap(id, coloring.cell.colorMap, coloring.cell.minimum, coloring.cell.maximum) + } + }) + } + }) } else { throw new Error("Unknown mesh cells coloring type: " + type) } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 5dafb1c8..4ad182dc 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -51,37 +51,31 @@ export function useMeshEdgesStyle() { if (type === "color") { return setMeshEdgesColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex === null) { + if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - if (coloring.vertex.name) { - return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshEdgesVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshEdgesVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshEdgesVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshEdgesVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } else if (type === "edge") { - if (coloring.edge === null) { + if (coloring.edge.name === undefined) { throw new Error("Edge attribute not set") } - if (coloring.edge.name) { - return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { - if (coloring.edge.minimum !== undefined && coloring.edge.maximum !== undefined) { - return setMeshEdgesEdgeAttributeRange(id, coloring.edge.minimum, coloring.edge.maximum).then(() => { - if (coloring.edge.colorMap) { - return setMeshEdgesEdgeAttributeColorMap(id, coloring.edge.colorMap, coloring.edge.minimum, coloring.edge.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { + if (coloring.edge.minimum !== undefined && coloring.edge.maximum !== undefined) { + return setMeshEdgesEdgeAttributeRange(id, coloring.edge.minimum, coloring.edge.maximum).then(() => { + if (coloring.edge.colorMap) { + return setMeshEdgesEdgeAttributeColorMap(id, coloring.edge.colorMap, coloring.edge.minimum, coloring.edge.maximum) + } + }) + } + }) } else { throw new Error("Unknown mesh edges coloring type: " + type) } diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 06eec220..c7915a71 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -52,21 +52,18 @@ export function useMeshPointsStyle() { if (type === "color") { return setMeshPointsColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex === null) { + if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - if (coloring.vertex.name) { - return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPointsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPointsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPointsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPointsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } else { throw new Error("Unknown mesh points coloring type: " + type) } diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 063dbe02..7647a327 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -267,37 +267,31 @@ export function useMeshPolygonsStyle() { } return setMeshPolygonsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex === null) { + if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - if (coloring.vertex.name) { - return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolygonsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPolygonsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPolygonsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolygonsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } else if (type === "polygon") { - if (coloring.polygon === null) { + if (coloring.polygon.name === undefined) { throw new Error("Polygon attribute not set") } - if (coloring.polygon.name) { - return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name).then(() => { - if (coloring.polygon.minimum !== undefined && coloring.polygon.maximum !== undefined) { - return setMeshPolygonsPolygonAttributeRange(id, coloring.polygon.minimum, coloring.polygon.maximum).then(() => { - if (coloring.polygon.colorMap) { - return setMeshPolygonsPolygonAttributeColorMap(id, coloring.polygon.colorMap, coloring.polygon.minimum, coloring.polygon.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name).then(() => { + if (coloring.polygon.minimum !== undefined && coloring.polygon.maximum !== undefined) { + return setMeshPolygonsPolygonAttributeRange(id, coloring.polygon.minimum, coloring.polygon.maximum).then(() => { + if (coloring.polygon.colorMap) { + return setMeshPolygonsPolygonAttributeColorMap(id, coloring.polygon.colorMap, coloring.polygon.minimum, coloring.polygon.maximum) + } + }) + } + }) } else { throw new Error("Unknown mesh polygons coloring type: " + type) } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 438e913c..c4e7b10f 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -51,37 +51,31 @@ export function useMeshPolyhedraStyle() { if (type === "color") { return setMeshPolyhedraColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex === null) { + if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - if (coloring.vertex.name) { - return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolyhedraVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPolyhedraVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then(() => { + if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { + return setMeshPolyhedraVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolyhedraVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) + } + }) + } + }) } else if (type === "polyhedron") { - if (coloring.polyhedron === null) { + if (coloring.polyhedron.name === undefined) { throw new Error("Polyhedron attribute not set") } - if (coloring.polyhedron.name) { - return setMeshPolyhedraPolyhedronAttributeName(id, coloring.polyhedron.name).then(() => { - if (coloring.polyhedron.minimum !== undefined && coloring.polyhedron.maximum !== undefined) { - return setMeshPolyhedraPolyhedronAttributeRange(id, coloring.polyhedron.minimum, coloring.polyhedron.maximum).then(() => { - if (coloring.polyhedron.colorMap) { - return setMeshPolyhedraPolyhedronAttributeColorMap(id, coloring.polyhedron.colorMap, coloring.polyhedron.minimum, coloring.polyhedron.maximum) - } - }) - } - }) - } - return Promise.resolve() + return setMeshPolyhedraPolyhedronAttributeName(id, coloring.polyhedron.name).then(() => { + if (coloring.polyhedron.minimum !== undefined && coloring.polyhedron.maximum !== undefined) { + return setMeshPolyhedraPolyhedronAttributeRange(id, coloring.polyhedron.minimum, coloring.polyhedron.maximum).then(() => { + if (coloring.polyhedron.colorMap) { + return setMeshPolyhedraPolyhedronAttributeColorMap(id, coloring.polyhedron.colorMap, coloring.polyhedron.minimum, coloring.polyhedron.maximum) + } + }) + } + }) } else { throw new Error("Unknown mesh polyhedra coloring type: " + type) } diff --git a/internal/stores/model/index.js b/internal/stores/model/index.js index 665ad991..7d83cfa8 100644 --- a/internal/stores/model/index.js +++ b/internal/stores/model/index.js @@ -154,8 +154,6 @@ export default function useModelStyle() { promise_array.push(modelPointsStyleStore.applyModelPointsStyle(id)) } else if (key === "edges") { promise_array.push(modelEdgesStyleStore.applyModelEdgesStyle(id)) - } else if (key === "attributes") { - // Do nothing } else { throw new Error("Unknown model key: " + key) } From d3f925a944f5537ee6bd1ff66a10b7232b38005d Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Wed, 4 Feb 2026 13:04:43 +0000 Subject: [PATCH 30/41] Apply prepare changes --- app/utils/default_styles.js | 63 ++++++++++++++++++++++++++----- internal/stores/mesh/cells.js | 50 ++++++++++++++++++------ internal/stores/mesh/edges.js | 50 ++++++++++++++++++------ internal/stores/mesh/points.js | 32 +++++++++++----- internal/stores/mesh/polygons.js | 55 ++++++++++++++++++++------- internal/stores/mesh/polyhedra.js | 55 ++++++++++++++++++++------- 6 files changed, 237 insertions(+), 68 deletions(-) diff --git a/app/utils/default_styles.js b/app/utils/default_styles.js index 94bb24da..163f406d 100644 --- a/app/utils/default_styles.js +++ b/app/utils/default_styles.js @@ -32,7 +32,12 @@ const meshPointsDefaultStyle = ( coloring: { active: "color", color, - vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + vertex: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, }, size, } @@ -48,8 +53,18 @@ const meshEdgesDefaultStyle = ( coloring: { active: "color", color, - edge: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, - vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + edge: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, + vertex: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, }, width, } @@ -63,10 +78,20 @@ const meshCellsDefaultStyle = ( visibility, coloring: { active: "color", - cell: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + cell: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, color, textures: null, - vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + vertex: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, }, } } @@ -81,8 +106,18 @@ const meshPolygonsDefaultStyle = ( active: "color", color, textures: null, - polygon: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, - vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + polygon: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, + vertex: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, }, } } @@ -96,8 +131,18 @@ const meshPolyhedraDefaultStyle = ( coloring: { active: "color", color, - polyhedron: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, - vertex: { name: undefined, minimum: 0, maximum: 1, colorMap: "Cool to Warm" }, + polyhedron: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, + vertex: { + name: undefined, + minimum: 0, + maximum: 1, + colorMap: "Cool to Warm", + }, }, } } diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 9f356c9f..c9eeb762 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -257,24 +257,50 @@ export function useMeshCellsStyle() { if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshCellsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshCellsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshCellsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshCellsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } else if (type === "cell") { if (coloring.cell.name === undefined) { throw new Error("Cell attribute not set") } return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { - if (coloring.cell.minimum !== undefined && coloring.cell.maximum !== undefined) { - return setMeshCellsCellAttributeRange(id, coloring.cell.minimum, coloring.cell.maximum).then(() => { + if ( + coloring.cell.minimum !== undefined && + coloring.cell.maximum !== undefined + ) { + return setMeshCellsCellAttributeRange( + id, + coloring.cell.minimum, + coloring.cell.maximum, + ).then(() => { if (coloring.cell.colorMap) { - return setMeshCellsCellAttributeColorMap(id, coloring.cell.colorMap, coloring.cell.minimum, coloring.cell.maximum) + return setMeshCellsCellAttributeColorMap( + id, + coloring.cell.colorMap, + coloring.cell.minimum, + coloring.cell.maximum, + ) } }) } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 2edd7cda..3eb500a7 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -54,24 +54,50 @@ export function useMeshEdgesStyle() { if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshEdgesVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshEdgesVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshEdgesVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshEdgesVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } else if (type === "edge") { if (coloring.edge.name === undefined) { throw new Error("Edge attribute not set") } return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { - if (coloring.edge.minimum !== undefined && coloring.edge.maximum !== undefined) { - return setMeshEdgesEdgeAttributeRange(id, coloring.edge.minimum, coloring.edge.maximum).then(() => { + if ( + coloring.edge.minimum !== undefined && + coloring.edge.maximum !== undefined + ) { + return setMeshEdgesEdgeAttributeRange( + id, + coloring.edge.minimum, + coloring.edge.maximum, + ).then(() => { if (coloring.edge.colorMap) { - return setMeshEdgesEdgeAttributeColorMap(id, coloring.edge.colorMap, coloring.edge.minimum, coloring.edge.maximum) + return setMeshEdgesEdgeAttributeColorMap( + id, + coloring.edge.colorMap, + coloring.edge.minimum, + coloring.edge.maximum, + ) } }) } diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 25855acb..0b940321 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -55,15 +55,29 @@ export function useMeshPointsStyle() { if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPointsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPointsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPointsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPointsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } else { throw new Error("Unknown mesh points coloring type: " + type) } diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 7647a327..bcb65756 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -270,24 +270,53 @@ export function useMeshPolygonsStyle() { if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolygonsVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPolygonsVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPolygonsVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolygonsVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } else if (type === "polygon") { if (coloring.polygon.name === undefined) { throw new Error("Polygon attribute not set") } - return setMeshPolygonsPolygonAttributeName(id, coloring.polygon.name).then(() => { - if (coloring.polygon.minimum !== undefined && coloring.polygon.maximum !== undefined) { - return setMeshPolygonsPolygonAttributeRange(id, coloring.polygon.minimum, coloring.polygon.maximum).then(() => { + return setMeshPolygonsPolygonAttributeName( + id, + coloring.polygon.name, + ).then(() => { + if ( + coloring.polygon.minimum !== undefined && + coloring.polygon.maximum !== undefined + ) { + return setMeshPolygonsPolygonAttributeRange( + id, + coloring.polygon.minimum, + coloring.polygon.maximum, + ).then(() => { if (coloring.polygon.colorMap) { - return setMeshPolygonsPolygonAttributeColorMap(id, coloring.polygon.colorMap, coloring.polygon.minimum, coloring.polygon.maximum) + return setMeshPolygonsPolygonAttributeColorMap( + id, + coloring.polygon.colorMap, + coloring.polygon.minimum, + coloring.polygon.maximum, + ) } }) } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index c4e7b10f..c30e6024 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -54,24 +54,53 @@ export function useMeshPolyhedraStyle() { if (coloring.vertex.name === undefined) { throw new Error("Vertex attribute not set") } - return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then(() => { - if (coloring.vertex.minimum !== undefined && coloring.vertex.maximum !== undefined) { - return setMeshPolyhedraVertexAttributeRange(id, coloring.vertex.minimum, coloring.vertex.maximum).then(() => { - if (coloring.vertex.colorMap) { - return setMeshPolyhedraVertexAttributeColorMap(id, coloring.vertex.colorMap, coloring.vertex.minimum, coloring.vertex.maximum) - } - }) - } - }) + return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then( + () => { + if ( + coloring.vertex.minimum !== undefined && + coloring.vertex.maximum !== undefined + ) { + return setMeshPolyhedraVertexAttributeRange( + id, + coloring.vertex.minimum, + coloring.vertex.maximum, + ).then(() => { + if (coloring.vertex.colorMap) { + return setMeshPolyhedraVertexAttributeColorMap( + id, + coloring.vertex.colorMap, + coloring.vertex.minimum, + coloring.vertex.maximum, + ) + } + }) + } + }, + ) } else if (type === "polyhedron") { if (coloring.polyhedron.name === undefined) { throw new Error("Polyhedron attribute not set") } - return setMeshPolyhedraPolyhedronAttributeName(id, coloring.polyhedron.name).then(() => { - if (coloring.polyhedron.minimum !== undefined && coloring.polyhedron.maximum !== undefined) { - return setMeshPolyhedraPolyhedronAttributeRange(id, coloring.polyhedron.minimum, coloring.polyhedron.maximum).then(() => { + return setMeshPolyhedraPolyhedronAttributeName( + id, + coloring.polyhedron.name, + ).then(() => { + if ( + coloring.polyhedron.minimum !== undefined && + coloring.polyhedron.maximum !== undefined + ) { + return setMeshPolyhedraPolyhedronAttributeRange( + id, + coloring.polyhedron.minimum, + coloring.polyhedron.maximum, + ).then(() => { if (coloring.polyhedron.colorMap) { - return setMeshPolyhedraPolyhedronAttributeColorMap(id, coloring.polyhedron.colorMap, coloring.polyhedron.minimum, coloring.polyhedron.maximum) + return setMeshPolyhedraPolyhedronAttributeColorMap( + id, + coloring.polyhedron.colorMap, + coloring.polyhedron.minimum, + coloring.polyhedron.maximum, + ) } }) } From 1037dbb3ffcb70b2c601241405ba49265ceb7ad6 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Wed, 4 Feb 2026 16:01:16 +0100 Subject: [PATCH 31/41] rm throw --- .../Viewer/Options/CellAttributeSelector.vue | 18 +++- .../Viewer/Options/EdgeAttributeSelector.vue | 18 +++- .../Options/PolygonAttributeSelector.vue | 18 +++- .../Options/PolyhedronAttributeSelector.vue | 21 +++- .../Options/VertexAttributeSelector.vue | 14 ++- internal/stores/mesh/cells.js | 92 ++++++++++++++-- internal/stores/mesh/edges.js | 90 ++++++++++++++-- internal/stores/mesh/points.js | 50 ++++++++- internal/stores/mesh/polygons.js | 100 ++++++++++++++++-- internal/stores/mesh/polyhedra.js | 98 +++++++++++++++-- .../stores/data_style/mesh/cells.nuxt.test.js | 8 +- .../stores/data_style/mesh/edges.nuxt.test.js | 8 +- .../data_style/mesh/points.nuxt.test.js | 8 +- .../data_style/mesh/polygons.nuxt.test.js | 8 +- .../data_style/mesh/polyhedra.nuxt.test.js | 8 +- 15 files changed, 477 insertions(+), 82 deletions(-) diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index 6eaa49b9..e153e979 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -23,12 +23,26 @@ get: () => storeCellAttribute.value?.name || "", set: (newName) => { if (newName) { - dataStyleStore.setMeshCellsCellAttributeName(props.id, newName) const attribute = cell_attribute_names.value.find( (attr) => attr.attribute_name === newName, ) if (attribute) { - onScalarRangeChange(attribute.min_value, attribute.max_value) + dataStyleStore + .setMeshCellsCellAttributeName( + props.id, + newName, + attribute.min_value, + attribute.max_value, + ) + .then(() => { + hybridViewerStore.remoteRender() + }) + } else { + dataStyleStore + .setMeshCellsCellAttributeName(props.id, newName) + .then(() => { + hybridViewerStore.remoteRender() + }) } } }, diff --git a/app/components/Viewer/Options/EdgeAttributeSelector.vue b/app/components/Viewer/Options/EdgeAttributeSelector.vue index 31ea5aab..ef885d77 100644 --- a/app/components/Viewer/Options/EdgeAttributeSelector.vue +++ b/app/components/Viewer/Options/EdgeAttributeSelector.vue @@ -23,12 +23,26 @@ get: () => storeEdgeAttribute.value?.name || "", set: (newName) => { if (newName) { - dataStyleStore.setMeshEdgesEdgeAttributeName(props.id, newName) const attribute = edge_attribute_names.value.find( (attr) => attr.attribute_name === newName, ) if (attribute) { - onScalarRangeChange(attribute.min_value, attribute.max_value) + dataStyleStore + .setMeshEdgesEdgeAttributeName( + props.id, + newName, + attribute.min_value, + attribute.max_value, + ) + .then(() => { + hybridViewerStore.remoteRender() + }) + } else { + dataStyleStore + .setMeshEdgesEdgeAttributeName(props.id, newName) + .then(() => { + hybridViewerStore.remoteRender() + }) } } }, diff --git a/app/components/Viewer/Options/PolygonAttributeSelector.vue b/app/components/Viewer/Options/PolygonAttributeSelector.vue index e425d4b6..2351f2f4 100644 --- a/app/components/Viewer/Options/PolygonAttributeSelector.vue +++ b/app/components/Viewer/Options/PolygonAttributeSelector.vue @@ -23,12 +23,26 @@ get: () => storePolygonAttribute.value?.name || "", set: (newName) => { if (newName) { - dataStyleStore.setMeshPolygonsPolygonAttributeName(props.id, newName) const attribute = polygon_attribute_names.value.find( (attr) => attr.attribute_name === newName, ) if (attribute) { - onScalarRangeChange(attribute.min_value, attribute.max_value) + dataStyleStore + .setMeshPolygonsPolygonAttributeName( + props.id, + newName, + attribute.min_value, + attribute.max_value, + ) + .then(() => { + hybridViewerStore.remoteRender() + }) + } else { + dataStyleStore + .setMeshPolygonsPolygonAttributeName(props.id, newName) + .then(() => { + hybridViewerStore.remoteRender() + }) } } }, diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index 937c42da..6ab89dbf 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -23,15 +23,26 @@ get: () => storePolyhedronAttribute.value?.name || "", set: (newName) => { if (newName) { - dataStyleStore.setMeshPolyhedraPolyhedronAttributeName( - props.id, - newName, - ) const attribute = polyhedron_attribute_names.value.find( (attr) => attr.attribute_name === newName, ) if (attribute) { - onScalarRangeChange(attribute.min_value, attribute.max_value) + dataStyleStore + .setMeshPolyhedraPolyhedronAttributeName( + props.id, + newName, + attribute.min_value, + attribute.max_value, + ) + .then(() => { + hybridViewerStore.remoteRender() + }) + } else { + dataStyleStore + .setMeshPolyhedraPolyhedronAttributeName(props.id, newName) + .then(() => { + hybridViewerStore.remoteRender() + }) } } }, diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index d7af4267..952a15c6 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -28,12 +28,22 @@ set: (newName) => { if (newName) { const methodName = `setMesh${capitalize(props.meshType)}VertexAttributeName` - dataStyleStore[methodName](props.id, newName) const attribute = vertex_attribute_names.value.find( (attr) => attr.attribute_name === newName, ) if (attribute) { - onScalarRangeChange(attribute.min_value, attribute.max_value) + dataStyleStore[methodName]( + props.id, + newName, + attribute.min_value, + attribute.max_value, + ).then(() => { + hybridViewerStore.remoteRender() + }) + } else { + dataStyleStore[methodName](props.id, newName).then(() => { + hybridViewerStore.remoteRender() + }) } } }, diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index c9eeb762..97fe45e2 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -86,7 +86,7 @@ export function useMeshCellsStyle() { const vertex = meshCellsStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshCellsVertexAttributeName(id, name) { + function setMeshCellsVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshCellsStyle(id).coloring return viewerStore.request( mesh_cells_schemas.attribute.vertex.name, @@ -96,7 +96,45 @@ export function useMeshCellsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } + const previousName = coloring_style.vertex.name + if (previousName) { + if (!coloring_style.vertex.attributes) { + coloring_style.vertex.attributes = {} + } + coloring_style.vertex.attributes[previousName] = { + minimum: coloring_style.vertex.minimum, + maximum: coloring_style.vertex.maximum, + colorMap: coloring_style.vertex.colorMap, + } + } + coloring_style.vertex.name = name + + if ( + coloring_style.vertex.attributes && + coloring_style.vertex.attributes[name] + ) { + const saved = coloring_style.vertex.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshCellsVertexAttributeRange(id, saved.minimum, saved.maximum) + if (saved.colorMap) { + setMeshCellsVertexAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshCellsVertexAttributeRange(id, defaultMin, defaultMax) + setMeshCellsVertexAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshCellsVertexAttributeName.name, { id }, name) }, }, @@ -165,7 +203,7 @@ export function useMeshCellsStyle() { function meshCellsCellAttributeName(id) { return meshCellsStyle(id).coloring.cell?.name ?? "" } - function setMeshCellsCellAttributeName(id, name) { + function setMeshCellsCellAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshCellsStyle(id).coloring return viewerStore.request( mesh_cells_schemas.attribute.cell.name, @@ -175,7 +213,45 @@ export function useMeshCellsStyle() { if (!coloring_style.cell) { coloring_style.cell = {} } + const previousName = coloring_style.cell.name + if (previousName) { + if (!coloring_style.cell.attributes) { + coloring_style.cell.attributes = {} + } + coloring_style.cell.attributes[previousName] = { + minimum: coloring_style.cell.minimum, + maximum: coloring_style.cell.maximum, + colorMap: coloring_style.cell.colorMap, + } + } + coloring_style.cell.name = name + + if ( + coloring_style.cell.attributes && + coloring_style.cell.attributes[name] + ) { + const saved = coloring_style.cell.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshCellsCellAttributeRange(id, saved.minimum, saved.maximum) + if (saved.colorMap) { + setMeshCellsCellAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshCellsCellAttributeRange(id, defaultMin, defaultMax) + setMeshCellsCellAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshCellsCellAttributeName.name, { id }, name) }, }, @@ -250,12 +326,12 @@ export function useMeshCellsStyle() { return setMeshCellsColor(id, coloring.color) } else if (type === "textures") { if (coloring.textures === null) { - throw new Error("Textures not set") + return Promise.resolve() } return setMeshCellsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex.name === undefined) { - throw new Error("Vertex attribute not set") + if (coloring.vertex?.name === undefined) { + return Promise.resolve() } return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then( () => { @@ -281,8 +357,8 @@ export function useMeshCellsStyle() { }, ) } else if (type === "cell") { - if (coloring.cell.name === undefined) { - throw new Error("Cell attribute not set") + if (coloring.cell?.name === undefined) { + return Promise.resolve() } return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { if ( @@ -306,7 +382,7 @@ export function useMeshCellsStyle() { } }) } else { - throw new Error("Unknown mesh cells coloring type: " + type) + return Promise.resolve() } } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 3eb500a7..34279a72 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -51,8 +51,8 @@ export function useMeshEdgesStyle() { if (type === "color") { return setMeshEdgesColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex.name === undefined) { - throw new Error("Vertex attribute not set") + if (coloring.vertex?.name === undefined) { + return Promise.resolve() } return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then( () => { @@ -78,8 +78,8 @@ export function useMeshEdgesStyle() { }, ) } else if (type === "edge") { - if (coloring.edge.name === undefined) { - throw new Error("Edge attribute not set") + if (coloring.edge?.name === undefined) { + return Promise.resolve() } return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { if ( @@ -103,7 +103,7 @@ export function useMeshEdgesStyle() { } }) } else { - throw new Error("Unknown mesh edges coloring type: " + type) + return Promise.resolve() } } @@ -155,7 +155,7 @@ export function useMeshEdgesStyle() { const vertex = meshEdgesStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshEdgesVertexAttributeName(id, name) { + function setMeshEdgesVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshEdgesStyle(id).coloring return viewerStore.request( mesh_edges_schemas.attribute.vertex.name, @@ -165,7 +165,45 @@ export function useMeshEdgesStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } + const previousName = coloring_style.vertex.name + if (previousName) { + if (!coloring_style.vertex.attributes) { + coloring_style.vertex.attributes = {} + } + coloring_style.vertex.attributes[previousName] = { + minimum: coloring_style.vertex.minimum, + maximum: coloring_style.vertex.maximum, + colorMap: coloring_style.vertex.colorMap, + } + } + coloring_style.vertex.name = name + + if ( + coloring_style.vertex.attributes && + coloring_style.vertex.attributes[name] + ) { + const saved = coloring_style.vertex.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshEdgesVertexAttributeRange(id, saved.minimum, saved.maximum) + if (saved.colorMap) { + setMeshEdgesVertexAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshEdgesVertexAttributeRange(id, defaultMin, defaultMax) + setMeshEdgesVertexAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshEdgesVertexAttributeName.name, { id }, name) }, }, @@ -235,7 +273,7 @@ export function useMeshEdgesStyle() { const edge = meshEdgesStyle(id).coloring.edge return edge ? edge.name : "" } - function setMeshEdgesEdgeAttributeName(id, name) { + function setMeshEdgesEdgeAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshEdgesStyle(id).coloring return viewerStore.request( mesh_edges_schemas.attribute.edge.name, @@ -245,7 +283,45 @@ export function useMeshEdgesStyle() { if (!coloring_style.edge) { coloring_style.edge = {} } + const previousName = coloring_style.edge.name + if (previousName) { + if (!coloring_style.edge.attributes) { + coloring_style.edge.attributes = {} + } + coloring_style.edge.attributes[previousName] = { + minimum: coloring_style.edge.minimum, + maximum: coloring_style.edge.maximum, + colorMap: coloring_style.edge.colorMap, + } + } + coloring_style.edge.name = name + + if ( + coloring_style.edge.attributes && + coloring_style.edge.attributes[name] + ) { + const saved = coloring_style.edge.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshEdgesEdgeAttributeRange(id, saved.minimum, saved.maximum) + if (saved.colorMap) { + setMeshEdgesEdgeAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshEdgesEdgeAttributeRange(id, defaultMin, defaultMax) + setMeshEdgesEdgeAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshEdgesEdgeAttributeName.name, { id }, name) }, }, diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 0b940321..e43eb012 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -52,8 +52,8 @@ export function useMeshPointsStyle() { if (type === "color") { return setMeshPointsColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex.name === undefined) { - throw new Error("Vertex attribute not set") + if (coloring.vertex?.name === undefined) { + return Promise.resolve() } return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then( () => { @@ -79,7 +79,7 @@ export function useMeshPointsStyle() { }, ) } else { - throw new Error("Unknown mesh points coloring type: " + type) + return Promise.resolve() } } @@ -113,7 +113,7 @@ export function useMeshPointsStyle() { const vertex = meshPointsStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshPointsVertexAttributeName(id, name) { + function setMeshPointsVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPointsStyle(id).coloring return viewerStore.request( mesh_points_schemas.attribute.vertex.name, @@ -123,7 +123,49 @@ export function useMeshPointsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } + const previousName = coloring_style.vertex.name + if (previousName) { + if (!coloring_style.vertex.attributes) { + coloring_style.vertex.attributes = {} + } + coloring_style.vertex.attributes[previousName] = { + minimum: coloring_style.vertex.minimum, + maximum: coloring_style.vertex.maximum, + colorMap: coloring_style.vertex.colorMap, + } + } + coloring_style.vertex.name = name + + if ( + coloring_style.vertex.attributes && + coloring_style.vertex.attributes[name] + ) { + const saved = coloring_style.vertex.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshPointsVertexAttributeRange( + id, + saved.minimum, + saved.maximum, + ) + if (saved.colorMap) { + setMeshPointsVertexAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshPointsVertexAttributeRange(id, defaultMin, defaultMax) + setMeshPointsVertexAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshPointsVertexAttributeName.name, { id }, name) }, }, diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index bcb65756..f3a00203 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -90,7 +90,7 @@ export function useMeshPolygonsStyle() { const vertex = meshPolygonsStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshPolygonsVertexAttributeName(id, name) { + function setMeshPolygonsVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.vertex.name, @@ -100,7 +100,49 @@ export function useMeshPolygonsStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } + const previousName = coloring_style.vertex.name + if (previousName) { + if (!coloring_style.vertex.attributes) { + coloring_style.vertex.attributes = {} + } + coloring_style.vertex.attributes[previousName] = { + minimum: coloring_style.vertex.minimum, + maximum: coloring_style.vertex.maximum, + colorMap: coloring_style.vertex.colorMap, + } + } + coloring_style.vertex.name = name + + if ( + coloring_style.vertex.attributes && + coloring_style.vertex.attributes[name] + ) { + const saved = coloring_style.vertex.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshPolygonsVertexAttributeRange( + id, + saved.minimum, + saved.maximum, + ) + if (saved.colorMap) { + setMeshPolygonsVertexAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshPolygonsVertexAttributeRange(id, defaultMin, defaultMax) + setMeshPolygonsVertexAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshPolygonsVertexAttributeName.name, { id }, name) }, }, @@ -174,7 +216,7 @@ export function useMeshPolygonsStyle() { const polygon = meshPolygonsStyle(id).coloring.polygon return polygon ? polygon.name : "" } - function setMeshPolygonsPolygonAttributeName(id, name) { + function setMeshPolygonsPolygonAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.polygon.name, @@ -184,7 +226,49 @@ export function useMeshPolygonsStyle() { if (!coloring_style.polygon) { coloring_style.polygon = {} } + const previousName = coloring_style.polygon.name + if (previousName) { + if (!coloring_style.polygon.attributes) { + coloring_style.polygon.attributes = {} + } + coloring_style.polygon.attributes[previousName] = { + minimum: coloring_style.polygon.minimum, + maximum: coloring_style.polygon.maximum, + colorMap: coloring_style.polygon.colorMap, + } + } + coloring_style.polygon.name = name + + if ( + coloring_style.polygon.attributes && + coloring_style.polygon.attributes[name] + ) { + const saved = coloring_style.polygon.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshPolygonsPolygonAttributeRange( + id, + saved.minimum, + saved.maximum, + ) + if (saved.colorMap) { + setMeshPolygonsPolygonAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshPolygonsPolygonAttributeRange(id, defaultMin, defaultMax) + setMeshPolygonsPolygonAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshPolygonsPolygonAttributeName.name, { id }, name) }, }, @@ -263,12 +347,12 @@ export function useMeshPolygonsStyle() { return setMeshPolygonsColor(id, coloring.color) } else if (type === "textures") { if (coloring.textures === null) { - throw new Error("Textures not set") + return Promise.resolve() } return setMeshPolygonsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex.name === undefined) { - throw new Error("Vertex attribute not set") + if (coloring.vertex?.name === undefined) { + return Promise.resolve() } return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then( () => { @@ -294,8 +378,8 @@ export function useMeshPolygonsStyle() { }, ) } else if (type === "polygon") { - if (coloring.polygon.name === undefined) { - throw new Error("Polygon attribute not set") + if (coloring.polygon?.name === undefined) { + return Promise.resolve() } return setMeshPolygonsPolygonAttributeName( id, @@ -322,7 +406,7 @@ export function useMeshPolygonsStyle() { } }) } else { - throw new Error("Unknown mesh polygons coloring type: " + type) + return Promise.resolve() } } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index c30e6024..8c76f14a 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -51,8 +51,8 @@ export function useMeshPolyhedraStyle() { if (type === "color") { return setMeshPolyhedraColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex.name === undefined) { - throw new Error("Vertex attribute not set") + if (coloring.vertex?.name === undefined) { + return Promise.resolve() } return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then( () => { @@ -78,8 +78,8 @@ export function useMeshPolyhedraStyle() { }, ) } else if (type === "polyhedron") { - if (coloring.polyhedron.name === undefined) { - throw new Error("Polyhedron attribute not set") + if (coloring.polyhedron?.name === undefined) { + return Promise.resolve() } return setMeshPolyhedraPolyhedronAttributeName( id, @@ -106,7 +106,7 @@ export function useMeshPolyhedraStyle() { } }) } else { - throw new Error("Unknown mesh polyhedra coloring type: " + type) + return Promise.resolve() } } @@ -141,7 +141,7 @@ export function useMeshPolyhedraStyle() { const vertex = meshPolyhedraStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshPolyhedraVertexAttributeName(id, name) { + function setMeshPolyhedraVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.vertex.name, @@ -151,7 +151,49 @@ export function useMeshPolyhedraStyle() { if (!coloring_style.vertex) { coloring_style.vertex = {} } + const previousName = coloring_style.vertex.name + if (previousName) { + if (!coloring_style.vertex.attributes) { + coloring_style.vertex.attributes = {} + } + coloring_style.vertex.attributes[previousName] = { + minimum: coloring_style.vertex.minimum, + maximum: coloring_style.vertex.maximum, + colorMap: coloring_style.vertex.colorMap, + } + } + coloring_style.vertex.name = name + + if ( + coloring_style.vertex.attributes && + coloring_style.vertex.attributes[name] + ) { + const saved = coloring_style.vertex.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshPolyhedraVertexAttributeRange( + id, + saved.minimum, + saved.maximum, + ) + if (saved.colorMap) { + setMeshPolyhedraVertexAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshPolyhedraVertexAttributeRange(id, defaultMin, defaultMax) + setMeshPolyhedraVertexAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log(setMeshPolyhedraVertexAttributeName.name, { id }, name) }, }, @@ -228,7 +270,7 @@ export function useMeshPolyhedraStyle() { const polyhedron = meshPolyhedraStyle(id).coloring.polyhedron return polyhedron ? polyhedron.name : "" } - function setMeshPolyhedraPolyhedronAttributeName(id, name) { + function setMeshPolyhedraPolyhedronAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.polyhedron.name, @@ -238,7 +280,49 @@ export function useMeshPolyhedraStyle() { if (!coloring_style.polyhedron) { coloring_style.polyhedron = {} } + const previousName = coloring_style.polyhedron.name + if (previousName) { + if (!coloring_style.polyhedron.attributes) { + coloring_style.polyhedron.attributes = {} + } + coloring_style.polyhedron.attributes[previousName] = { + minimum: coloring_style.polyhedron.minimum, + maximum: coloring_style.polyhedron.maximum, + colorMap: coloring_style.polyhedron.colorMap, + } + } + coloring_style.polyhedron.name = name + + if ( + coloring_style.polyhedron.attributes && + coloring_style.polyhedron.attributes[name] + ) { + const saved = coloring_style.polyhedron.attributes[name] + if (saved.minimum !== undefined && saved.maximum !== undefined) { + setMeshPolyhedraPolyhedronAttributeRange( + id, + saved.minimum, + saved.maximum, + ) + if (saved.colorMap) { + setMeshPolyhedraPolyhedronAttributeColorMap( + id, + saved.colorMap, + saved.minimum, + saved.maximum, + ) + } + } + } else if (defaultMin !== undefined && defaultMax !== undefined) { + setMeshPolyhedraPolyhedronAttributeRange(id, defaultMin, defaultMax) + setMeshPolyhedraPolyhedronAttributeColorMap( + id, + "Cool to Warm", + defaultMin, + defaultMax, + ) + } console.log( setMeshPolyhedraPolyhedronAttributeName.name, { id }, diff --git a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js index c9dadb6b..2d0bddf9 100644 --- a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js @@ -23,7 +23,7 @@ const cell_attribute = { name: "RGB_data" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) @@ -151,12 +151,6 @@ describe("Mesh cells", () => { ] for (let i = 0; i < coloringTypes.length; i++) { if (coloringTypes[i].function) { - expect(() => - dataStyleStore.setMeshCellsActiveColoring( - id, - coloringTypes[i].name, - ), - ).toThrowError() await coloringTypes[i].function() } const result = dataStyleStore.setMeshCellsActiveColoring( diff --git a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js index 64cea744..63215379 100644 --- a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js @@ -23,7 +23,7 @@ const edge_attribute = { name: "edge_attribute" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 25000) @@ -134,12 +134,6 @@ describe("Mesh edges", () => { ] for (let i = 0; i < coloringTypes.length; i++) { if (coloringTypes[i].function) { - expect(() => - dataStyleStore.setMeshEdgesActiveColoring( - id, - coloringTypes[i].name, - ), - ).toThrowError() await coloringTypes[i].function() } const result = dataStyleStore.setMeshEdgesActiveColoring( diff --git a/tests/integration/stores/data_style/mesh/points.nuxt.test.js b/tests/integration/stores/data_style/mesh/points.nuxt.test.js index f48e857a..d95f2f94 100644 --- a/tests/integration/stores/data_style/mesh/points.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/points.nuxt.test.js @@ -22,7 +22,7 @@ const vertex_attribute = { name: "points" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) @@ -94,12 +94,6 @@ describe("Mesh points", () => { ] for (let i = 0; i < coloringTypes.length; i++) { if (coloringTypes[i].function) { - expect(() => - dataStyleStore.setMeshPointsActiveColoring( - id, - coloringTypes[i].name, - ), - ).toThrowError() await coloringTypes[i].function() } const result = dataStyleStore.setMeshPointsActiveColoring( diff --git a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js index a7408b95..2073fe88 100644 --- a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js @@ -23,7 +23,7 @@ const polygon_attribute = { name: "test_attribute" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) @@ -155,12 +155,6 @@ describe("Mesh polygons", () => { for (let i = 0; i < coloringTypes.length; i++) { if (coloringTypes[i].function) { - expect(() => - dataStyleStore.setMeshPolygonsActiveColoring( - id, - coloringTypes[i].name, - ), - ).toThrowError() await coloringTypes[i].function() } const result = dataStyleStore.setMeshPolygonsActiveColoring( diff --git a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js index ed3ba99f..436e1b5b 100644 --- a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js @@ -23,7 +23,7 @@ const polyhedron_attribute = { name: "toto_on_polyhedra" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) @@ -102,12 +102,6 @@ describe("Mesh polyhedra", () => { ] for (let i = 0; i < coloringTypes.length; i++) { if (coloringTypes[i].function) { - expect(() => - dataStyleStore.setMeshPolyhedraActiveColoring( - id, - coloringTypes[i].name, - ), - ).toThrowError() await coloringTypes[i].function() } const result = dataStyleStore.setMeshPolyhedraActiveColoring( From 1861a0b7ad49c7f67285a7b6a892dc00f0a70690 Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Wed, 4 Feb 2026 15:02:39 +0000 Subject: [PATCH 32/41] Apply prepare changes --- internal/stores/mesh/polygons.js | 14 ++++++++++++-- internal/stores/mesh/polyhedra.js | 14 ++++++++++++-- .../stores/data_style/mesh/cells.nuxt.test.js | 2 +- .../stores/data_style/mesh/edges.nuxt.test.js | 2 +- .../stores/data_style/mesh/points.nuxt.test.js | 2 +- .../stores/data_style/mesh/polygons.nuxt.test.js | 2 +- .../stores/data_style/mesh/polyhedra.nuxt.test.js | 2 +- 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index f3a00203..e01a32dc 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -90,7 +90,12 @@ export function useMeshPolygonsStyle() { const vertex = meshPolygonsStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshPolygonsVertexAttributeName(id, name, defaultMin, defaultMax) { + function setMeshPolygonsVertexAttributeName( + id, + name, + defaultMin, + defaultMax, + ) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.vertex.name, @@ -216,7 +221,12 @@ export function useMeshPolygonsStyle() { const polygon = meshPolygonsStyle(id).coloring.polygon return polygon ? polygon.name : "" } - function setMeshPolygonsPolygonAttributeName(id, name, defaultMin, defaultMax) { + function setMeshPolygonsPolygonAttributeName( + id, + name, + defaultMin, + defaultMax, + ) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.polygon.name, diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 8c76f14a..9a175241 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -141,7 +141,12 @@ export function useMeshPolyhedraStyle() { const vertex = meshPolyhedraStyle(id).coloring.vertex return vertex ? vertex.name : "" } - function setMeshPolyhedraVertexAttributeName(id, name, defaultMin, defaultMax) { + function setMeshPolyhedraVertexAttributeName( + id, + name, + defaultMin, + defaultMax, + ) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.vertex.name, @@ -270,7 +275,12 @@ export function useMeshPolyhedraStyle() { const polyhedron = meshPolyhedraStyle(id).coloring.polyhedron return polyhedron ? polyhedron.name : "" } - function setMeshPolyhedraPolyhedronAttributeName(id, name, defaultMin, defaultMax) { + function setMeshPolyhedraPolyhedronAttributeName( + id, + name, + defaultMin, + defaultMax, + ) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.polyhedron.name, diff --git a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js index 2d0bddf9..1bc372bb 100644 --- a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js @@ -23,7 +23,7 @@ const cell_attribute = { name: "RGB_data" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) diff --git a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js index 63215379..cbcd28d8 100644 --- a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js @@ -23,7 +23,7 @@ const edge_attribute = { name: "edge_attribute" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 25000) diff --git a/tests/integration/stores/data_style/mesh/points.nuxt.test.js b/tests/integration/stores/data_style/mesh/points.nuxt.test.js index d95f2f94..c901104d 100644 --- a/tests/integration/stores/data_style/mesh/points.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/points.nuxt.test.js @@ -22,7 +22,7 @@ const vertex_attribute = { name: "points" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) diff --git a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js index 2073fe88..d6e50ded 100644 --- a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js @@ -23,7 +23,7 @@ const polygon_attribute = { name: "test_attribute" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) diff --git a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js index 436e1b5b..a08d638d 100644 --- a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js @@ -23,7 +23,7 @@ const polyhedron_attribute = { name: "toto_on_polyhedra" } let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) From 61cefeb5780925fc88446bf738676cc0b42358be Mon Sep 17 00:00:00 2001 From: SpliiT Date: Wed, 4 Feb 2026 17:36:18 +0100 Subject: [PATCH 33/41] tests integration --- .../integration/stores/data_style/mesh/cells.nuxt.test.js | 8 ++++---- .../integration/stores/data_style/mesh/edges.nuxt.test.js | 8 ++++---- .../integration/stores/data_style/mesh/index.nuxt.test.js | 4 ++-- .../stores/data_style/mesh/points.nuxt.test.js | 8 +++++--- .../stores/data_style/mesh/polygons.nuxt.test.js | 8 ++++---- .../stores/data_style/mesh/polyhedra.nuxt.test.js | 8 ++++---- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js index 2d0bddf9..89e96fad 100644 --- a/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/cells.nuxt.test.js @@ -94,13 +94,13 @@ describe("Mesh cells", () => { expect(result).toBeInstanceOf(Promise) await result expect(spy).toHaveBeenCalledWith( - mesh_cells_schemas.vertex_attribute, + mesh_cells_schemas.attribute.vertex.name, { id, ...vertex_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshCellsVertexAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshCellsVertexAttribute(id)).toMatchObject( vertex_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) @@ -119,13 +119,13 @@ describe("Mesh cells", () => { expect(result).toBeInstanceOf(Promise) await result expect(spy).toHaveBeenCalledWith( - mesh_cells_schemas.cell_attribute, + mesh_cells_schemas.attribute.cell.name, { id, ...cell_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshCellsCellAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshCellsCellAttribute(id)).toMatchObject( cell_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) diff --git a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js index 63215379..1c1a45aa 100644 --- a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js @@ -85,13 +85,13 @@ describe("Mesh edges", () => { const spy = vi.spyOn(viewerStore, "request") await dataStyleStore.setMeshEdgesVertexAttribute(id, vertex_attribute) expect(spy).toHaveBeenCalledWith( - mesh_edges_schemas.vertex_attribute, + mesh_edges_schemas.attribute.vertex.name, { id, ...vertex_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshEdgesVertexAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshEdgesVertexAttribute(id)).toMatchObject( vertex_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) @@ -104,13 +104,13 @@ describe("Mesh edges", () => { const spy = vi.spyOn(viewerStore, "request") await dataStyleStore.setMeshEdgesEdgeAttribute(id, edge_attribute) expect(spy).toHaveBeenCalledWith( - mesh_edges_schemas.edge_attribute, + mesh_edges_schemas.attribute.edge.name, { id, ...edge_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshEdgesEdgeAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshEdgesEdgeAttribute(id)).toMatchObject( edge_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) diff --git a/tests/integration/stores/data_style/mesh/index.nuxt.test.js b/tests/integration/stores/data_style/mesh/index.nuxt.test.js index ec310500..e6b64e13 100644 --- a/tests/integration/stores/data_style/mesh/index.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/index.nuxt.test.js @@ -21,7 +21,7 @@ const geode_object = "RegularGrid3D" let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ;({ id, back_port, viewer_port, project_folder_path } = + ; ({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) @@ -59,7 +59,7 @@ describe("Mesh", () => { }) describe("Apply mesh default style", () => { - test("test", async () => { + test("Apply mesh default style", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const result = dataStyleStore.applyMeshStyle(id) diff --git a/tests/integration/stores/data_style/mesh/points.nuxt.test.js b/tests/integration/stores/data_style/mesh/points.nuxt.test.js index d95f2f94..f8ac5660 100644 --- a/tests/integration/stores/data_style/mesh/points.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/points.nuxt.test.js @@ -129,21 +129,23 @@ describe("Mesh points", () => { expect(dataStyleStore.meshPointsSize(id)).toBe(size) expect(viewerStore.status).toBe(Status.CONNECTED) }) + }) - test("Points vertex attribute", async () => { + describe("Points vertex attribute", () => { + test("test coloring", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const spy = vi.spyOn(viewerStore, "request") await dataStyleStore.setMeshPointsVertexAttribute(id, vertex_attribute) expect(spy).toHaveBeenCalledWith( - mesh_points_schemas.vertex_attribute, + mesh_points_schemas.attribute.vertex.name, { id, ...vertex_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPointsVertexAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshPointsVertexAttribute(id)).toMatchObject( vertex_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) diff --git a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js index 2073fe88..023f11e6 100644 --- a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js @@ -94,13 +94,13 @@ describe("Mesh polygons", () => { expect(result).toBeInstanceOf(Promise) await result expect(spy).toHaveBeenCalledWith( - mesh_polygons_schemas.vertex_attribute, + mesh_polygons_schemas.attribute.vertex.name, { id, ...vertex_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPolygonsVertexAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshPolygonsVertexAttribute(id)).toMatchObject( vertex_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) @@ -119,13 +119,13 @@ describe("Mesh polygons", () => { expect(result).toBeInstanceOf(Promise) await result expect(spy).toHaveBeenCalledWith( - mesh_polygons_schemas.polygon_attribute, + mesh_polygons_schemas.attribute.polygon.name, { id, ...polygon_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPolygonsPolygonAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshPolygonsPolygonAttribute(id)).toMatchObject( polygon_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) diff --git a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js index 436e1b5b..fd923327 100644 --- a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js @@ -125,13 +125,13 @@ describe("Mesh polyhedra", () => { const spy = vi.spyOn(viewerStore, "request") await dataStyleStore.setMeshPolyhedraVertexAttribute(id, vertex_attribute) expect(spy).toHaveBeenCalledWith( - mesh_polyhedra_schemas.vertex_attribute, + mesh_polyhedra_schemas.attribute.vertex.name, { id, ...vertex_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPolyhedraVertexAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshPolyhedraVertexAttribute(id)).toMatchObject( vertex_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) @@ -147,13 +147,13 @@ describe("Mesh polyhedra", () => { polyhedron_attribute, ) expect(spy).toHaveBeenCalledWith( - mesh_polyhedra_schemas.polyhedron_attribute, + mesh_polyhedra_schemas.attribute.polyhedron.name, { id, ...polyhedron_attribute }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPolyhedraPolyhedronAttribute(id)).toStrictEqual( + expect(dataStyleStore.meshPolyhedraPolyhedronAttribute(id)).toMatchObject( polyhedron_attribute, ) expect(viewerStore.status).toBe(Status.CONNECTED) From 6f4013168d6531b675b60aa2cece75a161e2d592 Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:38:24 +0000 Subject: [PATCH 34/41] Apply prepare changes --- tests/integration/stores/data_style/mesh/index.nuxt.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/stores/data_style/mesh/index.nuxt.test.js b/tests/integration/stores/data_style/mesh/index.nuxt.test.js index e6b64e13..f2c9dc52 100644 --- a/tests/integration/stores/data_style/mesh/index.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/index.nuxt.test.js @@ -21,7 +21,7 @@ const geode_object = "RegularGrid3D" let id, back_port, viewer_port, project_folder_path beforeEach(async () => { - ; ({ id, back_port, viewer_port, project_folder_path } = + ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) }, 20000) From 5dac6233e56efb2b098576486c2474ed507f1ca6 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Wed, 4 Feb 2026 17:45:07 +0100 Subject: [PATCH 35/41] remove useless models --- app/components/Viewer/Generic/Mesh/CellsOptions.vue | 2 -- app/components/Viewer/Generic/Mesh/EdgesOptions.vue | 1 - app/components/Viewer/Generic/Mesh/PointsOptions.vue | 1 - app/components/Viewer/Generic/Mesh/PolygonsOptions.vue | 1 - app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue | 1 - 5 files changed, 6 deletions(-) diff --git a/app/components/Viewer/Generic/Mesh/CellsOptions.vue b/app/components/Viewer/Generic/Mesh/CellsOptions.vue index 9fd5a268..f6d70452 100644 --- a/app/components/Viewer/Generic/Mesh/CellsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/CellsOptions.vue @@ -60,8 +60,6 @@ v-model:coloring_style_key="coloring_style_key" v-model:color="color" v-model:textures="textures" - :vertex_attribute="{}" - :cell_attribute="{}" mesh-type="cells" /> diff --git a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue index 12e93eed..bc016f32 100644 --- a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +++ b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue @@ -77,7 +77,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - :vertex_attribute="{}" mesh-type="edges" /> diff --git a/app/components/Viewer/Generic/Mesh/PointsOptions.vue b/app/components/Viewer/Generic/Mesh/PointsOptions.vue index 09ed0f9d..d5846e3e 100644 --- a/app/components/Viewer/Generic/Mesh/PointsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -77,7 +77,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - :vertex_attribute="{}" mesh-type="points" /> diff --git a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue index a0a36415..ce017e14 100644 --- a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue @@ -61,7 +61,6 @@ v-model:coloring_style_key="coloring_style_key" v-model:color="color" v-model:textures="textures" - :vertex_attribute="{}" :polygon_attribute="{}" mesh-type="polygons" /> diff --git a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue index 0e5f46c8..0ab9f259 100644 --- a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue @@ -52,7 +52,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - :vertex_attribute="{}" :polyhedron_attribute="{}" mesh-type="polyhedra" /> From d3e605a18f69ed3d3af5bd0605a9bd2a54a6e9ce Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 5 Feb 2026 12:06:35 +0100 Subject: [PATCH 36/41] efactor attribute selectors architecture - Implement new defineModel pattern with separate v-models for name, range, and colorMap - Add per-attribute persistence for range and colorMap settings - Apply "Cool to Warm" colormap by default on first attribute selection - Fix immediate colormap update when modifying range min/max - Use local state in AttributeSelectors with event-driven communication - Add remoteRender() call in store after colormap application Affected components: - AttributeSelectors (Vertex, Edge, Cell, Polygon, Polyhedron) - ColoringTypeSelector - SpecificOptions (Polygons, Points, Polyhedra, Cells, Edges) - mesh/polygons.js store --- .../EdgedCurve/SpecificEdgesOptions.vue | 109 ++++++++++- .../Viewer/Generic/Mesh/CellsOptions.vue | 109 ++++++++++- .../Viewer/Generic/Mesh/EdgesOptions.vue | 1 - .../Viewer/Generic/Mesh/PointsOptions.vue | 1 - .../Viewer/Generic/Mesh/PolygonsOptions.vue | 2 - .../Viewer/Generic/Mesh/PolyhedraOptions.vue | 2 - .../Viewer/Options/AttributeColorBar.vue | 5 +- .../Viewer/Options/CellAttributeSelector.vue | 136 +++++--------- .../Viewer/Options/ColoringTypeSelector.vue | 107 ++++++++--- .../Viewer/Options/EdgeAttributeSelector.vue | 173 ++++++------------ .../Options/PolygonAttributeSelector.vue | 142 ++++++-------- .../Options/PolyhedronAttributeSelector.vue | 148 ++++++--------- .../Options/VertexAttributeSelector.vue | 144 ++++++--------- .../Viewer/PointSet/SpecificPointsOptions.vue | 58 +++++- .../SpecificPolygonsOptions.vue | 112 +++++++++++- .../Viewer/Solid/SpecificPolyhedraOptions.vue | 118 +++++++++++- internal/stores/mesh/polygons.js | 4 + 17 files changed, 823 insertions(+), 548 deletions(-) diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue index 77c2fb5f..8bd19186 100644 --- a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -44,20 +44,106 @@ hybridViewerStore.remoteRender() }, }) - const vertex_attribute = computed({ - get: () => dataStyleStore.meshEdgesVertexAttribute(id.value), + const vertex_attribute_name = computed({ + get: () => dataStyleStore.meshEdgesVertexAttributeName(id.value), + set: () => { + // Name is set via attribute-selected event to pass defaultMin/defaultMax + }, + }) + const vertex_attribute_range = computed({ + get: () => dataStyleStore.meshEdgesVertexAttributeRange(id.value), set: (newValue) => { - dataStyleStore.setMeshEdgesVertexAttribute(id.value, newValue) + dataStyleStore.setMeshEdgesVertexAttributeRange( + id.value, + newValue[0], + newValue[1], + ) + // Re-apply colormap with new range + const colorMap = dataStyleStore.meshEdgesVertexAttributeColorMap(id.value) + if (colorMap) { + dataStyleStore.setMeshEdgesVertexAttributeColorMap( + id.value, + colorMap, + newValue[0], + newValue[1], + ) + } hybridViewerStore.remoteRender() }, }) - const edge_attribute = computed({ - get: () => dataStyleStore.meshEdgesEdgeAttribute(id.value), + const vertex_attribute_color_map = computed({ + get: () => dataStyleStore.meshEdgesVertexAttributeColorMap(id.value), set: (newValue) => { - dataStyleStore.setMeshEdgesEdgeAttribute(id.value, newValue) + const range = dataStyleStore.meshEdgesVertexAttributeRange(id.value) + dataStyleStore.setMeshEdgesVertexAttributeColorMap( + id.value, + newValue, + range[0], + range[1], + ) hybridViewerStore.remoteRender() }, }) + const edge_attribute_name = computed({ + get: () => dataStyleStore.meshEdgesEdgeAttributeName(id.value), + set: () => { + // Name is set via attribute-selected event to pass defaultMin/defaultMax + }, + }) + const edge_attribute_range = computed({ + get: () => dataStyleStore.meshEdgesEdgeAttributeRange(id.value), + set: (newValue) => { + dataStyleStore.setMeshEdgesEdgeAttributeRange( + id.value, + newValue[0], + newValue[1], + ) + // Re-apply colormap with new range + const colorMap = dataStyleStore.meshEdgesEdgeAttributeColorMap(id.value) + if (colorMap) { + dataStyleStore.setMeshEdgesEdgeAttributeColorMap( + id.value, + colorMap, + newValue[0], + newValue[1], + ) + } + hybridViewerStore.remoteRender() + }, + }) + const edge_attribute_color_map = computed({ + get: () => dataStyleStore.meshEdgesEdgeAttributeColorMap(id.value), + set: (newValue) => { + const range = dataStyleStore.meshEdgesEdgeAttributeRange(id.value) + dataStyleStore.setMeshEdgesEdgeAttributeColorMap( + id.value, + newValue, + range[0], + range[1], + ) + hybridViewerStore.remoteRender() + }, + }) + + // Event handlers for attribute selection with default min/max + function onVertexAttributeSelected(data) { + dataStyleStore.setMeshEdgesVertexAttributeName( + id.value, + data.name, + data.defaultMin, + data.defaultMax, + ) + hybridViewerStore.remoteRender() + } + function onEdgeAttributeSelected(data) { + dataStyleStore.setMeshEdgesEdgeAttributeName( + id.value, + data.name, + data.defaultMin, + data.defaultMax, + ) + hybridViewerStore.remoteRender() + } diff --git a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue index bc016f32..beac6e5b 100644 --- a/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +++ b/app/components/Viewer/Generic/Mesh/EdgesOptions.vue @@ -77,7 +77,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - mesh-type="edges" /> diff --git a/app/components/Viewer/Generic/Mesh/PointsOptions.vue b/app/components/Viewer/Generic/Mesh/PointsOptions.vue index d5846e3e..e07836c9 100644 --- a/app/components/Viewer/Generic/Mesh/PointsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -77,7 +77,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - mesh-type="points" /> diff --git a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue index ce017e14..28d59394 100644 --- a/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue @@ -61,8 +61,6 @@ v-model:coloring_style_key="coloring_style_key" v-model:color="color" v-model:textures="textures" - :polygon_attribute="{}" - mesh-type="polygons" /> diff --git a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue index 0ab9f259..b8351368 100644 --- a/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +++ b/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue @@ -52,8 +52,6 @@ :id="id" v-model:coloring_style_key="coloring_style_key" v-model:color="color" - :polyhedron_attribute="{}" - mesh-type="polyhedra" /> diff --git a/app/components/Viewer/Options/AttributeColorBar.vue b/app/components/Viewer/Options/AttributeColorBar.vue index f1018fd1..1b2b3695 100644 --- a/app/components/Viewer/Options/AttributeColorBar.vue +++ b/app/components/Viewer/Options/AttributeColorBar.vue @@ -8,10 +8,7 @@ const minimum = defineModel("minimum", { type: Number }) const maximum = defineModel("maximum", { type: Number }) - const colorMap = defineModel("colorMap", { - type: String, - default: "Cool to Warm", - }) + const colorMap = defineModel("colorMap", { type: String }) const minValue = computed({ get: () => minimum.value ?? props.autoMin, diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index e153e979..ec5b9946 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -1,101 +1,43 @@ diff --git a/app/components/Viewer/Options/ColoringTypeSelector.vue b/app/components/Viewer/Options/ColoringTypeSelector.vue index aaea10a3..095033de 100644 --- a/app/components/Viewer/Options/ColoringTypeSelector.vue +++ b/app/components/Viewer/Options/ColoringTypeSelector.vue @@ -11,35 +11,76 @@ const color = defineModel("color") const textures = defineModel("textures") - const vertex_attribute = defineModel("vertex_attribute") - const edge_attribute = defineModel("edge_attribute") - const cell_attribute = defineModel("cell_attribute") - const polygon_attribute = defineModel("polygon_attribute") - const polyhedron_attribute = defineModel("polyhedron_attribute") + + // Vertex attribute models + const vertex_attribute_name = defineModel("vertex_attribute_name") + const vertex_attribute_range = defineModel("vertex_attribute_range") + const vertex_attribute_color_map = defineModel("vertex_attribute_color_map") + + // Edge attribute models + const edge_attribute_name = defineModel("edge_attribute_name") + const edge_attribute_range = defineModel("edge_attribute_range") + const edge_attribute_color_map = defineModel("edge_attribute_color_map") + + // Cell attribute models + const cell_attribute_name = defineModel("cell_attribute_name") + const cell_attribute_range = defineModel("cell_attribute_range") + const cell_attribute_color_map = defineModel("cell_attribute_color_map") + + // Polygon attribute models + const polygon_attribute_name = defineModel("polygon_attribute_name") + const polygon_attribute_range = defineModel("polygon_attribute_range") + const polygon_attribute_color_map = defineModel("polygon_attribute_color_map") + + // Polyhedron attribute models + const polyhedron_attribute_name = defineModel("polyhedron_attribute_name") + const polyhedron_attribute_range = defineModel("polyhedron_attribute_range") + const polyhedron_attribute_color_map = defineModel( + "polyhedron_attribute_color_map", + ) const props = defineProps({ id: { type: String, required: true }, - meshType: { type: String, required: false }, }) + const emit = defineEmits([ + "vertex-attribute-selected", + "edge-attribute-selected", + "cell-attribute-selected", + "polygon-attribute-selected", + "polyhedron-attribute-selected", + ]) + + function onVertexAttributeSelected(data) { + emit("vertex-attribute-selected", data) + } + function onEdgeAttributeSelected(data) { + emit("edge-attribute-selected", data) + } + function onCellAttributeSelected(data) { + emit("cell-attribute-selected", data) + } + function onPolygonAttributeSelected(data) { + emit("polygon-attribute-selected", data) + } + function onPolyhedronAttributeSelected(data) { + emit("polyhedron-attribute-selected", data) + } + const has_color = computed(() => (color.value !== undefined ? true : false)) const has_textures = computed(() => textures.value !== undefined ? true : false, ) - const has_vertex = computed(() => - vertex_attribute.value !== undefined ? true : false, - ) - const has_edge = computed(() => - edge_attribute.value !== undefined ? true : false, - ) - const has_cells = computed(() => - cell_attribute.value !== undefined ? true : false, - ) - const has_polygons = computed(() => - polygon_attribute.value !== undefined ? true : false, + // Check if parent component passes these v-models (not undefined means it's passed) + // We use a special marker: if the value is exactly undefined, the v-model wasn't passed + const has_vertex = computed(() => vertex_attribute_range.value !== undefined) + const has_edge = computed(() => edge_attribute_range.value !== undefined) + const has_cells = computed(() => cell_attribute_range.value !== undefined) + const has_polygons = computed( + () => polygon_attribute_range.value !== undefined, ) - const has_polyhedra = computed(() => - polyhedron_attribute.value !== undefined ? true : false, + const has_polyhedra = computed( + () => polyhedron_attribute_range.value !== undefined, ) const color_dict = { name: "Color", value: "color" } @@ -115,33 +156,49 @@ diff --git a/app/components/Viewer/Options/EdgeAttributeSelector.vue b/app/components/Viewer/Options/EdgeAttributeSelector.vue index ef885d77..623de38e 100644 --- a/app/components/Viewer/Options/EdgeAttributeSelector.vue +++ b/app/components/Viewer/Options/EdgeAttributeSelector.vue @@ -1,152 +1,89 @@ diff --git a/app/components/Viewer/Options/PolygonAttributeSelector.vue b/app/components/Viewer/Options/PolygonAttributeSelector.vue index 2351f2f4..498d2b35 100644 --- a/app/components/Viewer/Options/PolygonAttributeSelector.vue +++ b/app/components/Viewer/Options/PolygonAttributeSelector.vue @@ -1,101 +1,49 @@ diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index 6ab89dbf..f5d40937 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -1,105 +1,51 @@ diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index 952a15c6..87373778 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -1,99 +1,51 @@ diff --git a/app/components/Viewer/PointSet/SpecificPointsOptions.vue b/app/components/Viewer/PointSet/SpecificPointsOptions.vue index 68237370..6c408712 100644 --- a/app/components/Viewer/PointSet/SpecificPointsOptions.vue +++ b/app/components/Viewer/PointSet/SpecificPointsOptions.vue @@ -44,13 +44,59 @@ hybridViewerStore.remoteRender() }, }) - const vertex_attribute = computed({ - get: () => dataStyleStore.meshPointsVertexAttribute(id.value), + const vertex_attribute_name = computed({ + get: () => dataStyleStore.meshPointsVertexAttributeName(id.value), + set: () => { + // Name is set via attribute-selected event to pass defaultMin/defaultMax + }, + }) + const vertex_attribute_range = computed({ + get: () => dataStyleStore.meshPointsVertexAttributeRange(id.value), set: (newValue) => { - dataStyleStore.setMeshPointsVertexAttribute(id.value, newValue) + dataStyleStore.setMeshPointsVertexAttributeRange( + id.value, + newValue[0], + newValue[1], + ) + // Re-apply colormap with new range + const colorMap = dataStyleStore.meshPointsVertexAttributeColorMap( + id.value, + ) + if (colorMap) { + dataStyleStore.setMeshPointsVertexAttributeColorMap( + id.value, + colorMap, + newValue[0], + newValue[1], + ) + } hybridViewerStore.remoteRender() }, }) + const vertex_attribute_color_map = computed({ + get: () => dataStyleStore.meshPointsVertexAttributeColorMap(id.value), + set: (newValue) => { + const range = dataStyleStore.meshPointsVertexAttributeRange(id.value) + dataStyleStore.setMeshPointsVertexAttributeColorMap( + id.value, + newValue, + range[0], + range[1], + ) + hybridViewerStore.remoteRender() + }, + }) + + // Event handler for attribute selection with default min/max + function onVertexAttributeSelected(data) { + dataStyleStore.setMeshPointsVertexAttributeName( + id.value, + data.name, + data.defaultMin, + data.defaultMax, + ) + hybridViewerStore.remoteRender() + } diff --git a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue index 32d7b4b8..1fd152b9 100644 --- a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +++ b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue @@ -38,20 +38,113 @@ hybridViewerStore.remoteRender() }, }) - const vertex_attribute = computed({ - get: () => dataStyleStore.meshPolyhedraVertexAttribute(id.value), + const vertex_attribute_name = computed({ + get: () => dataStyleStore.meshPolyhedraVertexAttributeName(id.value), + set: () => { + // Name is set via attribute-selected event to pass defaultMin/defaultMax + }, + }) + const vertex_attribute_range = computed({ + get: () => dataStyleStore.meshPolyhedraVertexAttributeRange(id.value), set: (newValue) => { - dataStyleStore.setMeshPolyhedraVertexAttribute(id.value, newValue) + dataStyleStore.setMeshPolyhedraVertexAttributeRange( + id.value, + newValue[0], + newValue[1], + ) + // Re-apply colormap with new range + const colorMap = dataStyleStore.meshPolyhedraVertexAttributeColorMap( + id.value, + ) + if (colorMap) { + dataStyleStore.setMeshPolyhedraVertexAttributeColorMap( + id.value, + colorMap, + newValue[0], + newValue[1], + ) + } hybridViewerStore.remoteRender() }, }) - const polyhedron_attribute = computed({ - get: () => dataStyleStore.meshPolyhedraPolyhedronAttribute(id.value), + const vertex_attribute_color_map = computed({ + get: () => dataStyleStore.meshPolyhedraVertexAttributeColorMap(id.value), set: (newValue) => { - dataStyleStore.setMeshPolyhedraPolyhedronAttribute(id.value, newValue) + const range = dataStyleStore.meshPolyhedraVertexAttributeRange(id.value) + dataStyleStore.setMeshPolyhedraVertexAttributeColorMap( + id.value, + newValue, + range[0], + range[1], + ) hybridViewerStore.remoteRender() }, }) + const polyhedron_attribute_name = computed({ + get: () => dataStyleStore.meshPolyhedraPolyhedronAttributeName(id.value), + set: () => { + // Name is set via attribute-selected event to pass defaultMin/defaultMax + }, + }) + const polyhedron_attribute_range = computed({ + get: () => dataStyleStore.meshPolyhedraPolyhedronAttributeRange(id.value), + set: (newValue) => { + dataStyleStore.setMeshPolyhedraPolyhedronAttributeRange( + id.value, + newValue[0], + newValue[1], + ) + // Re-apply colormap with new range + const colorMap = dataStyleStore.meshPolyhedraPolyhedronAttributeColorMap( + id.value, + ) + if (colorMap) { + dataStyleStore.setMeshPolyhedraPolyhedronAttributeColorMap( + id.value, + colorMap, + newValue[0], + newValue[1], + ) + } + hybridViewerStore.remoteRender() + }, + }) + const polyhedron_attribute_color_map = computed({ + get: () => + dataStyleStore.meshPolyhedraPolyhedronAttributeColorMap(id.value), + set: (newValue) => { + const range = dataStyleStore.meshPolyhedraPolyhedronAttributeRange( + id.value, + ) + dataStyleStore.setMeshPolyhedraPolyhedronAttributeColorMap( + id.value, + newValue, + range[0], + range[1], + ) + hybridViewerStore.remoteRender() + }, + }) + + // Event handlers for attribute selection with default min/max + function onVertexAttributeSelected(data) { + dataStyleStore.setMeshPolyhedraVertexAttributeName( + id.value, + data.name, + data.defaultMin, + data.defaultMax, + ) + hybridViewerStore.remoteRender() + } + function onPolyhedronAttributeSelected(data) { + dataStyleStore.setMeshPolyhedraPolyhedronAttributeName( + id.value, + data.name, + data.defaultMin, + data.defaultMax, + ) + hybridViewerStore.remoteRender() + } diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index e01a32dc..61713a44 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -4,6 +4,7 @@ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schem // Local imports import { useDataStyleStateStore } from "../data_style_state" import { useViewerStore } from "@ogw_front/stores/viewer" +import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer" import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap" // Local constants @@ -12,6 +13,7 @@ const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons export function useMeshPolygonsStyle() { const dataStyleStateStore = useDataStyleStateStore() const viewerStore = useViewerStore() + const hybridViewerStore = useHybridViewerStore() function meshPolygonsStyle(id) { return dataStyleStateStore.getStyle(id).polygons @@ -202,6 +204,7 @@ export function useMeshPolygonsStyle() { coloring_style.vertex = {} } coloring_style.vertex.colorMap = colorMapName + hybridViewerStore.remoteRender() console.log(setMeshPolygonsVertexAttributeColorMap.name, { id, colorMapName, @@ -333,6 +336,7 @@ export function useMeshPolygonsStyle() { coloring_style.polygon = {} } coloring_style.polygon.colorMap = colorMapName + hybridViewerStore.remoteRender() console.log(setMeshPolygonsPolygonAttributeColorMap.name, { id, colorMapName, From 4063e7bc1d1b44cab10f6d5b39d215018cbcee8c Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 5 Feb 2026 14:00:13 +0100 Subject: [PATCH 37/41] rm comments --- .../Viewer/EdgedCurve/SpecificEdgesOptions.vue | 11 ++--------- app/components/Viewer/Generic/Mesh/CellsOptions.vue | 11 ++--------- .../Viewer/Options/CellAttributeSelector.vue | 2 -- .../Viewer/Options/ColoringTypeSelector.vue | 7 ------- .../Viewer/PointSet/SpecificPointsOptions.vue | 6 +----- .../PolygonalSurface/SpecificPolygonsOptions.vue | 11 ++--------- .../Viewer/Solid/SpecificPolyhedraOptions.vue | 11 ++--------- 7 files changed, 9 insertions(+), 50 deletions(-) diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue index 8bd19186..b5dada05 100644 --- a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -46,9 +46,7 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshEdgesVertexAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshEdgesVertexAttributeRange(id.value), @@ -58,7 +56,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshEdgesVertexAttributeColorMap(id.value) if (colorMap) { dataStyleStore.setMeshEdgesVertexAttributeColorMap( @@ -86,9 +83,7 @@ }) const edge_attribute_name = computed({ get: () => dataStyleStore.meshEdgesEdgeAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const edge_attribute_range = computed({ get: () => dataStyleStore.meshEdgesEdgeAttributeRange(id.value), @@ -98,7 +93,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshEdgesEdgeAttributeColorMap(id.value) if (colorMap) { dataStyleStore.setMeshEdgesEdgeAttributeColorMap( @@ -125,7 +119,6 @@ }, }) - // Event handlers for attribute selection with default min/max function onVertexAttributeSelected(data) { dataStyleStore.setMeshEdgesVertexAttributeName( id.value, diff --git a/app/components/Viewer/Generic/Mesh/CellsOptions.vue b/app/components/Viewer/Generic/Mesh/CellsOptions.vue index 5d0cc085..fc5ab236 100644 --- a/app/components/Viewer/Generic/Mesh/CellsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/CellsOptions.vue @@ -47,9 +47,7 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshCellsVertexAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshCellsVertexAttributeRange(id.value), @@ -59,7 +57,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshCellsVertexAttributeColorMap(id.value) if (colorMap) { dataStyleStore.setMeshCellsVertexAttributeColorMap( @@ -87,9 +84,7 @@ }) const cell_attribute_name = computed({ get: () => dataStyleStore.meshCellsCellAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const cell_attribute_range = computed({ get: () => dataStyleStore.meshCellsCellAttributeRange(id.value), @@ -99,7 +94,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshCellsCellAttributeColorMap(id.value) if (colorMap) { dataStyleStore.setMeshCellsCellAttributeColorMap( @@ -126,7 +120,6 @@ }, }) - // Event handlers for attribute selection with default min/max function onVertexAttributeSelected(data) { dataStyleStore.setMeshCellsVertexAttributeName( id.value, diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index ec5b9946..795e68d7 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -13,10 +13,8 @@ const cell_attribute_color_map = defineModel("cell_attribute_color_map") const cell_attributes = ref([]) - // Local state for the v-select const selectedName = ref(cell_attribute_name.value) - // Sync local state when parent value changes externally watch(cell_attribute_name, (newVal) => { selectedName.value = newVal }) diff --git a/app/components/Viewer/Options/ColoringTypeSelector.vue b/app/components/Viewer/Options/ColoringTypeSelector.vue index 095033de..1c5dc06a 100644 --- a/app/components/Viewer/Options/ColoringTypeSelector.vue +++ b/app/components/Viewer/Options/ColoringTypeSelector.vue @@ -12,27 +12,22 @@ const color = defineModel("color") const textures = defineModel("textures") - // Vertex attribute models const vertex_attribute_name = defineModel("vertex_attribute_name") const vertex_attribute_range = defineModel("vertex_attribute_range") const vertex_attribute_color_map = defineModel("vertex_attribute_color_map") - // Edge attribute models const edge_attribute_name = defineModel("edge_attribute_name") const edge_attribute_range = defineModel("edge_attribute_range") const edge_attribute_color_map = defineModel("edge_attribute_color_map") - // Cell attribute models const cell_attribute_name = defineModel("cell_attribute_name") const cell_attribute_range = defineModel("cell_attribute_range") const cell_attribute_color_map = defineModel("cell_attribute_color_map") - // Polygon attribute models const polygon_attribute_name = defineModel("polygon_attribute_name") const polygon_attribute_range = defineModel("polygon_attribute_range") const polygon_attribute_color_map = defineModel("polygon_attribute_color_map") - // Polyhedron attribute models const polyhedron_attribute_name = defineModel("polyhedron_attribute_name") const polyhedron_attribute_range = defineModel("polyhedron_attribute_range") const polyhedron_attribute_color_map = defineModel( @@ -71,8 +66,6 @@ const has_textures = computed(() => textures.value !== undefined ? true : false, ) - // Check if parent component passes these v-models (not undefined means it's passed) - // We use a special marker: if the value is exactly undefined, the v-model wasn't passed const has_vertex = computed(() => vertex_attribute_range.value !== undefined) const has_edge = computed(() => edge_attribute_range.value !== undefined) const has_cells = computed(() => cell_attribute_range.value !== undefined) diff --git a/app/components/Viewer/PointSet/SpecificPointsOptions.vue b/app/components/Viewer/PointSet/SpecificPointsOptions.vue index 6c408712..cd8ee00c 100644 --- a/app/components/Viewer/PointSet/SpecificPointsOptions.vue +++ b/app/components/Viewer/PointSet/SpecificPointsOptions.vue @@ -46,9 +46,7 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshPointsVertexAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshPointsVertexAttributeRange(id.value), @@ -58,7 +56,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshPointsVertexAttributeColorMap( id.value, ) @@ -87,7 +84,6 @@ }, }) - // Event handler for attribute selection with default min/max function onVertexAttributeSelected(data) { dataStyleStore.setMeshPointsVertexAttributeName( id.value, diff --git a/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue b/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue index b538e490..f8d4c95d 100644 --- a/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue +++ b/app/components/Viewer/PolygonalSurface/SpecificPolygonsOptions.vue @@ -47,9 +47,7 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshPolygonsVertexAttributeName(id.value), - set: (newValue) => { - // Called by parent when event fires with default values - }, + set: () => {}, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshPolygonsVertexAttributeRange(id.value), @@ -59,7 +57,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshPolygonsVertexAttributeColorMap( id.value, ) @@ -89,12 +86,9 @@ }) const polygon_attribute_name = computed({ get: () => dataStyleStore.meshPolygonsPolygonAttributeName(id.value), - set: (newValue) => { - // Called by parent when event fires with default values - }, + set: () => {}, }) - // Event handlers for attribute selection with default min/max function onVertexAttributeSelected(data) { dataStyleStore.setMeshPolygonsVertexAttributeName( id.value, @@ -102,7 +96,6 @@ data.defaultMin, data.defaultMax, ) - // Note: remoteRender is called by the store after the colormap is applied } function onPolygonAttributeSelected(data) { dataStyleStore.setMeshPolygonsPolygonAttributeName( diff --git a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue index 1fd152b9..236da61b 100644 --- a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +++ b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue @@ -40,9 +40,7 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshPolyhedraVertexAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshPolyhedraVertexAttributeRange(id.value), @@ -52,7 +50,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshPolyhedraVertexAttributeColorMap( id.value, ) @@ -82,9 +79,7 @@ }) const polyhedron_attribute_name = computed({ get: () => dataStyleStore.meshPolyhedraPolyhedronAttributeName(id.value), - set: () => { - // Name is set via attribute-selected event to pass defaultMin/defaultMax - }, + set: () => {}, }) const polyhedron_attribute_range = computed({ get: () => dataStyleStore.meshPolyhedraPolyhedronAttributeRange(id.value), @@ -94,7 +89,6 @@ newValue[0], newValue[1], ) - // Re-apply colormap with new range const colorMap = dataStyleStore.meshPolyhedraPolyhedronAttributeColorMap( id.value, ) @@ -126,7 +120,6 @@ }, }) - // Event handlers for attribute selection with default min/max function onVertexAttributeSelected(data) { dataStyleStore.setMeshPolyhedraVertexAttributeName( id.value, From d2125f64385cd8495b434999f59301e843222d42 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 5 Feb 2026 14:15:44 +0100 Subject: [PATCH 38/41] reset range --- .../Viewer/Options/CellAttributeSelector.vue | 7 +++++++ .../Viewer/Options/EdgeAttributeSelector.vue | 9 +++++++-- .../Viewer/Options/PolygonAttributeSelector.vue | 9 +++++++-- .../Viewer/Options/PolyhedronAttributeSelector.vue | 9 +++++++-- .../Viewer/Options/VertexAttributeSelector.vue | 13 +++++++------ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index 795e68d7..5ca8477d 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -67,6 +67,11 @@ }) } }) + const currentAttribute = computed(() => { + return cell_attributes.value.find( + (attr) => attr.attribute_name === selectedName.value, + ) + }) diff --git a/app/components/Viewer/Options/EdgeAttributeSelector.vue b/app/components/Viewer/Options/EdgeAttributeSelector.vue index 623de38e..96e196df 100644 --- a/app/components/Viewer/Options/EdgeAttributeSelector.vue +++ b/app/components/Viewer/Options/EdgeAttributeSelector.vue @@ -13,10 +13,8 @@ const edge_attribute_color_map = defineModel("edge_attribute_color_map") const edge_attributes = ref([]) - // Local state for the v-select const selectedName = ref(edge_attribute_name.value) - // Sync local state when parent value changes externally watch(edge_attribute_name, (newVal) => { selectedName.value = newVal }) @@ -69,6 +67,11 @@ }) } }) + const currentAttribute = computed(() => { + return edge_attributes.value.find( + (attr) => attr.attribute_name === selectedName.value, + ) + }) diff --git a/app/components/Viewer/Options/PolygonAttributeSelector.vue b/app/components/Viewer/Options/PolygonAttributeSelector.vue index 498d2b35..01e4b619 100644 --- a/app/components/Viewer/Options/PolygonAttributeSelector.vue +++ b/app/components/Viewer/Options/PolygonAttributeSelector.vue @@ -13,10 +13,8 @@ const polygon_attribute_color_map = defineModel("polygon_attribute_color_map") const polygon_attributes = ref([]) - // Local state for the v-select const selectedName = ref(polygon_attribute_name.value) - // Sync local state when parent value changes externally watch(polygon_attribute_name, (newVal) => { selectedName.value = newVal }) @@ -75,6 +73,11 @@ }) } }) + const currentAttribute = computed(() => { + return polygon_attributes.value.find( + (attr) => attr.attribute_name === selectedName.value, + ) + }) diff --git a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue index f5d40937..93a5d207 100644 --- a/app/components/Viewer/Options/PolyhedronAttributeSelector.vue +++ b/app/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -15,10 +15,8 @@ ) const polyhedron_attributes = ref([]) - // Local state for the v-select const selectedName = ref(polyhedron_attribute_name.value) - // Sync local state when parent value changes externally watch(polyhedron_attribute_name, (newVal) => { selectedName.value = newVal }) @@ -77,6 +75,11 @@ }) } }) + const currentAttribute = computed(() => { + return polyhedron_attributes.value.find( + (attr) => attr.attribute_name === selectedName.value, + ) + }) diff --git a/app/components/Viewer/Options/VertexAttributeSelector.vue b/app/components/Viewer/Options/VertexAttributeSelector.vue index 87373778..9f5c63e2 100644 --- a/app/components/Viewer/Options/VertexAttributeSelector.vue +++ b/app/components/Viewer/Options/VertexAttributeSelector.vue @@ -5,7 +5,6 @@ const geodeStore = useGeodeStore() - // Use local state for the select, and sync with parent via events const vertex_attribute_name = defineModel("vertex_attribute_name") const vertex_attribute_range = defineModel("vertex_attribute_range", { type: Array, @@ -14,10 +13,8 @@ const vertex_attribute_color_map = defineModel("vertex_attribute_color_map") const vertex_attributes = ref([]) - // Local state for the v-select (initialized from parent value) const selectedName = ref(vertex_attribute_name.value) - // Sync local state when parent value changes externally watch(vertex_attribute_name, (newVal) => { selectedName.value = newVal }) @@ -26,7 +23,6 @@ id: { type: String, required: true }, }) - // Computed properties for min/max to handle reactivity properly const rangeMin = computed({ get: () => vertex_attribute_range.value?.[0] ?? 0, set: (val) => { @@ -62,10 +58,8 @@ ) } - // Emit to notify parent about attribute selection with default min/max const emit = defineEmits(["attribute-selected"]) - // Watch local selection and emit event with default values watch(selectedName, (newName) => { if (!newName) return const attribute = vertex_attributes.value.find( @@ -79,6 +73,11 @@ }) } }) + const currentAttribute = computed(() => { + return vertex_attributes.value.find( + (attr) => attr.attribute_name === selectedName.value, + ) + }) From e3922c428a6fe51b3c4a82a83738e2045de0a507 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 5 Feb 2026 15:41:25 +0100 Subject: [PATCH 39/41] refacto --- app/utils/default_styles.js | 38 ++-- internal/stores/mesh/cells.js | 282 +++++++++++++--------------- internal/stores/mesh/edges.js | 298 ++++++++++++++--------------- internal/stores/mesh/points.js | 113 +++++------ internal/stores/mesh/polygons.js | 299 ++++++++++++++---------------- internal/stores/mesh/polyhedra.js | 283 +++++++++++++--------------- 6 files changed, 596 insertions(+), 717 deletions(-) diff --git a/app/utils/default_styles.js b/app/utils/default_styles.js index 163f406d..0caf4d14 100644 --- a/app/utils/default_styles.js +++ b/app/utils/default_styles.js @@ -34,9 +34,9 @@ const meshPointsDefaultStyle = ( color, vertex: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + + + attributes: {} }, }, size, @@ -55,15 +55,11 @@ const meshEdgesDefaultStyle = ( color, edge: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, vertex: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, }, width, @@ -80,17 +76,13 @@ const meshCellsDefaultStyle = ( active: "color", cell: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, color, textures: null, vertex: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, }, } @@ -108,15 +100,11 @@ const meshPolygonsDefaultStyle = ( textures: null, polygon: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, vertex: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, }, } @@ -133,15 +121,11 @@ const meshPolyhedraDefaultStyle = ( color, polyhedron: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, vertex: { name: undefined, - minimum: 0, - maximum: 1, - colorMap: "Cool to Warm", + attributes: {}, }, }, } diff --git a/internal/stores/mesh/cells.js b/internal/stores/mesh/cells.js index 97fe45e2..14a8ad0a 100644 --- a/internal/stores/mesh/cells.js +++ b/internal/stores/mesh/cells.js @@ -93,77 +93,71 @@ export function useMeshCellsStyle() { { id, name }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - const previousName = coloring_style.vertex.name - if (previousName) { - if (!coloring_style.vertex.attributes) { - coloring_style.vertex.attributes = {} - } - coloring_style.vertex.attributes[previousName] = { - minimum: coloring_style.vertex.minimum, - maximum: coloring_style.vertex.maximum, - colorMap: coloring_style.vertex.colorMap, - } - } - + const saved_preset = coloring_style.vertex.attributes[name] coloring_style.vertex.name = name - if ( - coloring_style.vertex.attributes && - coloring_style.vertex.attributes[name] - ) { - const saved = coloring_style.vertex.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshCellsVertexAttributeRange(id, saved.minimum, saved.maximum) - if (saved.colorMap) { - setMeshCellsVertexAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshCellsVertexAttributeRange(id, defaultMin, defaultMax) - setMeshCellsVertexAttributeColorMap( - id, - "Cool to Warm", - defaultMin, - defaultMax, - ) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.vertex.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshCellsVertexAttributeRange(id, minimum, maximum) + setMeshCellsVertexAttributeColorMap(id, colorMap, minimum, maximum) } - console.log(setMeshCellsVertexAttributeName.name, { id }, name) + console.log( + setMeshCellsVertexAttributeName.name, + { id }, + meshCellsVertexAttributeName(id), + ) }, }, ) } function meshCellsVertexAttributeRange(id) { - const vertex = meshCellsStyle(id).coloring.vertex - return vertex ? [vertex.minimum, vertex.maximum] : [0, 1] + const name = meshCellsVertexAttributeName(id) + const saved_preset = meshCellsStyle(id).coloring.vertex.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshCellsVertexAttributeRange(id, min, max) { + function setMeshCellsVertexAttributeRange(id, minimum, maximum) { const coloring_style = meshCellsStyle(id).coloring return viewerStore.request( mesh_cells_schemas.attribute.vertex.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.minimum = min - coloring_style.vertex.maximum = max - console.log(setMeshCellsVertexAttributeRange.name, { id, min, max }) + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshCellsVertexAttributeRange.name, + { id }, + meshCellsVertexAttributeRange(id), + ) }, }, ) } function meshCellsVertexAttributeColorMap(id) { - const vertex = meshCellsStyle(id).coloring.vertex - return vertex ? vertex.colorMap : null + const name = meshCellsVertexAttributeName(id) + const saved_preset = meshCellsStyle(id).coloring.vertex.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshCellsVertexAttributeColorMap( id, @@ -181,10 +175,9 @@ export function useMeshCellsStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.colorMap = colorMapName + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshCellsVertexAttributeColorMap.name, { id, colorMapName, @@ -210,77 +203,71 @@ export function useMeshCellsStyle() { { id, name }, { response_function: () => { - if (!coloring_style.cell) { - coloring_style.cell = {} - } - const previousName = coloring_style.cell.name - if (previousName) { - if (!coloring_style.cell.attributes) { - coloring_style.cell.attributes = {} - } - coloring_style.cell.attributes[previousName] = { - minimum: coloring_style.cell.minimum, - maximum: coloring_style.cell.maximum, - colorMap: coloring_style.cell.colorMap, - } - } - + const saved_preset = coloring_style.cell.attributes[name] coloring_style.cell.name = name - if ( - coloring_style.cell.attributes && - coloring_style.cell.attributes[name] - ) { - const saved = coloring_style.cell.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshCellsCellAttributeRange(id, saved.minimum, saved.maximum) - if (saved.colorMap) { - setMeshCellsCellAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshCellsCellAttributeRange(id, defaultMin, defaultMax) - setMeshCellsCellAttributeColorMap( - id, - "Cool to Warm", - defaultMin, - defaultMax, - ) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.cell.attributes[name] = { + minimum, + maximum, + colorMap, + } } - console.log(setMeshCellsCellAttributeName.name, { id }, name) + if (minimum !== undefined && maximum !== undefined) { + setMeshCellsCellAttributeRange(id, minimum, maximum) + setMeshCellsCellAttributeColorMap(id, colorMap, minimum, maximum) + } + console.log( + setMeshCellsCellAttributeName.name, + { id }, + meshCellsCellAttributeName(id), + ) }, }, ) } function meshCellsCellAttributeRange(id) { - const cell = meshCellsStyle(id).coloring.cell - return cell ? [cell.minimum, cell.maximum] : [0, 1] + const name = meshCellsCellAttributeName(id) + const saved_preset = meshCellsStyle(id).coloring.cell.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshCellsCellAttributeRange(id, min, max) { + function setMeshCellsCellAttributeRange(id, minimum, maximum) { const coloring_style = meshCellsStyle(id).coloring return viewerStore.request( mesh_cells_schemas.attribute.cell.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.cell) { - coloring_style.cell = {} - } - coloring_style.cell.minimum = min - coloring_style.cell.maximum = max - console.log(setMeshCellsCellAttributeRange.name, { id, min, max }) + const name = coloring_style.cell.name + const saved_preset = coloring_style.cell.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshCellsCellAttributeRange.name, + { id }, + meshCellsCellAttributeRange(id), + ) }, }, ) } function meshCellsCellAttributeColorMap(id) { - const cell = meshCellsStyle(id).coloring.cell - return cell ? cell.colorMap : null + const name = meshCellsCellAttributeName(id) + const saved_preset = meshCellsStyle(id).coloring.cell.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshCellsCellAttributeColorMap( id, @@ -298,10 +285,9 @@ export function useMeshCellsStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.cell) { - coloring_style.cell = {} - } - coloring_style.cell.colorMap = colorMapName + const name = coloring_style.cell.name + const saved_preset = coloring_style.cell.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshCellsCellAttributeColorMap.name, { id, colorMapName, @@ -330,59 +316,57 @@ export function useMeshCellsStyle() { } return setMeshCellsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex?.name === undefined) { + const name = coloring.vertex.name + if (name === undefined) { return Promise.resolve() } - return setMeshCellsVertexAttributeName(id, coloring.vertex.name).then( - () => { - if ( - coloring.vertex.minimum !== undefined && - coloring.vertex.maximum !== undefined - ) { - return setMeshCellsVertexAttributeRange( - id, - coloring.vertex.minimum, - coloring.vertex.maximum, - ).then(() => { - if (coloring.vertex.colorMap) { + const attributes = coloring.vertex.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshCellsVertexAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshCellsVertexAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { return setMeshCellsVertexAttributeColorMap( id, - coloring.vertex.colorMap, - coloring.vertex.minimum, - coloring.vertex.maximum, + colorMap, + minimum, + maximum, ) } - }) - } - }, - ) + }, + ) + } + }) } else if (type === "cell") { - if (coloring.cell?.name === undefined) { + const name = coloring.cell.name + if (name === undefined) { return Promise.resolve() } - return setMeshCellsCellAttributeName(id, coloring.cell.name).then(() => { - if ( - coloring.cell.minimum !== undefined && - coloring.cell.maximum !== undefined - ) { - return setMeshCellsCellAttributeRange( - id, - coloring.cell.minimum, - coloring.cell.maximum, - ).then(() => { - if (coloring.cell.colorMap) { - return setMeshCellsCellAttributeColorMap( - id, - coloring.cell.colorMap, - coloring.cell.minimum, - coloring.cell.maximum, - ) - } - }) + const attributes = coloring.cell.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshCellsCellAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshCellsCellAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { + return setMeshCellsCellAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + } + }, + ) } }) } else { - return Promise.resolve() + throw new Error("Unknown active coloring type: " + type) } } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 34279a72..31b958a9 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -51,59 +51,57 @@ export function useMeshEdgesStyle() { if (type === "color") { return setMeshEdgesColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex?.name === undefined) { + const name = coloring.vertex.name + if (name === undefined) { return Promise.resolve() } - return setMeshEdgesVertexAttributeName(id, coloring.vertex.name).then( - () => { - if ( - coloring.vertex.minimum !== undefined && - coloring.vertex.maximum !== undefined - ) { - return setMeshEdgesVertexAttributeRange( - id, - coloring.vertex.minimum, - coloring.vertex.maximum, - ).then(() => { - if (coloring.vertex.colorMap) { + const attributes = coloring.vertex.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshEdgesVertexAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshEdgesVertexAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { return setMeshEdgesVertexAttributeColorMap( id, - coloring.vertex.colorMap, - coloring.vertex.minimum, - coloring.vertex.maximum, + colorMap, + minimum, + maximum, ) } - }) - } - }, - ) + }, + ) + } + }) } else if (type === "edge") { - if (coloring.edge?.name === undefined) { + const name = coloring.edge.name + if (name === undefined) { return Promise.resolve() } - return setMeshEdgesEdgeAttributeName(id, coloring.edge.name).then(() => { - if ( - coloring.edge.minimum !== undefined && - coloring.edge.maximum !== undefined - ) { - return setMeshEdgesEdgeAttributeRange( - id, - coloring.edge.minimum, - coloring.edge.maximum, - ).then(() => { - if (coloring.edge.colorMap) { - return setMeshEdgesEdgeAttributeColorMap( - id, - coloring.edge.colorMap, - coloring.edge.minimum, - coloring.edge.maximum, - ) - } - }) + const attributes = coloring.edge.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshEdgesEdgeAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshEdgesEdgeAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { + return setMeshEdgesEdgeAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + } + }, + ) } }) } else { - return Promise.resolve() + throw new Error("Unknown active coloring type: " + type) } } @@ -162,77 +160,71 @@ export function useMeshEdgesStyle() { { id, name }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - const previousName = coloring_style.vertex.name - if (previousName) { - if (!coloring_style.vertex.attributes) { - coloring_style.vertex.attributes = {} - } - coloring_style.vertex.attributes[previousName] = { - minimum: coloring_style.vertex.minimum, - maximum: coloring_style.vertex.maximum, - colorMap: coloring_style.vertex.colorMap, - } - } - + const saved_preset = coloring_style.vertex.attributes[name] coloring_style.vertex.name = name - if ( - coloring_style.vertex.attributes && - coloring_style.vertex.attributes[name] - ) { - const saved = coloring_style.vertex.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshEdgesVertexAttributeRange(id, saved.minimum, saved.maximum) - if (saved.colorMap) { - setMeshEdgesVertexAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshEdgesVertexAttributeRange(id, defaultMin, defaultMax) - setMeshEdgesVertexAttributeColorMap( - id, - "Cool to Warm", - defaultMin, - defaultMax, - ) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.vertex.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshEdgesVertexAttributeRange(id, minimum, maximum) + setMeshEdgesVertexAttributeColorMap(id, colorMap, minimum, maximum) } - console.log(setMeshEdgesVertexAttributeName.name, { id }, name) + console.log( + setMeshEdgesVertexAttributeName.name, + { id }, + meshEdgesVertexAttributeName(id), + ) }, }, ) } function meshEdgesVertexAttributeRange(id) { - const vertex = meshEdgesStyle(id).coloring.vertex - return vertex ? [vertex.minimum, vertex.maximum] : [0, 1] + const name = meshEdgesVertexAttributeName(id) + const saved_preset = meshEdgesStyle(id).coloring.vertex.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshEdgesVertexAttributeRange(id, min, max) { + function setMeshEdgesVertexAttributeRange(id, minimum, maximum) { const coloring_style = meshEdgesStyle(id).coloring return viewerStore.request( mesh_edges_schemas.attribute.vertex.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.minimum = min - coloring_style.vertex.maximum = max - console.log(setMeshEdgesVertexAttributeRange.name, { id, min, max }) + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshEdgesVertexAttributeRange.name, + { id }, + meshEdgesVertexAttributeRange(id), + ) }, }, ) } function meshEdgesVertexAttributeColorMap(id) { - const vertex = meshEdgesStyle(id).coloring.vertex - return vertex ? vertex.colorMap : null + const name = meshEdgesVertexAttributeName(id) + const saved_preset = meshEdgesStyle(id).coloring.vertex.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshEdgesVertexAttributeColorMap( id, @@ -250,10 +242,9 @@ export function useMeshEdgesStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.colorMap = colorMapName + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshEdgesVertexAttributeColorMap.name, { id, colorMapName, @@ -280,86 +271,79 @@ export function useMeshEdgesStyle() { { id, name }, { response_function: () => { - if (!coloring_style.edge) { - coloring_style.edge = {} - } - const previousName = coloring_style.edge.name - if (previousName) { - if (!coloring_style.edge.attributes) { - coloring_style.edge.attributes = {} - } - coloring_style.edge.attributes[previousName] = { - minimum: coloring_style.edge.minimum, - maximum: coloring_style.edge.maximum, - colorMap: coloring_style.edge.colorMap, - } - } - + const saved_preset = coloring_style.edge.attributes[name] coloring_style.edge.name = name - if ( - coloring_style.edge.attributes && - coloring_style.edge.attributes[name] - ) { - const saved = coloring_style.edge.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshEdgesEdgeAttributeRange(id, saved.minimum, saved.maximum) - if (saved.colorMap) { - setMeshEdgesEdgeAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshEdgesEdgeAttributeRange(id, defaultMin, defaultMax) - setMeshEdgesEdgeAttributeColorMap( - id, - "Cool to Warm", - defaultMin, - defaultMax, - ) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.edge.attributes[name] = { + minimum, + maximum, + colorMap, + } } - console.log(setMeshEdgesEdgeAttributeName.name, { id }, name) + if (minimum !== undefined && maximum !== undefined) { + setMeshEdgesEdgeAttributeRange(id, minimum, maximum) + setMeshEdgesEdgeAttributeColorMap(id, colorMap, minimum, maximum) + } + console.log( + setMeshEdgesEdgeAttributeName.name, + { id }, + meshEdgesEdgeAttributeName(id), + ) }, }, ) } function meshEdgesEdgeAttributeRange(id) { - const edge = meshEdgesStyle(id).coloring.edge - return edge ? [edge.minimum, edge.maximum] : [0, 1] + const name = meshEdgesEdgeAttributeName(id) + const saved_preset = meshEdgesStyle(id).coloring.edge.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshEdgesEdgeAttributeRange(id, min, max) { + function setMeshEdgesEdgeAttributeRange(id, minimum, maximum) { const coloring_style = meshEdgesStyle(id).coloring if (!mesh_edges_schemas.edge_scalar_range) { console.warn("setMeshEdgesEdgeAttributeRange: RPC not available") - if (!coloring_style.edge) { - coloring_style.edge = {} - } - coloring_style.edge.minimum = min - coloring_style.edge.maximum = max + const name = coloring_style.edge.name + const saved_preset = coloring_style.edge.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum return Promise.resolve() } return viewerStore.request( mesh_edges_schemas.edge_scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.edge) { - coloring_style.edge = {} - } - coloring_style.edge.minimum = min - coloring_style.edge.maximum = max - console.log(setMeshEdgesEdgeAttributeRange.name, { id, min, max }) + const name = coloring_style.edge.name + const saved_preset = coloring_style.edge.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshEdgesEdgeAttributeRange.name, + { id }, + meshEdgesEdgeAttributeRange(id), + ) }, }, ) } function meshEdgesEdgeAttributeColorMap(id) { - const edge = meshEdgesStyle(id).coloring.edge - return edge ? edge.colorMap : null + const name = meshEdgesEdgeAttributeName(id) + const saved_preset = meshEdgesStyle(id).coloring.edge.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshEdgesEdgeAttributeColorMap( id, @@ -374,10 +358,9 @@ export function useMeshEdgesStyle() { } if (!mesh_edges_schemas.edge_color_map) { console.warn("setMeshEdgesEdgeAttributeColorMap: RPC not available") - if (!coloring_style.edge) { - coloring_style.edge = {} - } - coloring_style.edge.colorMap = colorMapName + const name = coloring_style.edge.name + const saved_preset = coloring_style.edge.attributes[name] + saved_preset.colorMap = colorMapName return Promise.resolve() } return viewerStore.request( @@ -385,10 +368,9 @@ export function useMeshEdgesStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.edge) { - coloring_style.edge = {} - } - coloring_style.edge.colorMap = colorMapName + const name = coloring_style.edge.name + const saved_preset = coloring_style.edge.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshEdgesEdgeAttributeColorMap.name, { id, colorMapName, diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index e43eb012..884f4335 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -52,26 +52,30 @@ export function useMeshPointsStyle() { if (type === "color") { return setMeshPointsColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex?.name === undefined) { + const name = coloring.vertex.name + if (name === undefined) { return Promise.resolve() } - return setMeshPointsVertexAttributeName(id, coloring.vertex.name).then( + const attributes = coloring.vertex.attributes + const minimum = attributes[name].minimum + const maximum = attributes[name].maximum + return setMeshPointsVertexAttributeName(id, name).then( () => { if ( - coloring.vertex.minimum !== undefined && - coloring.vertex.maximum !== undefined + minimum !== undefined && + maximum !== undefined ) { return setMeshPointsVertexAttributeRange( id, - coloring.vertex.minimum, - coloring.vertex.maximum, + minimum, + maximum, ).then(() => { if (coloring.vertex.colorMap) { return setMeshPointsVertexAttributeColorMap( id, coloring.vertex.colorMap, - coloring.vertex.minimum, - coloring.vertex.maximum, + minimum, + maximum, ) } }) @@ -79,7 +83,7 @@ export function useMeshPointsStyle() { }, ) } else { - return Promise.resolve() + throw new Error("Unknown active coloring type: " + type) } } @@ -110,8 +114,7 @@ export function useMeshPointsStyle() { return setMeshPointsVertexAttributeName(id, vertex_attribute.name) } function meshPointsVertexAttributeName(id) { - const vertex = meshPointsStyle(id).coloring.vertex - return vertex ? vertex.name : "" + return meshPointsStyle(id).coloring.vertex.name } function setMeshPointsVertexAttributeName(id, name, defaultMin, defaultMax) { const coloring_style = meshPointsStyle(id).coloring @@ -120,74 +123,51 @@ export function useMeshPointsStyle() { { id, name }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - const previousName = coloring_style.vertex.name - if (previousName) { - if (!coloring_style.vertex.attributes) { - coloring_style.vertex.attributes = {} - } - coloring_style.vertex.attributes[previousName] = { - minimum: coloring_style.vertex.minimum, - maximum: coloring_style.vertex.maximum, - colorMap: coloring_style.vertex.colorMap, - } - } - + const saved_preset = coloring_style.vertex.attributes[name] coloring_style.vertex.name = name - if ( - coloring_style.vertex.attributes && - coloring_style.vertex.attributes[name] - ) { - const saved = coloring_style.vertex.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshPointsVertexAttributeRange( - id, - saved.minimum, - saved.maximum, - ) - if (saved.colorMap) { - setMeshPointsVertexAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + if (saved_preset) { + let minimum, maximum, colorMap + if (saved_preset.minimum !== undefined && saved_preset.maximum !== undefined) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshPointsVertexAttributeRange(id, defaultMin, defaultMax) - setMeshPointsVertexAttributeColorMap( - id, - "Cool to Warm", - defaultMin, - defaultMax, - ) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" } - console.log(setMeshPointsVertexAttributeName.name, { id }, name) + setMeshPointsVertexAttributeRange(id, minimum, maximum) + setMeshPointsVertexAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + + console.log(setMeshPointsVertexAttributeName.name, { id }, meshPointsVertexAttributeName(id)) }, }, ) } function meshPointsVertexAttributeRange(id) { - const vertex = meshPointsStyle(id).coloring.vertex - return vertex ? [vertex.minimum, vertex.maximum] : [0, 1] + const name = meshPointsVertexAttributeName(id) + const saved_preset = meshPointsStyle(id).coloring.vertex.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshPointsVertexAttributeRange(id, min, max) { + function setMeshPointsVertexAttributeRange(id, minimum, maximum) { const coloring_style = meshPointsStyle(id).coloring return viewerStore.request( mesh_points_schemas.attribute.vertex.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.minimum = min - coloring_style.vertex.maximum = max - console.log(setMeshPointsVertexAttributeRange.name, { id, min, max }) + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log(setMeshPointsVertexAttributeRange.name, { id }, meshPointsVertexAttributeRange(id)) }, }, ) @@ -212,10 +192,9 @@ export function useMeshPointsStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.colorMap = colorMapName + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshPointsVertexAttributeColorMap.name, { id, colorMapName, diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 61713a44..6a742d8b 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -104,85 +104,76 @@ export function useMeshPolygonsStyle() { { id, name }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - const previousName = coloring_style.vertex.name - if (previousName) { - if (!coloring_style.vertex.attributes) { - coloring_style.vertex.attributes = {} - } - coloring_style.vertex.attributes[previousName] = { - minimum: coloring_style.vertex.minimum, - maximum: coloring_style.vertex.maximum, - colorMap: coloring_style.vertex.colorMap, - } - } - + const saved_preset = coloring_style.vertex.attributes[name] coloring_style.vertex.name = name - if ( - coloring_style.vertex.attributes && - coloring_style.vertex.attributes[name] - ) { - const saved = coloring_style.vertex.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshPolygonsVertexAttributeRange( - id, - saved.minimum, - saved.maximum, - ) - if (saved.colorMap) { - setMeshPolygonsVertexAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshPolygonsVertexAttributeRange(id, defaultMin, defaultMax) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.vertex.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshPolygonsVertexAttributeRange(id, minimum, maximum) setMeshPolygonsVertexAttributeColorMap( id, - "Cool to Warm", - defaultMin, - defaultMax, + colorMap, + minimum, + maximum, ) } - console.log(setMeshPolygonsVertexAttributeName.name, { id }, name) + console.log( + setMeshPolygonsVertexAttributeName.name, + { id }, + meshPolygonsVertexAttributeName(id), + ) }, }, ) } function meshPolygonsVertexAttributeRange(id) { - const vertex = meshPolygonsStyle(id).coloring.vertex - return vertex ? [vertex.minimum, vertex.maximum] : [0, 1] + const name = meshPolygonsVertexAttributeName(id) + const saved_preset = meshPolygonsStyle(id).coloring.vertex.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshPolygonsVertexAttributeRange(id, min, max) { + function setMeshPolygonsVertexAttributeRange(id, minimum, maximum) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.vertex.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.minimum = min - coloring_style.vertex.maximum = max - console.log(setMeshPolygonsVertexAttributeRange.name, { - id, - min, - max, - }) + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshPolygonsVertexAttributeRange.name, + { id }, + meshPolygonsVertexAttributeRange(id), + ) }, }, ) } function meshPolygonsVertexAttributeColorMap(id) { - const vertex = meshPolygonsStyle(id).coloring.vertex - return vertex ? vertex.colorMap : null + const name = meshPolygonsVertexAttributeName(id) + const saved_preset = meshPolygonsStyle(id).coloring.vertex.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshPolygonsVertexAttributeColorMap( id, @@ -200,10 +191,9 @@ export function useMeshPolygonsStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.colorMap = colorMapName + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.colorMap = colorMapName hybridViewerStore.remoteRender() console.log(setMeshPolygonsVertexAttributeColorMap.name, { id, @@ -236,85 +226,76 @@ export function useMeshPolygonsStyle() { { id, name }, { response_function: () => { - if (!coloring_style.polygon) { - coloring_style.polygon = {} - } - const previousName = coloring_style.polygon.name - if (previousName) { - if (!coloring_style.polygon.attributes) { - coloring_style.polygon.attributes = {} - } - coloring_style.polygon.attributes[previousName] = { - minimum: coloring_style.polygon.minimum, - maximum: coloring_style.polygon.maximum, - colorMap: coloring_style.polygon.colorMap, - } - } - + const saved_preset = coloring_style.polygon.attributes[name] coloring_style.polygon.name = name - if ( - coloring_style.polygon.attributes && - coloring_style.polygon.attributes[name] - ) { - const saved = coloring_style.polygon.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshPolygonsPolygonAttributeRange( - id, - saved.minimum, - saved.maximum, - ) - if (saved.colorMap) { - setMeshPolygonsPolygonAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshPolygonsPolygonAttributeRange(id, defaultMin, defaultMax) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.polygon.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshPolygonsPolygonAttributeRange(id, minimum, maximum) setMeshPolygonsPolygonAttributeColorMap( id, - "Cool to Warm", - defaultMin, - defaultMax, + colorMap, + minimum, + maximum, ) } - console.log(setMeshPolygonsPolygonAttributeName.name, { id }, name) + console.log( + setMeshPolygonsPolygonAttributeName.name, + { id }, + meshPolygonsPolygonAttributeName(id), + ) }, }, ) } function meshPolygonsPolygonAttributeRange(id) { - const polygon = meshPolygonsStyle(id).coloring.polygon - return polygon ? [polygon.minimum, polygon.maximum] : [0, 1] + const name = meshPolygonsPolygonAttributeName(id) + const saved_preset = meshPolygonsStyle(id).coloring.polygon.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshPolygonsPolygonAttributeRange(id, min, max) { + function setMeshPolygonsPolygonAttributeRange(id, minimum, maximum) { const coloring_style = meshPolygonsStyle(id).coloring return viewerStore.request( mesh_polygons_schemas.attribute.polygon.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.polygon) { - coloring_style.polygon = {} - } - coloring_style.polygon.minimum = min - coloring_style.polygon.maximum = max - console.log(setMeshPolygonsPolygonAttributeRange.name, { - id, - min, - max, - }) + const name = coloring_style.polygon.name + const saved_preset = coloring_style.polygon.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshPolygonsPolygonAttributeRange.name, + { id }, + meshPolygonsPolygonAttributeRange(id), + ) }, }, ) } function meshPolygonsPolygonAttributeColorMap(id) { - const polygon = meshPolygonsStyle(id).coloring.polygon - return polygon ? polygon.colorMap : null + const name = meshPolygonsPolygonAttributeName(id) + const saved_preset = meshPolygonsStyle(id).coloring.polygon.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshPolygonsPolygonAttributeColorMap( id, @@ -332,10 +313,9 @@ export function useMeshPolygonsStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.polygon) { - coloring_style.polygon = {} - } - coloring_style.polygon.colorMap = colorMapName + const name = coloring_style.polygon.name + const saved_preset = coloring_style.polygon.attributes[name] + saved_preset.colorMap = colorMapName hybridViewerStore.remoteRender() console.log(setMeshPolygonsPolygonAttributeColorMap.name, { id, @@ -365,62 +345,57 @@ export function useMeshPolygonsStyle() { } return setMeshPolygonsTextures(id, coloring.textures) } else if (type === "vertex") { - if (coloring.vertex?.name === undefined) { + const name = coloring.vertex.name + if (name === undefined) { return Promise.resolve() } - return setMeshPolygonsVertexAttributeName(id, coloring.vertex.name).then( - () => { - if ( - coloring.vertex.minimum !== undefined && - coloring.vertex.maximum !== undefined - ) { - return setMeshPolygonsVertexAttributeRange( - id, - coloring.vertex.minimum, - coloring.vertex.maximum, - ).then(() => { - if (coloring.vertex.colorMap) { + const attributes = coloring.vertex.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshPolygonsVertexAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshPolygonsVertexAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { return setMeshPolygonsVertexAttributeColorMap( id, - coloring.vertex.colorMap, - coloring.vertex.minimum, - coloring.vertex.maximum, + colorMap, + minimum, + maximum, ) } - }) - } - }, - ) + }, + ) + } + }) } else if (type === "polygon") { - if (coloring.polygon?.name === undefined) { + const name = coloring.polygon.name + if (name === undefined) { return Promise.resolve() } - return setMeshPolygonsPolygonAttributeName( - id, - coloring.polygon.name, - ).then(() => { - if ( - coloring.polygon.minimum !== undefined && - coloring.polygon.maximum !== undefined - ) { - return setMeshPolygonsPolygonAttributeRange( - id, - coloring.polygon.minimum, - coloring.polygon.maximum, - ).then(() => { - if (coloring.polygon.colorMap) { - return setMeshPolygonsPolygonAttributeColorMap( - id, - coloring.polygon.colorMap, - coloring.polygon.minimum, - coloring.polygon.maximum, - ) - } - }) + const attributes = coloring.polygon.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshPolygonsPolygonAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshPolygonsPolygonAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { + return setMeshPolygonsPolygonAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + } + }, + ) } }) } else { - return Promise.resolve() + throw new Error("Unknown active coloring type: " + type) } } diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index 9a175241..ab4575b8 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -51,62 +51,59 @@ export function useMeshPolyhedraStyle() { if (type === "color") { return setMeshPolyhedraColor(id, coloring.color) } else if (type === "vertex") { - if (coloring.vertex?.name === undefined) { + const name = coloring.vertex.name + if (name === undefined) { return Promise.resolve() } - return setMeshPolyhedraVertexAttributeName(id, coloring.vertex.name).then( - () => { - if ( - coloring.vertex.minimum !== undefined && - coloring.vertex.maximum !== undefined - ) { - return setMeshPolyhedraVertexAttributeRange( - id, - coloring.vertex.minimum, - coloring.vertex.maximum, - ).then(() => { - if (coloring.vertex.colorMap) { + const attributes = coloring.vertex.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshPolyhedraVertexAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshPolyhedraVertexAttributeRange(id, minimum, maximum).then( + () => { + if (colorMap) { return setMeshPolyhedraVertexAttributeColorMap( id, - coloring.vertex.colorMap, - coloring.vertex.minimum, - coloring.vertex.maximum, + colorMap, + minimum, + maximum, ) } - }) - } - }, - ) + }, + ) + } + }) } else if (type === "polyhedron") { - if (coloring.polyhedron?.name === undefined) { + const name = coloring.polyhedron.name + if (name === undefined) { return Promise.resolve() } - return setMeshPolyhedraPolyhedronAttributeName( - id, - coloring.polyhedron.name, - ).then(() => { - if ( - coloring.polyhedron.minimum !== undefined && - coloring.polyhedron.maximum !== undefined - ) { + const attributes = coloring.polyhedron.attributes + const minimum = attributes[name]?.minimum + const maximum = attributes[name]?.maximum + const colorMap = attributes[name]?.colorMap + return setMeshPolyhedraPolyhedronAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { return setMeshPolyhedraPolyhedronAttributeRange( id, - coloring.polyhedron.minimum, - coloring.polyhedron.maximum, + minimum, + maximum, ).then(() => { - if (coloring.polyhedron.colorMap) { + if (colorMap) { return setMeshPolyhedraPolyhedronAttributeColorMap( id, - coloring.polyhedron.colorMap, - coloring.polyhedron.minimum, - coloring.polyhedron.maximum, + colorMap, + minimum, + maximum, ) } }) } }) } else { - return Promise.resolve() + throw new Error("Unknown active coloring type: " + type) } } @@ -153,85 +150,76 @@ export function useMeshPolyhedraStyle() { { id, name }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - const previousName = coloring_style.vertex.name - if (previousName) { - if (!coloring_style.vertex.attributes) { - coloring_style.vertex.attributes = {} - } - coloring_style.vertex.attributes[previousName] = { - minimum: coloring_style.vertex.minimum, - maximum: coloring_style.vertex.maximum, - colorMap: coloring_style.vertex.colorMap, - } - } - + const saved_preset = coloring_style.vertex.attributes[name] coloring_style.vertex.name = name - if ( - coloring_style.vertex.attributes && - coloring_style.vertex.attributes[name] - ) { - const saved = coloring_style.vertex.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshPolyhedraVertexAttributeRange( - id, - saved.minimum, - saved.maximum, - ) - if (saved.colorMap) { - setMeshPolyhedraVertexAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshPolyhedraVertexAttributeRange(id, defaultMin, defaultMax) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.vertex.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshPolyhedraVertexAttributeRange(id, minimum, maximum) setMeshPolyhedraVertexAttributeColorMap( id, - "Cool to Warm", - defaultMin, - defaultMax, + colorMap, + minimum, + maximum, ) } - console.log(setMeshPolyhedraVertexAttributeName.name, { id }, name) + console.log( + setMeshPolyhedraVertexAttributeName.name, + { id }, + meshPolyhedraVertexAttributeName(id), + ) }, }, ) } function meshPolyhedraVertexAttributeRange(id) { - const vertex = meshPolyhedraStyle(id).coloring.vertex - return vertex ? [vertex.minimum, vertex.maximum] : [0, 1] + const name = meshPolyhedraVertexAttributeName(id) + const saved_preset = meshPolyhedraStyle(id).coloring.vertex.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshPolyhedraVertexAttributeRange(id, min, max) { + function setMeshPolyhedraVertexAttributeRange(id, minimum, maximum) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.vertex.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.minimum = min - coloring_style.vertex.maximum = max - console.log(setMeshPolyhedraVertexAttributeRange.name, { - id, - min, - max, - }) + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshPolyhedraVertexAttributeRange.name, + { id }, + meshPolyhedraVertexAttributeRange(id), + ) }, }, ) } function meshPolyhedraVertexAttributeColorMap(id) { - const vertex = meshPolyhedraStyle(id).coloring.vertex - return vertex ? vertex.colorMap : null + const name = meshPolyhedraVertexAttributeName(id) + const saved_preset = meshPolyhedraStyle(id).coloring.vertex.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshPolyhedraVertexAttributeColorMap( id, @@ -249,10 +237,9 @@ export function useMeshPolyhedraStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.vertex) { - coloring_style.vertex = {} - } - coloring_style.vertex.colorMap = colorMapName + const name = coloring_style.vertex.name + const saved_preset = coloring_style.vertex.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshPolyhedraVertexAttributeColorMap.name, { id, colorMapName, @@ -287,89 +274,78 @@ export function useMeshPolyhedraStyle() { { id, name }, { response_function: () => { - if (!coloring_style.polyhedron) { - coloring_style.polyhedron = {} - } - const previousName = coloring_style.polyhedron.name - if (previousName) { - if (!coloring_style.polyhedron.attributes) { - coloring_style.polyhedron.attributes = {} - } - coloring_style.polyhedron.attributes[previousName] = { - minimum: coloring_style.polyhedron.minimum, - maximum: coloring_style.polyhedron.maximum, - colorMap: coloring_style.polyhedron.colorMap, - } - } - + const saved_preset = coloring_style.polyhedron.attributes[name] coloring_style.polyhedron.name = name - if ( - coloring_style.polyhedron.attributes && - coloring_style.polyhedron.attributes[name] - ) { - const saved = coloring_style.polyhedron.attributes[name] - if (saved.minimum !== undefined && saved.maximum !== undefined) { - setMeshPolyhedraPolyhedronAttributeRange( - id, - saved.minimum, - saved.maximum, - ) - if (saved.colorMap) { - setMeshPolyhedraPolyhedronAttributeColorMap( - id, - saved.colorMap, - saved.minimum, - saved.maximum, - ) - } + let minimum, maximum, colorMap + if (saved_preset) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { + minimum = saved_preset.minimum + maximum = saved_preset.maximum + colorMap = saved_preset.colorMap } } else if (defaultMin !== undefined && defaultMax !== undefined) { - setMeshPolyhedraPolyhedronAttributeRange(id, defaultMin, defaultMax) + minimum = defaultMin + maximum = defaultMax + colorMap = "Cool to Warm" + coloring_style.polyhedron.attributes[name] = { + minimum, + maximum, + colorMap, + } + } + if (minimum !== undefined && maximum !== undefined) { + setMeshPolyhedraPolyhedronAttributeRange(id, minimum, maximum) setMeshPolyhedraPolyhedronAttributeColorMap( id, - "Cool to Warm", - defaultMin, - defaultMax, + colorMap, + minimum, + maximum, ) } console.log( setMeshPolyhedraPolyhedronAttributeName.name, { id }, - name, + meshPolyhedraPolyhedronAttributeName(id), ) }, }, ) } function meshPolyhedraPolyhedronAttributeRange(id) { - const polyhedron = meshPolyhedraStyle(id).coloring.polyhedron - return polyhedron ? [polyhedron.minimum, polyhedron.maximum] : [0, 1] + const name = meshPolyhedraPolyhedronAttributeName(id) + const saved_preset = + meshPolyhedraStyle(id).coloring.polyhedron.attributes[name] + return saved_preset ? [saved_preset.minimum, saved_preset.maximum] : [0, 1] } - function setMeshPolyhedraPolyhedronAttributeRange(id, min, max) { + function setMeshPolyhedraPolyhedronAttributeRange(id, minimum, maximum) { const coloring_style = meshPolyhedraStyle(id).coloring return viewerStore.request( mesh_polyhedra_schemas.attribute.polyhedron.scalar_range, - { id, minimum: min, maximum: max }, + { id, minimum, maximum }, { response_function: () => { - if (!coloring_style.polyhedron) { - coloring_style.polyhedron = {} - } - coloring_style.polyhedron.minimum = min - coloring_style.polyhedron.maximum = max - console.log(setMeshPolyhedraPolyhedronAttributeRange.name, { - id, - min, - max, - }) + const name = coloring_style.polyhedron.name + const saved_preset = coloring_style.polyhedron.attributes[name] + saved_preset.minimum = minimum + saved_preset.maximum = maximum + console.log( + setMeshPolyhedraPolyhedronAttributeRange.name, + { id }, + meshPolyhedraPolyhedronAttributeRange(id), + ) }, }, ) } function meshPolyhedraPolyhedronAttributeColorMap(id) { - const polyhedron = meshPolyhedraStyle(id).coloring.polyhedron - return polyhedron ? polyhedron.colorMap : null + const name = meshPolyhedraPolyhedronAttributeName(id) + const saved_preset = + meshPolyhedraStyle(id).coloring.polyhedron.attributes[name] + return saved_preset ? saved_preset.colorMap : null } function setMeshPolyhedraPolyhedronAttributeColorMap( id, @@ -387,10 +363,9 @@ export function useMeshPolyhedraStyle() { { id, points, minimum, maximum }, { response_function: () => { - if (!coloring_style.polyhedron) { - coloring_style.polyhedron = {} - } - coloring_style.polyhedron.colorMap = colorMapName + const name = coloring_style.polyhedron.name + const saved_preset = coloring_style.polyhedron.attributes[name] + saved_preset.colorMap = colorMapName console.log(setMeshPolyhedraPolyhedronAttributeColorMap.name, { id, colorMapName, From a95d9db5df6e3c45f67f26c54a8f5deb98a9999f Mon Sep 17 00:00:00 2001 From: SpliiT <106495600+SpliiT@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:42:08 +0000 Subject: [PATCH 40/41] Apply prepare changes --- app/utils/default_styles.js | 3 +- internal/stores/mesh/points.js | 47 +++++++++++++++---------------- internal/stores/mesh/polygons.js | 26 +++++++++-------- internal/stores/mesh/polyhedra.js | 26 +++++++++-------- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/app/utils/default_styles.js b/app/utils/default_styles.js index 0caf4d14..cfad7e90 100644 --- a/app/utils/default_styles.js +++ b/app/utils/default_styles.js @@ -35,8 +35,7 @@ const meshPointsDefaultStyle = ( vertex: { name: undefined, - - attributes: {} + attributes: {}, }, }, size, diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 884f4335..83e60088 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -59,17 +59,10 @@ export function useMeshPointsStyle() { const attributes = coloring.vertex.attributes const minimum = attributes[name].minimum const maximum = attributes[name].maximum - return setMeshPointsVertexAttributeName(id, name).then( - () => { - if ( - minimum !== undefined && - maximum !== undefined - ) { - return setMeshPointsVertexAttributeRange( - id, - minimum, - maximum, - ).then(() => { + return setMeshPointsVertexAttributeName(id, name).then(() => { + if (minimum !== undefined && maximum !== undefined) { + return setMeshPointsVertexAttributeRange(id, minimum, maximum).then( + () => { if (coloring.vertex.colorMap) { return setMeshPointsVertexAttributeColorMap( id, @@ -78,10 +71,10 @@ export function useMeshPointsStyle() { maximum, ) } - }) - } - }, - ) + }, + ) + } + }) } else { throw new Error("Unknown active coloring type: " + type) } @@ -128,7 +121,10 @@ export function useMeshPointsStyle() { if (saved_preset) { let minimum, maximum, colorMap - if (saved_preset.minimum !== undefined && saved_preset.maximum !== undefined) { + if ( + saved_preset.minimum !== undefined && + saved_preset.maximum !== undefined + ) { minimum = saved_preset.minimum maximum = saved_preset.maximum colorMap = saved_preset.colorMap @@ -139,14 +135,13 @@ export function useMeshPointsStyle() { colorMap = "Cool to Warm" } setMeshPointsVertexAttributeRange(id, minimum, maximum) - setMeshPointsVertexAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ) + setMeshPointsVertexAttributeColorMap(id, colorMap, minimum, maximum) - console.log(setMeshPointsVertexAttributeName.name, { id }, meshPointsVertexAttributeName(id)) + console.log( + setMeshPointsVertexAttributeName.name, + { id }, + meshPointsVertexAttributeName(id), + ) }, }, ) @@ -167,7 +162,11 @@ export function useMeshPointsStyle() { const saved_preset = coloring_style.vertex.attributes[name] saved_preset.minimum = minimum saved_preset.maximum = maximum - console.log(setMeshPointsVertexAttributeRange.name, { id }, meshPointsVertexAttributeRange(id)) + console.log( + setMeshPointsVertexAttributeRange.name, + { id }, + meshPointsVertexAttributeRange(id), + ) }, }, ) diff --git a/internal/stores/mesh/polygons.js b/internal/stores/mesh/polygons.js index 6a742d8b..bf1aa79d 100644 --- a/internal/stores/mesh/polygons.js +++ b/internal/stores/mesh/polygons.js @@ -380,18 +380,20 @@ export function useMeshPolygonsStyle() { const colorMap = attributes[name]?.colorMap return setMeshPolygonsPolygonAttributeName(id, name).then(() => { if (minimum !== undefined && maximum !== undefined) { - return setMeshPolygonsPolygonAttributeRange(id, minimum, maximum).then( - () => { - if (colorMap) { - return setMeshPolygonsPolygonAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ) - } - }, - ) + return setMeshPolygonsPolygonAttributeRange( + id, + minimum, + maximum, + ).then(() => { + if (colorMap) { + return setMeshPolygonsPolygonAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + } + }) } }) } else { diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index ab4575b8..c4ffbbcc 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -61,18 +61,20 @@ export function useMeshPolyhedraStyle() { const colorMap = attributes[name]?.colorMap return setMeshPolyhedraVertexAttributeName(id, name).then(() => { if (minimum !== undefined && maximum !== undefined) { - return setMeshPolyhedraVertexAttributeRange(id, minimum, maximum).then( - () => { - if (colorMap) { - return setMeshPolyhedraVertexAttributeColorMap( - id, - colorMap, - minimum, - maximum, - ) - } - }, - ) + return setMeshPolyhedraVertexAttributeRange( + id, + minimum, + maximum, + ).then(() => { + if (colorMap) { + return setMeshPolyhedraVertexAttributeColorMap( + id, + colorMap, + minimum, + maximum, + ) + } + }) } }) } else if (type === "polyhedron") { From 543f5d2fa3f8bfcde050cd09253b3ef061ffcb72 Mon Sep 17 00:00:00 2001 From: SpliiT Date: Thu, 5 Feb 2026 17:59:14 +0100 Subject: [PATCH 41/41] Last commit of the day --- .../EdgedCurve/SpecificEdgesOptions.vue | 31 ++--- .../Viewer/Generic/Mesh/CellsOptions.vue | 31 ++--- .../Viewer/Options/CellAttributeSelector.vue | 48 ++++---- .../Viewer/Options/ColoringTypeSelector.vue | 29 ----- .../Viewer/Options/EdgeAttributeSelector.vue | 48 ++++---- .../Options/PolygonAttributeSelector.vue | 48 ++++---- .../Options/PolyhedronAttributeSelector.vue | 48 ++++---- .../Options/VertexAttributeSelector.vue | 52 ++++----- .../Viewer/PointSet/SpecificPointsOptions.vue | 16 +-- .../SpecificPolygonsOptions.vue | 29 ++--- .../Viewer/Solid/SpecificPolyhedraOptions.vue | 31 ++--- internal/stores/mesh/cells.js | 100 +++++++--------- internal/stores/mesh/edges.js | 107 +++++++---------- internal/stores/mesh/points.js | 49 ++++---- internal/stores/mesh/polygons.js | 110 +++++++----------- internal/stores/mesh/polyhedra.js | 110 +++++++----------- 16 files changed, 363 insertions(+), 524 deletions(-) diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue index b5dada05..f937e125 100644 --- a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -46,7 +46,10 @@ }) const vertex_attribute_name = computed({ get: () => dataStyleStore.meshEdgesVertexAttributeName(id.value), - set: () => {}, + set: (newValue) => { + dataStyleStore.setMeshEdgesVertexAttributeName(id.value, newValue) + hybridViewerStore.remoteRender() + }, }) const vertex_attribute_range = computed({ get: () => dataStyleStore.meshEdgesVertexAttributeRange(id.value), @@ -83,7 +86,10 @@ }) const edge_attribute_name = computed({ get: () => dataStyleStore.meshEdgesEdgeAttributeName(id.value), - set: () => {}, + set: (newValue) => { + dataStyleStore.setMeshEdgesEdgeAttributeName(id.value, newValue) + hybridViewerStore.remoteRender() + }, }) const edge_attribute_range = computed({ get: () => dataStyleStore.meshEdgesEdgeAttributeRange(id.value), @@ -118,25 +124,6 @@ hybridViewerStore.remoteRender() }, }) - - function onVertexAttributeSelected(data) { - dataStyleStore.setMeshEdgesVertexAttributeName( - id.value, - data.name, - data.defaultMin, - data.defaultMax, - ) - hybridViewerStore.remoteRender() - } - function onEdgeAttributeSelected(data) { - dataStyleStore.setMeshEdgesEdgeAttributeName( - id.value, - data.name, - data.defaultMin, - data.defaultMax, - ) - hybridViewerStore.remoteRender() - } diff --git a/app/components/Viewer/Options/CellAttributeSelector.vue b/app/components/Viewer/Options/CellAttributeSelector.vue index 5ca8477d..45a51800 100644 --- a/app/components/Viewer/Options/CellAttributeSelector.vue +++ b/app/components/Viewer/Options/CellAttributeSelector.vue @@ -13,12 +13,6 @@ const cell_attribute_color_map = defineModel("cell_attribute_color_map") const cell_attributes = ref([]) - const selectedName = ref(cell_attribute_name.value) - - watch(cell_attribute_name, (newVal) => { - selectedName.value = newVal - }) - const props = defineProps({ id: { type: String, required: true }, }) @@ -52,31 +46,39 @@ ) } - const emit = defineEmits(["attribute-selected"]) - - watch(selectedName, (newName) => { - if (!newName) return - const attribute = cell_attributes.value.find( - (attr) => attr.attribute_name === newName, - ) - if (attribute && attribute.min_value !== -1 && attribute.max_value !== -1) { - emit("attribute-selected", { - name: newName, - defaultMin: attribute.min_value, - defaultMax: attribute.max_value, - }) - } - }) const currentAttribute = computed(() => { return cell_attributes.value.find( - (attr) => attr.attribute_name === selectedName.value, + (attr) => attr.attribute_name === cell_attribute_name.value, ) }) + + watch(cell_attribute_name, (newName) => { + if (newName) { + const attr = cell_attributes.value.find( + (a) => a.attribute_name === newName, + ) + if ( + attr && + attr.min_value !== undefined && + attr.max_value !== undefined + ) { + const currentRange = cell_attribute_range.value + const hasNoSavedPreset = + !currentRange || (currentRange[0] === 0 && currentRange[1] === 1) + if (hasNoSavedPreset) { + if (!cell_attribute_color_map.value) { + cell_attribute_color_map.value = "Cool to Warm" + } + cell_attribute_range.value = [attr.min_value, attr.max_value] + } + } + } + }) diff --git a/app/components/Viewer/Options/EdgeAttributeSelector.vue b/app/components/Viewer/Options/EdgeAttributeSelector.vue index 96e196df..bc4d8661 100644 --- a/app/components/Viewer/Options/EdgeAttributeSelector.vue +++ b/app/components/Viewer/Options/EdgeAttributeSelector.vue @@ -13,12 +13,6 @@ const edge_attribute_color_map = defineModel("edge_attribute_color_map") const edge_attributes = ref([]) - const selectedName = ref(edge_attribute_name.value) - - watch(edge_attribute_name, (newVal) => { - selectedName.value = newVal - }) - const props = defineProps({ id: { type: String, required: true }, }) @@ -52,31 +46,39 @@ ) } - const emit = defineEmits(["attribute-selected"]) - - watch(selectedName, (newName) => { - if (!newName) return - const attribute = edge_attributes.value.find( - (attr) => attr.attribute_name === newName, - ) - if (attribute && attribute.min_value !== -1 && attribute.max_value !== -1) { - emit("attribute-selected", { - name: newName, - defaultMin: attribute.min_value, - defaultMax: attribute.max_value, - }) - } - }) const currentAttribute = computed(() => { return edge_attributes.value.find( - (attr) => attr.attribute_name === selectedName.value, + (attr) => attr.attribute_name === edge_attribute_name.value, ) }) + + watch(edge_attribute_name, (newName) => { + if (newName) { + const attr = edge_attributes.value.find( + (a) => a.attribute_name === newName, + ) + if ( + attr && + attr.min_value !== undefined && + attr.max_value !== undefined + ) { + const currentRange = edge_attribute_range.value + const hasNoSavedPreset = + !currentRange || (currentRange[0] === 0 && currentRange[1] === 1) + if (hasNoSavedPreset) { + if (!edge_attribute_color_map.value) { + edge_attribute_color_map.value = "Cool to Warm" + } + edge_attribute_range.value = [attr.min_value, attr.max_value] + } + } + } + })