194 lines
6 KiB
Markdown
194 lines
6 KiB
Markdown
|
|
# Settings Management
|
||
|
|
|
||
|
|
## Summary
|
||
|
|
|
||
|
|
MatterControl uses a hierarchical settings system managing printer configurations, slicer parameters, and user preferences. Settings are organized into profiles with inheritance, preset support, and real-time validation.
|
||
|
|
|
||
|
|
## Technical Description
|
||
|
|
|
||
|
|
### Architecture
|
||
|
|
|
||
|
|
```
|
||
|
|
ProfileManager
|
||
|
|
├── ActiveProfiles (list of printer profiles)
|
||
|
|
└── PrinterSettings (per printer)
|
||
|
|
├── BaseLayer (OEM defaults)
|
||
|
|
├── OemLayer (manufacturer overrides)
|
||
|
|
├── UserLayer (user customizations)
|
||
|
|
└── MaterialPresets / QualityPresets
|
||
|
|
```
|
||
|
|
|
||
|
|
### PrinterSettings Class
|
||
|
|
|
||
|
|
Central settings container with layered overrides:
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class PrinterSettings
|
||
|
|
{
|
||
|
|
public SettingsLayer OemLayer { get; }
|
||
|
|
public SettingsLayer UserLayer { get; }
|
||
|
|
public List<SettingsLayer> MaterialPresets { get; }
|
||
|
|
public List<SettingsLayer> QualityPresets { get; }
|
||
|
|
|
||
|
|
public string GetValue(string key);
|
||
|
|
public T GetValue<T>(string key);
|
||
|
|
public void SetValue(string key, string value);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### Settings Layers
|
||
|
|
|
||
|
|
Settings resolution from highest to lowest priority:
|
||
|
|
|
||
|
|
1. **UserLayer** - User customizations
|
||
|
|
2. **ActiveQualityPreset** - Quality preset (Draft/Normal/Fine)
|
||
|
|
3. **ActiveMaterialPreset** - Material preset (PLA/ABS/etc.)
|
||
|
|
4. **OemLayer** - Manufacturer overrides
|
||
|
|
5. **BaseLayer** - Application defaults
|
||
|
|
|
||
|
|
### SettingsKey Constants
|
||
|
|
|
||
|
|
All settings keys defined in `SettingsKey` static class:
|
||
|
|
|
||
|
|
| Category | Sample Keys |
|
||
|
|
|----------|-------------|
|
||
|
|
| Printer | `printer_name`, `build_height`, `bed_size` |
|
||
|
|
| Layer | `layer_height`, `first_layer_height` |
|
||
|
|
| Perimeters | `perimeters`, `external_perimeter_speed` |
|
||
|
|
| Infill | `fill_density`, `infill_type` |
|
||
|
|
| Support | `support_material`, `support_type` |
|
||
|
|
| Temperature | `temperature`, `bed_temperature` |
|
||
|
|
| Speed | `travel_speed`, `perimeter_speed` |
|
||
|
|
| Retraction | `retract_length`, `retract_speed` |
|
||
|
|
| G-code | `start_gcode`, `end_gcode` |
|
||
|
|
|
||
|
|
### Profile Management
|
||
|
|
|
||
|
|
`ProfileManager` handles profile lifecycle:
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class ProfileManager
|
||
|
|
{
|
||
|
|
public static ProfileManager Instance { get; }
|
||
|
|
public IEnumerable<PrinterInfo> ActiveProfiles { get; }
|
||
|
|
|
||
|
|
public static Task<PrinterSettings> LoadSettingsAsync(string profileId);
|
||
|
|
public void SaveSettings(PrinterSettings settings);
|
||
|
|
public void DeleteProfile(string profileId);
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### Settings Validation
|
||
|
|
|
||
|
|
`SettingsValidation` checks configuration consistency:
|
||
|
|
|
||
|
|
| Check | Description |
|
||
|
|
|-------|-------------|
|
||
|
|
| Temperature bounds | Min/max temperature limits |
|
||
|
|
| Speed limits | Reasonable speed ranges |
|
||
|
|
| Layer height | Compatible with nozzle diameter |
|
||
|
|
| Retraction | Valid retraction settings |
|
||
|
|
| Bed size | Build volume constraints |
|
||
|
|
|
||
|
|
### UI Components
|
||
|
|
|
||
|
|
**SliceSettingsWidget:**
|
||
|
|
```
|
||
|
|
SliceSettingsWidget
|
||
|
|
├── Category Tabs (General, Infill, Support, etc.)
|
||
|
|
├── Settings Sections
|
||
|
|
│ └── SliceSettingsRow (individual settings)
|
||
|
|
└── PresetsToolbar
|
||
|
|
├── Material Preset Selector
|
||
|
|
└── Quality Preset Selector
|
||
|
|
```
|
||
|
|
|
||
|
|
**SliceSettingsRow:**
|
||
|
|
- Label and value editor
|
||
|
|
- Reset to default button
|
||
|
|
- Override indicator
|
||
|
|
- Help tooltip
|
||
|
|
|
||
|
|
### Preset System
|
||
|
|
|
||
|
|
**Material Presets:**
|
||
|
|
- PLA, ABS, PETG, TPU, etc.
|
||
|
|
- Temperature profiles
|
||
|
|
- Retraction settings
|
||
|
|
- Fan settings
|
||
|
|
|
||
|
|
**Quality Presets:**
|
||
|
|
- Draft (fast, low quality)
|
||
|
|
- Normal (balanced)
|
||
|
|
- Fine (slow, high quality)
|
||
|
|
- Custom user presets
|
||
|
|
|
||
|
|
### OEM Customization
|
||
|
|
|
||
|
|
Manufacturers can provide custom profiles via:
|
||
|
|
|
||
|
|
```
|
||
|
|
StaticData/
|
||
|
|
├── Printers/
|
||
|
|
│ └── {Manufacturer}/
|
||
|
|
│ └── {Model}.printer
|
||
|
|
│ ├── base.ini
|
||
|
|
│ ├── material_pla.ini
|
||
|
|
│ └── quality_normal.ini
|
||
|
|
└── OEMSettings/
|
||
|
|
└── OEMProfile.json
|
||
|
|
```
|
||
|
|
|
||
|
|
### Settings Events
|
||
|
|
|
||
|
|
| Event | Description |
|
||
|
|
|-------|-------------|
|
||
|
|
| `SettingChanged` | Individual setting modified |
|
||
|
|
| `AnyPrinterSettingChanged` | Static event for any printer |
|
||
|
|
| `ActiveProfileModified` | Active profile changed |
|
||
|
|
|
||
|
|
### Design Rationale
|
||
|
|
|
||
|
|
**Layered Settings**: Inheritance hierarchy provides:
|
||
|
|
- Clear override semantics
|
||
|
|
- Easy reset to defaults
|
||
|
|
- Manufacturer customization
|
||
|
|
- User freedom to modify
|
||
|
|
|
||
|
|
**Preset System**: Separating presets allows:
|
||
|
|
- Quick switching between materials/quality
|
||
|
|
- Consistent printing results
|
||
|
|
- OEM-tuned profiles
|
||
|
|
|
||
|
|
**Key-Value Model**: String-based settings enable:
|
||
|
|
- Flexible storage
|
||
|
|
- Easy serialization
|
||
|
|
- Runtime modification
|
||
|
|
|
||
|
|
## Reference
|
||
|
|
|
||
|
|
### Core Classes
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `PrinterSettings` | [SlicerConfiguration/Settings/PrinterSettings.cs](MatterControlLib/SlicerConfiguration/Settings/PrinterSettings.cs) | Settings container |
|
||
|
|
| `SettingsLayer` | [SlicerConfiguration/Settings/SettingsLayer.cs](MatterControlLib/SlicerConfiguration/Settings/SettingsLayer.cs) | Settings layer |
|
||
|
|
| `ProfileManager` | [SlicerConfiguration/Settings/ProfileManager.cs](MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs) | Profile manager |
|
||
|
|
| `SettingsKey` | [SlicerConfiguration/Settings/SettingsKey.cs](MatterControlLib/SlicerConfiguration/Settings/SettingsKey.cs) | Key constants |
|
||
|
|
|
||
|
|
### UI Components
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `SliceSettingsWidget` | [SlicerConfiguration/SliceSettingsWidget.cs](MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs) | Settings panel |
|
||
|
|
| `SliceSettingsRow` | [SlicerConfiguration/SliceSettingsRow.cs](MatterControlLib/SlicerConfiguration/SliceSettingsRow.cs) | Settings row |
|
||
|
|
| `PresetSelectorWidget` | [SlicerConfiguration/PresetSelectorWidget.cs](MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs) | Preset dropdown |
|
||
|
|
|
||
|
|
### Application Settings
|
||
|
|
|
||
|
|
| Class | Location | Description |
|
||
|
|
|-------|----------|-------------|
|
||
|
|
| `ApplicationSettings` | [SettingsManagement/ApplicationSettings.cs](MatterControlLib/SettingsManagement/ApplicationSettings.cs) | App-level settings |
|
||
|
|
| `UserSettings` | [SettingsManagement/UserSettings.cs](MatterControlLib/SettingsManagement/UserSettings.cs) | User preferences |
|
||
|
|
| `OemSettings` | [SettingsManagement/OemSettings.cs](MatterControlLib/SettingsManagement/OemSettings.cs) | OEM config |
|