cad-widgets 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. cad_widgets-0.1.0/.github/workflows/build-publish.yml +75 -0
  2. cad_widgets-0.1.0/.gitignore +52 -0
  3. cad_widgets-0.1.0/.python-version +1 -0
  4. cad_widgets-0.1.0/PKG-INFO +229 -0
  5. cad_widgets-0.1.0/README.md +209 -0
  6. cad_widgets-0.1.0/docs/ARCHITECTURE.md +1204 -0
  7. cad_widgets-0.1.0/examples/example_modular.py +535 -0
  8. cad_widgets-0.1.0/pyproject.toml +76 -0
  9. cad_widgets-0.1.0/src/cad_widgets/__init__.py +27 -0
  10. cad_widgets-0.1.0/src/cad_widgets/enums.py +54 -0
  11. cad_widgets-0.1.0/src/cad_widgets/managers/__init__.py +7 -0
  12. cad_widgets-0.1.0/src/cad_widgets/managers/geometry_manager.py +520 -0
  13. cad_widgets-0.1.0/src/cad_widgets/models/__init__.py +17 -0
  14. cad_widgets-0.1.0/src/cad_widgets/models/shape_properties.py +283 -0
  15. cad_widgets-0.1.0/src/cad_widgets/py.typed +2 -0
  16. cad_widgets-0.1.0/src/cad_widgets/services/__init__.py +8 -0
  17. cad_widgets-0.1.0/src/cad_widgets/services/geometry_service.py +410 -0
  18. cad_widgets-0.1.0/src/cad_widgets/services/selection_service.py +194 -0
  19. cad_widgets-0.1.0/src/cad_widgets/services/view_service.py +523 -0
  20. cad_widgets-0.1.0/src/cad_widgets/widgets/__init__.py +10 -0
  21. cad_widgets-0.1.0/src/cad_widgets/widgets/geometry_tree.py +401 -0
  22. cad_widgets-0.1.0/src/cad_widgets/widgets/ocp_widget.py +553 -0
  23. cad_widgets-0.1.0/src/cad_widgets/widgets/property_editor.py +335 -0
  24. cad_widgets-0.1.0/src/cad_widgets/widgets/selection_toolbar.py +116 -0
  25. cad_widgets-0.1.0/src/cad_widgets/widgets/view_toolbar.py +313 -0
  26. cad_widgets-0.1.0/tasks.py +59 -0
  27. cad_widgets-0.1.0/tests/__init__.py +5 -0
  28. cad_widgets-0.1.0/tests/conftest.py +22 -0
  29. cad_widgets-0.1.0/tests/test_enums.py +141 -0
  30. cad_widgets-0.1.0/tests/test_geometry_manager.py +598 -0
  31. cad_widgets-0.1.0/tests/test_geometry_manager_integration.py +599 -0
  32. cad_widgets-0.1.0/tests/test_geometry_tree.py +133 -0
  33. cad_widgets-0.1.0/tests/test_import_export.py +199 -0
  34. cad_widgets-0.1.0/tests/test_integration.py +307 -0
  35. cad_widgets-0.1.0/tests/test_property_editor.py +368 -0
  36. cad_widgets-0.1.0/tests/test_shapes.py +102 -0
  37. cad_widgets-0.1.0/tests/test_toolbar.py +231 -0
  38. cad_widgets-0.1.0/tests/test_widget.py +482 -0
  39. cad_widgets-0.1.0/uv.lock +890 -0
