67 Commits

Author SHA1 Message Date
jdegenstein
524a8dd6fd Change right click and drag to pan
Change right click and drag to pan (same as middle click and drag)
2023-02-02 15:25:27 -06:00
jdegenstein
bd12503e81 Additional info about build123d compat and more links 2023-01-23 11:29:18 -06:00
jdegenstein
2ba23c4659 build123d compat 2023-01-09 12:22:14 -06:00
jdegenstein
ee6a60705c remove debugging print 2023-01-09 12:18:23 -06:00
jdegenstein
a144b2e60a build123d compatibility improvements for file exporting
Removes the need to use .wrapped for the CQ-editor file exporter to work correctly. Also ran file through black formatter.
2023-01-09 12:16:49 -06:00
jdegenstein
7b49f25f94 Revert ubuntu-1804 changes to test ubuntu-2004 2022-11-03 13:57:23 -05:00
jdegenstein
2b3620b759 max verbosity 2022-11-01 21:14:08 -05:00
jdegenstein
afa20cd715 increase pip verbosity for cadquery and casadi install 2022-11-01 20:56:21 -05:00
jdegenstein
2d7fbeb08d changes for ubuntu1804
from:
casadi==3.5.5
to:
casadi
2022-11-01 20:46:50 -05:00
jdegenstein
ecaf68edac changes for ubuntu-1804
change from:
sudo apt install -y libblas-dev libblas3 libblas64-3 libblas64-dev
to:
sudo apt install -y libblas-dev libblas3
2022-11-01 20:42:57 -05:00
jdegenstein
69d6bc368e testing ubuntu-18.04 2022-11-01 20:39:09 -05:00
jdegenstein
dbc90c2724 register rand_color for use in console 2022-10-28 23:36:26 -05:00
jdegenstein
fbbb1fd7b6 Update debugger.py 2022-10-28 23:33:57 -05:00
jdegenstein
73a5825f3f add rand_color 2022-10-28 22:02:32 -05:00
jdegenstein
fefb57c2b9 remove rand_color 2022-10-28 21:59:28 -05:00
jdegenstein
5e0d68e2ad remove rand_color 2022-10-28 21:58:20 -05:00
jdegenstein
7c8fa2b100 from .widgets.object_tree import ObjectTree, rand_color 2022-10-28 21:02:07 -05:00
jdegenstein
925aded53c add rand_color() helper function
and seed(371353) global
2022-10-28 20:05:51 -05:00
jdegenstein
973448697a move to ubuntu-22.04 from ubuntu-latest (20.04)
trying to get libstdc++.so.6.30 instead of ...28
2022-10-28 15:34:40 -05:00
jdegenstein
c5e0d73422 fix list(tuple) 2022-10-28 12:05:18 -05:00
jdegenstein
a7a376f9f5 point to pyinstaller_pip.spec on Linux/MacOS 2022-10-28 11:59:52 -05:00
jdegenstein
e436bd3d7e Re-enable Linux/MacOS on -PIP-TAR.yaml
try and emulate Windows installation process, wherever possible
2022-10-28 11:52:16 -05:00
jdegenstein
26b64607a5 hookspath=['pyinstaller/extrahooks/']to _pip.spec 2022-10-28 11:28:22 -05:00
jdegenstein
000fe986e0 Delete dup hook-casadi.py 2022-10-28 11:24:30 -05:00
jdegenstein
acf5639e76 create subdir and add hook-casasi.py to it
create subdir and add hook-casasi.py to it
2022-10-28 11:24:12 -05:00
jdegenstein
ebcb831ca9 Update pyinstaller_pip.spec
add hook-casadi.py
2022-10-28 10:23:58 -05:00
jdegenstein
fd47eadcdc Create hook-casadi.py
per discussion https://github.com/pyinstaller/pyinstaller/discussions/7199
2022-10-28 10:22:11 -05:00
jdegenstein
67fa19704e Update pyinstaller-builds-actions-PIP-TAR.yml
change from:
pip install --pre cadquery casadi==3.5.5
to:
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
2022-10-28 10:18:01 -05:00
jdegenstein
272bede28f Update pyinstaller-builds-actions-PIP-TAR.yml
Remove: 
        pip install pipwin
        pipwin install numpy
