]> Creatis software - creaMaracasVisu.git/commitdiff
#2651 creaMaracasVisu Feature New Normal - Color Layer: Transparent Base, Refresh
authordavila <eduardo.davila@creatis.insa-lyon.fr>
Mon, 1 Jun 2015 13:13:39 +0000 (15:13 +0200)
committerdavila <eduardo.davila@creatis.insa-lyon.fr>
Mon, 1 Jun 2015 13:13:39 +0000 (15:13 +0200)
bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx
bbtk/src/bbcreaMaracasVisuColorLayerImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx

index 160795d57f2fccc04eb444a651a4a69defa78f1b..303736b51b00d7854a9d555b7bdb8cd15cdc2cda 100644 (file)
@@ -44,17 +44,24 @@ void ColorLayerImageView::Process()
  
     ColorLayerImageViewPanel *clivp = (ColorLayerImageViewPanel*)bbGetOutputWidget();
 
-    clivp->SetActive( bbGetInputActive() );
+        if (firsttime==true)
+        {
+               firsttime=false;
+       clivp->SetActive( bbGetInputActive() );
+        }
 
     clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() );
     clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 1 , bbGetInputWxVtkBaseView1() );
     clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 2 , bbGetInputWxVtkBaseView2() );
-   
+
     std::vector<double> base_color = bbGetInputlstBaseColor();
     clivp->GetColorLayerImageViewManager()->SetBaseColors( base_color );
 
     std::vector<double> grey_level_boundaries = bbGetInputlstGreyLevelBoundaries();
     clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries );
+
+    std::vector<double> transparence_level_boundaries = bbGetInputlstTransparenceBoundaries();
+    clivp->GetColorLayerImageViewManager()->SetBaseTransparence( transparence_level_boundaries );
  
     clivp->GetColorLayerImageViewManager()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() );
     clivp->SetFittingMode( bbGetInputFittingMode() );
