mattercontrol/research/design-only-fork.md
2026-01-28 14:06:53 -08:00

302 lines
9.9 KiB
Markdown

# Plan: Create Design-Only MatterControl Fork
**Goal:** Strip MatterControl down to a pure 3D design/modeling application, removing all printing, slicing, and cloud features.
## Feasibility Summary
| Feature Category | Removal Difficulty | Effort Estimate |
|------------------|-------------------|-----------------|
| **Cloud Features** | Easy | Low - 1-2 days |
| **Printing/Communication** | Moderate | Medium - 1-2 weeks |
| **Slicing (MatterSlice)** | Very Difficult | High - 3-4 weeks |
The codebase has **good architectural separation** for design vs printing, but slicing is deeply embedded. A "design-only" variant is feasible with moderate effort.
---
## Detailed Analysis
### 1. Cloud Features - EASY TO REMOVE
Cloud features use a **nullable delegate pattern** - already designed to be optional:
```csharp
// All cloud delegates are nullable (ApplicationController.cs)
public static Func<PrinterInfo, string, Task<PrinterSettings>> GetPrinterProfileAsync;
public static Func<string, Action<double,string>, Task> SyncCloudProfiles;
public static Func<bool> GuestUserActive;
public static Func<AuthenticationContext, DialogPage> GetAuthPage;
public static Func<bool> UserHasPro;
```
**To remove:** Simply don't register these delegates. Code already has null checks everywhere.
**Files to modify:** ~5-10 files to remove registration points
---
### 2. Printing/Communication - MODERATE EFFORT
**Good separation exists:**
- `DesignTabPage` (design-only) vs `PrinterTabPage` (printing)
- `PartWorkspace` supports `Printer == null` for design workspaces
- Design tools have ZERO printing dependencies
**Challenges:**
- `PrinterConfig` constructor always creates `PrinterConnection`
- 465+ printer-related null checks throughout codebase
- Print queue, temperature monitoring tightly coupled
**Approach:**
1. Remove `PrinterTabPage`, `PrinterActionsBar`, `SliceLayerSelector`
2. Remove `PrinterCommunication/` directory
3. Remove `MatterControl.Printing/` project
4. Modify `PrinterConfig` to be optional or remove entirely
5. Keep only `DesignTabPage` workspaces
**Files affected:** ~50-80 files
---
### 3. Slicing (MatterSlice) - VERY DIFFICULT
**Deep integration:**
- **248 files** reference slicing functionality
- **150+ settings** mapped in `EngineMappingsMatterSlice`
- `PrinterSettings.SliceEngines` assumed non-empty (crashes if empty)
- Settings validation checks `printer.Settings.Slicer.PrinterType`
**Critical coupling points:**
- Multi-extruder logic depends on slicer
- Support/raft/brim features depend on slicer
- G-code generation requires active slicer
- 30+ UI field types assume slicer presence
**If slicing removed, you also lose:**
- All print settings UI (no point without slicing)
- G-code preview/visualization
- Layer-by-layer analysis
- Print time estimation
---
## Architecture Overview
```
┌─────────────────────────────────────────────────┐
│ KEEP: Core Design Features │
├──────────────────────────────────────────────────┤
│ DesignTools/ - Primitives, booleans │
│ View3DWidget - 3D viewport │
│ Library/ - Content management │
│ DataStorage/ - SQLite persistence │
│ SettingsManagement/ - Basic settings │
│ agg-sharp/ - Rendering, UI, math │
└──────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│ REMOVE: Printing-Specific │
├──────────────────────────────────────────────────┤
│ PrinterCommunication/ - Serial I/O, drivers │
│ MatterControl.Printing/- G-code streams │
│ Queue/ - Print queue │
│ PrinterControls/ - Printer UI │
│ SlicerConfiguration/ - Slicer settings (150+) │
│ MatterSlice/ - Slicer engine │
│ PrinterTabPage - Printer workspace UI │
└──────────────────────────────────────────────────┘
```
---
## Recommended Approach
### Option A: Design-Only Fork (Recommended)
Create a stripped-down version keeping only design features:
1. **Remove projects:**
- `Submodules/MatterSlice/`
- `MatterControl.Printing/`
2. **Remove directories:**
- `MatterControlLib/PrinterCommunication/`
- `MatterControlLib/Queue/`
- `MatterControlLib/SlicerConfiguration/`
- `MatterControlLib/PrinterControls/`
- `MatterControlLib/ConfigurationPage/PrintLeveling/`
- `MatterControlLib/SetupWizard/`
3. **Modify:**
- Remove `PrinterTabPage` from `PartPreviewWindow/`
- Remove printer workspace creation from `ApplicationController`
- Remove printer-related settings from `SettingsManagement/`
- Update `MainViewWidget` to only create design tabs
4. **Keep intact:**
- `DesignTools/` - All parametric design
- `Library/` - Content management
- `View3DWidget` - 3D viewport
- `DataStorage/` - Persistence
- All `agg-sharp/` modules
**Estimated effort:** 2-3 weeks for clean separation
### Option B: Feature Flags (Alternative)
Add compile-time flags to conditionally include printing:
```csharp
#if PRINTING_ENABLED
// Printer-specific code
#endif
```
**Pros:** Maintains single codebase
**Cons:** More complex maintenance, larger binary
---
## What You'd Lose
Removing printing/slicing means losing:
- Printer connection and control
- G-code generation and preview
- Layer-by-layer visualization
- Print time/material estimation
- Temperature monitoring
- Print queue management
- Printer setup wizard
- 150+ slicer settings
## What You'd Keep
Design-only mode retains:
- Full 3D viewport with camera controls
- All parametric primitives (cube, sphere, cylinder, text, etc.)
- Boolean operations (union, subtract, intersect)
- Mesh operations (repair, decimate, hollow, twist, etc.)
- Transform tools (scale, rotate, mirror, array)
- File I/O (STL, OBJ, AMF, 3MF, MCX)
- Library browsing and management
- Undo/redo system
- Theme system
- Tabbed workspaces (design-only)
---
---
## Implementation Plan
### Phase 1: Remove Submodules & Projects (Day 1)
**Remove from solution:**
```
Submodules/MatterSlice/ # Slicing engine
MatterControl.Printing/ # G-code processing
```
**Update .gitmodules** to remove MatterSlice reference.
### Phase 2: Remove Printing Directories (Days 1-2)
**Delete directories:**
```
MatterControlLib/PrinterCommunication/ # Serial I/O, drivers
MatterControlLib/Queue/ # Print queue
MatterControlLib/SlicerConfiguration/ # 150+ slicer settings
MatterControlLib/PrinterControls/ # Printer UI widgets
MatterControlLib/ConfigurationPage/PrintLeveling/
MatterControlLib/SetupWizard/ # Printer setup wizard
MatterControlLib/EeProm/ # Printer EEPROM
```
### Phase 3: Modify Core Files (Days 2-5)
**Key files to modify:**
1. **ApplicationController.cs**
- Remove cloud delegate registrations
- Remove `PrinterConfig` creation logic
- Remove printer workspace support
- Keep design workspace support only
2. **MainViewWidget.cs**
- Remove `CreatePrinterTab()` calls
- Keep only `CreateDesignTab()`
- Remove printer-related status bar items
3. **PartPreviewWindow/PrinterTabPage.cs**
- DELETE entire file (or keep as reference)
4. **PartPreviewWindow/DesignTabPage.cs**
- Remove any printing-related conditionals
- This becomes the only tab type
5. **ApplicationView/PrinterConfig.cs**
- DELETE or heavily refactor
- Remove `PrinterConnection` instantiation
6. **SettingsManagement/**
- Remove slicer-related settings
- Keep only design/application settings
### Phase 4: Fix Compilation Errors (Days 5-10)
Expect ~200-300 compilation errors from removed dependencies. Systematically:
1. Remove `using` statements for deleted namespaces
2. Remove printer-related null checks
3. Remove printer-specific UI conditionals
4. Stub or remove features that depended on printing
### Phase 5: Clean Up & Test (Days 10-14)
1. Remove dead code and unused references
2. Update project files (.csproj)
3. Test all design features:
- 3D viewport and camera
- All primitives (cube, sphere, cylinder, text, etc.)
- Boolean operations
- Mesh operations (repair, decimate, etc.)
- File I/O (STL, OBJ, AMF, 3MF)
- Library browsing
- Undo/redo
4. Remove printing-related localization strings
---
## Verification Steps
After implementation, verify:
1. **Build succeeds** without MatterSlice or Printing references
2. **App launches** without printer setup wizard
3. **Design tab works:**
- Create new design workspace
- Add primitives to scene
- Apply boolean operations
- Save/load files (STL, OBJ, etc.)
4. **Library works:**
- Browse files
- Drag-and-drop import
5. **No printer references** in UI menus or settings
---
## Risk Assessment
| Risk | Mitigation |
|------|------------|
| Hidden printing dependencies | Incremental removal with frequent builds |
| Broken design features | Comprehensive testing after each phase |
| Missing shared code | Keep agg-sharp, VectorMath, PolygonMesh intact |
| Settings system breakage | Carefully separate design vs printer settings |
---
## Conclusion
**Feasibility: YES - Estimated 2-3 weeks**
The architecture supports this well. The main effort is removing ~6 directories and fixing ~200-300 compilation errors from broken references. Design features (DesignTools, View3DWidget, Library) have clean separation and should work unchanged.