Will probably break everything because we may need MKL-enabled numpy.
2022-10-28 08:56:08 -05:00
jdegenstein
9f4fa50c7c Update pyinstaller-builds-actions-PIP-TAR.yml
pip list
tree $PWD /F
2022-10-27 20:31:31 -05:00
jdegenstein
03e8575210 Update README.md
add pip install directions
2022-10-27 20:17:35 -05:00
jdegenstein
0087803ee4 Update pyinstaller-builds-actions-PIP-TAR.yml
unpin ipopt==3.4.10
2022-10-27 19:45:28 -05:00
jdegenstein
72e814db3b Update pyinstaller_pip.spec 2022-10-27 19:34:34 -05:00
jdegenstein
466d1e7534 Update pyinstaller-builds-actions-PIP-TAR.yml
pin ipopt==3.4.10 casadi==3.5.5
2022-10-27 19:33:50 -05:00
jdegenstein
3f3e22c2f1 Update pyinstaller_pip.spec
remove (occt_dir, 'opencascade') from _pip.spec
2022-10-27 16:51:32 -05:00
jdegenstein
aa90e48968 Create pyinstaller_pip.spec 2022-10-27 16:40:50 -05:00
jdegenstein
0e29e3091b Update pyinstaller-builds-actions-PIP-TAR.yml
point to new spec file
2022-10-27 16:37:33 -05:00
jdegenstein
66e620a877 Update pyinstaller-builds-actions-PIP-TAR.yml
change from:
pip install git+https://github.com/cadquery/cadquery
to:
pip install --pre cadquery

