Skip to content

Add per-object display modes to the Objects panel#594

Open
markomarkovic wants to merge 7 commits into
CadQuery:masterfrom
markomarkovic:per-object-visibility
Open

Add per-object display modes to the Objects panel#594
markomarkovic wants to merge 7 commits into
CadQuery:masterfrom
markomarkovic:per-object-visibility

Conversation

@markomarkovic

Copy link
Copy Markdown

Adds per-object display modes to the Objects panel. Each object can be shown as shaded, transparent, or wireframe, or hidden, chosen from a row of radios in the tree. An All row applies a single mode to every object at once as a global override, while each object keeps its own mode underneath.

Per-object display modes

Testing

New tests/test_display.py covers the state model; tests/test_app.py adds pytest-qt coverage for the tree state, viewer application, and the panel radios. The existing test_inspect was updated for the new "All" row and the radio-based visibility control. pytest tests/ — full suite passes.

Depends on #593 — this branch is stacked on it, so until #593 merges the diff also shows the main_window.py LogViewer fix.


Claude AI assisted with the implementation under my direction; design, testing, and review are mine.

PRINT_REDIRECTOR is a module-level singleton, so the lambda connected to
sigStdoutWrite in prepare_panes accumulated one connection per MainWindow and
was never disconnected. Each lambda also closed over self and resolved
self.components["log"] late through a dict that MainMixin holds as a class
attribute, so it reached whichever LogViewer registered last. Once a LogViewer
was destroyed, the next print() called into a deleted C++ object and raised
RuntimeError.

Connecting the bound method instead lets PyQt drop the connection when the
receiver is destroyed.
Introduces the display module: a per-object DisplayMode (Hidden, Wireframe,
Transparent, Shaded), a panel-wide GlobalMode override, and effective_mode()
resolving the two. HIDDEN always wins so an override never unhides an object.
Adds a per-object Display mode property (Hidden/Wireframe/Transparent/Shaded)
to ObjectTreeItem and a panel-wide global mode on ObjectTree, emitting
sigDisplayModesChanged/sigGlobalModeChanged with the resolved effective modes
so the viewer can apply them.
Wires the object tree's display-mode signals to the viewer: apply_display_modes
erases hidden objects and sets wireframe/shaded/transparency per object, and the
Wireframe/Shaded/Transparent toolbar actions drive and reflect the global mode.
Replaces the name-column visibility checkbox with a row of mutually exclusive
radios per object (Hidden/Wireframe/Transparent/Shaded) and an 'All' row that
sets the global override. Radios are centered under centered header icons, and
are torn down with the item so the joining QButtonGroup does not leak it.
@markomarkovic
markomarkovic force-pushed the per-object-visibility branch from aa64b4b to aa56474 Compare July 23, 2026 13:37
@markomarkovic

Copy link
Copy Markdown
Author

Rebased onto master to clear the conflicts with #590.

The per-object display modes now work with the nested assembly tree that #590 introduced:

  • Every item under CQ models gets its own row of mode radios, nested assembly parts included, and each part holds its own mode.
  • Setting the mode on an assembly row cascades to its parts. An assembly root often has no shape of its own, so on its own it would have nothing to show — this takes over the role the ItemIsAutoTristate check state propagation played in Better Assembly Handling #590, which no longer applies now that these rows carry radios instead of a checkbox.
  • The branch indent is drawn in the name column (setTreePosition), so the nesting stays visible while the mode columns still line up with their header icons.

Both entry points to a mode — the radios and the properties editor's dropdown — go through the same path, so either one cascades.

New tests cover the nested case: parts get their own radios and hold independent modes, a parent's mode cascades to its subtree, a hidden part stays hidden across a re-run with "Preserve properties on reload", and re-running a script that shows an assembly does not leak radio widgets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant