Compare commits
2 Commits
0.30-dev-4
...
run_and_ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4669eef9a2 | ||
|
|
8f62f098ee |
@@ -10,37 +10,33 @@ on:
|
|||||||
default: 'dir'
|
default: 'dir'
|
||||||
jobs:
|
jobs:
|
||||||
build-linux:
|
build-linux:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- uses: mamba-org/setup-micromamba@v1
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
with:
|
with:
|
||||||
#miniconda-version: "latest"
|
#miniconda-version: "latest"
|
||||||
#auto-update-conda: true
|
#auto-update-conda: true
|
||||||
environment-name: test
|
environment-name: test
|
||||||
environment-file: environment.yml
|
environment-file: environment.yml
|
||||||
create-args: >-
|
extra-specs:
|
||||||
python=3.10
|
python=3.9
|
||||||
- name: pip install cadquery CQ-editor ... etc
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
shell: bash --login {0}
|
shell: bash --login {0}
|
||||||
run: |
|
run: |
|
||||||
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||||
sudo apt install -y libxkbcommon0
|
sudo apt install -y libxkbcommon0
|
||||||
sudo apt install -y libxkbcommon-x11-0
|
sudo apt install -y libxkbcommon-x11-0
|
||||||
sudo apt install -y libxcb-xinerama0
|
sudo apt install -y libxcb-xinerama0
|
||||||
sudo apt install -y qtbase5-dev qt5-qmake
|
|
||||||
micromamba info
|
micromamba info
|
||||||
pip install pyopengl
|
|
||||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||||
pip install -vvv --pre git+https://github.com/cadquery/cadquery casadi
|
pip install -vvv --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
pip install pyinstaller==4.10
|
||||||
pip install path
|
pip install path
|
||||||
pip install jupyter-rfb
|
|
||||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
pip install git+https://github.com/gumyr/bd_warehouse
|
|
||||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
pip install git+https://github.com/gumyr/build123d
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
pip install git+https://github.com/JustinSDK/cqMore
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
pip list
|
pip list
|
||||||
- name: Run build
|
- name: Run build
|
||||||
@@ -49,38 +45,37 @@ jobs:
|
|||||||
micromamba info
|
micromamba info
|
||||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||||
cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
- uses: alehechka/upload-tartifact@v2
|
- uses: alehechka/upload-tartifact@v1
|
||||||
with:
|
with:
|
||||||
name: CQ-editor-Linux-x86_64
|
name: CQ-editor-Linux-x86_64
|
||||||
path: dist
|
path: dist
|
||||||
build-macos:
|
build-macos:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- uses: mamba-org/setup-micromamba@v1
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
with:
|
with:
|
||||||
#miniconda-version: "latest"
|
#miniconda-version: "latest"
|
||||||
#auto-update-conda: true
|
#auto-update-conda: true
|
||||||
environment-name: test
|
environment-name: test
|
||||||
environment-file: environment.yml
|
environment-file: environment.yml
|
||||||
create-args: >-
|
extra-specs:
|
||||||
python=3.10
|
python=3.9
|
||||||
- name: pip install cadquery CQ-editor ... etc
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
shell: bash --login {0}
|
shell: bash --login {0}
|
||||||
run: |
|
run: |
|
||||||
micromamba info
|
micromamba info
|
||||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||||
pip install --pre git+https://github.com/cadquery/cadquery casadi
|
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
pip install pyinstaller==4.10
|
||||||
pip install path
|
pip install path
|
||||||
pip uninstall -y PyQt5
|
pip uninstall -y PyQt5
|
||||||
pip install PyQt5==5.15.7
|
pip install PyQt5==5.15.7
|
||||||
pip install PyQtWebEngine==5.15.6
|
pip install PyQtWebEngine==5.15.6
|
||||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
pip install git+https://github.com/gumyr/bd_warehouse
|
|
||||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
pip install git+https://github.com/gumyr/build123d
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
pip install git+https://github.com/JustinSDK/cqMore
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
pip list
|
pip list
|
||||||
- name: Run build
|
- name: Run build
|
||||||
@@ -96,39 +91,36 @@ jobs:
|
|||||||
build-windows:
|
build-windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v2
|
||||||
- uses: mamba-org/setup-micromamba@v1
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
with:
|
with:
|
||||||
#miniconda-version: "latest"
|
#miniconda-version: "latest"
|
||||||
#auto-update-conda: true
|
#auto-update-conda: true
|
||||||
environment-name: test
|
environment-name: test
|
||||||
environment-file: environment.yml
|
environment-file: environment.yml
|
||||||
init-shell: >-
|
extra-specs:
|
||||||
powershell
|
python=3.9
|
||||||
create-args: >-
|
|
||||||
python=3.10
|
|
||||||
- name: pip install cadquery CQ-editor ... etc
|
- name: pip install cadquery CQ-editor ... etc
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
micromamba info
|
micromamba info
|
||||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||||
pip install --pre git+https://github.com/cadquery/cadquery casadi
|
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
|
||||||
pip install pyinstaller>=5.6 git+https://github.com/jdegenstein/pyinstaller-hooks-contrib
|
pip install pyinstaller==4.10
|
||||||
pip install path
|
pip install path
|
||||||
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
pip install git+https://github.com/gumyr/bd_warehouse
|
|
||||||
pip install git+https://github.com/meadiode/cq_gears.git@main
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
pip install git+https://github.com/gumyr/build123d
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
pip install git+https://github.com/JustinSDK/cqMore
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
pip list
|
pip list
|
||||||
- name: Run build
|
- name: Run build
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
micromamba info
|
micromamba info
|
||||||
pyinstaller pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
pyinstaller --debug all pyinstaller_pip.spec ${{ github.event.inputs.type }}
|
||||||
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||||
- uses: alehechka/upload-tartifact@v2
|
- uses: alehechka/upload-tartifact@v1
|
||||||
with:
|
with:
|
||||||
name: CQ-editor-Windows
|
name: CQ-editor-Windows
|
||||||
path: dist
|
path: dist
|
||||||
|
|||||||
122
.github/workflows/pyinstaller-builds-actions-mmamba-TAR.yml
vendored
Normal file
122
.github/workflows/pyinstaller-builds-actions-mmamba-TAR.yml
vendored
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
name: build-micromamba-DEV
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 1'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
type:
|
||||||
|
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||||
|
required: true
|
||||||
|
default: 'dir'
|
||||||
|
jobs:
|
||||||
|
# build-linux:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: mamba-org/provision-with-micromamba@main
|
||||||
|
# with:
|
||||||
|
# #miniconda-version: "latest"
|
||||||
|
# #auto-update-conda: true
|
||||||
|
# environment-name: test
|
||||||
|
# environment-file: environment.yml
|
||||||
|
# extra-specs:
|
||||||
|
# python=3.9
|
||||||
|
# - name: Mamba install CadQuery and pyinstaller
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||||
|
# sudo apt install -y libxkbcommon0
|
||||||
|
# sudo apt install -y libxkbcommon-x11-0
|
||||||
|
# sudo apt install -y libxcb-xinerama0
|
||||||
|
# micromamba info
|
||||||
|
# micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
# micromamba install -c conda-forge pyinstaller=4.10
|
||||||
|
# pip install path
|
||||||
|
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
# pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
# - name: Run build
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# micromamba info
|
||||||
|
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
# cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
# - uses: actions/upload-artifact@v2
|
||||||
|
# with:
|
||||||
|
# name: CQ-editor-Linux-x86_64
|
||||||
|
# path: dist
|
||||||
|
# build-macos:
|
||||||
|
# runs-on: macos-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: mamba-org/provision-with-micromamba@main
|
||||||
|
# with:
|
||||||
|
# #miniconda-version: "latest"
|
||||||
|
# #auto-update-conda: true
|
||||||
|
# environment-name: test
|
||||||
|
# environment-file: environment.yml
|
||||||
|
# extra-specs:
|
||||||
|
# python=3.9
|
||||||
|
# - name: Mamba install CadQuery and pyinstaller
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# micromamba info
|
||||||
|
# micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
# micromamba install -c conda-forge pyinstaller
|
||||||
|
# pip install path
|
||||||
|
# pip uninstall -y PyQt5
|
||||||
|
# pip install PyQt5==5.15.7
|
||||||
|
# pip install PyQtWebEngine==5.15.6
|
||||||
|
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
# pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
# - name: Run build
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# micromamba info
|
||||||
|
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
# cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
# - uses: actions/upload-artifact@v2
|
||||||
|
# with:
|
||||||
|
# name: CQ-editor-MacOS
|
||||||
|
# path: dist
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
|
with:
|
||||||
|
#miniconda-version: "latest"
|
||||||
|
#auto-update-conda: true
|
||||||
|
environment-name: test
|
||||||
|
environment-file: environment.yml
|
||||||
|
extra-specs:
|
||||||
|
python=3.9
|
||||||
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
micromamba install -c conda-forge pyinstaller=4.10 casadi ipopt
|
||||||
|
pip install path
|
||||||
|
pip install pipwin
|
||||||
|
pipwin install numpy
|
||||||
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
- name: Run build
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
micromamba info
|
||||||
|
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
Copy-Item C:\Users\runneradmin\micromamba-root\envs\test\Library\bin\casadi_nlpsol_ipopt.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||||
|
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||||
|
- uses: alehechka/upload-tartifact@v1
|
||||||
|
with:
|
||||||
|
name: CQ-editor-Windows
|
||||||
|
path: dist
|
||||||
121
.github/workflows/pyinstaller-builds-actions-mmamba.yml
vendored
Normal file
121
.github/workflows/pyinstaller-builds-actions-mmamba.yml
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
name: build-micromamba
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 1'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
type:
|
||||||
|
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||||
|
required: true
|
||||||
|
default: 'dir'
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
|
with:
|
||||||
|
#miniconda-version: "latest"
|
||||||
|
#auto-update-conda: true
|
||||||
|
environment-name: test
|
||||||
|
environment-file: environment.yml
|
||||||
|
extra-specs:
|
||||||
|
python=3.9
|
||||||
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
|
shell: bash --login {0}
|
||||||
|
run: |
|
||||||
|
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||||
|
sudo apt install -y libxkbcommon0
|
||||||
|
sudo apt install -y libxkbcommon-x11-0
|
||||||
|
sudo apt install -y libxcb-xinerama0
|
||||||
|
micromamba info
|
||||||
|
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
micromamba install -c conda-forge pyinstaller=4.10
|
||||||
|
pip install path
|
||||||
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
- name: Run build
|
||||||
|
shell: bash --login {0}
|
||||||
|
run: |
|
||||||
|
micromamba info
|
||||||
|
pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: CQ-editor-Linux-x86_64
|
||||||
|
path: dist
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
|
with:
|
||||||
|
#miniconda-version: "latest"
|
||||||
|
#auto-update-conda: true
|
||||||
|
environment-name: test
|
||||||
|
environment-file: environment.yml
|
||||||
|
extra-specs:
|
||||||
|
python=3.9
|
||||||
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
|
shell: bash --login {0}
|
||||||
|
run: |
|
||||||
|
micromamba info
|
||||||
|
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
micromamba install -c conda-forge pyinstaller
|
||||||
|
pip install path
|
||||||
|
pip uninstall -y PyQt5
|
||||||
|
pip install PyQt5==5.15.7
|
||||||
|
pip install PyQtWebEngine==5.15.6
|
||||||
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
- name: Run build
|
||||||
|
shell: bash --login {0}
|
||||||
|
run: |
|
||||||
|
micromamba info
|
||||||
|
pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: CQ-editor-MacOS
|
||||||
|
path: dist
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: mamba-org/provision-with-micromamba@main
|
||||||
|
with:
|
||||||
|
#miniconda-version: "latest"
|
||||||
|
#auto-update-conda: true
|
||||||
|
environment-name: test
|
||||||
|
environment-file: environment.yml
|
||||||
|
extra-specs:
|
||||||
|
python=3.9
|
||||||
|
- name: Mamba install CadQuery and pyinstaller
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
micromamba install -c cadquery -c conda-forge cq-editor=master cadquery=master debugpy ipython=8.4.0 jedi=0.17.2 python=3.9
|
||||||
|
micromamba install -c conda-forge pyinstaller=4.10
|
||||||
|
pip install path
|
||||||
|
pip install pipwin
|
||||||
|
pipwin install numpy
|
||||||
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
pip install git+https://github.com/JustinSDK/cqMore
|
||||||
|
- name: Run build
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
micromamba info
|
||||||
|
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: CQ-editor-Windows
|
||||||
|
path: dist
|
||||||
120
.github/workflows/pyinstaller-builds-actions.yml
vendored
Normal file
120
.github/workflows/pyinstaller-builds-actions.yml
vendored
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
name: build
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 1'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
type:
|
||||||
|
description: 'Whether to build a single file (onefile) or directory (dir) dist'
|
||||||
|
required: true
|
||||||
|
default: 'dir'
|
||||||
|
jobs:
|
||||||
|
# build-linux:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: conda-incubator/setup-miniconda@v2
|
||||||
|
# with:
|
||||||
|
# mamba-version: "*"
|
||||||
|
# channels: conda-forge,defaults
|
||||||
|
# channel-priority: true
|
||||||
|
# # auto-update-conda: true
|
||||||
|
# python-version: 3.9
|
||||||
|
# activate-environment: test
|
||||||
|
# - name: Install CadQuery, CQ-editor and pyinstaller
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
|
||||||
|
# sudo apt install -y libxkbcommon0
|
||||||
|
# sudo apt install -y libxkbcommon-x11-0
|
||||||
|
# sudo apt install -y libxcb-xinerama0
|
||||||
|
# conda info
|
||||||
|
# conda install -c cadquery -c conda-forge cq-editor=master cadquery=master python=3.9
|
||||||
|
# conda install -c conda-forge pyinstaller=4.10
|
||||||
|
# conda uninstall --force -y importlib_resources
|
||||||
|
# pip install path
|
||||||
|
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
# - name: Run build
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# conda info
|
||||||
|
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
# cp /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
# rm /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/CQ-editor/libstdc++.so.6
|
||||||
|
# - uses: actions/upload-artifact@v2
|
||||||
|
# with:
|
||||||
|
# name: CQ-editor-Linux-x86_64
|
||||||
|
# path: dist
|
||||||
|
# build-macos:
|
||||||
|
# runs-on: macos-latest
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: conda-incubator/setup-miniconda@v2
|
||||||
|
# with:
|
||||||
|
# mamba-version: "*"
|
||||||
|
# channels: conda-forge,defaults
|
||||||
|
# # auto-update-conda: true
|
||||||
|
# python-version: 3.9
|
||||||
|
# activate-environment: test
|
||||||
|
# - name: Install CadQuery, CQ-editor and pyinstaller=4.10
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# conda info
|
||||||
|
# conda install -c cadquery -c conda-forge cq-editor=master cadquery=master python=3.9
|
||||||
|
# conda install -c conda-forge pyinstaller
|
||||||
|
# conda uninstall --force -y importlib_resources
|
||||||
|
# pip install path
|
||||||
|
# pip uninstall -y PyQt5
|
||||||
|
# pip install PyQt5==5.15.7
|
||||||
|
# pip install PyQtWebEngine==5.15.6
|
||||||
|
# pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
# pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
# pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
# pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
# - name: Run build
|
||||||
|
# shell: bash --login {0}
|
||||||
|
# run: |
|
||||||
|
# conda info
|
||||||
|
# pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
# cp /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/pyinstaller/CQ-editor.sh /Users/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/
|
||||||
|
# - uses: actions/upload-artifact@v2
|
||||||
|
# with:
|
||||||
|
# name: CQ-editor-MacOS
|
||||||
|
# path: dist
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: conda-incubator/setup-miniconda@v2
|
||||||
|
with:
|
||||||
|
miniconda-version: "latest"
|
||||||
|
auto-update-conda: true
|
||||||
|
python-version: 3.9
|
||||||
|
activate-environment: test
|
||||||
|
- name: Install CadQuery and pyinstaller
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
conda install -c cadquery -c conda-forge cq-editor=master cadquery=master ipython=7.20 python=3.9
|
||||||
|
conda install -c conda-forge pyinstaller=4.10
|
||||||
|
pip install pipwin
|
||||||
|
pipwin install numpy
|
||||||
|
pip install path
|
||||||
|
pip install git+https://github.com/gumyr/cq_warehouse.git#egg=cq_warehouse
|
||||||
|
pip install git+https://github.com/meadiode/cq_gears.git@main
|
||||||
|
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=cq_cache&subdirectory=plugins/cq_cache"
|
||||||
|
pip install git+https://github.com/gumyr/build123d.git#egg=build123d
|
||||||
|
- name: Run build
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
conda info
|
||||||
|
pyinstaller --debug all pyinstaller.spec ${{ github.event.inputs.type }}
|
||||||
|
Copy-Item C:\Miniconda3\Library\bin\libssl-1_1-x64.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||||
|
Copy-Item C:\Miniconda3\Library\bin\libcrypto-1_1-x64.dll D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\CQ-editor\
|
||||||
|
Copy-Item D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\pyinstaller\CQ-editor.cmd D:\a\jmwright-CQ-Editor\jmwright-CQ-Editor\dist\
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: CQ-editor-Windows
|
||||||
|
path: dist
|
||||||
17
README.md
17
README.md
@@ -1,6 +1,6 @@
|
|||||||
# CadQuery editor
|
# CadQuery editor
|
||||||
|
|
||||||
This is a fork of [jmwright's fork](https://github.com/jmwright/CQ-editor) of [CadQuery/CQ-editor](https://github.com/CadQuery/CQ-editor). This fork includes changes that enable dark mode for CQ-editor (see screenshot below). Under the GitHub Actions menu this fork also contains static builds of CQ-editor for Linux/MacOS/Windows that include the [cq_gears](https://github.com/meadiode/cq_gears), [cq_cache](https://github.com/CadQuery/cadquery-plugins/tree/main/plugins/cq_cache), [cq_more](https://github.com/JustinSDK/cqMore), [cq_warehouse](https://github.com/gumyr/cq_warehouse), [bd_warehouse](https://github.com/gumyr/bd_warehouse), and [build123d](https://github.com/gumyr/build123d) libraries. Note you need to change color preferences to enable dark mode for all panes (see Edit -> Preferences).
|
This is a fork of [jmwright's fork](https://github.com/jmwright/CQ-editor) of [CadQuery/CQ-editor](https://github.com/CadQuery/CQ-editor). This fork includes changes that enable dark mode for CQ-editor (see screenshot below). Under the GitHub Actions menu this fork also contains static builds of CQ-editor for Linux/MacOS/Windows that include the [cq_gears](https://github.com/meadiode/cq_gears), [cq_cache](https://github.com/CadQuery/cadquery-plugins/tree/main/plugins/cq_cache), [cq_more](https://github.com/JustinSDK/cqMore), [cq_warehouse](https://github.com/gumyr/cq_warehouse), and [build123d](https://github.com/gumyr/build123d) libraries. Note you need to change color preferences to enable dark mode for all panes (see Edit -> Preferences).
|
||||||
|
|
||||||
This fork also contains additional changes to the `show_object` function in CQ-editor that make it easier to display and export build123d objects and object lists.
|
This fork also contains additional changes to the `show_object` function in CQ-editor that make it easier to display and export build123d objects and object lists.
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ CadQuery GUI editor based on PyQT supports Linux, Windows and Mac.
|
|||||||
|
|
||||||
### Release Packages
|
### Release Packages
|
||||||
|
|
||||||
Stable release builds which do not require Anaconda are attached to the [latest release](https://github.com/jdegenstein/jmwright-CQ-editor/releases). Download the zip file for your operating system, extract it, and run the CQ-editor script for your OS (CQ-editor.cmd for Windows, CQ-editor.sh for Linux and MacOS). On Windows you should be able to simply double-click on CQ-editor.cmd. On Linux and MacOS you may need to make the script executable with `chmod +x CQ-editor.sh` and run the script from the command line. On later MacOS versions you may also need `xattr -r -d com.apple.quarantine path/to/CQ-editor-MacOS`. The script contains an environment variable export that may be required to get CQ-editor to launch correctly on MacOS Big Sur, so it is better to use the script than to launch CQ-editor directly.
|
TBD
|
||||||
|
|
||||||
### Development Packages
|
### Development Packages
|
||||||
|
|
||||||
@@ -43,14 +43,9 @@ Development builds are also available, but can be unstable and should be used at
|
|||||||
|
|
||||||
## Installation (pip)
|
## Installation (pip)
|
||||||
|
|
||||||
Additional packages for Linux (known as needed on Ubuntu 22.04):
|
|
||||||
```
|
|
||||||
sudo apt install qtbase5-dev qt5-qmake
|
|
||||||
```
|
|
||||||
All platforms (Windows/Mac/Linux):
|
|
||||||
```
|
```
|
||||||
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
|
||||||
pip install --pre "cadquery>=2.2"
|
pip install --pre git+https://github.com/cadquery/cadquery
|
||||||
pip install git+https://github.com/gumyr/build123d
|
pip install git+https://github.com/gumyr/build123d
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -58,12 +53,10 @@ pip install git+https://github.com/gumyr/build123d
|
|||||||
|
|
||||||
### Showing Objects
|
### Showing Objects
|
||||||
|
|
||||||
By default, CQ-editor will display a 3D representation of all `Workplane` objects in a script with a default color and alpha (transparency). To have more control over what is shown, and what the color and alpha settings are, the `show_object` method can be used. `show_object` tells CQ-editor to explicity display an object, and accepts the `options` parameter. The `options` parameter is a dictionary of rendering options named `alpha` and `color`. `alpha` is scaled between 0.0 and 1.0, with 0.0 being completely opaque and 1.0 being completely transparent. The color is set using R (red), G (green) and B (blue) values, and each one is scaled from 0 to 255. Either option or both can be omitted. The `name` parameter can assign a custom name which will appear in the objects pane of CQ-editor.
|
By default, CQ-editor will display a 3D representation of all `Workplane` objects in a script with a default color and alpha (transparency). To have more control over what is shown, and what the color and alpha settings are, the `show_object` method can be used. `show_object` tells CQ-editor to explicity display an object, and accepts the `options` parameter. The `options` parameter is a dictionary of rendering options named `alpha` and `color`. `alpha` is scaled between 0.0 and 1.0, with 0.0 being completely opaque and 1.0 being completely transparent. The color is set using R (red), G (green) and B (blue) values, and each one is scaled from 0 to 255. Either option or both can be omitted.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
show_object(result, name="somename", options={"alpha":0.5, "color": (64, 164, 223)})
|
show_object(result, options={"alpha":0.5, "color": (64, 164, 223)})
|
||||||
# or using rand_color:
|
|
||||||
show_object(result, name="somename", options=rand_color(alpha=.5))
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `show_object` works for `Shape` and `TopoDS_Shape` objects too. In order to display objects from the embedded Python console use `show`.
|
Note that `show_object` works for `Shape` and `TopoDS_Shape` objects too. In order to display objects from the embedded Python console use `show`.
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import asyncio
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
NAME = 'CQ-editor'
|
NAME = 'CQ-editor'
|
||||||
|
|||||||
@@ -6,15 +6,9 @@ from typing import List
|
|||||||
|
|
||||||
import cadquery as cq
|
import cadquery as cq
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import Qt, QObject, pyqtSlot, pyqtSignal, QEventLoop, QAbstractTableModel
|
||||||
Qt,
|
from PyQt5.QtWidgets import (QAction,
|
||||||
QObject,
|
QTableView)
|
||||||
pyqtSlot,
|
|
||||||
pyqtSignal,
|
|
||||||
QEventLoop,
|
|
||||||
QAbstractTableModel,
|
|
||||||
)
|
|
||||||
from PyQt5.QtWidgets import QAction, QTableView
|
|
||||||
from logbook import info
|
from logbook import info
|
||||||
from path import Path
|
from path import Path
|
||||||
from pyqtgraph.parametertree import Parameter
|
from pyqtgraph.parametertree import Parameter
|
||||||
@@ -24,43 +18,46 @@ from random import randrange as rrr, seed
|
|||||||
from ..cq_utils import find_cq_objects, reload_cq
|
from ..cq_utils import find_cq_objects, reload_cq
|
||||||
from ..mixins import ComponentMixin
|
from ..mixins import ComponentMixin
|
||||||
|
|
||||||
DUMMY_FILE = "<string>"
|
DUMMY_FILE = '<string>'
|
||||||
|
|
||||||
|
|
||||||
class DbgState(Enum):
|
class DbgState(Enum):
|
||||||
|
|
||||||
STEP = auto()
|
STEP = auto()
|
||||||
CONT = auto()
|
CONT = auto()
|
||||||
STEP_IN = auto()
|
STEP_IN = auto()
|
||||||
RETURN = auto()
|
RETURN = auto()
|
||||||
|
|
||||||
|
|
||||||
class DbgEevent(object):
|
class DbgEevent(object):
|
||||||
LINE = "line"
|
|
||||||
CALL = "call"
|
|
||||||
RETURN = "return"
|
|
||||||
|
|
||||||
|
LINE = 'line'
|
||||||
|
CALL = 'call'
|
||||||
|
RETURN = 'return'
|
||||||
|
|
||||||
class LocalsModel(QAbstractTableModel):
|
class LocalsModel(QAbstractTableModel):
|
||||||
HEADER = ("Name", "Type", "Value")
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
HEADER = ('Name','Type', 'Value')
|
||||||
super(LocalsModel, self).__init__(parent)
|
|
||||||
|
def __init__(self,parent):
|
||||||
|
|
||||||
|
super(LocalsModel,self).__init__(parent)
|
||||||
self.frame = None
|
self.frame = None
|
||||||
|
|
||||||
def update_frame(self, frame):
|
def update_frame(self,frame):
|
||||||
self.frame = [
|
|
||||||
(k, type(v).__name__, str(v))
|
self.frame = \
|
||||||
for k, v in frame.items()
|
[(k,type(v).__name__, str(v)) for k,v in frame.items() if not k.startswith('_')]
|
||||||
if not k.startswith("_")
|
|
||||||
]
|
|
||||||
|
def rowCount(self,parent=QtCore.QModelIndex()):
|
||||||
|
|
||||||
def rowCount(self, parent=QtCore.QModelIndex()):
|
|
||||||
if self.frame:
|
if self.frame:
|
||||||
return len(self.frame)
|
return len(self.frame)
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def columnCount(self, parent=QtCore.QModelIndex()):
|
def columnCount(self,parent=QtCore.QModelIndex()):
|
||||||
|
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
def headerData(self, section, orientation, role=Qt.DisplayRole):
|
def headerData(self, section, orientation, role=Qt.DisplayRole):
|
||||||
@@ -77,11 +74,13 @@ class LocalsModel(QAbstractTableModel):
|
|||||||
return QtCore.QVariant()
|
return QtCore.QVariant()
|
||||||
|
|
||||||
|
|
||||||
class LocalsView(QTableView, ComponentMixin):
|
class LocalsView(QTableView,ComponentMixin):
|
||||||
name = "Variables"
|
|
||||||
|
|
||||||
def __init__(self, parent):
|
name = 'Variables'
|
||||||
super(LocalsView, self).__init__(parent)
|
|
||||||
|
def __init__(self,parent):
|
||||||
|
|
||||||
|
super(LocalsView,self).__init__(parent)
|
||||||
ComponentMixin.__init__(self)
|
ComponentMixin.__init__(self)
|
||||||
|
|
||||||
header = self.horizontalHeader()
|
header = self.horizontalHeader()
|
||||||
@@ -91,213 +90,180 @@ class LocalsView(QTableView, ComponentMixin):
|
|||||||
vheader.setVisible(False)
|
vheader.setVisible(False)
|
||||||
|
|
||||||
@pyqtSlot(dict)
|
@pyqtSlot(dict)
|
||||||
def update_frame(self, frame):
|
def update_frame(self,frame):
|
||||||
|
|
||||||
model = LocalsModel(self)
|
model = LocalsModel(self)
|
||||||
model.update_frame(frame)
|
model.update_frame(frame)
|
||||||
|
|
||||||
self.setModel(model)
|
self.setModel(model)
|
||||||
|
|
||||||
|
class Debugger(QObject,ComponentMixin):
|
||||||
|
|
||||||
class Debugger(QObject, ComponentMixin):
|
name = 'Debugger'
|
||||||
name = "Debugger"
|
|
||||||
|
preferences = Parameter.create(name='Preferences',children=[
|
||||||
|
{'name': 'Reload CQ', 'type': 'bool', 'value': False},
|
||||||
|
{'name': 'Add script dir to path','type': 'bool', 'value': True},
|
||||||
|
{'name': 'Change working dir to script dir','type': 'bool', 'value': True},
|
||||||
|
{'name': 'Reload imported modules', 'type': 'bool', 'value': True},
|
||||||
|
])
|
||||||
|
|
||||||
preferences = Parameter.create(
|
|
||||||
name="Preferences",
|
|
||||||
children=[
|
|
||||||
{"name": "Reload CQ", "type": "bool", "value": False},
|
|
||||||
{"name": "Add script dir to path", "type": "bool", "value": True},
|
|
||||||
{"name": "Change working dir to script dir", "type": "bool", "value": True},
|
|
||||||
{"name": "Reload imported modules", "type": "bool", "value": True},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
sigRendered = pyqtSignal(dict)
|
sigRendered = pyqtSignal(dict)
|
||||||
sigLocals = pyqtSignal(dict)
|
sigLocals = pyqtSignal(dict)
|
||||||
sigTraceback = pyqtSignal(object, str)
|
sigTraceback = pyqtSignal(object,str)
|
||||||
|
|
||||||
sigFrameChanged = pyqtSignal(object)
|
sigFrameChanged = pyqtSignal(object)
|
||||||
sigLineChanged = pyqtSignal(int)
|
sigLineChanged = pyqtSignal(int)
|
||||||
sigLocalsChanged = pyqtSignal(dict)
|
sigLocalsChanged = pyqtSignal(dict)
|
||||||
sigCQChanged = pyqtSignal(dict, bool)
|
sigCQChanged = pyqtSignal(dict,bool)
|
||||||
sigDebugging = pyqtSignal(bool)
|
sigDebugging = pyqtSignal(bool)
|
||||||
|
|
||||||
_frames: List[FrameType]
|
_frames : List[FrameType]
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self,parent):
|
||||||
super(Debugger, self).__init__(parent)
|
|
||||||
|
super(Debugger,self).__init__(parent)
|
||||||
ComponentMixin.__init__(self)
|
ComponentMixin.__init__(self)
|
||||||
|
|
||||||
self.inner_event_loop = QEventLoop(self)
|
self.inner_event_loop = QEventLoop(self)
|
||||||
|
|
||||||
self._actions = {
|
self._actions = \
|
||||||
"Run": [
|
{'Run' : [QAction(icon('run'),
|
||||||
QAction(
|
'Render',
|
||||||
icon("run"), "Render", self, shortcut="F5", triggered=self.render
|
self,
|
||||||
),
|
shortcut='F5',
|
||||||
QAction(
|
triggered=self.render),
|
||||||
icon("debug"),
|
QAction(icon('debug'),
|
||||||
"Debug",
|
'Debug',
|
||||||
self,
|
self,
|
||||||
checkable=True,
|
checkable=True,
|
||||||
shortcut="ctrl+F5",
|
shortcut='ctrl+F5',
|
||||||
triggered=self.debug,
|
triggered=self.debug),
|
||||||
),
|
QAction(icon('arrow-step-over'),
|
||||||
QAction(
|
'Step',
|
||||||
icon("arrow-step-over"),
|
|
||||||
"Step",
|
|
||||||
self,
|
self,
|
||||||
shortcut="ctrl+F10",
|
shortcut='ctrl+F10',
|
||||||
triggered=lambda: self.debug_cmd(DbgState.STEP),
|
triggered=lambda: self.debug_cmd(DbgState.STEP)),
|
||||||
),
|
QAction(icon('arrow-step-in'),
|
||||||
QAction(
|
'Step in',
|
||||||
icon("arrow-step-in"),
|
|
||||||
"Step in",
|
|
||||||
self,
|
self,
|
||||||
shortcut="ctrl+F11",
|
shortcut='ctrl+F11',
|
||||||
triggered=lambda: self.debug_cmd(DbgState.STEP_IN),
|
triggered=lambda: self.debug_cmd(DbgState.STEP_IN)),
|
||||||
),
|
QAction(icon('arrow-continue'),
|
||||||
QAction(
|
'Continue',
|
||||||
icon("arrow-continue"),
|
|
||||||
"Continue",
|
|
||||||
self,
|
self,
|
||||||
shortcut="ctrl+F12",
|
shortcut='ctrl+F12',
|
||||||
triggered=lambda: self.debug_cmd(DbgState.CONT),
|
triggered=lambda: self.debug_cmd(DbgState.CONT))
|
||||||
),
|
]}
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
self._frames = []
|
self._frames = []
|
||||||
|
|
||||||
def get_current_script(self):
|
def get_current_script(self):
|
||||||
return self.parent().components["editor"].get_text_with_eol()
|
|
||||||
|
return self.parent().components['editor'].get_text_with_eol()
|
||||||
|
|
||||||
def get_breakpoints(self):
|
def get_breakpoints(self):
|
||||||
return self.parent().components["editor"].debugger.get_breakpoints()
|
|
||||||
|
return self.parent().components['editor'].debugger.get_breakpoints()
|
||||||
|
|
||||||
def compile_code(self, cq_script):
|
def compile_code(self, cq_script):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module = ModuleType("temp")
|
module = ModuleType('temp')
|
||||||
cq_code = compile(cq_script, "<string>", "exec")
|
cq_code = compile(cq_script, '<string>', 'exec')
|
||||||
return cq_code, module
|
return cq_code, module
|
||||||
except Exception:
|
except Exception:
|
||||||
self.sigTraceback.emit(sys.exc_info(), cq_script)
|
self.sigTraceback.emit(sys.exc_info(), cq_script)
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def _exec(self, code, locals_dict, globals_dict):
|
def _exec(self, code, locals_dict, globals_dict):
|
||||||
with ExitStack() as stack:
|
|
||||||
fname = self.parent().components["editor"].filename
|
|
||||||
p = Path(fname if fname else "").abspath().dirname()
|
|
||||||
|
|
||||||
if self.preferences["Add script dir to path"] and p.exists():
|
with ExitStack() as stack:
|
||||||
sys.path.insert(0, p)
|
fname = self.parent().components['editor'].filename
|
||||||
|
p = Path(fname if fname else '').abspath().dirname()
|
||||||
|
|
||||||
|
if self.preferences['Add script dir to path'] and p.exists():
|
||||||
|
sys.path.insert(0,p)
|
||||||
stack.callback(sys.path.remove, p)
|
stack.callback(sys.path.remove, p)
|
||||||
if self.preferences["Change working dir to script dir"] and p.exists():
|
if self.preferences['Change working dir to script dir'] and p.exists():
|
||||||
stack.enter_context(p)
|
stack.enter_context(p)
|
||||||
if self.preferences["Reload imported modules"]:
|
if self.preferences['Reload imported modules']:
|
||||||
stack.enter_context(module_manager())
|
stack.enter_context(module_manager())
|
||||||
|
|
||||||
exec(code, locals_dict, globals_dict)
|
exec(code, locals_dict, globals_dict)
|
||||||
|
|
||||||
def _rand_color(self, alpha=0.0, cfloat=False):
|
def _rand_color(self, alpha = 0., cfloat=False):
|
||||||
# helper function to generate a random color dict
|
#helper function to generate a random color dict
|
||||||
# for CQ-editor's show_object function
|
#for CQ-editor's show_object function
|
||||||
lower = 10
|
lower = 10
|
||||||
upper = 100 # not too high to keep color brightness in check
|
upper = 100 #not too high to keep color brightness in check
|
||||||
if cfloat: # for two output types depending on need
|
if cfloat: #for two output types depending on need
|
||||||
return (
|
return (
|
||||||
(rrr(lower, upper) / 255),
|
(rrr(lower,upper)/255),
|
||||||
(rrr(lower, upper) / 255),
|
(rrr(lower,upper)/255),
|
||||||
(rrr(lower, upper) / 255),
|
(rrr(lower,upper)/255),
|
||||||
alpha,
|
alpha,
|
||||||
)
|
)
|
||||||
return {
|
return {"alpha": alpha,
|
||||||
"alpha": alpha,
|
|
||||||
"color": (
|
"color": (
|
||||||
rrr(lower, upper),
|
rrr(lower,upper),
|
||||||
rrr(lower, upper),
|
rrr(lower,upper),
|
||||||
rrr(lower, upper),
|
rrr(lower,upper),
|
||||||
),
|
)}
|
||||||
}
|
|
||||||
|
def _inject_locals(self,module):
|
||||||
|
|
||||||
def _inject_locals(self, module):
|
|
||||||
cq_objects = {}
|
cq_objects = {}
|
||||||
|
|
||||||
def _show_object(
|
def _show_object(obj,name=None, options={}):
|
||||||
obj,
|
|
||||||
name=None,
|
|
||||||
options={}, # all following inputs are ignored by cq-editor
|
|
||||||
parent=1,
|
|
||||||
clear=True,
|
|
||||||
port=3939,
|
|
||||||
axes=False,
|
|
||||||
axes0=False,
|
|
||||||
grid=False,
|
|
||||||
ticks=10,
|
|
||||||
ortho=True,
|
|
||||||
transparent=False,
|
|
||||||
default_color=(232, 176, 36),
|
|
||||||
reset_camera=True,
|
|
||||||
zoom=1.0,
|
|
||||||
default_edgecolor=(128, 128, 128),
|
|
||||||
render_edges=True,
|
|
||||||
render_normals=False,
|
|
||||||
render_mates=False,
|
|
||||||
mate_scale=1.0,
|
|
||||||
deviation=0.1,
|
|
||||||
angular_tolerance=0.2,
|
|
||||||
edge_accuracy=5.0,
|
|
||||||
ambient_intensity=1.0,
|
|
||||||
direct_intensity=0.12,
|
|
||||||
):
|
|
||||||
if name:
|
if name:
|
||||||
cq_objects.update({name: SimpleNamespace(shape=obj, options=options)})
|
cq_objects.update({name : SimpleNamespace(shape=obj,options=options)})
|
||||||
else:
|
else:
|
||||||
cq_objects.update(
|
cq_objects.update({str(id(obj)) : SimpleNamespace(shape=obj,options=options)})
|
||||||
{str(id(obj)): SimpleNamespace(shape=obj, options=options)}
|
|
||||||
)
|
|
||||||
|
|
||||||
def _debug(obj, name=None):
|
def _debug(obj,name=None):
|
||||||
_show_object(obj, name, options=dict(color="red", alpha=0.2))
|
|
||||||
|
|
||||||
module.__dict__["show_object"] = _show_object
|
_show_object(obj,name,options=dict(color='red',alpha=0.2))
|
||||||
module.__dict__["debug"] = _debug
|
|
||||||
module.__dict__["rand_color"] = self._rand_color
|
|
||||||
module.__dict__["log"] = lambda x: info(str(x))
|
|
||||||
module.__dict__["cq"] = cq
|
|
||||||
|
|
||||||
return cq_objects, set(module.__dict__) - {"cq"}
|
module.__dict__['show_object'] = _show_object
|
||||||
|
module.__dict__['debug'] = _debug
|
||||||
|
module.__dict__['rand_color'] = self._rand_color
|
||||||
|
module.__dict__['log'] = lambda x: info(str(x))
|
||||||
|
module.__dict__['cq'] = cq
|
||||||
|
|
||||||
def _cleanup_locals(self, module, injected_names):
|
return cq_objects, set(module.__dict__)-{'cq'}
|
||||||
for name in injected_names:
|
|
||||||
module.__dict__.pop(name)
|
def _cleanup_locals(self,module,injected_names):
|
||||||
|
|
||||||
|
for name in injected_names: module.__dict__.pop(name)
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def render(self):
|
def render(self):
|
||||||
seed(
|
seed(59798267586177) #reset the seed every time render is called (preserves colors run to run)
|
||||||
59798267586177
|
if self.preferences['Reload CQ']:
|
||||||
) # reset the seed every time render is called (preserves colors run to run)
|
|
||||||
if self.preferences["Reload CQ"]:
|
|
||||||
reload_cq()
|
reload_cq()
|
||||||
|
|
||||||
cq_script = self.get_current_script()
|
cq_script = self.get_current_script()
|
||||||
cq_code, module = self.compile_code(cq_script)
|
cq_code,module = self.compile_code(cq_script)
|
||||||
|
|
||||||
if cq_code is None:
|
if cq_code is None: return
|
||||||
return
|
|
||||||
|
|
||||||
cq_objects, injected_names = self._inject_locals(module)
|
cq_objects,injected_names = self._inject_locals(module)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._exec(cq_code, module.__dict__, module.__dict__)
|
self._exec(cq_code, module.__dict__, module.__dict__)
|
||||||
|
|
||||||
# remove the special methods
|
#remove the special methods
|
||||||
self._cleanup_locals(module, injected_names)
|
self._cleanup_locals(module,injected_names)
|
||||||
|
|
||||||
# collect all CQ objects if no explicit show_object was called
|
#collect all CQ objects if no explicit show_object was called
|
||||||
if len(cq_objects) == 0:
|
if len(cq_objects) == 0:
|
||||||
cq_objects = find_cq_objects(module.__dict__)
|
cq_objects = find_cq_objects(module.__dict__)
|
||||||
self.sigRendered.emit(cq_objects)
|
self.sigRendered.emit(cq_objects)
|
||||||
self.sigTraceback.emit(None, cq_script)
|
self.sigTraceback.emit(None,
|
||||||
|
cq_script)
|
||||||
self.sigLocals.emit(module.__dict__)
|
self.sigLocals.emit(module.__dict__)
|
||||||
except Exception:
|
except Exception:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
@@ -306,10 +272,11 @@ class Debugger(QObject, ComponentMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def breakpoints(self):
|
def breakpoints(self):
|
||||||
return [el[0] for el in self.get_breakpoints()]
|
return [ el[0] for el in self.get_breakpoints()]
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def debug(self, value):
|
def debug(self,value):
|
||||||
|
|
||||||
previous_trace = sys.gettrace()
|
previous_trace = sys.gettrace()
|
||||||
|
|
||||||
if value:
|
if value:
|
||||||
@@ -317,35 +284,37 @@ class Debugger(QObject, ComponentMixin):
|
|||||||
self.state = DbgState.STEP
|
self.state = DbgState.STEP
|
||||||
|
|
||||||
self.script = self.get_current_script()
|
self.script = self.get_current_script()
|
||||||
code, module = self.compile_code(self.script)
|
code,module = self.compile_code(self.script)
|
||||||
|
|
||||||
if code is None:
|
if code is None:
|
||||||
self.sigDebugging.emit(False)
|
self.sigDebugging.emit(False)
|
||||||
self._actions["Run"][1].setChecked(False)
|
self._actions['Run'][1].setChecked(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
cq_objects, injected_names = self._inject_locals(module)
|
cq_objects,injected_names = self._inject_locals(module)
|
||||||
|
|
||||||
# clear possible traceback
|
#clear possible traceback
|
||||||
self.sigTraceback.emit(None, self.script)
|
self.sigTraceback.emit(None,
|
||||||
|
self.script)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.settrace(self.trace_callback)
|
sys.settrace(self.trace_callback)
|
||||||
exec(code, module.__dict__, module.__dict__)
|
exec(code,module.__dict__,module.__dict__)
|
||||||
except Exception:
|
except Exception:
|
||||||
exc_info = sys.exc_info()
|
exc_info = sys.exc_info()
|
||||||
sys.last_traceback = exc_info[-1]
|
sys.last_traceback = exc_info[-1]
|
||||||
self.sigTraceback.emit(exc_info, self.script)
|
self.sigTraceback.emit(exc_info,
|
||||||
|
self.script)
|
||||||
finally:
|
finally:
|
||||||
sys.settrace(previous_trace)
|
sys.settrace(previous_trace)
|
||||||
self.sigDebugging.emit(False)
|
self.sigDebugging.emit(False)
|
||||||
self._actions["Run"][1].setChecked(False)
|
self._actions['Run'][1].setChecked(False)
|
||||||
|
|
||||||
if len(cq_objects) == 0:
|
if len(cq_objects) == 0:
|
||||||
cq_objects = find_cq_objects(module.__dict__)
|
cq_objects = find_cq_objects(module.__dict__)
|
||||||
self.sigRendered.emit(cq_objects)
|
self.sigRendered.emit(cq_objects)
|
||||||
|
|
||||||
self._cleanup_locals(module, injected_names)
|
self._cleanup_locals(module,injected_names)
|
||||||
self.sigLocals.emit(module.__dict__)
|
self.sigLocals.emit(module.__dict__)
|
||||||
|
|
||||||
self._frames = []
|
self._frames = []
|
||||||
@@ -353,37 +322,41 @@ class Debugger(QObject, ComponentMixin):
|
|||||||
sys.settrace(previous_trace)
|
sys.settrace(previous_trace)
|
||||||
self.inner_event_loop.exit(0)
|
self.inner_event_loop.exit(0)
|
||||||
|
|
||||||
def debug_cmd(self, state=DbgState.STEP):
|
|
||||||
|
def debug_cmd(self,state=DbgState.STEP):
|
||||||
|
|
||||||
self.state = state
|
self.state = state
|
||||||
self.inner_event_loop.exit(0)
|
self.inner_event_loop.exit(0)
|
||||||
|
|
||||||
def trace_callback(self, frame, event, arg):
|
|
||||||
|
def trace_callback(self,frame,event,arg):
|
||||||
|
|
||||||
filename = frame.f_code.co_filename
|
filename = frame.f_code.co_filename
|
||||||
|
|
||||||
if filename == DUMMY_FILE:
|
if filename==DUMMY_FILE:
|
||||||
if not self._frames:
|
if not self._frames:
|
||||||
self._frames.append(frame)
|
self._frames.append(frame)
|
||||||
self.trace_local(frame, event, arg)
|
self.trace_local(frame,event,arg)
|
||||||
return self.trace_callback
|
return self.trace_callback
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def trace_local(self, frame, event, arg):
|
def trace_local(self,frame,event,arg):
|
||||||
|
|
||||||
lineno = frame.f_lineno
|
lineno = frame.f_lineno
|
||||||
|
|
||||||
if event in (DbgEevent.LINE,):
|
if event in (DbgEevent.LINE,):
|
||||||
if (
|
if (self.state in (DbgState.STEP, DbgState.STEP_IN) and frame is self._frames[-1]) \
|
||||||
self.state in (DbgState.STEP, DbgState.STEP_IN)
|
or (lineno in self.breakpoints):
|
||||||
and frame is self._frames[-1]
|
|
||||||
) or (lineno in self.breakpoints):
|
|
||||||
if lineno in self.breakpoints:
|
if lineno in self.breakpoints:
|
||||||
self._frames.append(frame)
|
self._frames.append(frame)
|
||||||
|
|
||||||
self.sigLineChanged.emit(lineno)
|
self.sigLineChanged.emit(lineno)
|
||||||
self.sigFrameChanged.emit(frame)
|
self.sigFrameChanged.emit(frame)
|
||||||
self.sigLocalsChanged.emit(frame.f_locals)
|
self.sigLocalsChanged.emit(frame.f_locals)
|
||||||
self.sigCQChanged.emit(find_cq_objects(frame.f_locals), True)
|
self.sigCQChanged.emit(find_cq_objects(frame.f_locals),True)
|
||||||
|
|
||||||
self.inner_event_loop.exec_()
|
self.inner_event_loop.exec_()
|
||||||
|
|
||||||
@@ -402,7 +375,7 @@ class Debugger(QObject, ComponentMixin):
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def module_manager():
|
def module_manager():
|
||||||
"""unloads any modules loaded while the context manager is active"""
|
""" unloads any modules loaded while the context manager is active """
|
||||||
loaded_modules = set(sys.modules.keys())
|
loaded_modules = set(sys.modules.keys())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAction, QMenu, QWidget, QAbstractItemView
|
||||||
QTreeWidget,
|
|
||||||
QTreeWidgetItem,
|
|
||||||
QAction,
|
|
||||||
QMenu,
|
|
||||||
QWidget,
|
|
||||||
QAbstractItemView,
|
|
||||||
)
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||||
from pyqtgraph.parametertree import Parameter, ParameterTree
|
from pyqtgraph.parametertree import Parameter, ParameterTree
|
||||||
|
|
||||||
@@ -15,118 +8,107 @@ from OCP.gp import gp_Dir, gp_Pnt, gp_Ax1
|
|||||||
|
|
||||||
from ..mixins import ComponentMixin
|
from ..mixins import ComponentMixin
|
||||||
from ..icons import icon
|
from ..icons import icon
|
||||||
from ..cq_utils import (
|
from ..cq_utils import make_AIS, export, to_occ_color, is_obj_empty, get_occ_color, set_color
|
||||||
make_AIS,
|
|
||||||
export,
|
|
||||||
to_occ_color,
|
|
||||||
is_obj_empty,
|
|
||||||
get_occ_color,
|
|
||||||
set_color,
|
|
||||||
)
|
|
||||||
from .viewer import DEFAULT_FACE_COLOR
|
from .viewer import DEFAULT_FACE_COLOR
|
||||||
from ..utils import splitter, layout, get_save_filename
|
from ..utils import splitter, layout, get_save_filename
|
||||||
|
|
||||||
|
|
||||||
class TopTreeItem(QTreeWidgetItem):
|
class TopTreeItem(QTreeWidgetItem):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(TopTreeItem, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
def __init__(self,*args,**kwargs):
|
||||||
|
|
||||||
|
super(TopTreeItem,self).__init__(*args,**kwargs)
|
||||||
|
|
||||||
class ObjectTreeItem(QTreeWidgetItem):
|
class ObjectTreeItem(QTreeWidgetItem):
|
||||||
props = [
|
|
||||||
{"name": "Name", "type": "str", "value": ""},
|
|
||||||
{"name": "Color", "type": "color", "value": "#f4a824"},
|
|
||||||
{"name": "Alpha", "type": "float", "value": 0, "limits": (0, 1), "step": 1e-1},
|
|
||||||
{"name": "Visible", "type": "bool", "value": True},
|
|
||||||
]
|
|
||||||
|
|
||||||
def __init__(
|
props = [{'name': 'Name', 'type': 'str', 'value': ''},
|
||||||
self,
|
{'name': 'Color', 'type': 'color', 'value': "#f4a824"},
|
||||||
|
{'name': 'Alpha', 'type': 'float', 'value': 0, 'limits': (0,1), 'step': 1e-1},
|
||||||
|
{'name': 'Visible', 'type': 'bool','value': True}]
|
||||||
|
|
||||||
|
def __init__(self,
|
||||||
name,
|
name,
|
||||||
ais=None,
|
ais=None,
|
||||||
shape=None,
|
shape=None,
|
||||||
shape_display=None,
|
shape_display=None,
|
||||||
sig=None,
|
sig=None,
|
||||||
alpha=0.0,
|
alpha=0.,
|
||||||
color="#f4a824",
|
color='#f4a824',
|
||||||
**kwargs
|
**kwargs):
|
||||||
):
|
|
||||||
super(ObjectTreeItem, self).__init__([name], **kwargs)
|
super(ObjectTreeItem,self).__init__([name],**kwargs)
|
||||||
self.setFlags(self.flags() | Qt.ItemIsUserCheckable)
|
self.setFlags( self.flags() | Qt.ItemIsUserCheckable)
|
||||||
self.setCheckState(0, Qt.Checked)
|
self.setCheckState(0,Qt.Checked)
|
||||||
|
|
||||||
self.ais = ais
|
self.ais = ais
|
||||||
self.shape = shape
|
self.shape = shape
|
||||||
self.shape_display = shape_display
|
self.shape_display = shape_display
|
||||||
self.sig = sig
|
self.sig = sig
|
||||||
|
|
||||||
self.properties = Parameter.create(name="Properties", children=self.props)
|
self.properties = Parameter.create(name='Properties',
|
||||||
|
children=self.props)
|
||||||
|
|
||||||
self.properties["Name"] = name
|
self.properties['Name'] = name
|
||||||
self.properties["Alpha"] = ais.Transparency()
|
self.properties['Alpha'] = ais.Transparency()
|
||||||
self.properties["Color"] = (
|
self.properties['Color'] = get_occ_color(ais) if ais and ais.HasColor() else get_occ_color(DEFAULT_FACE_COLOR)
|
||||||
get_occ_color(ais)
|
|
||||||
if ais and ais.HasColor()
|
|
||||||
else get_occ_color(DEFAULT_FACE_COLOR)
|
|
||||||
)
|
|
||||||
self.properties.sigTreeStateChanged.connect(self.propertiesChanged)
|
self.properties.sigTreeStateChanged.connect(self.propertiesChanged)
|
||||||
|
|
||||||
def propertiesChanged(self, properties, changed):
|
def propertiesChanged(self, properties, changed):
|
||||||
|
|
||||||
changed_prop = changed[0][0]
|
changed_prop = changed[0][0]
|
||||||
|
|
||||||
self.setData(0, 0, self.properties["Name"])
|
self.setData(0,0,self.properties['Name'])
|
||||||
self.ais.SetTransparency(self.properties["Alpha"])
|
self.ais.SetTransparency(self.properties['Alpha'])
|
||||||
|
|
||||||
if changed_prop.name() == "Color":
|
if changed_prop.name() == 'Color':
|
||||||
set_color(self.ais, to_occ_color(self.properties["Color"]))
|
set_color(self.ais, to_occ_color(self.properties['Color']))
|
||||||
|
|
||||||
self.ais.Redisplay()
|
self.ais.Redisplay()
|
||||||
|
|
||||||
if self.properties["Visible"]:
|
if self.properties['Visible']:
|
||||||
self.setCheckState(0, Qt.Checked)
|
self.setCheckState(0,Qt.Checked)
|
||||||
else:
|
else:
|
||||||
self.setCheckState(0, Qt.Unchecked)
|
self.setCheckState(0,Qt.Unchecked)
|
||||||
|
|
||||||
if self.sig:
|
if self.sig:
|
||||||
self.sig.emit()
|
self.sig.emit()
|
||||||
|
|
||||||
|
|
||||||
class CQRootItem(TopTreeItem):
|
class CQRootItem(TopTreeItem):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(CQRootItem, self).__init__(["CQ models"], *args, **kwargs)
|
def __init__(self,*args,**kwargs):
|
||||||
|
|
||||||
|
super(CQRootItem,self).__init__(['CQ models'],*args,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class HelpersRootItem(TopTreeItem):
|
class HelpersRootItem(TopTreeItem):
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(HelpersRootItem, self).__init__(["Helpers"], *args, **kwargs)
|
def __init__(self,*args,**kwargs):
|
||||||
|
|
||||||
|
super(HelpersRootItem,self).__init__(['Helpers'],*args,**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ObjectTree(QWidget, ComponentMixin):
|
class ObjectTree(QWidget,ComponentMixin):
|
||||||
name = "Object Tree"
|
|
||||||
|
name = 'Object Tree'
|
||||||
_stash = []
|
_stash = []
|
||||||
|
|
||||||
preferences = Parameter.create(
|
preferences = Parameter.create(name='Preferences',children=[
|
||||||
name="Preferences",
|
{'name': 'Preserve properties on reload', 'type': 'bool', 'value': False},
|
||||||
children=[
|
{'name': 'Clear all before each run', 'type': 'bool', 'value': True},
|
||||||
{"name": "Preserve properties on reload", "type": "bool", "value": False},
|
{'name': 'STL precision','type': 'float', 'value': .1}])
|
||||||
{"name": "Clear all before each run", "type": "bool", "value": True},
|
|
||||||
{"name": "STL precision", "type": "float", "value": 0.1},
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
sigObjectsAdded = pyqtSignal([list], [list, bool])
|
sigObjectsAdded = pyqtSignal([list],[list,bool])
|
||||||
sigObjectsRemoved = pyqtSignal(list)
|
sigObjectsRemoved = pyqtSignal(list)
|
||||||
sigCQObjectSelected = pyqtSignal(object)
|
sigCQObjectSelected = pyqtSignal(object)
|
||||||
sigAISObjectsSelected = pyqtSignal(list)
|
sigAISObjectsSelected = pyqtSignal(list)
|
||||||
sigItemChanged = pyqtSignal(QTreeWidgetItem, int)
|
sigItemChanged = pyqtSignal(QTreeWidgetItem,int)
|
||||||
sigObjectPropertiesChanged = pyqtSignal()
|
sigObjectPropertiesChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self,parent):
|
||||||
super(ObjectTree, self).__init__(parent)
|
|
||||||
|
|
||||||
self.tree = tree = QTreeWidget(
|
super(ObjectTree,self).__init__(parent)
|
||||||
self, selectionMode=QAbstractItemView.ExtendedSelection
|
|
||||||
)
|
self.tree = tree = QTreeWidget(self,
|
||||||
|
selectionMode=QAbstractItemView.ExtendedSelection)
|
||||||
self.properties_editor = ParameterTree(self)
|
self.properties_editor = ParameterTree(self)
|
||||||
|
|
||||||
tree.setHeaderHidden(True)
|
tree.setHeaderHidden(True)
|
||||||
@@ -134,9 +116,10 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
tree.setRootIsDecorated(False)
|
tree.setRootIsDecorated(False)
|
||||||
tree.setContextMenuPolicy(Qt.ActionsContextMenu)
|
tree.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||||
|
|
||||||
# forward itemChanged singal
|
#forward itemChanged singal
|
||||||
tree.itemChanged.connect(lambda item, col: self.sigItemChanged.emit(item, col))
|
tree.itemChanged.connect(\
|
||||||
# handle visibility changes form tree
|
lambda item,col: self.sigItemChanged.emit(item,col))
|
||||||
|
#handle visibility changes form tree
|
||||||
tree.itemChanged.connect(self.handleChecked)
|
tree.itemChanged.connect(self.handleChecked)
|
||||||
|
|
||||||
self.CQ = CQRootItem()
|
self.CQ = CQRootItem()
|
||||||
@@ -148,31 +131,30 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
|
|
||||||
tree.expandToDepth(1)
|
tree.expandToDepth(1)
|
||||||
|
|
||||||
self._export_STL_action = QAction(
|
self._export_STL_action = \
|
||||||
"Export as STL",
|
QAction('Export as STL',
|
||||||
self,
|
self,
|
||||||
enabled=False,
|
enabled=False,
|
||||||
triggered=lambda: self.export("stl", self.preferences["STL precision"]),
|
triggered=lambda: \
|
||||||
)
|
self.export('stl',
|
||||||
|
self.preferences['STL precision']))
|
||||||
|
|
||||||
self._export_STEP_action = QAction(
|
self._export_STEP_action = \
|
||||||
"Export as STEP", self, enabled=False, triggered=lambda: self.export("step")
|
QAction('Export as STEP',
|
||||||
)
|
|
||||||
|
|
||||||
self._clear_current_action = QAction(
|
|
||||||
icon("delete"),
|
|
||||||
"Clear current",
|
|
||||||
self,
|
self,
|
||||||
enabled=False,
|
enabled=False,
|
||||||
triggered=self.removeSelected,
|
triggered=lambda: \
|
||||||
)
|
self.export('step'))
|
||||||
|
|
||||||
self._toolbar_actions = [
|
self._clear_current_action = QAction(icon('delete'),
|
||||||
QAction(
|
'Clear current',
|
||||||
icon("delete-many"), "Clear all", self, triggered=self.removeObjects
|
self,
|
||||||
),
|
enabled=False,
|
||||||
self._clear_current_action,
|
triggered=self.removeSelected)
|
||||||
]
|
|
||||||
|
self._toolbar_actions = \
|
||||||
|
[QAction(icon('delete-many'),'Clear all',self,triggered=self.removeObjects),
|
||||||
|
self._clear_current_action,]
|
||||||
|
|
||||||
self.prepareMenu()
|
self.prepareMenu()
|
||||||
|
|
||||||
@@ -181,157 +163,135 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
|
|
||||||
self.prepareLayout()
|
self.prepareLayout()
|
||||||
|
|
||||||
|
|
||||||
def prepareMenu(self):
|
def prepareMenu(self):
|
||||||
|
|
||||||
self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
|
|
||||||
self._context_menu = QMenu(self)
|
self._context_menu = QMenu(self)
|
||||||
self._context_menu.addActions(self._toolbar_actions)
|
self._context_menu.addActions(self._toolbar_actions)
|
||||||
self._context_menu.addActions(
|
self._context_menu.addActions((self._export_STL_action,
|
||||||
(self._export_STL_action, self._export_STEP_action)
|
self._export_STEP_action))
|
||||||
)
|
|
||||||
|
|
||||||
def prepareLayout(self):
|
def prepareLayout(self):
|
||||||
self._splitter = splitter(
|
|
||||||
(self.tree, self.properties_editor),
|
self._splitter = splitter((self.tree,self.properties_editor),
|
||||||
stretch_factors=(2, 1),
|
stretch_factors = (2,1),
|
||||||
orientation=Qt.Vertical,
|
orientation=Qt.Vertical)
|
||||||
)
|
layout(self,(self._splitter,),top_widget=self)
|
||||||
layout(self, (self._splitter,), top_widget=self)
|
|
||||||
|
|
||||||
self._splitter.show()
|
self._splitter.show()
|
||||||
|
|
||||||
def showMenu(self, position):
|
def showMenu(self,position):
|
||||||
|
|
||||||
self._context_menu.exec_(self.tree.viewport().mapToGlobal(position))
|
self._context_menu.exec_(self.tree.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
|
|
||||||
def menuActions(self):
|
def menuActions(self):
|
||||||
return {"Tools": [self._export_STL_action, self._export_STEP_action]}
|
|
||||||
|
return {'Tools' : [self._export_STL_action,
|
||||||
|
self._export_STEP_action]}
|
||||||
|
|
||||||
def toolbarActions(self):
|
def toolbarActions(self):
|
||||||
|
|
||||||
return self._toolbar_actions
|
return self._toolbar_actions
|
||||||
|
|
||||||
def addLines(self):
|
def addLines(self):
|
||||||
origin = (0, 0, 0)
|
|
||||||
|
origin = (0,0,0)
|
||||||
ais_list = []
|
ais_list = []
|
||||||
|
|
||||||
for name, color, direction in zip(
|
for name,color,direction in zip(('X','Y','Z'),
|
||||||
("X", "Y", "Z"),
|
('red','lawngreen','blue'),
|
||||||
((0.2, 0, 0), "lawngreen", "blue"),
|
((1,0,0),(0,1,0),(0,0,1))):
|
||||||
((1, 0, 0), (0, 1, 0), (0, 0, 1)),
|
line_placement = Geom_Line(gp_Ax1(gp_Pnt(*origin),
|
||||||
):
|
gp_Dir(*direction)))
|
||||||
line_placement = Geom_Line(gp_Ax1(gp_Pnt(*origin), gp_Dir(*direction)))
|
|
||||||
line = AIS_Line(line_placement)
|
line = AIS_Line(line_placement)
|
||||||
line.SetColor(to_occ_color(color))
|
line.SetColor(to_occ_color(color))
|
||||||
|
|
||||||
self.Helpers.addChild(ObjectTreeItem(name, ais=line))
|
self.Helpers.addChild(ObjectTreeItem(name,
|
||||||
|
ais=line))
|
||||||
|
|
||||||
ais_list.append(line)
|
ais_list.append(line)
|
||||||
|
|
||||||
self.sigObjectsAdded.emit(ais_list)
|
self.sigObjectsAdded.emit(ais_list)
|
||||||
|
|
||||||
def _current_properties(self):
|
def _current_properties(self):
|
||||||
|
|
||||||
current_params = {}
|
current_params = {}
|
||||||
for i in range(self.CQ.childCount()):
|
for i in range(self.CQ.childCount()):
|
||||||
child = self.CQ.child(i)
|
child = self.CQ.child(i)
|
||||||
current_params[child.properties["Name"]] = child.properties
|
current_params[child.properties['Name']] = child.properties
|
||||||
|
|
||||||
return current_params
|
return current_params
|
||||||
|
|
||||||
def _restore_properties(self, obj, properties):
|
def _restore_properties(self,obj,properties):
|
||||||
for p in properties[obj.properties["Name"]]:
|
|
||||||
|
for p in properties[obj.properties['Name']]:
|
||||||
obj.properties[p.name()] = p.value()
|
obj.properties[p.name()] = p.value()
|
||||||
|
|
||||||
@pyqtSlot(dict, bool)
|
@pyqtSlot(dict,bool)
|
||||||
@pyqtSlot(dict)
|
@pyqtSlot(dict)
|
||||||
def addObjects(self, objects, clean=False, root=None):
|
def addObjects(self,objects,clean=False,root=None):
|
||||||
|
|
||||||
if root is None:
|
if root is None:
|
||||||
root = self.CQ
|
root = self.CQ
|
||||||
|
|
||||||
request_fit_view = True if root.childCount() == 0 else False
|
request_fit_view = True if root.childCount() == 0 else False
|
||||||
preserve_props = self.preferences["Preserve properties on reload"]
|
preserve_props = self.preferences['Preserve properties on reload']
|
||||||
|
|
||||||
if preserve_props:
|
if preserve_props:
|
||||||
current_props = self._current_properties()
|
current_props = self._current_properties()
|
||||||
|
|
||||||
if clean or self.preferences["Clear all before each run"]:
|
if clean or self.preferences['Clear all before each run']:
|
||||||
self.removeObjects()
|
self.removeObjects()
|
||||||
|
|
||||||
ais_list = []
|
ais_list = []
|
||||||
|
|
||||||
# remove empty objects
|
#remove empty objects
|
||||||
objects_f = {k: v for k, v in objects.items() if not is_obj_empty(v.shape)}
|
objects_f = {k:v for k,v in objects.items() if not is_obj_empty(v.shape)}
|
||||||
|
|
||||||
for name, obj in objects_f.items():
|
for name,obj in objects_f.items():
|
||||||
ais, shape_display = make_AIS(obj.shape, obj.options)
|
ais,shape_display = make_AIS(obj.shape,obj.options)
|
||||||
|
|
||||||
child = ObjectTreeItem(
|
child = ObjectTreeItem(name,
|
||||||
name,
|
|
||||||
shape=obj.shape,
|
shape=obj.shape,
|
||||||
shape_display=shape_display,
|
shape_display=shape_display,
|
||||||
ais=ais,
|
ais=ais,
|
||||||
sig=self.sigObjectPropertiesChanged,
|
sig=self.sigObjectPropertiesChanged)
|
||||||
)
|
|
||||||
|
|
||||||
if preserve_props and name in current_props:
|
if preserve_props and name in current_props:
|
||||||
self._restore_properties(child, current_props)
|
self._restore_properties(child,current_props)
|
||||||
|
|
||||||
if child.properties["Visible"]:
|
if child.properties['Visible']:
|
||||||
ais_list.append(ais)
|
ais_list.append(ais)
|
||||||
|
|
||||||
root.addChild(child)
|
root.addChild(child)
|
||||||
|
|
||||||
if request_fit_view:
|
if request_fit_view:
|
||||||
self.sigObjectsAdded[list, bool].emit(ais_list, True)
|
self.sigObjectsAdded[list,bool].emit(ais_list,True)
|
||||||
else:
|
else:
|
||||||
self.sigObjectsAdded[list].emit(ais_list)
|
self.sigObjectsAdded[list].emit(ais_list)
|
||||||
|
|
||||||
@pyqtSlot(object, str, object)
|
@pyqtSlot(object,str,object)
|
||||||
def addObject(
|
def addObject(self,obj,name='',options={}):
|
||||||
self,
|
|
||||||
obj,
|
|
||||||
name="",
|
|
||||||
options={}, # all following inputs are ignored by cq-editor
|
|
||||||
parent=1,
|
|
||||||
clear=True,
|
|
||||||
port=3939,
|
|
||||||
axes=False,
|
|
||||||
axes0=False,
|
|
||||||
grid=False,
|
|
||||||
ticks=10,
|
|
||||||
ortho=True,
|
|
||||||
transparent=False,
|
|
||||||
default_color=(232, 176, 36),
|
|
||||||
reset_camera=True,
|
|
||||||
zoom=1.0,
|
|
||||||
default_edgecolor=(128, 128, 128),
|
|
||||||
render_edges=True,
|
|
||||||
render_normals=False,
|
|
||||||
render_mates=False,
|
|
||||||
mate_scale=1.0,
|
|
||||||
deviation=0.1,
|
|
||||||
angular_tolerance=0.2,
|
|
||||||
edge_accuracy=5.0,
|
|
||||||
ambient_intensity=1.0,
|
|
||||||
direct_intensity=0.12,
|
|
||||||
):
|
|
||||||
root = self.CQ
|
root = self.CQ
|
||||||
|
|
||||||
ais, shape_display = make_AIS(obj, options)
|
ais,shape_display = make_AIS(obj, options)
|
||||||
|
|
||||||
root.addChild(
|
root.addChild(ObjectTreeItem(name,
|
||||||
ObjectTreeItem(
|
|
||||||
name,
|
|
||||||
shape=obj,
|
shape=obj,
|
||||||
shape_display=shape_display,
|
shape_display=shape_display,
|
||||||
ais=ais,
|
ais=ais,
|
||||||
sig=self.sigObjectPropertiesChanged,
|
sig=self.sigObjectPropertiesChanged))
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
self.sigObjectsAdded.emit([ais])
|
self.sigObjectsAdded.emit([ais])
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def removeObjects(self, objects=None):
|
def removeObjects(self,objects=None):
|
||||||
|
|
||||||
if objects:
|
if objects:
|
||||||
removed_items_ais = [self.CQ.takeChild(i).ais for i in objects]
|
removed_items_ais = [self.CQ.takeChild(i).ais for i in objects]
|
||||||
else:
|
else:
|
||||||
@@ -340,7 +300,8 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
self.sigObjectsRemoved.emit(removed_items_ais)
|
self.sigObjectsRemoved.emit(removed_items_ais)
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def stashObjects(self, action: bool):
|
def stashObjects(self,action : bool):
|
||||||
|
|
||||||
if action:
|
if action:
|
||||||
self._stash = self.CQ.takeChildren()
|
self._stash = self.CQ.takeChildren()
|
||||||
removed_items_ais = [ch.ais for ch in self._stash]
|
removed_items_ais = [ch.ais for ch in self._stash]
|
||||||
@@ -353,12 +314,14 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def removeSelected(self):
|
def removeSelected(self):
|
||||||
|
|
||||||
ixs = self.tree.selectedIndexes()
|
ixs = self.tree.selectedIndexes()
|
||||||
rows = [ix.row() for ix in ixs]
|
rows = [ix.row() for ix in ixs]
|
||||||
|
|
||||||
self.removeObjects(rows)
|
self.removeObjects(rows)
|
||||||
|
|
||||||
def export(self, export_type, precision=None):
|
def export(self,export_type,precision=None):
|
||||||
|
|
||||||
items = self.tree.selectedItems()
|
items = self.tree.selectedItems()
|
||||||
|
|
||||||
# if CQ models is selected get all children
|
# if CQ models is selected get all children
|
||||||
@@ -370,12 +333,13 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
shapes = [item.shape for item in items if item.parent() is self.CQ]
|
shapes = [item.shape for item in items if item.parent() is self.CQ]
|
||||||
|
|
||||||
fname = get_save_filename(export_type)
|
fname = get_save_filename(export_type)
|
||||||
if fname != "":
|
if fname != '':
|
||||||
export(shapes, export_type, fname, precision)
|
export(shapes,export_type,fname,precision)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def handleSelection(self):
|
def handleSelection(self):
|
||||||
items = self.tree.selectedItems()
|
|
||||||
|
items =self.tree.selectedItems()
|
||||||
if len(items) == 0:
|
if len(items) == 0:
|
||||||
self._export_STL_action.setEnabled(False)
|
self._export_STL_action.setEnabled(False)
|
||||||
self._export_STEP_action.setEnabled(False)
|
self._export_STEP_action.setEnabled(False)
|
||||||
@@ -392,9 +356,10 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
self._export_STEP_action.setEnabled(True)
|
self._export_STEP_action.setEnabled(True)
|
||||||
self._clear_current_action.setEnabled(True)
|
self._clear_current_action.setEnabled(True)
|
||||||
self.sigCQObjectSelected.emit(item.shape)
|
self.sigCQObjectSelected.emit(item.shape)
|
||||||
self.properties_editor.setParameters(item.properties, showTop=False)
|
self.properties_editor.setParameters(item.properties,
|
||||||
|
showTop=False)
|
||||||
self.properties_editor.setEnabled(True)
|
self.properties_editor.setEnabled(True)
|
||||||
elif item is self.CQ and item.childCount() > 0:
|
elif item is self.CQ and item.childCount()>0:
|
||||||
self._export_STL_action.setEnabled(True)
|
self._export_STL_action.setEnabled(True)
|
||||||
self._export_STEP_action.setEnabled(True)
|
self._export_STEP_action.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
@@ -405,7 +370,8 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
self.properties_editor.clear()
|
self.properties_editor.clear()
|
||||||
|
|
||||||
@pyqtSlot(list)
|
@pyqtSlot(list)
|
||||||
def handleGraphicalSelection(self, shapes):
|
def handleGraphicalSelection(self,shapes):
|
||||||
|
|
||||||
self.tree.clearSelection()
|
self.tree.clearSelection()
|
||||||
|
|
||||||
CQ = self.CQ
|
CQ = self.CQ
|
||||||
@@ -415,10 +381,11 @@ class ObjectTree(QWidget, ComponentMixin):
|
|||||||
if item.ais.Shape().IsEqual(shape):
|
if item.ais.Shape().IsEqual(shape):
|
||||||
item.setSelected(True)
|
item.setSelected(True)
|
||||||
|
|
||||||
@pyqtSlot(QTreeWidgetItem, int)
|
@pyqtSlot(QTreeWidgetItem,int)
|
||||||
def handleChecked(self, item, col):
|
def handleChecked(self,item,col):
|
||||||
|
|
||||||
if type(item) is ObjectTreeItem:
|
if type(item) is ObjectTreeItem:
|
||||||
if item.checkState(0):
|
if item.checkState(0):
|
||||||
item.properties["Visible"] = True
|
item.properties['Visible'] = True
|
||||||
else:
|
else:
|
||||||
item.properties["Visible"] = False
|
item.properties['Visible'] = False
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from OCP.Aspect import Aspect_DisplayConnection, Aspect_TypeOfTriedronPosition
|
|||||||
from OCP.OpenGl import OpenGl_GraphicDriver
|
from OCP.OpenGl import OpenGl_GraphicDriver
|
||||||
from OCP.V3d import V3d_Viewer
|
from OCP.V3d import V3d_Viewer
|
||||||
from OCP.AIS import AIS_InteractiveContext, AIS_DisplayMode
|
from OCP.AIS import AIS_InteractiveContext, AIS_DisplayMode
|
||||||
from OCP.Quantity import Quantity_Color, Quantity_TOC_RGB as TOC_RGB
|
from OCP.Quantity import Quantity_Color
|
||||||
|
|
||||||
|
|
||||||
ZOOM_STEP = 0.9
|
ZOOM_STEP = 0.9
|
||||||
@@ -54,8 +54,6 @@ class OCCTWidget(QWidget):
|
|||||||
Aspect_TypeOfTriedronPosition.Aspect_TOTP_RIGHT_LOWER,
|
Aspect_TypeOfTriedronPosition.Aspect_TOTP_RIGHT_LOWER,
|
||||||
Quantity_Color(), 0.1)
|
Quantity_Color(), 0.1)
|
||||||
|
|
||||||
view.ZBufferTriedronSetup(Quantity_Color(*(0.2, 0.0, 0.0), TOC_RGB))
|
|
||||||
|
|
||||||
viewer = self.viewer
|
viewer = self.viewer
|
||||||
|
|
||||||
viewer.SetDefaultLights()
|
viewer.SetDefaultLights()
|
||||||
@@ -97,8 +95,8 @@ class OCCTWidget(QWidget):
|
|||||||
self.old_pos.y() - y, theToStart=True)
|
self.old_pos.y() - y, theToStart=True)
|
||||||
|
|
||||||
elif event.buttons() == Qt.RightButton:
|
elif event.buttons() == Qt.RightButton:
|
||||||
self.view.Pan(x - self.old_pos.x(),
|
self.view.ZoomAtPoint(self.old_pos.x(), y,
|
||||||
self.old_pos.y() - y, theToStart=True)
|
x, self.old_pos.y())
|
||||||
|
|
||||||
self.old_pos = pos
|
self.old_pos = pos
|
||||||
|
|
||||||
|
|||||||
@@ -252,13 +252,13 @@ class OCCViewer(QWidget,ComponentMixin):
|
|||||||
def front_view(self):
|
def front_view(self):
|
||||||
|
|
||||||
v = self._get_view()
|
v = self._get_view()
|
||||||
v.SetProj(0,-1,0)
|
v.SetProj(0,1,0)
|
||||||
v.SetTwist(0)
|
v.SetTwist(0)
|
||||||
|
|
||||||
def back_view(self):
|
def back_view(self):
|
||||||
|
|
||||||
v = self._get_view()
|
v = self._get_view()
|
||||||
v.SetProj(0,1,0)
|
v.SetProj(0,-1,0)
|
||||||
v.SetTwist(0)
|
v.SetTwist(0)
|
||||||
|
|
||||||
def left_view(self):
|
def left_view(self):
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ channels:
|
|||||||
- conda-forge
|
- conda-forge
|
||||||
- defaults
|
- defaults
|
||||||
dependencies:
|
dependencies:
|
||||||
- python=3.10
|
- python=3.9
|
||||||
98
pyinstaller.spec
Normal file
98
pyinstaller.spec
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
# -*- mode: python -*-
|
||||||
|
|
||||||
|
import sys, site, os
|
||||||
|
from path import Path
|
||||||
|
from PyInstaller.utils.hooks import collect_all, collect_submodules
|
||||||
|
|
||||||
|
block_cipher = None
|
||||||
|
|
||||||
|
spyder_data = Path(site.getsitepackages()[-1]) / 'spyder'
|
||||||
|
parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*')
|
||||||
|
cqw_path = Path(site.getsitepackages()[-1]) / 'cq_warehouse'
|
||||||
|
cq_path = Path(site.getsitepackages()[-1]) / 'cadquery'
|
||||||
|
|
||||||
|
if sys.platform == 'linux':
|
||||||
|
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||||
|
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-39-x86_64-linux-gnu.so'), '.')
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||||
|
ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-39-darwin.so'), '.')
|
||||||
|
elif sys.platform == 'win32':
|
||||||
|
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
|
||||||
|
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp39-win_amd64.pyd'), '.')]
|
||||||
|
cas_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'casadi_nlpsol_ipopt.dll'), '.')]
|
||||||
|
ipo_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'ipopt-3.dll'), '.')]
|
||||||
|
bla_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'libblas.dll'), '.')]
|
||||||
|
lap_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'liblapack.dll'), '.')]
|
||||||
|
mum_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'dmumps.dll'), '.')]
|
||||||
|
fla_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'flang.dll'), '.')]
|
||||||
|
flr_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'flangrti.dll'), '.')]
|
||||||
|
omp_DLL = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'libomp.dll'), '.')]
|
||||||
|
mkl_DLLs = [(os.path.join(Path(sys.prefix), 'Library', 'bin', 'mkl*.dll'), '.')]
|
||||||
|
#cas_dllA = os.path.join(HOMEPATH, 'casadi', 'libcasadi.dll')
|
||||||
|
#cas_dllB = os.path.join(HOMEPATH, 'casadi', 'libcasadi_nlpsol_ipopt.dll')
|
||||||
|
|
||||||
|
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
|
||||||
|
hiddenimports2 = collect_submodules('xmlrpc')
|
||||||
|
|
||||||
|
a = Analysis(['run.py'],
|
||||||
|
pathex=['.'],
|
||||||
|
binaries=ocp_path + cas_DLL + ipo_DLL + bla_DLL + lap_DLL + mum_DLL + fla_DLL + flr_DLL + omp_DLL + mkl_DLLs + binaries1,
|
||||||
|
datas=[(spyder_data, 'spyder'),
|
||||||
|
(occt_dir, 'opencascade'),
|
||||||
|
(cqw_path, 'cq_warehouse'),
|
||||||
|
(cq_path, 'cadquery')] +
|
||||||
|
[(p, 'parso/python') for p in parso_grammar] + datas1,
|
||||||
|
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
|
||||||
|
'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5',
|
||||||
|
'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5',
|
||||||
|
'pyqtgraph.imageview.ImageViewTemplate_pyqt5', 'xmlrpc', 'ipopt', 'casadi',
|
||||||
|
'zmq.backend', 'cq_warehouse', 'cq_warehouse.bearing', 'cq_warehouse.chain',
|
||||||
|
'cq_warehouse.drafting', 'cq_warehouse.extensions', 'cq_warehouse.fastener',
|
||||||
|
'cq_warehouse.sprocket', 'cq_warehouse.thread', 'cq_gears', 'cq_cache',
|
||||||
|
'build123d', 'cqmore'] + hiddenimports1 + hiddenimports2,
|
||||||
|
hookspath=[],
|
||||||
|
runtime_hooks=['pyinstaller/pyi_rth_occ.py',
|
||||||
|
'pyinstaller/pyi_rth_fontconfig.py'],
|
||||||
|
excludes=['_tkinter'],
|
||||||
|
win_no_prefer_redirects=False,
|
||||||
|
win_private_assemblies=False,
|
||||||
|
cipher=block_cipher,
|
||||||
|
noarchive=False)
|
||||||
|
|
||||||
|
# There is an issue that keeps the OpenSSL libraries from being copied to the output directory.
|
||||||
|
# This should work if nothing else, but does not with GitHub Actions
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
from PyInstaller.depend.bindepend import getfullnameof
|
||||||
|
rel_data_path = ['PyQt5', 'Qt', 'bin']
|
||||||
|
a.datas += [
|
||||||
|
(getfullnameof('libssl-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||||
|
(getfullnameof('libcrypto-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
pyz = PYZ(a.pure, a.zipped_data,
|
||||||
|
cipher=block_cipher)
|
||||||
|
exe = EXE(pyz,
|
||||||
|
a.scripts,
|
||||||
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
|
name='CQ-editor',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
console=True,
|
||||||
|
icon='icons/cadquery_logo_dark.ico')
|
||||||
|
|
||||||
|
exclude = ()
|
||||||
|
#exclude = ('libGL','libEGL','libbsd')
|
||||||
|
a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)])
|
||||||
|
|
||||||
|
coll = COLLECT(exe,
|
||||||
|
a.binaries,
|
||||||
|
a.zipfiles,
|
||||||
|
a.datas,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
name='CQ-editor')
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# hook-py_lib3mf.py
|
|
||||||
from PyInstaller.utils.hooks import collect_dynamic_libs
|
|
||||||
|
|
||||||
binaries = collect_dynamic_libs('py_lib3mf')
|
|
||||||
@@ -9,18 +9,17 @@ block_cipher = None
|
|||||||
spyder_data = Path(site.getsitepackages()[-1]) / 'spyder'
|
spyder_data = Path(site.getsitepackages()[-1]) / 'spyder'
|
||||||
parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*')
|
parso_grammar = (Path(site.getsitepackages()[-1]) / 'parso/python').glob('grammar*')
|
||||||
cqw_path = Path(site.getsitepackages()[-1]) / 'cq_warehouse'
|
cqw_path = Path(site.getsitepackages()[-1]) / 'cq_warehouse'
|
||||||
bdw_path = Path(site.getsitepackages()[-1]) / 'bd_warehouse'
|
|
||||||
cq_path = Path(site.getsitepackages()[-1]) / 'cadquery'
|
cq_path = Path(site.getsitepackages()[-1]) / 'cadquery'
|
||||||
|
|
||||||
if sys.platform == 'linux':
|
if sys.platform == 'linux':
|
||||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-310-x86_64-linux-gnu.so'), '.')]
|
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-39-x86_64-linux-gnu.so'), '.')]
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
|
||||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-310-darwin.so'), '.')]
|
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cpython-39-darwin.so'), '.')]
|
||||||
elif sys.platform == 'win32':
|
elif sys.platform == 'win32':
|
||||||
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
|
occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
|
||||||
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp310-win_amd64.pyd'), '.')]
|
ocp_path = [(os.path.join(HOMEPATH, 'OCP.cp39-win_amd64.pyd'), '.')]
|
||||||
|
|
||||||
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
|
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
|
||||||
hiddenimports2 = collect_submodules('xmlrpc')
|
hiddenimports2 = collect_submodules('xmlrpc')
|
||||||
@@ -30,7 +29,6 @@ a = Analysis(['run.py'],
|
|||||||
binaries=ocp_path + binaries1,
|
binaries=ocp_path + binaries1,
|
||||||
datas=[(spyder_data, 'spyder'),
|
datas=[(spyder_data, 'spyder'),
|
||||||
(cqw_path, 'cq_warehouse'),
|
(cqw_path, 'cq_warehouse'),
|
||||||
(bdw_path, 'bd_warehouse'),
|
|
||||||
(cq_path, 'cadquery')] +
|
(cq_path, 'cadquery')] +
|
||||||
[(p, 'parso/python') for p in parso_grammar] + datas1,
|
[(p, 'parso/python') for p in parso_grammar] + datas1,
|
||||||
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
|
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
|
||||||
@@ -40,8 +38,7 @@ a = Analysis(['run.py'],
|
|||||||
'zmq.backend', 'cq_warehouse', 'cq_warehouse.bearing', 'cq_warehouse.chain',
|
'zmq.backend', 'cq_warehouse', 'cq_warehouse.bearing', 'cq_warehouse.chain',
|
||||||
'cq_warehouse.drafting', 'cq_warehouse.extensions', 'cq_warehouse.fastener',
|
'cq_warehouse.drafting', 'cq_warehouse.extensions', 'cq_warehouse.fastener',
|
||||||
'cq_warehouse.sprocket', 'cq_warehouse.thread', 'cq_gears', 'cq_cache',
|
'cq_warehouse.sprocket', 'cq_warehouse.thread', 'cq_gears', 'cq_cache',
|
||||||
'build123d', 'cqmore', 'bd_warehouse', 'bd_warehouse.pipe', 'bd_warehouse.flange',
|
'build123d', 'cqmore'] + hiddenimports1 + hiddenimports2,
|
||||||
'bd_warehouse.thread', 'bd_warehouse.gears'] + hiddenimports1 + hiddenimports2,
|
|
||||||
hookspath=['pyinstaller/extrahooks/'],
|
hookspath=['pyinstaller/extrahooks/'],
|
||||||
runtime_hooks=['pyinstaller/pyi_rth_occ.py',
|
runtime_hooks=['pyinstaller/pyi_rth_occ.py',
|
||||||
'pyinstaller/pyi_rth_fontconfig.py'],
|
'pyinstaller/pyi_rth_fontconfig.py'],
|
||||||
@@ -53,13 +50,13 @@ a = Analysis(['run.py'],
|
|||||||
|
|
||||||
# There is an issue that keeps the OpenSSL libraries from being copied to the output directory.
|
# There is an issue that keeps the OpenSSL libraries from being copied to the output directory.
|
||||||
# This should work if nothing else, but does not with GitHub Actions
|
# This should work if nothing else, but does not with GitHub Actions
|
||||||
# if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
# from PyInstaller.depend.bindepend import getfullnameof
|
from PyInstaller.depend.bindepend import getfullnameof
|
||||||
# rel_data_path = ['PyQt5', 'Qt', 'bin']
|
rel_data_path = ['PyQt5', 'Qt', 'bin']
|
||||||
# a.datas += [
|
a.datas += [
|
||||||
# (getfullnameof('libssl-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
(getfullnameof('libssl-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||||
# (getfullnameof('libcrypto-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
(getfullnameof('libcrypto-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'),
|
||||||
# ]
|
]
|
||||||
|
|
||||||
|
|
||||||
pyz = PYZ(a.pure, a.zipped_data,
|
pyz = PYZ(a.pure, a.zipped_data,
|
||||||
|
|||||||
7
setup.py
7
setup.py
@@ -26,14 +26,15 @@ setup(
|
|||||||
"CQ-editor = cq_editor.__main__:main",
|
"CQ-editor = cq_editor.__main__:main",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
python_requires=">=3.8,<3.12",
|
python_requires=">=3.8,<3.11",
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"logbook>=1",
|
"logbook>=1",
|
||||||
"ipython",
|
"ipython==8.4.0",
|
||||||
|
"jedi==0.17.2",
|
||||||
"path>=16",
|
"path>=16",
|
||||||
"PyQt5>=5",
|
"PyQt5>=5",
|
||||||
"requests>=2,<3",
|
"requests>=2,<3",
|
||||||
"spyder>=5,<6",
|
"spyder>=5,<6",
|
||||||
"pyqtgraph",
|
"pyqtgraph==0.12.4",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user