]> Creatis software - creaMaracasVisu.git/commitdiff
Color Layer update
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 2 Dec 2020 15:16:16 +0000 (16:16 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 2 Dec 2020 15:16:16 +0000 (16:16 +0100)
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx

index 46c2aae99bb70208ef1cd5729cd5dec5b0487d1b..251df8868a30597bff1ccc374f58fd95eb634136 100644 (file)
@@ -124,25 +124,18 @@ printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n
  **/
 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max,int opacity, int type)
 //: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
-
 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
-
-
 {
-
        _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
        _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
-
        _cb_ShowHide                            = NULL;
        _sl_SliceImageX                         = NULL;
        _sl_SliceImageY                         = NULL;
        _sl_SliceImageZ                         = NULL;
        _histogram                                      = NULL;
        _histogramMinMaxLevel           = NULL;
-
        wxFlexGridSizer * sizer         = NULL;
        _colorLayerImageViewManager     = new ColorLayerImageViewManager();
-
        if (type==1)
        {
                sizer                                                   = new wxFlexGridSizer(1);
@@ -212,14 +205,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
 
        } // type==1
 
-
        if (type==2)
        {
                sizer                                                   = new wxFlexGridSizer(2);
                _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") );
                _interpolationCheckBox->SetValue(true);
                _opacity = new wxSlider(this, wxID_ANY, opacity, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-
                Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
                Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
 //             sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxEXPAND );
@@ -229,7 +220,6 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
 
        } // type==2
 
-
        this->SetSizer( sizer );
 //     this->SetAutoLayout( true );
 //     this->Layout();
@@ -244,40 +234,31 @@ ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
 {
 }
 
-
 //----------------------------------------------------------------------------
 ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
 {
    return _colorLayerImageViewManager;
 }
 
-
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
-    {
-               
+    {          
                if (_histogramMinMaxLevel!=NULL) 
                {
                        _histogramMinMaxLevel->Configure( img );
                }
         _colorLayerImageViewManager->SetImage( img );
-
         double         spcOriginalLayer[3];
         int    dimensionOriginalLayer[3];
-
         double         spcBase[3];
         int    dimensionBase[3];
-
         double         newSpc[3];
-
                GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer);               
                GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer);           
-
                GetColorLayerImageViewManager()->GetSpcBase(0,spcBase);         
                GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase);             
-
                if (_sl_SliceImageX!=NULL)
                {
                    _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
@@ -285,7 +266,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                    _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] );
                }
 
-
         if (   (spcOriginalLayer[0]!=spcBase[0]) || 
                                (spcOriginalLayer[1]!=spcBase[1]) || 
                                (spcOriginalLayer[2]!=spcBase[2]) ||
@@ -349,10 +329,8 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
            _colorLayerImageViewManager->onThreshold();
                RefreshView();
        } // _ative 
-
 }
 
-
 void ColorLayerImageViewPanel::RefreshView()
 {
 //EED01        _colorLayerImageView->Refresh();
@@ -387,19 +365,19 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 //      w.ShowModal();
        printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
 
-       creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
-       
-       vtkImageChangeInformation *change = vtkImageChangeInformation::New();
-       vtkImageData *img = diag.getImageData();
        int     ext[6];
        double  spc[6];
        double  origin[3];
+       origin[0]       = 0;
+       origin[1]       = 0;
+       origin[2]       = 0;
+
+       creaMaracasVisuKernel::OpenImageDialog  diag    = creaMaracasVisuKernel::OpenImageDialog();
+       vtkImageChangeInformation                               *change = vtkImageChangeInformation::New();
+       vtkImageData                                                    *img    = diag.getImageData();
        img             -> GetExtent( ext );    
        img             -> GetSpacing( spc );   
        change  -> SetInputData( img );
-       origin[0]=0;
-       origin[1]=0;
-       origin[2]=0;
        change  -> SetOutputSpacing( spc[0] , spc[1] , spc [2] );
        change  -> SetOutputExtentStart(0,0,0);
        change  -> SetOutputOrigin( origin );
index c295169ae16fc898a8eb0fab5bb0708ab31cde3e..cbf55cfc471739c5bc5ac76749438e6087315fc5 100644 (file)
@@ -547,7 +547,6 @@ void LayerImageBase::onThreshold()
 #else
                _thresholdMapper->SetInputData( img );
 #endif
-
                _thresholdMapper->SetLookupTable( _thresholdTable );
 
 
index f20eefcf92e9d57318477c5711e7cd62ecd63d35..0ab4c87e8ac3ac985eb3566b10f14905967a4724 100644 (file)
@@ -81,9 +81,8 @@ void ThresholdImageView::ConfigLookupTable()  // virtual
        int minVal = floor (_minValue);
        int maxVal = floor (_maxValue);
 
-       vtkLookupTable* thresholdTable = GetThresholdTable();
-       thresholdTable->SetNumberOfTableValues(maxTot+1);
-       thresholdTable->SetTableRange(range); 
+       vtkLookupTable *thresholdTable = GetThresholdTable();
+       thresholdTable->SetNumberOfTableValues( (maxTot-minTot) );
        thresholdTable->SetAlphaRange(0, 1);
        thresholdTable->SetValueRange(0, 1);
        thresholdTable->SetSaturationRange(0, 0); 
@@ -91,27 +90,40 @@ void ThresholdImageView::ConfigLookupTable()  // virtual
 
        //Assign a fake color for the upper image, and set the white as transparent
        int i;
-       for(i = minTot; i <= maxTot; i++)
+       int minVal2;
+       int maxVal2;
+       int minTot2;
+       int maxTot2;
+
+       minVal2=minVal-minTot;
+       maxVal2=maxVal-minTot;
+       minTot2=minTot-minTot;
+       maxTot2=maxTot-minTot;
+
+//     thresholdTable->SetTableRange(minVal,maxVal); 
+//EED  You need to do this loop just the first time
+//     for(i = minTot2; i <= maxTot2; i++)
+//     {
+//             thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
+//     } // for
+       
+       thresholdTable->SetTableRange(range); 
+       for(i = minTot2; i <= maxTot2; i++)
        {
-               if( i >= minVal && i <= maxVal )
+               if( i >= minVal2 && i <= maxVal2 )
                {
                        thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
-               }
-               else if( i >= minTot && i < minVal )
+               } else if( i >= minTot2 && i < minVal2 )
                {
                        thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-               }
-               else if( i > maxVal && i < maxTot )
+               } else if( i > maxVal2 && i < maxTot2 )
                {
                        thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
-               }
-               else
-               {
+               } else {
                        thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
                }
        } // for
        thresholdTable->Build( );
-
 }