Salome HOME
Fix for the issue #1766 : treat face as equal with different orientation to find...
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
index 012ebb0b584eaba717e4c250fdcb339dd7a69512..ae98b8a18d4f8d79798063e20a8c77c72cb6c098 100755 (executable)
@@ -12,6 +12,7 @@
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_IconFactory.h>
+#include <ModuleBase_ResultPrs.h>
 
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeRefAttr.h>
@@ -21,6 +22,7 @@
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeRefAttrList.h>
 #include <ModelAPI_ResultPart.h>
+#include <ModelAPI_ResultConstruction.h>
 #include <Events_Loop.h>
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Events.h>
 
+#include <ModelGeomAlgo_Point2D.h>
+
 #include <TopoDS_Iterator.hxx>
 
 #include <GeomDataAPI_Point2D.h>
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
+#include <GeomAPI_ShapeExplorer.h>
 
 #include <Config_PropManager.h>
+#include <Config_Translator.h>
+
+#include <Prs3d_PointAspect.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+
+#include <Image_AlienPixMap.hxx>
 
 #include <QWidget>
 #include <QLayout>
 #include <QApplication>
 #include <QMessageBox>
 #include <QAction>
+#include <QTextCodec>
 
 #include <sstream>
 #include <string>
 
+#ifdef WIN32
+#pragma warning(disable : 4996) // for getenv
+#endif
+
 const double tolerance = 1e-7;
+const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4;
 
 //#define DEBUG_ACTIVATE_WINDOW
 //#define DEBUG_SET_FOCUS
@@ -74,6 +91,12 @@ const double tolerance = 1e-7;
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 #endif
 
+#ifdef WIN32
+# define FSEP "\\"
+#else
+# define FSEP "/"
+#endif
+
 namespace ModuleBase_Tools {
 
 //******************************************************************
@@ -292,26 +315,12 @@ QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
                                                                                        .c_str());
     }
     if (isUseAttributesInfo) {
-      std::list<AttributePtr> anAttrs = aFeature->data()->attributes("");
-      std::list<AttributePtr>::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end();
-      QStringList aValues;
-      for(; anIt != aLast; anIt++) {
-        AttributePtr anAttr = *anIt;
-        QString aValue = "not defined";
-        std::string aType = anAttr->attributeType();
-        if (aType == GeomDataAPI_Point2D::typeId()) {
-          std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-                                                                                         anAttr);
-          if (aPoint.get())
-            aValue = QString("(%1, %2)").arg(aPoint->x()).arg(aPoint->y());
-        }
-        else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
-        }
-
-        aValues.push_back(QString("%1: %2").arg(anAttr->id().c_str()).arg(aValue).toStdString().c_str());
-      }
-      if (!aValues.empty())
-        aFeatureStr.append(QString(", attributes: %1").arg(aValues.join(", ").toStdString().c_str()));
+      std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes;
+      std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(aFeature,
+                                                                          anAttributes).c_str();
+      if (!aPointsInfo.empty())
+        aFeatureStr.append(QString(", attributes: %1")
+          .arg(aPointsInfo.c_str()).toStdString().c_str());
     }
   }
 
@@ -332,6 +341,8 @@ QString getShapeTypeInfo(const int theType)
     case TopAbs_EDGE:      anInfo = "edge"; break;
     case TopAbs_VERTEX:    anInfo = "vertex"; break;
     case TopAbs_SHAPE:     anInfo = "shape"; break;
+    case ModuleBase_ResultPrs::Sel_Result:
+                           anInfo = "result_shape"; break;
     default: break;
   }
   return anInfo;
