]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_VersionedBoolean.cpp
Salome HOME
General approach of versioning the feature. Update Boolean operations according.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_VersionedBoolean.cpp
index ea18dd5a9fa50e89dbb0e87d46caec09b0c28faf..bba9645aa9e90f81ceff04cc4fa35eed3d512423 100644 (file)
@@ -71,19 +71,20 @@ static void performBoolean(const GeomAlgoAPI_Tools::BOPType theBooleanType,
 }
 
 //=================================================================================================
-void FeaturesPlugin_VersionedBoolean::initVersion(const int theVersion,
+void FeaturesPlugin_VersionedBoolean::initVersion(const std::string& theVersion,
                                                   const AttributePtr theObjectsAttr,
                                                   const AttributePtr theToolsAttr)
 {
-  AttributePtr aVerAttr = data()->addAttribute(VERSION_ID(), ModelAPI_AttributeInteger::typeId());
-  aVerAttr->setIsArgument(false);
-  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VERSION_ID());
-  if (!integer(VERSION_ID())->isInitialized() &&
-      (!theObjectsAttr || !theObjectsAttr->isInitialized()) &&
-      (!theToolsAttr || !theToolsAttr->isInitialized())) {
+  AttributeIntegerPtr anOldVersionAttr = integer("version");
+  if (anOldVersionAttr && anOldVersionAttr->isInitialized() && data()->version().empty()) {
+    // move value to the common version interface in ModelAPI_Data
+    data()->setVersion(BOP_VERSION_9_4());
+  }
+  else if ((!theObjectsAttr || !theObjectsAttr->isInitialized()) &&
+           (!theToolsAttr || !theToolsAttr->isInitialized())) {
     // this is a newly created feature (not read from file),
     // so, initialize the latest version
-    integer(VERSION_ID())->setValue(theVersion);
+    data()->setVersion(theVersion);
   }
 }
 
@@ -450,16 +451,6 @@ void FeaturesPlugin_VersionedBoolean::resizePlanes(
   }
 }
 
-//=================================================================================================
-int FeaturesPlugin_VersionedBoolean::version()
-{
-  AttributeIntegerPtr aVersionAttr = integer(VERSION_ID());
-  int aVersion = 0;
-  if (aVersionAttr && aVersionAttr->isInitialized())
-    aVersion = aVersionAttr->value();
-  return aVersion;
-}
-
 //=================================================================================================
 
 void FeaturesPlugin_VersionedBoolean::ObjectHierarchy::AddObject(const GeomShapePtr& theObject)