feat(ztools): appearance mode toggle UI and observer #21

Open
opened 2026-02-07 16:26:07 +00:00 by forbes · 0 comments
Owner
title, labels, milestone, depends
title labels milestone depends
feat(ztools): appearance mode toggle UI and observer
feature
ztools
appearance
ui
Appearance System
feat(ztools): appearance mode system with engineering color presets

Summary

Wire the appearance mode system (Phase 1) into the viewport with live switching, document observers for automatic recoloring, and context menu integration for quick category tagging.

Scope

View Menu Integration

  • View → Appearance Mode submenu with radio group: Realistic / Engineering
  • Toolbar dropdown button for quick mode switching
  • Status bar indicator showing current active mode

Document Observer

  • Observer hooks into slotChangedObject and slotCreatedObject
  • Auto-applies active mode when parts are added, modified, or recomputed
  • Debounced re-color pass to avoid flicker during batch recompute
  • Observer registered/unregistered on workbench activate/deactivate

Category Tagging UI

  • Right-click context menu on tree view parts: Set Category → [enum values]
  • Batch-tag command: select multiple parts → assign category in one action
  • Category shown in part tooltip when Engineering mode is active

Transactions

  • Category property changes wrapped in FreeCAD undo transactions
  • Mode switches do not create undo entries (view-only, non-persistent change)

Implementation Notes

  • Observer listens on slotChangedObject for KindredCategory property changes → single-part re-color
  • Observer listens on slotCreatedObject → apply default category + current mode color
  • Full document re-color on mode switch is debounced (100ms) to batch rapid changes
  • Context menu uses FreeCADGui.Selection.getSelectionEx() for multi-select batch tagging
  • Toolbar icon reflects current mode (e.g., paintbrush with mode-colored indicator)

File Structure

mods/ztools/
├── appearance/
│   ├── observer.py           # DocumentObserver for auto-recolor
│   ├── commands.py           # FreeCAD Command classes (toggle, set category)
│   └── ui.py                 # Menu/toolbar registration helpers

Acceptance Criteria

  • Mode can be toggled from View menu, toolbar button, or Python console
  • Adding a new part auto-applies current mode coloring without manual refresh
  • Recompute does not reset colors (observer re-applies after recompute)
  • Right-click → Set Category updates color immediately in Engineering mode
  • Multi-select batch category assignment works
  • Category changes are undoable via Edit → Undo
  • No flicker during recompute of large assemblies (debounce working)
--- title: "feat(ztools): appearance mode toggle UI and observer" labels: ["feature", "ztools", "appearance", "ui"] milestone: "Appearance System" depends: ["feat(ztools): appearance mode system with engineering color presets"] --- ## Summary Wire the appearance mode system (Phase 1) into the viewport with live switching, document observers for automatic recoloring, and context menu integration for quick category tagging. ## Scope ### View Menu Integration - [ ] **View → Appearance Mode** submenu with radio group: Realistic / Engineering - [ ] Toolbar dropdown button for quick mode switching - [ ] Status bar indicator showing current active mode ### Document Observer - [ ] Observer hooks into `slotChangedObject` and `slotCreatedObject` - [ ] Auto-applies active mode when parts are added, modified, or recomputed - [ ] Debounced re-color pass to avoid flicker during batch recompute - [ ] Observer registered/unregistered on workbench activate/deactivate ### Category Tagging UI - [ ] Right-click context menu on tree view parts: **Set Category → [enum values]** - [ ] Batch-tag command: select multiple parts → assign category in one action - [ ] Category shown in part tooltip when Engineering mode is active ### Transactions - [ ] Category property changes wrapped in FreeCAD undo transactions - [ ] Mode switches do not create undo entries (view-only, non-persistent change) ## Implementation Notes - Observer listens on `slotChangedObject` for `KindredCategory` property changes → single-part re-color - Observer listens on `slotCreatedObject` → apply default category + current mode color - Full document re-color on mode switch is debounced (100ms) to batch rapid changes - Context menu uses `FreeCADGui.Selection.getSelectionEx()` for multi-select batch tagging - Toolbar icon reflects current mode (e.g., paintbrush with mode-colored indicator) ## File Structure ``` mods/ztools/ ├── appearance/ │ ├── observer.py # DocumentObserver for auto-recolor │ ├── commands.py # FreeCAD Command classes (toggle, set category) │ └── ui.py # Menu/toolbar registration helpers ``` ## Acceptance Criteria - [ ] Mode can be toggled from View menu, toolbar button, or Python console - [ ] Adding a new part auto-applies current mode coloring without manual refresh - [ ] Recompute does not reset colors (observer re-applies after recompute) - [ ] Right-click → Set Category updates color immediately in Engineering mode - [ ] Multi-select batch category assignment works - [ ] Category changes are undoable via Edit → Undo - [ ] No flicker during recompute of large assemblies (debounce working)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#21