X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_I%2FGEOM_Gen_i.cc;h=3dec744598d0d66bea80c39edcbf6df1f18dc184;hb=bed71e55e89040080f5b0ca691d9654b59a26a0d;hp=aeaec2c4863853100f6a4f34cb3b0f0c20001df8;hpb=f6f891919b7610d9d6a8a2cab646a61be676dacb;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index aeaec2c48..3dec74459 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -1,23 +1,24 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com #ifdef WNT #pragma warning( disable:4786 ) @@ -27,6 +28,7 @@ #include "GEOM_Gen_i.hh" #include "GEOM_Object_i.hh" +#include "GEOM_version.h" #include #include @@ -181,11 +183,11 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName"); SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); aName->SetValue("Geometry"); - aName->Destroy(); + aName->UnRegister(); anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap"); SALOMEDS::AttributePixMap_var aPixMap=SALOMEDS::AttributePixMap::_narrow(anAttr); aPixMap->SetPixMap("ICON_OBJBROWSER_Geometry"); - aPixMap->Destroy(); + aPixMap->UnRegister(); aStudyBuilder->DefineComponentInstance(aFather, (GEOM::GEOM_Gen_var)GEOM_Gen::_this()); } if (aFather->_is_nil()) return aResultSO; @@ -341,10 +343,10 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } aResultSO->SetAttrString("AttributeString",aVars.ToCString()); - aFather->Destroy(); + aFather->UnRegister(); //Set a name of the GEOM object - aShape->SetName(theName); + aShape->SetName(aShapeName.ToCString()); return aResultSO._retn(); } @@ -616,7 +618,7 @@ CORBA::Boolean GEOM_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var aString=anIOR->Value(); - anIOR->Destroy(); + anIOR->UnRegister(); CORBA::Object_var anObj = _orb->string_to_object(aString); GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(anObj); // If the object is null one it can't be copied: return false @@ -705,7 +707,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var objStr = _orb->object_to_string(obj); anIOR->SetValue(objStr.in()); - anIOR->Destroy(); + anIOR->UnRegister(); // Return the created in the Study SObject return aNewSO._retn(); @@ -740,7 +742,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR.in()); if(aFatherSO->_is_nil()) return aResultSO._retn(); aResultSO = aStudyBuilder->NewObject(aFatherSO); - aFatherSO->Destroy(); + aFatherSO->UnRegister(); //aStudyBuilder->Addreference(aResultSO, aResultSO); } @@ -752,16 +754,20 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy, if(aLength < 1) return aResultSO._retn(); //Publish the arguments + TCollection_AsciiString aPrevID; // to avoid multiple references to same object for(Standard_Integer i = 0; i< aLength; i++) { GEOM::GEOM_Object_var anObject = aList[i]; if(anObject->_is_nil()) continue; IOR = _orb->object_to_string(anObject); SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR.in()); if(aSO->_is_nil()) continue; + CORBA::String_var anID = aSO->GetID(); + if ( aPrevID == anID.in() ) continue; + aPrevID = anID.in(); SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO); aStudyBuilder->Addreference(aSubSO, aSO); - aSO->Destroy(); - aSubSO->Destroy(); + aSO->UnRegister(); + aSubSO->UnRegister(); } return aResultSO._retn(); @@ -793,7 +799,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesO (SALOMEDS::Study_ptr theStudy, aParts = RestoreSubShapes(theStudy, theObject, aSO, theArgs, theFindMethod, theInheritFirstArg, theAddPrefix); - if (!CORBA::is_nil(aSO)) aSO->Destroy(); + if (!CORBA::is_nil(aSO)) aSO->UnRegister(); return aParts._retn(); } @@ -823,7 +829,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesO (SALOMEDS::Study_ptr theS aParts = RestoreGivenSubShapes(theStudy, theObject, aSO, theArgs, theFindMethod, theInheritFirstArg, theAddPrefix); - if (!CORBA::is_nil(aSO)) aSO->Destroy(); + if (!CORBA::is_nil(aSO)) aSO->UnRegister(); return aParts._retn(); } @@ -954,7 +960,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, theObject->SetMarkerTexture(aList[0]->GetMarkerTexture()); } - anArgSO->Destroy(); + anArgSO->UnRegister(); } else { // Get interface, containing method, which we will use to reconstruct sub-shapes @@ -1179,7 +1185,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, } } } // try to build from published parts - anArgSO->Destroy(); + anArgSO->UnRegister(); } } // process arguments } @@ -1545,7 +1551,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStu theObject->SetMarkerTexture(aList[0]->GetMarkerTexture()); } - anArgSO->Destroy(); + anArgSO->UnRegister(); } else { // Get interface, containing method, which we will use to reconstruct sub-shapes @@ -1719,7 +1725,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStu } } } // try to build from published parts - anArgSO->Destroy(); + anArgSO->UnRegister(); } } // process arguments } @@ -2308,13 +2314,13 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShap if (CORBA::is_nil(theMainShape) || theIndices.length() < 1) return GEOM::GEOM_Object::_nil(); CORBA::String_var entry = theMainShape->GetEntry(); - Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), entry); - if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil(); + Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry); + if (aMainShape.IsNull()) return GEOM::GEOM_Object::_nil(); Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length()); for(Standard_Integer i = 0; iSetValue(i+1, theIndices[i]); - Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray, true); + Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainShape, anArray, true); if(anObject.IsNull()) return GEOM::GEOM_Object::_nil(); TCollection_AsciiString anEntry; @@ -2418,12 +2424,12 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry) if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var aVal = anIOR->Value(); - anIOR->Destroy(); + anIOR->UnRegister(); CORBA::Object_var anObject = aStudy->ConvertIORToObject(aVal); aGeomObject = GEOM::GEOM_Object::_narrow(anObject); } if (!aSObj->_is_nil() ) - aSObj->Destroy(); + aSObj->UnRegister(); const char* aTypeInfo = "Object"; if ( !aGeomObject->_is_nil() ) { @@ -2546,6 +2552,16 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry) return ret; } +// Version information +char* GEOM_Gen_i::getVersion() +{ +#if GEOM_DEVELOPMENT + return CORBA::string_dup(GEOM_VERSION_STR"dev"); +#else + return CORBA::string_dup(GEOM_VERSION_STR); +#endif +} + //===================================================================================== // EXPORTED METHODS //=====================================================================================