]> Creatis software - creaMaracasVisu.git/commitdiff
#2855 creaMaracasVisu Bug New Normal - ColorLayer box spacing size not identified
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 10 Mar 2016 15:07:16 +0000 (16:07 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 10 Mar 2016 15:07:16 +0000 (16:07 +0100)
bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx
bbtk/src/bbcreaMaracasVisuColorLayerImageView.h
bbtk/src/bbmaracasvisuTransferFunctionView.cxx
bbtk/src/bbmaracasvisuViewerNV.cxx
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
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h

index 90d5de2ea0d3c8d22fe9bea13f74334338658841..ba35577a98bf650128b1f5f16168b1a038cbf4f4 100644 (file)
@@ -74,6 +74,8 @@ void ColorLayerImageView::Process()
 
     clivp->SetImage( bbGetInputIn() );
 
+    bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) );
+
 
 
 //   std::string msg;
index 7191b72618f9bbf5a9974b649ce6997de43a8fa8..5fbe03e67c134aa31ff68a588b7c8c55bd202c30 100644 (file)
@@ -57,6 +57,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView
   BBTK_DECLARE_INPUT(lstRangeForColorBar,std::vector<double>);
   BBTK_DECLARE_INPUT(PlainOrGradientColor,bool);
   BBTK_DECLARE_INPUT(FittingMode,int);
+  BBTK_DECLARE_OUTPUT(NewImage,vtkImageData*);
   BBTK_PROCESS(Process);
   void Process();
   BBTK_CREATE_WIDGET(CreateWidget);
@@ -90,6 +91,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ColorLayerImageView,bbtk::WxBlackBox);
 
   BBTK_INPUT(ColorLayerImageView,PlainOrGradientColor,"true=Plane false=Gradient (Default 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_OUTPUT(ColorLayerImageView,NewImage,"Image with correct Spacing",vtkImageData*,"");
+
+
 BBTK_END_DESCRIBE_BLACK_BOX(ColorLayerImageView);
 //=====
 // Don't edit this file. This file is generated from xml description..
index 7d6765e4344345f820d58e3d4c81b4c9c8b5c576..ca7fa29fa7413104d3910684d0a77424bf1fe457 100644 (file)
@@ -37,12 +37,13 @@ void TransferFunctionView::Process()
        if(bbGetInputIn()!=NULL)
        {
 
-               if(_currentimg != bbGetInputIn()){
+//             if(_currentimg != bbGetInputIn())
+//             {
                        _currentimg =  bbGetInputIn();
                        //mwxwidget->initializeHistogram(_currentimg);                  
                        mwxwidget->setImageData(_currentimg);   
                        //mwxwidget->Refresh(); 
-               }               
+//             }               
 
 //             onColorChange();
                /*
@@ -75,7 +76,7 @@ void TransferFunctionView::onColorChange()
        unsigned int i;
        for(i = 0; i < greylevel.size();i++){
                _tfun->AddPoint(greylevel[i], value[i]);
-               std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+//             std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
        }
        _ctfun->RemoveAllPoints();
        _ctfun->SetScaleToLinear ();
@@ -99,7 +100,7 @@ void TransferFunctionView::onColorChange()
                        nc = ((greylevelcolors[i]-min)/dif)*w + c-w/2;
 //                     _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
                        _ctfun->AddRGBPoint( nc , red[i],green[i], blue[i]);
-               std::cout<<"EED TransferFunctionView::Process()transfer color function <<"<<nc<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+//             std::cout<<"EED TransferFunctionView::Process()transfer color function <<"<<nc<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
                }
                i=greylevelcolors.size()-1;
                _ctfun->AddRGBPoint( greylevelcolors[i] , red[i],green[i], blue[i]);
@@ -116,29 +117,13 @@ void TransferFunctionView::onColorChange()
 }
 
 void TransferFunctionView::onSliderChange()
-       {
-       
-               //EED
+{
                onColorChange();
-
                bbSignalOutputModification();
-
-printf("EED TransferFunctionView::onSliderChange  ---------------------  \n");
-
 //     bbSetOutputWindowLevel(mwxwidget->GetWindowLevel());
 //     bbSetOutputColorLevel(mwxwidget->GetColorLevel());
-
 }
 
-/*
-//-----------------------------------------------------
-void TransferFunctionView::onActive()
-{
-       bbSignalOutputModification();
-
-   printf("EED TransferFunctionView::onActive popopopopopopopop \n");
-}
-*/
 
 //-----------------------------------------------------
 void TransferFunctionView::CreateWidget(wxWindow* parent)
@@ -199,13 +184,6 @@ void TransferFunctionView::bbUserSetDefaultValues()
                _box->onSliderChange();
        }
 
-/*
-       void HandlerTransferFunctionView::onActive(wxCommandEvent& event)
-       {
-               _box->onActive();
-       }
-*/
-
 }
 
 // EO namespace bbcreaMaracasVisu
