]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the problem where group is moved to the end, after the operation it was not...
authormpv <mpv@opencascade.com>
Wed, 11 Nov 2015 09:21:52 +0000 (12:21 +0300)
committermpv <mpv@opencascade.com>
Wed, 11 Nov 2015 09:21:52 +0000 (12:21 +0300)
src/ConnectorPlugin/ConnectorPlugin_ExportFeature.py
src/Model/Model_AttributeSelection.cpp
src/Model/Model_BodyBuilder.cpp
src/Model/Model_BodyBuilder.h
src/Model/Model_Document.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultCompSolid.cpp
src/Model/Model_ResultCompSolid.h
src/ModelAPI/ModelAPI_BodyBuilder.h
src/ModelAPI/ModelAPI_ResultBody.h

index 9241308435320ab15b5bc4f3b83fd8f7431371cb..30844b6744a29fb0c941fb4d783fe027fd5d6bb5 100644 (file)
@@ -114,13 +114,15 @@ class ExportFeature(ModelAPI.ModelAPI_Feature):
             else:
                 groupType = "SOLID"
 
-        # iterate on exported objects and check if the current
-        # group refers to this object
-        for obj in self.geomObjects: 
-            if aSelectionContext.shape().isEqual(obj[0]):
-                aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
-                self.geompy.UnionIDs(aGroup,Ids)
-                self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
+        aContextBody = ModelAPI.modelAPI_ResultBody(aSelectionContext)
+        if aContextBody is not None:
+          # iterate on exported objects and check if the current
+          # group refers to this object
+          for obj in self.geomObjects: 
+              if aContextBody.isLatestEqual(obj[0]):
+                  aGroup = self.geompy.CreateGroup(obj[1], self.geompy.ShapeType[groupType])
+                  self.geompy.UnionIDs(aGroup,Ids)
+                  self.geompy.addToStudyInFather(obj[1], aGroup, theGroupName)
           
     ## Exports all shapes and groups into the GEOM module.
     def execute(self):
index 232ff61b558ead55e47049e9d23208513d06c975..bdc924e2766a9535110372d85243134f768a584c 100644 (file)
@@ -327,11 +327,14 @@ TDF_LabelMap& Model_AttributeSelection::scope()
          aCompositeOwnerOwner = ModelAPI_Tools::compositeOwner(aCompositeOwner);
       }
     }
+    // for group Scope is not limitet: this is always up to date objects
+    bool isGroup = aFeature.get() && aFeature->getKind() == "Group";
     for(; aFIter != allFeatures.end(); aFIter++) {
       if (*aFIter == owner()) {  // the left features are created later (except subs of composite)
         aMePassed = true;
         continue;
       }
+      if (isGroup) aMePassed = false;
       bool isInScope = !aMePassed;
       if (!isInScope && aComposite.get()) { // try to add sub-elements of composite if this is composite
         if (aComposite->isSub(*aFIter))
@@ -903,14 +906,24 @@ void Model_AttributeSelection::selectSubShape(
 
 int Model_AttributeSelection::Id()
 {
+  int anID = 0;
   std::shared_ptr<GeomAPI_Shape> aSelection = value();
   std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
-  const TopoDS_Shape& aMainShape = aContext->impl<TopoDS_Shape>();
+  TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
   const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
-  int anID = 0;
+  // searching for the latest main shape
   if (aSelection && !aSelection->isNull() &&
     aContext   && !aContext->isNull())
   {
+    std::shared_ptr<Model_Document> aDoc =
+      std::dynamic_pointer_cast<Model_Document>(context()->document());
+    if (aDoc.get()) {
+      Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel());
+      if (!aNS.IsNull()) {
+        aMainShape = TNaming_Tool::CurrentShape(aNS);
+      }
+    }
+
     TopTools_IndexedMapOfShape aSubShapesMap;
     TopExp::MapShapes(aMainShape, aSubShapesMap);
     anID = aSubShapesMap.FindIndex(aSubShape);
index bacee75ebf41ae62d1dca4d11fa31add5e425b7c..ee6ba1b792ecd6b8d366645774a92f95da0d225c 100755 (executable)
@@ -12,6 +12,7 @@
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Iterator.hxx>
+#include <TNaming_Tool.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TopoDS.hxx>
@@ -759,3 +760,21 @@ std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
   }
   return std::shared_ptr<GeomAPI_Shape>();
 }
+
+bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  if (theShape.get()) {
+    TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();  
+    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
+    if (aData) {
+      TDF_Label& aShapeLab = aData->shapeLab();
+      Handle(TNaming_NamedShape) aName;
+      if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+        TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName);
+        if (aLatest.IsEqual(aShape))
+          return true;
+      }
+    }
+  }
+  return false;
+}
index 85032d4f81d5282f3a93f60f6324e6f81d563625..3785d2164243e2370fa7651dfe2cf7f14cc8b222 100755 (executable)
@@ -109,6 +109,10 @@ public:
   /// (theFlag = true) and back (theFlag = false)
   MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
 
