]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
fox for the Bug GVIEW10181
authorpkv <pkv@opencascade.com>
Fri, 7 Oct 2005 15:10:09 +0000 (15:10 +0000)
committerpkv <pkv@opencascade.com>
Fri, 7 Oct 2005 15:10:09 +0000 (15:10 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h

index 9520e3cc418090f28dc85a9aee74eebc0008ad07..a3f0cb339e83631a7e75e397f130f0e2eeaa3298 100644 (file)
@@ -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: {"<<aVal[0]<<"; "<<aVal[1]<<"; "<<aVal[2]<<"}";
          }
-
+         
          std::string aString = aStr.str();
-         myTextActor->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: "<<anObjId;
+  //
+  vtkIdType aVtkId = GetNodeVTKID(anObjId);
+  if(aVtkId >= 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: "<<aCellID;
+      std::string aParentName = aParent->GetElemName(aCellID);
+      if(aParentName != "") {
+       aStr<<"\nParentCellName: '"<<aParentName<<"'";
       }
-      mySphereActorSelected->SetVisibility(1);
+      aStr<<"\nLocalPntID: "<<aLocalPntID;
+      aStr<<"\nScalar: "<<aVal;
+    }
+    if(aVectorArray) {
+      float* pVec = aVectorArray->GetTuple3(aVtkId);
+      aStr<<"\nVector: {"<<pVec[0]<<"; "<<pVec[1]<<"; "<<pVec[2]<<"}";
+    }
+    //
+    // myTextActor
+    std::string aString=aStr.str();
+    myTextActor->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);
     }
   }
 }
index 23e65a98f39bbbe2e3a873449ff60b28e466bc30..1c5d70606fc6b8e886b54dfd4a16f4fd969a72d5 100644 (file)
@@ -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:
   //----------------------------------------------------------------------------