Skip to content

Commit 9265c13

Browse files
authored
Allow to set view perspective (#1991)
1 parent ac575ab commit 9265c13

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cadquery/vis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def show(
410410
xpos: Union[int, float] = 0,
411411
ypos: Union[int, float] = 0,
412412
fxaa: bool = True,
413+
orthographic: bool = False,
413414
):
414415
"""
415416
Show CQ objects using VTK. This functions optionally allows to make screenshots.
@@ -506,6 +507,9 @@ def show(
506507
# set camera
507508
camera = renderer.GetActiveCamera()
508509

510+
# set perspective or parallel (orthographic) projection
511+
camera.SetParallelProjection(orthographic)
512+
509513
# Update camera position with user provided absolute positions
510514
if viewup:
511515
camera.SetViewUp(*viewup)

tests/test_vis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,8 @@ def test_camera_position(wp, patch_vtk):
234234
def test_frustrum_clipping_range(wp, patch_vtk):
235235

236236
show(wp, zoom=2.0, clipping_range=(1, 100))
237+
238+
239+
def test_orthographic(wp, patch_vtk):
240+
241+
show(wp, orthographic=True)

0 commit comments

Comments
 (0)