]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Patch on Bug GVIEW10227
authorapo <apo@opencascade.com>
Tue, 18 Oct 2005 15:14:43 +0000 (15:14 +0000)
committerapo <apo@opencascade.com>
Tue, 18 Oct 2005 15:14:43 +0000 (15:14 +0000)
  Highlighted group of elements remains in 3D viewer.

src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/VVTK/VVTK_Renderer.cxx
src/VVTK/VVTK_Renderer.h
src/VVTK/VVTK_ViewWindow.cxx

index 90c4e50cf383859f0bae32954cfc3f379fa1d2a5..c576c022445dd9e526d683276156256a442754bc 100644 (file)
@@ -493,13 +493,11 @@ VISU_Actor
 //----------------------------------------------------------------------------
 bool
 VISU_Actor
-::PreHighlight(SVTK_Selector* theSelector, 
-              vtkInteractorStyle* theInteractorStyle, 
+::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
               SVTK_SelectionEvent* theSelectionEvent,
               bool theIsHighlight)
 {
-  bool aRet = Superclass::PreHighlight(theSelector,
-                                      theInteractorStyle,
+  bool aRet = Superclass::PreHighlight(theInteractorStyle,
                                       theSelectionEvent,
                                       theIsHighlight);
 #ifndef ENABLE_ANNOTATION
@@ -520,7 +518,7 @@ VISU_Actor
        return false;
       
       vtkIdType aVTKId = myCellPicker->GetCellId();
-      if(aVTKId >= 0  && theSelector->IsValid(this,aVTKId,true) && hasIO()){
+      if(aVTKId >= 0  && mySelector->IsValid(this,aVTKId,true) && hasIO()){
        vtkIdType anObjId = GetElemObjId(aVTKId);
        if(vtkCell* aCell = GetElemCell(anObjId)){
          vtkPoints* aPts = aCell->GetPoints();
@@ -564,7 +562,7 @@ VISU_Actor
        return false;
 
       vtkIdType aVtkId = myPointPicker->GetPointId();
-      if(aVtkId >= 0  && theSelector->IsValid(this,aVtkId,true) && hasIO()){
+      if(aVtkId >= 0  && mySelector->IsValid(this,aVtkId,true) && hasIO()){
        vtkIdType anObjId = GetNodeObjId( aVtkId );
        if(float* aCoord = GetNodeCoord(anObjId)){
          // Display coordinates
index 8a6c5de09d7987afc05b5e1c78aaad9a96ecf4c8..6078198e93e39f381b2189ebecb9a39d77e9af51 100644 (file)
@@ -178,8 +178,7 @@ class VTKOCC_EXPORT VISU_Actor :
   //----------------------------------------------------------------------------
   virtual
   bool
-  PreHighlight(SVTK_Selector* theSelector, 
-              vtkInteractorStyle* theInteractorStyle, 
+  PreHighlight(vtkInteractorStyle* theInteractorStyle, 
               SVTK_SelectionEvent* theSelectionEvent,
               bool theIsHighlight);
 
index 4d7c1eff7396ac64ae3dfdc2b38d06129925d6e9..98620e9ffc9dfad4aa1e00312bbaed4b9c9fcce3 100644 (file)
@@ -58,6 +58,7 @@
 #include <vtkCallbackCommand.h>
 #include <vtkInteractorStyle.h>
 #include <vtkRenderWindowInteractor.h>
+#include <vtkOutlineSource.h>
 
 #include <sstream>
 #include <boost/bind.hpp>
@@ -469,23 +470,22 @@ bool VISU_GaussPtsAct::IsInfinitive()
 }
 
 //----------------------------------------------------------------------------
-bool VISU_GaussPtsAct::PreHighlight(SVTK_Selector* theSelector, 
-                                   vtkInteractorStyle* theInteractorStyle, 
+bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
                                    SVTK_SelectionEvent* theSelectionEvent,
                                    bool theIsHighlight)
 {
+  myPreHighlightActor->SetVisibility(false);
+  myCursorPyramid->SetVisibility(false);  
+
   if (!myBarVisibility) {
     return false;
   }
-  myCursorPyramid->SetVisibility(false);  
 
   if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight)
-    return Superclass::PreHighlight(theSelector,
-                                   theInteractorStyle,
+    return Superclass::PreHighlight(theInteractorStyle,
                                    theSelectionEvent,
                                    theIsHighlight);
 
-  myPreHighlightActor->SetVisibility(false);
 
   bool anIsSelectionModeChanged = (theSelectionEvent->mySelectionMode != mySelectionMode);
   if(!anIsSelectionModeChanged && mySelectionMode == ActorSelection)
@@ -508,7 +508,7 @@ bool VISU_GaussPtsAct::PreHighlight(SVTK_Selector* theSelector,
        return false;
       
       vtkIdType aVtkId = myPointPicker->GetPointId();
-      if(aVtkId >= 0 && theSelector->IsValid(this,aVtkId,true) && hasIO()){
+      if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
        vtkIdType anObjId = GetNodeObjId( aVtkId );
        if(myLastObjPointID != anObjId){
          float* aNodeCoord = GetNodeCoord(anObjId);
@@ -536,64 +536,59 @@ bool VISU_GaussPtsAct::PreHighlight(SVTK_Selector* theSelector,
 
   return anIsChanged;
 }
+
+
 //----------------------------------------------------------------------------
-bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector, 
-                                vtkInteractorStyle* theInteractorStyle, 
+bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, 
                                 SVTK_SelectionEvent* theSelectionEvent,
                                 bool theIsHighlight)
 { 
   if (!myBarVisibility) {
     return false;
   }
-  vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
-  vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
   //
-  Selection_Mode aSelectionMode=theSelectionEvent->mySelectionMode;
-  mySelectionMode=aSelectionMode;
+  Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
   //
-  if(aSelectionMode==ActorSelection ){
-    return Superclass::Highlight(theSelector,
-                                theInteractorStyle,
+  if(aSelectionMode == ActorSelection){
+    return Superclass::Highlight(theInteractorStyle,
                                 theSelectionEvent,
                                 theIsHighlight);
   }
   //
-  bool bRet = false;
-  
   if(!theSelectionEvent->myIsRectangle){
 
+    vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
     myPointPicker->Pick(theSelectionEvent->myX, 
                        theSelectionEvent->myY,
                        0.0, 
                        aRenderer);
 
     if(myPointPicker->GetActor() != this) {
-      theSelector->ClearIObjects();
-      return bRet;
+      mySelector->ClearIObjects();
+      return true;
     }
 
     vtkIdType aVtkId = myPointPicker->GetPointId();
-    if( aVtkId >= 0  && theSelector->IsValid( this, aVtkId, true ) && hasIO())  {
+    if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
       vtkIdType anObjId = GetNodeObjId( aVtkId );
       if(anObjId >= 0){
-       bRet=!bRet;
-       //
        // Update the Selector
-       if(theSelector->IsSelected(myIO))
-         theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
+       if(mySelector->IsSelected(myIO))
+         mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
        else{
          if(!theSelectionEvent->myIsShift){
-           theSelector->ClearIObjects();
+           mySelector->ClearIObjects();
          }
-         theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
-         theSelector->AddIObject(this);
+         mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
+         mySelector->AddIObject(this);
        }
        //
        float* aNodeCoord = GetNodeCoord(anObjId);
        //
        // FlyTo
+       vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
        float aDollyWas = anInteractor->GetDolly();
-       int aNumberOfFlyFramesWas=anInteractor->GetNumberOfFlyFrames();
+       int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
        
        anInteractor->SetDolly(0.);
        anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
@@ -602,13 +597,15 @@ bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
        anInteractor->SetDolly(aDollyWas);
        anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
        
-       return bRet;
+       mySelectionMode = aSelectionMode;
+
+       return true;
        //
       }// if( anObjId >= 0 ) {
-    }//if( aVtkId >= 0  && theSelector->IsValid( this, aVtkId, true ) && hasIO()) 
+    }//if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) 
   }//if(!theSelectionEvent->myIsRectangle){
   
-  return bRet;
+  return false;
 }
 
 //==================================================================
@@ -616,8 +613,8 @@ bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
 // purpose  :
 //==================================================================
 void
-VISU_GaussPtsAct::highlight(bool theHighlight,
-                           Selection_Mode theSelectionMode)
+VISU_GaussPtsAct
+::highlight(bool theIsHighlight)
 {
   myTextActor->SetVisibility(0);
   myCursorPyramidSelected->SetVisibility(0);
@@ -625,20 +622,15 @@ VISU_GaussPtsAct::highlight(bool theHighlight,
   myCellActor->SetVisibility(0);
   GetScalarBarCtrl()->SetIsMarked(false);
   GetScalarBarCtrl()->Update();
-}
-//==================================================================
-// function : highlight
-// purpose  :
-//==================================================================
-void VISU_GaussPtsAct::highlight(bool theHighlight,
-                                SVTK_Selector* theSelector)
-{
+
+  bool anIsVisible = GetVisibility();
+
+  if(mySelector->SelectionMode() == ActorSelection)
+    Superclass::highlight(theIsHighlight);
+
   TColStd_IndexedMapOfInteger aMapIndex;
-  //
-  theSelector->GetIndex( getIO(), aMapIndex );
-  int aNbOfParts = aMapIndex.Extent();
-  //
-  if(aNbOfParts!=1 || !myBarVisibility) {
+  mySelector->GetIndex( getIO(), aMapIndex );
+  if(aMapIndex.Extent() != 1 || !myBarVisibility) {
     return;
   }
   //
@@ -673,7 +665,7 @@ void VISU_GaussPtsAct::highlight(bool theHighlight,
                                    aRadius,
                                    aNodeCoord,
                                    myHighlightActor->GetProperty()->GetColor());
-      myCursorPyramidSelected->SetVisibility(1);
+      myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
       //
       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
        myGaussPointsPL->GetGaussPtsIDMapper();
@@ -701,7 +693,7 @@ void VISU_GaussPtsAct::highlight(bool theHighlight,
     myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
     myTextActor->SetWorldPoint(aWorldCoord);
     myTextActor->SetText(aString.c_str());
-    myTextActor->SetVisibility(1);
+    myTextActor->SetVisibility(anIsVisible && theIsHighlight);
     //
     // myCellActor
     if(myPickingSettings->GetDisplayParentMesh()){
@@ -718,10 +710,14 @@ void VISU_GaussPtsAct::highlight(bool theHighlight,
       vtkCell* aCell = aParent->GetElemCell(aCellID);
       myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
       myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug
-      myCellActor->SetVisibility(1);
+      myCellActor->SetVisibility(anIsVisible && theIsHighlight);
     }
   }
+  myOutline->SetBounds( GetInput()->GetBounds() );
+  myOutlineActor->SetVisibility( anIsVisible && theIsHighlight );
 }
+
+
 //----------------------------------------------------------------
 void
 VISU_GaussPtsAct
index 4fe5e38b400bdbf38e5940fe76d589e97916fc75..64b8c97e1cd02145292f00c46a877bd9e99f4fa5 100644 (file)
@@ -154,16 +154,18 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   ChangeMagnification();
 
   //----------------------------------------------------------------------------
+  virtual
+  void
+  highlight(bool theIsHighlight);
   virtual
   bool
-  PreHighlight(SVTK_Selector* theSelector, 
-              vtkInteractorStyle* theInteractorStyle, 
+  PreHighlight(vtkInteractorStyle* theInteractorStyle, 
               SVTK_SelectionEvent* theSelectionEvent,
               bool theIsHighlight);
   virtual
   bool
-  Highlight(SVTK_Selector* theSelector, 
-           vtkInteractorStyle* theInteractorStyle, 
+  Highlight(vtkInteractorStyle* theInteractorStyle, 
            SVTK_SelectionEvent* theSelectionEvent,
            bool theIsHighlight);
 
@@ -174,16 +176,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   void
   UpdatePickingSettings();
 
-  virtual
-  void
-  highlight(bool theHighlight, 
-           SVTK_Selector* theSelector);
-  virtual
-  void
-  highlight(bool theHighlight, 
-           Selection_Mode theSelectionMode);
   virtual
   bool
   IsInfinitive();
index afe15d1c48cfea66bb8ef7ac0fe445458d687242..a54004e62f8f9e80daefdcfdf2240436253fc0f9 100644 (file)
@@ -265,9 +265,10 @@ void VVTK_Renderer1::AdjustImplicitFunctionWidget()
 //----------------------------------------------------------------------------
 void 
 VVTK_Renderer1
-::SetInteractor(vtkRenderWindowInteractor* theInteractor)
+::Initialize(vtkRenderWindowInteractor* theInteractor,
+            SVTK_Selector* theSelector)
 {
-  SVTK_Renderer::SetInteractor(theInteractor);
+  SVTK_Renderer::Initialize(theInteractor,theSelector);
   myImplicitFunctionWidget->SetInteractor(theInteractor);
 }
 
index 60531f5623b4d8026bbc2efa9963e371f315b4af..0c50b277384f6126c2272b6cdbccdeb3101d0bfc 100644 (file)
@@ -76,15 +76,16 @@ class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer
 
   virtual
   void 
-  AddActor(VTKViewer_Actor* theActor);
+  Initialize(vtkRenderWindowInteractor* theInteractor,
+            SVTK_Selector* theSelector);
 
   virtual
   void 
-  RemoveActor(VTKViewer_Actor* theActor);
+  AddActor(VTKViewer_Actor* theActor);
 
   virtual
   void 
-  SetInteractor(vtkRenderWindowInteractor* theInteractor);
+  RemoveActor(VTKViewer_Actor* theActor);
 
   void
   SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
index 00bb81c7ec3da208c05d55c160f09df93f093d2d..59bab6e17cdcb76537f8cfc0f3de1de55344be86 100755 (executable)
@@ -81,6 +81,7 @@ VVTK_ViewWindow
        new SVTK_RenderWindowInteractor(myMainWindow1,"SVTK_RenderWindowInteractor1");
       
       VVTK_Renderer1* aRenderer = VVTK_Renderer1::New();
+      aRenderer->Initialize(anIteractor->GetDevice(),aSelector);
       anImplicitFunctionWidget = aRenderer->GetImplicitFunctionWidget();
       aRenderer->SetOutsideCursorSettings(anOutsideCursorSettings);
       aRenderer->SetPickingSettings(aPickingSettings);
@@ -113,6 +114,7 @@ VVTK_ViewWindow
        new SVTK_RenderWindowInteractor(myMainWindow2,"SVTK_RenderWindowInteractor1");
       
       VVTK_Renderer2* aRenderer = VVTK_Renderer2::New();
+      aRenderer->Initialize(anIteractor->GetDevice(),aSelector);
       aRenderer->SetImplicitFunctionWidget(anImplicitFunctionWidget);
       aRenderer->SetPickingSettings(aPickingSettings);