Salome HOME
Issue #1664 In the Sketcher, add the function Split a segment - correction for arc...
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Translation.cpp
index 423ea9459aed423d9865c008c595aa6452a20e6d..e335277846986784435cb6a3cde322cc9736273e 100644 (file)
@@ -27,8 +27,6 @@ void FeaturesPlugin_Translation::initAttributes()
   AttributeSelectionListPtr aSelection = 
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Translation::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
-  // revolution works with faces always
-  aSelection->setSelectionType("SOLID");
 
   data()->addAttribute(FeaturesPlugin_Translation::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FeaturesPlugin_Translation::DISTANCE_ID(), ModelAPI_AttributeDouble::typeId());
@@ -47,7 +45,8 @@ void FeaturesPlugin_Translation::execute()
   for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
     std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr = anObjectsSelList->value(anObjectsIndex);
     std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) {
+    if(!anObject.get()) { // may be for not-activated parts
+      eraseResults();
       return;
     }
     anObjects.push_back(anObject);
@@ -88,27 +87,27 @@ void FeaturesPlugin_Translation::execute()
       aResultPart->setTrsf(*aContext, aTrsf);
       setResult(aResultPart);
     } else {
-      GeomAlgoAPI_Translation aMovementAlgo(aBaseShape, anAxis, aDistance);
+      GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance);
 
       // Checking that the algorithm worked properly.
-      if(!aMovementAlgo.isDone()) {
-        static const std::string aFeatureError = "Movement algorithm failed";
+      if(!aTranslationAlgo.isDone()) {
+        static const std::string aFeatureError = "Error: Translation algorithm failed.";
         setError(aFeatureError);
         break;
       }
-      if(aMovementAlgo.shape()->isNull()) {
-        static const std::string aShapeError = "Resulting shape is Null";
+      if(aTranslationAlgo.shape()->isNull()) {
+        static const std::string aShapeError = "Error: Resulting shape is Null.";
         setError(aShapeError);
         break;
       }
-      if(!aMovementAlgo.isValid()) {
-        std::string aFeatureError = "Warning: resulting shape is not valid";
+      if(!aTranslationAlgo.isValid()) {
+        std::string aFeatureError = "Error: Resulting shape is not valid.";
         setError(aFeatureError);
         break;
       }
 
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      LoadNamingDS(aMovementAlgo, aResultBody, aBaseShape);
+      loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape);
       setResult(aResultBody, aResultIndex);
     }
     aResultIndex++;
@@ -118,19 +117,19 @@ void FeaturesPlugin_Translation::execute()
   removeResults(aResultIndex);
 }
 
-void FeaturesPlugin_Translation::LoadNamingDS(const GeomAlgoAPI_Translation& theMovementAlgo,
-                                           std::shared_ptr<ModelAPI_ResultBody> theResultBody,
-                                           std::shared_ptr<GeomAPI_Shape> theBaseShape)
+void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo,
+                                              std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                                              std::shared_ptr<GeomAPI_Shape> theBaseShape)
 {
   // Store result.
-  theResultBody->storeModified(theBaseShape, theMovementAlgo.shape());
+  theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape());
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theMovementAlgo.mapOfShapes();
+  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
 
-  int aMovedTag = 1;
-  std::string aMovedName = "Moved";
-  theResultBody->loadAndOrientModifiedShapes(theMovementAlgo.makeShape().get(),
-                                              theBaseShape, GeomAPI_Shape::FACE,
-                                              aMovedTag, aMovedName, *aSubShapes.get());
+  int aTranslatedTag = 1;
+  std::string aTranslatedName = "Translated";
+  theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo,
+                                             theBaseShape, GeomAPI_Shape::FACE,
+                                             aTranslatedTag, aTranslatedName, *aSubShapes.get());
 
 }