Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SObject_i.cxx
index 5f5ddded8977a4af4324f3905c2e1d3135c4516f..35c5087af6385c4a68b45df0c587372444155b63 100644 (file)
@@ -188,7 +188,7 @@ namespace SALOMEDS{
     TAttrID2FunMap::const_iterator anEnd = __AttrID2FunMap__.end();
     for(; anIter != anEnd; anIter++){
       const TAttrID2FunMap::key_type& aKey = anIter->first;
-      const TAttrID2FunMap::data_type& aValue = anIter->second;
+      const TAttrID2FunMap::mapped_type& aValue = anIter->second;
       __GUID2AttrIDMap__[aValue.myGetGUID()] = aKey;
     };
 
@@ -223,7 +223,7 @@ namespace SALOMEDS{
   {
     TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
     if(anIter != __AttrID2FunMap__.end()){
-      const TAttrID2FunMap::data_type& aValue = anIter->second;
+      const TAttrID2FunMap::mapped_type& aValue = anIter->second;
       return aValue.myGetGUID();
     }
     // create tree node GUID by name
@@ -365,12 +365,19 @@ char* SALOMEDS_SObject_i::GetID()
  *  Purpose  : 
  */
 //============================================================================
+TDF_Label SALOMEDS_SObject_i::GetFatherComponentLabel()
+{
+  TDF_Label aLabel = _lab;
+  while(!SALOMEDS_SComponent_i::IsA(aLabel) && !aLabel.IsRoot())
+    aLabel = aLabel.Father();
+
+  return aLabel;
+}
+
 SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
 {
-  TDF_Label aSCompLabel = _lab;
-  while(!SALOMEDS_SComponent_i::IsA(aSCompLabel) && !aSCompLabel.IsRoot()){
-    aSCompLabel = aSCompLabel.Father();
-  }
+  TDF_Label aSCompLabel = GetFatherComponentLabel();
+
   return SALOMEDS_SComponent_i::NewRef(_study,aSCompLabel)._retn();
 }
   
@@ -530,17 +537,8 @@ char* SALOMEDS_SObject_i::GetIOR() {
 SALOMEDS_SObject_i::TAttrHolder 
 SALOMEDS_SObject_i::_FindGenAttribute(const Handle(TDF_Attribute)& theAttr)
 {
-  TAttrHolder anGenAttr;
-
-  Standard_GUID aGUID = theAttr->ID();
-
-  TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID);
-  if(anIter != __GUID2AttrIDMap__.end()){
-    const TAttributeID& anAttributeID = anIter->second;
-    anGenAttr = _FindGenAttribute(anAttributeID.c_str());
-  }
-
-  return anGenAttr;
+  std::string aType = GetType(theAttr);
+  return _FindGenAttribute(aType.c_str());
 }
 
 
@@ -577,10 +575,10 @@ SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
   SALOMEDS_GenericAttribute_i* anAttr;
   TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
   if(anIter != __AttrID2FunMap__.end()){
-    const TAttrID2FunMap::data_type& aValue = anIter->second;
+    const TAttrID2FunMap::mapped_type& aValue = anIter->second;
     
-    if(aValue.myIsCheckLockedStudy())
-      _study->CheckLocked();
+    //if(aValue.myIsCheckLockedStudy()) // mpv 03.02.05: creation of CORBA objects does not modify the study
+    //  _study->CheckLocked();
     
     anAttr = aValue.myNewInstance(theAttr,this);
     return TAttrHolder(anAttr,anAttr->_this());
@@ -633,25 +631,17 @@ SALOMEDS_SObject_i::_FindGenAttribute(const char* theType)
 }
 
 
-SALOMEDS::GenericAttribute_ptr 
-SALOMEDS_SObject_i::_FindCORBAAttribute(const char* theType)
+CORBA::Boolean 
+SALOMEDS_SObject_i::FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
+                                 const char* theType)
 {
   TAttrHolder anAttr = _FindGenAttribute(theType);
   SALOMEDS::GenericAttribute_var anGenAttr = anAttr.second;
   if(!CORBA::is_nil(anGenAttr)){
-    return anGenAttr._retn();
+    theAttribute = SALOMEDS::GenericAttribute::_duplicate(anGenAttr);
+    return true;
   }
-
-  return SALOMEDS::GenericAttribute::_nil();
-}
-
-
-CORBA::Boolean 
-SALOMEDS_SObject_i::FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
-                                 const char* theType)
-{
-  theAttribute = _FindCORBAAttribute(theType);
-  return !CORBA::is_nil(theAttribute);
+  return false;
 }
 
 
@@ -666,7 +656,7 @@ Handle(TDF_Attribute)
   Handle(TDF_Attribute) anAttr;
   TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
   if(anIter != __AttrID2FunMap__.end()){
-    const TAttrID2FunMap::data_type& aValue = anIter->second;
+    const TAttrID2FunMap::mapped_type& aValue = anIter->second;
     
     if(aValue.myIsCheckLockedStudy())
       _study->CheckLocked();
@@ -688,7 +678,6 @@ Handle(TDF_Attribute)
     if(!_lab.FindAttribute(aGUID,anAttr)){
       _study->CheckLocked();
       anAttr = TDataStd_TreeNode::Set(_lab,aGUID);
-      _lab.AddAttribute(anAttr);
       return anAttr;
     }
   }
@@ -698,7 +687,6 @@ Handle(TDF_Attribute)
     if(!_lab.FindAttribute(aGUID,anAttr)){
       _study->CheckLocked();
       anAttr = TDataStd_UAttribute::Set(_lab,aGUID);
-      _lab.AddAttribute(anAttr);
       return anAttr;
     }
   }