From e2d6919b33774af48e1e3d0615bdd072e76f0cef Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Tue, 21 Jul 2026 14:10:39 +0200 Subject: [PATCH 1/3] TIGLCreator: scope shared 3D-scene shapes to the owning document 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 Claude-Session: https://claude.ai/code/session_01AyogF1kmLgJiCG63GVzpNW --- TIGLCreator/src/DocumentId.h | 27 ++ TIGLCreator/src/ModificatorModel.cpp | 11 +- TIGLCreator/src/TIGLCreatorContext.cpp | 92 +++++- TIGLCreator/src/TIGLCreatorContext.h | 49 ++- TIGLCreator/src/TIGLCreatorDocument.cpp | 296 +++++++++--------- TIGLCreator/src/TIGLCreatorDocument.h | 10 +- TIGLCreator/src/TIGLCreatorInputoutput.cpp | 9 +- TIGLCreator/src/TIGLCreatorInputoutput.h | 9 +- TIGLCreator/src/TIGLCreatorWidget.cpp | 2 +- TIGLCreator/src/TIGLCreatorWindow.cpp | 26 +- TIGLCreator/src/TIGLCreatorWindow.h | 4 + .../ModificatorDisplayOptionsWidget.cpp | 14 +- 12 files changed, 340 insertions(+), 209 deletions(-) create mode 100644 TIGLCreator/src/DocumentId.h diff --git a/TIGLCreator/src/DocumentId.h b/TIGLCreator/src/DocumentId.h new file mode 100644 index 0000000000..1a553743d6 --- /dev/null +++ b/TIGLCreator/src/DocumentId.h @@ -0,0 +1,27 @@ +/* +* Copyright (C) 2026 German Aerospace Center (DLR/SC) +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef DOCUMENTID_H +#define DOCUMENTID_H + +// Identifies one open document (a CPACS configuration or an imported geometry +// file) in TIGLCreator, independent of whether it has a TIGLCreatorDocument +// instance. Used to scope shapes displayed in the shared 3D scene to the +// document that owns them. +using DocumentId = int; + +constexpr DocumentId InvalidDocumentId = -1; + +#endif // DOCUMENTID_H diff --git a/TIGLCreator/src/ModificatorModel.cpp b/TIGLCreator/src/ModificatorModel.cpp index 5f90b18b48..6b749e4627 100644 --- a/TIGLCreator/src/ModificatorModel.cpp +++ b/TIGLCreator/src/ModificatorModel.cpp @@ -1173,7 +1173,7 @@ void ModificatorModel::onDeleteFuselageRequested() void ModificatorModel::highlightShape(const std::string& name){ - auto iobjects = scene->GetShapeManager().GetIObjectsFromShapeName(name); + auto iobjects = scene->GetShapeManager(doc->docId()).GetIObjectsFromShapeName(name); if (iobjects.size() > 0) { scene->getContext()->ClearSelected(Standard_False); @@ -1186,7 +1186,7 @@ void ModificatorModel::highlight(std::vector element { try { for (size_t i = 0; i < elements.size(); i++) { - Handle(AIS_InteractiveObject) shape = scene->displayShapeHLMode(elements[i]->GetWire()); + Handle(AIS_InteractiveObject) shape = scene->displayShapeHLMode(elements[i]->GetWire(), doc->docId()); highligthteds.push_back(shape); } } catch (...) { @@ -1204,8 +1204,7 @@ void ModificatorModel::highlight(tigl::CCPACSPositioning &positioning, const tig tigl::CTiglPoint bPoint = positioning.GetToPoint(); aPoint = parentTransformation * aPoint; bPoint = parentTransformation * bPoint; - Handle(AIS_InteractiveObject) shape = scene->displayLineHLMode(aPoint.x, aPoint.y, aPoint.z, bPoint.x, bPoint.y, - bPoint.z); + Handle(AIS_InteractiveObject) shape = scene->displayLineHLMode(aPoint.x, aPoint.y, aPoint.z, bPoint.x, bPoint.y, bPoint.z, doc->docId()); highligthteds.push_back(shape); } catch (...) { LOG(ERROR) << "ModificatorManager::highlight: Error, No highlighting!"; @@ -1283,7 +1282,7 @@ QVariant ModificatorModel::data(const QModelIndex& index, int role) const // get visibility state and check or uncheck accordingly std::string uid = item->getUid(); if (!uid.empty() && doc->GetConfiguration().GetUIDManager().HasGeometricComponent(uid)) { - bool vis = scene->GetShapeManager().GetVisibility(uid); + bool vis = scene->GetShapeManager(doc->docId()).GetVisibility(uid); return vis ? Qt::Checked : Qt::Unchecked; } @@ -1358,7 +1357,7 @@ bool ModificatorModel::setData(const QModelIndex& index, const QVariant& value, if (!node) { return; } - if (scene->GetShapeManager().GetVisibility(node->getUid())) { + if (scene->GetShapeManager(doc->docId()).GetVisibility(node->getUid())) { mark_as_changed(node); } for (auto* child : node->getChildren()) { diff --git a/TIGLCreator/src/TIGLCreatorContext.cpp b/TIGLCreator/src/TIGLCreatorContext.cpp index 77b953e837..29c4b26c89 100644 --- a/TIGLCreator/src/TIGLCreatorContext.cpp +++ b/TIGLCreator/src/TIGLCreatorContext.cpp @@ -210,6 +210,43 @@ void TIGLCreatorContext::deleteAllObjects() myContext->Remove( aListIterator.Value(), Standard_False); } myContext->UpdateCurrentViewer(); + + myDocumentObjects.clear(); + myShapeManagers.clear(); +} + +void TIGLCreatorContext::trackDocumentObject(DocumentId docId, const Handle(AIS_InteractiveObject)& obj) +{ + if (docId == InvalidDocumentId || obj.IsNull()) { + return; + } + myDocumentObjects[docId].push_back(obj); +} + +void TIGLCreatorContext::trackDisplayedObject(DocumentId docId, const Handle(AIS_InteractiveObject)& obj) +{ + trackDocumentObject(docId, obj); +} + +void TIGLCreatorContext::deleteObjectsOfDocument(DocumentId docId) +{ + // Mirrors the pre-existing (global) deleteAllObjects(): removes AIS + // objects only. It intentionally does NOT clear the document's named + // shape manager entries (see GetShapeManager) - callers that redraw a + // document rely on stale-but-present entries (e.g. HasShapeEntry checks + // guarding "draw only if not already displayed"). Callers that are + // closing a document for good should also clear its shape manager + // explicitly. + auto it = myDocumentObjects.find(docId); + if (it != myDocumentObjects.end()) { + for (const auto& obj : it->second) { + if (!obj.IsNull()) { + myContext->Remove(obj, Standard_False); + } + } + myDocumentObjects.erase(it); + } + myContext->UpdateCurrentViewer(); } /*! \brief Sets the privileged plane to the XY Axis. @@ -386,7 +423,7 @@ void TIGLCreatorContext::setGridOffset (Standard_Real offset) } // a small helper when we just want to display a shape -Handle(AIS_Shape) TIGLCreatorContext::displayShape(const TopoDS_Shape& loft, bool updateViewer, Quantity_Color color, double transparency, bool shaded) +Handle(AIS_Shape) TIGLCreatorContext::displayShape(const TopoDS_Shape& loft, DocumentId docId, bool updateViewer, Quantity_Color color, double transparency, bool shaded) { TIGLCreatorSettings& settings = TIGLCreatorSettings::Instance(); Handle(AIS_TexturedShape) shape = new AIS_TexturedShape(loft); @@ -404,7 +441,8 @@ Handle(AIS_Shape) TIGLCreatorContext::displayShape(const TopoDS_Shape& loft, boo #endif myContext->Display(shape, updateViewer); - + trackDocumentObject(docId, shape); + if (settings.enumerateFaces()) { TopTools_IndexedMapOfShape shapeMap; TopExp::MapShapes(loft, TopAbs_FACE, shapeMap); @@ -412,14 +450,14 @@ Handle(AIS_Shape) TIGLCreatorContext::displayShape(const TopoDS_Shape& loft, boo const TopoDS_Face& face = TopoDS::Face(shapeMap(i)); gp_Pnt p = GetCentralFacePoint(face); QString s = QString("%1").arg(i); - displayPoint(p, s.toStdString().c_str(), false, 0., 0., 0., 10.); + displayPoint(p, s.toStdString().c_str(), docId, false, 0., 0., 0., 10.); } } return shape; } // a small helper when we just want to display a shape -Handle(AIS_Shape) TIGLCreatorContext::displayShape(const PNamedShape& pshape, bool updateViewer, Quantity_Color color, double transparency, bool shaded) +Handle(AIS_Shape) TIGLCreatorContext::displayShape(const PNamedShape& pshape, DocumentId docId, bool updateViewer, Quantity_Color color, double transparency, bool shaded) { if (!pshape) { return nullptr; @@ -445,6 +483,7 @@ Handle(AIS_Shape) TIGLCreatorContext::displayShape(const PNamedShape& pshape, bo //myUndoStack->push(command); myContext->Display(shape, Standard_False); myContext->UpdateCurrentViewer(); + trackDocumentObject(docId, shape); if (settings.enumerateFaces()) { @@ -458,16 +497,17 @@ Handle(AIS_Shape) TIGLCreatorContext::displayShape(const PNamedShape& pshape, bo } gp_Pnt p = GetCentralFacePoint(face); QString s = QString("%1 - %2").arg(i).arg(faceName.c_str()); - displayPoint(p, s.toStdString().c_str(), false, 0., 0., 0., 10.); + displayPoint(p, s.toStdString().c_str(), docId, false, 0., 0., 0., 10.); } } - GetShapeManager().addObject(pshape, shape); + GetShapeManager(docId).addObject(pshape, shape); return shape; } // Displays a point on the screen Handle(AIS_Shape) TIGLCreatorContext::displayPoint(const gp_Pnt& aPoint, const char* aText, + DocumentId docId, Standard_Boolean UpdateViewer, Standard_Real anXoffset, Standard_Real anYoffset, @@ -475,31 +515,34 @@ Handle(AIS_Shape) TIGLCreatorContext::displayPoint(const gp_Pnt& aPoint, Standard_Real TextScale) { if (std::string(aText).empty()) { - return displayShape(BRepBuilderAPI_MakeVertex(gp_Pnt(aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset)), UpdateViewer, Quantity_NOC_YELLOW); + return displayShape(BRepBuilderAPI_MakeVertex(gp_Pnt(aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset)), docId, UpdateViewer, Quantity_NOC_YELLOW); } else { Handle(ISession_Point) aGraphicPoint = new ISession_Point(aPoint.X(), aPoint.Y(), aPoint.Z()); myContext->Display(aGraphicPoint,UpdateViewer); + trackDocumentObject(docId, aGraphicPoint); Handle(ISession_Text) aGraphicText = new ISession_Text(aText, aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset); aGraphicText->SetScale(TextScale); myContext->Display(aGraphicText,UpdateViewer); + trackDocumentObject(docId, aGraphicText); return Handle(AIS_Shape)::DownCast(aGraphicPoint); } } // convenience wrapper -void TIGLCreatorContext::drawPoint(double x, double y, double z) +void TIGLCreatorContext::drawPoint(double x, double y, double z, DocumentId docId) { - displayPoint(gp_Pnt(x,y,z), "", Standard_True, 0,0,0, 1.0); + displayPoint(gp_Pnt(x,y,z), "", docId, Standard_True, 0,0,0, 1.0); } // Displays a vector on the screen void TIGLCreatorContext::displayVector(const gp_Pnt& aPoint, const gp_Vec& aVec, const char* aText, + DocumentId docId, Standard_Boolean UpdateViewer, Standard_Real anXoffset, Standard_Real anYoffset, @@ -508,11 +551,13 @@ void TIGLCreatorContext::displayVector(const gp_Pnt& aPoint, { Handle(ISession_Direction) aGraphicDirection = new ISession_Direction(aPoint, aVec); myContext->Display(aGraphicDirection,UpdateViewer); + trackDocumentObject(docId, aGraphicDirection); Handle(ISession_Text) aGraphicText = new ISession_Text(aText, aPoint.X() + anXoffset, aPoint.Y() + anYoffset, aPoint.Z() + aZoffset); aGraphicText->SetScale(TextScale); myContext->Display(aGraphicText,UpdateViewer); + trackDocumentObject(docId, aGraphicText); } bool TIGLCreatorContext::hasSelectedShapes() const @@ -539,9 +584,9 @@ void TIGLCreatorContext::updateViewer() } // convenience wrapper -void TIGLCreatorContext::drawVector(double x, double y, double z, double dirx, double diry, double dirz) +void TIGLCreatorContext::drawVector(double x, double y, double z, double dirx, double diry, double dirz, DocumentId docId) { - displayVector(gp_Pnt(x,y,z), gp_Vec(dirx, diry, dirz), "", Standard_True, 0,0,0, 1.0); + displayVector(gp_Pnt(x,y,z), gp_Vec(dirx, diry, dirz), "", docId, Standard_True, 0,0,0, 1.0); } std::vector TIGLCreatorContext::selected() @@ -667,12 +712,23 @@ void TIGLCreatorContext::setFaceBoundariesEnabled(bool enabled) { } } -InteractiveShapeManager& TIGLCreatorContext::GetShapeManager() +InteractiveShapeManager& TIGLCreatorContext::GetShapeManager(DocumentId docId) { - return myShapeManager; + return myShapeManagers[docId]; +} + +PNamedShape TIGLCreatorContext::GetShapeFromIObject(const Handle(AIS_Shape)& obj) +{ + for (auto& kv : myShapeManagers) { + PNamedShape shape = kv.second.GetShapeFromIObject(obj); + if (shape) { + return shape; + } + } + return PNamedShape(); } -Handle(AIS_InteractiveObject) TIGLCreatorContext::displayShapeHLMode(const TopoDS_Shape& loft, bool updateViewer, +Handle(AIS_InteractiveObject) TIGLCreatorContext::displayShapeHLMode(const TopoDS_Shape& loft, DocumentId docId, bool updateViewer, Quantity_Color color, double transparency) { TIGLCreatorSettings& settings = TIGLCreatorSettings::Instance(); @@ -691,6 +747,7 @@ Handle(AIS_InteractiveObject) TIGLCreatorContext::displayShapeHLMode(const TopoD #endif myContext->Display(shape, true); + trackDocumentObject(docId, shape); if (settings.enumerateFaces()) { TopTools_IndexedMapOfShape shapeMap; @@ -699,14 +756,15 @@ Handle(AIS_InteractiveObject) TIGLCreatorContext::displayShapeHLMode(const TopoD const TopoDS_Face& face = TopoDS::Face(shapeMap(i)); gp_Pnt p = GetCentralFacePoint(face); QString s = QString("%1").arg(i); - displayPoint(p, s.toStdString().c_str(), false, 0., 0., 0., 10.); + displayPoint(p, s.toStdString().c_str(), docId, false, 0., 0., 0., 10.); } } return shape; } Handle(AIS_InteractiveObject) TIGLCreatorContext::displayLineHLMode(double Ax, double Ay, double Az, double Bx, - double By, double Bz, bool updateViewer, + double By, double Bz, DocumentId docId, + bool updateViewer, Quantity_Color color, double transparency) { gp_Pnt aPoint(Ax, Ay, Az); @@ -718,7 +776,7 @@ Handle(AIS_InteractiveObject) TIGLCreatorContext::displayLineHLMode(double Ax, d } TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aPoint, bPoint); TopoDS_Wire wire = BRepBuilderAPI_MakeWire(aEdge1); - return displayShapeHLMode(wire, updateViewer, color, transparency); + return displayShapeHLMode(wire, docId, updateViewer, color, transparency); } void TIGLCreatorContext::removeShape(Handle(AIS_InteractiveObject) shape) diff --git a/TIGLCreator/src/TIGLCreatorContext.h b/TIGLCreator/src/TIGLCreatorContext.h index 6fe269ae0a..3d75dc0339 100644 --- a/TIGLCreator/src/TIGLCreatorContext.h +++ b/TIGLCreator/src/TIGLCreatorContext.h @@ -32,9 +32,11 @@ #include "TIGLCreatorColors.h" #include "TIGLInteractiveShapeManager.h" #include "TIGLCreatorSettings.h" +#include "DocumentId.h" #include #include #include +#include #if OCC_VERSION_HEX >= VERSION_HEX_CODE(6,7,0) #include #endif @@ -64,15 +66,17 @@ class TIGLCreatorContext : public QObject Handle(AIS_Shape) displayPoint(const gp_Pnt& aPoint, const char* aText, + DocumentId docId, Standard_Boolean UpdateViewer, Standard_Real anXoffset, Standard_Real anYoffset, Standard_Real aZoffset, Standard_Real TextScale); - + void displayVector(const gp_Pnt& aPoint, const gp_Vec& aVec, const char* aText, + DocumentId docId, Standard_Boolean UpdateViewer, Standard_Real anXoffset, Standard_Real anYoffset, @@ -83,12 +87,21 @@ class TIGLCreatorContext : public QObject void updateViewer(); - InteractiveShapeManager& GetShapeManager(); + // Returns the shape manager tracking the named/UID shapes belonging to + // one document. Created on first access. + InteractiveShapeManager& GetShapeManager(DocumentId docId); + + // Cross-document lookup: resolves a picked AIS object back to its named + // shape, regardless of which open document owns it. Used for 3D-view + // picking, where the shared viewport can show shapes from any open + // document. + PNamedShape GetShapeFromIObject(const Handle(AIS_Shape)& obj); // Function used to highlight (HL) shape (used by ModificatorManager) // display the shape using highlighting settings and return the AIS_InteractiveObject Handle(AIS_InteractiveObject) displayShapeHLMode( const TopoDS_Shape &loft, + DocumentId docId, bool updateViewer = Standard_True, Quantity_Color color = Quantity_NOC_Highlight, double transparency = 0.); @@ -99,18 +112,31 @@ class TIGLCreatorContext : public QObject double Bx, double By, double Bz, + DocumentId docId, bool updateViewer = Standard_True, Quantity_Color color = Quantity_NOC_Highlight, double transparency = 0.); // remove the shape referenced by shape of the scene void removeShape( Handle(AIS_InteractiveObject) shape); + // Removes all objects (named and unnamed) belonging to one document from + // the scene, without touching shapes owned by other open documents. + void deleteObjectsOfDocument(DocumentId docId); + + // Registers an AIS object that was displayed outside of the + // displayShape()/displayPoint()/... helpers (e.g. imported geometry + // shown directly via getContext()->Display()) as belonging to a + // document, so it participates in deleteObjectsOfDocument() scoping. + void trackDisplayedObject(DocumentId docId, const Handle(AIS_InteractiveObject)& obj); + public slots: - Handle(AIS_Shape) displayShape(const PNamedShape& pshape, bool updateViewer, Quantity_Color color= Quantity_NOC_ShapeCol, double transparency=0., bool shaded = true); - Handle(AIS_Shape) displayShape(const TopoDS_Shape& loft, bool updateViewer, Quantity_Color color = Quantity_NOC_ShapeCol, double transparency=0., bool shaded = true); + Handle(AIS_Shape) displayShape(const PNamedShape& pshape, DocumentId docId, bool updateViewer, Quantity_Color color= Quantity_NOC_ShapeCol, double transparency=0., bool shaded = true); + Handle(AIS_Shape) displayShape(const TopoDS_Shape& loft, DocumentId docId, bool updateViewer, Quantity_Color color = Quantity_NOC_ShapeCol, double transparency=0., bool shaded = true); - void drawPoint(double x, double y, double z); - void drawVector(double x, double y, double z, double dirx, double diry, double dirz); + void drawPoint(double x, double y, double z, DocumentId docId = InvalidDocumentId); + void drawVector(double x, double y, double z, double dirx, double diry, double dirz, DocumentId docId = InvalidDocumentId); + // Removes all objects from the scene, across all open documents. Used + // when shutting down the scene entirely (e.g. no documents left open). void deleteAllObjects(); void gridXY (); void gridXZ (); @@ -155,7 +181,16 @@ public slots: Handle(Graphic3d_ShaderProgram) myShader; #endif QUndoStack* myUndoStack; - InteractiveShapeManager myShapeManager; + + // Named/UID shape lookup, scoped per document. Entries are created + // lazily on first GetShapeManager(docId) access. + std::map myShapeManagers; + // Every AIS object displayed for a given document (named or not), used + // to scope deleteObjectsOfDocument() without affecting other open + // documents' shapes in the shared scene. + std::map> myDocumentObjects; + + void trackDocumentObject(DocumentId docId, const Handle(AIS_InteractiveObject)& obj); void initShaders(); }; diff --git a/TIGLCreator/src/TIGLCreatorDocument.cpp b/TIGLCreator/src/TIGLCreatorDocument.cpp index c1caa0cabe..f0b26fa0c4 100644 --- a/TIGLCreator/src/TIGLCreatorDocument.cpp +++ b/TIGLCreator/src/TIGLCreatorDocument.cpp @@ -121,13 +121,14 @@ double getAbsDeflection(const TopoDS_Shape& theShape, double relDeflection) return aDeflection; } -TIGLCreatorDocument::TIGLCreatorDocument(TIGLCreatorWindow* parentWidget) +TIGLCreatorDocument::TIGLCreatorDocument(TIGLCreatorWindow* parentWidget, DocumentId docId) : QObject(parentWidget) , m_flapsDialog(new TIGLCreatorSelectWingAndFlapStatusDialog(this, parentWidget)) , modifiedSinceLastSave(false) { app = parentWidget; m_cpacsHandle = -1; + m_docId = docId; } TIGLCreatorDocument::~TIGLCreatorDocument() @@ -333,7 +334,7 @@ void TIGLCreatorDocument::updateConfiguration() START_COMMAND() tiglCloseCPACSConfiguration(m_cpacsHandle); m_cpacsHandle = -1; - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); openCpacsConfigurationFromFile(loadedConfigurationFileName); emit documentUpdated(m_cpacsHandle); } @@ -809,7 +810,7 @@ void TIGLCreatorDocument::drawComponentByUID(const QString& uid) return; } - if (!app->getScene()->GetShapeManager().HasShapeEntry(uid.toStdString())) { + if (!app->getScene()->GetShapeManager(m_docId).HasShapeEntry(uid.toStdString())) { PNamedShape loft = component.GetLoft(); if (loft) { @@ -821,21 +822,21 @@ void TIGLCreatorDocument::drawComponentByUID(const QString& uid) shaded = false; } - auto shape = app->getScene()->displayShape(loft, true, getDefaultShapeColor(), opacity, shaded); - app->getScene()->GetShapeManager().addObject(uid.toStdString(), shape); + auto shape = app->getScene()->displayShape(loft, m_docId, true, getDefaultShapeColor(), opacity, shaded); + app->getScene()->GetShapeManager(m_docId).addObject(uid.toStdString(), shape); auto* geometricComp = dynamic_cast(&component); if (geometricComp) { PNamedShape mirroredLoft = geometricComp->GetMirroredLoft(); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor(), opacity, shaded); - app->getScene()->GetShapeManager().addObject(uid.toStdString(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, getDefaultShapeSymmetryColor(), opacity, shaded); + app->getScene()->GetShapeManager(m_docId).addObject(uid.toStdString(), shape); } } } } else { - IObjectList objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(uid.toStdString()); + IObjectList objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(uid.toStdString()); if (objects.empty()) { throw tigl::CTiglError("No object found for component with uid \"" + uid.toStdString() + "\""); return; @@ -968,7 +969,7 @@ void TIGLCreatorDocument::drawControlPointNetByUID(const QString& uid) } } - app->getScene()->displayShape(control_point_net, false, Quantity_NOC_YELLOW); + app->getScene()->displayShape(control_point_net, m_docId, false, Quantity_NOC_YELLOW); } if (valid_face_count == 0) { LOG(WARNING) << "Cannot draw control net: The geometric shape for the component with uid \"" << uid.toStdString() << "\" has no faces that are a B-Spline surface."; @@ -1024,7 +1025,7 @@ void TIGLCreatorDocument::drawConfiguration(bool withDuctCutouts) void TIGLCreatorDocument::drawConfigurationWithDuctCutouts() { - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); drawConfiguration(true); } @@ -1105,14 +1106,14 @@ void TIGLCreatorDocument::drawWingGuideCurves(tigl::CCPACSWing& wing) for (; anIter.More(); anIter.Next()) { const TopoDS_Shape& wire = anIter.Value(); - app->getScene()->displayShape(wire, Standard_False, Quantity_NOC_RED); + app->getScene()->displayShape(wire, m_docId, Standard_False, Quantity_NOC_RED); } //display guide curve points (TODO: these points are not sorted and // there are probably duplicates) std::vector points = wing.GetGuideCurvePoints(); for (const auto& point : points) { - app->getScene()->displayPoint(point, "", Standard_False, 0, 0, 0, 1.); + app->getScene()->displayPoint(point, "", m_docId, Standard_False, 0, 0, 0, 1.); } app->getScene()->getContext()->UpdateCurrentViewer(); @@ -1120,7 +1121,7 @@ void TIGLCreatorDocument::drawWingGuideCurves(tigl::CCPACSWing& wing) void TIGLCreatorDocument::drawFuselageProfiles() { - displayedShapeNames = app->getScene()->GetShapeManager().GetDisplayedShapeNames(); + displayedShapeNames = app->getScene()->GetShapeManager(m_docId).GetDisplayedShapeNames(); removeAirfoil(); QString fuselageProfile = dlgGetFuselageProfileSelection(); if (fuselageProfile == "") { @@ -1128,12 +1129,12 @@ void TIGLCreatorDocument::drawFuselageProfiles() } START_COMMAND() - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); tigl::CCPACSFuselageProfile& profile = GetConfiguration().GetFuselageProfile(fuselageProfile.toStdString()); TopoDS_Wire wire = profile.GetWire(); - auto wireObj = app->getScene()->displayShape(wire, true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(std::string("airfoil"), wireObj); + auto wireObj = app->getScene()->displayShape(wire, m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(std::string("airfoil"), wireObj); if (profile.GetPointList_choice1()) { const std::vector& points = profile.GetPointList_choice1()->AsVector(); @@ -1143,7 +1144,7 @@ void TIGLCreatorDocument::drawFuselageProfiles() std::stringstream str; str << i << ": (" << p.x << ", " << p.y << ", " << p.z << ")"; gp_Pnt pnt = p.Get_gp_Pnt(); - app->getScene()->displayPoint(pnt, str.str().c_str(), Standard_False, 0., 0., 0., 6.); + app->getScene()->displayPoint(pnt, str.str().c_str(), m_docId, Standard_False, 0., 0., 0., 6.); } } else { @@ -1152,8 +1153,7 @@ void TIGLCreatorDocument::drawFuselageProfiles() gp_Pnt wirePoint = profile.GetPoint(zeta); std::ostringstream text; text << "PT(" << zeta << ")"; - app->getScene()->displayPoint(wirePoint, const_cast(text.str().c_str()), Standard_False, 0.0, - 0.0, 0.0, 2.0); + app->getScene()->displayPoint(wirePoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); } catch (tigl::CTiglError& ex) { @@ -1192,14 +1192,14 @@ void TIGLCreatorDocument::drawFuselageGuideCurves(const QString& Uid) for (; anIter.More(); anIter.Next()) { const TopoDS_Shape& wire = anIter.Value(); - app->getScene()->displayShape(wire, Standard_False, Quantity_NOC_RED); + app->getScene()->displayShape(wire, m_docId, Standard_False, Quantity_NOC_RED); } //display guide curve points (TODO: these points are not sorted and // there are probably duplicates) const std::vector& points = fuselage.GetGuideCurvePoints(); for (const auto& point : points) { - app->getScene()->displayPoint(point, "", Standard_False, 0, 0, 0, 1.); + app->getScene()->displayPoint(point, "", m_docId, Standard_False, 0, 0, 0, 1.); } app->getScene()->getContext()->UpdateCurrentViewer(); @@ -1212,9 +1212,9 @@ void TIGLCreatorDocument::drawWing(const QString& Uid, bool drawFlaps) tigl::CCPACSWing& wing = GetConfiguration().GetWing(wingUid.toStdString()); wing.SetBuildFlaps(drawFlaps); - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(wingUid.toStdString()); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(wingUid.toStdString()); for (auto& obj : objects) { - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); app->getScene()->getContext()->Remove(obj, Standard_False); } removeWingFlaps(wingUid); @@ -1279,14 +1279,14 @@ bool TIGLCreatorDocument::drawWingFlaps(tigl::CCPACSWing& wing) removeWing(QString::fromStdString(wing.GetUID())); - auto shape = app->getScene()->displayShape(wing.GetLoftWithCutouts(), true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(wing.GetLoftWithCutouts(), m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); PNamedShape loftNamed(new CNamedShape(wing.GetLoftWithCutouts(), wing.GetUID().c_str())); PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); } for (auto& pcs : wing.GetComponentSegments()->GetComponentSegments()) { @@ -1296,11 +1296,11 @@ bool TIGLCreatorDocument::drawWingFlaps(tigl::CCPACSWing& wing) if (auto& teds = pcs->GetControlSurfaces()->GetTrailingEdgeDevices()) { for (auto& ted : teds->GetTrailingEdgeDevices()) { - auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(ted->GetUID()); + auto objs = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(ted->GetUID()); // remove old wireframe flap shapes for (auto& obj : objs) { app->getScene()->getContext()->Remove(obj, Standard_True); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } drawWingFlap(ted->GetUID().c_str()); @@ -1310,11 +1310,11 @@ bool TIGLCreatorDocument::drawWingFlaps(tigl::CCPACSWing& wing) if (auto& leds = pcs->GetControlSurfaces()->GetLeadingEdgeDevices()) { for (auto& led : leds->GetLeadingEdgeDevices()) { - auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(led->GetUID()); + auto objs = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(led->GetUID()); // remove old wireframe flap shapes for (auto& obj : objs) { app->getScene()->getContext()->Remove(obj, Standard_True); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } drawWingFlap(led->GetUID().c_str()); } @@ -1386,14 +1386,14 @@ void TIGLCreatorDocument::drawWingFlap(const QString& uid) if (*obj.type == typeid(tigl::CCPACSTrailingEdgeDevice)) { auto* ted = static_cast(obj.ptr); - app->getScene()->displayShape(ted->GetLoft(), false, Quantity_NOC_GREEN); + app->getScene()->displayShape(ted->GetLoft(), m_docId, false, Quantity_NOC_GREEN); // if flap has mirrored loft, display it too (not mirrored), to later update its transform and then mirror it PNamedShape mirrored_loft = ted->GetMirroredLoft(); if (mirrored_loft) { PNamedShape mirror_named(new CNamedShape(ted->GetLoft()->Shape(), (ted->GetUID() + ":mirrored").c_str())); - auto mirror_shape = app->getScene()->displayShape(mirror_named, false, Quantity_NOC_GREEN); - app->getScene()->GetShapeManager().addObject(ted->GetUID(), mirror_shape); + auto mirror_shape = app->getScene()->displayShape(mirror_named, m_docId, false, Quantity_NOC_GREEN); + app->getScene()->GetShapeManager(m_docId).addObject(ted->GetUID(), mirror_shape); } updateFlapTransform(ted->GetUID()); @@ -1401,14 +1401,14 @@ void TIGLCreatorDocument::drawWingFlap(const QString& uid) else if (*obj.type == typeid(tigl::CCPACSLeadingEdgeDevice)) { auto* led = static_cast(obj.ptr); - app->getScene()->displayShape(led->GetLoft(), false, Quantity_NOC_GREEN); + app->getScene()->displayShape(led->GetLoft(), m_docId, false, Quantity_NOC_GREEN); // if flap has mirrored loft, display it too (not mirrored), to later update its transform and then mirror it PNamedShape mirrored_loft = led->GetMirroredLoft(); if (mirrored_loft) { PNamedShape mirror_named(new CNamedShape(led->GetLoft()->Shape(), (led->GetUID() + ":mirrored").c_str())); - auto mirror_shape = app->getScene()->displayShape(mirror_named, false, Quantity_NOC_GREEN); - app->getScene()->GetShapeManager().addObject(led->GetUID(), mirror_shape); + auto mirror_shape = app->getScene()->displayShape(mirror_named, m_docId, false, Quantity_NOC_GREEN); + app->getScene()->GetShapeManager(m_docId).addObject(led->GetUID(), mirror_shape); } updateFlapTransform(led->GetUID()); @@ -1439,9 +1439,9 @@ void TIGLCreatorDocument::updateFlapTransform(const std::string& controlUID) trsf = controlSurfaceDevice->GetFlapTransform(); flaps = - app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); + app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); mflaps = - app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+":mirrored"); + app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+":mirrored"); } catch (...) { displayError(QString("Error computing control surface device '%1'").arg(controlUID.c_str()), @@ -1455,9 +1455,9 @@ void TIGLCreatorDocument::updateFlapTransform(const std::string& controlUID) trsf = controlSurfaceDevice->GetFlapTransform(); flaps = - app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); + app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()); mflaps = - app->getScene()->GetShapeManager().GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+":mirrored"); + app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(controlSurfaceDevice->GetUID()+":mirrored"); } catch (...) { displayError(QString("Error computing control surface device '%1'").arg(controlUID.c_str()), @@ -1501,10 +1501,10 @@ void TIGLCreatorDocument::removeWing(const QString& Uid) { tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(wing.GetUID()); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(wing.GetUID()); for (auto& obj : objects) { app->getScene()->getContext()->Remove(obj, Standard_False); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } } @@ -1524,21 +1524,21 @@ void TIGLCreatorDocument::removeWingFlaps(const QString& Uid) if (auto& teds = cs.GetControlSurfaces()->GetTrailingEdgeDevices()) { for (auto& ted : teds->GetTrailingEdgeDevices()) { - auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(ted->GetUID()); + auto objs = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(ted->GetUID()); // remove flap shapes for (auto& obj : objs) { app->getScene()->getContext()->Remove(obj, Standard_True); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } } } if (auto& leds = cs.GetControlSurfaces()->GetLeadingEdgeDevices()) { for (auto& led : leds->GetLeadingEdgeDevices()) { - auto objs = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(led->GetUID()); + auto objs = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(led->GetUID()); // remove flap shapes for (auto& obj : objs) { app->getScene()->getContext()->Remove(obj, Standard_True); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } } } @@ -1549,10 +1549,10 @@ void TIGLCreatorDocument::removeFuselage(const QString& Uid) { tigl::CCPACSFuselage& fuselage = GetConfiguration().GetFuselage(Uid.toStdString()); - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(fuselage.GetUID()); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(fuselage.GetUID()); for (auto& obj : objects) { app->getScene()->getContext()->Remove(obj, Standard_False); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } } @@ -1572,7 +1572,7 @@ void TIGLCreatorDocument::drawFuselage(const QString& Uid) for (int i = 1; i <= fuselage.GetSegmentCount(); i++) { // Draw segment loft auto& segment = (tigl::CCPACSFuselageSegment&)fuselage.GetSegment(i); - app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(segment.GetLoft(), m_docId, true, getDefaultShapeColor()); } } @@ -1613,8 +1613,8 @@ void TIGLCreatorDocument::drawFuselageTriangulation(const QString& Uid) TopoDS_Compound triangulation; createShapeTriangulation(fusedFuselage, triangulation); - auto shape = app->getScene()->displayShape(triangulation, true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), shape); + auto shape = app->getScene()->displayShape(triangulation, m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(fuselageUid.toStdString(), shape); } void TIGLCreatorDocument::drawWingSamplePoints(const QString& Uid) @@ -1657,8 +1657,8 @@ void TIGLCreatorDocument::drawFuselageSamplePoints(const QString& Uid) 1, // TODO: we need to implement that function to use UID instead of index! segmentIndex, eta, zeta, &x, &y, &z); - auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", false, 0, 0, 0, 1.0); - app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), points); + auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, false, 0, 0, 0, 1.0); + app->getScene()->GetShapeManager(m_docId).addObject(fuselageUid.toStdString(), points); } } } @@ -1692,13 +1692,13 @@ void TIGLCreatorDocument::drawFuselageSamplePointsAngle(const QString& Uid) for (int i = 1; i <= fuselage.GetSegmentCount(); i++) { auto& segment = (tigl::CCPACSFuselageSegment&)fuselage.GetSegment(i); - app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(segment.GetLoft(), m_docId, true, getDefaultShapeColor()); // Display the intersection point tiglFuselageGetPointAngle(m_cpacsHandle, fuselageIndex, i, 0.5, angle, &x, &y, &z); - auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); - app->getScene()->GetShapeManager().addObject(fuselageUid.toStdString(), points); + auto points = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager(m_docId).addObject(fuselageUid.toStdString(), points); } app->getScene()->updateViewer(); } @@ -1706,7 +1706,7 @@ void TIGLCreatorDocument::drawFuselageSamplePointsAngle(const QString& Uid) void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() { START_COMMAND() - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); // Draw all wings for (int wingIndex = 1; wingIndex <= GetConfiguration().GetWingCount(); wingIndex++) { @@ -1715,7 +1715,7 @@ void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() continue; } - app->getScene()->displayShape(wing.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(wing.GetLoft(), m_docId, true, getDefaultShapeColor()); for (int segmentIndex = 1; segmentIndex <= wing.GetSegmentCount(); segmentIndex++) { for (double eta = 0.0; eta <= 1.0; eta += 0.1) { @@ -1723,11 +1723,11 @@ void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() double x, y, z; tiglWingGetUpperPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0, 0, 0, 1.); + app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0, 0, 0, 1.); tiglWingGetLowerPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0, 0, 0, 1.); + app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0, 0, 0, 1.); } } } @@ -1738,7 +1738,7 @@ void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() for (int fuselageIndex = 1; fuselageIndex <= GetConfiguration().GetFuselageCount(); fuselageIndex++) { auto& fuselage = GetConfiguration().GetFuselage(fuselageIndex); - app->getScene()->displayShape(fuselage.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(fuselage.GetLoft(), m_docId, true, getDefaultShapeColor()); for (int segmentIndex = 1; segmentIndex <= fuselage.GetSegmentCount(); segmentIndex++) { // Draw some points on the fuselage segment @@ -1747,7 +1747,7 @@ void TIGLCreatorDocument::drawAllFuselagesAndWingsSurfacePoints() double x, y, z; tiglFuselageGetPoint(m_cpacsHandle, fuselageIndex, segmentIndex, eta, zeta, &x, &y, &z); - app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0, 0, 0, 1.); + app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0, 0, 0, 1.); } } } @@ -2317,7 +2317,7 @@ void TIGLCreatorDocument::drawFusedFuselage(const QString& Uid) START_COMMAND() removeFuselage(fuselageUid); auto& fuselage = GetConfiguration().GetFuselage(fuselageUid.toStdString()); - app->getScene()->displayShape(fuselage.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(fuselage.GetLoft(), m_docId, true, getDefaultShapeColor()); } void TIGLCreatorDocument::drawFusedWing(const QString& Uid) @@ -2359,7 +2359,7 @@ void TIGLCreatorDocument::drawFusedAircraft() return; } - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); ListPNamedShape map = GroupFaces(airplane, tigl::NAMED_COMPOUNDS); ListPNamedShape::iterator it; @@ -2373,7 +2373,7 @@ void TIGLCreatorDocument::drawFusedAircraft() } PNamedShape shape = *it; if (shape) { - app->getScene()->displayShape(shape, true, colors[icol++]); + app->getScene()->displayShape(shape, m_docId, true, colors[icol++]); } } @@ -2398,11 +2398,11 @@ void TIGLCreatorDocument::drawFusedAircraftTriangulation() { START_COMMAND() TopoDS_Shape airplane = GetConfiguration().AircraftFusingAlgo()->FusedPlane()->Shape(); - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); TopoDS_Compound triangulation; createShapeTriangulation(airplane, triangulation); - app->getScene()->displayShape(triangulation, true, getDefaultShapeColor()); + app->getScene()->displayShape(triangulation, m_docId, true, getDefaultShapeColor()); } void TIGLCreatorDocument::drawIntersectionLine() @@ -2476,12 +2476,12 @@ void TIGLCreatorDocument::drawIntersectionLine() } // load first wire for (int wireID = 1; wireID <= Intersector->GetCountIntersectionLines(); ++wireID) { - app->getScene()->displayShape(Intersector->GetWire(wireID), true, getDefaultShapeColor()); + app->getScene()->displayShape(Intersector->GetWire(wireID), m_docId, true, getDefaultShapeColor()); /* now calculate intersection and display single points */ for (double eta = 0.0; eta <= 1.0; eta += 0.025) { gp_Pnt point = Intersector->GetPoint(eta, wireID); - app->getScene()->displayPoint(point, "", Standard_False, 0, 0, 0, 1); + app->getScene()->displayPoint(point, "", m_docId, Standard_False, 0, 0, 0, 1); } } app->getScene()->updateViewer(); @@ -2500,23 +2500,23 @@ void TIGLCreatorDocument::drawWingComponentSegment(const QString& Uid) auto& cs = GetConfiguration().GetUIDManager().ResolveObject(csUid.toStdString()); - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(Uid.toStdString()); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(Uid.toStdString()); for (auto& obj : objects) { app->getScene()->getContext()->Remove(obj, Standard_False); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } removeWingFlaps(Uid); tigl::CCPACSWing& wing = GetConfiguration().GetWing(Uid.toStdString()); // display component segment shape with transparency - auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(Uid.toStdString(), cs_shape); + auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(Uid.toStdString(), cs_shape); PNamedShape mirroredLoft = wing.GetMirroredLoft(cs.GetLoft()); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); - app->getScene()->GetShapeManager().addObject(Uid.toStdString(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager(m_docId).addObject(Uid.toStdString(), shape); } @@ -2600,23 +2600,23 @@ void TIGLCreatorDocument::drawWingStructure(const QString& Uid) return; } - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(WingUid.toStdString()); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(WingUid.toStdString()); for (auto& obj : objects) { app->getScene()->getContext()->Remove(obj, Standard_False); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } removeWingFlaps(WingUid); tigl::CCPACSWing& wing = GetConfiguration().GetWing(WingUid.toStdString()); // display component segment shape with transparency - auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), true, Quantity_NOC_ShapeCol, 0.5); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), cs_shape); + auto cs_shape = app->getScene()->displayShape(cs.GetLoft(), m_docId, true, Quantity_NOC_ShapeCol, 0.5); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), cs_shape); PNamedShape mirroredLoft = wing.GetMirroredLoft(cs.GetLoft()); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_ShapeCol, 0.5); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, Quantity_NOC_ShapeCol, 0.5); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), shape); } @@ -2626,15 +2626,15 @@ void TIGLCreatorDocument::drawWingStructure(const QString& Uid) for (int ispar = 1; ispar <= structure.GetSparSegmentCount(); ++ispar) { const tigl::CCPACSWingSparSegment& spar = structure.GetSparSegment(ispar); TopoDS_Shape sparGeom = spar.GetSparGeometry(); - auto spar_shape = app->getScene()->displayShape(sparGeom, true, Quantity_NOC_RED); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), spar_shape); + auto spar_shape = app->getScene()->displayShape(sparGeom, m_docId, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), spar_shape); PNamedShape loftNamed(new CNamedShape(sparGeom, WingUid.toStdString())); PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_RED); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), shape); } } @@ -2643,16 +2643,16 @@ void TIGLCreatorDocument::drawWingStructure(const QString& Uid) for (int irib = 1; irib <= structure.GetRibsDefinitionCount(); ++irib) { const tigl::CCPACSWingRibsDefinition& rib = structure.GetRibsDefinition(irib); TopoDS_Shape ribGeom = rib.GetRibsGeometry(); - auto rib_shape = app->getScene()->displayShape(ribGeom, true, Quantity_NOC_RED); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), rib_shape); + auto rib_shape = app->getScene()->displayShape(ribGeom, m_docId, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), rib_shape); PNamedShape loftNamed(new CNamedShape(ribGeom, WingUid.toStdString())); tigl::CCPACSWing& wing = GetConfiguration().GetWing(WingUid.toStdString()); PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, Quantity_NOC_RED); - app->getScene()->GetShapeManager().addObject(WingUid.toStdString(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, Quantity_NOC_RED); + app->getScene()->GetShapeManager(m_docId).addObject(WingUid.toStdString(), shape); } } @@ -2690,11 +2690,10 @@ void TIGLCreatorDocument::drawSystems() tigl::CCPACSGenericSystem& genericSystem = GetConfiguration().GetGenericSystem(gs); try { - app->getScene()->displayShape(genericSystem.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(genericSystem.GetLoft(), m_docId, true, getDefaultShapeColor()); if (genericSystem.GetSymmetryAxis() != TIGL_NO_SYMMETRY) { - app->getScene()->displayShape(genericSystem.GetMirroredLoft()->Shape(), true, - getDefaultShapeSymmetryColor()); + app->getScene()->displayShape(genericSystem.GetMirroredLoft()->Shape(), m_docId, true, getDefaultShapeSymmetryColor()); } } catch (const tigl::CTiglError& err) { @@ -2918,22 +2917,22 @@ void TIGLCreatorDocument::drawRotorByUID(const QString& uid) START_COMMAND() tigl::CCPACSRotor& rotor = GetConfiguration().GetRotor(rotorUid.toStdString()); - if (!app->getScene()->GetShapeManager().HasShapeEntry(rotorUid.toStdString())) { + if (!app->getScene()->GetShapeManager(m_docId).HasShapeEntry(rotorUid.toStdString())) { // Draw segment loft - app->getScene()->displayShape(rotor.GetLoft(), true, Quantity_NOC_RotorCol); + app->getScene()->displayShape(rotor.GetLoft(), m_docId, true, Quantity_NOC_RotorCol); // Draw rotor disk TopoDS_Shape rotorDisk = rotor.GetRotorDisk()->Shape(); - auto shape = app->getScene()->displayShape(rotorDisk, true, Quantity_NOC_RotorCol, 0.9); - app->getScene()->GetShapeManager().addObject(rotorUid.toStdString(), shape); + auto shape = app->getScene()->displayShape(rotorDisk, m_docId, true, Quantity_NOC_RotorCol, 0.9); + app->getScene()->GetShapeManager(m_docId).addObject(rotorUid.toStdString(), shape); if (rotor.GetSymmetryAxis() == TIGL_NO_SYMMETRY) { return; } // Draw mirrored rotor - shape = app->getScene()->displayShape(rotor.GetMirroredLoft()->Shape(), false, Quantity_NOC_MirrRotorCol); - app->getScene()->GetShapeManager().addObject(rotorUid.toStdString(), shape); + shape = app->getScene()->displayShape(rotor.GetMirroredLoft()->Shape(), m_docId, false, Quantity_NOC_MirrRotorCol); + app->getScene()->GetShapeManager(m_docId).addObject(rotorUid.toStdString(), shape); // Draw mirrored rotor disk gp_Ax2 mirrorPlane; @@ -2951,11 +2950,11 @@ void TIGLCreatorDocument::drawRotorByUID(const QString& uid) BRepBuilderAPI_Transform myBRepTransformation(rotorDisk, theTransformation); const TopoDS_Shape& mirrRotorDisk = myBRepTransformation.Shape(); - shape = app->getScene()->displayShape(mirrRotorDisk, true, Quantity_NOC_MirrRotorCol, 0.9); - app->getScene()->GetShapeManager().addObject(rotorUid.toStdString(), shape); + shape = app->getScene()->displayShape(mirrRotorDisk, m_docId, true, Quantity_NOC_MirrRotorCol, 0.9); + app->getScene()->GetShapeManager(m_docId).addObject(rotorUid.toStdString(), shape); } else { - IObjectList objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName(rotorUid.toStdString()); + IObjectList objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName(rotorUid.toStdString()); for (auto& obj : objects) { app->getScene()->getContext()->Display(obj, Standard_False); } @@ -2972,7 +2971,7 @@ void TIGLCreatorDocument::drawRotor() } //clear screen - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); drawRotorByUID(rotorUid); } @@ -2990,11 +2989,11 @@ void TIGLCreatorDocument::drawRotorDisk(const QString& uid) START_COMMAND() //clear screen - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); // Draw rotor disk TopoDS_Shape rotorDisk = rotor.GetRotorDisk()->Shape(); - app->getScene()->displayShape(rotorDisk, true, Quantity_NOC_RotorCol, 0.9); + app->getScene()->displayShape(rotorDisk, m_docId, true, Quantity_NOC_RotorCol, 0.9); } void TIGLCreatorDocument::showRotorProperties(const QString& uid) @@ -3085,12 +3084,12 @@ Quantity_Color TIGLCreatorDocument::getDefaultShapeSymmetryColor() */ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) { - displayedShapeNames = app->getScene()->GetShapeManager().GetDisplayedShapeNames(); - app->getScene()->deleteAllObjects(); + displayedShapeNames = app->getScene()->GetShapeManager(m_docId).GetDisplayedShapeNames(); + app->getScene()->deleteObjectsOfDocument(m_docId); TopoDS_Wire wire = profile.GetWire(); - auto WireObj = app->getScene()->displayShape(wire, true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(std::string("airfoil"), WireObj); + auto WireObj = app->getScene()->displayShape(wire, m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(std::string("airfoil"), WireObj); // Leading/trailing edges gp_Pnt lePoint = profile.GetLEPoint(); @@ -3098,10 +3097,10 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) std::ostringstream text; text << "LE(" << lePoint.X() << ", " << lePoint.Y() << ", " << lePoint.Z() << ")"; - app->getScene()->displayPoint(lePoint, const_cast(text.str().c_str()), Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->displayPoint(lePoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); text << "TE(" << tePoint.X() << ", " << tePoint.Y() << ", " << tePoint.Z() << ")"; - app->getScene()->displayPoint(tePoint, const_cast(text.str().c_str()), Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->displayPoint(tePoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); gp_Lin gpline = gce_MakeLin(lePoint, tePoint); @@ -3111,7 +3110,7 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) if (length > 0.0) { Handle(Geom_TrimmedCurve) trimmedLine = GC_MakeSegment(gpline, -length * 0.2, length * 1.2); TopoDS_Edge le_te_edge = BRepBuilderAPI_MakeEdge(trimmedLine); - app->getScene()->displayShape(le_te_edge, true, getDefaultShapeSymmetryColor()); + app->getScene()->displayShape(le_te_edge, m_docId, true, getDefaultShapeSymmetryColor()); } // display points in case of a few sample points @@ -3122,7 +3121,7 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) std::stringstream str; str << i << ": (" << p.x << ", " << p.y << ", " << p.z << ")"; gp_Pnt pnt = p.Get_gp_Pnt(); - app->getScene()->displayPoint(pnt, str.str().c_str(), Standard_False, 0., 0., 0., 6.); + app->getScene()->displayPoint(pnt, str.str().c_str(), m_docId, Standard_False, 0., 0., 0., 6.); } } else { @@ -3132,8 +3131,7 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) gp_Pnt chordPoint = profile.GetChordPoint(xsi); text << "CPT(" << xsi << ")"; text << "(" << chordPoint.X() << ", " << chordPoint.Y() << ", " << chordPoint.Z() << ")"; - app->getScene()->displayPoint(chordPoint, const_cast(text.str().c_str()), Standard_False, 0.0, - 0.0, 0.0, 2.0); + app->getScene()->displayPoint(chordPoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); } catch (tigl::CTiglError& ex) { @@ -3150,8 +3148,7 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) gp_Pnt upperPoint = profile.GetUpperPoint(xsi); text << "UPT(" << xsi << ")"; text << "(" << upperPoint.X() << ", " << upperPoint.Y() << ", " << upperPoint.Z() << ")"; - app->getScene()->displayPoint(upperPoint, const_cast(text.str().c_str()), Standard_False, 0.0, - 0.0, 0.0, 2.0); + app->getScene()->displayPoint(upperPoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); } catch (tigl::CTiglError& ex) { @@ -3168,8 +3165,7 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) gp_Pnt lowerPoint = profile.GetLowerPoint(xsi); text << "LPT(" << xsi << ")"; text << "(" << lowerPoint.X() << ", " << lowerPoint.Y() << ", " << lowerPoint.Z() << ")"; - app->getScene()->displayPoint(lowerPoint, const_cast(text.str().c_str()), Standard_False, 0.0, - 0.0, 0.0, 2.0); + app->getScene()->displayPoint(lowerPoint, const_cast(text.str().c_str()), m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); text.str(""); } catch (tigl::CTiglError& ex) { @@ -3191,15 +3187,15 @@ void TIGLCreatorDocument::drawAirfoil(tigl::CCPACSWingProfile& profile) void TIGLCreatorDocument::removeAirfoil() { - auto objects = app->getScene()->GetShapeManager().GetIObjectsFromShapeName("airfoil"); + auto objects = app->getScene()->GetShapeManager(m_docId).GetIObjectsFromShapeName("airfoil"); for (auto& obj : objects) { app->getScene()->getContext()->Remove(obj, Standard_False); - app->getScene()->GetShapeManager().removeObject(obj); + app->getScene()->GetShapeManager(m_docId).removeObject(obj); } if (!objects.empty()) { - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); for (const auto& name : displayedShapeNames) { drawComponentByUID(QString::fromStdString(name)); } @@ -3234,8 +3230,8 @@ void TIGLCreatorDocument::drawWingOverlayProfilePoints(tigl::CCPACSWing& wing) gp_Pnt pnt = j.Get_gp_Pnt(); pnt = innerT.Transform(pnt); - auto point = app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); + auto point = app->getScene()->displayPoint(pnt, "", m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), point); } // Get outer profile point list @@ -3253,8 +3249,8 @@ void TIGLCreatorDocument::drawWingOverlayProfilePoints(tigl::CCPACSWing& wing) gp_Pnt pnt = j.Get_gp_Pnt(); pnt = outerT.Transform(pnt); - auto point = app->getScene()->displayPoint(pnt, "", Standard_False, 0.0, 0.0, 0.0, 2.0); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); + auto point = app->getScene()->displayPoint(pnt, "", m_docId, Standard_False, 0.0, 0.0, 0.0, 2.0); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), point); } } app->getScene()->updateViewer(); @@ -3267,11 +3263,11 @@ void TIGLCreatorDocument::drawWing(tigl::CCPACSWing& wing) { START_COMMAND() - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); for (int i = 1; i <= wing.GetSegmentCount(); i++) { // Draw segment loft - app->getScene()->displayShape(wing.GetSegment(i).GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(wing.GetSegment(i).GetLoft(), m_docId, true, getDefaultShapeColor()); } } @@ -3291,15 +3287,15 @@ void TIGLCreatorDocument::drawWingTriangulation(tigl::CCPACSWing& wing) TopoDS_Compound compound; createShapeTriangulation(fusedWing, compound); - auto shape = app->getScene()->displayShape(compound, true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(compound, m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); PNamedShape loftNamed(new CNamedShape(compound, wing.GetUID().c_str())); PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); } app->getScene()->updateViewer(); } @@ -3331,14 +3327,14 @@ void TIGLCreatorDocument::drawWingSamplePoints(tigl::CCPACSWing& wing) // Draw segment loft auto& segment = (tigl::CCPACSWingSegment&)wing.GetSegment(segmentIndex); - auto shape = app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(segment.GetLoft(), m_docId, true, getDefaultShapeColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); PNamedShape mirroredLoft = wing.GetMirroredLoft(segment.GetLoft()); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, getDefaultShapeSymmetryColor()); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, getDefaultShapeSymmetryColor()); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); } @@ -3348,13 +3344,13 @@ void TIGLCreatorDocument::drawWingSamplePoints(tigl::CCPACSWing& wing) double x, y, z; tiglWingGetUpperPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - auto point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); + auto point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), point); tiglWingGetLowerPoint(m_cpacsHandle, wingIndex, segmentIndex, eta, xsi, &x, &y, &z); - point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", Standard_False, 0., 0., 0., 1.); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), point); + point = app->getScene()->displayPoint(gp_Pnt(x, y, z), "", m_docId, Standard_False, 0., 0., 0., 1.); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), point); } } } @@ -3367,8 +3363,8 @@ void TIGLCreatorDocument::drawWingSamplePoints(tigl::CCPACSWing& wing) void TIGLCreatorDocument::drawFusedWing(tigl::CCPACSWing& wing) { START_COMMAND() - app->getScene()->deleteAllObjects(); - app->getScene()->displayShape(wing.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->deleteObjectsOfDocument(m_docId); + app->getScene()->displayShape(wing.GetLoft(), m_docId, true, getDefaultShapeColor()); } /* @@ -3377,9 +3373,9 @@ void TIGLCreatorDocument::drawFusedWing(tigl::CCPACSWing& wing) void TIGLCreatorDocument::drawWingComponentSegment(tigl::CCPACSWingComponentSegment& segment) { START_COMMAND() - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); - app->getScene()->displayShape(segment.GetLoft(), true, getDefaultShapeColor()); + app->getScene()->displayShape(segment.GetLoft(), m_docId, true, getDefaultShapeColor()); } /* @@ -3414,7 +3410,7 @@ void TIGLCreatorDocument::drawWingComponentSegmentPoint(const std::string& csUID TiglReturnCode ret = tiglWingComponentSegmentGetPoint(getCpacsHandle(), csUID.c_str(), eta, xsi, &x, &y, &z); if (ret == TIGL_SUCCESS) { gp_Pnt point(x, y, z); - app->getScene()->displayPoint(point, "", Standard_True, 0, 0, 0, 1.0); + app->getScene()->displayPoint(point, "", m_docId, Standard_True, 0, 0, 0, 1.0); } else { displayError(QString("Error in tiglWingComponentSegmentPointGetPoint. ReturnCode: %1").arg(ret), @@ -3437,14 +3433,14 @@ void TIGLCreatorDocument::drawWingShells(tigl::CCPACSWing& wing) Quantity_NameOfColor colors[2] = {Quantity_NOC_GREEN, Quantity_NOC_RED}; for (int i = 0; i < 2; ++i) { - auto shape = app->getScene()->displayShape(shapes[i], true, colors[i]); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(shapes[i], m_docId, true, colors[i]); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); PNamedShape loftNamed(new CNamedShape(shapes[i], wing.GetUID().c_str())); PNamedShape mirroredLoft = wing.GetMirroredLoft(loftNamed); if (mirroredLoft) { - auto shape = app->getScene()->displayShape(mirroredLoft, true, colors[i]); - app->getScene()->GetShapeManager().addObject(wing.GetUID(), shape); + auto shape = app->getScene()->displayShape(mirroredLoft, m_docId, true, colors[i]); + app->getScene()->GetShapeManager(m_docId).addObject(wing.GetUID(), shape); } } app->getScene()->getViewer()->Update(); @@ -3517,7 +3513,7 @@ void TIGLCreatorDocument::updateCpacsConfigurationFromString(const std::string& tiglCloseCPACSConfiguration(m_cpacsHandle); m_cpacsHandle = -1; - app->getScene()->deleteAllObjects(); + app->getScene()->deleteObjectsOfDocument(m_docId); QStringList configurations; app->getScene()->getContext()->SetDisplayMode(AIS_Shaded, Standard_False); diff --git a/TIGLCreator/src/TIGLCreatorDocument.h b/TIGLCreator/src/TIGLCreatorDocument.h index 38c5a5ff57..d7e00ad94f 100644 --- a/TIGLCreator/src/TIGLCreatorDocument.h +++ b/TIGLCreator/src/TIGLCreatorDocument.h @@ -26,6 +26,7 @@ #include "TIGLCreator.h" #include "CCPACSConfiguration.h" #include "TIGLCreatorContext.h" +#include "DocumentId.h" #include @@ -42,9 +43,13 @@ class TIGLCreatorDocument : public QObject public: - explicit TIGLCreatorDocument(TIGLCreatorWindow *parentWidget); + explicit TIGLCreatorDocument(TIGLCreatorWindow *parentWidget, DocumentId docId); ~TIGLCreatorDocument( ) override; + // Identifies this document's shapes in the shared 3D scene (see + // TIGLCreatorContext::GetShapeManager/deleteObjectsOfDocument). + DocumentId docId() const { return m_docId; } + TiglReturnCode openCpacsConfigurationFromFile(const QString& fileName, const QString& config_uid=""); TiglReturnCode openCpacsConfigurationFromString(const std::string cpacsFileContent, const QString& config_uid=""); // Empty fileName as default value if the function is called from openCpacsConfigurationFromFile => No fileName exists @@ -183,8 +188,9 @@ private slots: QString dlgGetFuselageSegmentSelection(); QString dlgGetFuselageProfileSelection(); -private: +private: TiglCPACSConfigurationHandle m_cpacsHandle; + DocumentId m_docId; TIGLCreatorWindow* app; QString loadedConfigurationFileName; TIGLCreatorContext* myScene; diff --git a/TIGLCreator/src/TIGLCreatorInputoutput.cpp b/TIGLCreator/src/TIGLCreatorInputoutput.cpp index 2383999ddc..45a8a572ef 100644 --- a/TIGLCreator/src/TIGLCreatorInputoutput.cpp +++ b/TIGLCreator/src/TIGLCreatorInputoutput.cpp @@ -38,7 +38,8 @@ bool TIGLCreatorInputOutput::importModel( const QString& fileName, const FileFormat format, - TIGLCreatorContext& scene ) + TIGLCreatorContext& scene, + DocumentId docId ) { QApplication::setOverrideCursor( Qt::WaitCursor ); @@ -51,14 +52,15 @@ bool TIGLCreatorInputOutput::importModel( const QString& fileName, } for ( int i = 1; i <= shapes->Length(); i++ ) { - scene.displayShape(shapes->Value(i), true); + scene.displayShape(shapes->Value(i), docId, true); } return true; } bool TIGLCreatorInputOutput::importTriangulation( const QString& fileName, const FileFormat format, - TIGLCreatorContext& scene ) + TIGLCreatorContext& scene, + DocumentId docId ) { Handle(AIS_InteractiveContext) ic = scene.getContext(); Handle(Poly_Triangulation) triangulation; @@ -90,6 +92,7 @@ bool TIGLCreatorInputOutput::importTriangulation( const QString& fileName, shape->SetDisplayMode(AIS_Shaded); ic->Display(shape,Standard_False); ic->UpdateCurrentViewer(); + scene.trackDisplayedObject(docId, shape); return true; } diff --git a/TIGLCreator/src/TIGLCreatorInputoutput.h b/TIGLCreator/src/TIGLCreatorInputoutput.h index b5e8da52fb..096660581f 100644 --- a/TIGLCreator/src/TIGLCreatorInputoutput.h +++ b/TIGLCreator/src/TIGLCreatorInputoutput.h @@ -24,6 +24,7 @@ #include #include "TIGLCreator.h" #include "TIGLCreatorContext.h" +#include "DocumentId.h" #include class TIGLCreatorWidget; @@ -47,12 +48,14 @@ class TIGLCreatorInputOutput : public QObject ~TIGLCreatorInputOutput() override = default; bool importModel( const QString& fileName, - const FileFormat format, - TIGLCreatorContext& scene ); + const FileFormat format, + TIGLCreatorContext& scene, + DocumentId docId ); bool importTriangulation( const QString& fileName, const FileFormat format, - TIGLCreatorContext& scene ); + TIGLCreatorContext& scene, + DocumentId docId ); bool exportModel( const QString& fileName, const FileFormat format, diff --git a/TIGLCreator/src/TIGLCreatorWidget.cpp b/TIGLCreator/src/TIGLCreatorWidget.cpp index 660c31083a..3072d42dd0 100644 --- a/TIGLCreator/src/TIGLCreatorWidget.cpp +++ b/TIGLCreator/src/TIGLCreatorWidget.cpp @@ -865,7 +865,7 @@ void TIGLCreatorWidget::onLeftButtonUp( Qt::KeyboardModifiers nFlags, const QPo if (!shape.IsNull()) { - auto cnamedShape = viewerContext->GetShapeManager().GetShapeFromIObject(shape); + auto cnamedShape = viewerContext->GetShapeFromIObject(shape); if (cnamedShape) { auto shapeName = cnamedShape->Name(); diff --git a/TIGLCreator/src/TIGLCreatorWindow.cpp b/TIGLCreator/src/TIGLCreatorWindow.cpp index 7bac4c157a..d1d6afbf2b 100644 --- a/TIGLCreator/src/TIGLCreatorWindow.cpp +++ b/TIGLCreator/src/TIGLCreatorWindow.cpp @@ -343,7 +343,7 @@ void TIGLCreatorWindow::closeConfiguration() treeWidget->refresh(); if (cpacsConfiguration) { - getScene()->deleteAllObjects(); + getScene()->deleteObjectsOfDocument(myDocId); delete cpacsConfiguration; cpacsConfiguration = nullptr; } @@ -352,7 +352,7 @@ void TIGLCreatorWindow::closeConfiguration() setCurrentFile(""); undoStack->clear(); // when the document is closed, we remove all undo - getScene()->GetShapeManager().clear(); + getScene()->GetShapeManager(myDocId).clear(); } void TIGLCreatorWindow::setTiglWindowTitle(const QString &title, bool forceTitle) @@ -393,7 +393,7 @@ void TIGLCreatorWindow::openFile(const QString& fileName, const QString& config_ fileType = fileInfo.suffix(); if (fileType.toLower() == tr("xml")) { - TIGLCreatorDocument* config = new TIGLCreatorDocument(this); + TIGLCreatorDocument* config = new TIGLCreatorDocument(this, myDocId); TiglReturnCode tiglRet = config->openCpacsConfigurationFromFile(fileInfo.absoluteFilePath(), config_uid); @@ -430,10 +430,10 @@ void TIGLCreatorWindow::openFile(const QString& fileName, const QString& config_ triangulation = true; } if (triangulation) { - success = reader.importTriangulation( fileInfo.absoluteFilePath(), format, *getScene() ); + success = reader.importTriangulation( fileInfo.absoluteFilePath(), format, *getScene(), myDocId ); } else { - success = reader.importModel ( fileInfo.absoluteFilePath(), format, *getScene() ); + success = reader.importModel ( fileInfo.absoluteFilePath(), format, *getScene(), myDocId ); } } @@ -451,12 +451,12 @@ void TIGLCreatorWindow::openFile(const QString& fileName, const QString& config_ void TIGLCreatorWindow::reopenFile() { if (currentFile.suffix().toLower() == tr("xml")){ - std::vector displayedShapeNames = getScene()->GetShapeManager().GetDisplayedShapeNames(); - + std::vector displayedShapeNames = getScene()->GetShapeManager(myDocId).GetDisplayedShapeNames(); + modificatorModel->setCPACSConfiguration(nullptr); cpacsConfiguration->updateConfiguration(); modificatorModel->setCPACSConfiguration(cpacsConfiguration); - getScene()->deleteAllObjects(); + getScene()->deleteObjectsOfDocument(myDocId); for (const auto& name : displayedShapeNames) { cpacsConfiguration->drawComponentByUID(QString::fromStdString(name)); } @@ -500,7 +500,7 @@ void TIGLCreatorWindow::openNewFile(const QString& templatePath) // Read CPACS template file content into string and open the CPACS configuration from that std::string cpacsFileContent = readFileContent(strdup((const char*)templatePath.toLatin1())); - TIGLCreatorDocument* config = new TIGLCreatorDocument(this); + TIGLCreatorDocument* config = new TIGLCreatorDocument(this, myDocId); TiglReturnCode tiglRet = config->openCpacsConfigurationFromString(cpacsFileContent); if (tiglRet != TIGL_SUCCESS) { delete config; @@ -1074,7 +1074,7 @@ void TIGLCreatorWindow::onComponentVisibilityChanged(const QString& uid, bool vi cpacsConfiguration->drawComponentByUID(uid); } else { - auto& shapeManager = myScene->GetShapeManager(); + auto& shapeManager = myScene->GetShapeManager(cpacsConfiguration->docId()); if (shapeManager .HasShapeEntry(uid.toStdString())) { auto objs = shapeManager .GetIObjectsFromShapeName(uid.toStdString()); for (auto& obj : objs) { @@ -1286,7 +1286,7 @@ void TIGLCreatorWindow::drawPoint() gp_Pnt point = dialog.getPoint().Get_gp_Pnt(); std::stringstream stream; stream << "(" << point.X() << ", " << point.Y() << ", " << point.Z() << ")"; - getScene()->displayPoint(point, stream.str().c_str(), Standard_True, 0, 0, 0, 1.); + getScene()->displayPoint(point, stream.str().c_str(), InvalidDocumentId, Standard_True, 0, 0, 0, 1.); } void TIGLCreatorWindow::drawVector() @@ -1301,12 +1301,12 @@ void TIGLCreatorWindow::drawVector() gp_Vec dir = dialog.getDirection().Get_gp_Pnt().XYZ(); std::stringstream stream; stream << "(" << point.X() << ", " << point.Y() << ", " << point.Z() << ")"; - getScene()->displayVector(point, dir, stream.str().c_str(), Standard_True, 0,0,0, 1.); + getScene()->displayVector(point, dir, stream.str().c_str(), InvalidDocumentId, Standard_True, 0,0,0, 1.); } void TIGLCreatorWindow::updateScene() { - myScene->deleteAllObjects(); + myScene->deleteObjectsOfDocument(cpacsConfiguration->docId()); cpacsConfiguration->drawConfiguration(); cpacsConfiguration->configurationModifiedSinceLastSave(); } diff --git a/TIGLCreator/src/TIGLCreatorWindow.h b/TIGLCreator/src/TIGLCreatorWindow.h index 063ffefe0d..7bc1f1fd72 100644 --- a/TIGLCreator/src/TIGLCreatorWindow.h +++ b/TIGLCreator/src/TIGLCreatorWindow.h @@ -155,6 +155,10 @@ private slots: QString myLastFolder; TIGLCreatorDocument* cpacsConfiguration; + // Identifies the (currently only) open document's shapes in the shared + // 3D scene. Used both by cpacsConfiguration and by imported non-CPACS + // geometry, which has no TIGLCreatorDocument of its own. + DocumentId myDocId{0}; QFileInfo currentFile; QString controlFileName; QString preferredTitle; diff --git a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp index 46be4d71be..234bb82dbe 100644 --- a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp +++ b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp @@ -127,7 +127,7 @@ void ModificatorDisplayOptionsWidget::setFromItem(cpcr::CPACSTreeItem* item, TIG } // get current values - auto &sm = context->GetShapeManager(); + auto &sm = context->GetShapeManager(currentDoc->docId()); if (sm.HasShapeEntry(uid.toStdString())) { auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); if (objs.empty()) { @@ -280,7 +280,7 @@ bool ModificatorDisplayOptionsWidget::apply() if (currentItem) { const QString uid = QString::fromStdString(currentItem->getUid()); if (!uid.isEmpty()) { - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); if (sm.HasShapeEntry(uid.toStdString())) { auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); @@ -358,7 +358,7 @@ void ModificatorDisplayOptionsWidget::onTransparencyChanged(int value) if (uid.isEmpty()) { return; } - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); if (!sm.HasShapeEntry(uid.toStdString()) && currentDoc) { currentDoc->drawComponentByUID(uid); } @@ -403,7 +403,7 @@ void ModificatorDisplayOptionsWidget::onRenderingModeChanged(int displayMode) if (uid.isEmpty()) { return; } - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); for (auto &obj : objs) { if (obj.IsNull()) { @@ -429,7 +429,7 @@ void ModificatorDisplayOptionsWidget::onColorChosen() } QColor initial; const QString uid = QString::fromStdString(currentItem->getUid()); - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); if (!objs.empty()) { @@ -484,7 +484,7 @@ void ModificatorDisplayOptionsWidget::onMaterialChanged(const QString &mat) if (uid.isEmpty()) { return; } - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); auto it = tiglMaterials::materialMap.find(mat); if (it == tiglMaterials::materialMap.end()) { @@ -516,7 +516,7 @@ void ModificatorDisplayOptionsWidget::onResetOptions() if (uid.isEmpty()) { return; } - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); auto objs = sm.GetIObjectsFromShapeName(uid.toStdString()); auto context = currentContext->getContext(); for (auto &obj : objs) { From a39489afc880ca2b80410ed61825aaf0ca17117e Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Wed, 22 Jul 2026 17:37:15 +0200 Subject: [PATCH 2/3] fix compiler error --- TIGLCreator/src/TIGLCreatorContext.cpp | 13 ++++++++++++- TIGLCreator/src/TIGLCreatorContext.h | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/TIGLCreator/src/TIGLCreatorContext.cpp b/TIGLCreator/src/TIGLCreatorContext.cpp index 29c4b26c89..cc38fcc33b 100644 --- a/TIGLCreator/src/TIGLCreatorContext.cpp +++ b/TIGLCreator/src/TIGLCreatorContext.cpp @@ -394,7 +394,7 @@ void TIGLCreatorContext::selectShape(const QString& uid) return; } - IObjectList iobjects = myShapeManager.GetIObjectsFromShapeName(uid.toStdString()); + IObjectList iobjects = GetIObjectsFromShapeName(uid.toStdString()); if (iobjects.empty()) { LOG(WARNING) << "TIGLCreatorContext::selectShape: No shape found for UID \"" << uid.toStdString() << "\"" << std::endl; return; @@ -728,6 +728,17 @@ PNamedShape TIGLCreatorContext::GetShapeFromIObject(const Handle(AIS_Shape)& obj return PNamedShape(); } +IObjectList TIGLCreatorContext::GetIObjectsFromShapeName(const std::string& name) const +{ + for (const auto& kv : myShapeManagers) { + IObjectList objects = kv.second.GetIObjectsFromShapeName(name); + if (!objects.empty()) { + return objects; + } + } + return IObjectList(); +} + Handle(AIS_InteractiveObject) TIGLCreatorContext::displayShapeHLMode(const TopoDS_Shape& loft, DocumentId docId, bool updateViewer, Quantity_Color color, double transparency) { diff --git a/TIGLCreator/src/TIGLCreatorContext.h b/TIGLCreator/src/TIGLCreatorContext.h index 3d75dc0339..133b675730 100644 --- a/TIGLCreator/src/TIGLCreatorContext.h +++ b/TIGLCreator/src/TIGLCreatorContext.h @@ -97,6 +97,12 @@ class TIGLCreatorContext : public QObject // document. PNamedShape GetShapeFromIObject(const Handle(AIS_Shape)& obj); + // Cross-document lookup: finds the interactive objects for a named + // shape, regardless of which open document owns it. Used by + // selectShape(), which (e.g. via the scripting console) has no + // document context of its own. + IObjectList GetIObjectsFromShapeName(const std::string& name) const; + // Function used to highlight (HL) shape (used by ModificatorManager) // display the shape using highlighting settings and return the AIS_InteractiveObject From 05b87274cea4c2ed05967c5175226a5c8a49d348 Mon Sep 17 00:00:00 2001 From: Jan Kleinert Date: Thu, 23 Jul 2026 12:53:41 +0200 Subject: [PATCH 3/3] Fix build: pass DocumentId to GetShapeManager() at two sites merged from main Commit aa9933bc0 (symmetry-toggle-sync, merged into this branch via bdb4c35cc) called the pre-PR1 no-arg GetShapeManager(), which no longer exists now that shape managers are scoped per document. --- TIGLCreator/src/TIGLCreatorDocument.cpp | 2 +- .../src/modificators/ModificatorDisplayOptionsWidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TIGLCreator/src/TIGLCreatorDocument.cpp b/TIGLCreator/src/TIGLCreatorDocument.cpp index 247c2e399a..42c25c2184 100644 --- a/TIGLCreator/src/TIGLCreatorDocument.cpp +++ b/TIGLCreator/src/TIGLCreatorDocument.cpp @@ -859,7 +859,7 @@ void TIGLCreatorDocument::drawComponentByUID(const QString& uid) } } } - bool symmetryVisible = app->getScene()->GetShapeManager().GetSymmetryVisible(uid.toStdString()); + bool symmetryVisible = app->getScene()->GetShapeManager(m_docId).GetSymmetryVisible(uid.toStdString()); for (std::size_t i = 0; i < objects.size(); ++i) { auto& obj = objects[i]; // objects[1], if present, is the mirrored/symmetry shape (see addObject() calls diff --git a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp index 2dd98dee42..c174379fff 100644 --- a/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp +++ b/TIGLCreator/src/modificators/ModificatorDisplayOptionsWidget.cpp @@ -612,7 +612,7 @@ void ModificatorDisplayOptionsWidget::onShowSymmetryToggled(bool checked) if (uid.isEmpty()) { return; } - auto &sm = currentContext->GetShapeManager(); + auto &sm = currentContext->GetShapeManager(currentDoc->docId()); // Persist the preference so it survives the mirrored shape being torn down and // re-created (e.g. by toggling this component's visibility in the CPACS tree). sm.SetSymmetryVisible(uid.toStdString(), checked);