-
Notifications
You must be signed in to change notification settings - Fork 396
cq.vis.show improvements #1726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
cq.vis.show improvements #1726
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e97ed36
Handle vtkActors
adam-urbanczyk 1b67a71
Mypy fix
adam-urbanczyk da2061a
Update Showables
adam-urbanczyk ef73e0b
Add specular lighting
adam-urbanczyk 7bccca4
Make show non-blocking and add title
adam-urbanczyk 107523a
Return only qwin
adam-urbanczyk 98e6b16
Revert
adam-urbanczyk 69bdc2a
Test fix
adam-urbanczyk 6bcf125
Better coverage
adam-urbanczyk b0cba29
Adding vis docs
adam-urbanczyk 4354326
Add references
adam-urbanczyk 60e2d6e
Primer tweaks
adam-urbanczyk 7bb47e7
Cleanup
adam-urbanczyk 4a4338e
Correct file names
adam-urbanczyk f5db234
Tweaks
adam-urbanczyk 62bd068
Try with -q
adam-urbanczyk 369d200
Try with always_yes
adam-urbanczyk bbbde0a
Remove -q
adam-urbanczyk a1fbf29
Try with mamba
adam-urbanczyk 16d6cb1
Use mamba run
adam-urbanczyk e62dd00
Set MAMBA_ROOT_PREFIX
adam-urbanczyk 06681af
Fix prefix
adam-urbanczyk f0f856a
Apply suggestions from code review
adam-urbanczyk 1ab6a6e
Do not use full screen
adam-urbanczyk 76c2c68
State correct version
adam-urbanczyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Adding vis docs
- Loading branch information
commit b0cba29fc6a8e8d63f0c5569fcd16cd91d0ac638
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| .. _vis: | ||
|
|
||
|
|
||
| =========================== | ||
| Visualization facilities | ||
| =========================== | ||
|
|
||
|
|
||
| Pure Python | ||
| =========== | ||
|
|
||
| Since version 2.5 CadQuery support visualization without any external tools. Those facilities are based on the VTK library | ||
adam-urbanczyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| and are not tied to any external tool. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from cadquery import * | ||
| from cadquery.vis import show | ||
|
|
||
| w = Workplane().sphere(1).split(keepTop=True) - Workplane().sphere(0.5) | ||
|
|
||
| # Show the result | ||
| show(w, alpha=0.5) | ||
|
|
||
|
|
||
| .. image:: _static/show.png | ||
|
|
||
|
|
||
| One can visualize objects of type Workplanes, Sketches, Assemblies, Shapes, Vectors, Locations and lists thereof. | ||
|
|
||
|
|
||
| .. code-block:: python | ||
|
|
||
| adquery import * | ||
| from cadquery.occ_impl.shapes import * | ||
| from cadquery.vis import show | ||
|
|
||
| w = Workplane().sphere(0.5).split(keepTop=True) | ||
| sk = Sketch().rect(1.5, 1.5) | ||
| sh = torus(5, 0.5) | ||
|
|
||
| r = rect(2, 2) | ||
| c = circle(2) | ||
|
|
||
| N = 50 | ||
| params = [i/N for i in range(N)] | ||
|
|
||
| vecs = r.positions(params) | ||
| locs = c.locations(params) | ||
|
|
||
| # Render the solid | ||
| show(w, sk, sh, vecs, locs) | ||
|
|
||
|
|
||
| .. image:: _static/show_demo.png | ||
|
|
||
|
|
||
| Additionally it is possibly to integrate with other libraries using VTK and display any `vtkProp` object. | ||
adam-urbanczyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| .. code-block:: python | ||
|
|
||
| from cadquery.vis import show | ||
| from cadquery.occ_impl.shapes import torus | ||
|
|
||
| from vtkmodules.vtkRenderingAnnotation import vtkAnnotatedCubeActor | ||
|
|
||
|
|
||
| a = vtkAnnotatedCubeActor() | ||
| t = torus(5,1) | ||
|
|
||
| show(t, a) | ||
|
|
||
| .. image:: _static/show_vtk.png | ||
|
|
||
|
|
||
| Note that currently the show functions is blocking. | ||
adam-urbanczyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Jupyter/JupterLab | ||
| ================= | ||
|
|
||
| There is also more limited support for displaying Shapes, Workplanes, Sketches and Assemblies in Jupyter and JupyterLab. | ||
| This functionality is implemented using VTK.js. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from cadquery import * | ||
|
|
||
| w = Workplane().sphere(1).split(keepTop=True) | ||
|
|
||
| w | ||
|
|
||
| .. image:: _static/show_jupyter.png | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.