From: apo Date: Thu, 11 Sep 2008 14:42:39 +0000 (+0000) Subject: Improving "Filtering by Scalars" functionality X-Git-Tag: TG_VISU_2008_2008-09-12~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=233525d83fb40c7368b10ec138fd9e4c16efb09c;p=modules%2Fvisu.git Improving "Filtering by Scalars" functionality - introduction special marks on scalar bar --- diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 6dd93b81..64b5d807 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -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; diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index 3c01e1bd..2fb6f9c6 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -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 } diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index add4a36d..ab53522a 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -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(); diff --git a/src/PIPELINE/VISU_LookupTable.cxx b/src/PIPELINE/VISU_LookupTable.cxx index 8c4dfc90..c325fa06 100644 --- a/src/PIPELINE/VISU_LookupTable.cxx +++ b/src/PIPELINE/VISU_LookupTable.cxx @@ -32,8 +32,12 @@ 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) diff --git a/src/PIPELINE/VISU_LookupTable.hxx b/src/PIPELINE/VISU_LookupTable.hxx index 93fc7a47..ff525110 100644 --- a/src/PIPELINE/VISU_LookupTable.hxx +++ b/src/PIPELINE/VISU_LookupTable.hxx @@ -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); diff --git a/src/PIPELINE/VISU_ScalarBarCtrl.cxx b/src/PIPELINE/VISU_ScalarBarCtrl.cxx index 5dbf6e47..3003295d 100644 --- a/src/PIPELINE/VISU_ScalarBarCtrl.cxx +++ b/src/PIPELINE/VISU_ScalarBarCtrl.cxx @@ -39,68 +39,6 @@ #include -//---------------------------------------------------------------------------- -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 ); } } diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 04b34d9f..8736573f 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -799,7 +799,7 @@ VISU::ColoredPrs3d_i vtkFloatingPointType aScalarRange[ 2 ] = { theMin, theMax }; ProcessVoidEvent(new TVoidMemFun1ArgEvent - (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 ]; } diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index ec37d5fa..850d6de0 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -432,12 +432,21 @@ VISU::ScalarMap_i ::UpdateActor(VISU_Actor* theActor) { if(VISU_ScalarMapAct* anActor = dynamic_cast(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();