index 1b17eec7de9729c10600818c5b9b863ff014f6c8..a1910174557d31e4535b4e197d6561879810996b 100644 (file)
@@ -86,17 +86,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox);
 void ViewerNV::Process()
 {
        vtkImageData* img = bbGetInputIn();
-/*
-       double spc[3];
-       img->GetSpacing(spc);
-    printf ("EED ViewerNV::Process A %f %f %f \n", spc[0], spc[1], spc[2] );
-       img->SetSpacing( 1,1,1 );
-       img->Update(  );
-       img->GetSpacing(spc);
-       img->PrintSelf(std::cout,(vtkIndent)2);
-       img->Print(std::cout);
-    printf ("EED ViewerNV::Process B %f %f %f \n", spc[0], spc[1], spc[2] );
-*/
+
+
        std::vector<int> type = bbGetInputnTypeView();
 
 
@@ -107,11 +98,10 @@ void ViewerNV::Process()
                }else if (img != _currentimg){
                        _mwxwidget->SetImage(img);
                }
-
                _mwxwidget->RefreshView();
 
-               _currenttype = type;
-               _currentimg = img;
+               _currenttype    = type;
+               _currentimg     = img;
 
                _point.clear();
                _point.push_back((int)_mwxwidget->GetX());
index 1306f71915a08e43a0e65ddef8a27bbfd50beaf0..bc06bfded77c992a6d614819ed56fb3889a7c2ff 100644 (file)
@@ -384,6 +384,16 @@ void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
   } // for 
 }
 
+//----------------------------------------------------------------------------
+vtkImageData* ColorLayerImageViewManager::GetImageChangeInformation(int id)
+{
+       if (_colorLayerImageViewLst[id]!=NULL)
+       {
+          return _colorLayerImageViewLst[id]->GetImage( );
+       } // if 
+       return NULL;
+}
+
 //----------------------------------------------------------------------------
 void ColorLayerImageViewManager::GetDimensionBase(int id,int *dim)
 {
index c898121d97cef5b4e68185b40d2479a2941214c0..06194feac52723a90d9bbb1976e5b42753282013 100644 (file)
@@ -68,11 +68,12 @@ class  ColorLayerImageViewManager
          void                          SetSliceFixDynamic( bool fixdin );
          void                          onThresholdChangeOpacity( int opacity );
          void                          SetImage( vtkImageData* img );
+         vtkImageData*         GetImageChangeInformation(int id);
 
-         void                          GetDimensionBase                        (int id,int *dim);
-         void                          GetSpcBase                                      (int id,double *spc);
-         void                          GetDimensionOriginalLayer       (int id,int *dim);
-         void                          GetSpcOriginalLayer                     (int id,double *spc);
+         void                          GetDimensionBase                        (int id,int     *dim);
+         void                          GetSpcBase                                      (int id,double  *spc);
+         void                          GetDimensionOriginalLayer       (int id,int     *dim);
+         void                          GetSpcOriginalLayer                     (int id,double  *spc);
          void                          SetNewSpacingLayer(double *spc);
 
   private:
index e6b81ed42d980f173bfb7f15aaaf9c7daf8cd4ba..5f08d62021a081d794c46d1884032c0c7265303a 100644 (file)
@@ -278,15 +278,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                GetColorLayerImageViewManager()->GetSpcBase(0,spcBase);         
                GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase);             
 
