]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Pre-highlighting in viewer
authorvsv <vsv@opencascade.com>
Fri, 28 Sep 2018 08:13:16 +0000 (11:13 +0300)
committervsv <vsv@opencascade.com>
Fri, 28 Sep 2018 08:13:16 +0000 (11:13 +0300)
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 899ca492d4b0788c76e61f677b02724bc57fcee1..8af188b48c6e85d6583ab83e6d716588531383e2 100644 (file)
@@ -167,7 +167,7 @@ void XGUI_ViewerProxy::connectToViewer()
           SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
 
   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
-    this, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+    this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
 
   connect(aViewer, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)),
     this, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
@@ -287,79 +287,9 @@ void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouse
   emit mouseDoubleClick(theWnd, theEvent);
 }
 
-void XGUI_ViewerProxy::displayHighlight()
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-
-  if (myResult->groupName() == ModelAPI_ResultConstruction::group()) {
-    FeaturePtr aFeature = ModelAPI_Feature::feature(myResult);
-    if (aFeature.get()) {
-      std::list<ResultPtr> aResults = aFeature->results();
-      std::list<ResultPtr>::const_iterator aIt;
-      ResultPtr aRes;
-      Handle(AIS_Shape) aAis;
-      for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
-        aRes = (*aIt);
-        TopoDS_Shape aTShape = aRes->shape()->impl<TopoDS_Shape>();
-        aAis = new AIS_Shape(aTShape);
-        aAis->SetColor(Quantity_NOC_CYAN4);
-        aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost
-        myHighlights.Append(aAis);
-        aContext->Display(aAis, false);
-        aContext->Deactivate(aAis);
-      }
-    }
-  }
-  else {
-    TopoDS_Shape aTShape = myResult->shape()->impl<TopoDS_Shape>();
-    Handle(AIS_Shape) aAis = new AIS_Shape(aTShape);
-    aAis->SetColor(Quantity_NOC_CYAN4);
-    aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost
-    myHighlights.Append(aAis);
-    aContext->Display(aAis, false);
-    aContext->Deactivate(aAis);
-  }
-}
-
-void XGUI_ViewerProxy::eraseHighlight()
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  Handle(AIS_InteractiveObject) anAISIO;
-  AIS_ListIteratorOfListOfInteractive aLIt;
-  for (aLIt.Initialize(myHighlights); aLIt.More(); aLIt.Next()) {
-    anAISIO = aLIt.Value();
-    aContext->Remove(anAISIO, false);
-  }
-  myHighlights.Clear();
-}
-
 void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
 {
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull()) {
-    Handle(SelectMgr_EntityOwner) aOwner;
-    Handle(AIS_InteractiveObject) anIO;
-    bool isDisplayed = false;
-    ResultPtr aRes;
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
-      aOwner = aContext->DetectedOwner();
-      anIO = Handle(AIS_InteractiveObject)::DownCast(aOwner->Selectable());
-      aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aDisplayer->getObject(anIO));
-      if (aRes.get() && (aRes != myResult)) {
-        eraseHighlight();
-        myResult = aRes;
-        displayHighlight();
-        aContext->UpdateCurrentViewer();
-      }
-      isDisplayed = aRes.get();
-    }
-    if (!isDisplayed) {
-      eraseHighlight();
-      aContext->UpdateCurrentViewer();
-      myResult = ResultPtr();
-    }
-  }
+  updateHighlight();
   emit mouseMove(theWnd, theEvent);
 }
 
@@ -472,6 +402,89 @@ bool XGUI_ViewerProxy::canDragByMouse() const
   }
 }
 
+//***************************************
+void XGUI_ViewerProxy::displayHighlight()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+
+  if (myResult->groupName() == ModelAPI_ResultConstruction::group()) {
+    FeaturePtr aFeature = ModelAPI_Feature::feature(myResult);
+    if (aFeature.get()) {
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      ResultPtr aRes;
+      Handle(AIS_Shape) aAis;
+      for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+        aRes = (*aIt);
+        TopoDS_Shape aTShape = aRes->shape()->impl<TopoDS_Shape>();
+        aAis = new AIS_Shape(aTShape);
+        aAis->SetColor(Quantity_NOC_CYAN4);
+        aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost
+        myHighlights.Append(aAis);
+        aContext->Display(aAis, false);
+        aContext->Deactivate(aAis);
+      }
+    }
+  }
+  else {
+    TopoDS_Shape aTShape = myResult->shape()->impl<TopoDS_Shape>();
+    Handle(AIS_Shape) aAis = new AIS_Shape(aTShape);
+    aAis->SetColor(Quantity_NOC_CYAN4);
+    aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost
+    myHighlights.Append(aAis);
+    aContext->Display(aAis, false);
+    aContext->Deactivate(aAis);
+  }
+}
+
+void XGUI_ViewerProxy::eraseHighlight()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  Handle(AIS_InteractiveObject) anAISIO;
+  AIS_ListIteratorOfListOfInteractive aLIt;
+  for (aLIt.Initialize(myHighlights); aLIt.More(); aLIt.Next()) {
+    anAISIO = aLIt.Value();
+    aContext->Remove(anAISIO, false);
+  }
+  myHighlights.Clear();
+}
+
+void XGUI_ViewerProxy::updateHighlight()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aContext.IsNull()) {
+    Handle(SelectMgr_EntityOwner) aOwner;
+    Handle(AIS_InteractiveObject) anIO;
+    bool isDisplayed = false;
+    ResultPtr aRes;
+    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
+      aOwner = aContext->DetectedOwner();
+      anIO = Handle(AIS_InteractiveObject)::DownCast(aOwner->Selectable());
+      aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aDisplayer->getObject(anIO));
+      if (aRes.get() && (aRes != myResult)) {
+        eraseHighlight();
+        myResult = aRes;
+        displayHighlight();
+        aContext->UpdateCurrentViewer();
+      }
+      isDisplayed = aRes.get();
+    }
+    if (!isDisplayed) {
+      eraseHighlight();
+      aContext->UpdateCurrentViewer();
+      myResult = ResultPtr();
+    }
+  }
+}
+
+#ifdef HAVE_SALOME
+void XGUI_ViewerProxy::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  updateHighlight();
+  emit mouseMove(theWnd, theEvent);
+}
+#endif
 
 //***************************************
 //void XGUI_ViewerProxy::Zfitall()
index 0e3396fb8426f268947a2eba2a7985ad7635aa17..178b99ab2651ecef6f51c8fc203a59aaff53d424 100644 (file)
@@ -152,11 +152,14 @@ private slots:
   void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
 
   void onViewTransformed(AppElements_ViewWindow::OperationType);
+#else
+  void onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*);
 #endif
 
  private:
    void displayHighlight();
    void eraseHighlight();
+   void updateHighlight();
 
   XGUI_Workshop* myWorkshop;
   ResultPtr myResult;