From 3322116afa10854ea21a102042e2e90750a7969d Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Tue, 14 May 2024 13:02:24 +0200 Subject: [PATCH] use viewer in examples --- docs/examples/example_mesh_basic.py | 16 +++++++-------- .../example_mesh_constrained_on-arch.py | 20 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/examples/example_mesh_basic.py b/docs/examples/example_mesh_basic.py index e47b947..b1c5430 100644 --- a/docs/examples/example_mesh_basic.py +++ b/docs/examples/example_mesh_basic.py @@ -6,7 +6,7 @@ from compas.geometry import Vector from compas_dr.numdata import InputData from compas_dr.solvers import dr_numpy -from compas_view2.app import App +from compas_viewer import Viewer # ============================================================================= # Input @@ -38,11 +38,11 @@ forcecolor = Color.green().darkened(50) -viewer = App() -viewer.view.camera.position = [5, -5, 20] -viewer.view.camera.look_at([5, 5, 0]) +viewer = Viewer() +viewer.renderer.camera.target = [5, 5, 0] +viewer.renderer.camera.position = [5, 4, 20] -viewer.add(mesh) +viewer.scene.add(mesh, show_points=False) for vertex in fixed: point = Point(*mesh.vertex_coordinates(vertex)) @@ -51,7 +51,7 @@ ball = Sphere(radius=0.1, point=point).to_brep() line = Line(point, point - residual) - viewer.add(ball, facecolor=Color.red()) - viewer.add(line, linecolor=forcecolor, linewidth=3) + viewer.scene.add(ball, surfacecolor=Color.red()) + viewer.scene.add(line, linecolor=forcecolor, lineswidth=3, show_points=False) -viewer.run() +viewer.show() diff --git a/docs/examples/example_mesh_constrained_on-arch.py b/docs/examples/example_mesh_constrained_on-arch.py index cc314b6..5efd07d 100644 --- a/docs/examples/example_mesh_constrained_on-arch.py +++ b/docs/examples/example_mesh_constrained_on-arch.py @@ -8,7 +8,7 @@ from compas_dr.constraints import Constraint from compas_dr.numdata import InputData from compas_dr.solvers import dr_constrained_numpy -from compas_view2.app import App +from compas_viewer import Viewer # ============================================================================= # Input @@ -54,22 +54,22 @@ forcecolor = Color.green().darkened(50) -viewer = App() -viewer.view.camera.position = [-7, -10, 5] -viewer.view.camera.look_at([5, 5, 2]) +viewer = Viewer() +viewer.renderer.camera.target = [5, 5, 2] +viewer.renderer.camera.position = [-7, -10, 5] -viewer.add(mesh) -viewer.add(arch.to_polyline(), linecolor=Color.cyan(), linewidth=3) +viewer.scene.add(mesh, show_points=False) +viewer.scene.add(arch.to_polyline(), linecolor=Color.cyan(), lineswidth=3, show_points=False) for vertex in fixed: point = Point(*mesh.vertex_coordinates(vertex)) - residual = Vector(*result.residuals[vertex]) * 0.1 + residual = Vector(*result.residuals[vertex]) * 0.5 ball = Sphere(radius=0.1, point=point).to_brep() line = Line(point, point - residual) ballcolor = Color.blue() if constraints[vertex] else Color.red() - viewer.add(ball, facecolor=ballcolor) - viewer.add(line, linecolor=forcecolor, linewidth=3) + viewer.scene.add(ball, surfacecolor=ballcolor, show_points=False) + viewer.scene.add(line, linecolor=forcecolor, lineswidth=3, show_points=False) -viewer.run() +viewer.show()