@@ -382,8 +393,9 @@ QString displayedInteractiveObjects(Handle(AIS_InteractiveContext)& theContext,
 
     if (!aShapePrs.IsNull()) {
       const TopoDS_Shape& aShape = aShapePrs->Shape();
-      if (aShape.IsNull())
-        Events_Error::throwException("An empty AIS presentation");
+      if (aShape.IsNull()) {
+        //Events_Error::throwException("An empty AIS presentation");
+      }
       else
         anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
     }
@@ -443,8 +455,9 @@ QString activeOwners(Handle(AIS_InteractiveContext)& theContext, const bool theS
 
     if (!BROwnr.IsNull() && BROwnr->HasShape()) {
       const TopoDS_Shape& aShape = BROwnr->Shape();
-      if (aShape.IsNull())
-        Events_Error::throwException("An empty AIS presentation");
+      if (aShape.IsNull()) {
+        //Events_Error::throwException("An empty AIS presentation");
+      }
       else
         anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
     }
@@ -456,7 +469,8 @@ QString activeOwners(Handle(AIS_InteractiveContext)& theContext, const bool theS
   return aValue;
 }
 
-QString selectedOwners(Handle(AIS_InteractiveContext)& theContext, const bool theShapeInfoOnly = true)
+QString selectedOwners(Handle(AIS_InteractiveContext)& theContext, 
+                              const bool theShapeInfoOnly = true)
 {
   QStringList anObjects;
   if (theContext.IsNull())
@@ -503,10 +517,10 @@ void selectionInfo(Handle(AIS_InteractiveContext)& theContext, const std::string
 #endif
 }
 
-typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
+typedef QMap<QString, int> ShapeTypes;
 static ShapeTypes myShapeTypes;
 
-TopAbs_ShapeEnum shapeType(const QString& theType)
+int shapeType(const QString& theType)
 {
   if (myShapeTypes.count() == 0) {
     myShapeTypes["compound"]   = TopAbs_COMPOUND;
@@ -525,12 +539,13 @@ TopAbs_ShapeEnum shapeType(const QString& theType)
     myShapeTypes["edges"]      = TopAbs_EDGE;
     myShapeTypes["vertex"]     = TopAbs_VERTEX;
     myShapeTypes["vertices"]   = TopAbs_VERTEX;
-    myShapeTypes["objects"]    = TopAbs_SHAPE;
+    myShapeTypes["object"]     = ModuleBase_ResultPrs::Sel_Result;
+    myShapeTypes["objects"]    = ModuleBase_ResultPrs::Sel_Result;
   }
   QString aType = theType.toLower();
   if(myShapeTypes.contains(aType))
     return myShapeTypes[aType];
-  Events_Error::send("Shape type defined in XML is not implemented!");
+  Events_InfoMessage("ModuleBase_Tools", "Shape type defined in XML is not implemented!").send();
   return TopAbs_SHAPE;
 }
 
@@ -556,14 +571,59 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe
   }
 }
 
+/*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
+{
+  if (!theGeomShape.get())
+    return false;
+  // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+  // correction of deviation for them should not influence to the application performance
+  GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
+  bool anEmpty = anExp.empty();
+  return !anExp.more();
+}*/
+
+/*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
+                                    const Handle(Prs3d_Drawer)& theDrawer)
+{
+  if (!theResult.get())
+    return;
+  bool aUseDeviation = false;
+
+  std::string aResultGroup = theResult->groupName();
+  if (aResultGroup == ModelAPI_ResultConstruction::group())
+    aUseDeviation = true;
+  else if (aResultGroup == ModelAPI_ResultBody::group()) {
+    GeomShapePtr aGeomShape = theResult->shape();
+    if (aGeomShape.get())
+      aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
+  }
+  if (aUseDeviation)
+    theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
+}
+*/
 void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
                                     const Handle(Prs3d_Drawer)& theDrawer)
 {
   if (theShape.IsNull())
     return;
-  TopAbs_ShapeEnum aType = theShape.ShapeType();
-  if ((aType == TopAbs_EDGE) || (aType == TopAbs_WIRE)) 
-    theDrawer->SetDeviationCoefficient(1.e-4);
+
+  std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
+  aGeomShape->setImpl(new TopoDS_Shape(theShape));
+
+  // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+  // correction of deviation for them should not influence to the application performance
+  GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+  bool isConstruction = !anExp.more();
+
+  double aDeflection;
+  if (isConstruction)
+    aDeflection = Config_PropManager::real("Visualization", "construction_deflection",
+                                           ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
+  else
+    aDeflection = Config_PropManager::real("Visualization", "body_deflection",
+                                           ModelAPI_ResultBody::DEFAULT_DEFLECTION());
+
+  theDrawer->SetDeviationCoefficient(aDeflection);
 }
 
 Quantity_Color color(const std::string& theSection,
@@ -579,17 +639,20 @@ ObjectPtr getObject(const AttributePtr& theAttribute)
   ObjectPtr anObject;
   std::string anAttrType = theAttribute->attributeType();
   if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    AttributeRefAttrPtr anAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
     if (anAttr != NULL && anAttr->isObject())
       anObject = anAttr->object();
   }
   if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
-    AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+    AttributeSelectionPtr anAttr =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
     if (anAttr != NULL)
       anObject = anAttr->context();
   }
   if (anAttrType == ModelAPI_AttributeReference::typeId()) {
-    AttributeReferencePtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+    AttributeReferencePtr anAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
     if (anAttr.get() != NULL)
       anObject = anAttr->value();
   }
