From 96a86667a9ffe5128ffeb08720a9ced6f8b3954b Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 23 Dec 2019 14:57:39 +0300 Subject: [PATCH] Transfer BreakLink from Object to Gen --- src/SMESHGUI/SMESHGUI.cxx | 27 +++++++++++++++++++++++---- src/SMESHGUI/SMESHGUI_Selection.cxx | 23 +++++++++++++++++++---- src/SMESHGUI/SMESHGUI_Selection.h | 2 ++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 776e7653c..e70e976fa 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -172,6 +172,7 @@ #include #include #include "utilities.h" +#include // OCCT includes #include @@ -1392,7 +1393,8 @@ namespace if (selected.Extent()) { Handle(SALOME_InteractiveObject) anIObject = selected.First(); _PTR(Study) aStudy = SMESH::getStudy(); - _PTR(SObject) aSObj = aStudy->FindObjectID(anIObject->getEntry()); + std::string aEntry = anIObject->getEntry(); + _PTR(SObject) aSObj = aStudy->FindObjectID(aEntry); if (aSObj) { std::string aName = aSObj->GetName(); QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(), @@ -1400,9 +1402,26 @@ namespace QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()), SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No); if (aRes == SUIT_MessageBox::Yes) { - GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface(aSObj); - if (!aObject->_is_nil()) - aObject->BreakLinks(); + SUIT_DataOwnerPtrList aList; + aSel->selected(aList, "ObjectBrowser", true); + SUIT_DataOwner* aOwn = aList.first(); + LightApp_DataOwner* sowner = dynamic_cast(aOwn); + QString aREntry = sowner->entry(); + + static GEOM::GEOM_Gen_var geomGen; + if (CORBA::is_nil(geomGen)) { + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + if (app) { + SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService()); + Engines::EngineComponent_var comp = + ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY"); + geomGen = GEOM::GEOM_Gen::_narrow(comp); + } + } + if (!CORBA::is_nil(geomGen)) { + geomGen->BreakLink(aREntry.toStdString().c_str()); + } } } } diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index c79334554..ab4a1ca8e 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -43,6 +43,8 @@ #include #include #include +#include +#include // IDL includes #include @@ -77,6 +79,8 @@ void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr if( mgr ) { + myOwners.clear(); + mgr->selected(myOwners, client); for( int i=0, n=count(); i= 0 && ind < myTypes.count()) { - _PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() ); - GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface(aSObject); - if (!aObject->_is_nil()) - return aObject->IsParametrical(); + if (isReference(ind)) { + SUIT_DataOwner* aOwn = myOwners.at(ind); + LightApp_DataOwner* sowner = dynamic_cast(aOwn); + QString aEntry = sowner->entry(); + _PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID(aEntry.toStdString()); + _PTR(SObject) aFatherObj = aSObject->GetFather(); + _PTR(SComponent) aComponent = aFatherObj->GetFatherComponent(); + if (aComponent->ComponentDataType() == "SMESH") { + QString aObjEntry = entry(ind); + _PTR(SObject) aGeomSObject = SMESH::getStudy()->FindObjectID(aObjEntry.toStdString()); + GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface(aGeomSObject); + if (!aObject->_is_nil()) + return aObject->IsParametrical(); + } + } } return false; } diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 6ca2c0cb1..3ec17a9a8 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -32,6 +32,7 @@ // SALOME GUI includes #include +#include // SALOME KERNEL includes #include @@ -96,6 +97,7 @@ private: QStringList myTypes; QStringList myControls; QList myActors; + SUIT_DataOwnerPtrList myOwners; }; #endif // SMESHGUI_SELECTION_H -- 2.39.2