Skip to content

Introduce a document id to support multiple documents in TiGLCreator#1401

Draft
joergbrech wants to merge 4 commits into
mainfrom
1399-prepare-support-for-multiple-open-documents
Draft

Introduce a document id to support multiple documents in TiGLCreator#1401
joergbrech wants to merge 4 commits into
mainfrom
1399-prepare-support-for-multiple-open-documents

Conversation

@joergbrech

@joergbrech joergbrech commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1399. Adresses #1211.

⚠️ Should be merged after the TiGL 3.5 release. This is unstable and needs further testing.

Today TIGLCreatorContext (the shared OpenCASCADE 3D scene) has a single global InteractiveShapeManager and a single global deleteAllObjects(). That's fine as long as only one CPACS document is ever open, but it's the reason multiple simultaneously-open documents (#1211) can't work: two open documents could easily share a component UID (e.g. two sibling models from one CPACS file, or two variants of the same aircraft), which would silently collide in the shared shape manager, and closing/redrawing one document would wipe every document's shapes out of the viewport.

This PR introduces a DocumentId (TIGLCreator/src/DocumentId.h) and scopes the scene's shape bookkeeping
to it:

  • GetShapeManager()GetShapeManager(DocumentId), backed by a std::map<DocumentId, InteractiveShapeManager> instead of one shared instance.
  • Every displayShape/displayPoint/displayVector/displayShapeHLMode/displayLineHLMode call now takes a DocumentId and registers the resulting AIS object against it, so unnamed/untracked shapes (e.g. control-point-net previews) are also scoped correctly, not just named ones.
  • New deleteObjectsOfDocument(DocumentId) removes only one document's shapes from the scene, leaving other open documents' shapes untouched — the scoped replacement for the old global deleteAllObjects().
  • New GetShapeFromIObject(...) at the context level resolves a 3D-view pick across all open documents' shape managers, since a click in the shared viewport can land on any of them.

I made the DocumentId parameter mandatory everywhere rather than defaulted, specifically so the compiler would force auditing every call site (there turned out to be ~150 of them across TIGLCreatorDocument.cpp, ModificatorModel.cpp, TIGLCreatorWidget.cpp, ModificatorDisplayOptionsWidget.cpp, TIGLCreatorWindow.cpp, and TIGLCreatorInputoutput.cpp`) rather than risk silently missing one.

This PR is intentionally a pure backend refactor with no user-visible behavior change. Only one document is ever open today, so a single fixed DocumentId is used everywhere and every code path behaves exactly as before. It lays the groundwork for #1400 (tabbed CPACS tree for multiple open documents) and #1302 (auto-loading multiple models from one file), neither of which is possible without this.

One subtlety worth calling out for review: deleteObjectsOfDocument() intentionally does not clear a document's named shape-manager entries (unlike closing a document, which does, via a separate GetShapeManager(id).clear() call) — several redraw code paths rely on HasShapeEntry() still returning true for shapes that were removed from the viewport but not yet redrawn. Folding the clear into the delete would have subtly changed "draw only if not already displayed" behavior at ~14 call sites.

How Has This Been Tested?

Not at all 😨

Screenshots, that help to understand the changes(if applicable):

Checklist for PR Author:

  • Unit or integration test added (if applicable)
  • Python interface updated (if applicable)
  • Python test added (if Python interface updated)
  • Doxygen docstrings added
  • ChangeLog.md updated

Give the shared TIGLCreatorContext scene a per-document shape manager
and AIS-object tracking, keyed by a new DocumentId, instead of one
global InteractiveShapeManager and a global deleteAllObjects(). This
is prep for #1211 (multiple simultaneously open CPACS documents):
today only one document is ever open, so a single fixed DocumentId is
used everywhere and behavior is unchanged, but every display call and
shape-manager access now goes through an explicit DocumentId rather
than an implicit global, so a later PR can open several documents at
once in the shared viewport without their shapes colliding by UID or
getting wiped by each other's redraws/closes.

Also adds TIGLCreatorContext::GetShapeFromIObject() for cross-document
3D-pick resolution (a click in the shared viewport can land on any
open document's shape).

Not yet covered by automated tests: TIGLCreator has no GUI test
target, and this environment cannot run the GUI to manually verify
runtime behavior. Verified via a clean full rebuild of every changed
file (zero warnings/errors) and the existing 899 core-library unit
tests (unaffected, src/ untouched).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyogF1kmLgJiCG63GVzpNW
@joergbrech joergbrech linked an issue Jul 22, 2026 that may be closed by this pull request
@github-actions

Copy link
Copy Markdown
Contributor

PR Reminders

This PR has changes in TIGLCreator/ but not in src/, tests/unittests/, tests/integrationtests/, tests/python/, or bindings/python_internal/. ChangeLog.md has no changes.

  • 📝 Tip: Don't forget to add an entry to ChangeLog.md

This is an automated reminder from CI

@joergbrech joergbrech changed the title TIGLCreator: scope shared 3D-scene shapes to the owning document Introduce a document id to support multiple documents in TiGLCreator Jul 22, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (48cbe0c) to head (05b8727).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1401   +/-   ##
=======================================
  Coverage   73.20%   73.20%           
=======================================
  Files         324      324           
  Lines       28598    28598           
=======================================
  Hits        20934    20934           
  Misses       7664     7664           
Flag Coverage Δ
unittests 73.20% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…rom main

Commit aa9933b (symmetry-toggle-sync, merged into this branch via
bdb4c35) called the pre-PR1 no-arg GetShapeManager(), which no longer
exists now that shape managers are scoped per document.
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.

Prepare support for multiple open documents

1 participant