]> Creatis software - creaMaracasVisu.git/commitdiff
#3546 bug ColorLayer with images all 0
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 22 Dec 2023 16:28:23 +0000 (17:28 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 22 Dec 2023 16:28:23 +0000 (17:28 +0100)
bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx
bbtk/src/bbmaracasvisuImageChangeInformation.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx

index 3b9ad123312adca11bdd5b1fcbe86b1e6f7ee11a..6fde87a4c8705862f9e6faf623ee10003b5751a1 100644 (file)
@@ -92,7 +92,6 @@ void ColorLayerImageView::Process()
                 std::vector<double> base_color                      = bbGetInputlstBaseColor();
                 std::vector<double> grey_level_boundaries           = bbGetInputlstGreyLevelBoundaries();
                 std::vector<double> transparence_level_boundaries   = bbGetInputlstTransparenceBoundaries();
-
                 clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() );
                 clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 1 , bbGetInputWxVtkBaseView1() );
                 clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 2 , bbGetInputWxVtkBaseView2() );
@@ -104,7 +103,7 @@ void ColorLayerImageView::Process()
                 clivp->GetColorLayerImageViewManager()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() );
                 clivp->SetFittingMode( bbGetInputFittingMode() );
                 clivp->SetImage( bbGetInputIn() );
-                
+
                 bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) );
                 bbSetOutputLookupTable( clivp->GetColorLayerImageViewManager()->GetLookupTable(0) );
                 bbSetOutputOutOpacity( clivp->GetOpacity() );
index 1eb17aecf1fb9891caf3736c386bde73143b802b..26314f4f642e11de359c30640c465411dffbf0e5 100644 (file)
@@ -81,14 +81,10 @@ void ImageChangeInformation::Process()
                mchange->Update();    //important
                bbSetOutputOut( mchange->GetOutput() );
     } else {
-        printf("EED ImageChangeInformation::Process  NULL\n");
         bbSetOutputOut( NULL );
-
     }  // if img
-
 }
 
-
 void ImageChangeInformation::bbUserSetDefaultValues()
 {
        mchange = NULL;
index 869b844f9abc91838a89d33112a0b4c58cbcd402..af5bf5728820d72348cca8735f42c3ff174ae373 100644 (file)
@@ -303,7 +303,6 @@ void ColorLayerImageView::SetDefaultBaseColorAndGreyLevelBoundary()
 //----------------------------------------------------------------------------
 void ColorLayerImageView::ConfigLookupTable()  // virtual
 {
-
   // CM 2014
   // EED        28/01/2015     
   // Grey level extrema retrieved from the image grey level extrema.
@@ -327,8 +326,8 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                {
 //EED                          std::cout << "CM ColorLayerImageView::ConfigLookupTable : ERROR!!! Inconsistency between the sizes of vectors _base_color and _grey_level_boundary. _base_color.size()/3 (=" <<_base_color.size()/3 << ") should be equal to _grey_level_boundary.size()+1 (=" << _grey_level_boundary.size()<<"+1)." << std::endl;
 //EED                          std::cout << "CM The default values for the base colors and the grey level boundaries will be set." << std::endl;
-                               SetDefaultGreyLevelBoundary();     
-               } // if 
+                               SetDefaultGreyLevelBoundary();
+               } // if
                } // _color_type 
 
                if (_color_type==false)  // Gradiant
@@ -382,7 +381,6 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
   thresholdTable->SetNumberOfTableValues( maxColorsThresholdTable+1 );
   thresholdTable->SetNanColor(0,0,0,0);
 
-
   // Defines the lookup table.
   // If the image has a degradation in one (or both) extremum (lower or higher),
   // sets the corresponding grey levels as transparent white in the lookup table.
@@ -435,7 +433,7 @@ void ColorLayerImageView::ConfigLookupTable()  // virtual
                        }// for 
                } //if                          
   } //  End Of if (!_color_type)
-
+    
   double minRangeForColorBar, maxRangeForColorBar;
   GetRangeForColorBar( minRangeForColorBar, maxRangeForColorBar );
   thresholdTable->SetRange( minRangeForColorBar, maxRangeForColorBar );
