Salome HOME
ADD a end user module (services.py) to help the manipulation of SALOME KERNEL service...
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyManager.cxx
index 2e2e012aec05ef5597c30bb3e908fcbcb1d1b2d7..96fb9c896b678f5ecd9be59b8a377074d42f5f24 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  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
 //
 
 //  File   : SALOMEDSImpl_StudyManager.cxx
@@ -417,12 +417,30 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy,
 
   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
 
-  int aLength = 0, anIndex, i;
+  std::string units = aProp->GetUnits();
+  std::string comment = aProp->GetComment();
+
+  int aLength = 0, anIndex, i, unitsSize = 0, commentSize = 0;
   for(i=1; i<=aNames.size(); i++)
     aLength += aNames[i-1].size() + 1;
-
-  //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte
-  char* aProperty = new char[3 + aLength + 12 * aNames.size()];
+  
+  unitsSize = units.size();
+  commentSize = comment.size();
+
+  //string format:
+  //locked flag, modified flag,
+  //minutes, hours, day, months, year, user name, char(1), 
+  //minutes, hours, day, months, year, user name, char(1),
+  //.....................................................,
+  //.....................................................,
+  //.....................................................,
+  //minutes, hours, day, months, year, user name, char(1), char(30) <- !!!! used to define end of section with modifications !!!!
+  //units, char(1), comment, char(0)
+
+  //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimeter)
+  // unit length + 1, comment length, "zero" byte
+  
+  char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize ];
 
 
   sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(),  (aProp->IsLocked())?'l':'u');
@@ -440,8 +458,27 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy,
     a = strlen(aProperty);
     aProperty[a++] = 1;
   }
-  aProperty[a] = 0;
 
+  //Write delimeter of the section to define end of the modifications section
+  aProperty[a++] = 30;
+
+  //Write units if need
+  if(units.size() > 0) {
+    sprintf(&(aProperty[a]),"%s",units.c_str());
+    a = strlen(aProperty);
+  }
+
+  aProperty[a++] = 1;
+
+  //Write comments if need
+  if(comment.size() > 0) {
+    sprintf(&(aProperty[a]),"%s",comment.c_str());
+    a = strlen(aProperty);
+    a++;
+  }
+
+  aProperty[a] = 0;
+  
   name_len = (hdf_int32) a;
   size[0] = name_len + 1 ;
   hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
@@ -450,7 +487,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(SALOMEDSImpl_Study* aStudy,
   hdf_dataset->CloseOnDisk();
   hdf_dataset=0; //will be deleted by hdf_sco_group destructor
   delete [] aProperty;
-
+  
   aProp->SetModified(0);
   return true;
 }
@@ -1088,6 +1125,8 @@ DF_Label SALOMEDSImpl_StudyManager::PasteLabel(SALOMEDSImpl_Study* theDestinatio
       aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
       aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag());
     }
+    SALOMEDSImpl_SObject so = theDestinationStudy->GetSObject(aTargetLabel);
+    theDestinationStudy->addSO_Notification(so);
   }
 
   // check auxiliary label for TMPFile => IOR