+  /// Returns true if the latest modification of this body in the naming history
+  // is equal to the given shape
+  MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
 protected:
   /// Default constructor accessible only by Model_Objects
   Model_BodyBuilder(ModelAPI_Object* theOwner);
index 1c7645b0c4f149782f9312a0acd103747a0ce4ec..b3bdb63b71bbe40f9a71902f1ee8acb3b2322222 100644 (file)
@@ -265,6 +265,7 @@ class Model_Document : public ModelAPI_Document
   friend class Model_AttributeReference;
   friend class Model_AttributeRefAttr;
   friend class Model_AttributeRefList;
+  friend class Model_AttributeSelection;
   friend class Model_ResultPart;
   friend class Model_ResultCompSolid;
   friend class DFBrowser;
index d7e3f46c9fe0bf6336671aa5a4f3e1e83c62fbc4..8418ba22fa5c63adfe506f5f044f939c64ddc977 100644 (file)
@@ -41,3 +41,8 @@ bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, con
   }
   return aChanged;
 }
+
+bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  return myBuilder->isLatestEqual(theShape);
+}
index 1300be1c53d8f4dab2f607350c2908c8cdc18482..3c4b0f9caad6e4a898ae28c6d78d607a1928866d 100644 (file)
@@ -40,6 +40,11 @@ public:
   /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
     const bool theFlag);
+
+  /// Returns true if the latest modification of this body in the naming history
+  // is equal to the given shape
+  MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
   /// Removes the stored builders
   MODEL_EXPORT virtual ~Model_ResultBody() {};
 
index b731fdcef7714d526b569535fc5190ac77221f52..4b83d3d5941327966c599f75e3bb596e635599d5 100755 (executable)
@@ -188,3 +188,8 @@ void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& the
     aECreator->sendUpdated(data()->owner(), EVENT_DISP);
   }
 }
+
+bool Model_ResultCompSolid::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  return myBuilder->isLatestEqual(theShape);
+}
index 21fb163b9769a7ef3ca15542319b63b7b2999764..ba92674e8c80a03228a3349655dc711447eef05a 100755 (executable)
@@ -70,6 +70,10 @@ public:
   /// Sets all subs as concealed in the data tree (referenced by other objects)
   MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
 
+  /// Returns true if the latest modification of this body in the naming history
+  // is equal to the given shape
+  MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
 protected:
   /// Makes a body on the given feature
   Model_ResultCompSolid();
index 3d945b47c4622c9bef6547bba2e98240c421354c..38f2868a97c8b34bc2dba827158686ff50c45111 100755 (executable)
@@ -101,6 +101,10 @@ public:
   /// (theFlag = true) and back (theFlag = false)
   virtual void evolutionToSelection(const bool theFlag) = 0;
 
+  /// Returns true if the latest modification of this body in the naming history
+  // is equal to the given shape
+  virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
 protected:
   /// Returns the data manager of this object: attributes
   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
index 54df9a2c65c6cfa974ce5a958a9a3f35f9dc5626..272d94e3e6e50e89183fefd4926a953327024e29 100644 (file)
@@ -111,6 +111,10 @@ public:
   MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
     const std::string& theName,int&  theTag);
 
+  /// Returns true if the latest modification of this body in the naming history
+  // is equal to the given shape
+  MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+
 protected:
   /// Default constructor accessible only from Model_Objects
   MODELAPI_EXPORT ModelAPI_ResultBody();