@@ -455,24 +453,29 @@ int ColorLayerImageView::GrayLevel_TO_colorTableIndex( double VALUE )
 
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
-  GetImage()->Update();
+    GetImage()->Update();
 #else
   //...
 #endif
 
 //EED 20 oct 2015
 //  GetImage()->GetScalarRange(_range);
-  GetImageScalarRange();
-
-  double minRange = _range[0];
-  double maxRange = _range[1];
-  return  maxColorsThresholdTable * (VALUE-minRange) / (maxRange-minRange);    
+    GetImageScalarRange();
+    double minRange = _range[0];
+    double maxRange = _range[1];
+    
+    if (maxRange==minRange)
+    {
+        return 0;
+    } else {
+        return  maxColorsThresholdTable * (VALUE-minRange) / (maxRange-minRange);
+    }
 }
 
 //----------------------------------------------------------------------------
 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();
+    vtkLookupTable* thresholdTable = GetThresholdTable();
        int     iTable;
        double  delta   = end-start;
        double  dr              = (r2-r1)/delta;
@@ -483,8 +486,6 @@ void ColorLayerImageView::FillColorTable(int start, int end, double r1, double g
        {
                thresholdTable->SetTableValue(  iTable+start , r1+dr*iTable, g1+dg*iTable, b1+db*iTable,t1+dt*iTable);
        } // for iTable
-
-
 }
 
 // EOF
index 631c11a76bddb5259cd5476cd6a30f4b5c77ea7f..cca709a45d337067b448f602113cfe18b552fac5 100644 (file)
@@ -481,7 +481,7 @@ void ColorLayerImageViewManager::SetImageStep2(  vtkImageData* img  )
             } // spc !_spcBase   dim!__dimBase
             this->SetNewSpacingLayer(newSpc);
         } // img
+
     if (_active==true)
     {
         this->onThreshold();
@@ -491,7 +491,6 @@ void ColorLayerImageViewManager::SetImageStep2(  vtkImageData* img  )
         } // img
         this->Refresh();
     } // _active
-
 }
 
 //----------------------------------------------------------------------------
index b5287a88fb8fc11978152a291dde0d0dd229d2e6..3d84d0746a14a2a44754b93ba6d2383adbde9c26 100644 (file)
@@ -382,7 +382,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
     _colorLayerImageViewManager->SetImageStep2( img );
 
 //    } // img
-
 }
 
 //----------------------------------------------------------------------------
index 1b3bec6e4b4ff600f4c88364639b010583fd7045..3831807b3c21cfc20ddc8b954c54ae232011942e 100644 (file)
@@ -459,7 +459,6 @@ void LayerImageBase::onThreshold()
                        directionViewer =  wxvtk2dbasevie->GetDirection();
                } // ParallelProjection
 
-
                if (!GetActorPresent())
                {
                        if (_thresholdTable==NULL)
@@ -497,6 +496,7 @@ void LayerImageBase::onThreshold()
                                        _thresholdActor->SetPosition( 0,0, -900-1 );
                                }
                        } // _thresholdActor
+
                        _baseView->GetRenderer()->AddActor( _thresholdActor );
                        _baseView->GetRenderer()->AddActor2D( _scalarbarActor );
                        _actorPresent = true;
@@ -563,7 +563,7 @@ void LayerImageBase::onThreshold()
                _thresholdMapper->Update();
                _thresholdActor->SetInputData( _thresholdMapper->GetOutput() );
 #endif
-               
+
                _thresholdActor->SetOpacity(_opacity);
                _scalarbarActor->SetLookupTable( _thresholdTable );
 //             _scalarbarActor->SetLookupTable( _thresholdMapper->GetLookupTable() );
@@ -573,11 +573,8 @@ void LayerImageBase::onThreshold()
                _scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2);
 //             _scalarbarActor->SetTextPad(4);  ??
     } // if _image
-            
 }
 
-
-
 //----------------------------------------------------------------------------
 void LayerImageBase::onThresholdChange()
 {