hopefully will resolve cadquery-ocp
2022-10-27 16:26:56 -05:00
jdegenstein
14535ec7a4 Create pyinstaller-builds-actions-PIP-TAR.yml
trying to use as few conda/mamba steps as possible
2022-10-27 16:14:02 -05:00
jdegenstein
ee09398909 Update viewer.py to bring up to date with Mainline a2df6ff 2022-10-27 14:52:00 -05:00
jdegenstein
10a81d4e12 Update cq_utils.py to bring up to date with Mainline a2df6ff 2022-10-27 14:50:32 -05:00
jdegenstein
ca706045ba Update test_app.py to bring up to date with Mainline a2df6ff 2022-10-27 14:46:05 -05:00
jdegenstein
ce68e6e120 Update setup.py
add "pyqtgraph==0.12.4"
2022-10-27 13:30:47 -05:00
jdegenstein
839d514f66 add missing libraries to spec file
casadi_nlpsol_ipopt.dll
ipopt-3.dll
libblas.dll
liblapack.dll
dmumps.dll
flang.dll
flangrti.dll
libomp.dll
mkl*.dll (a few dozen DLLs)
2022-10-27 10:12:10 -05:00
jdegenstein
36f2896652 Fix casadi*.dll path 2022-10-26 13:10:40 -05:00
jdegenstein
36f23a4d7e change casadi...dll path in mmamba-TAR.yml 2022-10-26 12:55:46 -05:00
jdegenstein
c85c8358f5 Update mmamba-TAR.yml to include casadi_nlpsol_ipopt.dll
using Copy-Item after PyInstaller has run
2022-10-26 12:33:24 -05:00
jdegenstein
de73e88033 Remove casadi DLLs from pyinstaller.spec
remove cas_DLLs from binaries and datas
2022-10-26 12:29:24 -05:00
jdegenstein
be62509ba7 Update pyinstaller-builds-actions-mmamba-TAR.yml
install casadi and ipopt
2022-10-26 10:49:29 -05:00
jdegenstein
b0284ac80c Add ipopt and casadi to hidden imports in spec 2022-10-26 10:27:15 -05:00
jdegenstein
2d7cb64247 Update pyinstaller.spec
attempt to add cas_DLLs to datas (in addition to binaries earlier)
2022-10-25 21:41:28 -05:00
jdegenstein
5b474bb493 Update pyinstaller.spec
try to only add casadi DLLs
2022-10-25 21:17:11 -05:00
jdegenstein
0818537f34 Update pyinstaller-builds-actions-mmamba-TAR.yml
re-enable tar(tifact)
2022-10-25 21:07:35 -05:00
jdegenstein
cf7253ebe7 Update pyinstaller.spec
add casadi DLL directory
2022-10-25 20:57:27 -05:00
jdegenstein
4a6e9a1cc3 Update pyinstaller.spec
add casadi to datas
2022-10-25 19:45:18 -05:00
jdegenstein
22c3d3a37b Update pyinstaller-builds-actions-mmamba-TAR.yml 2022-10-25 16:42:33 -05:00
jdegenstein
dfb79aa306 Update pyinstaller.spec
add a comma
2022-10-25 16:41:51 -05:00
jdegenstein
3ac6e93a5e Update pyinstaller.spec to include casadi 2022-10-25 16:13:25 -05:00
jdegenstein
621e0dc86b Update pyinstaller.spec
str to list
2022-10-25 15:56:38 -05:00
jdegenstein
3764233ed7 Update pyinstaller-builds-actions-mmamba-TAR.yml
use windows only, disabled TAR
2022-10-25 15:33:08 -05:00
jdegenstein
6e26bdb7fc Testing add casadi DLLs to pyinstaller.spec 2022-10-25 15:31:03 -05:00
jdegenstein
5fd737ab50 pin jedi==0.17.2 in setup.py 2022-10-20 22:41:26 -05:00
jdegenstein
cfb952047f fix pin 2022-10-20 22:18:58 -05:00
jdegenstein
974fd51f88 Merge pull request #2 from jdegenstein/dev
Dev to Main
2022-10-21 03:13:34 +00:00
jdegenstein
6bd2148257 Pin ipython=8.4.0 version to setup.py 2022-10-20 22:11:29 -05:00
jdegenstein
39bb40289f Update setup.py for pip install per u/sethfischer
from a PR on mainline
2022-10-20 22:00:48 -05:00
jdegenstein
02453f7823 Link to projects, remove wrong install, link to build actions 2022-10-17 15:23:48 -05:00
14 changed files with 934 additions and 589 deletions

View File

@@ -0,0 +1,126 @@
name: build-PIP-TAR
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-20.04
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
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
pip install -vvv --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
pip install 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
pip list
- name: Run build
shell: bash --login {0}
run: |
micromamba info
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/
- uses: alehechka/upload-tartifact@v1
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
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
pip install pyinstaller==4.10
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
pip list
- name: Run build
shell: bash --login {0}
run: |
micromamba info
pyinstaller pyinstaller_pip.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: alehechka/upload-tartifact@v1
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: pip install cadquery CQ-editor ... etc
shell: powershell
run: |
micromamba info
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
pip install --pre git+https://github.com/cadquery/cadquery casadi==3.5.5
pip install 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
pip list
- name: Run build
shell: powershell
run: |
micromamba info
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\
- uses: alehechka/upload-tartifact@v1
with:
name: CQ-editor-Windows
path: dist

View File

