Skip to content

Add GUI elements to fig.Figure#1943

Merged
adam-urbanczyk merged 18 commits intomasterfrom
fig-gui
Feb 5, 2026
Merged

Add GUI elements to fig.Figure#1943
adam-urbanczyk merged 18 commits intomasterfrom
fig-gui

Conversation

@adam-urbanczyk
Copy link
Member

@adam-urbanczyk adam-urbanczyk commented Nov 23, 2025

This PR adds a toolbar and minimal objects list to fig.Figure:

image image

@adam-urbanczyk adam-urbanczyk marked this pull request as draft November 23, 2025 15:35
@adam-urbanczyk
Copy link
Member Author

@lorenzncode this is by far not finished, but I remember you were interested in this.

@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

❌ Patch coverage is 98.37398% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.40%. Comparing base (fe53ca0) to head (47b72b4).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
cadquery/fig.py 98.37% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1943      +/-   ##
==========================================
+ Coverage   95.96%   96.40%   +0.43%     
==========================================
  Files          29       29              
  Lines        7857     9837    +1980     
  Branches     1174     1558     +384     
==========================================
+ Hits         7540     9483    +1943     
- Misses        183      212      +29     
- Partials      134      142       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adam-urbanczyk adam-urbanczyk mentioned this pull request Jan 15, 2026
9 tasks
@adam-urbanczyk adam-urbanczyk marked this pull request as ready for review January 27, 2026 17:16
@adam-urbanczyk adam-urbanczyk requested review from jmwright and lorenzncode and removed request for jmwright January 27, 2026 17:17
@adam-urbanczyk
Copy link
Member Author

At the moment this is still meant for dogfooding.

@jmwright
Copy link
Member

@adam-urbanczyk Does this feature only work in Windows? I see that the test_fig test is skipped if not run in a Windows environment and I'm getting some errors in Linux.

@adam-urbanczyk
Copy link
Member Author

Only win CI works out of the box with UI AFAIK and I don't want to maintain something like CQ-editor has/had. The feature as such should work on all systems. What kind of errors are we talking about?

@jmwright
Copy link
Member

@adam-urbanczyk Here is the error I get. Maybe I'm not setting things up correctly?

