Major changes: - Fixed right-click handler to directly set mode to NONE instead of relying on main app signal handling - Added safety checks in left-click handler to prevent drawing when no draggable point is found in NONE mode - Enhanced mode compatibility by treating Python None as SketchMode.NONE in set_mode() method - Added comprehensive debug logging for mode changes and interaction state tracking - Resolved integration issue where persistent constraint modes were prematurely reset by main app - Ensured point dragging is only enabled in NONE mode, preventing accidental polyline creation This fixes the reported issue where deactivating the line tool would still create lines when dragging, and ensures proper mode transitions between drawing tools and selection/drag mode.
5.1 KiB
5.1 KiB
WARP.md
This file provides guidance to WARP (warp.dev) when working with code in this repository.
Project Overview
Fluency is a CAD (Computer Aided Design) application built with Python/PySide6 that provides parametric 3D modeling through a timeline-based project system. The application combines 2D sketching with constraint solving, 3D visualization using VTK, and SDF (Signed Distance Function) based mesh generation.
Common Commands
Development Environment Setup
# Activate virtual environment (if exists)
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
Running the Application
# Run the main application
python main.py
# Run with debugging
python -u main.py
UI Development
# Convert Qt Designer UI file to Python code
pyside6-uic gui.ui > Gui.py -g python
Building Executable
The project uses Nuitka for compilation (configured in main.py header):
# Build standalone executable
nuitka --standalone --plugin-enable=pyside6 --plugin-enable=numpy --macos-create-app-bundle main.py
Testing
# Run mesh generation test
python meshtest.py
Architecture Overview
Core Components
Main Application (main.py)
- MainWindow: Central UI controller that manages all widgets and user interactions
- Project System: Hierarchical structure:
Project → Timeline → Component → Sketch/Body - Signal-based Communication: Qt signals coordinate between 2D sketching and 3D rendering
Project Hierarchy
Project
├── Timeline (list of Components)
└── Component
├── Sketches (dict)
├── Bodies (dict)
└── Connectors (for assembly)
Drawing Modules (drawing_modules/)
- SketchWidget (
draw_widget_solve.py): 2D parametric sketching with SolverSpace constraint solving - VTKWidget (
vtk_widget.py): 3D visualization and mesh interaction using VTK - PyVistaWidget (
vysta_widget.py): Alternative 3D rendering backend
Mesh Generation (mesh_modules/)
- VESTA (
vesta_mesh.py): Multi-threaded SDF-to-mesh conversion using marching cubes - Interactor Mesh (
interactor_mesh.py): Simplified edge-based meshes for 3D selection - Simple Mesh (
simple_mesh.py): Basic mesh utilities
Data Flow Architecture
2D to 3D Pipeline
- 2D Sketching: User draws in SketchWidget using Qt coordinate system
- Constraint Solving: SolverSpace resolves geometric constraints
- SDF Generation: Sketch converted to Signed Distance Functions for 3D operations
- Mesh Generation: VESTA generates triangle meshes from SDF using marching cubes
- 3D Rendering: VTK displays both solid meshes and interactive edges
Signal Flow (from doc/flow.md)
- 2D QPoint → cartesian space → SolverSpace dict → constraint solving → display
- 3D mesh selection → projection to 2D → sketch widget integration
Key Classes
Core Data Structures
- Sketch: 2D geometric data with origin, normal, points, and constraints
- Body: 3D mesh representation containing SDF objects and interactor meshes
- Component: Container grouping related sketches and bodies
- Interactor: Simplified edge-based mesh for 3D manipulation
Constraint Solving
The application uses python_solvespace for parametric constraint solving:
- Point-to-point constraints
- Distance constraints
- Horizontal/vertical line constraints
- Point-to-line constraints
Technology Stack
- GUI: PySide6 (Qt for Python)
- 3D Graphics: VTK for rendering, PyVista as alternative
- Constraint Solving: SolverSpace for parametric geometry
- Mesh Generation: SDF library with custom VESTA marching cubes implementation
- Scientific Computing: NumPy for mathematical operations
Development Workflow
Adding New Sketch Tools
- Add UI button in
gui.ui - Convert UI:
pyside6-uic gui.ui > Gui.py -g python - Connect signal in
MainWindow.__init__() - Implement tool logic in
SketchWidget
Adding New 3D Operations
- Extend operation buttons in the Modify group
- Implement operation logic using SDF functions
- Update Body creation and timeline management
- Handle interactor mesh generation for selection
Debugging Tips
- Monitor solver results through
SolverSystemstatus - Use VTK's built-in debugging for rendering issues
- Check coordinate transformations between 2D sketch and 3D space
- Verify SDF function outputs before mesh generation
File Structure
main.py: Application entry point and main windowGui.py: Auto-generated UI code (do not edit directly)gui.ui: Qt Designer UI definition filedrawing_modules/: 2D and 3D rendering widgetsmesh_modules/: Mesh generation and processingdoc/: Architecture and command documentation
Dependencies
Primary external libraries:
PySide6: Qt GUI frameworkvtk: 3D visualization toolkitpython-solvespace: Constraint solvingsdf: Signed Distance Function operationsnumpy: Numerical computationsscikit-image: Marching cubes algorithmnames: Random name generation for sketches