Salome HOME
Make SHAPERSTUDY group never main shape
[modules/shaper_study.git] / src / PY / SHAPERSTUDY_Object.py
index 17ee361ef44797e1b42346590480103924054a4c..d0d2317eae418bd591344ce144410526e1b07f8c 100755 (executable)
@@ -193,6 +193,14 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
           return self.data.getTick()
         return 0
 
+    def SetTick( self, theValue ):
+        """
+        Sets value of a modification counter of the object
+        """
+        if self.data:
+          return self.data.setTick(theValue)
+        return 0
+
     def GetStudyEntry( self ):
         """
         Get a Study entry where this object was published.
@@ -256,14 +264,18 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
         """
         aStudy = getStudy()
         aBuilder = aStudy.NewBuilder()
-        aRes, aHistSO = self.SO.FindSubObject(2)
+        aRes, aHistSO = self.SO.FindSubObject(10000)
         if not aRes: # create a "history" folder if it does not exist
-          aHistSO = aBuilder.NewObjectToTag(self.SO, 2)
+          aHistSO = aBuilder.NewObjectToTag(self.SO, 10000)
           aHistSO.SetAttrString("AttributeName", "History")
 
         aDeadSO = aBuilder.NewObject(aHistSO)
         anIndex = aDeadSO.Tag()
         aDeadSO.SetAttrString("AttributeName", self.SO.GetName() + " (" + str(anIndex) + ")")
+        aRes, aPixMap = aBuilder.FindAttribute(self.SO, "AttributePixMap")
+        if aRes:
+          aDeadPixMap = aBuilder.FindOrCreateAttribute(aDeadSO, "AttributePixMap")
+          aDeadPixMap.SetPixMap(aPixMap.GetPixMap())
         aDead = SHAPERSTUDY_Object()
         aDeadEntry = "dead" + str(anIndex) + "_" + self.GetEntry()
         aDead.SetEntry(aDeadEntry)
@@ -281,18 +293,32 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object,
           anIOR = aGroupSO.GetIOR()
           if len(anIOR):
             aGroup = salome.orb.string_to_object(anIOR)
-            if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group):
-              aDeadGroup = SHAPERSTUDY_Group()
+            if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group) or \
+               isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field):
+              if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Group):
+                aDeadGroup = SHAPERSTUDY_Group()
+              else:
+                aDeadGroup = SHAPERSTUDY_Field()
               aDeadGroupEntry = "dead" + str(anIndex) + "_" + aGroup.GetEntry()
               aDeadGroup.SetEntry(aDeadGroupEntry)
-              aDeadGroup.SetShapeByPointer(aGroup.getShape())
               aDeadGroup.SetSelectionType(aGroup.GetSelectionType())
               aDeadGroup.SetSelection(aGroup.GetSelection())
+              if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field): # additional field data
+                aDeadGroup.SetValuesType(aGroup.GetValuesType())
+                aDeadGroup.SetSteps(aGroup.GetSteps())
+                aDeadGroup.SetComponents(aGroup.GetComponents())
+                for aStep in aGroup.GetSteps():
+                  aStepObj = aGroup.GetStep(aStep)
+                  aDeadGroup.AddFieldStep(aStepObj.GetStamp(), aStep, aStepObj.GetValues())
               aDeadGroupSO = aBuilder.NewObject(aDeadSO)
               aDeadGroup.SetSO(aDeadGroupSO)
               # 15.01.20 groups and fields names stays the same
               #aDeadGroupSO.SetAttrString("AttributeName", aGroupSO.GetName() + " (" + str(anIndex) + ")")
               aDeadGroupSO.SetAttrString("AttributeName", aGroupSO.GetName())
+              aRes, aPixMap = aBuilder.FindAttribute(aGroupSO, "AttributePixMap")
+              if aRes:
+                aDeadPixMap = aBuilder.FindOrCreateAttribute(aDeadGroupSO, "AttributePixMap")
+                aDeadPixMap.SetPixMap(aPixMap.GetPixMap())
               aDeadGroupObj = aDeadGroup._this()
               anIOR = salome.orb.object_to_string(aDeadGroupObj)
               aDeadGroupSO.SetAttrString("AttributeIOR", anIOR)
@@ -349,6 +375,12 @@ class SHAPERSTUDY_Group(SHAPERSTUDY_ORB__POA.SHAPER_Group, SHAPERSTUDY_Object):
         """
         return self.selection
 
+    def IsMainShape( self ):
+        """
+        Returns True if this object is not a sub-shape of another object.
+        """
+        return False
+
     def GetMainShape( self ):
         """
         Main shape is groups owner
@@ -407,6 +439,13 @@ class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
       """
       self.valtype = theType
 
+    def GetValuesType( self ):
+      """
+      Returns the type of values in the field
+      """
+      return self.valtype
+
+
     def GetDataType( self ):
       """
       Returns the type of values in the field in terms of GEOM enumeration