]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx
#3513 CleanMeshWithPatch
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkScalarsToColors.cxx
index 50c2cbc2e8532df3618d09af7bf6955a5390e5ec..4aceca30aee008ced73ee882ba39ed697c223b28 100644 (file)
@@ -238,13 +238,17 @@ void ScalarsToColors::Process()
                        {
                                colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]);
 //                             colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
-                               colorLookupTable->SetBelowRangeColor(1,1,1,0);  // White transparent 
-                               colorLookupTable->SetAboveRangeColor(1,1,1,0);  // White transparent 
-                               colorLookupTable->UseBelowRangeColorOn();
-                               colorLookupTable->UseAboveRangeColorOn();
-                       } 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 );
@@ -268,6 +272,17 @@ void ScalarsToColors::Process()
                                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;
@@ -290,18 +305,29 @@ void ScalarsToColors::Process()
                if ((bbGetInputType()==1) || (bbGetInputType()==101) )
                {
                        vtkLookupTable *colorLookupTable = vtkLookupTable::New();
-                       if (bbGetInputRange().size()==2)
-                       {
-                               colorLookupTable->SetRange( bbGetInputRange()[0],bbGetInputRange()[1]);
-//                             colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]);
-                               colorLookupTable->SetBelowRangeColor(1,1,1,0);  // White transparent 
-                               colorLookupTable->SetAboveRangeColor(1,1,1,0);  // White transparent 
-                               colorLookupTable->UseBelowRangeColorOn();
-                               colorLookupTable->UseAboveRangeColorOn();
+            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
+            }
 
-                       } else {
-                               colorLookupTable->SetRange(0,255);
-                       }
                        colorLookupTable->SetValueRange(0.0, 1.0); // from black to white
                        colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation
                        colorLookupTable->SetRampToLinear();
@@ -335,7 +361,6 @@ void ScalarsToColors::Process()
                        _scalarstocolors = _LutEED;
                } // If Type 3
 
-
 //     } // firsttime
        double rgb[3];
        std::vector<double>colorRGB;
@@ -345,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::vector<double>range;
-   range.push_back( 0 );
-   range.push_back( 1 );
-       bbSetInputRange(range);
+//   std::vector<double>range;
+//   range.push_back( 0 );
+//   range.push_back( 1 );
+//     bbSetInputRange(range);
    bbSetInputScalarValue(0);
+   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