Salome HOME
Change icons for chamfer
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Trim.cpp
index 387f3a8b4e9edaf2ccfcffc9263c3f0b0066b81d..66d7157c1abb0fb372a78cb862de0585aa19a9be 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  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
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "SketchPlugin_Trim.h"
@@ -240,6 +239,10 @@ void SketchPlugin_Trim::execute()
   std::cout << " Base Feature: " << aBaseFeature->data()->name() << std::endl;
 #endif
   findShapePoints(SELECTED_OBJECT(), SELECTED_POINT(), aStartShapePoint, aLastShapePoint);
+  if (!aStartShapePoint || !aLastShapePoint) {
+    setError("Error: Selected point is not placed on any edge");
+    return;
+  }
 
   std::shared_ptr<GeomAPI_Pnt2d> aStartShapePoint2d = convertPoint(aStartShapePoint);
   std::shared_ptr<GeomAPI_Pnt2d> aLastShapePoint2d = convertPoint(aLastShapePoint);
@@ -292,6 +295,9 @@ void SketchPlugin_Trim::execute()
   std::cout << "[" << aRefsToFeature.size() << "] " << aRefsInfo << std::endl;
   std::cout << "---- getRefAttributes:end ----" << std::endl;
 #endif
+
+  keepCurrentFeature();
+
   std::set<AttributePoint2DPtr> aFurtherCoincidences;
   std::set<std::pair<AttributePtr, AttributePtr>> aModifiedAttributes;
   const std::string& aKind = aBaseFeature->getKind();
@@ -315,6 +321,8 @@ void SketchPlugin_Trim::execute()
                           aFurtherCoincidences, aModifiedAttributes);
   }
 
+  restoreCurrentFeature();
+
   // constraints to end points of trim feature
   if (myObjectToPoints.find(aBaseObject) == myObjectToPoints.end())
     fillObjectShapes(aBaseObject, sketch()->data()->owner(), myCashedShapes, myObjectToPoints);
@@ -478,6 +486,7 @@ void SketchPlugin_Trim::execute()
 #endif
 }
 
+// LCOV_EXCL_START
 std::string SketchPlugin_Trim::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
 #ifdef DEBUG_TRIM_METHODS
@@ -529,6 +538,7 @@ std::string SketchPlugin_Trim::processEvent(const std::shared_ptr<Events_Message
   }
   return aFilledAttributeName;
 }
+// LCOV_EXCL_STOP
 
 bool SketchPlugin_Trim::setCoincidenceToAttribute(const AttributePtr& theAttribute,
                                 const std::set<AttributePoint2DPtr>& theFurtherCoincidences,
@@ -1197,20 +1207,6 @@ void SketchPlugin_Trim::fillAttribute(const AttributePtr& theModifiedAttribute,
     if (aModifiedAttribute.get() && aSourceAttribute.get())
       aModifiedAttribute->setValue(aSourceAttribute->value());
   }
-  else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttributeToFill = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                                                             theModifiedAttribute);
-    AttributeRefAttrPtr aSourceRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                         theSourceAttribute);
-    if (!aSourceRefAttr.get())
-      aRefAttributeToFill->setAttr(theSourceAttribute);
-    else {
-      if (aSourceRefAttr->isObject())
-        aRefAttributeToFill->setObject(aSourceRefAttr->object());
-      else
-        aRefAttributeToFill->setAttr(aSourceRefAttr->attr());
-    }
-  }
 }
 
 FeaturePtr SketchPlugin_Trim::createLineFeature(const FeaturePtr& theBaseFeature,