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

index a3f0cb339e83631a7e75e397f130f0e2eeaa3298..a195e3a3b760555bf5073958fc928833a6f2269f 100644 (file)
@@ -97,12 +97,8 @@ VISU_GaussPtsAct
   myGaussPointsPL(NULL),
   myLastObjPointID(-1),
   myTextActor(VISU_FramedTextActor::New()),
-  mySphereSource(vtkSphereSource::New()),
-  mySphereMapper(vtkPolyDataMapper::New()),
-  mySphereActor(vtkActor::New()),
   myCursorPyramid(VISU_CursorPyramid::New()),
-  mySphereSourceSelected(vtkSphereSource::New()),
-  mySphereActorSelected(vtkActor::New()),
+  myCursorPyramidSelected(VISU_CursorPyramid::New()),
   myCellSource(vtkUnstructuredGrid::New()),
   myCellActor(vtkActor::New()),
   myScalarBarCtrl(VISU_ScalarBarCtrl::New()),
@@ -116,14 +112,8 @@ VISU_GaussPtsAct
   myDeviceActor->Delete();
   myTextActor->Delete();
 
-  mySphereSource->Delete();
-  mySphereMapper->Delete();
-  mySphereActor->Delete();
-
   myCursorPyramid->Delete();
-
-  mySphereSourceSelected->Delete();
-  mySphereActorSelected->Delete();
+  myCursorPyramidSelected->Delete();
 
   myCellSource->Delete();
   myCellActor->Delete();
@@ -137,20 +127,7 @@ VISU_GaussPtsAct
 
   myTextActor->SetVisibility(false);
   myTextActor->SetPickable(false);
-
-  mySphereMapper->SetInput(mySphereSource->GetOutput());
-  mySphereActor->SetMapper(mySphereMapper.GetPointer());
-  mySphereActor->SetVisibility(false);
-  mySphereActor->SetPickable(false);
-
-  vtkPolyDataMapper* aSphereMapperSelected = vtkPolyDataMapper::New();
-  aSphereMapperSelected->SetInput(mySphereSourceSelected->GetOutput());
-
-  mySphereActorSelected->SetMapper(aSphereMapperSelected);
-  mySphereActorSelected->GetProperty()->SetColor(1.0,1.0,1.0);
-  mySphereActorSelected->SetVisibility(false);
-  mySphereActorSelected->SetPickable(false);
-
+  //
   myCellSource->Allocate();
   vtkDataSetMapper* aCellMapper = vtkDataSetMapper::New();
   aCellMapper->SetInput(myCellSource.GetPointer());
@@ -253,11 +230,10 @@ VISU_GaussPtsAct
   myDeviceActor->AddToRender(theRenderer);
 
   theRenderer->AddActor(myTextActor.GetPointer());
-  theRenderer->AddActor(mySphereActor.GetPointer());
-  theRenderer->AddActor(mySphereActorSelected.GetPointer());
   theRenderer->AddActor(myCellActor.GetPointer());
 
   myCursorPyramid->AddToRender(theRenderer);
+  myCursorPyramidSelected->AddToRender(theRenderer);
   myScalarBarCtrl->AddToRender(theRenderer);
 }
 
@@ -271,12 +247,11 @@ VISU_GaussPtsAct
 
   myDeviceActor->RemoveFromRender(theRenderer);
   
-  theRenderer->RemoveActor(mySphereActor.GetPointer());
   theRenderer->RemoveActor(myTextActor.GetPointer());
-  theRenderer->RemoveActor(mySphereActorSelected.GetPointer());
   theRenderer->RemoveActor(myCellActor.GetPointer());
   
   myCursorPyramid->RemoveFromRender(theRenderer);
+  myCursorPyramidSelected->RemoveFromRender(theRenderer);
   myScalarBarCtrl->RemoveFromRender(theRenderer);
 }
 
@@ -392,7 +367,7 @@ VISU_GaussPtsAct
 ::SetBarVisibility(bool theMode)
 {
   myBarVisibility = theMode;
-  myScalarBarCtrl->SetBarVisibility(theMode);
+  myScalarBarCtrl->SetBarVisibility(theMode); 
 }
 
 bool
@@ -481,14 +456,14 @@ VISU_GaussPtsAct
 
 
 //----------------------------------------------------------------------------
-bool
-VISU_GaussPtsAct
-::PreHighlight(SVTK_Selector* theSelector, 
-              vtkInteractorStyle* theInteractorStyle, 
-              SVTK_SelectionEvent* theSelectionEvent,
-              bool theIsHighlight)
+bool VISU_GaussPtsAct::PreHighlight(SVTK_Selector* theSelector, 
+                                   vtkInteractorStyle* theInteractorStyle, 
+                                   SVTK_SelectionEvent* theSelectionEvent,
+                                   bool theIsHighlight)
 {
-  mySphereActor->SetVisibility(false);
+  if (!myBarVisibility) {
+    return false;
+  }
   myCursorPyramid->SetVisibility(false);  
 
   if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight)
