X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkScalarsToColors.cxx;h=4aceca30aee008ced73ee882ba39ed697c223b28;hb=500bc2ff1c3fe51a9ce94324dee722fb2f7bfd36;hp=c8ec324d11e1a0a3bc7e9f25c065cd039431948c;hpb=9cd91c842e8da723181e6cfa0bd237ecc9d41173;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx index c8ec324..4aceca3 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx @@ -227,9 +227,9 @@ void ScalarsToColors::Process() // std::cout << "Output value = " <SetRange( bbGetInputRange()[0],bbGetInputRange()[1]); // colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); - } else { + } else if (bbGetInputWindowColorLevel().size()==2) { + double w = bbGetInputWindowColorLevel()[0] / 2; + double c = bbGetInputWindowColorLevel()[1]; + colorLookupTable->SetRange( c-w , c+w ); + }else { colorLookupTable->SetRange(0,255); } + + colorLookupTable->UseBelowRangeColorOn(); + colorLookupTable->UseAboveRangeColorOn(); + int NumberOfColors=1000; int NumberOfColorsHalf=NumberOfColors/2; colorLookupTable->SetNumberOfTableValues( NumberOfColors ); @@ -250,19 +258,33 @@ void ScalarsToColors::Process() int iLookTable; for (iLookTable = 0; iLookTableGetTableValue( iLookTable, rgba1); - colorLookupTable->GetTableValue(NumberOfColors-1-iLookTable, rgba2); - colorLookupTable->SetTableValue(NumberOfColors-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]); - colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]); + colorLookupTable->GetTableValue( iLookTable, rgba1 ); + colorLookupTable->GetTableValue(NumberOfColors-1-iLookTable, rgba2 ); + colorLookupTable->SetTableValue(NumberOfColors-1-iLookTable, rgba1[0],rgba1[1],rgba1[2],rgba1[3] ); + colorLookupTable->SetTableValue( iLookTable, rgba2[0],rgba2[1],rgba2[2],rgba2[3] ); } // for iLookTable - double rgba[4]; - colorLookupTable->GetTableValue(0,rgba); - rgba[3]=0; - colorLookupTable->SetTableValue(0,rgba); // Transparency if (bbGetInputType()==0) { + // First Element + double rgba[4]; + colorLookupTable->GetTableValue(0,rgba); + rgba[3]=0; + colorLookupTable->SetTableValue(0,rgba); + + colorLookupTable->UseBelowRangeColorOn(); + colorLookupTable->UseAboveRangeColorOn(); + if (bbGetInputBelowAboveRangeTransparence()==true) + { + colorLookupTable->SetBelowRangeColor(1,1,1,0); // White transparent + colorLookupTable->SetAboveRangeColor(1,1,1,0); // White transparent + } else { + colorLookupTable->SetBelowRangeColor(0,0,0,1); // White transparent + colorLookupTable->SetAboveRangeColor(1,1,1,1); // White transparent + } + + // Middle range int i,iMax=(NumberOfColors/16)*4; for (i=0;iSetRange( bbGetInputRange()[0],bbGetInputRange()[1]); -// colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); - } else { - colorLookupTable->SetRange(0,255); - } + if (bbGetInputRange().size()==2) + { + colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]); +// colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); + } else if (bbGetInputWindowColorLevel().size()==2) { + double w = bbGetInputWindowColorLevel()[0] / 2; + double c = bbGetInputWindowColorLevel()[1]; + colorLookupTable->SetRange( c-w , c+w ); + }else { + colorLookupTable->SetRange(0,255); + } + + colorLookupTable->UseBelowRangeColorOn(); + colorLookupTable->UseAboveRangeColorOn(); + if (bbGetInputBelowAboveRangeTransparence()==true) + { + colorLookupTable->SetBelowRangeColor(1,1,1,0); // White transparent + colorLookupTable->SetAboveRangeColor(1,1,1,0); // White transparent + } else { + colorLookupTable->SetBelowRangeColor(0,0,0,1); // White transparent + colorLookupTable->SetAboveRangeColor(1,1,1,1); // White transparent + } + colorLookupTable->SetValueRange(0.0, 1.0); // from black to white colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation colorLookupTable->SetRampToLinear(); @@ -297,6 +335,7 @@ void ScalarsToColors::Process() // Transparency if (bbGetInputType()==1) { + // First Element double rgba[4]; colorLookupTable->GetTableValue(0,rgba); rgba[3]=0; @@ -322,8 +361,7 @@ void ScalarsToColors::Process() _scalarstocolors = _LutEED; } // If Type 3 - - } // firsttime +// } // firsttime double rgb[3]; std::vectorcolorRGB; _scalarstocolors->GetColor( bbGetInputScalarValue() , rgb ); @@ -332,52 +370,48 @@ void ScalarsToColors::Process() colorRGB.push_back( rgb[2] ); bbSetOutputColor( colorRGB ); bbSetOutputLookupTable( _scalarstocolors ); - - } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void ScalarsToColors::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputType(0); - std::vectorrange; - range.push_back( 0 ); - range.push_back( 1 ); - bbSetInputRange(range); +// std::vectorrange; +// range.push_back( 0 ); +// range.push_back( 1 ); +// bbSetInputRange(range); bbSetInputScalarValue(0); - firsttime = true; + bbSetInputBelowAboveRangeTransparence(true); +// firsttime = true; _scalarstocolors = NULL; } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void ScalarsToColors::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void ScalarsToColors::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - -} } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk