]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Improving "Filtering by Scalars" functionality
authorapo <apo@opencascade.com>
Thu, 11 Sep 2008 14:42:39 +0000 (14:42 +0000)
committerapo <apo@opencascade.com>
Thu, 11 Sep 2008 14:42:39 +0000 (14:42 +0000)
  - introduction special marks on scalar bar

src/PIPELINE/VISUPipeLine.cxx
src/PIPELINE/VISU_ColoredPL.cxx
src/PIPELINE/VISU_ColoredPL.hxx
src/PIPELINE/VISU_LookupTable.cxx
src/PIPELINE/VISU_LookupTable.hxx
src/PIPELINE/VISU_ScalarBarCtrl.cxx
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ScalarMap_i.cc

index 6dd93b813009e8e7173815de0946f06ab2ad449e..64b5d807778c618acf410ecd0c54c6c909c8faf7 100644 (file)
@@ -225,7 +225,7 @@ CreateColoredPL(VISU_Convertor* theConvertor,
 cout << "before filter limits set" << endl;
       vtkObject::GlobalWarningDisplayOn();
       aPresent->DebugOn();
-  aPresent->SetScalarFilteredRange( aRange );
+  aPresent->SetScalarFilterRange( aRange );
   aPresent->UseScalarFiltering( true );
 cout << "after filter set" << endl;
 
index 3c01e1bd5968601e1278541fb472ceb4c1930295..2fb6f9c6cd7f4d9e06704f10d75fcd41a6fcd50b 100644 (file)
@@ -106,7 +106,7 @@ VISU_ColoredPL
     if ( theIsCopyInput ) {
       SetScalarRange( aPipeLine->GetScalarRange() );
       if ( this->IsScalarFilterUsed() )
-       SetScalarFilteredRange( aPipeLine->GetScalarFilteredRange() );
+       SetScalarFilterRange( aPipeLine->GetScalarFilterRange() );
     }
 
     SetScalarMode(aPipeLine->GetScalarMode());
@@ -192,10 +192,10 @@ VISU_ColoredPL
 //----------------------------------------------------------------------------
 void
 VISU_ColoredPL
-::SetScalarFilteredRange( vtkFloatingPointType theRange[2] )
+::SetScalarFilterRange( vtkFloatingPointType theRange[2] )
 {
   vtkFloatingPointType aRange[ 2 ];
-  this->GetScalarFilteredRange( aRange );
+  this->GetScalarFilterRange( aRange );
 
   if ( VISU::CheckIsSameRange( aRange, theRange) )
     return;
@@ -207,7 +207,7 @@ VISU_ColoredPL
 //----------------------------------------------------------------------------
 void
 VISU_ColoredPL
-::GetScalarFilteredRange( vtkFloatingPointType theRange[2] )
+::GetScalarFilterRange( vtkFloatingPointType theRange[2] )
 {
   theRange[ 0 ] = myThreshold->GetLowerThreshold();
   theRange[ 1 ] = myThreshold->GetUpperThreshold();
@@ -217,11 +217,11 @@ VISU_ColoredPL
 //----------------------------------------------------------------------------
 vtkFloatingPointType*
 VISU_ColoredPL
-::GetScalarFilteredRange()
+::GetScalarFilterRange()
 {
   static vtkFloatingPointType aRange[ 2 ];
 
-  this->GetScalarFilteredRange( aRange );
+  this->GetScalarFilterRange( aRange );
 
   return aRange;
 }
@@ -374,7 +374,7 @@ VISU_ColoredPL
   GetSourceRange( aRange );
 
   SetScalarRange( aRange );
-  SetScalarFilteredRange( aRange );
+  SetScalarFilterRange( aRange );
 }
 
 //----------------------------------------------------------------------------
@@ -382,17 +382,9 @@ vtkPointSet*
 VISU_ColoredPL
 ::GetClippedInput()
 {
-/* RKV  if(GetFieldTransformFilter()->GetInput())
-    GetFieldTransformFilter()->Update();
-  return GetFieldTransformFilter()->GetUnstructuredGridOutput();
-    */
-  // RKV : Begin
-  // The pass filter is used here for possibility to include/exclude 
-  // threshold filter before it.
   if(myPassFilter->GetInput())
-       myPassFilter->Update();
+    myPassFilter->Update();
   return myPassFilter->GetUnstructuredGridOutput();
-  // RKV : End
 }
 
 
index add4a36d55364f210cd71ca429d465e1cf699217..ab53522ad395a5a50d715ec606cca5bc9ee761ea 100644 (file)
@@ -69,13 +69,13 @@ public:
   SetScalarRange( vtkFloatingPointType theRange[2] );
 
   void
-  SetScalarFilteredRange( vtkFloatingPointType theRange[2] );
+  SetScalarFilterRange( vtkFloatingPointType theRange[2] );
 
   void
-  GetScalarFilteredRange( vtkFloatingPointType theRange[2] );
+  GetScalarFilterRange( vtkFloatingPointType theRange[2] );
 
   vtkFloatingPointType* 
-  GetScalarFilteredRange();
+  GetScalarFilterRange();
 
   bool
   IsScalarFilterUsed();
index 8c4dfc9008c49672de178fd7c26a7c4163186b56..c325fa0656e0f397e6548af9ea58cf26a36a59a5 100644 (file)
 
 using namespace std;
 
+
+//----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_LookupTable);
 
+
+//----------------------------------------------------------------------------
 VISU_LookupTable
 ::VISU_LookupTable(int sze, int ext):
   vtkLookupTable(sze, ext), 
@@ -41,6 +45,73 @@ VISU_LookupTable
   myBicolor(false) 
 {}
 
+//----------------------------------------------------------------------------
+namespace
+{
+  inline
+  void
+  CopyColor( unsigned char* theTaget, const unsigned char* theSource )
+  {
+    theTaget[0] = theSource[0];
+    theTaget[1] = theSource[1];
+    theTaget[2] = theSource[2];
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_LookupTable
+::MarkValueByColor( vtkFloatingPointType theValue,
+                   unsigned char* theColor )
+{ 
+  vtkIdType anIndex = this->GetIndex( theValue );
+  unsigned char *aTablePtr = this->GetPointer( anIndex );
+  CopyColor( aTablePtr, theColor );
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_LookupTable
+::FillByColor( unsigned char* theColor )
+{
+  vtkIdType aNbColors = this->GetNumberOfColors();
+  for(int i = 0; i < aNbColors; i++){
+    unsigned char *aTablePtr = this->GetPointer(i);
+    CopyColor( aTablePtr, theColor );
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_LookupTable
+::MakeBiColor()
+{
+  unsigned char aRedPtr[3] = {255, 0, 0};
+  unsigned char aBluePtr[3] = {0, 0, 255};
+  
+  vtkFloatingPointType aRange[2];
+  this->GetTableRange(aRange);
+  vtkIdType aNbColors = this->GetNumberOfColors();
+  
+  vtkFloatingPointType aDelta = (aRange[1]-aRange[0])/aNbColors;
+  vtkFloatingPointType aValue = aRange[0]+0.5*aDelta;
+  for(int i = 0; i < aNbColors; i++){
+    vtkIdType anIndex = this->GetIndex(aValue);
+    unsigned char* aTablePtr = this->GetPointer(anIndex);
+    if(aValue > 0.0){
+      CopyColor(aTablePtr,aRedPtr);
+    }else{
+      CopyColor(aTablePtr,aBluePtr);
+    }
+    aValue += aDelta;
+  }
+}
+
+
+//----------------------------------------------------------------------------
 void 
 VISU_LookupTable
 ::SetMapScale(vtkFloatingPointType theScale)
index 93fc7a47b137c19cadbe062c5ac3158baa7d93bd..ff525110ea7846594adb52bc7b6f0b1f42c87bde 100644 (file)
@@ -44,8 +44,17 @@ class VISU_LookupTable: public vtkLookupTable
   bool GetBicolor() { return myBicolor; }
   void SetBicolor( bool theBicolor );
 
-   static int ComputeLogRange(vtkFloatingPointType inRange[2], vtkFloatingPointType outRange[2]);
-   unsigned char *MapValue(vtkFloatingPointType v);
+  static int ComputeLogRange( vtkFloatingPointType inRange[2], 
+                             vtkFloatingPointType outRange[2] );
+  
+  unsigned char *MapValue(vtkFloatingPointType v);
+
+  void MarkValueByColor( vtkFloatingPointType theValue,
+                        unsigned char* theColor );
+
+  void FillByColor( unsigned char* theColor );
+
+  void MakeBiColor();
 
  protected:
    VISU_LookupTable(int sze=256, int ext=256);
index 5dbf6e47845fbcb471eba2af6b5a238ca41bbe15..3003295d07d3eaabeec5d03db689c3d8805522e1 100644 (file)
 #include <string.h>
 
 
-//----------------------------------------------------------------------------
-namespace
-{
-  inline
-  void
-  MarkValueByColor(VISU_LookupTable* theTable,
-                  vtkFloatingPointType theValue,
-                  unsigned char* theColor)
-  { 
-    vtkIdType anIndex = theTable->GetIndex(theValue);
-    unsigned char *aTablePtr = theTable->GetPointer(anIndex);
-    aTablePtr[0] = theColor[0];
-    aTablePtr[1] = theColor[1];
-    aTablePtr[2] = theColor[2];
-  }
-
-  inline
-  void
-  CopyColor(unsigned char* theTaget, const unsigned char* theSource)
-  {
-    theTaget[0] = theSource[0];
-    theTaget[1] = theSource[1];
-    theTaget[2] = theSource[2];
-  }
-
-  void
-  FillByColor(VISU_LookupTable* theTable,
-             unsigned char* theColor)
-  {
-    vtkIdType aNbColors = theTable->GetNumberOfColors();
-    for(int i = 0; i < aNbColors; i++){
-      unsigned char *aTablePtr = theTable->GetPointer(i);
-      CopyColor(aTablePtr,theColor);
-    }
-  }
-
-  void
-  MakeBiColor(VISU_LookupTable* theTable)
-  {
-    unsigned char aRedPtr[3] = {255, 0, 0};
-    unsigned char aBluePtr[3] = {0, 0, 255};
-
-    vtkFloatingPointType aRange[2];
-    theTable->GetTableRange(aRange);
-    vtkIdType aNbColors = theTable->GetNumberOfColors();
-
-    vtkFloatingPointType aDelta = (aRange[1]-aRange[0])/aNbColors;
-    vtkFloatingPointType aValue = aRange[0]+0.5*aDelta;
-    for(int i = 0; i < aNbColors; i++){
-      vtkIdType anIndex = theTable->GetIndex(aValue);
-      unsigned char* aTablePtr = theTable->GetPointer(anIndex);
-      if(aValue > 0.0){
-       CopyColor(aTablePtr,aRedPtr);
-      }else{
-       CopyColor(aTablePtr,aBluePtr);
-      }
-      aValue += aDelta;
-    }
-  }
-}
-
-
 //----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_ScalarBarCtrl);
 
@@ -435,16 +373,16 @@ VISU_ScalarBarCtrl
 {
   if(myMarked){
     if(myMode == eGlobal){
-      MarkValueByColor(myGlobalLookupTable, myMarkedValue, myBlack);
+      myGlobalLookupTable->MarkValueByColor( myMarkedValue, myBlack );
     }else{
-      MarkValueByColor(myLocalLookupTable, myMarkedValue, myBlack);
+      myLocalLookupTable->MarkValueByColor( myMarkedValue, myBlack );
     }
   }
   if(myGlobalRangeIsDefined){
     vtkFloatingPointType aLocalRange[2];
     myLocalLookupTable->GetTableRange(aLocalRange);
-    MarkValueByColor(myGlobalLookupTable, aLocalRange[0], myBlack);
-    MarkValueByColor(myGlobalLookupTable, aLocalRange[1], myBlack);
+    myGlobalLookupTable->MarkValueByColor( aLocalRange[0], myBlack );
+    myGlobalLookupTable->MarkValueByColor( aLocalRange[1], myBlack );
   }
 }
 
@@ -490,9 +428,9 @@ VISU_ScalarBarCtrl
 ::UpdateForColor()
 {
   if(myMode == eGlobal){ 
-    FillByColor(myLocalLookupTable,myGrey);
+    myLocalLookupTable->FillByColor( myGrey );
   }else if(myMode == eLocal){
-    FillByColor(myGlobalLookupTable,myGrey);
+    myGlobalLookupTable->FillByColor( myGrey );
   }
 }
 
@@ -506,15 +444,15 @@ VISU_ScalarBarCtrl
   myLocalLookupTable->Build();
 
   if(myMode == eSimple){
-    MakeBiColor(myLocalLookupTable);
+    myLocalLookupTable->MakeBiColor();
     return;
   }
 
   if(myMode == eGlobal){
-    MakeBiColor(myGlobalLookupTable);
-    FillByColor(myLocalLookupTable,myGrey);
+    myGlobalLookupTable->MakeBiColor();
+    myLocalLookupTable->FillByColor( myGrey );
   }else if(myMode == eLocal){
-    MakeBiColor(myLocalLookupTable);
-    FillByColor(myGlobalLookupTable,myGrey);
+    myLocalLookupTable->MakeBiColor();
+    myGlobalLookupTable->FillByColor( myGrey );
   }
 }
index 04b34d9f670adebd904006da2b9ee14a498dbe45..8736573f3d4ee1e74acdc81f0e71f707b73218fc 100644 (file)
@@ -799,7 +799,7 @@ VISU::ColoredPrs3d_i
 
   vtkFloatingPointType aScalarRange[ 2 ] = { theMin, theMax };
   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ColoredPL, vtkFloatingPointType*>
-                  (GetSpecificPL(), &VISU_ColoredPL::SetScalarFilteredRange, aScalarRange) );
+                  (GetSpecificPL(), &VISU_ColoredPL::SetScalarFilterRange, aScalarRange) );
 }
 
 
@@ -809,7 +809,7 @@ VISU::ColoredPrs3d_i
 ::GetScalarFilterMin()
 {
   vtkFloatingPointType aScalarRange[ 2 ];
-  GetSpecificPL()->GetScalarFilteredRange( aScalarRange );
+  GetSpecificPL()->GetScalarFilterRange( aScalarRange );
 
   return aScalarRange[ 0 ];
 }
@@ -821,7 +821,7 @@ VISU::ColoredPrs3d_i
 ::GetScalarFilterMax()
 {
   vtkFloatingPointType aScalarRange[ 2 ];
-  GetSpecificPL()->GetScalarFilteredRange( aScalarRange );
+  GetSpecificPL()->GetScalarFilterRange( aScalarRange );
 
   return aScalarRange[ 1 ];
 }
index ec37d5fa92553c77d9e8cc74810ffb50f3927f8b..850d6de079f1292fbc4cd5bd1866bf6be8af85d7 100644 (file)
@@ -432,12 +432,21 @@ VISU::ScalarMap_i
 ::UpdateActor(VISU_Actor* theActor) 
 {
   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
+    VISU_LookupTable * aLookupTable = GetSpecificPL()->GetBarTable();
+
+    if ( IsScalarFilterUsed() ) {
+      unsigned char MARK_COLOR[] = { 1, 1, 1 };
+      aLookupTable->MarkValueByColor( GetScalarFilterMin(), MARK_COLOR );
+      aLookupTable->MarkValueByColor( GetScalarFilterMax(), MARK_COLOR );
+      aLookupTable->Modified();
+    }
+
     VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
-    aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable());
-    // RKV : Begin
-    aScalarBar->SetDistribution(GetSpecificPL()->GetDistribution());
-    aScalarBar->SetDistributionVisibility(GetIsDistributionVisible());
-    // RKV : End
+    aScalarBar->SetLookupTable( aLookupTable );
+
+    aScalarBar->SetDistribution( GetSpecificPL()->GetDistribution() );
+    aScalarBar->SetDistributionVisibility( GetIsDistributionVisible() );
+
     aScalarBar->SetTitle(GetScalarBarTitle().c_str());
     aScalarBar->SetOrientation(GetBarOrientation());
     aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();