Salome HOME
Copyright update 2020
[modules/shaper.git] / src / Model / Model_Data.cpp
index e5641930e1b1253ab05e0a83f5afbd1ab8c34137..b78b1c70746fba86e8a6c329ef350c9dfa17cc21 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Point2DArray.h>
 
 #include <GeomData_Point.h>
 #include <GeomData_Point2D.h>
+#include <GeomData_Point2DArray.h>
 #include <GeomData_Dir.h>
 #include <Events_Loop.h>
 #include <Events_InfoMessage.h>
@@ -75,7 +77,7 @@ static const int kFlagDisplayed = 1;
 static const int kFlagDeleted = 2;
 // TDataStd_Integer - 0 if the name of the object is generated automatically,
 //                    otherwise the name is defined by user
-Standard_GUID kUSER_DEFINED_NAME("9c694d18-a83c-4a56-bc9b-8020628a8244");
+static const Standard_GUID kUSER_DEFINED_NAME("9c694d18-a83c-4a56-bc9b-8020628a8244");
 
 // invalid data
 const static std::shared_ptr<ModelAPI_Data> kInvalid(new Model_Data());
@@ -83,6 +85,9 @@ const static std::shared_ptr<ModelAPI_Data> kInvalid(new Model_Data());
 static const Standard_GUID kGroupAttributeGroupID("df64ea4c-fc42-4bf8-ad7e-08f7a54bf1b8");
 static const Standard_GUID kGroupAttributeID("ebdcb22a-e045-455b-9a7f-cfd38d68e185");
 
+// id of attribute to store the version of the feature
+static const Standard_GUID kVERSION_ID("61cdb78a-1ba7-4942-976f-63bea7f4a2b1");
+
 
 Model_Data::Model_Data() : mySendAttributeUpdated(true), myWasChangedButBlocked(false)
 {
@@ -156,6 +161,24 @@ bool Model_Data::hasUserDefinedName() const
   return shapeLab().IsAttribute(kUSER_DEFINED_NAME);
 }
 
+std::string Model_Data::version()
+{
+  Handle(TDataStd_Name) aVersionAttr;
+  std::string aVersion;
+  if (shapeLab().FindAttribute(kVERSION_ID, aVersionAttr))
+    aVersion = TCollection_AsciiString(aVersionAttr->Get()).ToCString();
+  return aVersion;
+}
+
+void Model_Data::setVersion(const std::string& theVersion)
+{
+  Handle(TDataStd_Name) aVersionAttr;
+  std::string aVersion;
+  if (!shapeLab().FindAttribute(kVERSION_ID, aVersionAttr))
+    aVersionAttr = TDataStd_Name::Set(shapeLab(), kVERSION_ID, TCollection_ExtendedString());
+  aVersionAttr->Set(theVersion.c_str());
+}
+
 AttributePtr Model_Data::addAttribute(
   const std::string& theID, const std::string theAttrType, const int theIndex)
 {
@@ -217,7 +240,10 @@ AttributePtr Model_Data::addAttribute(
     }
     anAttribute->myIsInitialized = anAllInitialized;
     anAttr = anAttribute;
+  } else if (theAttrType == GeomData_Point2DArray::typeId()) {
+    anAttr = new GeomData_Point2DArray(anAttrLab);
   }
+
   if (anAttr) {
     aResult = std::shared_ptr<ModelAPI_Attribute>(anAttr);
     myAttrs[theID] = std::pair<AttributePtr, int>(aResult, anAttrIndex);
@@ -432,7 +458,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
   } else {
     // trim: need to redisplay or set color in the python script
     if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" ||
-      theAttr->id() == "Transparency" || theAttr->id() == "Deflection")) {
+      theAttr->id() == "Transparency" || theAttr->id() == "Deflection" ||
+      theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines")) {
       static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
       ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
     }