@@ -1,4 +1,4 @@
name: build-micromamba-TAR
name: build-micromamba-DEV
on:
schedule:
- cron: '0 0 * * 1'
@@ -31,20 +31,19 @@ jobs:
# 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
# micromamba 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
# 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/
# rm /home/runner/work/jmwright-CQ-Editor/jmwright-CQ-Editor/dist/CQ-editor/libstdc++.so.6
# - uses: actions/upload-tartifact@main
# - uses: actions/upload-artifact@v2
# with:
# name: CQ-editor-Linux-x86_64
# path: dist
@@ -66,7 +65,6 @@ jobs:
# 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
# micromamba uninstall --force -y importlib_resources
# pip install path
# pip uninstall -y PyQt5
# pip install PyQt5==5.15.7
@@ -75,13 +73,14 @@ jobs:
# 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-tartifact@main
# - uses: actions/upload-artifact@v2
# with:
# name: CQ-editor-MacOS
# path: dist
@@ -101,7 +100,7 @@ jobs:
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
micromamba install -c conda-forge pyinstaller=4.10 casadi ipopt
pip install path
pip install pipwin
pipwin install numpy
@@ -109,17 +108,15 @@ jobs:
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
#- uses: alehechka/download-tartifact@v1
# with:
# name: CQ-editor-Windows
# path: dist

View File

