X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshOp.cxx;h=73d5aab8efa4a7a937226111bb5fb37829d82ca6;hb=824f011cef0dc8fee10a7eaca511e9f61690766b;hp=9ad1a47fc5ae4d4a5ae928f3d6d315ce80107e92;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 9ad1a47fc..73d5aab8e 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -40,6 +40,7 @@ #include #include #include +#include // SALOME GUI includes #include @@ -56,6 +57,8 @@ // SALOME KERNEL includes #include #include +#include +#include // Qt includes #include @@ -72,10 +75,6 @@ #include #include CORBA_CLIENT_HEADER(SMESH_Gen) -//To disable automatic genericobj management, the following line should be commented. -//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx -#define WITHGENERICOBJ - //================================================================================ /*! * \brief Constructor @@ -297,9 +296,9 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true ); } else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate ) - return new SMESH_TypeFilter( MESHorSUBMESH ); + return new SMESH_TypeFilter( SMESH::MESHorSUBMESH ); else if ( theId == SMESHGUI_MeshDlg::Mesh ) - return new SMESH_TypeFilter( MESH ); + return new SMESH_TypeFilter( SMESH::MESH ); else return 0; } @@ -336,8 +335,7 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); if (geomGen->_is_nil() || !aStudy) return false; - GEOM::GEOM_IGroupOperations_var op = - geomGen->GetIGroupOperations(aStudy->StudyId()); + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId()); if (op->_is_nil()) return false; // check all selected shapes @@ -352,18 +350,18 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const if (aSubGeomVar->_is_nil()) return false; // skl for NPAL14695 - implementation of searching of mainObj - GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); - //if (mainObj->_is_nil() || - // string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false; + GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as + mainObj already exists! */ while(1) { if (mainObj->_is_nil()) return false; - if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry())) + CORBA::String_var entry1 = mainObj->GetEntry(); + CORBA::String_var entry2 = mainGeom->GetEntry(); + if (std::string( entry1.in() ) == entry2.in() ) return true; mainObj = op->GetMainShape(mainObj); } } - //return true; } return false; @@ -896,7 +894,8 @@ void SMESHGUI_MeshOp::existingHyps( const int theDim, SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar ); if ( !aHypVar->_is_nil() ) { - HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() ); + CORBA::String_var hypType = aHypVar->GetName(); + HypothesisData* aData = SMESH::GetHypothesisData( hypType.in() ); if ( !aData) continue; if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) && ( isCompatible ( theAlgoData, aData, theHypType )) && @@ -1100,14 +1099,10 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim, // Call hypothesis creation server method (without GUI) SMESH::SMESH_Hypothesis_var aHyp = SMESH::CreateHypothesis(theTypeName, aHypName, false); -#ifdef WITHGENERICOBJ - if (!CORBA::is_nil(aHyp)) - aHyp->UnRegister(); -#endif - } else { + aHyp.out(); + } + else { // Get hypotheses creator client (GUI) - // BUG 0020378 - //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName); SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName); // Create hypothesis @@ -1176,10 +1171,7 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim, else { SMESH::SMESH_Hypothesis_var aHyp = SMESH::CreateHypothesis(theTypeName, aHypName, false); -#ifdef WITHGENERICOBJ - if (!CORBA::is_nil(aHyp)) - aHyp->UnRegister(); -#endif + aHyp.out(); } } @@ -1650,13 +1642,6 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList ) if ( !anAlgoVar->_is_nil() ) SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar ); } -#ifdef WITHGENERICOBJ - // obj has been published in study. Its refcount has been incremented. - // It is safe to decrement its refcount - // so that it will be destroyed when the entry in study will be removed - if (aMeshSO) - aMeshVar->UnRegister(); -#endif } return true; } @@ -1710,7 +1695,7 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); if (!geomGen->_is_nil() && aStudy) { - GEOM::GEOM_IGroupOperations_var op = + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(aStudy->StudyId()); if (!op->_is_nil()) { // check and add all selected GEOM objects: they must be @@ -1735,18 +1720,20 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList aSeq[iSubSh] = aSubGeomVar; } // create a group - GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType); + GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(mainGeom, aGroupType); op->UnionList(aGroupVar, aSeq); - if (op->IsDone()) { - aGeomVar = aGroupVar; + if (op->IsDone()) + { + aGeomVar = GEOM::GEOM_Object::_duplicate( aGroupVar.in() ); // publish the GEOM group in study QString aNewGeomGroupName ("Auto_group_for_"); aNewGeomGroupName += aName; - SALOMEDS::SObject_var aNewGroupSO = - geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar, - aNewGeomGroupName.toLatin1().data(), mainGeom); + SALOMEDS::Study_var aStudyVar = _CAST(Study, aStudy)->GetStudy(); + SALOMEDS::SObject_wrap aNewGroupSO = + geomGen->AddInStudy( aStudyVar, aGeomVar, + aNewGeomGroupName.toLatin1().data(), mainGeom); } } } @@ -1914,32 +1901,25 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim ) if (aHypData) { QString aClientLibName = aHypData->ClientLibName; - if (aClientLibName == "") + if ( aClientLibName.isEmpty() ) { // Call hypothesis creation server method (without GUI) SMESH::SMESH_Hypothesis_var aHyp = SMESH::CreateHypothesis(aHypName, aHypName, true); -#ifdef WITHGENERICOBJ - if (!CORBA::is_nil(aHyp)) - aHyp->UnRegister(); -#endif + aHyp.out(); } else { // Get hypotheses creator client (GUI) - // BUG 0020378 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName); // Create algorithm if (aCreator) - aCreator->create(true, aHypName, myDlg, 0, QString::null ); + aCreator->create( true, aHypName, myDlg, 0, QString::null ); else { SMESH::SMESH_Hypothesis_var aHyp = SMESH::CreateHypothesis(aHypName, aHypName, true); -#ifdef WITHGENERICOBJ - if (!CORBA::is_nil(aHyp)) - aHyp->UnRegister(); -#endif + aHyp.out(); } } QStringList tmpList; @@ -1965,10 +1945,9 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim ) //================================================================================ /*! - * \brief Reads parameters of edited mesh and assigns them to the dialog + * \brief Reads parameters of an edited mesh and assigns them to the dialog * - * Reads parameters of edited mesh and assigns them to the dialog (called when - * mesh is edited only) + * Called when mesh is edited only. */ //================================================================================ void SMESHGUI_MeshOp::readMesh() @@ -2005,8 +1984,8 @@ void SMESHGUI_MeshOp::readMesh() // Get hypotheses and algorithms assigned to the mesh/sub-mesh QStringList anExisting; - const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D; - for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) + const int lastDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D; + for ( int dim = SMESH::DIM_3D; dim >= lastDim; --dim ) { // get algorithm existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] ); @@ -2030,7 +2009,7 @@ void SMESHGUI_MeshOp::readMesh() // get hypotheses bool hypWithoutAlgo = false; - for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) + for ( int dim = SMESH::DIM_3D; dim >= lastDim; --dim ) { for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ ) {