@@ -646,7 +709,8 @@ void getParameters(QStringList& theParameters)
   }
 }
 
-std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop, const FeaturePtr& theFeature)
+std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop, 
+                               const FeaturePtr& theFeature)
 {
   std::string anAttributeId;
 
@@ -671,14 +735,16 @@ bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
 
   std::string aType = theAttribute->attributeType();
   if (aType == ModelAPI_AttributeReference::typeId()) {
-    AttributeReferencePtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+    AttributeReferencePtr aRef = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
     ObjectPtr aObject = aRef->value();
     aHasObject = aObject && aObject->isSame(theObject);
     //if (!(aObject && aObject->isSame(theObject))) {
     //  aRef->setValue(theObject);
     //}
   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    AttributeRefAttrPtr aRefAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
 
     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
     if (anAttribute.get()) {
@@ -704,17 +770,17 @@ bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
                          std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
     aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily);
-    //if (!theCheckIfAttributeHasObject || !aSelectionListAttr->isInList(aResult, theShape, theTemporarily))
-    //  aSelectionListAttr->append(aResult, theShape, theTemporarily);
   }
   else if (aType == ModelAPI_AttributeRefList::typeId()) {
-    AttributeRefListPtr aRefListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    AttributeRefListPtr aRefListAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
     aHasObject = aRefListAttr->isInList(theObject);
     //if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
     //  aRefListAttr->append(theObject);
   }
   else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
-    AttributeRefAttrListPtr aRefAttrListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
+    AttributeRefAttrListPtr aRefAttrListAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
 
     if (anAttribute.get()) {
@@ -731,22 +797,25 @@ bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
   return aHasObject;
 }
 
-void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
+bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
                const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
                const bool theTemporarily, const bool theCheckIfAttributeHasObject)
 {
   if (!theAttribute.get())
-    return;
+    return false;
 
+  bool isDone = true;
   std::string aType = theAttribute->attributeType();
   if (aType == ModelAPI_AttributeReference::typeId()) {
-    AttributeReferencePtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
+    AttributeReferencePtr aRef = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
     ObjectPtr aObject = aRef->value();
     if (!(aObject && aObject->isSame(theObject))) {
       aRef->setValue(theObject);
     }
   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    AttributeRefAttrPtr aRefAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
 
     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
     if (anAttribute.get())
@@ -769,16 +838,23 @@ void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
     AttributeSelectionListPtr aSelectionListAttr =
                          std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (!theCheckIfAttributeHasObject || !aSelectionListAttr->isInList(aResult, theShape, theTemporarily))
+    if (!theCheckIfAttributeHasObject || 
+        !aSelectionListAttr->isInList(aResult, theShape, theTemporarily))
       aSelectionListAttr->append(aResult, theShape, theTemporarily);
   }
   else if (aType == ModelAPI_AttributeRefList::typeId()) {
-    AttributeRefListPtr aRefListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
-    if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
-      aRefListAttr->append(theObject);
+    AttributeRefListPtr aRefListAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+    if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
+      if (theObject.get())
+        aRefListAttr->append(theObject);
+      else
+        isDone = false;
+    }
   }
   else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
-    AttributeRefAttrListPtr aRefAttrListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
+    AttributeRefAttrListPtr aRefAttrListAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
 
     if (anAttribute.get()) {
@@ -786,10 +862,15 @@ void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
         aRefAttrListAttr->append(anAttribute);
     }
     else {
-      if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
-        aRefAttrListAttr->append(theObject);
+      if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
+        if (theObject.get())
+          aRefAttrListAttr->append(theObject);
+        else
+          isDone = false;
+      }
     }
   }
+  return isDone;
 }
 
 GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
@@ -801,7 +882,8 @@ GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* th
   std::string aType = theAttribute->attributeType();
   if (aType == ModelAPI_AttributeReference::typeId()) {
   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
-    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+    AttributeRefAttrPtr aRefAttr = 
+      std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
     if (aRefAttr.get() && !aRefAttr->isObject()) {
       AttributePtr anAttribute = aRefAttr->attr();
       aShape = theWorkshop->module()->findShape(anAttribute);
@@ -811,6 +893,8 @@ GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* th
                                                                                  (theAttribute);
     aShape = aSelectAttr->value();
   }
+  else // Geom2D point processing
+    aShape = theWorkshop->module()->findShape(theAttribute);
   return aShape;
 }
 
