Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / XGUI / XGUI_FacesPanel.cpp
index 01211ae75611a35ec61984507a104cf0dcddc314..2a1624da88adccfa72d99557287b703a348729a4 100644 (file)
@@ -232,9 +232,12 @@ void XGUI_FacesPanel::processSelection()
       aPrs->interactive());
     if (aResultPrs.IsNull())
       continue;
+    QString aItemName = XGUI_Tools::generateName(aPrs);
+    if (myListView->hasItem(aItemName))
+      return;
 
     myItems.insert(myLastItemIndex, aPrs);
-    myListView->addItem(generateName(aPrs), myLastItemIndex);
+    myListView->addItem(aItemName, myLastItemIndex);
     myLastItemIndex++;
     isModified = true;
 
@@ -422,31 +425,6 @@ void XGUI_FacesPanel::closeEvent(QCloseEvent* theEvent)
   emit closed();
 }
 
-//********************************************************************
-QString XGUI_FacesPanel::generateName(const ModuleBase_ViewerPrsPtr& thePrs)
-{
-  if (!thePrs.get() || !thePrs->object().get())
-    return "Undefined";
-
-  GeomShapePtr aContext;
-  ObjectPtr anObject = thePrs->object();
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-  if (aResult.get())
-    aContext = aResult->shape();
-  else {
-    // TODO if there is this case
-  }
-
-  QString aName = anObject->data()->name().c_str();
-  if (aContext.get()) {
-    GeomShapePtr aSubShape(new GeomAPI_Shape());
-    aSubShape->setImpl(new TopoDS_Shape(ModuleBase_Tools::getSelectedShape(thePrs)));
-    if (!aSubShape->isEqual(aContext))
-      aName += QString("_%1").arg(GeomAlgoAPI_CompoundBuilder::id(aContext, aSubShape));
-  }
-  return aName;
-}
-
 //********************************************************************
 bool XGUI_FacesPanel::customizeObject(const ObjectPtr& theObject,
                                       const AISObjectPtr& thePresentation)