Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index dbe635b33d2d5b25be75b94c51ec7731606fed9d..736de32d2d7059deaafe0394e5b8e1d83f5cf0cd 100644 (file)
@@ -12,6 +12,8 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Tools.h>
 
+#include <ModuleBase_ResultPrs.h>
+
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_IPresentable.h>
 
@@ -59,7 +61,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
         boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
         if (aShapePtr) {
           anAIS = AISObjectPtr(new GeomAPI_AISObject());
-          anAIS->createShape(aShapePtr);
+          anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
+          //anAIS->createShape(aShapePtr);
           isShading = true;
         }
       }
@@ -107,38 +110,27 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
   if (!isVisible(theObject))
     return;
 
-  Handle(AIS_InteractiveObject) aAISIO;
   AISObjectPtr aAISObj = getAISObject(theObject);
+  Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+
   GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
   if (aPrs) {
     AISObjectPtr aAIS_Obj = aPrs->getAISObject(aAISObj);
-    if (aAISObj && !aAIS_Obj) {
+    if (!aAIS_Obj) {
       erase(theObject, isUpdateViewer);
       return;
     }
-    aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
-  } else {
-    ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-    if (aResult) {
-      boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
-      if (aShapePtr) {
-        Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(
-            aAISObj->impl<Handle(AIS_InteractiveObject)>());
-        if (!aAISShape.IsNull()) {
-          aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
-          aAISIO = aAISShape;
-        }
-      }
+    if (aAIS_Obj != aAISObj) {
+      myResult2AISObjectMap[theObject] = aAIS_Obj;
     }
+    aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
   }
+
   if (!aAISIO.IsNull()) {
     Handle(AIS_InteractiveContext) aContext = AISContext();
     if (aContext.IsNull())
       return;
     aContext->Redisplay(aAISIO, isUpdateViewer);
-    //if (aContext->HasOpenedContext()) {
-    //  aContext->Load(aAISIO, -1, true/*allow decomposition*/);
-    //}
   }
 }
 
@@ -258,8 +250,10 @@ void XGUI_Displayer::setSelected(const QList<ObjectPtr>& theResults, const bool
 void XGUI_Displayer::clearSelected()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext)
+  if (aContext) {
+    aContext->UnhilightCurrents(false);
     aContext->ClearSelected();
+  }
 }
 
 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)