]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #769: fillet now does not destroy the naming of the modified edge...
authormpv <mpv@opencascade.com>
Wed, 16 Sep 2015 07:27:52 +0000 (10:27 +0300)
committermpv <mpv@opencascade.com>
Wed, 16 Sep 2015 07:27:52 +0000 (10:27 +0300)
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_CompositeFeature.cpp
src/ModelAPI/ModelAPI_CompositeFeature.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index bb9fa83e26bd5ba038f77a9c3a1bd867773a811c..ee9b20d749bdc785f6c7919eff937de7aa9310e0 100644 (file)
@@ -164,6 +164,37 @@ void Model_AttributeRefList::substitute(const ObjectPtr& theCurrent, const Objec
   }
 }
 
+void Model_AttributeRefList::exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2)
+{
+  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+      owner()->document());
+  if (aDoc) {
+    std::shared_ptr<Model_Data> aData1 = std::dynamic_pointer_cast<Model_Data>(theObject1->data());
+    if (aData1.get() && aData1->isValid()) {
+      TDF_Label aLab1 = aData1->label().Father();
+      if (theObject2.get() && theObject2->data()->isValid()) { // the new may be null
+        std::shared_ptr<Model_Data> aData2 = 
+          std::dynamic_pointer_cast<Model_Data>(theObject2->data());
+        if (aData2.get() && aData2->isValid()) {
+          TDF_Label aLab2 = aData2->label().Father();
+          // do the substitution: use the temporary label, as usually in exchange
+          TDF_Label aTmpLab = aLab1.Root();
+          if (myRef->InsertAfter(aTmpLab, aLab1)) {
+            myRef->Remove(aLab1);
+          }
+          if (myRef->InsertAfter(aLab1, aLab2)) {
+            myRef->Remove(aLab2);
+          }
+          if (myRef->InsertAfter(aLab2, aTmpLab)) {
+            myRef->Remove(aTmpLab);
+          }
+          owner()->data()->sendAttributeUpdated(this);
+        }
+      }
+    }
+  }
+}
+
 void Model_AttributeRefList::removeLast()
 {
   std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
index 52de359b1ea41042959c5f7b0da4546c87fee383..c329662d0e66117d2ff174a54d2b2ecfd49d54f1 100644 (file)
@@ -50,6 +50,9 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   /// Substitutes the feature by another one. Does nothing if such object is not found.
   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
 
+  /// Substitutes the object by another one and back. So, features wil become exchanged in the list
+  MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
+
   /// Removes the last element in the list.
   MODEL_EXPORT virtual void removeLast();
 
index 2a282108fb911197c2f837557fa4e62cd827865b..d519000225f194394ffe0231acbe356abdeb4303 100644 (file)
@@ -52,9 +52,12 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute
   ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
   virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const = 0;
 
-  /// Substitutes the feature by another one. Does nothing if such object is not found.
+  /// Substitutes the object by another one. Does nothing if such object is not found.
   virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
 
+  /// Substitutes the object by another one and back. So, features wil become exchanged in the list
+  virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2) = 0;
+
   /// Removes the last element in the list.
   virtual void removeLast() = 0;
 
index 71b6fc28041bcf767487080742d706ee38867f49..7913a8bde50d9e534dc7fd0ff19c982d782288be 100644 (file)
@@ -10,3 +10,9 @@ ModelAPI_CompositeFeature::~ModelAPI_CompositeFeature()
 {
 
 }
+
+void ModelAPI_CompositeFeature::exchangeIDs(
+  std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+  // by default nothing is in the implementation
+}
index 4a86409e2214825cffba19f8263846d9c97dc0b1..bc31a21eb80cc57f014b44c3e9478cf2843aaf4d 100644 (file)
@@ -39,6 +39,10 @@ public:
   /// This method to inform that sub-feature is removed and must be removed from the internal data
   /// structures of the owner (the remove from the document will be done outside just after)
   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+
+  /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769)
+  MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
+    std::shared_ptr<ModelAPI_Feature> theFeature2);
 };
 
 //! Pointer on the composite feature object
index 5b63142db203f2ed690463c4597ed8c9e45640c0..e4df553d7cbe92289ce95475453f4205dde148df 100644 (file)
@@ -337,6 +337,7 @@ void PartSet_WidgetSketchLabel::showPreviewPlanes()
     // Create Preview
     std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
     std::shared_ptr<GeomAPI_Dir> aYZDir(new GeomAPI_Dir(1, 0, 0));
+    // -1, not 1 for correct internal sketch coords (issue 898)
     std::shared_ptr<GeomAPI_Dir> aXZDir(new GeomAPI_Dir(0, -1, 0));
     std::shared_ptr<GeomAPI_Dir> aXYDir(new GeomAPI_Dir(0, 0, 1));
 
index 6cf6da8f669062a579482109de07df6828394d46..a9f00c9f48b58520803e6a7b11f23c71869d9a60 100644 (file)
@@ -316,6 +316,9 @@ void SketchPlugin_ConstraintFillet::execute()
     myBaseObjects.clear();
     myBaseObjects.push_back(aFeatureA);
     myBaseObjects.push_back(aFeatureB);
+    // exchange the naming IDs of newly created and old line that become auxiliary
+    sketch()->exchangeIDs(aFeatureA, aNewFeatureA);
+    sketch()->exchangeIDs(aFeatureB, aNewFeatureB);
   } else {
     // Update radius value
     int aNbSubs = sketch()->numberOfSubs();
index 972c956933dabe339a0c71183b85a6f8bf307003..21247d13a37b631f049f8327f5cf77e5452d0456 100644 (file)
@@ -319,3 +319,9 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the
 
   return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir()));
 }
+
+void SketchPlugin_Sketch::exchangeIDs(
+  std::shared_ptr<ModelAPI_Feature> theFeature1, std::shared_ptr<ModelAPI_Feature> theFeature2)
+{
+  reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2);
+}
index 3246a2ad728721f27e3024645f43dc7ee9095cdd..cef6307e658255d11adecb1bf8a8b384784f5cd7 100644 (file)
@@ -196,6 +196,11 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu
 
   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
+  /// Exchanges IDs of two given features: needed for fillet feature better naming (issue 769)
+  SKETCHPLUGIN_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
+    std::shared_ptr<ModelAPI_Feature> theFeature2);
+
+
   /// \brief Create a result for the point in the attribute if the attribute is initialized
   /// \param theAttributeID an attribute string
   /// \param theIndex an index of the result