@@ -0,0 +1,75 @@
1
+ name: Build and Publish
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ name: Build on ${{ matrix.os }}
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu-latest, windows-latest]
16
+ python-version: ['3.12']
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Set up Python ${{ matrix.python-version }}
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+
27
+ - name: Install build dependencies
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install build hatchling
31
+
32
+ - name: Build package
33
+ run: python -m build
34
+
35
+ - name: Upload build artifacts
36
+ uses: actions/upload-artifact@v4
37
+ with:
38
+ name: dist-${{ matrix.os }}-py${{ matrix.python-version }}
39
+ path: dist/*
40
+ retention-days: 7
41
+
42
+
43
+ publish:
44
+ name: Publish to PyPI
45
+ needs: [build]
46
+ runs-on: ubuntu-latest
47
+ environment:
48
+ name: pypi
49
+ url: https://pypi.org/p/cad-widgets
50
+ permissions:
51
+ contents: read # Required for actions/checkout
52
+ id-token: write # Required for trusted publishing
53
+
54
+ steps:
55
+ - name: Checkout code
56
+ uses: actions/checkout@v4
57
+
58
+ - name: Set up Python
59
+ uses: actions/setup-python@v5
60
+ with:
61
+ python-version: '3.12'
62
+
63
+ - name: Install build dependencies
64
+ run: |
65
+ python -m pip install --upgrade pip
66
+ pip install build hatchling
67
+
68
+ - name: Build package
69
+ run: python -m build
70
+
71
+ - name: Publish to PyPI
72
+ uses: pypa/gh-action-pypi-publish@release/v1
73
+ with:
74
+ skip-existing: true
75
+ verbose: true
@@ -0,0 +1,52 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # Virtual environments
28
+ venv/
29
+ env/
30
+ ENV/
31
+ .venv
32
+
33
+ # IDEs
34
+ .vscode/
35
+ .idea/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # OS
41
+ .DS_Store
42
+ Thumbs.db
43
+
44
+ # Pytest
45
+ .pytest_cache/
46
+
47
+ # Coverage
48
+ htmlcov/
49
+ .coverage
50
+ .coverage.*
51
+ coverage.xml
52
+ *.cover
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: cad-widgets
3
+ Version: 0.1.0
4
+ Summary: OpenCascade PySide6 3D CAD viewer widgets with modular architecture
5
+ Project-URL: Homepage, https://github.com/gcmartins/cad-widgets
6
+ Project-URL: Repository, https://github.com/gcmartins/cad-widgets
7
+ Author: CAD Widgets Contributors
8
+ Keywords: 3d,cad,opencascade,pyside6,viewer,widget
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.12
15
+ Requires-Dist: cadquery-ocp-stubs>=7.9.3.1
16
+ Requires-Dist: cadquery-ocp>=7.7.0
17
+ Requires-Dist: numpy>=1.24.0
18
+ Requires-Dist: pyside6>=6.6.0
19
+ Description-Content-Type: text/markdown
20
+
21
+ # CAD Widgets
22
+
23
+ A Python library for building 3D CAD viewers with PySide6 and OpenCascade (OCP). Features a clean, modular architecture with reusable components and signal-based communication.
24
+
25
+ ![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)
26
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
27
+
28
+ ## Features
29
+
30
+ - 🎨 **Modular Architecture** - Layered design with widgets, services, managers, and models
31
+ - 🖱️ **Smooth Interaction** - Flicker-free rotation, panning, and zooming
32
+ - 🎯 **Multiple View Modes** - Perspective/orthographic projections, standard views
33
+ - 🎨 **Display Modes** - Shaded, wireframe, or combination rendering
34
+ - 🌳 **Geometry Management** - Tree view with visibility controls and property editing
35
+ - ✂️ **Boolean Operations** - Union, subtraction, and intersection operations
36
+ - 🎯 **Advanced Selection** - Volume, surface, edge, and vertex selection modes
37
+ - 🔧 **Shape Creation** - Clean API for boxes, spheres, cylinders, cones, and tori
38
+ - 🧪 **Well Tested** - Comprehensive test suite with >90% coverage
39
+ - 📚 **Documented** - Extensive documentation and examples
40
+ - 🖥️ **Cross-Platform** - Works on Linux (X11), Windows, and macOS
41
+
42
+ ## Quick Start
43
+
44
+ ### Installation
45
+
46
+ ```bash
47
+ # Clone the repository
48
+ git clone <repository-url>
49
+ cd cad_widgets
50
+
51
+ # Install dependencies using uv (recommended)
52
+ uv sync
53
+ source .venv/bin/activate
54
+
55
+ # Or using pip
56
+ pip install -e .
57
+ ```
58
+
59
+ ### Simple Example
60
+
61
+ ```python
62
+ from PySide6.QtWidgets import QApplication
63
+ from cad_widgets import OCPWidget, GeometryService
64
+
65
+ app = QApplication([])
66
+
67
+ viewer = OCPWidget()
68
+ viewer.resize(800, 600)
69
+
70
+ geo = GeometryService()
71
+ box = geo.create_box(100, 100, 100)
72
+ viewer.display_shape(box, color=(0.8, 0.2, 0.2))
73
+ viewer.fit_all()
74
+
75
+ viewer.show()
76
+ app.exec()
77
+ ```
78
+
79
+ ### Running Examples
80
+
81
+ ```bash
82
+ # Full-featured modular example with all widgets
83
+ python examples/example_modular.py
84
+ ```
85
+
86
+ ## Project Structure
87
+
88
+ ```
89
+ cad_widgets/
90
+ ├── src/
91
+ │ └── cad_widgets/ # Main package
92
+ │ ├── __init__.py # Package exports
93
+ │ ├── enums.py # Enums for display and selection
94
+ │ ├── widgets/ # UI Widget components
95
+ │ │ ├── ocp_widget.py # Core 3D viewer
96
+ │ │ ├── view_toolbar.py # View controls toolbar
97
+ │ │ ├── selection_toolbar.py # Selection mode toolbar
98
+ │ │ ├── geometry_tree.py # Geometry tree view
99
+ │ │ └── property_editor.py # Property editor panel
100
+ │ ├── services/ # Service layer
101
+ │ │ ├── geometry_service.py # Shape creation/manipulation
102
+ │ │ ├── view_service.py # View and display management
103
+ │ │ └── selection_service.py # Selection handling
104
+ │ ├── managers/ # Business logic layer
105
+ │ │ └── geometry_manager.py # Geometry lifecycle management
106
+ │ └── models/ # Data models
107
+ │ └── shape_properties.py # Property classes
108
+ ├── examples/ # Example applications
109
+ │ └── example_modular.py # Full-featured example
110
+ ├── tests/ # Comprehensive test suite
111
+ ├── docs/ # Documentation
112
+ │ └── ARCHITECTURE.md # Architecture guide
113
+ └── pyproject.toml # Project configuration
114
+ ```
115
+
116
+ ## Architecture
117
+
118
+ CAD Widgets follows a clean, layered architecture with clear separation of concerns:
119
+
120
+ - **Widget Layer** - UI components (OCPWidget, toolbars, tree view, property editor)
121
+ - **Manager Layer** - High-level orchestration (GeometryManager)
122
+ - **Service Layer** - Business logic (GeometryService, ViewService, SelectionService)
123
+ - **Models Layer** - Data structures (ShapeProperties, Translation, Rotation)
124
+
125
+ Components communicate through Qt signals for loose coupling and reusability. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed architectural documentation including patterns, component details, and extension points.
126
+
127
+ ## Mouse Controls
128
+
129
+ - **Left Click + Drag**: Rotate view
130
+ - **Middle Click + Drag**: Pan view
131
+ - **Scroll Wheel**: Zoom in/out
132
+
133
+ ## API Reference
134
+
135
+ For a complete API reference including all widget methods, signals, service methods, and enums, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#api-reference).
136
+
137
+ ## Dependencies
138
+
139
+ - **PySide6** ≥ 6.6.0 - Qt for Python GUI framework
140
+ - **cadquery-ocp** ≥ 7.7.0 - OpenCascade Python bindings
141
+ - **numpy** ≥ 1.24.0 - Numerical operations
142
+
143
+ ## Development
144
+
145
+ ### Quick Start
146
+
147
+ ```bash
148
+ # Run tests
149
+ pytest tests/
150
+
151
+ # Run with coverage
152
+ pytest tests/ --cov=cad_widgets
153
+
154
+ # Type check
155
+ mypy src/cad_widgets
156
+
157
+ # Lint and format
158
+ ruff check src tests examples
159
+ ruff format src tests examples
160
+
161
+ # Run all checks
162
+ uv run invoke check
163
+ ```
164
+
165
+ For detailed development guidelines, testing strategies, and contributing instructions, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#testing).
166
+
167
+ ## Documentation
168
+
169
+ - **[Architecture Guide](docs/ARCHITECTURE.md)** - Detailed architecture documentation
170
+ - **Examples** - See `examples/` directory for complete applications
171
+
172
+ ## Troubleshooting
173
+
174
+ ### Qt DBus Warnings (Linux)
175
+
176
+ Suppress harmless DBus warnings:
177
+
178
+ ```bash
179
+ export QT_LOGGING_RULES='qt.qpa.theme.gnome=false'
180
+ python examples/example_modular.py
181
+ ```
182
+
183
+ Or in code:
184
+
185
+ ```python
186
+ import os
187
+ os.environ['QT_LOGGING_RULES'] = 'qt.qpa.theme.gnome=false'
188
+ ```
189
+
190
+ ### Import Errors
191
+
192
+ Ensure dependencies are installed:
193
+
194
+ ```bash
195
+ uv sync # or pip install -e .
196
+ ```
197
+
198
+ ### Display Issues
199
+
200
+ - Verify OpenGL support is available on your system
201
+ - Check console for error messages
202
+ - Try different Qt platform plugins if available
203
+
204
+ ## Contributing
205
+
206
+ Contributions are welcome! Please:
207
+
208
+ 1. Follow the existing architecture patterns
209
+ 2. Use signals for component communication
210
+ 3. Add tests for new features
211
+ 4. Update documentation
212
+ 5. Run `ruff check --fix` before committing
213
+
214
+ ## License
215
+
216
+ This project is provided as-is for educational and development purposes.
217
+
218
+ ## Resources
219
+
220
+ - [OCP Documentation](https://github.com/CadQuery/OCP)
221
+ - [PySide6 Documentation](https://doc.qt.io/qtforpython/)
222
+ - [OpenCascade Documentation](https://dev.opencascade.org/)
223
+
224
+ ## Acknowledgments
225
+
226
+ Built with:
227
+ - [OpenCascade](https://www.opencascade.com/) - 3D modeling kernel
228
+ - [PySide6](https://wiki.qt.io/Qt_for_Python) - Qt for Python
229
+ - [CadQuery OCP](https://github.com/CadQuery/OCP) - Python bindings for OpenCascade
@@ -0,0 +1,209 @@
1
+ # CAD Widgets
2
+
3
+ A Python library for building 3D CAD viewers with PySide6 and OpenCascade (OCP). Features a clean, modular architecture with reusable components and signal-based communication.
4
+
5
+ ![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)
6
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
7
+
8
+ ## Features
9
+
10
+ - 🎨 **Modular Architecture** - Layered design with widgets, services, managers, and models
11
+ - 🖱️ **Smooth Interaction** - Flicker-free rotation, panning, and zooming
12
+ - 🎯 **Multiple View Modes** - Perspective/orthographic projections, standard views
13
+ - 🎨 **Display Modes** - Shaded, wireframe, or combination rendering
14
+ - 🌳 **Geometry Management** - Tree view with visibility controls and property editing
15
+ - ✂️ **Boolean Operations** - Union, subtraction, and intersection operations
16
+ - 🎯 **Advanced Selection** - Volume, surface, edge, and vertex selection modes
17
+ - 🔧 **Shape Creation** - Clean API for boxes, spheres, cylinders, cones, and tori
18
+ - 🧪 **Well Tested** - Comprehensive test suite with >90% coverage
19
+ - 📚 **Documented** - Extensive documentation and examples
20
+ - 🖥️ **Cross-Platform** - Works on Linux (X11), Windows, and macOS
21
+
22
+ ## Quick Start
23
+
24
+ ### Installation
25
+
26
+ ```bash
27
+ # Clone the repository
28
+ git clone <repository-url>
29
+ cd cad_widgets
30
+
31
+ # Install dependencies using uv (recommended)
32
+ uv sync
33
+ source .venv/bin/activate
34
+
35
+ # Or using pip
36
+ pip install -e .
37
+ ```
38
+
39
+ ### Simple Example
40
+
41
+ ```python
42
+ from PySide6.QtWidgets import QApplication
43
+ from cad_widgets import OCPWidget, GeometryService
44
+
45
+ app = QApplication([])
46
+
47
+ viewer = OCPWidget()
48
+ viewer.resize(800, 600)
49
+
50
+ geo = GeometryService()
51
+ box = geo.create_box(100, 100, 100)
52
+ viewer.display_shape(box, color=(0.8, 0.2, 0.2))
53
+ viewer.fit_all()
54
+
55
+ viewer.show()
56
+ app.exec()
57
+ ```
58
+
59
+ ### Running Examples
60
+
61
+ ```bash
62
+ # Full-featured modular example with all widgets
63
+ python examples/example_modular.py
64
+ ```
65
+
66
+ ## Project Structure
67
+
68
+ ```
69
+ cad_widgets/
70
+ ├── src/
71
+ │ └── cad_widgets/ # Main package
72
+ │ ├── __init__.py # Package exports
73
+ │ ├── enums.py # Enums for display and selection
74
+ │ ├── widgets/ # UI Widget components
75
+ │ │ ├── ocp_widget.py # Core 3D viewer
76
+ │ │ ├── view_toolbar.py # View controls toolbar
77
+ │ │ ├── selection_toolbar.py # Selection mode toolbar
78
+ │ │ ├── geometry_tree.py # Geometry tree view
79
+ │ │ └── property_editor.py # Property editor panel
80
+ │ ├── services/ # Service layer
81
+ │ │ ├── geometry_service.py # Shape creation/manipulation
82
+ │ │ ├── view_service.py # View and display management
83
+ │ │ └── selection_service.py # Selection handling
84
+ │ ├── managers/ # Business logic layer
85
+ │ │ └── geometry_manager.py # Geometry lifecycle management
86
+ │ └── models/ # Data models
87
+ │ └── shape_properties.py # Property classes
88
+ ├── examples/ # Example applications
89
+ │ └── example_modular.py # Full-featured example
90
+ ├── tests/ # Comprehensive test suite
91
+ ├── docs/ # Documentation
92
+ │ └── ARCHITECTURE.md # Architecture guide
93
+ └── pyproject.toml # Project configuration
94
+ ```
95
+
96
+ ## Architecture
97
+
98
+ CAD Widgets follows a clean, layered architecture with clear separation of concerns:
99
+
100
+ - **Widget Layer** - UI components (OCPWidget, toolbars, tree view, property editor)
101
+ - **Manager Layer** - High-level orchestration (GeometryManager)
102
+ - **Service Layer** - Business logic (GeometryService, ViewService, SelectionService)
103
+ - **Models Layer** - Data structures (ShapeProperties, Translation, Rotation)
104
+
105
+ Components communicate through Qt signals for loose coupling and reusability. See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed architectural documentation including patterns, component details, and extension points.
106
+
107
+ ## Mouse Controls
108
+
109
+ - **Left Click + Drag**: Rotate view
110
+ - **Middle Click + Drag**: Pan view
111
+ - **Scroll Wheel**: Zoom in/out
112
+
113
+ ## API Reference
114
+
115
+ For a complete API reference including all widget methods, signals, service methods, and enums, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#api-reference).
116
+
117
+ ## Dependencies
118
+
119
+ - **PySide6** ≥ 6.6.0 - Qt for Python GUI framework
120
+ - **cadquery-ocp** ≥ 7.7.0 - OpenCascade Python bindings
121
+ - **numpy** ≥ 1.24.0 - Numerical operations
122
+
123
+ ## Development
124
+
125
+ ### Quick Start
126
+
127
+ ```bash
128
+ # Run tests
129
+ pytest tests/
130
+
131
+ # Run with coverage
132
+ pytest tests/ --cov=cad_widgets
133
+
134
+ # Type check
135
+ mypy src/cad_widgets
136
+
137
+ # Lint and format
138
+ ruff check src tests examples
139
+ ruff format src tests examples
140
+
141
+ # Run all checks
142
+ uv run invoke check
143
+ ```
144
+
145
+ For detailed development guidelines, testing strategies, and contributing instructions, see [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#testing).
146
+
147
+ ## Documentation
148
+
149
+ - **[Architecture Guide](docs/ARCHITECTURE.md)** - Detailed architecture documentation
150
+ - **Examples** - See `examples/` directory for complete applications
151
+
152
+ ## Troubleshooting
153
+
154
+ ### Qt DBus Warnings (Linux)
155
+
156
+ Suppress harmless DBus warnings:
157
+
158
+ ```bash
159
+ export QT_LOGGING_RULES='qt.qpa.theme.gnome=false'
160
+ python examples/example_modular.py
161
+ ```
162
+
163
+ Or in code:
164
+
165
+ ```python
166
+ import os
167
+ os.environ['QT_LOGGING_RULES'] = 'qt.qpa.theme.gnome=false'
168
+ ```
169
+
170
+ ### Import Errors
171
+
172
+ Ensure dependencies are installed:
173
+
174
+ ```bash
175
+ uv sync # or pip install -e .
176
+ ```
177
+
178
+ ### Display Issues
179
+
180
+ - Verify OpenGL support is available on your system
181
+ - Check console for error messages
182
+ - Try different Qt platform plugins if available
183
+
184
+ ## Contributing
185
+
186
+ Contributions are welcome! Please:
187
+
188
+ 1. Follow the existing architecture patterns
189
+ 2. Use signals for component communication
190
+ 3. Add tests for new features
191
+ 4. Update documentation
192
+ 5. Run `ruff check --fix` before committing
193
+
194
+ ## License
195
+
196
+ This project is provided as-is for educational and development purposes.
197
+
198
+ ## Resources
199
+
200
+ - [OCP Documentation](https://github.com/CadQuery/OCP)
201
+ - [PySide6 Documentation](https://doc.qt.io/qtforpython/)
202
+ - [OpenCascade Documentation](https://dev.opencascade.org/)
203
+
204
+ ## Acknowledgments
205
+
206
+ Built with:
207
+ - [OpenCascade](https://www.opencascade.com/) - 3D modeling kernel
208
+ - [PySide6](https://wiki.qt.io/Qt_for_Python) - Qt for Python
209
+ - [CadQuery OCP](https://github.com/CadQuery/OCP) - Python bindings for OpenCascade