]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
#2651 creaMaracasVisu Feature New Normal - Color Layer: Transparent Base, Refresh
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageView.cxx
index 61bb9bb0f682cd3f17d323ec458d6f957a0277fd..a1db87799b57e9dca27c2643594e74f3faf380bc 100644 (file)
@@ -141,6 +141,14 @@ void ColorLayerImageView::SetBaseColors(std::vector<double> & base_color)
     std::cout << "CM ColorLayerImageView::SetBaseColors : ERROR!!! The base color vector has an inconsistent size. It must be of a size multiple of 3, different from 0, but its size is: "<< base_color.size() << ". Therefore, the default values will be used as base colors." << std::endl;
 }
 
+
+//----------------------------------------------------------------------------
+void ColorLayerImageView::SetBaseTransparence(std::vector<double> & base_transparence)
+{
+  _transparence_level_boundary = base_transparence;
+}
+
+
 //----------------------------------------------------------------------------
 double ColorLayerImageView::GetBaseColors(unsigned int index)
 {
@@ -287,10 +295,16 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
    }
   // ------------------ End Of Setting Default Values
 
+       int iTransparence,transparenceSize = _transparence_level_boundary.size();
+       for (iTransparence= transparenceSize ; iTransparence < GetBaseColorNb(); iTransparence++ )
+       {
+      _transparence_level_boundary.push_back(1);
+       }
+
   // ------------------ Defining the Threshold Table
   vtkLookupTable* thresholdTable = GetThresholdTable();
   double thresholdTable_range[2];
-  double r1,r2,g1,g2,b1,b2;
+  double r1,r2,g1,g2,b1,b2,t1,t2;
   int start,end;
 
   // CM Number of table values consistent with the effective number of values (see loop below).
@@ -321,14 +335,14 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
          {
                        start = 0;      
                        end     = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(0) );  
-                       FillColorTable(start,end, 0,0,0, 0,0,0);
+                       FillColorTable(start,end, 0,0,0, 0,0,0, 0,0);
      }
 
      if ( maxRange>GetGreyLevelBoundaries(  _grey_level_boundary.size()-1   ) )
          {
                        start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries( _grey_level_boundary.size()-1 ) );  
                        end     = GrayLevel_TO_colorTableIndex( maxRange );  
-                       FillColorTable(start,end, 0,0,0, 0,0,0);
+                       FillColorTable(start,end, 0,0,0, 0,0,0, 0,0);
      }
 
       for (int iColor = 0; iColor < GetBaseColorNb(); iColor++)
@@ -338,7 +352,9 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                        b1              = GetBaseColors(iColor*3+2);
                        start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );  
                        end     = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );  
-                       FillColorTable(start,end, r1,g1,b1,r1,g1,b1);
+         t1    = _transparence_level_boundary[iColor];
+                       t2              = _transparence_level_boundary[iColor+1];
+                       FillColorTable(start,end, r1,g1,b1,r1,g1,b1,t1,t2);
                } // for i
        } // End Of if (_color_type)
 
@@ -355,6 +371,9 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                                        r1              = 0;
                                        g1              = 0;
                                        b1              = 0;
+                                       r1              = GetBaseColors((iColor-1)*3+0);
+                                       g1              = GetBaseColors((iColor-1)*3+1);
+                                       b1              = GetBaseColors((iColor-1)*3+2);
                                } else {
                                        r1              = GetBaseColors((iColor-1)*3+0);
                                        g1              = GetBaseColors((iColor-1)*3+1);
@@ -366,7 +385,9 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                                b2              = GetBaseColors(iColor*3+2);
                                start = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor) );  
                                end     = GrayLevel_TO_colorTableIndex( GetGreyLevelBoundaries(iColor+1) );  
-                               FillColorTable( start,end, r1,g1,b1, r2,g2,b2 );
+                t1     = _transparence_level_boundary[iColor];
+                               t2              = _transparence_level_boundary[iColor+1];
+                               FillColorTable( start,end, r1,g1,b1, r2,g2,b2, t1,t1 );
                        }// for 
                } //if                          
   } //  End Of if (!_color_type)
@@ -389,7 +410,7 @@ int ColorLayerImageView::GrayLevel_TO_colorTableIndex( double VALUE )
 }
 
 //----------------------------------------------------------------------------
-void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2)
+void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2, double t1, double t2)
 {
    vtkLookupTable* thresholdTable = GetThresholdTable();
        int      iTable;
@@ -397,12 +418,13 @@ void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g
        double dr               = (r2-r1)/delta;
        double dg               = (g2-g1)/delta;
        double db               = (b2-b1)/delta;
+   double dt      = (t2-t1)/delta;
        for (iTable=0; iTable<=delta; iTable++)
        {
-               thresholdTable->SetTableValue(  iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,1);
+               thresholdTable->SetTableValue(  iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,t1+dt*iTable);
        } // for iTable
 
-       if (start==0) thresholdTable->SetTableValue(  start , r1, g1, b1,0);   // The first color in the table is transparent
+//     if (start==0) thresholdTable->SetTableValue(  start , r1, g1, b1,0);   // The first color in the table is transparent
 
 }