@@ -1,10 +1,11 @@
# CadQuery editor
This is a fork of jmwright's fork of 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, cq_cache, cq_warehouse, and 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.
![image](https://user-images.githubusercontent.com/16868537/191054760-a2cac297-3488-48d4-b9f6-52747dffcce3.png)
[![Build status](https://ci.appveyor.com/api/projects/status/g98rs7la393mgy91/branch/master?svg=true)](https://ci.appveyor.com/project/adam-urbanczyk/cq-editor/branch/master)
[![codecov](https://codecov.io/gh/CadQuery/CQ-editor/branch/master/graph/badge.svg)](https://codecov.io/gh/CadQuery/CQ-editor)
[![Build Status](https://dev.azure.com/cadquery/CQ-editor/_apis/build/status/CadQuery.CQ-editor?branchName=master)](https://dev.azure.com/cadquery/CQ-editor/_build/latest?definitionId=3&branchName=master)
@@ -32,34 +33,17 @@ CadQuery GUI editor based on PyQT supports Linux, Windows and Mac.
### Release Packages
Stable release builds which do not require Anaconda are attached to the [latest release](https://github.com/CadQuery/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. 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 builds are also available, but can be unstable and should be used at your own risk. Click on the newest build with a green checkmark [here](https://github.com/jmwright/CQ-editor/actions?query=workflow%3Abuild), wait for the _Artifacts_ section at the bottom of the page to load, and then click on the appropriate download for your operating system. Extract the archive file and run the shell (Linux/MacOS) or cmd (Windows) script in the root CQ-editor directory. The CQ-editor window should launch.
Development builds are also available, but can be unstable and should be used at your own risk. Click on the newest build with a green checkmark [here](https://github.com/jdegenstein/jmwright-CQ-editor/actions), wait for the _Artifacts_ section at the bottom of the page to load, and then click on the appropriate download for your operating system. Extract the archive file and run the shell (Linux/MacOS) or cmd (Windows) script in the root CQ-editor directory. The CQ-editor window should launch.
## Installation (Anaconda)
## Installation (pip)
Use conda to install:
```
conda install -c cadquery -c conda-forge cq-editor=master
```
and then simply type `cq-editor` to run it. This installs the latest version built directly from the HEAD of this repository.
Alternatively clone this git repository and set up the following conda environment:
```
conda env create -f cqgui_env.yml -n cqgui
conda activate cqgui
python run.py
```
On some linux distributions (e.g. `Ubuntu 18.04`) it might be necessary to install additonal packages:
```
sudo apt install libglu1-mesa libgl1-mesa-dri mesa-common-dev libglu1-mesa-dev
```
On Fedora 29 the packages can be installed as follows:
```
dnf install -y mesa-libGLU mesa-libGL mesa-libGLU-devel
pip install git+https://github.com/jdegenstein/jmwright-CQ-Editor
pip install --pre git+https://github.com/cadquery/cadquery
```
## Usage

View File

@@ -8,54 +8,100 @@ from types import SimpleNamespace
from OCP.XCAFPrs import XCAFPrs_AISObject
from OCP.TopoDS import TopoDS_Shape
from OCP.AIS import AIS_InteractiveObject, AIS_Shape
from OCP.Quantity import \
Quantity_TOC_RGB as TOC_RGB, Quantity_Color
from OCP.Quantity import (
Quantity_TOC_RGB as TOC_RGB,
Quantity_Color,
Quantity_NOC_GOLD as GOLD,
)
from OCP.Graphic3d import Graphic3d_NOM_JADE, Graphic3d_MaterialAspect
from PyQt5.QtGui import QColor
def find_cq_objects(results : dict):
DEFAULT_FACE_COLOR = Quantity_Color(GOLD)
DEFAULT_MATERIAL = Graphic3d_MaterialAspect(Graphic3d_NOM_JADE)
return {k:SimpleNamespace(shape=v,options={}) for k,v in results.items() if isinstance(v,cq.Workplane)}
def to_compound(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Shape], cq.Sketch]):
def find_cq_objects(results: dict):
return {
k: SimpleNamespace(shape=v, options={})
for k, v in results.items()
if isinstance(v, cq.Workplane)
}
def to_compound(
obj: Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Shape], cq.Sketch]
):
vals = []
if isinstance(obj,cq.Workplane):
if isinstance(obj, cq.Workplane):
vals.extend(obj.vals())
elif isinstance(obj,cq.Shape):
elif isinstance(obj, cq.Shape):
vals.append(obj)
elif isinstance(obj,list) and isinstance(obj[0],cq.Workplane):
for o in obj: vals.extend(o.vals())
elif isinstance(obj,list) and isinstance(obj[0],cq.Shape):
elif isinstance(obj, list) and isinstance(obj[0], cq.Workplane):
for o in obj:
vals.extend(o.vals())
elif isinstance(obj, list) and isinstance(obj[0], cq.Shape):
vals.extend(obj)
elif isinstance(obj, TopoDS_Shape):
vals.append(cq.Shape.cast(obj))
elif isinstance(obj,list) and isinstance(obj[0],TopoDS_Shape):
elif isinstance(obj, list) and isinstance(obj[0], TopoDS_Shape):
vals.extend(cq.Shape.cast(o) for o in obj)
elif hasattr(obj, "wrapped") and isinstance(obj.wrapped, TopoDS_Shape):
vals.append(cq.Shape.cast(obj.wrapped))
elif hasattr(obj, "_obj") and hasattr(obj._obj, "wrapped") and isinstance(obj._obj.wrapped, TopoDS_Shape):
elif (
isinstance(obj, list)
and hasattr(obj[0], "wrapped")
and isinstance(obj[0].wrapped, TopoDS_Shape)
):
vals.extend(o for o in obj)
elif (
hasattr(obj, "_obj")
and hasattr(obj._obj, "wrapped")
and isinstance(obj._obj.wrapped, TopoDS_Shape)
):
vals.append(cq.Shape.cast(obj._obj.wrapped))
elif (
isinstance(obj, list)
and hasattr(obj[0], "_obj")
and hasattr(obj[0]._obj, "wrapped")
and isinstance(obj[0]._obj.wrapped, TopoDS_Shape)
):
vals.append(o for o in obj)
elif isinstance(obj, cq.Sketch):
if obj._faces:
vals.append(obj._faces)
else:
vals.extend(obj._edges)
else:
raise ValueError(f'Invalid type {type(obj)}')
raise ValueError(f"Invalid type {type(obj)}")
return cq.Compound.makeCompound(vals)
def to_workplane(obj : cq.Shape):
rv = cq.Workplane('XY')
rv.objects = [obj,]
def to_workplane(obj: cq.Shape):
rv = cq.Workplane("XY")
rv.objects = [
obj,
]
return rv
def make_AIS(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Shape], cq.Assembly, AIS_InteractiveObject],
options={}):
def make_AIS(
obj: Union[
cq.Workplane,
List[cq.Workplane],
cq.Shape,
List[cq.Shape],
cq.Assembly,
AIS_InteractiveObject,
],
options={},
):
shape = None
@@ -68,29 +114,35 @@ def make_AIS(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Sha
shape = to_compound(obj)
ais = AIS_Shape(shape.wrapped)
if 'alpha' in options:
ais.SetTransparency(options['alpha'])
if 'color' in options:
ais.SetColor(to_occ_color(options['color']))
if 'rgba' in options:
r,g,b,a = options['rgba']
ais.SetColor(to_occ_color((r,g,b)))
ais.SetTransparency(a)
set_material(ais, DEFAULT_MATERIAL)
set_color(ais, DEFAULT_FACE_COLOR)
return ais,shape
if "alpha" in options:
set_transparency(ais, options["alpha"])
if "color" in options:
set_color(ais, to_occ_color(options["color"]))
if "rgba" in options:
r, g, b, a = options["rgba"]
set_color(ais, to_occ_color((r, g, b)))
set_transparency(ais, a)
def export(obj : Union[cq.Workplane, List[cq.Workplane]], type : str,
file, precision=1e-1):
return ais, shape
def export(
obj: Union[cq.Workplane, List[cq.Workplane]], type: str, file, precision=1e-1
):
comp = to_compound(obj)
if type == 'stl':
if type == "stl":
comp.exportStl(file, tolerance=precision)
elif type == 'step':
elif type == "step":
comp.exportStep(file)
elif type == 'brep':
elif type == "brep":
comp.exportBrep(file)
def to_occ_color(color) -> Quantity_Color:
if not isinstance(color, QColor):
@@ -100,16 +152,14 @@ def to_occ_color(color) -> Quantity_Color:
elif isinstance(color[0], float):
color = QColor.fromRgbF(*color)
else:
raise ValueError('Unknown color format')
raise ValueError("Unknown color format")
else:
color = QColor(color)
return Quantity_Color(color.redF(),
color.greenF(),
color.blueF(),
TOC_RGB)
return Quantity_Color(color.redF(), color.greenF(), color.blueF(), TOC_RGB)
def get_occ_color(obj : Union[AIS_InteractiveObject, Quantity_Color]) -> QColor:
def get_occ_color(obj: Union[AIS_InteractiveObject, Quantity_Color]) -> QColor:
if isinstance(obj, AIS_InteractiveObject):
color = Quantity_Color()
@@ -119,13 +169,34 @@ def get_occ_color(obj : Union[AIS_InteractiveObject, Quantity_Color]) -> QColor:
return QColor.fromRgbF(color.Red(), color.Green(), color.Blue())
def set_color(ais : AIS_Shape, color : Quantity_Color) -> AIS_Shape:
def set_color(ais: AIS_Shape, color: Quantity_Color) -> AIS_Shape:
drawer = ais.Attributes()
drawer.SetupOwnShadingAspect()
drawer.ShadingAspect().SetColor(color)
return ais
def set_material(ais: AIS_Shape, material: Graphic3d_MaterialAspect) -> AIS_Shape:
drawer = ais.Attributes()
drawer.SetupOwnShadingAspect()
drawer.ShadingAspect().SetMaterial(material)
return ais
def set_transparency(ais: AIS_Shape, alpha: float) -> AIS_Shape:
drawer = ais.Attributes()
drawer.SetupOwnShadingAspect()
drawer.ShadingAspect().SetTransparency(alpha)
return ais
def reload_cq():
# NB: order of reloads is important
@@ -146,13 +217,13 @@ def reload_cq():
reload(cq.occ_impl.exporters.dxf)
reload(cq.occ_impl.exporters.amf)
reload(cq.occ_impl.exporters.json)
#reload(cq.occ_impl.exporters.assembly)
# reload(cq.occ_impl.exporters.assembly)
reload(cq.occ_impl.exporters)
reload(cq.assembly)
reload(cq)
def is_obj_empty(obj : Union[cq.Workplane,cq.Shape]) -> bool:
def is_obj_empty(obj: Union[cq.Workplane, cq.Shape]) -> bool:
rv = False

View File

@@ -299,6 +299,7 @@ class MainWindow(QMainWindow,MainMixin):
#CQ related items
console.push_vars({'show' : obj_tree.addObject,
'show_object' : obj_tree.addObject,
'rand_color' : self.components['debugger']._rand_color,
'cq' : cq,
'log' : Logger(self.name).info})

View File

@@ -13,6 +13,7 @@ from logbook import info
from path import Path
from pyqtgraph.parametertree import Parameter
from spyder.utils.icon_manager import icon
from random import randrange as rrr, seed
from ..cq_utils import find_cq_objects, reload_cq
from ..mixins import ComponentMixin
@@ -192,6 +193,25 @@ class Debugger(QObject,ComponentMixin):
exec(code, locals_dict, globals_dict)
def _rand_color(self, alpha = 0., cfloat=False):
#helper function to generate a random color dict
#for CQ-editor's show_object function
lower = 10
upper = 100 #not too high to keep color brightness in check
if cfloat: #for two output types depending on need
return (
(rrr(lower,upper)/255),
(rrr(lower,upper)/255),
(rrr(lower,upper)/255),
alpha,
)
return {"alpha": alpha,
"color": (
rrr(lower,upper),
rrr(lower,upper),
rrr(lower,upper),
)}
def _inject_locals(self,module):
cq_objects = {}
@@ -209,6 +229,7 @@ class Debugger(QObject,ComponentMixin):
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
@@ -220,7 +241,7 @@ class Debugger(QObject,ComponentMixin):
@pyqtSlot(bool)
def render(self):
seed(371353) #reset the seed every time render is called (preserves colors run to run)
if self.preferences['Reload CQ']:
reload_cq()

View File

@@ -1,6 +1,5 @@
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAction, QMenu, QWidget, QAbstractItemView
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
from pyqtgraph.parametertree import Parameter, ParameterTree
from OCP.AIS import AIS_Line
@@ -390,6 +389,3 @@ class ObjectTree(QWidget,ComponentMixin):
item.properties['Visible'] = True
else:
item.properties['Visible'] = False

View File

@@ -95,8 +95,8 @@ class OCCTWidget(QWidget):
self.old_pos.y() - y, theToStart=True)
elif event.buttons() == Qt.RightButton:
self.view.ZoomAtPoint(self.old_pos.x(), y,
x, self.old_pos.y())
self.view.Pan(x - self.old_pos.x(),
self.old_pos.y() - y, theToStart=True)
self.old_pos = pos

View File

@@ -7,21 +7,21 @@ from OCP.Graphic3d import Graphic3d_Camera, Graphic3d_StereoMode, Graphic3d_NOM_
Graphic3d_MaterialAspect
from OCP.AIS import AIS_Shaded,AIS_WireFrame, AIS_ColoredShape, AIS_Axis
from OCP.Aspect import Aspect_GDM_Lines, Aspect_GT_Rectangular
from OCP.Quantity import Quantity_NOC_BLACK as BLACK, Quantity_NOC_GOLD as GOLD,\
Quantity_TOC_RGB as TOC_RGB, Quantity_Color
from OCP.Quantity import Quantity_NOC_BLACK as BLACK, Quantity_TOC_RGB as TOC_RGB,\
Quantity_Color
from OCP.Geom import Geom_Axis1Placement
from OCP.gp import gp_Ax3, gp_Dir, gp_Pnt, gp_Ax1
from ..utils import layout, get_save_filename
from ..mixins import ComponentMixin
from ..icons import icon
from ..cq_utils import to_occ_color, make_AIS
from ..cq_utils import to_occ_color, make_AIS, DEFAULT_FACE_COLOR
from .occt_widget import OCCTWidget
from pyqtgraph.parametertree import Parameter
import qtawesome as qta
DEFAULT_FACE_COLOR = Quantity_Color(GOLD)
DEFAULT_EDGE_COLOR = Quantity_Color(BLACK)
DEFAULT_EDGE_WIDTH = 2

View File

@@ -19,14 +19,25 @@ elif sys.platform == 'darwin':
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'), '.')
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] + binaries1,
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'),
@@ -35,10 +46,11 @@ a = Analysis(['run.py'],
hiddenimports=['ipykernel.datapub', 'debugpy', 'vtkmodules', 'vtkmodules.all',
'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5',
'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5',
'pyqtgraph.imageview.ImageViewTemplate_pyqt5', 'xmlrpc',
'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,
'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'],

View File

@@ -0,0 +1,9 @@
# hook-casadi.py
from PyInstaller.utils.hooks import collect_dynamic_libs
binaries = collect_dynamic_libs('casadi')
# Something about legacy import codepaths in casadi.casadi causes PyInstaller's analysis to pick up
# casadi._casadi as a top-level _casadi module, which is wrong.
hiddenimports = ['casadi._casadi']
excludedimports = ['_casadi']

86
pyinstaller_pip.spec Normal file
View File

@@ -0,0 +1,86 @@
# -*- 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'), '.')]
datas1, binaries1, hiddenimports1 = collect_all('debugpy')
hiddenimports2 = collect_submodules('xmlrpc')
a = Analysis(['run.py'],
pathex=['.'],
binaries=ocp_path + binaries1,
datas=[(spyder_data, 'spyder'),
(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',
'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=['pyinstaller/extrahooks/'],
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')

View File

@@ -16,12 +16,25 @@ def get_version(rel_path):
else:
raise RuntimeError("Unable to find version string.")
setup(name='CQ-editor',
version=get_version('cq_editor/_version.py'),
packages=find_packages(),
entry_points={
'gui_scripts': [
'cq-editor = cq_editor.__main__:main',
'CQ-editor = cq_editor.__main__:main'
]}
)
setup(
name="CQ-editor",
version=get_version("cq_editor/_version.py"),
packages=find_packages(),
entry_points={
"gui_scripts": [
"cq-editor = cq_editor.__main__:main",
"CQ-editor = cq_editor.__main__:main",
]
},
python_requires=">=3.8,<3.11",
install_requires=[
"logbook>=1",
"ipython==8.4.0",
"jedi==0.17.2",
"path>=16",
"PyQt5>=5",
"requests>=2,<3",
"spyder>=5,<6",
"pyqtgraph==0.12.4",
],
)

View File

@@ -1093,6 +1093,36 @@ def test_render_colors_console(main_clean):
qtbot.wait(100)
assert('Unknown color format' in log.toPlainText().splitlines()[-1])
code_shading = \
'''
import cadquery as cq
res1 = cq.Workplane('XY').box(5, 7, 5)
res2 = cq.Workplane('XY').box(8, 5, 4)
show_object(res1)
show_object(res2,options={"alpha":0})
'''
def test_shading_aspect(main_clean):
qtbot, win = main_clean
obj_tree = win.components['object_tree']
editor = win.components['editor']
debugger = win.components['debugger']
editor.set_text(code_shading)
debugger._actions['Run'][0].triggered.emit()
CQ = obj_tree.CQ
# get material aspects
ma1 = CQ.child(0).ais.Attributes().ShadingAspect().Material()
ma2 = CQ.child(1).ais.Attributes().ShadingAspect().Material()
# verify that they are the same
assert ma1.Shininess() == ma2.Shininess()
def test_confirm_new(monkeypatch,editor):
qtbot, editor = editor
@@ -1433,4 +1463,3 @@ def test_modulefinder(tmp_path, main):
qtbot.wait(100)
assert("Cannot determine imported modules" in log.toPlainText().splitlines()[-1])