-/*
-        int dim[3];
-        int ext[6];
-        img->GetWholeExtent(ext);
-        dim[0] = ext[1]-ext[0]+1;
-        dim[1] = ext[3]-ext[2]+1;
-        dim[2] = ext[5]-ext[4]+1;
-*/
-
                if (_sl_SliceImageX!=NULL)
                {
                    _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
@@ -294,31 +285,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                    _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] );
                }
 
-/*
-printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
-printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
-printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
-printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
-printf("  Here I have to analyse the spacing and size image to calculate new spacingvv\n"  );
-printf("  I need the caracteristics of the base image\n"  );
-
-               wxVtkBaseView   *wxvtkbaseview  =       GetColorLayerImageViewManager()->GetwxVtkBaseView(0);
-               if (wxvtkbaseview!=NULL)
-               {
-                       vtkImageData    *imagebase              =       wxvtkbaseview->GetVtkBaseData()->GetImageData();
-                       if (imagebase!=NULL) 
-                       {       
-                               imagebase->GetSpacing(_spcBase);
-                               int ext[6];
-                               imagebase->GetWholeExtent(ext);
-                               _dimBase[0]=ext[1]-ext[0]+1;                            
-                               _dimBase[1]=ext[3]-ext[2]+1;                            
-                               _dimBase[2]=ext[5]-ext[4]+1;                            
-                       } // if imagebase
-               } // if wxvtkbaseview
-
-*/
-
 
         if (   (spcOriginalLayer[0]!=spcBase[0]) || 
                                (spcOriginalLayer[1]!=spcBase[1]) || 
@@ -349,16 +315,13 @@ printf("  I need the caracteristics of the base image\n"  );
                        //EO CM
             if (typeOfTransformation==1)  // Adapt spacing 
             {
-printf("EED ColorLayerImageViewPanel::SetImag 1 \n");
                 newSpc[0] = spcBase[0] * dimensionBase[0] / dimensionOriginalLayer[0];
                 newSpc[1] = spcBase[1] * dimensionBase[1] / dimensionOriginalLayer[1];
                 newSpc[2] = spcBase[2] * dimensionBase[2] / dimensionOriginalLayer[2];
-printf("EED ColorLayerImageViewPanel::SetImag 1  newSpc=%f  %f  %f \n", newSpc[0],newSpc[1],newSpc[2] );
             }
 
             if (typeOfTransformation==2)  // keep spacing of the Layer Image
             {
-printf("EED ColorLayerImageViewPanel::SetImag 2 \n");
                 newSpc[0] = spcOriginalLayer[0];
                 newSpc[1] = spcOriginalLayer[1];
                 newSpc[2] = spcOriginalLayer[2];
@@ -366,22 +329,19 @@ printf("EED ColorLayerImageViewPanel::SetImag 2 \n");
 
             if (typeOfTransformation==3)  // Use the spacing of the Base Image
             {
-printf("EED ColorLayerImageViewPanel::SetImag 3 \n");
                 newSpc[0] = spcBase[0];
                 newSpc[1] = spcBase[1];
                 newSpc[2] = spcBase[2];
-//                spc[0] = 1;
-//                spc[1] = 1;
-//                spc[2] = 1;
             }
-
-       
                        GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc);
+        } else {
+                newSpc[0] = spcOriginalLayer[0];
+                newSpc[1] = spcOriginalLayer[1];
+                newSpc[2] = spcOriginalLayer[2];
+               } // spc !_spcBase   dim!__dimBase
+
+               GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc);
 
