diff --git a/.gitignore b/.gitignore index 4aae54c0..18245e49 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,4 @@ logs .pytest_cache __snapshots__ coverage -# package-lock.json +# package-lock.json \ No newline at end of file diff --git a/assets/viewer_svgs/edged_curve_edges.svg b/assets/viewer_svgs/edged_curve_edges.svg new file mode 100644 index 00000000..750587ef --- /dev/null +++ b/assets/viewer_svgs/edged_curve_edges.svg @@ -0,0 +1,67 @@ + + + + + + + + + + image/svg+xml + + + + + + + + diff --git a/assets/viewer_svgs/edged_curve_points.svg b/assets/viewer_svgs/edged_curve_points.svg new file mode 100644 index 00000000..c1c113cb --- /dev/null +++ b/assets/viewer_svgs/edged_curve_points.svg @@ -0,0 +1,95 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/assets/viewer_svgs/grid_2d_cells.svg b/assets/viewer_svgs/grid_2d_cells.svg new file mode 100644 index 00000000..b50c26aa --- /dev/null +++ b/assets/viewer_svgs/grid_2d_cells.svg @@ -0,0 +1,78 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/viewer_svgs/grid_2d_edges.svg b/assets/viewer_svgs/grid_2d_edges.svg new file mode 100644 index 00000000..eb9757d9 --- /dev/null +++ b/assets/viewer_svgs/grid_2d_edges.svg @@ -0,0 +1,71 @@ + + + + + + + + + + image/svg+xml + + + + + + + + diff --git a/assets/viewer_svgs/grid_2d_points.svg b/assets/viewer_svgs/grid_2d_points.svg new file mode 100644 index 00000000..835f3b9e --- /dev/null +++ b/assets/viewer_svgs/grid_2d_points.svg @@ -0,0 +1,108 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/grid_3d_cells.svg b/assets/viewer_svgs/grid_3d_cells.svg new file mode 100644 index 00000000..c2b5e118 --- /dev/null +++ b/assets/viewer_svgs/grid_3d_cells.svg @@ -0,0 +1,76 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/assets/viewer_svgs/grid_3d_edges.svg b/assets/viewer_svgs/grid_3d_edges.svg new file mode 100644 index 00000000..470a2135 --- /dev/null +++ b/assets/viewer_svgs/grid_3d_edges.svg @@ -0,0 +1,72 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/viewer_svgs/grid_3d_facets.svg b/assets/viewer_svgs/grid_3d_facets.svg new file mode 100644 index 00000000..ae1c511f --- /dev/null +++ b/assets/viewer_svgs/grid_3d_facets.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/grid_3d_points.svg b/assets/viewer_svgs/grid_3d_points.svg new file mode 100644 index 00000000..5a25cf31 --- /dev/null +++ b/assets/viewer_svgs/grid_3d_points.svg @@ -0,0 +1,172 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/point_set_points.svg b/assets/viewer_svgs/point_set_points.svg new file mode 100644 index 00000000..6b6014f3 --- /dev/null +++ b/assets/viewer_svgs/point_set_points.svg @@ -0,0 +1,86 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/assets/viewer_svgs/solid_edges.svg b/assets/viewer_svgs/solid_edges.svg new file mode 100644 index 00000000..e2ca7198 --- /dev/null +++ b/assets/viewer_svgs/solid_edges.svg @@ -0,0 +1,96 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/solid_facets.svg b/assets/viewer_svgs/solid_facets.svg new file mode 100644 index 00000000..dcb276b4 --- /dev/null +++ b/assets/viewer_svgs/solid_facets.svg @@ -0,0 +1,119 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/solid_points.svg b/assets/viewer_svgs/solid_points.svg new file mode 100644 index 00000000..f1ace08b --- /dev/null +++ b/assets/viewer_svgs/solid_points.svg @@ -0,0 +1,134 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/solid_polyhedra.svg b/assets/viewer_svgs/solid_polyhedra.svg new file mode 100644 index 00000000..4adef1db --- /dev/null +++ b/assets/viewer_svgs/solid_polyhedra.svg @@ -0,0 +1,103 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/surface_edges.svg b/assets/viewer_svgs/surface_edges.svg new file mode 100644 index 00000000..9848875d --- /dev/null +++ b/assets/viewer_svgs/surface_edges.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/assets/viewer_svgs/surface_points.svg b/assets/viewer_svgs/surface_points.svg new file mode 100644 index 00000000..f8701ff4 --- /dev/null +++ b/assets/viewer_svgs/surface_points.svg @@ -0,0 +1,115 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/assets/viewer_svgs/surface_triangles.svg b/assets/viewer_svgs/surface_triangles.svg new file mode 100644 index 00000000..17c9eb08 --- /dev/null +++ b/assets/viewer_svgs/surface_triangles.svg @@ -0,0 +1,92 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/components/ContextMenu.vue b/components/ContextMenu.vue new file mode 100644 index 00000000..dbcfd11f --- /dev/null +++ b/components/ContextMenu.vue @@ -0,0 +1,123 @@ + + + + + + + + + + + diff --git a/components/ContextMenuItem.vue b/components/ContextMenuItem.vue new file mode 100644 index 00000000..e6ac0d39 --- /dev/null +++ b/components/ContextMenuItem.vue @@ -0,0 +1,90 @@ + + + + + + + + + {{ props.tooltip }} + + + + + + + + + + + + + + diff --git a/components/HybridRenderingView.vue b/components/HybridRenderingView.vue new file mode 100644 index 00000000..1ba0af3a --- /dev/null +++ b/components/HybridRenderingView.vue @@ -0,0 +1,41 @@ + + + + + + + + + + + diff --git a/components/VeaseViewToolbar.vue b/components/VeaseViewToolbar.vue new file mode 100644 index 00000000..0636e8b6 --- /dev/null +++ b/components/VeaseViewToolbar.vue @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/BreadCrumb.vue b/components/Viewer/BreadCrumb.vue new file mode 100644 index 00000000..54c4b9c2 --- /dev/null +++ b/components/Viewer/BreadCrumb.vue @@ -0,0 +1,61 @@ + + + + + + + mdi-file-tree + + / + + {{ + selectedTree && selectedTree.icon + ? selectedTree.icon + : "mdi-shape-outline" + }} + + + Model Explorer ({{ metaDatas.displayed_name }}) + + + + + + mdi-file-tree + + Objects + + + + + + + + + diff --git a/components/Viewer/EdgedCurve/EdgesOptions.vue b/components/Viewer/EdgedCurve/EdgesOptions.vue new file mode 100644 index 00000000..9eef6804 --- /dev/null +++ b/components/Viewer/EdgedCurve/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/EdgedCurve/PointsOptions.vue b/components/Viewer/EdgedCurve/PointsOptions.vue new file mode 100644 index 00000000..b623a7bf --- /dev/null +++ b/components/Viewer/EdgedCurve/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Generic/Mesh/EdgesOptions.vue b/components/Viewer/Generic/Mesh/EdgesOptions.vue new file mode 100644 index 00000000..7efcff08 --- /dev/null +++ b/components/Viewer/Generic/Mesh/EdgesOptions.vue @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/components/Viewer/Generic/Mesh/PointsOptions.vue b/components/Viewer/Generic/Mesh/PointsOptions.vue new file mode 100644 index 00000000..5c4ad9fc --- /dev/null +++ b/components/Viewer/Generic/Mesh/PointsOptions.vue @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/Generic/Mesh/PolygonsOptions.vue b/components/Viewer/Generic/Mesh/PolygonsOptions.vue new file mode 100644 index 00000000..1d24c64f --- /dev/null +++ b/components/Viewer/Generic/Mesh/PolygonsOptions.vue @@ -0,0 +1,65 @@ + + + + + + + + + + + + diff --git a/components/Viewer/Generic/Mesh/PolyhedraOptions.vue b/components/Viewer/Generic/Mesh/PolyhedraOptions.vue new file mode 100644 index 00000000..03fe2c3e --- /dev/null +++ b/components/Viewer/Generic/Mesh/PolyhedraOptions.vue @@ -0,0 +1,58 @@ + + + + + + + + + + + + + diff --git a/components/Viewer/Generic/Model/EdgesOptions.vue b/components/Viewer/Generic/Model/EdgesOptions.vue new file mode 100644 index 00000000..939947ad --- /dev/null +++ b/components/Viewer/Generic/Model/EdgesOptions.vue @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/components/Viewer/Generic/Model/PointsOptions.vue b/components/Viewer/Generic/Model/PointsOptions.vue new file mode 100644 index 00000000..2ac49621 --- /dev/null +++ b/components/Viewer/Generic/Model/PointsOptions.vue @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/Grid/2D/CellsOptions.vue b/components/Viewer/Grid/2D/CellsOptions.vue new file mode 100644 index 00000000..25b00af8 --- /dev/null +++ b/components/Viewer/Grid/2D/CellsOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/components/Viewer/Grid/2D/EdgesOptions.vue b/components/Viewer/Grid/2D/EdgesOptions.vue new file mode 100644 index 00000000..19c975ad --- /dev/null +++ b/components/Viewer/Grid/2D/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Grid/2D/PointsOptions.vue b/components/Viewer/Grid/2D/PointsOptions.vue new file mode 100644 index 00000000..42139a52 --- /dev/null +++ b/components/Viewer/Grid/2D/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Grid/3D/CellsOptions.vue b/components/Viewer/Grid/3D/CellsOptions.vue new file mode 100644 index 00000000..4d9d8e29 --- /dev/null +++ b/components/Viewer/Grid/3D/CellsOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/components/Viewer/Grid/3D/EdgesOptions.vue b/components/Viewer/Grid/3D/EdgesOptions.vue new file mode 100644 index 00000000..e8040fcc --- /dev/null +++ b/components/Viewer/Grid/3D/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Grid/3D/FacetsOptions.vue b/components/Viewer/Grid/3D/FacetsOptions.vue new file mode 100644 index 00000000..5dec27f7 --- /dev/null +++ b/components/Viewer/Grid/3D/FacetsOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/components/Viewer/Grid/3D/PointsOptions.vue b/components/Viewer/Grid/3D/PointsOptions.vue new file mode 100644 index 00000000..383c9ac7 --- /dev/null +++ b/components/Viewer/Grid/3D/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/HybridSolid/EdgesOptions.vue b/components/Viewer/HybridSolid/EdgesOptions.vue new file mode 100644 index 00000000..58bad2d4 --- /dev/null +++ b/components/Viewer/HybridSolid/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/HybridSolid/PointsOptions.vue b/components/Viewer/HybridSolid/PointsOptions.vue new file mode 100644 index 00000000..01320719 --- /dev/null +++ b/components/Viewer/HybridSolid/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/HybridSolid/PolygonsOptions.vue b/components/Viewer/HybridSolid/PolygonsOptions.vue new file mode 100644 index 00000000..67c81a7a --- /dev/null +++ b/components/Viewer/HybridSolid/PolygonsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/HybridSolid/PolyhedraOptions.vue b/components/Viewer/HybridSolid/PolyhedraOptions.vue new file mode 100644 index 00000000..eb21bf47 --- /dev/null +++ b/components/Viewer/HybridSolid/PolyhedraOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Options/ColorPicker.vue b/components/Viewer/Options/ColorPicker.vue new file mode 100644 index 00000000..c0671209 --- /dev/null +++ b/components/Viewer/Options/ColorPicker.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/components/Viewer/Options/ColoringTypeSelector.vue b/components/Viewer/Options/ColoringTypeSelector.vue new file mode 100644 index 00000000..dca239d0 --- /dev/null +++ b/components/Viewer/Options/ColoringTypeSelector.vue @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/Options/PolygonAttributeSelector.vue b/components/Viewer/Options/PolygonAttributeSelector.vue new file mode 100644 index 00000000..a80a02e2 --- /dev/null +++ b/components/Viewer/Options/PolygonAttributeSelector.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/components/Viewer/Options/PolyhedronAttributeSelector.vue b/components/Viewer/Options/PolyhedronAttributeSelector.vue new file mode 100644 index 00000000..485c8ae3 --- /dev/null +++ b/components/Viewer/Options/PolyhedronAttributeSelector.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/components/Viewer/Options/TextureItem.vue b/components/Viewer/Options/TextureItem.vue new file mode 100644 index 00000000..4070bdc7 --- /dev/null +++ b/components/Viewer/Options/TextureItem.vue @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/Options/TexturesSelector.vue b/components/Viewer/Options/TexturesSelector.vue new file mode 100644 index 00000000..66ec8517 --- /dev/null +++ b/components/Viewer/Options/TexturesSelector.vue @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/Options/VertexAttributeSelector.vue b/components/Viewer/Options/VertexAttributeSelector.vue new file mode 100644 index 00000000..b7a6b5bd --- /dev/null +++ b/components/Viewer/Options/VertexAttributeSelector.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/components/Viewer/Options/VisibilitySwitch.vue b/components/Viewer/Options/VisibilitySwitch.vue new file mode 100644 index 00000000..3dd8e9d6 --- /dev/null +++ b/components/Viewer/Options/VisibilitySwitch.vue @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/components/Viewer/PointSet/PointsOptions.vue b/components/Viewer/PointSet/PointsOptions.vue new file mode 100644 index 00000000..0d9369fd --- /dev/null +++ b/components/Viewer/PointSet/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/PointSet/SpecificPointsOptions.vue b/components/Viewer/PointSet/SpecificPointsOptions.vue new file mode 100644 index 00000000..8d2c7371 --- /dev/null +++ b/components/Viewer/PointSet/SpecificPointsOptions.vue @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/PolygonalSurface/EdgesOptions.vue b/components/Viewer/PolygonalSurface/EdgesOptions.vue new file mode 100644 index 00000000..4e5d54de --- /dev/null +++ b/components/Viewer/PolygonalSurface/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/PolygonalSurface/PointsOptions.vue b/components/Viewer/PolygonalSurface/PointsOptions.vue new file mode 100644 index 00000000..a5c514d6 --- /dev/null +++ b/components/Viewer/PolygonalSurface/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/PolygonalSurface/PolygonsOptions.vue b/components/Viewer/PolygonalSurface/PolygonsOptions.vue new file mode 100644 index 00000000..4f3865fb --- /dev/null +++ b/components/Viewer/PolygonalSurface/PolygonsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Solid/EdgesOptions.vue b/components/Viewer/Solid/EdgesOptions.vue new file mode 100644 index 00000000..a9f00eb4 --- /dev/null +++ b/components/Viewer/Solid/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Solid/PointsOptions.vue b/components/Viewer/Solid/PointsOptions.vue new file mode 100644 index 00000000..3746c2d4 --- /dev/null +++ b/components/Viewer/Solid/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Solid/PolygonsOptions.vue b/components/Viewer/Solid/PolygonsOptions.vue new file mode 100644 index 00000000..16733305 --- /dev/null +++ b/components/Viewer/Solid/PolygonsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/Solid/PolyhedraOptions.vue b/components/Viewer/Solid/PolyhedraOptions.vue new file mode 100644 index 00000000..4b6468b5 --- /dev/null +++ b/components/Viewer/Solid/PolyhedraOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue b/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue new file mode 100644 index 00000000..ca5eb0a0 --- /dev/null +++ b/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/components/Viewer/TetrahedralSolid/TrianglesOptions.vue b/components/Viewer/TetrahedralSolid/TrianglesOptions.vue new file mode 100644 index 00000000..fead6783 --- /dev/null +++ b/components/Viewer/TetrahedralSolid/TrianglesOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/components/Viewer/Tree/ObjectTree.vue b/components/Viewer/Tree/ObjectTree.vue new file mode 100644 index 00000000..f7bfa2f1 --- /dev/null +++ b/components/Viewer/Tree/ObjectTree.vue @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Viewer/TreeComponent.vue b/components/Viewer/TreeComponent.vue new file mode 100644 index 00000000..782e346c --- /dev/null +++ b/components/Viewer/TreeComponent.vue @@ -0,0 +1,93 @@ + + + + {{ item.title }} + + + + + + + diff --git a/components/Viewer/TreeObject.vue b/components/Viewer/TreeObject.vue new file mode 100644 index 00000000..6b71d438 --- /dev/null +++ b/components/Viewer/TreeObject.vue @@ -0,0 +1,100 @@ + + + + + {{ item.title }} + + + + + + + + + + + + diff --git a/components/Viewer/TriangulatedSurface/EdgesOptions.vue b/components/Viewer/TriangulatedSurface/EdgesOptions.vue new file mode 100644 index 00000000..9852fcb4 --- /dev/null +++ b/components/Viewer/TriangulatedSurface/EdgesOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/TriangulatedSurface/PointsOptions.vue b/components/Viewer/TriangulatedSurface/PointsOptions.vue new file mode 100644 index 00000000..00a19abb --- /dev/null +++ b/components/Viewer/TriangulatedSurface/PointsOptions.vue @@ -0,0 +1,14 @@ + + + + + diff --git a/components/Viewer/TriangulatedSurface/TrianglesOptions.vue b/components/Viewer/TriangulatedSurface/TrianglesOptions.vue new file mode 100644 index 00000000..38dfb8c0 --- /dev/null +++ b/components/Viewer/TriangulatedSurface/TrianglesOptions.vue @@ -0,0 +1,15 @@ + + + + + diff --git a/internal_stores/data_style_state.js b/internal_stores/data_style_state.js new file mode 100644 index 00000000..967974ee --- /dev/null +++ b/internal_stores/data_style_state.js @@ -0,0 +1,18 @@ +import { reactive, computed } from "vue" + +export default function useDataStyleState() { + const styles = reactive({}) + + const objectVisibility = computed(() => (id) => styles[id]?.visibility) + const selectedObjects = computed(() => { + const selection = [] + for (const [id, value] of Object.entries(styles)) { + if (value.visibility === true) { + selection.push(id) + } + } + return selection + }) + + return { styles, objectVisibility, selectedObjects } +} diff --git a/internal_stores/mesh/edges.js b/internal_stores/mesh/edges.js new file mode 100644 index 00000000..34a44b68 --- /dev/null +++ b/internal_stores/mesh/edges.js @@ -0,0 +1,106 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges + +export function useMeshEdgesStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + + /** Getters **/ + function edgesVisibility(id) { + return dataStyleStore.styles[id].edges.visibility + } + function edgesActiveColoring(id) { + return dataStyleStore.styles[id].edges.coloring.active + } + function edgesColor(id) { + return dataStyleStore.styles[id].edges.coloring.color + } + function edgesSize(id) { + return dataStyleStore.styles[id].edges.size + } + + /** Actions **/ + function setEdgesVisibility(id, visibility) { + viewer_call( + { + schema: mesh_edges_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].edges.visibility = visibility + console.log( + "setEdgesVisibility", + dataStyleStore.styles[id].edges.visibility, + ) + }, + }, + ) + } + function setEdgesActiveColoring(id, type) { + if (type == "color") + setEdgesColor(id, dataStyleStore.styles[id].edges.coloring.color) + else if (type == "vertex") { + const vertex = dataStyleStore.styles[id].edges.coloring.vertex + if (vertex !== null) setEdgesVertexAttribute(id, vertex) + } else if (type == "edges") { + const edges = dataStyleStore.styles[id].edges.coloring.edges + if (edges !== null) setEdgesEdgeAttribute(id, edges) + } else throw new Error("Unknown edges coloring type: " + type) + dataStyleStore.styles[id].edges.coloring.active = type + console.log( + "setEdgesActiveColoring", + dataStyleStore.styles[id].edges.coloring.active, + ) + } + + function setEdgesColor(id, color) { + viewer_call( + { + schema: mesh_edges_schemas.color, + params: { id, color }, + }, + { + response_function: () => { + dataStyleStore.styles[id].edges.coloring.color = color + console.log( + "setEdgesColor", + dataStyleStore.styles[id].edges.coloring.color, + ) + }, + }, + ) + } + function setEdgesSize(id, size) { + viewer_call( + { + schema: mesh_edges_schemas.size, + params: { id, size }, + }, + { + response_function: () => { + dataStyleStore.styles[id].edges.size = size + console.log("setEdgesSize", dataStyleStore.styles[id].edges.size) + }, + }, + ) + } + + function applyEdgesStyle(id, style) { + setEdgesVisibility(id, style.visibility) + setEdgesActiveColoring(id, style.coloring.active) + // setEdgesSize(id, style.size); + } + + return { + edgesVisibility, + edgesActiveColoring, + edgesColor, + edgesSize, + setEdgesVisibility, + setEdgesActiveColoring, + setEdgesColor, + setEdgesSize, + applyEdgesStyle, + } +} diff --git a/internal_stores/mesh/index.js b/internal_stores/mesh/index.js new file mode 100644 index 00000000..e827a75c --- /dev/null +++ b/internal_stores/mesh/index.js @@ -0,0 +1,50 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +import { useMeshPointsStyle } from "./points.js" +import { useMeshEdgesStyle } from "./edges.js" +import { useMeshPolygonsStyle } from "./polygons.js" +import { useMeshPolyhedraStyle } from "./polyhedra.js" + +export default function useMeshStyle() { + const dataStyleStore = useDataStyleStore() + const pointsStyleStore = useMeshPointsStyle() + const edgesStyleStore = useMeshEdgesStyle() + const polygonsStyleStore = useMeshPolygonsStyle() + const polyhedraStyleStore = useMeshPolyhedraStyle() + + function setMeshVisibility(id, visibility) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.mesh.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].visibility = visibility + console.log("setMeshVisibility", dataStyleStore.styles[id].visibility) + }, + }, + ) + } + + function applyMeshDefaultStyle(id) { + const id_style = dataStyleStore.styles[id] + for (const [key, value] of Object.entries(id_style)) { + if (key == "visibility") setMeshVisibility(id, value) + else if (key == "points") pointsStyleStore.applyPointsStyle(id, value) + else if (key == "edges") edgesStyleStore.applyEdgesStyle(id, value) + else if (key == "polygons") + polygonsStyleStore.applyPolygonsStyle(id, value) + else if (key == "polyhedra") + polyhedraStyleStore.applyPolyhedraStyle(id, value) + } + } + + return { + setMeshVisibility, + applyMeshDefaultStyle, + ...useMeshPointsStyle(), + ...useMeshEdgesStyle(), + ...useMeshPolygonsStyle(), + ...useMeshPolyhedraStyle(), + } +} diff --git a/internal_stores/mesh/points.js b/internal_stores/mesh/points.js new file mode 100644 index 00000000..91e1316f --- /dev/null +++ b/internal_stores/mesh/points.js @@ -0,0 +1,131 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points + +export function useMeshPointsStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + + /** Getters **/ + function pointsVisibility(id) { + return dataStyleStore.styles[id].points.visibility + } + function pointsActiveColoring(id) { + return dataStyleStore.styles[id].points.coloring.active + } + function pointsColor(id) { + return dataStyleStore.styles[id].points.coloring.color + } + function pointsVertexAttribute(id) { + return dataStyleStore.styles[id].points.coloring.vertex + } + function pointsSize(id) { + return dataStyleStore.styles[id].points.size + } + + /** Actions **/ + function setPointsVisibility(id, visibility) { + viewer_call( + { + schema: mesh_points_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.visibility = visibility + console.log( + "setPointsVisibility", + dataStyleStore.styles[id].points.visibility, + ) + }, + }, + ) + } + + function setPointsColor(id, color) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.mesh.points.color, + params: { id, color }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.coloring.color = color + console.log( + "setPointsColor", + dataStyleStore.styles[id].points.coloring.color, + ) + }, + }, + ) + } + function setPointsVertexAttribute(id, vertex_attribute) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.mesh.points.vertex_attribute, + params: { id, ...vertex_attribute }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.coloring.vertex = vertex_attribute + console.log( + "setPointsVertexAttribute", + dataStyleStore.styles[id].points.coloring.vertex, + ) + }, + }, + ) + } + function setPointsSize(id, size) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.mesh.points.size, + params: { id, size }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.size = size + console.log("setPointsSize", dataStyleStore.styles[id].points.size) + }, + }, + ) + } + + function setPointsActiveColoring(id, type) { + if (type == "color") + dataStyleStore.setPointsColor( + id, + dataStyleStore.styles[id].points.coloring.color, + ) + else if (type == "vertex") { + const vertex = dataStyleStore.styles[id].points.coloring.vertex + if (vertex !== null) dataStyleStore.setPointsVertexAttribute(id, vertex) + } else throw new Error("Unknown edges coloring type: " + type) + dataStyleStore.styles[id].points.coloring.active = type + console.log( + "setPointsActiveColoring", + dataStyleStore.styles[id].points.coloring.active, + ) + } + + function applyPointsStyle(id, style) { + setPointsVisibility(id, style.visibility) + setPointsActiveColoring(id, style.coloring.active) + setPointsSize(id, style.size) + } + + return { + pointsVisibility, + pointsActiveColoring, + pointsColor, + pointsVertexAttribute, + pointsSize, + setPointsVisibility, + setPointsActiveColoring, + setPointsColor, + setPointsVertexAttribute, + setPointsSize, + applyPointsStyle, + } +} + +export default useMeshPointsStyle diff --git a/internal_stores/mesh/polygons.js b/internal_stores/mesh/polygons.js new file mode 100644 index 00000000..4c0ea40c --- /dev/null +++ b/internal_stores/mesh/polygons.js @@ -0,0 +1,159 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons + +export function useMeshPolygonsStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + + /** Getters **/ + function polygonsVisibility(id) { + return dataStyleStore.styles[id].polygons.visibility + } + function polygonsActiveColoring(id) { + return dataStyleStore.styles[id].polygons.coloring.active + } + function polygonsColor(id) { + return dataStyleStore.styles[id].polygons.coloring.color + } + function polygonsTextures(id) { + return dataStyleStore.styles[id].polygons.coloring.textures + } + function polygonsPolygonAttribute(id) { + return dataStyleStore.styles[id].polygons.coloring.polygon + } + function polygonsVertexAttribute(id) { + return dataStyleStore.styles[id].polygons.coloring.vertex + } + + /** Actions **/ + function setPolygonsVisibility(id, visibility) { + viewer_call( + { + schema: mesh_polygons_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polygons.visibility = visibility + console.log( + "setPolygonsVisibility", + dataStyleStore.styles[id].polygons.visibility, + ) + }, + }, + ) + } + function setPolygonsActiveColoring(id, type) { + console.log("setPolygonsActiveColoring", id, type) + if (type == "color") { + setPolygonsColor(id, dataStyleStore.styles[id].polygons.coloring.color) + } else if (type == "textures") { + const textures = dataStyleStore.styles[id].polygons.coloring.textures + if (textures !== null) setPolygonsTextures(id, textures) + } else if (type == "vertex") { + const vertex = dataStyleStore.styles[id].polygons.coloring.vertex + if (vertex !== null) { + console.log("vertex", vertex) + setPolygonsVertexAttribute(id, vertex) + } + } else if (type == "polygon") { + const polygon = dataStyleStore.styles[id].polygons.coloring.polygon + if (polygon !== null) setPolygonsPolygonAttribute(id, polygon) + } else throw new Error("Unknown polygons coloring type: " + type) + dataStyleStore.styles[id].polygons.coloring.active = type + console.log( + "setPolygonsActiveColoring", + dataStyleStore.styles[id].polygons.coloring.active, + ) + } + function setPolygonsColor(id, color) { + viewer_call( + { + schema: mesh_polygons_schemas.color, + params: { id, color }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polygons.coloring.color = color + console.log( + "setPolygonsColor", + dataStyleStore.styles[id].polygons.coloring.color, + ) + }, + }, + ) + } + function setPolygonsTextures(id, textures) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.mesh.apply_textures, + params: { id, textures }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polygons.coloring.textures = textures + console.log( + "setPolygonsTextures", + dataStyleStore.styles[id].polygons.coloring.textures, + ) + }, + }, + ) + } + function setPolygonsVertexAttribute(id, vertex_attribute) { + viewer_call( + { + schema: mesh_polygons_schemas.vertex_attribute, + params: { id, ...vertex_attribute }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polygons.coloring.vertex = vertex_attribute + console.log( + "setPolygonsVertexAttribute", + dataStyleStore.styles[id].polygons.coloring.vertex, + ) + }, + }, + ) + } + function setPolygonsPolygonAttribute(id, polygon_attribute) { + viewer_call( + { + schema: mesh_polygons_schemas.polygon_attribute, + params: { id, ...polygon_attribute }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polygons.coloring.polygon = + polygon_attribute + console.log( + "setPolygonsPolygonAttribute", + dataStyleStore.styles[id].polygons.coloring.polygon, + ) + }, + }, + ) + } + + function applyPolygonsStyle(id, style) { + setPolygonsVisibility(id, style.visibility) + setPolygonsActiveColoring(id, style.coloring.active) + } + + return { + polygonsVisibility, + polygonsActiveColoring, + polygonsColor, + polygonsTextures, + polygonsPolygonAttribute, + polygonsVertexAttribute, + setPolygonsVisibility, + setPolygonsActiveColoring, + setPolygonsColor, + setPolygonsTextures, + setPolygonsVertexAttribute, + setPolygonsPolygonAttribute, + applyPolygonsStyle, + } +} diff --git a/internal_stores/mesh/polyhedra.js b/internal_stores/mesh/polyhedra.js new file mode 100644 index 00000000..eb225798 --- /dev/null +++ b/internal_stores/mesh/polyhedra.js @@ -0,0 +1,136 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const mesh_polyhedra_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polyhedra + +export function useMeshPolyhedraStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + + /** Getters **/ + function polyhedraVisibility(id) { + return dataStyleStore.styles[id].polyhedra.visibility + } + function polyhedraActiveColoring(id) { + return dataStyleStore.styles[id].polyhedra.coloring.active + } + function polyhedraColor(id) { + return dataStyleStore.styles[id].polyhedra.coloring.color + } + function polyhedraVertexAttribute(id) { + return dataStyleStore.styles[id].polyhedra.coloring.vertex + } + function polyhedraPolygonAttribute(id) { + return dataStyleStore.styles[id].polyhedra.coloring.polygon + } + function polyhedraPolyhedronAttribute(id) { + return dataStyleStore.styles[id].polyhedra.coloring.polyhedron + } + + /** Actions **/ + function setPolyhedraVisibility(id, visibility) { + viewer_call( + { + schema: mesh_polyhedra_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polyhedra.visibility = visibility + console.log( + "setPolyhedraVisibility", + dataStyleStore.styles[id].polyhedra.visibility, + ) + }, + }, + ) + } + function setPolyhedraActiveColoring(id, type) { + if (type == "color") + setPolyhedraColor(id, dataStyleStore.styles[id].polyhedra.coloring.color) + else if (type == "vertex") { + const vertex = dataStyleStore.styles[id].polyhedra.coloring.vertex + if (vertex !== null) setPolyhedraVertexAttribute(id, vertex) + } else if (type == "polyhedron") { + const polyhedron = dataStyleStore.styles[id].polyhedra.coloring.polyhedron + if (polyhedron !== null) setPolyhedraPolyhedronAttribute(id, polyhedron) + } else throw new Error("Unknown polyhedra coloring type: " + type) + dataStyleStore.styles[id].polyhedra.coloring.active = type + console.log( + "setPolyhedraActiveColoring", + dataStyleStore.styles[id].polyhedra.coloring.active, + ) + } + function setPolyhedraColor(id, color) { + viewer_call( + { + schema: mesh_polyhedra_schemas.color, + params: { id, color }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polyhedra.coloring.color = color + console.log( + "setPolyhedraColor", + dataStyleStore.styles[id].polyhedra.coloring.color, + ) + }, + }, + ) + } + + function setPolyhedraVertexAttribute(id, vertex_attribute) { + viewer_call( + { + schema: mesh_polyhedra_schemas.vertex_attribute, + params: { id, ...vertex_attribute }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polyhedra.coloring.vertex = vertex_attribute + console.log( + "setPolyhedraVertexAttribute", + dataStyleStore.styles[id].polyhedra.coloring.vertex, + ) + }, + }, + ) + } + + function setPolyhedraPolyhedronAttribute(id, polyhedron_attribute) { + viewer_call( + { + schema: mesh_polyhedra_schemas.polyhedron_attribute, + params: { id, ...polyhedron_attribute }, + }, + { + response_function: () => { + dataStyleStore.styles[id].polyhedra.coloring.polyhedron = + polyhedron_attribute + console.log( + "setPolyhedraPolyhedronAttribute", + dataStyleStore.styles[id].polyhedra.coloring.polyhedron, + ) + }, + }, + ) + } + + function applyPolyhedraStyle(id, style) { + setPolyhedraVisibility(id, style.visibility) + setPolyhedraActiveColoring(id, style.coloring.active) + } + + return { + polyhedraVisibility, + polyhedraActiveColoring, + polyhedraColor, + polyhedraVertexAttribute, + polyhedraPolygonAttribute, + polyhedraPolyhedronAttribute, + setPolyhedraVisibility, + setPolyhedraActiveColoring, + setPolyhedraColor, + setPolyhedraVertexAttribute, + setPolyhedraPolyhedronAttribute, + applyPolyhedraStyle, + } +} diff --git a/internal_stores/model/blocks.js b/internal_stores/model/blocks.js new file mode 100644 index 00000000..3c64f7c6 --- /dev/null +++ b/internal_stores/model/blocks.js @@ -0,0 +1,60 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +import _ from "lodash" +const blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks + +export function useBlocksStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + const dataBaseStore = useDataBaseStore() + + /** Getters **/ + function blockVisibility(id, block_id) { + return dataStyleStore.styles[id].blocks[block_id].visibility + } + + /** Actions **/ + function setBlockVisibility(id, block_ids, visibility) { + const block_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids) + viewer_call( + { + schema: blocks_schemas.visibility, + params: { id, block_ids: block_flat_indexes, visibility }, + }, + { + response_function: () => { + for (const block_id of block_ids) { + if (!dataStyleStore.styles[id].blocks[block_id]) + dataStyleStore.styles[id].blocks[block_id] = {} + dataStyleStore.styles[id].blocks[block_id].visibility = visibility + } + console.log("setBlockVisibility", block_ids, visibility) + }, + }, + ) + } + + function setBlocksDefaultStyle(id) { + const block_ids = dataBaseStore.getBlocksUuids(id) + setBlockVisibility( + id, + block_ids, + dataStyleStore.styles[id].blocks.visibility, + ) + } + + function applyBlocksStyle(id) { + const blocks = dataStyleStore.styles[id].blocks + for (const [block_id, style] of Object.entries(blocks)) { + setBlockVisibility(id, [block_id], style.visibility) + } + } + + return { + blockVisibility, + setBlocksDefaultStyle, + setBlockVisibility, + applyBlocksStyle, + } +} + +export default useBlocksStyle diff --git a/internal_stores/model/corners.js b/internal_stores/model/corners.js new file mode 100644 index 00000000..e3b2a481 --- /dev/null +++ b/internal_stores/model/corners.js @@ -0,0 +1,63 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const corners_schemas = viewer_schemas.opengeodeweb_viewer.model.corners + +export function useCornersStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + const dataBaseStore = useDataBaseStore() + + /** Getters **/ + function cornerVisibility(id, corner_id) { + return dataStyleStore.styles[id].corners[corner_id].visibility + } + + /** Actions **/ + function setCornerVisibility(id, corner_ids, visibility) { + const corner_flat_indexes = dataBaseStore.getFlatIndexes(id, corner_ids) + viewer_call( + { + schema: corners_schemas.visibility, + params: { id, block_ids: corner_flat_indexes, visibility }, + }, + { + response_function: () => { + for (const corner_id of corner_ids) { + if (!dataStyleStore.styles[id].corners[corner_id]) + dataStyleStore.styles[id].corners[corner_id] = {} + dataStyleStore.styles[id].corners[corner_id].visibility = visibility + } + console.log("setCornerVisibility", corner_ids, visibility) + }, + }, + ) + } + + function setCornersDefaultStyle(id) { + const corner_ids = dataBaseStore.getCornersUuids(id) + console.log( + "dataStyleStore.styles[id].corners.visibility", + dataStyleStore.styles[id].corners.visibility, + ) + setCornerVisibility( + id, + corner_ids, + dataStyleStore.styles[id].corners.visibility, + ) + } + + function applyCornersStyle(id) { + const corners = dataStyleStore.styles[id].corners + for (const [corner_id, style] of Object.entries(corners)) { + setCornerVisibility(id, [corner_id], style.visibility) + } + } + + return { + cornerVisibility, + setCornersDefaultStyle, + setCornerVisibility, + applyCornersStyle, + } +} + +export default useCornersStyle diff --git a/internal_stores/model/edges.js b/internal_stores/model/edges.js new file mode 100644 index 00000000..4b62e8ac --- /dev/null +++ b/internal_stores/model/edges.js @@ -0,0 +1,47 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const model_edges_schemas = viewer_schemas.opengeodeweb_viewer.model.edges + +export function useModelEdgesStyle() { + const dataStyleStore = useDataStyleStore() + + function modelEdgesVisibility(id) { + return dataStyleStore.styles[id].edges.visibility + } + + function setModelEdgesVisibility(id, visibility) { + if (!dataStyleStore.styles[id]) { + dataStyleStore.styles[id] = {} + } + if (!dataStyleStore.styles[id].edges) { + dataStyleStore.styles[id].edges = {} + } + + viewer_call( + { + schema: model_edges_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].edges.visibility = visibility + console.log("setModelEdgesVisibility", visibility) + }, + }, + ) + } + + function applyModelEdgesStyle(id, style) { + setModelEdgesVisibility(id, style.visibility) + } + + function setModelEdgesDefaultStyle(id) { + setModelEdgesVisibility(id, false) + } + + return { + modelEdgesVisibility, + setModelEdgesVisibility, + applyModelEdgesStyle, + setModelEdgesDefaultStyle, + } +} diff --git a/internal_stores/model/index.js b/internal_stores/model/index.js new file mode 100644 index 00000000..93a3b403 --- /dev/null +++ b/internal_stores/model/index.js @@ -0,0 +1,154 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +import { useSurfacesStyle } from "./surfaces.js" +import { useCornersStyle } from "./corners.js" +import { useBlocksStyle } from "./blocks.js" +import { useLinesStyle } from "./lines.js" +import { useModelEdgesStyle } from "./edges.js" +import { useModelPointsStyle } from "./points.js" + +export default function useModelStyle() { + /** States **/ + const dataBaseStore = useDataBaseStore() + const dataStyleStore = useDataStyleStore() + const cornersStyleStore = useCornersStyle() + const linesStyleStore = useLinesStyle() + const surfacesStyleStore = useSurfacesStyle() + const blocksStyleStore = useBlocksStyle() + const modelEdgesStore = useModelEdgesStyle() + const modelPointsStore = useModelPointsStyle() + + /** Getters **/ + function modelVisibility(id) { + return dataStyleStore.styles[id]?.visibility + } + + function visibleMeshComponents(id) { + const visible_mesh_components = ref([]) + const styles = dataStyleStore.styles[id] + if (!styles) return visible_mesh_components + + Object.entries(styles.corners || {}).forEach(([corner_id, style]) => { + if (style.visibility) visible_mesh_components.value.push(corner_id) + }) + + Object.entries(styles.lines || {}).forEach(([line_id, style]) => { + if (style.visibility) visible_mesh_components.value.push(line_id) + }) + + Object.entries(styles.surfaces || {}).forEach(([surface_id, style]) => { + if (style.visibility) visible_mesh_components.value.push(surface_id) + }) + + Object.entries(styles.blocks || {}).forEach(([block_id, style]) => { + if (style.visibility) visible_mesh_components.value.push(block_id) + }) + + return visible_mesh_components + } + + function modelMeshComponentVisibility(id, component_type, component_id) { + switch (component_type) { + case "Corner": + return cornersStyleStore.cornerVisibility(id, component_id) + case "Line": + return linesStyleStore.lineVisibility(id, component_id) + case "Surface": + return surfacesStyleStore.surfaceVisibility(id, component_id) + case "Block": + return blocksStyleStore.blockVisibility(id, component_id) + default: + return false + } + } + + function setModelVisibility(id, visibility) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.model.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].visibility = visibility + console.log("setModelVisibility", visibility) + }, + }, + ) + } + + function setModelColor(id, color) { + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.model.color, + params: { id, color }, + }, + { + response_function: () => { + dataStyleStore.styles[id].color = color + console.log("setModelColor", color) + }, + }, + ) + } + + function setModelMeshComponentVisibility( + id, + component_type, + component_id, + visibility, + ) { + switch (component_type) { + case "Corner": + cornersStyleStore.setCornerVisibility(id, [component_id], visibility) + break + case "Line": + linesStyleStore.setLineVisibility(id, [component_id], visibility) + break + case "Surface": + surfacesStyleStore.setSurfaceVisibility(id, [component_id], visibility) + break + case "Block": + blocksStyleStore.setBlockVisibility(id, [component_id], visibility) + break + } + } + + function applyModelDefaultStyle(id) { + const id_style = dataStyleStore.styles[id] + for (const [key, value] of Object.entries(id_style)) { + if (key === "visibility") setModelVisibility(id, value) + else if (key === "edges") modelEdgesStore.applyModelEdgesStyle(id, value) + else if (key === "points") + modelPointsStore.applyModelPointsStyle(id, value) + } + } + + function setMeshComponentsDefaultStyle(id) { + const { mesh_components } = dataBaseStore.itemMetaDatas(id) + if ("Corner" in mesh_components) + cornersStyleStore.setCornersDefaultStyle(id) + if ("Line" in mesh_components) linesStyleStore.setLinesDefaultStyle(id) + if ("Surface" in mesh_components) + surfacesStyleStore.setSurfacesDefaultStyle(id) + if ("Block" in mesh_components) blocksStyleStore.setBlocksDefaultStyle(id) + modelEdgesStore.setModelEdgesDefaultStyle(id) + modelPointsStore.setModelPointsDefaultStyle(id) + } + + return { + modelVisibility, + visibleMeshComponents, + modelMeshComponentVisibility, + setModelVisibility, + setModelColor, + setModelMeshComponentVisibility, + applyModelDefaultStyle, + setMeshComponentsDefaultStyle, + ...useSurfacesStyle(), + ...useCornersStyle(), + ...useBlocksStyle(), + ...useLinesStyle(), + ...useModelEdgesStyle(), + ...useModelPointsStyle(), + } +} diff --git a/internal_stores/model/lines.js b/internal_stores/model/lines.js new file mode 100644 index 00000000..1b0eb70e --- /dev/null +++ b/internal_stores/model/lines.js @@ -0,0 +1,81 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const lines_schemas = viewer_schemas.opengeodeweb_viewer.model.lines + +export function useLinesStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + const dataBaseStore = useDataBaseStore() + + /** Getters **/ + function lineVisibility(id, line_id) { + return dataStyleStore.styles[id].lines[line_id].visibility + } + + function linesColor(id) { + return dataStyleStore.styles[id].lines.color + } + + /** Actions **/ + function setLineVisibility(id, line_ids, visibility) { + const line_flat_indexes = dataBaseStore.getFlatIndexes(id, line_ids) + viewer_call( + { + schema: lines_schemas.visibility, + params: { id, block_ids: line_flat_indexes, visibility }, + }, + { + response_function: () => { + for (const line_id of line_ids) { + if (!dataStyleStore.styles[id].lines[line_id]) + dataStyleStore.styles[id].lines[line_id] = {} + dataStyleStore.styles[id].lines[line_id].visibility = visibility + } + console.log("setLineVisibility", line_ids, visibility) + }, + }, + ) + } + + function setLineColor(id, line_ids, color) { + const line_flat_indexes = dataBaseStore.getFlatIndexes(id, line_ids) + viewer_call( + { + schema: lines_schemas.color, + params: { id, block_ids: line_flat_indexes, color }, + }, + { + response_function: () => { + for (const line_id of line_ids) { + if (!dataStyleStore.styles[id].lines[line_id]) + dataStyleStore.styles[id].lines[line_id] = {} + dataStyleStore.styles[id].lines[line_id].color = color + } + console.log("setLineColor", line_ids, color) + }, + }, + ) + } + + function setLinesDefaultStyle(id) { + const line_ids = dataBaseStore.getLinesUuids(id) + setLineVisibility(id, line_ids, dataStyleStore.styles[id].lines.visibility) + setLineColor(id, line_ids, dataStyleStore.styles[id].lines.color) + } + + function applyLinesStyle(id) { + const lines = dataStyleStore.styles[id].lines + for (const [line_id, style] of Object.entries(lines)) { + setLineVisibility(id, [line_id], style.visibility) + } + } + + return { + lineVisibility, + linesColor, + setLinesDefaultStyle, + setLineVisibility, + applyLinesStyle, + } +} + +export default useLinesStyle diff --git a/internal_stores/model/points.js b/internal_stores/model/points.js new file mode 100644 index 00000000..25d252e8 --- /dev/null +++ b/internal_stores/model/points.js @@ -0,0 +1,61 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const model_points_schemas = viewer_schemas.opengeodeweb_viewer.model.points + +export function useModelPointsStyle() { + const dataStyleStore = useDataStyleStore() + + function modelPointsVisibility(id) { + return dataStyleStore.styles[id].points.visibility + } + function modelPointsSize(id) { + return dataStyleStore.styles[id].points.size + } + + function setModelPointsVisibility(id, visibility) { + viewer_call( + { + schema: model_points_schemas.visibility, + params: { id, visibility }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.visibility = visibility + console.log("setModelPointsVisibility", visibility) + }, + }, + ) + } + + function setModelPointsSize(id, size) { + viewer_call( + { + schema: model_points_schemas.size, + params: { id, size }, + }, + { + response_function: () => { + dataStyleStore.styles[id].points.size = size + console.log("setModelPointsSize", size) + }, + }, + ) + } + + function applyModelPointsStyle(id, style) { + setModelPointsVisibility(id, style.visibility) + setModelPointsSize(id, style.size) + } + + function setModelPointsDefaultStyle(id) { + setModelPointsVisibility(id, false) + } + + return { + modelPointsVisibility, + modelPointsSize, + setModelPointsVisibility, + setModelPointsSize, + applyModelPointsStyle, + setModelPointsDefaultStyle, + } +} diff --git a/internal_stores/model/surfaces.js b/internal_stores/model/surfaces.js new file mode 100644 index 00000000..cb58b9ed --- /dev/null +++ b/internal_stores/model/surfaces.js @@ -0,0 +1,60 @@ +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +const surfaces_schemas = viewer_schemas.opengeodeweb_viewer.model.surfaces + +export function useSurfacesStyle() { + /** State **/ + const dataStyleStore = useDataStyleStore() + const dataBaseStore = useDataBaseStore() + + /** Getters **/ + function surfaceVisibility(id, surface_id) { + return dataStyleStore.styles[id].surfaces[surface_id].visibility + } + + /** Actions **/ + function setSurfaceVisibility(id, surface_ids, visibility) { + const surface_flat_indexes = dataBaseStore.getFlatIndexes(id, surface_ids) + viewer_call( + { + schema: surfaces_schemas.visibility, + params: { id, block_ids: surface_flat_indexes, visibility }, + }, + { + response_function: () => { + for (const surface_id of surface_ids) { + if (!dataStyleStore.styles[id].surfaces[surface_id]) + dataStyleStore.styles[id].surfaces[surface_id] = {} + dataStyleStore.styles[id].surfaces[surface_id].visibility = + visibility + } + console.log("setSurfaceVisibility", surface_ids, visibility) + }, + }, + ) + } + + function setSurfacesDefaultStyle(id) { + const surface_ids = dataBaseStore.getSurfacesUuids(id) + setSurfaceVisibility( + id, + surface_ids, + dataStyleStore.styles[id].surfaces.visibility, + ) + } + + function applySurfacesStyle(id) { + const surfaces = dataStyleStore.styles[id].surfaces + for (const [surface_id, style] of Object.entries(surfaces)) { + setSurfaceVisibility(id, [surface_id], style.visibility) + } + } + + return { + surfaceVisibility, + setSurfacesDefaultStyle, + setSurfaceVisibility, + applySurfacesStyle, + } +} + +export default useSurfacesStyle diff --git a/stores/data_base.js b/stores/data_base.js new file mode 100644 index 00000000..4e836046 --- /dev/null +++ b/stores/data_base.js @@ -0,0 +1,148 @@ +import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" + +export const useDataBaseStore = defineStore("dataBase", () => { + const treeview_store = use_treeview_store() + const hybridViewerStore = useHybridViewerStore() + + /** State **/ + const db = reactive({}) + + /** Getters **/ + function itemMetaDatas(id) { + return db[id] + } + + function formatedMeshComponents(id) { + const { mesh_components } = itemMetaDatas(id) + const formated_mesh_components = ref([]) + + for (const [category, uuids] of Object.entries(mesh_components)) { + formated_mesh_components.value.push({ + id: category, + title: category, + children: uuids.map((uuid) => ({ + id: uuid, + title: uuid, + category, + })), + }) + } + return formated_mesh_components.value + } + + function meshComponentType(id, uuid) { + const { mesh_components } = itemMetaDatas(id) + + if (mesh_components["Corner"]?.includes(uuid)) return "corner" + else if (mesh_components["Line"]?.includes(uuid)) return "line" + else if (mesh_components["Surface"]?.includes(uuid)) return "surface" + else if (mesh_components["Block"]?.includes(uuid)) return "block" + return null + } + + /** Actions **/ + async function addItem( + id, + value = { + object_type, + geode_object, + native_filename, + viewable_filename, + displayed_name, + vtk_js: { binary_light_viewable }, + }, + ) { + db[id] = value + + if (value.object_type === "model") { + await fetchMeshComponents(id) + await fetchUuidToFlatIndexDict(id) + } + treeview_store.addItem( + value.geode_object, + value.displayed_name, + id, + value.object_type, + ) + + hybridViewerStore.addItem(id, value.vtk_js) + } + + async function fetchMeshComponents(id) { + const { native_filename, geode_object } = itemMetaDatas(id) + await api_fetch( + { + schema: back_schemas.opengeodeweb_back.models.mesh_components, + params: { + filename: native_filename, + geode_object, + }, + }, + { + response_function: async (response) => { + if (response._data?.uuid_dict) { + db[id].mesh_components = response._data.uuid_dict + } + }, + }, + ) + } + + async function fetchUuidToFlatIndexDict(id) { + await api_fetch( + { + schema: back_schemas.opengeodeweb_back.models.vtm_component_indices, + params: { id }, + }, + { + response_function: async (response) => { + if (response._data?.uuid_to_flat_index) { + db[id]["uuid_to_flat_index"] = response._data.uuid_to_flat_index + } + }, + }, + ) + } + + function getCornersUuids(id) { + const { mesh_components } = itemMetaDatas(id) + return Object.values(mesh_components["Corner"]) + } + + function getLinesUuids(id) { + const { mesh_components } = itemMetaDatas(id) + return Object.values(mesh_components["Line"]) + } + function getSurfacesUuids(id) { + const { mesh_components } = itemMetaDatas(id) + return Object.values(mesh_components["Surface"]) + } + function getBlocksUuids(id) { + const { mesh_components } = itemMetaDatas(id) + return Object.values(mesh_components["Block"]) + } + + function getFlatIndexes(id, mesh_component_ids) { + const { uuid_to_flat_index } = itemMetaDatas(id) + + const flat_indexes = mesh_component_ids.map( + (mesh_component_id) => uuid_to_flat_index[mesh_component_id] || null, + ) + return flat_indexes.filter((index) => index !== null) + } + + return { + db, + itemMetaDatas, + meshComponentType, + formatedMeshComponents, + addItem, + fetchUuidToFlatIndexDict, + fetchMeshComponents, + getCornersUuids, + getLinesUuids, + getSurfacesUuids, + getBlocksUuids, + getFlatIndexes, + } +}) diff --git a/stores/data_style.js b/stores/data_style.js new file mode 100644 index 00000000..9f84fd6d --- /dev/null +++ b/stores/data_style.js @@ -0,0 +1,57 @@ +import useDataStyleState from "../internal_stores/data_style_state.js" +import useMeshStyle from "../internal_stores/mesh/index.js" +import useModelStyle from "../internal_stores/model/index.js" + +export const useDataStyleStore = defineStore("dataStyle", () => { + /** States **/ + const dataStyleState = useDataStyleState() + const meshStyleStore = useMeshStyle() + const modelStyleStore = useModelStyle() + const dataBaseStore = useDataBaseStore() + + /** Actions **/ + function addDataStyle(id, geode_object, object_type) { + dataStyleState.styles[id] = getDefaultStyle(geode_object) + + if (object_type === "mesh") { + meshStyleStore.applyMeshDefaultStyle(id) + } else if (object_type === "model") { + modelStyleStore.setMeshComponentsDefaultStyle(id) + modelStyleStore.applyModelDefaultStyle(id) + } + } + + function setVisibility(id, visibility) { + const object_type = dataBaseStore.itemMetaDatas(id).object_type + if (object_type === "mesh") { + meshStyleStore.setMeshVisibility(id, visibility) + } else if (object_type === "model") { + modelStyleStore.setModelVisibility(id, visibility) + } + } + + function setModelEdgesVisibility(id, visibility) { + modelStyleStore.setModelMeshComponentVisibility( + id, + "Edge", + null, + visibility, + ) + } + + function modelEdgesVisibility(id) { + return modelStyleStore.modelMeshComponentVisibility(id, "Edge", null) + } + + return { + ...dataStyleState, + addDataStyle, + setVisibility, + setModelEdgesVisibility, + modelEdgesVisibility, + ...meshStyleStore, + ...modelStyleStore, + } +}) + +export default useDataStyleStore diff --git a/stores/hybrid_viewer.js b/stores/hybrid_viewer.js new file mode 100644 index 00000000..75a2e017 --- /dev/null +++ b/stores/hybrid_viewer.js @@ -0,0 +1,193 @@ +import "@kitware/vtk.js/Rendering/Profiles/Geometry" +import vtkGenericRenderWindow from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow" +import vtkXMLPolyDataReader from "@kitware/vtk.js/IO/XML/XMLPolyDataReader" +import vtkMapper from "@kitware/vtk.js/Rendering/Core/Mapper" +import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor" + +import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" +import Status from "@ogw_f/utils/status.js" + +export const useHybridViewerStore = defineStore("hybridViewer", () => { + const viewer_store = use_viewer_store() + const db = reactive({}) + const status = ref(Status.NOT_CREATED) + const camera_options = reactive({}) + const genericRenderWindow = reactive({}) + const is_moving = ref(false) + const zScale = ref(1.0) + let viewStream + let gridActor = null + + async function initHybridViewer() { + if (status.value !== Status.NOT_CREATED) return + status.value = Status.CREATING + genericRenderWindow.value = vtkGenericRenderWindow.newInstance({ + background: [180 / 255, 180 / 255, 180 / 255], + listenWindowResize: false, + }) + + const webGLRenderWindow = + genericRenderWindow.value.getApiSpecificRenderWindow() + const imageStyle = webGLRenderWindow.getReferenceByName("bgImage").style + imageStyle.transition = "opacity 0.1s ease-in" + imageStyle.zIndex = 1 + + await viewer_store.ws_connect() + viewStream = viewer_store.client.getImageStream().createViewStream("-1") + viewStream.onImageReady((e) => { + if (is_moving.value) return + const webGLRenderWindow = + genericRenderWindow.value.getApiSpecificRenderWindow() + const imageStyle = webGLRenderWindow.getReferenceByName("bgImage").style + webGLRenderWindow.setBackgroundImage(e.image) + imageStyle.opacity = 1 + }) + + status.value = Status.CREATED + } + + async function addItem(id, value) { + const reader = vtkXMLPolyDataReader.newInstance() + const textEncoder = new TextEncoder() + await reader.parseAsArrayBuffer( + textEncoder.encode(value.binary_light_viewable), + ) + const polydata = reader.getOutputData(0) + const mapper = vtkMapper.newInstance() + mapper.setInputData(polydata) + const actor = vtkActor.newInstance() + actor.getProperty().setColor(20 / 255, 20 / 255, 20 / 255) + actor.setMapper(mapper) + const renderer = genericRenderWindow.value.getRenderer() + const renderWindow = genericRenderWindow.value.getRenderWindow() + renderer.addActor(actor) + renderer.resetCamera() + renderWindow.render() + db[id] = { actor, polydata, mapper } + } + + async function setZScaling(z_scale) { + zScale.value = z_scale + const renderer = genericRenderWindow.value.getRenderer() + const actors = renderer.getActors() + actors.forEach((actor) => { + if (actor !== gridActor) { + const scale = actor.getScale() + actor.setScale(scale[0], scale[1], z_scale) + } + }) + renderer.resetCamera() + genericRenderWindow.value.getRenderWindow().render() + const schema = viewer_schemas?.opengeodeweb_viewer?.viewer?.set_z_scaling + if (!schema) return + await viewer_call({ + schema, + params: { + z_scale: z_scale, + }, + }) + } + + function syncRemoteCamera() { + const renderer = genericRenderWindow.value.getRenderer() + const camera = renderer.getActiveCamera() + const params = { + camera_options: { + focal_point: camera.getFocalPoint(), + view_up: camera.getViewUp(), + position: camera.getPosition(), + view_angle: camera.getViewAngle(), + clipping_range: camera.getClippingRange(), + distance: camera.getDistance(), + }, + } + viewer_call( + { + schema: viewer_schemas.opengeodeweb_viewer.viewer.update_camera, + params, + }, + { + response_fonction: () => { + for (const key in params.camera_options) { + camera_options[key] = params.camera_options[key] + } + }, + }, + ) + } + + function remoteRender() { + viewer_call({ + schema: viewer_schemas.opengeodeweb_viewer.viewer.render_now, + }) + } + + function setContainer(container) { + genericRenderWindow.value.setContainer(container.value.$el) + const webGLRenderWindow = + genericRenderWindow.value.getApiSpecificRenderWindow() + webGLRenderWindow.setUseBackgroundImage(true) + const imageStyle = webGLRenderWindow.getReferenceByName("bgImage").style + imageStyle.transition = "opacity 0.1s ease-in" + imageStyle.zIndex = 1 + resize(container.value.$el.offsetWidth, container.value.$el.offsetHeight) + + useMousePressed({ + target: container, + onPressed: (event) => { + if (event.button == 0) { + is_moving.value = true + event.stopPropagation() + imageStyle.opacity = 0 + } + }, + onReleased: () => { + is_moving.value = false + syncRemoteCamera() + }, + }) + + let wheelEventEndTimeout = null + useEventListener(container, "wheel", () => { + is_moving.value = true + imageStyle.opacity = 0 + clearTimeout(wheelEventEndTimeout) + wheelEventEndTimeout = setTimeout(() => { + is_moving.value = false + syncRemoteCamera() + }, 600) + }) + } + + async function resize(width, height) { + if ( + viewer_store.status !== Status.CONNECTED || + status.value !== Status.CREATED + ) { + return + } + const webGLRenderWindow = + genericRenderWindow.value.getApiSpecificRenderWindow() + const canvas = webGLRenderWindow.getCanvas() + canvas.width = width + canvas.height = height + await nextTick() + webGLRenderWindow.setSize(width, height) + viewStream.setSize(width, height) + const renderWindow = genericRenderWindow.value.getRenderWindow() + renderWindow.render() + remoteRender() + } + + return { + db, + genericRenderWindow, + addItem, + setZScaling, + syncRemoteCamera, + initHybridViewer, + resize, + setContainer, + zScale, + } +}) diff --git a/stores/menu.js b/stores/menu.js new file mode 100644 index 00000000..f6fd0fb7 --- /dev/null +++ b/stores/menu.js @@ -0,0 +1,182 @@ +// PointSet components +import PointSetPointsOptions from "@ogw_f/components/Viewer/PointSet/PointsOptions.vue" + +// EdgedCurve components +import EdgedCurvePointsOptions from "@ogw_f/components/Viewer/EdgedCurve/PointsOptions.vue" +import EdgedCurveEdgesOptions from "@ogw_f/components/Viewer/EdgedCurve/EdgesOptions.vue" + +// PolygonalSurface components +import PolygonalSurfacePointsOptions from "@ogw_f/components/Viewer/PolygonalSurface/PointsOptions.vue" +import PolygonalSurfaceEdgesOptions from "@ogw_f/components/Viewer/PolygonalSurface/EdgesOptions.vue" +import PolygonalSurfacePolygonsOptions from "@ogw_f/components/Viewer/PolygonalSurface/PolygonsOptions.vue" + +// TriangulatedSurface components +import TriangulatedSurfacePointsOptions from "@ogw_f/components/Viewer/TriangulatedSurface/PointsOptions.vue" +import TriangulatedSurfaceEdgesOptions from "@ogw_f/components/Viewer/TriangulatedSurface/EdgesOptions.vue" +import TriangulatedSurfaceTrianglesOptions from "@ogw_f/components/Viewer/TriangulatedSurface/TrianglesOptions.vue" + +// Grid 2D components +import Grid2DPointsOptions from "@ogw_f/components/Viewer/Grid/2D/PointsOptions.vue" +import Grid2DEdgesOptions from "@ogw_f/components/Viewer/Grid/2D/EdgesOptions.vue" +import Grid2DCellsOptions from "@ogw_f/components/Viewer/Grid/2D/CellsOptions.vue" + +// Grid 3D components +import Grid3DPointsOptions from "@ogw_f/components/Viewer/Grid/3D/PointsOptions.vue" +import Grid3DEdgesOptions from "@ogw_f/components/Viewer/Grid/3D/EdgesOptions.vue" +import Grid3DFacetsOptions from "@ogw_f/components/Viewer/Grid/3D/FacetsOptions.vue" +import Grid3DCellsOptions from "@ogw_f/components/Viewer/Grid/3D/CellsOptions.vue" + +// Solid components +import SolidPointsOptions from "@ogw_f/components/Viewer/Solid/PointsOptions.vue" +import SolidEdgesOptions from "@ogw_f/components/Viewer/Solid/EdgesOptions.vue" +import SolidPolygonsOptions from "@ogw_f/components/Viewer/Solid/PolygonsOptions.vue" +import SolidPolyhedraOptions from "@ogw_f/components/Viewer/Solid/PolyhedraOptions.vue" + +// TetrahedralSolid components +import TetrahedralSolidTrianglesOptions from "@ogw_f/components/Viewer/TetrahedralSolid/TrianglesOptions.vue" +import TetrahedralSolidTetrahedraOptions from "@ogw_f/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue" + +// Model components +import ModelEdgesOptions from "@ogw_f/components/Viewer/Generic/Model/EdgesOptions.vue" +import ModelPointsOptions from "@ogw_f/components/Viewer/Generic/Model/PointsOptions.vue" + +const PointSet_menu = [PointSetPointsOptions] + +const EdgedCurve_menu = [EdgedCurvePointsOptions, EdgedCurveEdgesOptions] + +const PolygonalSurface_menu = [ + PolygonalSurfacePointsOptions, + PolygonalSurfaceEdgesOptions, + PolygonalSurfacePolygonsOptions, +] + +const TriangulatedSurface_menu = [ + TriangulatedSurfacePointsOptions, + TriangulatedSurfaceEdgesOptions, + TriangulatedSurfaceTrianglesOptions, +] + +const Grid2D_menu = [ + Grid2DPointsOptions, + Grid2DEdgesOptions, + Grid2DCellsOptions, +] +const Grid3D_menu = [ + Grid3DPointsOptions, + Grid3DEdgesOptions, + Grid3DFacetsOptions, + Grid3DCellsOptions, +] + +const Solid_menu = [ + SolidPointsOptions, + SolidEdgesOptions, + SolidPolygonsOptions, + SolidPolyhedraOptions, +] + +const TetrahedralSolid_menu = [ + SolidPointsOptions, + SolidEdgesOptions, + TetrahedralSolidTrianglesOptions, + TetrahedralSolidTetrahedraOptions, +] + +const BRep_menu = [ModelEdgesOptions, ModelPointsOptions] + +const CrossSection_menu = [ModelEdgesOptions, ModelPointsOptions] + +const ImplicitCrossSection_menu = [ModelEdgesOptions, ModelPointsOptions] +const ImplicitStructuralModel_menu = [ModelEdgesOptions, ModelPointsOptions] + +const Section_menu = [ModelEdgesOptions, ModelPointsOptions] + +const StructuralModel_menu = [ModelEdgesOptions, ModelPointsOptions] + +const menusData = { + mesh: { + EdgedCurve2D: EdgedCurve_menu, + EdgedCurve3D: EdgedCurve_menu, + HybridSolid3D: Solid_menu, + LightRegularGrid2D: Grid2D_menu, + LightRegularGrid3D: Grid3D_menu, + PointSet2D: PointSet_menu, + PointSet3D: PointSet_menu, + PolygonalSurface2D: PolygonalSurface_menu, + PolygonalSurface3D: PolygonalSurface_menu, + PolyhedralSolid3D: Solid_menu, + RegularGrid2D: Grid2D_menu, + RegularGrid3D: Grid3D_menu, + TetrahedralSolid3D: TetrahedralSolid_menu, + TriangulatedSurface2D: TriangulatedSurface_menu, + TriangulatedSurface3D: TriangulatedSurface_menu, + }, + model: { + BRep: BRep_menu, + CrossSection: CrossSection_menu, + ImplicitCrossSection: ImplicitCrossSection_menu, + ImplicitStructuralModel: ImplicitStructuralModel_menu, + Section: Section_menu, + StructuralModel: StructuralModel_menu, + }, +} + +export const useMenuStore = defineStore("menu", () => { + const menus = ref(menusData) + const display_menu = ref(false) + const current_id = ref(null) + const menuX = ref(0) + const menuY = ref(0) + const containerWidth = ref(window.innerWidth) + const containerHeight = ref(window.innerHeight) + + function getMenuItems(objectType, geodeObject) { + if (!objectType || !geodeObject || !menus.value[objectType]) { + return [] + } + return menus.value[objectType][geodeObject] || [] + } + + function closeMenu() { + display_menu.value = false + current_id.value = null + } + + async function openMenu(id, x, y, containerWidth, containerHeight) { + await closeMenu() + current_id.value = id + + if (x !== undefined && y !== undefined) { + menuX.value = x + menuY.value = y + } + + if (containerWidth) containerWidth.value = containerWidth + if (containerHeight) containerHeight.value = containerHeight + + display_menu.value = true + } + + function showItemsWithDelay() { + const DELAY = 50 + const items = getMenuItems() + items.forEach((item, index) => { + setTimeout(() => { + item.visible = true + }, index * DELAY) + }) + } + + return { + display_menu, + current_id, + menuX, + menuY, + containerWidth, + containerHeight, + getMenuItems, + closeMenu, + openMenu, + showItemsWithDelay, + } +}) diff --git a/stores/treeview.js b/stores/treeview.js new file mode 100644 index 00000000..0d1afa06 --- /dev/null +++ b/stores/treeview.js @@ -0,0 +1,64 @@ +export const use_treeview_store = defineStore("treeview", () => { + const dataStyleStore = useDataStyleStore() + + /** State **/ + const items = ref([]) + const selection = ref([]) + const components_selection = ref([]) + const isAdditionnalTreeDisplayed = ref(false) + const panelWidth = ref(300) + const model_id = ref("") + const isTreeCollection = ref(false) + const selectedTree = ref(null) + + /** Functions **/ + function addItem(geodeObject, displayed_name, id, object_type) { + dataStyleStore.addDataStyle(id, geodeObject, object_type) + const child = { title: displayed_name, id, object_type } + for (let i = 0; i < items.value.length; i++) { + if (items.value[i].title === geodeObject) { + items.value[i].children.push(child) + selection.value.push(child) + return + } + } + items.value.push({ title: geodeObject, children: [child] }) + selection.value.push(child) + } + + function displayAdditionalTree(id) { + isAdditionnalTreeDisplayed.value = true + model_id.value = id + } + + function displayFileTree() { + isAdditionnalTreeDisplayed.value = false + } + + function toggleTreeView() { + isTreeCollection.value = !isTreeCollection.value + console.log( + "Switched to", + isTreeCollection.value ? "TreeCollection" : "TreeComponent", + ) + } + + function setPanelWidth(width) { + panelWidth.value = width + } + + return { + items, + selection, + components_selection, + isAdditionnalTreeDisplayed, + panelWidth, + model_id, + selectedTree, + addItem, + displayAdditionalTree, + displayFileTree, + toggleTreeView, + setPanelWidth, + } +})