]> Creatis software - creaMaracasVisu.git/commitdiff
#2855 creaMaracasVisu Bug New Normal - ColorLayer box spacing size not identified
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 9 Mar 2016 10:37:08 +0000 (11:37 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 9 Mar 2016 10:37:08 +0000 (11:37 +0100)
bbtk/src/bbcreaMaracasVisuManualPaint.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/ColorLayerImageViewManager.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp

index ba692644e2b621d30379b32924f6654c832adf62..d5373bf0cd3b843b3337cffbd9b380dd67744d2a 100644 (file)
@@ -52,8 +52,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint,bbtk::WxBlackBox);
 //=====
 void ManualPaint::Process()
 {
-printf("ManualPaint::Process start\n");
-
 
 /*
    std::string msg;
index 1f66131a66e8263cea5772564875569df9136b97..38f25f35139a03833313d5b32021c68a0c48e0b6 100644 (file)
@@ -45,7 +45,7 @@
 //=========================================================================
 ColorLayerImageView::ColorLayerImageView( )
 {
-  _z2                                  =       0;
+  _z2                          =       0;
   _fix_dynamic         =       true;
   _color_type          =       false;
 }
index b478c254c48bb109c184e5798fddb794cccf214b..1306f71915a08e43a0e65ddef8a27bbfd50beaf0 100644 (file)
@@ -384,5 +384,57 @@ void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
   } // for 
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::GetDimensionBase(int id,int *dim)
+{
+       if (_colorLayerImageViewLst[id]!=NULL)
+       {
+          _colorLayerImageViewLst[id]->GetDimensionBase( dim );
+       } // if 
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::GetSpcBase(int id,double *spc)
+{
+       if (_colorLayerImageViewLst[id]!=NULL)
+       {
+          _colorLayerImageViewLst[id]->GetSpcBase( spc );
+       } // if 
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::GetDimensionOriginalLayer(int id,int *dim)
+{
+       if (_colorLayerImageViewLst[id]!=NULL)
+       {
+          _colorLayerImageViewLst[id]->GetDimensionOriginalLayer( dim );
+       } // if 
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::GetSpcOriginalLayer(int id,double *spc)
+{
+       if (_colorLayerImageViewLst[id]!=NULL)
+       {
+          _colorLayerImageViewLst[id]->GetSpcOriginalLayer( spc );
+       } // if 
+}
+
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+void ColorLayerImageViewManager::SetNewSpacingLayer(double *spc)
+{
+  int i, size=_colorLayerImageViewLst.size();
+  for (i=0;i<size;i++)
+  {
+       if (_colorLayerImageViewLst[i]!=NULL)
+       {
+          _colorLayerImageViewLst[i]->SetNewSpacingLayer( spc );
+       } // if 
+  } // for 
+}
+
+
+
 // EOF
 
index 3c2fd26abcee0c12461cb0e943006e8c65d7022b..c898121d97cef5b4e68185b40d2479a2941214c0 100644 (file)
@@ -68,6 +68,13 @@ class  ColorLayerImageViewManager
          void                          SetSliceFixDynamic( bool fixdin );
          void                          onThresholdChangeOpacity( int opacity );
          void                          SetImage( vtkImageData* img );
+
+         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:
 
        std::vector< ColorLayerImageView* >     _colorLayerImageViewLst;
index af7317cc5877fadcfdfe33a2bbf51de04b092ad7..e6b81ed42d980f173bfb7f15aaaf9c7daf8cd4ba 100644 (file)
@@ -56,15 +56,22 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(
                                                                        int &typeOfTransformation,
                                                                        bool &dlgWxOK)
 {
-       wxDialog* dial                  = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,550),wxRESIZE_BORDER);
-       wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
+       wxDialog* dial                  = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,525),wxRESIZE_BORDER);
+       wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK);
        wxBoxSizer *dialSizer   = new wxBoxSizer(wxVERTICAL);
 
        wxString lstOptOperation[3];
-       lstOptOperation[0]=_T("By Dimension");
-       lstOptOperation[1]=_T("By Spacing");
-       lstOptOperation[2]=_T("By Pixel");
-       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(250,90), 3 , lstOptOperation,  3, wxRA_SPECIFY_COLS);
+//     lstOptOperation[0]=_T("By Dimension");
+//     lstOptOperation[1]=_T("By Spacing");
+//     lstOptOperation[2]=_T("By Pixel");
+
+       lstOptOperation[0]=_T("Adapt spacing of the Layer Image");
+       lstOptOperation[1]=_T("Keep the spacing of the Layer Image");
+       lstOptOperation[2]=_T("Use the same spacing of the Base Image");
+
+
+
+       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of spacing transformation"), wxDefaultPosition, wxSize(250,160), 3 , lstOptOperation,  1, wxRA_SPECIFY_COLS);
 
        wxString str;
        wxString strBaseSpc(str);
@@ -72,12 +79,11 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(
        wxString strBaseDim;
        wxString strLayerDim;
 
-       strBaseSpc.Printf(wxT("Base spacing: %f %f %f"), baseSpc[0],baseSpc[1],baseSpc[2] );
-       strLayerSpc.Printf(wxT("Layer spacing: %f %f %f"), layerSpc[0],layerSpc[1],layerSpc[2] );
-       strBaseDim.Printf(wxT("Base dimension: %d %d %d"), baseDim[0],baseDim[1],baseDim[2] );
-       strLayerDim.Printf(wxT("Layer dimension: %d %d %d"), layerDim[0],layerDim[1],layerDim[2] );
+       strBaseSpc.Printf(wxT("Base spacing: %f %f %f")         , baseSpc[0],baseSpc[1],baseSpc[2]              );
+       strLayerSpc.Printf(wxT("Layer spacing: %f %f %f")       , layerSpc[0],layerSpc[1],layerSpc[2]   );
+       strBaseDim.Printf(wxT("Base dimension: %d %d %d")       , baseDim[0],baseDim[1],baseDim[2]              );
+       strLayerDim.Printf(wxT("Layer dimension: %d %d %d")     , layerDim[0],layerDim[1],layerDim[2]   );
 
-       dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
        dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
        dialSizer->Add( new wxStaticText(dial,-1, strBaseSpc    )       , 0, wxGROW );
        dialSizer->Add( new wxStaticText(dial,-1, strLayerSpc   )       , 0, wxGROW );
@@ -97,9 +103,12 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(
        typeOfTransformation    = -1;
        dlgWxOK                                 = false;
 
+printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType AAA\n");
+
        if (dial->GetReturnCode() == wxID_OK)
        {
                typeOfTransformation    = radioOpts->GetSelection() + 1;
+printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n",typeOfTransformation);
                dlgWxOK                                 = true;
        }
 }
@@ -124,12 +133,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _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;
+       _cb_ShowHide                            = NULL;
+       _sl_SliceImageX                         = NULL;
+       _sl_SliceImageY                         = NULL;
+       _sl_SliceImageZ                         = NULL;
+       _histogram                                      = NULL;
+       _histogramMinMaxLevel           = NULL;
 
        wxFlexGridSizer * sizer         = NULL;
        _colorLayerImageViewManager     = new ColorLayerImageViewManager();
@@ -243,77 +252,80 @@ ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewMana
 }
 
 
-//----------------------------------------------------------------------------
-// This is the new spacing of the background image  (1,1,1)
-void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3])
-{
-       _spcBase[0] = spc[0];
-       _spcBase[1] = spc[1];
-       _spcBase[2] = spc[2];
-
-       _spcBase[0] = 1;
-       _spcBase[1] = 1;
-       _spcBase[2] = 1;
-}
-
-//----------------------------------------------------------------------------
-// This is the Original spacing of the background image
-void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3])
-{
-       _spcOrg[0] = spc[0];
-       _spcOrg[1] = spc[1];
-       _spcOrg[2] = spc[2];
-}
-
-//----------------------------------------------------------------------------
-// This is the size in pixels of the background image
-void ColorLayerImageViewPanel::SetBaseDimension(int dim[3])
-{
-       _dimBase[0] = dim[0];
-       _dimBase[1] = dim[1];
-       _dimBase[2] = dim[2];
-}
-
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
     {
+               
                if (_histogramMinMaxLevel!=NULL) 
                {
                        _histogramMinMaxLevel->Configure( img );
                }
         _colorLayerImageViewManager->SetImage( img );
 
-        double spc[3];
-        img->GetSpacing(spc);
+        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);             
+
+/*
         int dim[3];
         int ext[6];
         img->GetWholeExtent(ext);
-        dim[0] = ext[1]-ext[0];
-        dim[1] = ext[3]-ext[2];
-        dim[2] = ext[5]-ext[4];
-
+        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 , dim[0] );
-                   _sl_SliceImageY->SetRange( 0 , dim[1] );
-                   _sl_SliceImageZ->SetRange( 0 , dim[2] );
+                   _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
+                   _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] );
+                   _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"  );
-//                     GetColorLayerImageViewManager()->GetwxVtkBaseView(0);
+/*
+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"  );
 
-
-        if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
-             (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
+               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]) || 
+                               (spcOriginalLayer[2]!=spcBase[2]) ||
+               (dimensionOriginalLayer[0]!=dimensionBase[0]) || 
+                               (dimensionOriginalLayer[1]!=dimensionBase[1]) || 
+                               (dimensionOriginalLayer[2]!=dimensionBase[2])
             )
         {
                        // CM
@@ -322,9 +334,9 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                        if (_fitting_mode == -1)
                        {
                                bool transformOkDlg;
-                       wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
+                       wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? ");
                        wxDlgTransformByDimensionBySpacingByPixel dlg;
-                       dlg.GetTransformType(this,_spcBase,spc,_dimBase,dim,msg,typeOfTransformation,transformOkDlg);
+                       dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg);
                        // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
                        if (transformOkDlg == false)
                                {
@@ -335,29 +347,40 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                        } // _fitting_mode -1
 
                        //EO CM
-            if (typeOfTransformation==1)  // make dimensions equals
+            if (typeOfTransformation==1)  // Adapt spacing 
             {
-                printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
-                spc[0]=_spcBase[0]*_dimBase[0]/dim[0];
-                spc[1]=_spcBase[1]*_dimBase[1]/dim[1];
-                spc[2] = 1;
+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)  // make spacing equals
+            if (typeOfTransformation==2)  // keep spacing of the Layer Image
             {
-                spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0];
-                spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1];
-                spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2];
+printf("EED ColorLayerImageViewPanel::SetImag 2 \n");
+                newSpc[0] = spcOriginalLayer[0];
+                newSpc[1] = spcOriginalLayer[1];
+                newSpc[2] = spcOriginalLayer[2];
             }
 
-            if (typeOfTransformation==3)  // make spacing = 1
+            if (typeOfTransformation==3)  // Use the spacing of the Base Image
             {
-                spc[0] = 1;
-                spc[1] = 1;
-                spc[2] = 1;
+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;
             }
 
-            img->SetSpacing(spc);
+       
+                       GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc);
+
+//            img->SetSpacing(newSpc);
+//                     img->Update();
+//                     img->Modified();
         } // spc !_spcBase   dim!__dimBase
     } // _firsttime_mode
 
index a26343843979618652779f4ad38353b6f7fafdd9..4982e11e9559ddf91e6ae57e135e39b97fd466e4 100644 (file)
@@ -79,9 +79,8 @@ class ColorLayerImageViewPanel
 //EED01                        ColorLayerImageView* GetColorLayerImageView();
 //EED01                        void SetColorLayerImageView(ColorLayerImageView* colorLayerImageView);
                        bool IsVisible();
-                       void SetBaseSpacing(double spc[3]);
-                       void SetBaseDimension(int dim[3]);
-                       void SetOriginalSpacing(double spc[3]);
+
+
                        void SetImage(vtkImageData *img);
                        void SetFittingMode(int fitting_mode);
                        int  GetFittingMode();
index d89c05ed8da74f5e309c9d3ca49cba03a4b90c85..a86251cddaa68abde26eba60a6d3a7b2560c367e 100644 (file)
@@ -93,17 +93,18 @@ private:
 
 LayerImageBase::LayerImageBase()
 {
-       _actorPresent           =       false;
-       _X                                      =       0;
-       _Y                                      =       0;
-       _Z                                      =       0;
-       _thresholdTable         =       NULL;
-       _thresholdMapper        =       NULL;
-       _scalarbarActor         =       NULL;
-       _thresholdActor         =       NULL;
-       _image                          =       NULL;
-       _baseView                       =       NULL;
-       _imageReslicer          =       vtkImageReslice::New();
+       _actorPresent                   =       false;
+       _X                                              =       0;
+       _Y                                              =       0;
+       _Z                                              =       0;
+       _thresholdTable                 =       NULL;
+       _thresholdMapper                =       NULL;
+       _scalarbarActor                 =       NULL;
+       _thresholdActor                 =       NULL;
+       _image                                  =       NULL;
+       _baseView                               =       NULL;
+       _imageReslicer                  =       vtkImageReslice::New();
+       _imageChangeInformation =       vtkImageChangeInformation::New();
 }
 
 //----------------------------------------------------------------------------
@@ -150,7 +151,8 @@ int LayerImageBase::GetZ()  // virtual
 //----------------------------------------------------------------------------
 vtkImageData* LayerImageBase::GetImage()
 {
-       return _image;
+//     return _image;
+       return _imageChangeInformation->GetOutput();
 }
 
 //----------------------------------------------------------------------------
@@ -160,34 +162,132 @@ bool LayerImageBase::GetActorPresent()
 }
 
 
-
 //----------------------------------------------------------------------------
 void LayerImageBase::SetImage(vtkImageData* image)
 {
-       double spc[3];
-       int ext[6];
+       int     ext[6];
+       int     dimensionOriginalLayer[3];
        _image = image;
-       _image->GetSpacing(spc);
        _image->GetWholeExtent(ext);
-       int sx=ext[1]-ext[0]+1;
-       int sy=ext[3]-ext[2]+1;
-       int sz=ext[5]-ext[4]+1;
-       int ssx=(sx/2)*spc[0];
-       int ssy=(sy/2)*spc[1];
-       int ssz=(sz/2)*spc[2];
-       SetX( ssx );
-       SetY( ssy );
-       SetZ( ssz );
+       dimensionOriginalLayer[0] = ext[1]-ext[0]+1;
+       dimensionOriginalLayer[1] = ext[3]-ext[2]+1;
+       dimensionOriginalLayer[2] = ext[5]-ext[4]+1;
+       SetDimensionOriginalLayer(dimensionOriginalLayer);
+       double  spcOriginalLayer[3];
+       _image->GetSpacing(spcOriginalLayer);
+       SetSpcOriginalLayer(spcOriginalLayer);
+       if (GetwxVtkBaseView()!=NULL)
+       {
+               vtkImageData    *imagebase              =       GetwxVtkBaseView()->GetVtkBaseData()->GetImageData();
+               if (imagebase!=NULL) 
+               {       
+                       int dimBase[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;                             
+                       SetDimensionBase(dimBase);
+                       double  spcBase[3];
+                       imagebase->GetSpacing(spcBase);
+                       SetSpcBase(spcBase);
+                       SetX( dimBase[0]*spcBase[0]/2 );
+                       SetY( dimBase[1]*spcBase[1]/2 );
+                       SetZ( dimBase[2]*spcBase[2]/2 );
+               } // if imagebase
+       } // if wxvtkbaseview
        _image->Update();
        _image->GetScalarRange( _range );
        _thresholdTable = vtkLookupTable::New();
+
+       _imageChangeInformation->SetInput(_image);
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::SetSpcOriginalLayer(double spc[3])
+{
+       _spcOriginalLayer[0] = spc[0];
+       _spcOriginalLayer[1] = spc[1];
+       _spcOriginalLayer[2] = spc[2];
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::SetNewSpacingLayer(double spc[3])
+{
+       _newSpcLayer[0]=spc[0];
+       _newSpcLayer[1]=spc[1];
+       _newSpcLayer[2]=spc[2];
+       _imageChangeInformation->SetOutputSpacing( _newSpcLayer );  
+
+}
+
+
+//------------------------------------------------------------------------------
+void LayerImageBase::SetSpcBase(double spc[3])
+{
+       _spcBase[0] = spc[0];
+       _spcBase[1] = spc[1];
+       _spcBase[2] = spc[2];
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::SetDimensionOriginalLayer(int dim[3])
+{
+       _dimOriginalLayer[0] = dim[0];
+       _dimOriginalLayer[1] = dim[1];
+       _dimOriginalLayer[2] = dim[2];
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::SetDimensionBase(int dim[3])
+{
+       _dimBase[0] = dim[0];
+       _dimBase[1] = dim[1];
+       _dimBase[2] = dim[2];
+}
+
+
+
+//------------------------------------------------------------------------------
+void LayerImageBase::GetSpcOriginalLayer(double *spc)
+{
+       spc[0] = _spcOriginalLayer[0];
+       spc[1] = _spcOriginalLayer[1];
+       spc[2] = _spcOriginalLayer[2];
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::GetSpcBase(double *spc)
+{
+       spc[0] = _spcBase[0];
+       spc[1] = _spcBase[1];
+       spc[2] = _spcBase[2];
 }
 
+//------------------------------------------------------------------------------
+void LayerImageBase::GetDimensionOriginalLayer(int *dim)
+{
+       dim[0] = _dimOriginalLayer[0];
+       dim[1] = _dimOriginalLayer[1];
+       dim[2] = _dimOriginalLayer[2];
+}
+
+//------------------------------------------------------------------------------
+void LayerImageBase::GetDimensionBase(int *dim)
+{
+       dim[0] = _dimBase[0];
+       dim[1] = _dimBase[1];
+       dim[2] = _dimBase[2];
+}
+
+
+//------------------------------------------------------------------------------
 void LayerImageBase::SetRangeForColorBar(std::vector<double> &range)
 {
    _rangeForColorBar=range;
 }
 
+
+//------------------------------------------------------------------------------
 void LayerImageBase::GetRangeForColorBar(double &minRange, double &maxRange)
 {
        if (_rangeForColorBar.size()==2)
@@ -240,8 +340,6 @@ vtkLookupTable* LayerImageBase::GetThresholdTable()
 //----------------------------------------------------------------------------
 void LayerImageBase::CleanXYZ(double &x, double &y, double &z)
 {
-       int ext[6];
-       _image->GetWholeExtent(ext);
 
        if (x<0)
        {
@@ -258,6 +356,29 @@ void LayerImageBase::CleanXYZ(double &x, double &y, double &z)
                z=0;
        }
 
+       double maxSize;
+
+       maxSize=_dimOriginalLayer[0]*_newSpcLayer[0];
+       if ( x > maxSize  )
+       {
+               x=maxSize;
+       }
+
+       maxSize=_dimOriginalLayer[1]*_newSpcLayer[1];
+       if ( y > maxSize  )
+       {
+               y = maxSize;
+       }
+
+       maxSize=_dimOriginalLayer[2]*_newSpcLayer[2];
+       if ( z > maxSize  )
+       {
+               z = maxSize;
+       }
+
+       
+/*
+
        if ( x > (ext[1]-ext[0]) )
        {
                z=ext[1]-ext[0];
@@ -272,7 +393,7 @@ void LayerImageBase::CleanXYZ(double &x, double &y, double &z)
        {
                z=ext[5]-ext[4];
        }
-
+*/
 
 }
 
