From d19d90280cc9f827120d978ced85428a7de1a3a3 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 18 Oct 2005 15:14:43 +0000 Subject: [PATCH] Patch on Bug GVIEW10227 Highlighted group of elements remains in 3D viewer. --- src/OBJECT/VISU_Actor.cxx | 10 ++-- src/OBJECT/VISU_Actor.h | 3 +- src/OBJECT/VISU_GaussPtsAct.cxx | 96 ++++++++++++++++----------------- src/OBJECT/VISU_GaussPtsAct.h | 20 +++---- src/VVTK/VVTK_Renderer.cxx | 5 +- src/VVTK/VVTK_Renderer.h | 7 +-- src/VVTK/VVTK_ViewWindow.cxx | 2 + 7 files changed, 66 insertions(+), 77 deletions(-) diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 90c4e50c..c576c022 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -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 diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 8a6c5de0..6078198e 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -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); diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 4d7c1eff..98620e9f 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 4fe5e38b..64b8c97e 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -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(); diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index afe15d1c..a54004e6 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -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); } diff --git a/src/VVTK/VVTK_Renderer.h b/src/VVTK/VVTK_Renderer.h index 60531f56..0c50b277 100644 --- a/src/VVTK/VVTK_Renderer.h +++ b/src/VVTK/VVTK_Renderer.h @@ -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); diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index 00bb81c7..59bab6e1 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -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); -- 2.39.2