diff --git a/app/components/Viewer/EdgedCurve/EdgesOptions.vue b/app/components/Viewer/EdgedCurve/EdgesOptions.vue index 6c98546a..faa4f24f 100644 --- a/app/components/Viewer/EdgedCurve/EdgesOptions.vue +++ b/app/components/Viewer/EdgedCurve/EdgesOptions.vue @@ -1,15 +1,17 @@ diff --git a/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue new file mode 100644 index 00000000..eca0430e --- /dev/null +++ b/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue @@ -0,0 +1,105 @@ + + + diff --git a/app/components/Viewer/Generic/Mesh/CellsOptions.vue b/app/components/Viewer/Generic/Mesh/CellsOptions.vue index 7eb4ef3a..2343ebe2 100644 --- a/app/components/Viewer/Generic/Mesh/CellsOptions.vue +++ b/app/components/Viewer/Generic/Mesh/CellsOptions.vue @@ -3,6 +3,7 @@ :itemProps="props.itemProps" :tooltip="props.tooltip" :btn_image="props.btn_image" + :index="props.index" > @@ -11,5 +12,6 @@ const props = defineProps({ itemProps: { type: Object, required: true }, + index: { type: Number, required: true }, }) diff --git a/app/components/Viewer/Solid/PolyhedraOptions.vue b/app/components/Viewer/Solid/PolyhedraOptions.vue index 3828966a..7ba7b8ff 100644 --- a/app/components/Viewer/Solid/PolyhedraOptions.vue +++ b/app/components/Viewer/Solid/PolyhedraOptions.vue @@ -1,15 +1,17 @@ diff --git a/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue new file mode 100644 index 00000000..ed18cf01 --- /dev/null +++ b/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue @@ -0,0 +1,78 @@ + + + diff --git a/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue b/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue index 1e58b835..4cb41219 100644 --- a/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +++ b/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue @@ -3,6 +3,7 @@ :itemProps="props.itemProps" :btn_image="TetrahedralSolidTetrahedra" tooltip="Tetrahedra options" + :index="props.index" /> @@ -12,5 +13,6 @@ const props = defineProps({ itemProps: { type: Object, required: true }, + index: { type: Number, required: true }, }) diff --git a/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue b/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue index a1cb4fde..559dfac4 100644 --- a/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +++ b/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue @@ -3,6 +3,7 @@ :itemProps="props.itemProps" :btn_image="TetrahedralSolidTriangles" tooltip="Triangles options" + :index="props.index" /> @@ -12,5 +13,6 @@ const props = defineProps({ itemProps: { type: Object, required: true }, + index: { type: Number, required: true }, }) diff --git a/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue b/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue index f17e779f..d1e16ff4 100644 --- a/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue +++ b/app/components/Viewer/TriangulatedSurface/EdgesOptions.vue @@ -2,6 +2,7 @@ @@ -11,5 +12,6 @@ const props = defineProps({ itemProps: { type: Object, required: true }, + index: { type: Number, required: true }, }) diff --git a/app/components/Viewer/TriangulatedSurface/PointsOptions.vue b/app/components/Viewer/TriangulatedSurface/PointsOptions.vue index fb8093e9..459f445f 100644 --- a/app/components/Viewer/TriangulatedSurface/PointsOptions.vue +++ b/app/components/Viewer/TriangulatedSurface/PointsOptions.vue @@ -2,6 +2,7 @@ @@ -11,5 +12,6 @@ const props = defineProps({ itemProps: { type: Object, required: true }, + index: { type: Number, required: true }, }) diff --git a/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue b/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue index ba5e30c3..1e55f246 100644 --- a/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue +++ b/app/components/Viewer/TriangulatedSurface/TrianglesOptions.vue @@ -1,16 +1,18 @@ diff --git a/app/stores/geode.js b/app/stores/geode.js index 61623b76..1d1a975c 100644 --- a/app/stores/geode.js +++ b/app/stores/geode.js @@ -44,36 +44,33 @@ export const useGeodeStore = defineStore("geode", { }, }, actions: { - ping_task() { + set_ping() { + this.ping() setInterval(() => { - this.do_ping() + this.ping() }, 10 * 1000) }, - do_ping() { + ping() { const geodeStore = this const feedbackStore = useFeedbackStore() - return $fetch(back_schemas.opengeodeweb_back.ping.$id, { - baseURL: this.base_url, - method: back_schemas.opengeodeweb_back.ping.methods[0], - body: {}, - onResponse({ response }) { - if (response.ok) { + return this.request( + back_schemas.opengeodeweb_back.ping, + {}, + { + request_error_function: () => { + feedbackStore.$patch({ server_error: true }) + geodeStore.status = Status.NOT_CONNECTED + }, + response_function: () => { feedbackStore.$patch({ server_error: false }) geodeStore.status = Status.CONNECTED - } - }, - onResponseError({ response }) { - feedbackStore.$patch({ server_error: true }) - geodeStore.status = Status.NOT_CONNECTED - }, - onRequestError({ error }) { - feedbackStore.$patch({ server_error: true }) - geodeStore.status = Status.NOT_CONNECTED + }, + response_error_function: () => { + feedbackStore.$patch({ server_error: true }) + geodeStore.status = Status.NOT_CONNECTED + }, }, - }) - }, - ping() { - return this.do_ping() + ) }, start_request() { this.request_counter++ @@ -87,7 +84,8 @@ export const useGeodeStore = defineStore("geode", { }, connect() { console.log("[GEODE] Connecting to geode microservice...") - return this.ping_task() + this.set_ping() + return Promise.resolve() }, request(schema, params, callbacks = {}) { console.log("[GEODE] Request:", schema.$id) diff --git a/app/utils/default_styles.js b/app/utils/default_styles.js index 517cf33b..58a61bde 100644 --- a/app/utils/default_styles.js +++ b/app/utils/default_styles.js @@ -7,7 +7,7 @@ const polygons_defaultVisibility = true const polyhedra_defaultVisibility = true const points_defaultSize = 10 const points_defaultColor = { r: 20, g: 20, b: 20 } -const edges_defaultSize = 5 +const edges_defaultWidth = 2 const edges_defaultColor = { r: 20, g: 20, b: 20 } const cells_defaultColor = { r: 255, g: 255, b: 255 } const polygons_defaultColor = { r: 255, g: 255, b: 255 } @@ -41,7 +41,7 @@ const meshPointsDefaultStyle = ( const meshEdgesDefaultStyle = ( visibility = edges_defaultVisibility, - size = edges_defaultSize, + width = edges_defaultWidth, color = edges_defaultColor, ) => { return { @@ -49,8 +49,10 @@ const meshEdgesDefaultStyle = ( coloring: { active: "color", color, + edge: null, + vertex: null, }, - size, + width, } } @@ -196,7 +198,7 @@ const brep_defaultStyle = () => { surfaces: modelSurfacesDefaultStyle(), blocks: modelBlocksDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } @@ -207,7 +209,7 @@ const crossSection_defaultStyle = () => { lines: modelLinesDefaultStyle(), surfaces: modelSurfacesDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } @@ -219,7 +221,7 @@ const structuralModel_defaultStyle = () => { surfaces: modelSurfacesDefaultStyle(), blocks: modelBlocksDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } @@ -230,7 +232,7 @@ const section_defaultStyle = () => { lines: modelLinesDefaultStyle(), surfaces: modelSurfacesDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } @@ -241,7 +243,7 @@ const implicitCrossSection_defaultStyle = () => { lines: modelLinesDefaultStyle(), surfaces: modelSurfacesDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } @@ -253,7 +255,7 @@ const implicitStructuralModel_defaultStyle = () => { surfaces: modelSurfacesDefaultStyle(), blocks: modelBlocksDefaultStyle(), points: modelPointsDefaultStyle(false, points_defaultSize), - edges: modelEdgesDefaultStyle(false, edges_defaultSize), + edges: modelEdgesDefaultStyle(false, edges_defaultWidth), } } diff --git a/internal/stores/mesh/edges.js b/internal/stores/mesh/edges.js index 7755c093..19fa0e84 100644 --- a/internal/stores/mesh/edges.js +++ b/internal/stores/mesh/edges.js @@ -49,10 +49,16 @@ export function useMeshEdgesStyle() { ) if (type === "color") { return setMeshEdgesColor(id, coloring.color) - // } else if (type == "vertex" && coloring.vertex !== null) { - // return setEdgesVertexAttribute(id, coloring.vertex) - // } else if (type == "edges" && coloring.edges !== null) { - // return setEdgesEdgeAttribute(id, coloring.edges) + } else if (type === "vertex") { + if (coloring.vertex === null) { + return + } + return setMeshEdgesVertexAttribute(id, coloring.vertex) + } else if (type === "edge") { + if (coloring.edge === null) { + return + } + return setMeshEdgesEdgeAttribute(id, coloring.edge) } else { throw new Error("Unknown mesh edges coloring type: " + type) } @@ -80,7 +86,7 @@ export function useMeshEdgesStyle() { } function meshEdgesWidth(id) { - return meshEdgesStyle(id).size + return meshEdgesStyle(id).width } function setMeshEdgesWidth(id, width) { const edges_style = meshEdgesStyle(id) @@ -96,12 +102,54 @@ export function useMeshEdgesStyle() { ) } + function meshEdgesVertexAttribute(id) { + return meshEdgesStyle(id).coloring.vertex + } + function setMeshEdgesVertexAttribute(id, vertex_attribute) { + const coloring_style = meshEdgesStyle(id).coloring + return viewerStore.request( + mesh_edges_schemas.vertex_attribute, + { id, ...vertex_attribute }, + { + response_function: () => { + coloring_style.vertex = vertex_attribute + console.log( + setMeshEdgesVertexAttribute.name, + { id }, + meshEdgesVertexAttribute(id), + ) + }, + }, + ) + } + + function meshEdgesEdgeAttribute(id) { + return meshEdgesStyle(id).coloring.edge + } + function setMeshEdgesEdgeAttribute(id, edge_attribute) { + const coloring_style = meshEdgesStyle(id).coloring + return viewerStore.request( + mesh_edges_schemas.edge_attribute, + { id, ...edge_attribute }, + { + response_function: () => { + coloring_style.edge = edge_attribute + console.log( + setMeshEdgesEdgeAttribute.name, + { id }, + meshEdgesEdgeAttribute(id), + ) + }, + }, + ) + } + function applyMeshEdgesStyle(id) { const style = meshEdgesStyle(id) return Promise.all([ setMeshEdgesVisibility(id, style.visibility), setMeshEdgesActiveColoring(id, style.coloring.active), - // setMeshEdgesWidth(id, style.width); + setMeshEdgesWidth(id, style.width), ]) } @@ -111,9 +159,13 @@ export function useMeshEdgesStyle() { meshEdgesColor, meshEdgesVisibility, meshEdgesWidth, + meshEdgesVertexAttribute, + meshEdgesEdgeAttribute, setMeshEdgesActiveColoring, setMeshEdgesColor, setMeshEdgesVisibility, setMeshEdgesWidth, + setMeshEdgesVertexAttribute, + setMeshEdgesEdgeAttribute, } } diff --git a/internal/stores/mesh/points.js b/internal/stores/mesh/points.js index 6627f836..38e63746 100644 --- a/internal/stores/mesh/points.js +++ b/internal/stores/mesh/points.js @@ -48,9 +48,12 @@ export function useMeshPointsStyle() { { id }, meshPointsActiveColoring(id), ) - if (type == "color") { + if (type === "color") { return setMeshPointsColor(id, coloring.color) - } else if (type == "vertex" && coloring.vertex !== null) { + } else if (type === "vertex") { + if (coloring.vertex === null) { + return + } return setMeshPointsVertexAttribute(id, coloring.vertex) } else { throw new Error("Unknown mesh points coloring type: " + type) diff --git a/internal/stores/mesh/polyhedra.js b/internal/stores/mesh/polyhedra.js index e44f8ee4..6e76e8c7 100644 --- a/internal/stores/mesh/polyhedra.js +++ b/internal/stores/mesh/polyhedra.js @@ -49,10 +49,16 @@ export function useMeshPolyhedraStyle() { ) if (type === "color") { return setMeshPolyhedraColor(id, coloring.color) - // } else if (type === "vertex" && coloring.vertex !== null) { - // return setPolyhedraVertexAttribute(id, coloring.vertex) - // } else if (type === "polyhedron" && coloring.polyhedron !== null) { - // return setPolyhedraPolyhedronAttribute(id, coloring.polyhedron) + } else if (type === "vertex") { + if (coloring.vertex === null) { + return + } + return setPolyhedraVertexAttribute(id, coloring.vertex) + } else if (type === "polyhedron") { + if (coloring.polyhedron === null) { + return + } + return setPolyhedraPolyhedronAttribute(id, coloring.polyhedron) } else { throw new Error("Unknown mesh polyhedra coloring type: " + type) } @@ -79,62 +85,47 @@ export function useMeshPolyhedraStyle() { ) } - // function polyhedraVertexAttribute(id) { - // return meshPolyhedraStyle(id).coloring.vertex - // } - // function setPolyhedraVertexAttribute(id, vertex_attribute) { - // const coloring_style = meshPolyhedraStyle(id).coloring - // return viewerStore.request( - // mesh_polyhedra_schemas.vertex_attribute, - // { id, ...vertex_attribute }, - // { - // response_function: () => { - // coloring_style.vertex = vertex_attribute - // console.log( - // setPolyhedraVertexAttribute.name} ${polyhedraVertexAttribute(id), - // ) - // }, - // }, - // ) - // } - - // function polyhedraPolygonAttribute(id) { - // return meshPolyhedraStyle(id).coloring.polygon - // } - // function setPolyhedraPolygonAttribute(id, polygon_attribute) { - // const coloring_style = meshPolyhedraStyle(id).coloring - // return viewerStore.request( - // mesh_polyhedra_schemas.polygon_attribute, - // { id, ...polygon_attribute }, - // { - // response_function: () => { - // coloring_style.polygon = polygon_attribute - // console.log( - // setPolyhedraPolygonAttribute.name} ${polyhedraPolygonAttribute(id), - // ) - // }, - // }, - // ) - // } + function polyhedraVertexAttribute(id) { + return meshPolyhedraStyle(id).coloring.vertex + } + function setPolyhedraVertexAttribute(id, vertex_attribute) { + const coloring_style = meshPolyhedraStyle(id).coloring + return viewerStore.request( + mesh_polyhedra_schemas.vertex_attribute, + { id, ...vertex_attribute }, + { + response_function: () => { + coloring_style.vertex = vertex_attribute + console.log( + setPolyhedraVertexAttribute.name, + { id }, + polyhedraVertexAttribute(id), + ) + }, + }, + ) + } - // function polyhedraPolyhedronAttribute(id) { - // return meshPolyhedraStyle(id).coloring.polyhedron - // } - // function setPolyhedraPolyhedronAttribute(id, polyhedron_attribute) { - // const coloring = meshPolyhedraStyle(id).coloring - // return viewerStore.request( - // mesh_polyhedra_schemas.polyhedron_attribute, - // { id, ...polyhedron_attribute }, - // { - // response_function: () => { - // coloring.polyhedron = polyhedron_attribute - // console.log( - // setPolyhedraPolyhedronAttribute.name} ${polyhedraPolyhedronAttribute(id), - // ) - // }, - // }, - // ) - // } + function polyhedraPolyhedronAttribute(id) { + return meshPolyhedraStyle(id).coloring.polyhedron + } + function setPolyhedraPolyhedronAttribute(id, polyhedron_attribute) { + const coloring = meshPolyhedraStyle(id).coloring + return viewerStore.request( + mesh_polyhedra_schemas.polyhedron_attribute, + { id, ...polyhedron_attribute }, + { + response_function: () => { + coloring.polyhedron = polyhedron_attribute + console.log( + setPolyhedraPolyhedronAttribute.name, + { id }, + polyhedraPolyhedronAttribute(id), + ) + }, + }, + ) + } function applyMeshPolyhedraStyle(id) { const style = meshPolyhedraStyle(id) @@ -148,15 +139,13 @@ export function useMeshPolyhedraStyle() { applyMeshPolyhedraStyle, meshPolyhedraActiveColoring, meshPolyhedraColor, - // polyhedraVertexAttribute, + polyhedraVertexAttribute, meshPolyhedraVisibility, - // polyhedraPolyhedronAttribute, - // polyhedraPolygonAttribute, + polyhedraPolyhedronAttribute, setMeshPolyhedraActiveColoring, setMeshPolyhedraColor, - // setPolyhedraPolyhedronAttribute, - // setPolyhedraPolygonAttribute, - // setPolyhedraVertexAttribute, + setPolyhedraPolyhedronAttribute, + setPolyhedraVertexAttribute, setMeshPolyhedraVisibility, } } diff --git a/tests/integration/data/uploads/test.og_edc3d b/tests/integration/data/uploads/test.og_edc3d new file mode 100644 index 00000000..6dbeaf77 Binary files /dev/null and b/tests/integration/data/uploads/test.og_edc3d differ diff --git a/tests/integration/data/uploads/test.vtu b/tests/integration/data/uploads/test.vtu new file mode 100644 index 00000000..7c86fa9c --- /dev/null +++ b/tests/integration/data/uploads/test.vtu @@ -0,0 +1,22 @@ + + + + + + 1 2 3 4 5 6 7 8 9 10 11 + 0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 + + + 0 0 0 1 0 0 2 1 0 1 2 0 0 2 0 0 0 1 1 0 1 2 1 1 1 2 1 0 2 1 1 1 2 + + + 3 4 5 6 + + + 0 1 3 4 5 6 8 9 1 2 3 6 7 8 5 6 8 9 10 6 7 8 10 + 8 14 19 23 + 12 13 14 10 + + + + diff --git a/tests/integration/microservices/back/requirements.txt b/tests/integration/microservices/back/requirements.txt index ecd51b9e..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.0rc1 diff --git a/tests/integration/microservices/viewer/requirements.txt b/tests/integration/microservices/viewer/requirements.txt index 8293def3..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.14.0 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 56130974..b2cce4ae 100644 --- a/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/edges.nuxt.test.js @@ -15,8 +15,9 @@ import { setupIntegrationTests } from "../../../setup" // Local constants const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges -const file_name = "test.og_edc2d" -const geode_object = "EdgedCurve2D" +const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points +const file_name = "test.og_edc3d" +const geode_object = "EdgedCurve3D" let id, back_port, viewer_port, project_folder_path @@ -36,9 +37,9 @@ afterEach(async () => { delete_folder_recursive(project_folder_path) }) -describe("Mesh edges", () => { - describe("Edges visibility", () => { - test("Visibility true", async () => { +describe("Mesh EdgedCurve3D", () => { + describe("Edges", () => { + test("Edges visibility", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const visibility = true @@ -54,10 +55,8 @@ describe("Mesh edges", () => { expect(dataStyleStore.meshEdgesVisibility(id)).toBe(visibility) expect(viewerStore.status).toBe(Status.CONNECTED) }) - }) - describe("Edges color", () => { - test("Color red", async () => { + test("Edges color red", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const color = { r: 255, g: 0, b: 0 } @@ -73,13 +72,11 @@ describe("Mesh edges", () => { expect(dataStyleStore.meshEdgesColor(id)).toStrictEqual(color) expect(viewerStore.status).toBe(Status.CONNECTED) }) - }) - describe("Edges active coloring", () => { - test("test coloring", async () => { + test("Edges active coloring", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() - const coloringTypes = ["color"] + const coloringTypes = ["color", "vertex", "edge"] for (let i = 0; i < coloringTypes.length; i++) { dataStyleStore.setMeshEdgesActiveColoring(id, coloringTypes[i]) expect(dataStyleStore.meshEdgesActiveColoring(id)).toBe( @@ -88,5 +85,43 @@ describe("Mesh edges", () => { expect(viewerStore.status).toBe(Status.CONNECTED) } }) + + test("Edges vertex attribute", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const vertex_attribute = { name: "vertex_attribute" } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setMeshEdgesVertexAttribute(id, vertex_attribute) + expect(spy).toHaveBeenCalledWith( + mesh_edges_schemas.vertex_attribute, + { id, ...vertex_attribute }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.meshEdgesVertexAttribute(id)).toStrictEqual( + vertex_attribute, + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) + + test("Edges edge attribute", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const edge_attribute = { name: "edge_attribute" } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setMeshEdgesEdgeAttribute(id, edge_attribute) + expect(spy).toHaveBeenCalledWith( + mesh_edges_schemas.edge_attribute, + { id, ...edge_attribute }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.meshEdgesEdgeAttribute(id)).toStrictEqual( + edge_attribute, + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) }) }) 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 90df2076..7c717ea4 100644 --- a/tests/integration/stores/data_style/mesh/points.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/points.nuxt.test.js @@ -107,5 +107,24 @@ describe("Mesh points", () => { expect(dataStyleStore.meshPointsSize(id)).toBe(size) expect(viewerStore.status).toBe(Status.CONNECTED) }) + + test("Points vertex attribute", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const vertex_attribute = { name: "points" } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setMeshPointsVertexAttribute(id, vertex_attribute) + expect(spy).toHaveBeenCalledWith( + mesh_points_schemas.vertex_attribute, + { id, ...vertex_attribute }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.meshPointsVertexAttribute(id)).toStrictEqual( + 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 b445d919..7b63dd2c 100644 --- a/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js @@ -15,6 +15,7 @@ import { setupIntegrationTests } from "../../../setup" // Local constants const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons +const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points const file_name = "test.og_psf3d" const geode_object = "PolygonalSurface3D" @@ -23,7 +24,7 @@ let id, back_port, viewer_port, project_folder_path beforeEach(async () => { ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) -}, 20000) +}, 25000) afterEach(async () => { console.log( @@ -76,6 +77,21 @@ describe("Mesh polygons", () => { }) }) + describe("Polygons active coloring", () => { + test("test coloring", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const coloringTypes = ["color", "vertex", "polygon"] + for (let i = 0; i < coloringTypes.length; i++) { + dataStyleStore.setMeshPolygonsActiveColoring(id, coloringTypes[i]) + expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe( + coloringTypes[i], + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + } + }) + }) + describe("Polygons vertex attribute", () => { test("Coloring vertex attribute", async () => { const dataStyleStore = useDataStyleStore() @@ -120,19 +136,4 @@ describe("Mesh polygons", () => { expect(viewerStore.status).toBe(Status.CONNECTED) }) }) - - describe("Polygons active coloring", () => { - test("test coloring", async () => { - const dataStyleStore = useDataStyleStore() - const viewerStore = useViewerStore() - const coloringTypes = ["color", "vertex", "polygon"] - for (let i = 0; i < coloringTypes.length; i++) { - dataStyleStore.setMeshPolygonsActiveColoring(id, coloringTypes[i]) - expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe( - coloringTypes[i], - ) - 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 63399496..93a75f42 100644 --- a/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +++ b/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js @@ -15,15 +15,18 @@ import { setupIntegrationTests } from "../../../setup" // Local constants const mesh_polyhedra_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polyhedra -const file_name = "test.og_rgd3d" -const geode_object = "RegularGrid3D" +const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons +const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges +const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points +const file_name = "test.vtu" +const geode_object = "HybridSolid3D" let id, back_port, viewer_port, project_folder_path beforeEach(async () => { ;({ id, back_port, viewer_port, project_folder_path } = await setupIntegrationTests(file_name, geode_object)) -}, 20000) +}, 30000) afterEach(async () => { console.log( @@ -37,8 +40,8 @@ afterEach(async () => { }) describe("Mesh polyhedra", () => { - describe("Polyhedra visibility", () => { - test("Visibility true", async () => { + describe("Polyhedra", () => { + test("Polyhedra visibility", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const visibility = true @@ -54,12 +57,28 @@ describe("Mesh polyhedra", () => { expect(dataStyleStore.meshPolyhedraVisibility(id)).toBe(visibility) expect(viewerStore.status).toBe(Status.CONNECTED) }) - }) - describe("Polyhedra active coloring", () => { - test("test coloring", async () => { + + test("Polyhedra color red", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const color = { r: 255, g: 0, b: 0 } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setMeshPolyhedraColor(id, color) + expect(spy).toHaveBeenCalledWith( + mesh_polyhedra_schemas.color, + { id, color }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.meshPolyhedraColor(id)).toStrictEqual(color) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) + + test("Polyhedra active coloring", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() - const coloringTypes = ["color"] + const coloringTypes = ["color", "vertex", "polyhedron"] for (let i = 0; i < coloringTypes.length; i++) { dataStyleStore.setMeshPolyhedraActiveColoring(id, coloringTypes[i]) expect(dataStyleStore.meshPolyhedraActiveColoring(id)).toBe( @@ -68,23 +87,110 @@ describe("Mesh polyhedra", () => { expect(viewerStore.status).toBe(Status.CONNECTED) } }) + + test("Polyhedra vertex attribute", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const vertex_attribute = { name: "toto_on_vertices" } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setPolyhedraVertexAttribute(id, vertex_attribute) + expect(spy).toHaveBeenCalledWith( + mesh_polyhedra_schemas.vertex_attribute, + { id, ...vertex_attribute }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.polyhedraVertexAttribute(id)).toStrictEqual( + vertex_attribute, + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) + + test("Polyhedra polyhedron attribute", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const polyhedron_attribute = { name: "toto_on_polyhedra" } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setPolyhedraPolyhedronAttribute( + id, + polyhedron_attribute, + ) + expect(spy).toHaveBeenCalledWith( + mesh_polyhedra_schemas.polyhedron_attribute, + { id, ...polyhedron_attribute }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.polyhedraPolyhedronAttribute(id)).toStrictEqual( + polyhedron_attribute, + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) }) - describe("Polyhedra color", () => { - test("Color red", async () => { + + describe("Polygons", () => { + test("Polygons color red", async () => { const dataStyleStore = useDataStyleStore() const viewerStore = useViewerStore() const color = { r: 255, g: 0, b: 0 } const spy = vi.spyOn(viewerStore, "request") - await dataStyleStore.setMeshPolyhedraColor(id, color) + await dataStyleStore.setMeshPolygonsColor(id, color) expect(spy).toHaveBeenCalledWith( - mesh_polyhedra_schemas.color, + mesh_polygons_schemas.color, { id, color }, { response_function: expect.any(Function), }, ) - expect(dataStyleStore.meshPolyhedraColor(id)).toStrictEqual(color) + expect(dataStyleStore.meshPolygonsColor(id)).toStrictEqual(color) expect(viewerStore.status).toBe(Status.CONNECTED) }) + + test("Polygons active coloring", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const coloringTypes = ["color", "vertex", "polygon"] + for (let i = 0; i < coloringTypes.length; i++) { + dataStyleStore.setMeshPolygonsActiveColoring(id, coloringTypes[i]) + expect(dataStyleStore.meshPolygonsActiveColoring(id)).toBe( + coloringTypes[i], + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + } + }) + }) + + describe("Edges", () => { + test("Edges color red", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const color = { r: 255, g: 0, b: 0 } + const spy = vi.spyOn(viewerStore, "request") + await dataStyleStore.setMeshEdgesColor(id, color) + expect(spy).toHaveBeenCalledWith( + mesh_edges_schemas.color, + { id, color }, + { + response_function: expect.any(Function), + }, + ) + expect(dataStyleStore.meshEdgesColor(id)).toStrictEqual(color) + expect(viewerStore.status).toBe(Status.CONNECTED) + }) + + test("Edges active coloring", async () => { + const dataStyleStore = useDataStyleStore() + const viewerStore = useViewerStore() + const coloringTypes = ["color", "vertex", "edge"] + for (let i = 0; i < coloringTypes.length; i++) { + dataStyleStore.setMeshEdgesActiveColoring(id, coloringTypes[i]) + expect(dataStyleStore.meshEdgesActiveColoring(id)).toBe( + coloringTypes[i], + ) + expect(viewerStore.status).toBe(Status.CONNECTED) + } + }) }) })