-//            img->SetSpacing(newSpc);
-//                     img->Update();
-//                     img->Modified();
-        } // spc !_spcBase   dim!__dimBase
     } // _firsttime_mode
 
        if (_active==true)
index a86251cddaa68abde26eba60a6d3a7b2560c367e..8f1fc5e04406beae38226215da1528ddab6cd2fc 100644 (file)
@@ -152,7 +152,14 @@ int LayerImageBase::GetZ()  // virtual
 vtkImageData* LayerImageBase::GetImage()
 {
 //     return _image;
-       return _imageChangeInformation->GetOutput();
+       vtkImageData *result;
+       if (_image==NULL)
+       {
+               result = NULL;
+       } else {
+               result = _imageChangeInformation->GetOutput();
+       }
+       return result;
 }
 
 //----------------------------------------------------------------------------
@@ -402,26 +409,16 @@ void LayerImageBase::onThreshold()
 {
        if ((_image!=NULL) && (_baseView!=NULL))
        {
-double spc[3];
-GetImage()-> GetSpacing(spc);
-printf("EED  LayerImageBase::onThreshold  A img-spc %f  %f  %f\n", spc[0],spc[1],spc[2]);
                double x=GetX();
                double y=GetY();
                double z=GetZ();
 
-//             x = x*spc[0];
-//             y = y*spc[1];
-//             z = z*spc[2];
-
-               
                x = x*_spcBase[0];
                y = y*_spcBase[1];
                z = z*_spcBase[2];
 
-
                CleanXYZ(x,y,z);
 
-
                vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera();
                int directionViewer=0;
                if (camera->GetParallelProjection()==1)
@@ -430,7 +427,6 @@ printf("EED  LayerImageBase::onThreshold  A img-spc %f  %f  %f\n", spc[0],spc[1]
                        directionViewer =  wxvtk2dbasevie->GetDirection();
                } // ParallelProjection
 
-
                if (!GetActorPresent())
                {
                        if (_thresholdTable==NULL)
@@ -516,9 +512,6 @@ printf("EED  LayerImageBase::onThreshold  A img-spc %f  %f  %f\n", spc[0],spc[1]
 
 //             _scalarbarActor->SetTextPad(4);  ??
 
-GetImage()-> GetSpacing(spc);
-printf("EED  LayerImageBase::onThreshold  B img-spc %f  %f  %f\n", spc[0],spc[1],spc[2]);
-
 
                } // _image
 }
index b6ad1e1dfd4e02209616220a6b2871d92489b4d3..0a9f0c0327505c44dac943cbeeb2dcbea726e64c 100644 (file)
@@ -85,13 +85,14 @@ class LayerImageBase
   public:
                LayerImageBase();
                virtual ~LayerImageBase();
-               void SetX(int x);
-               void SetY(int y);
-               void SetZ(int z);
-               void SetImage(vtkImageData* image);
-               void SetRangeForColorBar(std::vector<double> &range);
-               void GetRangeForColorBar(double &minRange, double &maxRange);
-               void SetwxVtkBaseView(wxVtkBaseView *baseview);
+               void                    SetX(int x);
+               void                    SetY(int y);
+               void                    SetZ(int z);
+               void                    SetImage(vtkImageData* image);
+               vtkImageData*   GetImage();
+               void                    SetRangeForColorBar(std::vector<double> &range);
+               void                    GetRangeForColorBar(double &minRange, double &maxRange);
+               void                    SetwxVtkBaseView(wxVtkBaseView *baseview);
 
                void onThreshold();
                void onThresholdChange();
@@ -148,7 +149,6 @@ class LayerImageBase
 
   protected:
                vtkLookupTable                          *GetThresholdTable();
-               vtkImageData                            *GetImage();
                double                                          _range[2];
                std::vector<double>             _rangeForColorBar;
  };