MCPcopy
hub / github.com/CadQuery/cadquery / show

Function show

cadquery/vis.py:397–581  ·  view source on GitHub ↗

Show CQ objects using VTK. This functions optionally allows to make screenshots.

(
    *objs: Showable,
    scale: float = 0.2,
    alpha: float = 1,
    tolerance: float = 1e-3,
    edges: bool = False,
    specular: bool = True,
    title: str = "CQ viewer",
    screenshot: Optional[str] = None,
    interact: bool = True,
    zoom: float = 1.0,
    roll: float = -35,
    elevation: float = -45,
    azimuth: float = 0,
    position: Optional[Tuple[float, float, float]] = None,
    focus: Optional[Tuple[float, float, float]] = None,
    viewup: Optional[Tuple[float, float, float]] = None,
    clipping_range: Optional[Tuple[float, float]] = None,
    width: Union[int, float] = 0.5,
    height: Union[int, float] = 0.5,
    trihedron: bool = True,
    bgcolor: tuple[float, float, float] = (1, 1, 1),
    gradient: bool = True,
    xpos: Union[int, float] = 0,
    ypos: Union[int, float] = 0,
    fxaa: bool = False,
    orthographic: bool = False,
)

Source from the content-addressed store, hash-verified

395
396
397def show(
398 *objs: Showable,
399 scale: float = 0.2,
400 alpha: float = 1,
401 tolerance: float = 1e-3,
402 edges: bool = False,
403 specular: bool = True,
404 title: str = "CQ viewer",
405 screenshot: Optional[str] = None,
406 interact: bool = True,
407 zoom: float = 1.0,
408 roll: float = -35,
409 elevation: float = -45,
410 azimuth: float = 0,
411 position: Optional[Tuple[float, float, float]] = None,
412 focus: Optional[Tuple[float, float, float]] = None,
413 viewup: Optional[Tuple[float, float, float]] = None,
414 clipping_range: Optional[Tuple[float, float]] = None,
415 width: Union[int, float] = 0.5,
416 height: Union[int, float] = 0.5,
417 trihedron: bool = True,
418 bgcolor: tuple[float, float, float] = (1, 1, 1),
419 gradient: bool = True,
420 xpos: Union[int, float] = 0,
421 ypos: Union[int, float] = 0,
422 fxaa: bool = False,
423 orthographic: bool = False,
424):
425 """
426 Show CQ objects using VTK. This functions optionally allows to make screenshots.
427 """
428
429 # split objects
430 shapes, vecs, locs, props = _split_showables(objs)
431
432 # construct the assy
433 assy = _to_assy(*shapes, alpha=alpha)
434
435 # construct the points and locs
436 pts = _to_vtk_pts(vecs)
437 axs = _to_vtk_axs(locs, scale=scale)
438
439 # assy+renderer
440 renderer = vtkRenderer()
441
442 for act in toVTKAssy(assy, tolerance=tolerance):
443 renderer.AddActor(act)
444
445 # VTK window boilerplate
446 win = vtkRenderWindow()
447
448 # Render off-screen when not interacting
449 if not interact:
450 win.SetOffScreenRendering(1)
451
452 win.SetWindowName(title)
453 win.AddRenderer(renderer)
454

Callers 7

test_showFunction · 0.90
test_show_nurbsFunction · 0.90
test_screenshotFunction · 0.90
test_screenshot_no_patchFunction · 0.90
test_camera_positionFunction · 0.90
test_orthographicFunction · 0.90

Calls 14

_split_showablesFunction · 0.85
_to_assyFunction · 0.85
_to_vtk_ptsFunction · 0.85
_to_vtk_axsFunction · 0.85
toVTKAssyFunction · 0.85
SetOffScreenRenderingMethod · 0.80
SetPositionMethod · 0.80
InitializeMethod · 0.80
GetScreenSizeMethod · 0.80
SetSizeMethod · 0.80
RenderMethod · 0.80
UpdateMethod · 0.80

Tested by 7

test_showFunction · 0.72
test_show_nurbsFunction · 0.72
test_screenshotFunction · 0.72
test_screenshot_no_patchFunction · 0.72
test_camera_positionFunction · 0.72
test_orthographicFunction · 0.72