]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx
#3464 Aboce Below Range color in ScalarsToColors box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkScalarsToColors.cxx
index d306ff39b5e9824781f14187ba1b509eb4cb20ef..50c2cbc2e8532df3618d09af7bf6955a5390e5ec 100644 (file)
@@ -227,86 +227,78 @@ void ScalarsToColors::Process()
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
   
 
-printf("EED ScalarsToColors::Process  Start\n");
-
-       if (firsttime==true)
-       {
-               firsttime=false;
+//     if (firsttime==true)
+//     {
+//             firsttime=false;
                // Create the color map
-               if (bbGetInputType()==0)
+               if ((bbGetInputType()==0) || (bbGetInputType()==100) )
                {
                        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();
                        } else {
                                colorLookupTable->SetRange(0,255);
                        }
-                       colorLookupTable->SetNumberOfTableValues(1000);
+                       int NumberOfColors=1000;
+                       int NumberOfColorsHalf=NumberOfColors/2;
+                       colorLookupTable->SetNumberOfTableValues( NumberOfColors );
                        colorLookupTable->Build();
                        double rgba1[4];
                        double rgba2[4];
                        int iLookTable;
-                       for (iLookTable = 0; iLookTable<500; iLookTable++)
+                       for (iLookTable = 0; iLookTable<NumberOfColorsHalf; iLookTable++)
                        {
-                               colorLookupTable->GetTableValue(      iLookTable, rgba1);
-                               colorLookupTable->GetTableValue(1000-1-iLookTable, rgba2);
-                               colorLookupTable->SetTableValue(1000-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);
-                       int i,iMax;
-                       iMax=(1000/16)*4;
-                       for (i=0;i<iMax;i++)
-                       {
-                               colorLookupTable->GetTableValue(500+i, rgba);
-                               rgba[3]=(double)i/(double)iMax;
-                               colorLookupTable->SetTableValue(500+i,rgba);
-                               colorLookupTable->GetTableValue(500-i, rgba);
-                               rgba[3]=(double)i/(double)iMax;
-                               colorLookupTable->SetTableValue(500-i,rgba);
-                       } // for
-/*
-                       iMax=100;
-                       for (i=0;i<iMax;i++)
-                       {
-
-                               _colorLookupTable->GetTableValue(500+100+i, rgba);
-                               rgba[3]=(double)i/(double)iMax;
-                               _colorLookupTable->SetTableValue(500+100+i,rgba);
-                               _colorLookupTable->GetTableValue(500-100-i, rgba);
-                               rgba[3]=(double)i/(double)iMax;
-                               _colorLookupTable->SetTableValue(500-100-i,rgba);
-
-                       } // for
-
-                       iMax=200;
-                       for (i=0;i<iMax;i++)
+                       
+                       // Transparency
+                       if (bbGetInputType()==0)   
                        {
-                               _colorLookupTable->GetTableValue(500+i, rgba);
-                               rgba[3]=0;
-                               _colorLookupTable->SetTableValue(500+i,rgba);
-                               _colorLookupTable->GetTableValue(500-i, rgba);
+                               // First Element
+                               double rgba[4];
+                               colorLookupTable->GetTableValue(0,rgba);
                                rgba[3]=0;
-                               _colorLookupTable->SetTableValue(500-i,rgba);
-                       } // for
-*/
+                               colorLookupTable->SetTableValue(0,rgba);
+                               
+                               // Middle  range
+                               int i,iMax=(NumberOfColors/16)*4;
+                               for (i=0;i<iMax;i++)
+                               {
+                                       colorLookupTable->GetTableValue(NumberOfColorsHalf+i, rgba);
+                                       rgba[3]=(double)i/(double)iMax;
+                                       colorLookupTable->SetTableValue(NumberOfColorsHalf+i,rgba);
+                                       colorLookupTable->GetTableValue(NumberOfColorsHalf-i, rgba);
+                                       rgba[3]=(double)i/(double)iMax;
+                                       colorLookupTable->SetTableValue(NumberOfColorsHalf-i,rgba);
+                               } // for
+                       } //if Type 0                   
+                       
                        colorLookupTable->Modified();
                        _scalarstocolors = colorLookupTable;
-               } // if Type 0
+               } // if Type 0 || 100 
 
 //EED 2018-06-8 ***********************ARDS Projet***********************************************
-               if (bbGetInputType()==1)
+               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();
+
                        } else {
                                colorLookupTable->SetRange(0,255);
                        }
@@ -314,12 +306,17 @@ printf("EED ScalarsToColors::Process  Start\n");
                        colorLookupTable->SetSaturationRange(0.0, 0.0); // no color saturation
                        colorLookupTable->SetRampToLinear();
                        colorLookupTable->Build();
-                       double rgba[4];
-                       colorLookupTable->GetTableValue(0,rgba);
-                       rgba[3]=0;
-                       colorLookupTable->SetTableValue(0,rgba);
+                       // Transparency
+                       if (bbGetInputType()==1) 
+                       {
+                               // First Element
+                               double rgba[4];
+                               colorLookupTable->GetTableValue(0,rgba);
+                               rgba[3]=0;
+                               colorLookupTable->SetTableValue(0,rgba);
+                       } // if Type 1
                        _scalarstocolors = colorLookupTable;
-               } // If Type 1
+               } // If Type 1 || 101
 
 
                if (bbGetInputType()==2)  // Direction Color Vector
@@ -339,7 +336,7 @@ printf("EED ScalarsToColors::Process  Start\n");
                } // If Type 3
 
 
-       } // firsttime
+//     } // firsttime
        double rgb[3];
        std::vector<double>colorRGB;
        _scalarstocolors->GetColor( bbGetInputScalarValue() , rgb );
@@ -349,8 +346,6 @@ printf("EED ScalarsToColors::Process  Start\n");
        bbSetOutputColor( colorRGB );
        bbSetOutputLookupTable( _scalarstocolors );
 
-printf("EED ScalarsToColors::Process  End\n");
-
 
 }
 //===== 
@@ -367,7 +362,7 @@ void ScalarsToColors::bbUserSetDefaultValues()
    range.push_back( 1 );
        bbSetInputRange(range);
    bbSetInputScalarValue(0);
-   firsttime           = true;
+//   firsttime         = true;
    _scalarstocolors    = NULL;
 }
 //=====