$ python
Python 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cadquery.fig import Figure
>>> fig = Figure()
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    fig = Figure()
  File "/home/jwright/repos/cadquery/cadquery/fig.py", line 196, in __init__
    self.view = vtk_widgets.VtkRemoteView(
                ~~~~~~~~~~~~~~~~~~~~~~~~~^
        win, interactive_ratio=1, interactive_quality=100
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/jwright/venvs/cq-fig/lib/python3.13/site-packages/trame_vtk/widgets/vtk/common.py", line 690, in __init__
    self._helper.has_capabilities("web", "rendering")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'has_capabilities'

@lorenzncode
Copy link
Member

@jmwright It is working for me locally. I tried with both python 3.12 and 3.13.

$ python
Python 3.13.11 | packaged by conda-forge | (main, Jan 26 2026, 23:57:06) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cadquery.fig import Figure
>>> fig = Figure()
>>>
$ uname -a
Linux fedora 6.18.6-200.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 18 18:57:00 UTC 2026 x86_64 GNU/Linux

I'm currently experimenting with pixi but expect same with conda/mamba.

$ pixi list "trame|cadquery|python"
Name                     Version   Build                     Size  Kind   Source
cadquery                 master    v2.6.1_19_ga8d1864  370.43 KiB  conda  https://conda.anaconda.org/cadquery
cadquery                 2.7.dev0                                  pypi
ipython                  9.9.0     pyh53cf698_0        631.10 KiB  conda  https://conda.anaconda.org/conda-forge
ipython_pygments_lexers  1.1.1     pyhd8ed1ab_0         13.67 KiB  conda  https://conda.anaconda.org/conda-forge
msgpack-python           1.1.2     py313h7037e92_1     100.71 KiB  conda  https://conda.anaconda.org/conda-forge
python                   3.13.11   hc97d973_101_cp313   35.45 MiB  conda  https://conda.anaconda.org/conda-forge
python_abi               3.13      8_cp313               6.84 KiB  conda  https://conda.anaconda.org/conda-forge
trame                    3.12.0    pyhd8ed1ab_0         27.52 KiB  conda  https://conda.anaconda.org/conda-forge
trame-client             3.11.2    pyhd8ed1ab_0        199.15 KiB  conda  https://conda.anaconda.org/conda-forge
trame-common             1.1.1     pyhd8ed1ab_0         24.23 KiB  conda  https://conda.anaconda.org/conda-forge
trame-components         2.5.0     pyhd8ed1ab_0         78.90 KiB  conda  https://conda.anaconda.org/conda-forge
trame-server             3.10.0    pyhd8ed1ab_0         41.20 KiB  conda  https://conda.anaconda.org/conda-forge
trame-vtk                2.10.3    pyh932262d_0        430.39 KiB  conda  https://conda.anaconda.org/conda-forge
trame-vuetify            3.2.0     pyhd8ed1ab_0          2.82 MiB  conda  https://conda.anaconda.org/conda-forge
$ ipython
Python 3.13.11 | packaged by conda-forge | (main, Jan 26 2026, 23:57:06) [GCC 14.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.9.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: Use `--theme`, or the `%colors` magic to change IPython's themes and colors.

In [1]: run test1.py

image

@jmwright
Copy link
Member

I installed via pip install -e .

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I like the simple interface. I'm testing a vtk.js based viewer with similar features and layout.

Image

There seems to be a bug with the visibility controls. The state of the fill/no-fill red circle gets out of sync with the object visibility. See video:

Kooha-2026-01-31-19-35-46.webm

@adam-urbanczyk
Copy link
Member Author

Thanks @lorenzncode , I think I fixed it.

@jmwright could you list what ends up in your env?

@lorenzncode
Copy link
Member

Thanks @lorenzncode , I think I fixed it.

Yes, confirmed!

@jmwright
Copy link
Member

jmwright commented Feb 2, 2026

@adam-urbanczyk Here's the pip list on my environment.

$ pip list
Package                 Version       Editable project location
----------------------- ------------- ----------------------------
aiohappyeyeballs        2.6.1
aiohttp                 3.13.3
aiosignal               1.4.0
asttokens               3.0.1
attrs                   25.4.0
cadquery                2.7.dev0      /home/jwright/repos/cadquery
cadquery-ocp            7.8.1.1.post1
cadquery_vtk            9.3.1
casadi                  3.7.2
decorator               5.2.1
docutils                0.22.4
executing               2.2.1
ezdxf                   1.4.3
fonttools               4.61.1
frozenlist              1.8.0
idna                    3.11
iniconfig               2.3.0
ipython                 9.9.0
ipython_pygments_lexers 1.1.1
jedi                    0.19.2
matplotlib-inline       0.2.1
more-itertools          10.8.0
msgpack                 1.1.2
multidict               6.7.1
multimethod             1.12
nlopt                   2.10.0
numpy                   2.4.1
packaging               26.0
parso                   0.8.5
path                    17.1.1
pexpect                 4.9.0
pip                     25.1.1
pluggy                  1.6.0
prompt_toolkit          3.0.52
propcache               0.4.1
ptyprocess              0.7.0
pure_eval               0.2.3
Pygments                2.19.2
pyparsing               3.3.2
pytest                  9.0.2
PyYAML                  6.0.3
runtype                 0.5.3
stack-data              0.6.3
traitlets               5.14.3
trame                   3.12.0
trame-client            3.11.2
trame-common            1.1.1
trame-components        2.5.0
trame-server            3.10.0
trame-vtk               2.10.3
trame-vuetify           3.2.0
typing_extensions       4.15.0
wcwidth                 0.5.2
wslink                  2.5.0
yarl                    1.22.0

@adam-urbanczyk
Copy link
Member Author

@jmwright I'm mainly developing on Windows right now. With the following env everything is working fine.

aiohappyeyeballs  2.6.1
aiohttp           3.13.3
aiosignal         1.4.0
attrs             25.4.0
cadquery          2.7.dev0      C:\Users\...
cadquery-ocp      7.8.1.1.post1
casadi            3.7.2
contourpy         1.3.3
cycler            0.12.1
ezdxf             1.4.3
fonttools         4.61.1
frozenlist        1.8.0
idna              3.11
kiwisolver        1.4.9
matplotlib        3.10.8
more-itertools    10.8.0
msgpack           1.1.2
multidict         6.7.1
multimethod       1.12
nlopt             2.10.0
numpy             2.4.2
packaging         26.0
path              17.1.1
pillow            12.1.0
pip               26.0.1
propcache         0.4.1
pyparsing         3.3.2
python-dateutil   2.9.0.post0
PyYAML            6.0.3
runtype           0.5.3
setuptools        80.10.2
six               1.17.0
trame             3.12.0
trame-client      3.11.2
trame-common      1.1.1
trame-components  2.5.0
trame-server      3.10.0
trame-vtk         2.11.0
trame-vuetify     3.2.1
typing_extensions 4.15.0
vtk               9.3.1
wheel             0.46.3
wslink            2.5.0
yarl              1.22.0

with python 3.13 and cadquery-vtk I can reproduce your error. I'm not sure what cadquery-vtk exactly is (our custom build?) and I don't think it is within the scope of this PR to fix it. What do you think?

@jmwright
Copy link
Member

jmwright commented Feb 5, 2026

@adam-urbanczyk I'm fine with merging as-is.

@adam-urbanczyk
Copy link
Member Author

Thanks! Could you though shed some light on cadquery-vtk? What is the delta wrt vtk?

@adam-urbanczyk adam-urbanczyk merged commit 0cccbe4 into master Feb 5, 2026
6 checks passed
@jmwright
Copy link
Member

jmwright commented Feb 5, 2026

cadquery-vtk exists to add support for platforms and Python versions that the stock VTK package does not. Ideally, it would not exist, but older official VTK packages on PyPI do not get updated for newer Python versions.

@adam-urbanczyk
Copy link
Member Author

Is there a delta in the build configuration? Where can I actually see how it is built or open an issue?

@bernhard-42
Copy link
Contributor

Background

cadquery-vtk was an attempt to support Python 3.13 for OCP 7.8 on pypi.org. VTK wasn't available on pypi for Python 3.13 these days, hence I built a standard VTK package for it and we published it as cadquery_vtk for Python 3.13 only. And cadquery_ocp 7.8 for Python 3.13 relies on it.

In the meantime, I don't think it was a too good idea, hence we did not build it anymore.

OCCT's dependency on VTK restricts the Python and OS version support for cadquery_ocp on pypi to what VTK supports. Plus, at least for the pypi version, it forced users to use exactly the VTK version cadquery_ocp was built against, which could lead to conflicts.

ocp-build-system builds cadquery_ocp in a vtk and a novtk version since OCP 7.8. But for OCP 7.9 we do not build cadquery_vtk for Python 3.14 any more, so the Python support for OCP 7.9 on pypi is:

  • cadquery_ocp: Python3.10-3.13
  • cadquery_ocp_novtk: Python3.10-3.14

Re:

Is there a delta in the build configuration? Where can I actually see how it is built or open an issue?

I wouldn't spend time on it, see above. With OCP 7.9 it is not used any more. And cadquery_ocp (the vtk version) 7.9 has the same full OCCT bindings including IVTK as the conda version.

If you are nevertheless interested: https://github.com/CadQuery/ocp-build-system/tree/5ab1918e870820915c2a253025712905c12f22f1 (it has been already deleted on master)

How to avoid cadquery_vtk

For cadquery_ocp 7.8.1.1.post1 use Python 3.12 or use cadquery_ocp 7.9.3.0

Hope that helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants