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

Function style

cadquery/vis.py:312–394  ·  view source on GitHub ↗

Apply styling to CQ objects. To be used in conjunction with show.

(
    obj: Showable,
    scale: float = 0.2,
    alpha: float = 1,
    tolerance: float = 1e-2,
    edges: bool = True,
    mesh: bool = False,
    specular: bool = True,
    markersize: float = 5,
    linewidth: float = 2,
    spheres: bool = False,
    tubes: bool = False,
    color: str = "gold",
    edgecolor: str = "black",
    meshcolor: str = "lightgrey",
    vertexcolor: str = "cyan",
    **kwargs,
)

Source from the content-addressed store, hash-verified

310
311
312def style(
313 obj: Showable,
314 scale: float = 0.2,
315 alpha: float = 1,
316 tolerance: float = 1e-2,
317 edges: bool = True,
318 mesh: bool = False,
319 specular: bool = True,
320 markersize: float = 5,
321 linewidth: float = 2,
322 spheres: bool = False,
323 tubes: bool = False,
324 color: str = "gold",
325 edgecolor: str = "black",
326 meshcolor: str = "lightgrey",
327 vertexcolor: str = "cyan",
328 **kwargs,
329) -> List[vtkProp3D]:
330 """
331 Apply styling to CQ objects. To be used in conjunction with show.
332 """
333
334 # styling functions
335 def _apply_style(actor):
336 props = actor.GetProperty()
337 props.SetEdgeColor(vtkNamedColors().GetColor3d(meshcolor))
338 props.SetVertexColor(vtkNamedColors().GetColor3d(vertexcolor))
339 props.SetPointSize(markersize)
340 props.SetLineWidth(linewidth)
341 props.SetRenderPointsAsSpheres(spheres)
342 props.SetRenderLinesAsTubes(tubes)
343 props.SetEdgeVisibility(mesh)
344
345 if specular:
346 props.SetSpecular(SPECULAR)
347 props.SetSpecularPower(SPECULAR_POWER)
348 props.SetSpecularColor(SPECULAR_COLOR)
349
350 def _apply_color(actor):
351 props = actor.GetProperty()
352 props.SetColor(vtkNamedColors().GetColor3d(color))
353 props.SetOpacity(alpha)
354
355 # split showables
356 shapes, vecs, locs, actors = _split_showables([obj,])
357
358 # convert to a prop
359 rv: Union[vtkActor, List[vtkProp3D]]
360
361 if shapes:
362 rv = _to_vtk_shapes(
363 shapes,
364 color=vtkNamedColors().GetColor3d(color),
365 edgecolor=vtkNamedColors().GetColor3d(edgecolor),
366 edges=edges,
367 linewidth=linewidth,
368 alpha=alpha,
369 tolerance=tolerance,

Callers 2

test_styleFunction · 0.90
showMethod · 0.85

Calls 8

_split_showablesFunction · 0.85
_to_vtk_shapesFunction · 0.85
_iterate_actorsFunction · 0.85
_apply_styleFunction · 0.85
_to_vtk_ptsFunction · 0.85
_apply_colorFunction · 0.85
_to_vtk_axsFunction · 0.85
appendMethod · 0.80

Tested by 1

test_styleFunction · 0.72