From c265e97397974c423043b28e4053e64cc46ab6ac Mon Sep 17 00:00:00 2001 From: pkv Date: Fri, 7 Oct 2005 15:10:09 +0000 Subject: [PATCH] fox for the Bug GVIEW10181 --- src/OBJECT/VISU_GaussPtsAct.cxx | 232 ++++++++++++++++---------------- src/OBJECT/VISU_GaussPtsAct.h | 4 + 2 files changed, 119 insertions(+), 117 deletions(-) diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 9520e3cc..a3f0cb33 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -488,13 +488,14 @@ VISU_GaussPtsAct SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight) { - myTextActor->SetVisibility(false); mySphereActor->SetVisibility(false); myCursorPyramid->SetVisibility(false); - myCellActor->SetVisibility(false); if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight) - return Superclass::PreHighlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight); + return Superclass::PreHighlight(theSelector, + theInteractorStyle, + theSelectionEvent, + theIsHighlight); myPreHighlightActor->SetVisibility(false); @@ -526,9 +527,6 @@ VISU_GaussPtsAct // To calculate display (2D) position of the annotation float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0}; - myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); - myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); - myTextActor->SetWorldPoint(aWorldCoord); // // To prepare the annotation text std::ostringstream aStr; @@ -574,13 +572,10 @@ VISU_GaussPtsAct float* aVal = aVectorArray->GetTuple3(aVtkId); aStr<<"\nVector: {"<SetText(aString.c_str()); myLastObjPointID = anObjId; } - - myTextActor->SetVisibility(true); mySphereActor->SetVisibility(true); myCursorPyramid->SetVisibility(true); myIsPreselected = theIsHighlight; @@ -593,39 +588,27 @@ VISU_GaussPtsAct return anIsChanged; } - - //---------------------------------------------------------------------------- -bool -VISU_GaussPtsAct -::Highlight(SVTK_Selector* theSelector, - vtkInteractorStyle* theInteractorStyle, - SVTK_SelectionEvent* theSelectionEvent, - bool theIsHighlight) +bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector, + vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight) { - int aTextVisibility = myTextActor->GetVisibility(); - int aSphereVisibility = mySphereActor->GetVisibility(); - int aSphereVisibilitySelected = mySphereActorSelected->GetVisibility(); - // - myTextActor->SetVisibility(0); - mySphereActor->SetVisibility(0); - mySphereActorSelected->SetVisibility(0); - myCellActor->SetVisibility(0); - // vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor(); // - Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; - mySelectionMode = aSelectionMode; + Selection_Mode aSelectionMode=theSelectionEvent->mySelectionMode; + mySelectionMode=aSelectionMode; // - if(aSelectionMode == ActorSelection ){ - myTextActor->SetVisibility(aTextVisibility); - mySphereActor->SetVisibility(aSphereVisibility); - mySphereActorSelected->SetVisibility(aSphereVisibilitySelected); - return Superclass::Highlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight); + if(aSelectionMode==ActorSelection ){ + return Superclass::Highlight(theSelector, + theInteractorStyle, + theSelectionEvent, + theIsHighlight); } // bool bRet = false; + if(!theSelectionEvent->myIsRectangle){ myPointPicker->Pick(theSelectionEvent->myX, @@ -634,13 +617,7 @@ VISU_GaussPtsAct aRenderer); if(myPointPicker->GetActor() != this) { - myTextActor->SetVisibility(aTextVisibility); - mySphereActor->SetVisibility(aSphereVisibility); - // - if (GetScalarBarCtrl()->GetIsMarked()) { - GetScalarBarCtrl()->SetIsMarked(false); - GetScalarBarCtrl()->Update(); - } + theSelector->ClearIObjects(); return bRet; } @@ -661,8 +638,9 @@ VISU_GaussPtsAct theSelector->AddIObject(this); } // - // FlyTo float* aNodeCoord = GetNodeCoord(anObjId); + // + // FlyTo float aDollyWas = anInteractor->GetDolly(); int aNumberOfFlyFramesWas=anInteractor->GetNumberOfFlyFrames(); @@ -672,100 +650,120 @@ VISU_GaussPtsAct aRenderer->ResetCameraClippingRange(); anInteractor->SetDolly(aDollyWas); anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); - // - // To calculate display (2D) position of the annotation - float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; - myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); - myTextActor->SetWorldPoint(aWorldCoord); - // - // Selected - mySphereSourceSelected->SetCenter(aNodeCoord); - // - vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ - float aVal = aScalarArray->GetTuple1(aVtkId); - float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); - mySphereSourceSelected->SetRadius(aRadius); - if(theSelector->HasIndex(myIO)){ - mySphereActorSelected->SetVisibility(1); - GetScalarBarCtrl()->SetIsMarked(true); - GetScalarBarCtrl()->SetMarkValue(aVal); - } - else{ - mySphereActorSelected->SetVisibility(0); - mySphereActor->SetVisibility(1); - GetScalarBarCtrl()->SetIsMarked(false); - } - GetScalarBarCtrl()->Update(); - myTextActor->SetVisibility(1); - } - if(aSelectionMode == CellSelection){ - // Hilighting an element from the parent Mesh - if(theSelector->HasIndex(myIO)){ - const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = - myGaussPointsPL->GetGaussPtsIDMapper(); - VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent(); - - myCellSource->Reset(); - myCellSource->Modified(); // a VTK bug - myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints()); - - VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId); - vtkIdType aCellID = aGaussPointID.first; - vtkCell* aCell = aParent->GetElemCell(aCellID); - myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); - myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug - myCellActor->SetVisibility(1); - } - } + return bRet; // }// if( anObjId >= 0 ) { }//if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO()) - if (GetScalarBarCtrl()->GetIsMarked()) { - GetScalarBarCtrl()->SetIsMarked(false); - GetScalarBarCtrl()->Update(); - } - } + }//if(!theSelectionEvent->myIsRectangle){ + return bRet; } - //================================================================== // function : highlight // purpose : //================================================================== void -VISU_GaussPtsAct -::highlight(bool theHighlight, - SVTK_Selector* theSelector) +VISU_GaussPtsAct::highlight(bool theHighlight, + Selection_Mode theSelectionMode) +{ + myTextActor->SetVisibility(0); + mySphereActorSelected->SetVisibility(0); + myCellActor->SetVisibility(0); + GetScalarBarCtrl()->SetIsMarked(false); + GetScalarBarCtrl()->Update(); +} +//================================================================== +// function : highlight +// purpose : +//================================================================== +void VISU_GaussPtsAct::highlight(bool theHighlight, + SVTK_Selector* theSelector) { TColStd_IndexedMapOfInteger aMapIndex; + // theSelector->GetIndex( getIO(), aMapIndex ); int aNbOfParts = aMapIndex.Extent(); - if(!aNbOfParts){ - mySphereActorSelected->SetVisibility(0); - GetScalarBarCtrl()->SetIsMarked(false); - GetScalarBarCtrl()->Update(); - }else if(aNbOfParts == 1){ - int anObjId = aMapIndex(1); - vtkIdType aVtkId = GetNodeVTKID(anObjId); - if(aVtkId >= 0){ - float* aNodeCoord = GetNodeCoord(anObjId); + // + if(aNbOfParts!=1) { + return; + } + // + std::ostringstream aStr; + int anObjId = aMapIndex(1); + aStr<<"Global ID: "<= 0){ + float *aNodeCoord, aVal, aRadius; + // + aNodeCoord = GetNodeCoord(anObjId); + float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.}; + // + vtkDataSet* aDataSet = GetInput(); + vtkCellData* aCellData = aDataSet->GetCellData(); + // + vtkDataArray* aScalarArray = aCellData->GetScalars(); + vtkDataArray *aVectorArray = aCellData->GetVectors(); + // + // mySphereSourceSelected + if(aScalarArray){ + aVal = aScalarArray->GetTuple1(aVtkId); + aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); + // mySphereSourceSelected->SetCenter(aNodeCoord); + mySphereSourceSelected->SetRadius(aRadius); + mySphereActorSelected->SetVisibility(1); + // ScalarBarCtrl + GetScalarBarCtrl()->SetIsMarked(true); + GetScalarBarCtrl()->SetMarkValue(aVal); + GetScalarBarCtrl()->Update(); + // + const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper= + myGaussPointsPL->GetGaussPtsIDMapper(); + VISU::TNamedIDMapper* aParent=aGaussPtsIDMapper->GetParent(); - vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ - float aVal = aScalarArray->GetTuple1(aVtkId); - float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); - mySphereSourceSelected->SetRadius(aRadius); - GetScalarBarCtrl()->SetIsMarked(true); - GetScalarBarCtrl()->SetMarkValue(aVal); - GetScalarBarCtrl()->Update(); + VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId); + VISU::TCellID aCellID = aGaussPointID.first; + VISU::TLocalPntID aLocalPntID=aGaussPointID.second; + aStr<<"\nParentCellID: "<GetElemName(aCellID); + if(aParentName != "") { + aStr<<"\nParentCellName: '"<SetVisibility(1); + aStr<<"\nLocalPntID: "<GetTuple3(aVtkId); + aStr<<"\nVector: {"<SetModePosition(myPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + myTextActor->SetText(aString.c_str()); + myTextActor->SetVisibility(1); + // + // myCellActor + if(mySelectionMode==CellSelection){ + const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = + myGaussPointsPL->GetGaussPtsIDMapper(); + VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent(); + + myCellSource->Reset(); + myCellSource->Modified(); // a VTK bug + myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints()); + + VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId); + vtkIdType aCellID = aGaussPointID.first; + vtkCell* aCell = aParent->GetElemCell(aCellID); + myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds()); + myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug + myCellActor->SetVisibility(1); } } } diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 23e65a98..1c5d7060 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -182,6 +182,10 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor highlight(bool theHighlight, SVTK_Selector* theSelector); + virtual + void + highlight(bool theHighlight, + Selection_Mode theSelectionMode); protected: //---------------------------------------------------------------------------- -- 2.39.2