@@ -281,16 +402,25 @@ void LayerImageBase::onThreshold()
 {
        if ((_image!=NULL) && (_baseView!=NULL))
        {
-               double spc[3];
-               GetImage()-> GetSpacing(spc);
+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);
 
-               x = x*spc[0];
-               y = y*spc[1];
-               z = z*spc[2];
 
                vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera();
                int directionViewer=0;
@@ -386,6 +516,10 @@ void LayerImageBase::onThreshold()
 
 //             _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 6de2f5d4a85e1e069e518e261a9d7885b353f7a1..b6ad1e1dfd4e02209616220a6b2871d92489b4d3 100644 (file)
@@ -45,6 +45,8 @@
 #include "vtkScalarBarActor.h"
 
 #include "InteractorStyleMaracas.h"
+#include "vtkImageChangeInformation.h"
+
 
 //----------------------------------------------------------------------------------
 //----------------------------------------------------------------------------------
@@ -106,30 +108,49 @@ class LayerImageBase
                bool GetActorPresent();
                void GetImageScalarRange();
 
+               void SetDimensionOriginalLayer(int dim[3]);
+               void SetDimensionBase(int dim[3]);
+               void SetSpcOriginalLayer(double spc[3]);
+               void SetNewSpacingLayer(double spc[3]);
+               void SetSpcBase(double spc[3]);
+               void GetDimensionOriginalLayer(int *dim);
+               void GetDimensionBase(int *dim);
+               void GetSpcOriginalLayer(double *spc);
+               void GetSpcBase(double *spc);
+
 
   private:
-               int                                             _X;
-               int                                             _Y;
-               int                                             _Z;
-               bool                                    _actorPresent;
-               vtkImageData                    *_image;
-               vtkImageReslice                 *_imageReslicer;
-               vtkLookupTable                  *_thresholdTable;
-               vtkImageMapToColors             *_thresholdMapper;
-               vtkImageActor                   *_thresholdActor;
-               wxVtkBaseView                   *_baseView;
+               int                                                     _X;
+               int                                                     _Y;
+               int                                                     _Z;
+               bool                                            _actorPresent;
+               int                                             _dimOriginalLayer[3];
+               double                                          _spcOriginalLayer[3];
+               double                                          _newSpcLayer[3];
+               int                                             _dimBase[3];
+               double                                          _spcBase[3];
+
+               
+
+               vtkImageData                            *_image;
+               vtkImageChangeInformation       *_imageChangeInformation;
+               vtkImageReslice                         *_imageReslicer;
+               vtkLookupTable                          *_thresholdTable;
+               vtkImageMapToColors                     *_thresholdMapper;
+               vtkImageActor                           *_thresholdActor;
+               wxVtkBaseView                           *_baseView;
 
-               vtkScalarBarActor               *_scalarbarActor;
+               vtkScalarBarActor                       *_scalarbarActor;
 
-               virtual void                    ConfigLookupTable() = 0;                
-               void                                    CleanXYZ(double &x, double &y, double &z);
+               virtual void                            ConfigLookupTable() = 0;                
+               void                                            CleanXYZ(double &x, double &y, double &z);
 
 
   protected:
-               vtkLookupTable                  *GetThresholdTable();
-               vtkImageData                    *GetImage();
-               double                                  _range[2];
-               std::vector<double>     _rangeForColorBar;
+               vtkLookupTable                          *GetThresholdTable();
+               vtkImageData                            *GetImage();
+               double                                          _range[2];
+               std::vector<double>             _rangeForColorBar;
  };
 
 