@@ -882,7 +966,8 @@ QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
 }
 
 //**************************************************************
-void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, std::set<FeaturePtr>& theRefFeatures)
+void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, 
+                                    std::set<FeaturePtr>& theRefFeatures)
 {
   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
   if (aFeature.get()) {
@@ -894,7 +979,7 @@ void refsToFeatureInFeatureDocument(const ObjectPtr& theObject, std::set<Feature
 
 
 //**************************************************************
-bool isSubOfComposite(const ObjectPtr& theObject)
+/*bool isSubOfComposite(const ObjectPtr& theObject)
 {
   bool isSub = false;
   std::set<FeaturePtr> aRefFeatures;
@@ -905,10 +990,10 @@ bool isSubOfComposite(const ObjectPtr& theObject)
     isSub = isSubOfComposite(theObject, *anIt);
   }
   return isSub;
-}
+}*/
 
 //**************************************************************
-bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
+/*bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
 {
   bool isSub = false;
   CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
@@ -924,6 +1009,18 @@ bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
     }
   }
   return isSub;
+}*/
+
+//**************************************************************
+ResultPtr firstResult(const ObjectPtr& theObject)
+{
+  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (!aResult.get()) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+    if (aFeature.get())
+      aResult = aFeature->firstResult();
+  }
+  return aResult;
 }
 
 //**************************************************************
@@ -941,15 +1038,44 @@ bool isFeatureOfResult(const FeaturePtr& theFeature, const std::string& theGroup
   return aFirstResult->groupName() == theGroupOfResult;
 }
 
+//**************************************************************
+bool hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures)
+{
+  bool aFoundModuleDocumentObject = false;
+  DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
+
+  std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+  for (; anIt != aLast && !aFoundModuleDocumentObject; anIt++) {
+    FeaturePtr aFeature = *anIt;
+    ResultPtr aResult = ModuleBase_Tools::firstResult(aFeature);
+    if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group())
+      continue;
+    aFoundModuleDocumentObject = aFeature->document() == aModuleDoc;
+  }
+
+  return aFoundModuleDocumentObject;
+}
+
 //**************************************************************
 bool askToDelete(const std::set<FeaturePtr> theFeatures,
                  const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
                  QWidget* theParent,
-                 std::set<FeaturePtr>& theReferencesToDelete)
+                 std::set<FeaturePtr>& theReferencesToDelete,
+                 const std::string& thePrefixInfo)
 {
+  QString aNotActivatedDocWrn;
+  std::string aNotActivatedNames;
+  if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
+    if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures))
+      aNotActivatedDocWrn = 
+        QObject::tr("Selected objects can be used in Part documents which are not loaded:%1.\n")
+                            .arg(aNotActivatedNames.c_str());
+  }
+  
   std::set<FeaturePtr> aFeaturesRefsTo;
   std::set<FeaturePtr> aFeaturesRefsToParameter;
   std::set<FeaturePtr> aParameterFeatures;
+  QStringList aPartFeatureNames;
   std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
                                        aLast = theFeatures.end();
   // separate features to references to parameter features and references to others
@@ -958,6 +1084,9 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
     if (theReferences.find(aFeature) == theReferences.end())
       continue;
 
+    if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
+      aPartFeatureNames.append(aFeature->name().c_str());
+
     std::set<FeaturePtr> aRefFeatures;
     std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
     std::set<FeaturePtr>::const_iterator aRefIt = aRefList.begin(), aRefLast = aRefList.end();
@@ -990,7 +1119,7 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
     }
   }
   aParamFeatureNames.sort();