@@ -86,6 +93,7 @@ void ColorLayerImageView::CreateWidget(wxWindow* parent)
 //=====
 void ColorLayerImageView::bbUserSetDefaultValues()
 {
+    firsttime=true;
     bbSetInputIn(NULL);
     bbSetInputActive(true);
     bbSetInputWxVtkBaseView(NULL);
index e12f2ddbdd4f569633b0b0e1429f909ed958472b..b51d3ac647926452604e126037a34c8c80b89a96 100644 (file)
@@ -52,6 +52,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView
   BBTK_DECLARE_INPUT(WxVtkBaseView2,wxVtkBaseView *);
   BBTK_DECLARE_INPUT(lstBaseColor,std::vector<double>);
   BBTK_DECLARE_INPUT(lstGreyLevelBoundaries,std::vector<double>);
+  BBTK_DECLARE_INPUT(lstTransparenceBoundaries,std::vector<double>);
   BBTK_DECLARE_INPUT(PlainOrGradientColor,bool);
   BBTK_DECLARE_INPUT(FittingMode,int);
   BBTK_PROCESS(Process);
@@ -59,6 +60,8 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView
   BBTK_CREATE_WIDGET(CreateWidget);
   void CreateWidget(wxWindow*);
 
+  bool firsttime;
+
 //=====
 // Don't edit this file. This file is generated from xml description..
 //=====
@@ -75,7 +78,11 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColorLayerImageView,bbtk::WxBlackBox);
   BBTK_INPUT(ColorLayerImageView,WxVtkBaseView1," 1 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,"");
   BBTK_INPUT(ColorLayerImageView,WxVtkBaseView2," 2 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,"");
   BBTK_INPUT(ColorLayerImageView,lstBaseColor,"List of Base Colors in RGB format to define the color map. Requirement: must be of a size being a multiple of 3, with values between 0 and 1. For example, for 2 colors: \"1 0 0 0 0 1\". If not provided as required, the histogram is equally split into three areas, blue, yellow and red.",std::vector<double>,"");
+  BBTK_INPUT(ColorLayerImageView,lstTransparenceBoundaries,"Transparence vector. (The same size of color lst).",std::vector<double>,"");
+
   BBTK_INPUT(ColorLayerImageView,lstGreyLevelBoundaries,"List of the Grey Level Boundaries to define the color map (grey level outside the color boundaries will not be disayed). Requirement: Must have one more element than the number of colours. For example, for 2 colors: \"50 150 250\". If not provided as required, the histogram is equally split into areas, which number corresponds to the number of colors provided (3 by default).",std::vector<double>,"");
+
+
   BBTK_INPUT(ColorLayerImageView,PlainOrGradientColor,"Choose between Plain (true) or Gradient (false) colors. Default is false.",bool,"");
   BBTK_INPUT(ColorLayerImageView,FittingMode,"Choose the fitting mode between the images, the transformation can be either by Dimension (1), by Spacing (2) or by Pixel (3). If you want to make the choice through a dialog box, choose (-1). Default is by Pixel (3).",int,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ColorLayerImageView);
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
 
 }
 
index 75c6e1a107c62ec04af4d204798cd4a7ad4d6cfa..305afdc15188853f5ff389aa743fef3e24a0972a 100644 (file)
@@ -58,6 +58,11 @@ class  ColorLayerImageView : public LayerImageBase
           * \param base_color the base color vector.
           */
          void SetBaseColors(std::vector<double> & base_color);
+
+
+         void SetBaseTransparence(std::vector<double> & base_transparence);
+
+
          /** 
           * \brief  Returns the base color for a given index (first coordinate of the first color being 1, second coordinate of the first color being 2, etc.).
           *
@@ -92,7 +97,7 @@ class  ColorLayerImageView : public LayerImageBase
          int GetBaseColorNb();
 
 
-               void    FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2);
+               void    FillColorTable(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2, double t1, double t2);
 
                int     GrayLevel_TO_colorTableIndex( double VALUE );
 
@@ -114,6 +119,8 @@ class  ColorLayerImageView : public LayerImageBase
          std::vector<double> _base_color;
          //! Grey level boundaries.
          std::vector<double> _grey_level_boundary;
+         //! Grey level boundaries.
+         std::vector<double> _transparence_level_boundary;
          //! Color type (plain or gradient color).
          bool _color_type;
 
index 2e5b403247f113bab6b143bce9b1baf49402698e..51e552d7d66ec4c14432ecff28b25a126a19bb27 100644 (file)
@@ -175,6 +175,21 @@ void ColorLayerImageViewManager::SetBaseColors(std::vector<double> & base_color)
   } // for 
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::SetBaseTransparence(std::vector<double> & base_transparence)
+{
+  int i, size=_colorLayerImageViewLst.size();
+  for (i=0;i<size;i++)
+  {
+       if (_colorLayerImageViewLst[i]!=NULL)
+       {
+          _colorLayerImageViewLst[i]->SetBaseTransparence( base_transparence );
+       } // if 
+  } // for 
+}
+
+
+
 //----------------------------------------------------------------------------
 double ColorLayerImageViewManager::GetBaseColors(unsigned int index)
 {
index 0d6a6a899c9216f95f4a6503964a26ea21484c5d..05425bf56a2b648745db38ac493990de884160fa 100644 (file)
@@ -54,6 +54,7 @@ class  ColorLayerImageViewManager
          void SetBaseColors(std::vector<double> & base_color);
          double GetBaseColors(unsigned int index);
          void SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary);
+         void SetBaseTransparence(std::vector<double> & base_transparence);
          double GetGreyLevelBoundaries(unsigned int index);
          void SetPlainOrGradientColor(bool color_type);
          int GetBaseColorNb();
index d6efc9123ee1ebbf4b0249a3c1d2370295f6592b..20a723cd68e948279419dddbffd77dd57f5b2860 100644 (file)
@@ -289,15 +289,16 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 
             img->SetSpacing(spc);
         } // spc !_spcBase   dim!__dimBase
+    } // _firsttime_mode
 
-               if (_active==true)
-               {
-                   _colorLayerImageViewManager->onThreshold();
-                RefreshView();
-               }
-
+printf("EED ColorLayerImageViewPanel::SetImage\n");
+       if (_active==true)
+       {
+printf("EED ColorLayerImageViewPanel::SetImage _active=true \n");
+           _colorLayerImageViewManager->onThreshold();
+               RefreshView();
+       } // _ative 
 
-    }
 }
 
 
@@ -354,6 +355,7 @@ void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
 {
         _thresholdGo = _cb_ShowHide->GetValue();
+                       _active = _thresholdGo;
         if (_thresholdGo)
         {
                    _colorLayerImageViewManager->onThreshold();
@@ -411,8 +413,8 @@ void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
-        int opacity = _opacity->GetValue();
-        _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
+       int opacity = _opacity->GetValue();
+       _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
        RefreshView();
 }
 
index 15ec30669619dfd9f52651a7c45b3a0f6c699771..a283606543dea92ca61c0af924dcf5c58c85455f 100644 (file)
@@ -258,8 +258,11 @@ void LayerImageBase::CleanXYZ(double &x, double &y, double &z)
 //----------------------------------------------------------------------------
 void LayerImageBase::onThreshold()
 {
+printf("EED LayerImageBase::onThreshold Start \n");
+
        if ((_image!=NULL) && (_baseView!=NULL))
        {
+printf("EED LayerImageBase::onThreshold 1 \n");
                double spc[3];
                GetImage()-> GetSpacing(spc);
                double x=GetX();
@@ -282,6 +285,7 @@ void LayerImageBase::onThreshold()
 
                if (!GetActorPresent())
                {
+printf("EED LayerImageBase::onThreshold 2 \n");
                        if (_thresholdTable==NULL)
                        {
                                //Lookup Table
@@ -323,6 +327,8 @@ void LayerImageBase::onThreshold()
                _imageReslicer->SetInput( GetImage() );
                _imageReslicer->SetInformationInput( GetImage() );
 
+printf("EED LayerImageBase::onThreshold  directionViewer=%d\n", directionViewer );
+
                if (directionViewer==0)
                {
                        _imageReslicer->SetResliceAxesDirectionCosines( 0,0,1, 0,1,0,  -1,0,0 );