index 122eccf2f9e551153215930e6f93b248b0e47f34..b6af3ea5366170be78d96c35361e72fbba9e7eca 100644 (file)
@@ -30,8 +30,8 @@
 
 vtkInteractorManualPaint::vtkInteractorManualPaint(ManualPaintControler* mpc) {
        _manualPaintControler = mpc;
-       _state = false;
-       _stateKey = false;
+       _state          = false;
+       _stateKey       = false;
        _stateMouse = false;
 }
 
@@ -71,8 +71,8 @@ bool vtkInteractorManualPaint::OnLeftButtonUp() {
 //---------------------------------------------------------------------------
 bool vtkInteractorManualPaint::OnMouseMove() 
 {
-printf("EED vtkInteractorManualPaint::OnMouseMove \n");
-       if ((_state == true) || (_stateKey == true)) {
+       if ((_state == true) || (_stateKey == true)) 
+       {
                wxVtk2DBaseView *wxvtk2Dbaseview =
                                (wxVtk2DBaseView*) _vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
                wxVTKRenderWindowInteractor *wxVTKiren =
@@ -87,7 +87,6 @@ printf("EED vtkInteractorManualPaint::OnMouseMove \n");
 //        wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z,true, typeView);
                wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z, true);
 
-printf("EED vtkInteractorManualPaint::OnMouseMove A  %d %d %d\n", (int) X, (int) Y, (int) Z);
                _manualPaintControler->PaintImage((int) X, (int) Y, (int) Z);
                this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();