-# Copyright (C) 2007-2019 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) 2019-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
aDeadGroupEntry = "dead" + str(anIndex) + "_" + aGroup.GetEntry()
aDeadGroup.SetEntry(aDeadGroupEntry)
aDeadGroup.SetSelectionType(aGroup.GetSelectionType())
- aDeadGroup.SetSelection(aGroup.GetSelection())
+ anOldSelection = aGroup.GetSelectionOld()
+ if len(anOldSelection) == 0: # in case there is no old modification, get the current, same as in shape
+ anOldSelection = aGroup.GetSelection()
+ aDeadGroup.SetSelection(anOldSelection)
if isinstance(aGroup, SHAPERSTUDY_ORB._objref_SHAPER_Field): # additional field data
aDeadGroup.SetValuesType(aGroup.GetValuesType())
aDeadGroup.SetSteps(aGroup.GetSteps())
if not self.data:
self.data = StudyData_Swig.StudyData_Object()
self.data.SetShapeByPointer(theShape)
+ return
+
+ ### unnecessary methods that can be accidentally called from any module
+ def GetTopologyType(self, *args): return GEOM.SHAPE
+ def GetMinShapeType(self, *args): return GEOM.SHAPE
+ def GetMaxShapeType(self, *args): return GEOM.SHAPE
+ def GetSubShapeName(self, *args): return ""
+ def SetColor(self, *args): return
+ def GetColor(self, *args): import SALOMEDS; return SALOMEDS.Color( 0,0,0 )
+ def SetAutoColor(self, *args): return
+ def GetAutoColor(self, *args): return False
+ def SetMarkerStd(self, *args): return
+ def SetMarkerTexture(self, *args): return
+ def GetMarkerType(self, *args): return GEOM.MT_NONE
+ def GetMarkerSize(self, *args): return GEOM.MS_NONE
+ def GetMarkerTexture(self, *args): return 0
pass
SHAPERSTUDY_GenericObject.__init__(self)
self.seltype = None
self.selection = []
+ self.selectionTick = -2 # tick of the main shape when the current selection is set
+ self.selectionOld = [] # keep selection for breaking link
self.SO = None
self.data = None
self.entry = ""
"""
Sets what is returned in the GEOM_IGroupOperations::GetObjects
"""
- self.data = None # nullify the cashed shape when selection is changed
- self.selection = theSelection
+ aTick = -2
+ if self.SO:
+ aMainShape = self.GetMainShape()
+ if aMainShape:
+ aTick = aMainShape.GetTick()
+ if aTick > self.selectionTick or aTick == -2:
+ self.selectionOld = self.selection
+ self.selection = theSelection
+ self.selectionTick = aTick
+ #print("Set selection " + self.entry + " old = " + str(self.selectionOld) + " new = " + str(self.selection) + " tick = " + str(aTick))
+ elif self.selection != theSelection:
+ self.selectionOld = self.selection
+ self.selection = theSelection
+ if self.selectionTick < 0:
+ self.selectionTick = aTick + 1
+ else:
+ self.selectionTick = self.selectionTick + 1 # when the group is changed, but the main shape stays the same, make tick + 1
+ #print("Set selection " + self.entry + " old = " + str(self.selectionOld) + " new = " + str(self.selection) + " tick = " + str(self.selectionTick))
+ pass
def GetSelection(self):
"""
"""
return self.selection
+ def GetSelectionOld(self):
+ """
+ Returns the previously selected sub-shapes indices
+ """
+ #print("get selection OLD " + self.entry + " old = " + str(self.selectionOld) + " new = " + str(self.selection))
+ return self.selectionOld
+
def IsMainShape( self ):
"""
Returns True if this object is not a sub-shape of another object.
pass
+ def GetTick( self ):
+ """
+ Get value of a modification counter of the group
+ """
+ return self.selectionTick
+
+ def SetTick( self, theValue ):
+ """
+ Sets value of a modification counter of the group
+ """
+ #print("Set tick " + self.entry + " tick = " + str(theValue))
+ self.selectionTick = theValue
+
class SHAPERSTUDY_Field(SHAPERSTUDY_ORB__POA.SHAPER_Field, SHAPERSTUDY_Group):
"""
Constructs an instance of SHAPERSTUDY Field (inherits selection from a Group object)
SHAPERSTUDY_GenericObject.__init__(self)
self.seltype = None
self.selection = []
+ self.selectionTick = -2 # tick of the main shape when the current selection is set
+ self.selectionOld = [] # keep selection for breaking link
self.SO = None
self.data = None
self.entry = None
return aResult
pass
+