@@ -528,10 +503,6 @@ VISU_GaussPtsAct
          // To calculate display (2D) position of the annotation
          float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0};
          //
-         // To prepare the annotation text
-         std::ostringstream aStr;
-         aStr<<"Global ID: "<<anObjId;
-
          const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
            myGaussPointsPL->GetGaussPtsIDMapper();
          VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
@@ -539,44 +510,31 @@ VISU_GaussPtsAct
          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<<"'";
-         aStr<<"\nLocalPntID: "<<aLocalPntID;
-
+         //
          vtkDataSet* aDataSet = GetInput();
          vtkCellData* aCellData = aDataSet->GetCellData();
          if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
            float aVal = aScalarArray->GetTuple1(aVtkId);
-           aStr<<"\nScalar: "<<aVal;
-
-           mySphereSource->SetCenter(aNodeCoord);
            float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
-           mySphereSource->SetRadius(aRadius);
-
-           float aColor[3];
-           VISU_LookupTable* aLookupTable = myGaussPointsPL->GetMapperTable();
-           aLookupTable->GetColor(aVal,aColor);
-           mySphereActor->GetProperty()->SetColor(aColor);
+           //float aColor[3];
+           //VISU_LookupTable* aLookupTable = myGaussPointsPL->GetMapperTable();
+           //aLookupTable->GetColor(aVal,aColor);
            //
            float aPyramidHeight = myPickingSettings->GetPyramidHeight();
            aPyramidHeight=aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
            myCursorPyramid->Init(aPyramidHeight,
                                  aRadius,
                                  aNodeCoord,
-                                 aColor);
+                                 myPreHighlightProperty.GetPointer()->GetColor()); 
          }
 
          if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
            float* aVal = aVectorArray->GetTuple3(aVtkId);
-           aStr<<"\nVector: {"<<aVal[0]<<"; "<<aVal[1]<<"; "<<aVal[2]<<"}";
          }
          
-         std::string aString = aStr.str();
          myLastObjPointID = anObjId;
        }
-       mySphereActor->SetVisibility(true);
        myCursorPyramid->SetVisibility(true);
        myIsPreselected = theIsHighlight;
        anIsChanged = true;
@@ -594,6 +552,9 @@ bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
                                 SVTK_SelectionEvent* theSelectionEvent,
                                 bool theIsHighlight)
 { 
+  if (!myBarVisibility) {
+    return false;
+  }
   vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
   vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
   //
@@ -669,7 +630,8 @@ VISU_GaussPtsAct::highlight(bool theHighlight,
                            Selection_Mode theSelectionMode)
 {
   myTextActor->SetVisibility(0);
-  mySphereActorSelected->SetVisibility(0);
+  myCursorPyramidSelected->SetVisibility(0);
+  myCursorPyramid->SetVisibility(0);
   myCellActor->SetVisibility(0);
   GetScalarBarCtrl()->SetIsMarked(false);
   GetScalarBarCtrl()->Update();
@@ -686,7 +648,7 @@ void VISU_GaussPtsAct::highlight(bool theHighlight,
   theSelector->GetIndex( getIO(), aMapIndex );
   int aNbOfParts = aMapIndex.Extent();
   //
-  if(aNbOfParts!=1) {
+  if(aNbOfParts!=1 || !myBarVisibility) {
     return;
   }
   //
@@ -707,19 +669,22 @@ void VISU_GaussPtsAct::highlight(bool theHighlight,
     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();
       //
+      float aPyramidHeight = myPickingSettings->GetPyramidHeight();
+      aPyramidHeight=aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
+      myCursorPyramidSelected->Init(aPyramidHeight,
+                                   aRadius,
+                                   aNodeCoord,
+                                   myHighlightProperty.GetPointer()->GetColor());
+      myCursorPyramidSelected->SetVisibility(1);
+      //
       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper= 
        myGaussPointsPL->GetGaussPtsIDMapper();
       VISU::TNamedIDMapper* aParent=aGaussPtsIDMapper->GetParent();
index 1c5d70606fc6b8e886b54dfd4a16f4fd969a72d5..28291387ffaaacea240db2459b145634525b6d88 100644 (file)
@@ -227,16 +227,10 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   vtkIdType myLastObjPointID;
 
   vtkSmartPointer<VISU_FramedTextActor> myTextActor;
-  
-  vtkSmartPointer<vtkSphereSource> mySphereSource;
-  vtkSmartPointer<vtkPolyDataMapper> mySphereMapper;
-  vtkSmartPointer<vtkActor> mySphereActor;
 
   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
-
-  vtkSmartPointer<vtkSphereSource> mySphereSourceSelected;
-  vtkSmartPointer<vtkActor> mySphereActorSelected;
-
+  vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
+  
   vtkSmartPointer<vtkUnstructuredGrid> myCellSource;
   vtkSmartPointer<vtkActor> myCellActor;