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

Class Figure

cadquery/fig.py:40–494  ·  view source on GitHub ↗

Non-blocking visualization class.

Source from the content-addressed store, hash-verified

38
39
40class Figure:
41 """
42 Non-blocking visualization class.
43 """
44
45 server: Server
46 win: vtkRenderWindow
47 ren: vtkRenderer
48 view: vtk_widgets.VtkRemoteView
49 shapes: BiDict[str, ShapeLike]
50 actors: BiDict[str, tuple[vtkProp3D, ...]]
51 loop: AbstractEventLoop
52 thread: Thread
53 empty: bool
54 active: Optional[str]
55 last: Optional[
56 tuple[
57 list[ShapeLike], list[vtkProp3D], Optional[list[vtkProp3D]], list[vtkProp3D]
58 ]
59 ]
60
61 _instance = None
62 _initialized: bool = False
63
64 def __new__(cls, *args, **kwargs):
65
66 if not cls._instance:
67 cls._instance = object.__new__(cls)
68
69 return cls._instance
70
71 def __init__(self, port: int = 18081):
72
73 if self._initialized:
74 return
75
76 self.loop = new_event_loop()
77 set_event_loop(self.loop)
78
79 # vtk boilerplate
80 renderer = vtkRenderer()
81 win = vtkRenderWindow()
82 w, h = win.GetScreenSize()
83 win.SetSize(w, h)
84 win.AddRenderer(renderer)
85 win.OffScreenRenderingOn()
86
87 inter = vtkRenderWindowInteractor()
88 inter.SetInteractorStyle(vtkInteractorStyleTrackballCamera())
89 inter.SetRenderWindow(win)
90
91 # background
92 renderer.SetBackground(1, 1, 1)
93 renderer.GradientBackgroundOn()
94
95 # axes
96 axes = vtkAxesActor()
97 axes.SetDragable(0)

Callers 6

figFunction · 0.90
test_figFunction · 0.90
test_fig_free_funcFunction · 0.90
showFunction · 0.85
clearFunction · 0.85
fitFunction · 0.85

Calls

no outgoing calls

Tested by 3

figFunction · 0.72
test_figFunction · 0.72
test_fig_free_funcFunction · 0.72