-  QStringList aPartFeatureNames, anOtherFeatureNames;
+  QStringList anOtherFeatureNames;
   anIt = theReferencesToDelete.begin();
   aLast = theReferencesToDelete.end();
   for (; anIt != aLast; anIt++) {
@@ -1012,16 +1141,28 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
   aMessageBox.setDefaultButton(QMessageBox::No);
 
   QString aText;
+  if (!thePrefixInfo.empty())
+    aText = thePrefixInfo.c_str();
   QString aSep = ", ";
-  if (!aPartFeatureNames.empty())
-    aText += QString(QObject::tr("The following parts will be deleted: %1.\n")).arg(aPartFeatureNames.join(aSep));
-  if (!anOtherFeatureNames.empty())
-    aText += QString(QObject::tr("Selected features are used in the following features: %1.\nThese features will be deleted.\n"))
+  if (!aPartFeatureNames.empty()) {
+    aText += QString(QObject::tr("The following parts will be deleted: %1.\n"))
+             .arg(aPartFeatureNames.join(aSep));
+  }
+  if (!aNotActivatedDocWrn.isEmpty())
+    aText += aNotActivatedDocWrn;
+  if (!anOtherFeatureNames.empty()) {
+    const char* aMsg = "Features are used in the following features: %1.\nThese \
+ features will be deleted.\n";
+    aText += QString(QObject::tr(aMsg))
                      .arg(anOtherFeatureNames.join(aSep));
+  }
   if (!aParamFeatureNames.empty()) {
-    aText += QString(QObject::tr("Selected parameters are used in the following features: %1.\nThese features will be deleted.\nOr parameters could be replaced by their values.\n"))
+    const char* aMsg = "Parameters are used in the following features: %1.\nThese features will \
+ be deleted.\nOr parameters could be replaced by their values.\n";
+    aText += QString(QObject::tr(aMsg))
                      .arg(aParamFeatureNames.join(aSep));
-    QPushButton *aReplaceButton = aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
+    QPushButton *aReplaceButton = 
+      aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
   }
 
   if (!aText.isEmpty()) {
@@ -1038,7 +1179,8 @@ bool askToDelete(const std::set<FeaturePtr> theFeatures,
         ModelAPI_ReplaceParameterMessage::send(aObj, 0);
     }
     else
-      theReferencesToDelete.insert(aFeaturesRefsToParameterOnly.begin(), aFeaturesRefsToParameterOnly.end());
+      theReferencesToDelete.insert(aFeaturesRefsToParameterOnly.begin(), 
+                                   aFeaturesRefsToParameterOnly.end());
   }
   return true;
 }
@@ -1058,6 +1200,66 @@ void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& t
   }
 }
 
+void translate(const std::string& theContext, std::string& theMessage)
+{
+  if (!theMessage.empty()) {
+    std::string aStr = Config_Translator::translate(theContext, theMessage);
+    if (!aStr.empty()) {
+      std::string aCodec = Config_Translator::codec(theContext);
+      theMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str()).toStdString();
+    }
+  }
+}
+
+void setPointBallHighlighting(AIS_Shape* theAIS)
+{
+  static Handle(Image_AlienPixMap) aPixMap;
+  if(aPixMap.IsNull()) {
+    // Load icon for the presentation
+    std::string aFile;
+    char* anEnv = getenv("SHAPER_ROOT_DIR");
+    if(anEnv) {
+      aFile = std::string(anEnv) +
+        FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
+    } else {
+      anEnv = getenv("OPENPARTS_ROOT_DIR");
+      if (anEnv)
+        aFile = std::string(anEnv) + FSEP + "resources";
+    }
+
+    aFile += FSEP;
+    static const std::string aMarkerName = "marker_dot.png";
+    aFile += aMarkerName;
+    aPixMap = new Image_AlienPixMap();
+    if(!aPixMap->Load(aFile.c_str())) {
+      // The icon for constraint is not found
+      static const std::string aMsg = 
+        "Error: Point market not found by path: \"" + aFile + "\". Falling back.";
+      //Events_InfoMessage("ModuleBase_Tools::setPointBallHighlighting", aMsg).send();
+    }
+  }
+
+  Handle(Graphic3d_AspectMarker3d) anAspect;
+  Handle(Prs3d_Drawer) aDrawer = theAIS->HilightAttributes();
+  if(aDrawer->HasOwnPointAspect()) {
+    Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
+    if(aPixMap->IsEmpty()) {
+      anAspect = aPntAspect->Aspect();
+      anAspect->SetType(Aspect_TOM_BALL);
+    } else {
+      if(aPixMap->Format() == Image_PixMap::ImgGray) {
+        aPixMap->SetFormat (Image_PixMap::ImgAlpha);
+      } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) {
+        aPixMap->SetFormat (Image_PixMap::ImgAlphaF);
+      }
+      anAspect = new Graphic3d_AspectMarker3d(aPixMap);
+      aPntAspect->SetAspect(anAspect);
+    }
+    aDrawer->SetPointAspect(aPntAspect);
+    theAIS->SetHilightAttributes(aDrawer);
+  }
+}
+
 } // namespace ModuleBase_Tools