]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
Feature #1606 Add a new entry to ColorLayerImageView to select the fitting mode betwe...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.cxx
index fb4d6abf84c3361f606695f5b527f703dcd301b9..92d9fcbf5b693b598c845454072ac566c49a3954 100644 (file)
@@ -44,12 +44,12 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
        dial->ShowModal();
 
        typeOfTransformation    = -1;
-       dlgWxOK                                 = false;
+       dlgWxOK                 = false;
 
        if (dial->GetReturnCode() == wxID_OK)
        {
-               typeOfTransformation    = radioOpts->GetSelection();
-               dlgWxOK                         = true;
+               typeOfTransformation    = radioOpts->GetSelection() + 1;
+               dlgWxOK                 = true;
        }
 }
 
@@ -129,6 +129,10 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        this->SetSizer( sizer );
        this->SetAutoLayout( true );
        this->Layout();
+     
+       //CM Sets the default fitting mode to Pixel mode.
+       _fitting_mode = 3;
+       // EO CM
 }
 
 //----------------------------------------------------------------------------
@@ -200,16 +204,26 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
              (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
             )
         {
-
-            bool transformOkDlg;
-            int typeOfTransformation;
-            wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
-            wxDlgTransformByDimensionBySpacingByPixel dlg;
-            dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg);
-
-    printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
-
-            if (typeOfTransformation==0)  // make dimensions equals
+         // CM
+         int typeOfTransformation;     
+         // In case of the option is set to create a dialog box.
+         if (_fitting_mode == -1)
+           {
+             bool transformOkDlg;
+             wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
+             wxDlgTransformByDimensionBySpacingByPixel dlg;
+             dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg);
+             // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
+             if (transformOkDlg == false)
+               typeOfTransformation = 3;
+           }
+         else
+           typeOfTransformation = _fitting_mode;
+         //EO CM
+
+         printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
+
+            if (typeOfTransformation==1)  // make dimensions equals
             {
                 printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
                 spc[0]=_spcBase[0]*_dimBase[0]/dim[0];
@@ -217,14 +231,14 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
                 spc[2] = 1;
             }
 
-            if (typeOfTransformation==1)  // make spacing equals
+            if (typeOfTransformation==2)  // make spacing equals
             {
                 spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0];
                 spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1];
                 spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2];
             }
 
-            if (typeOfTransformation==2)  // make spacing = 1
+            if (typeOfTransformation==3)  // make spacing = 1
             {
                 spc[0] = 1;
                 spc[1] = 1;
@@ -244,6 +258,26 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
     }
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::SetFittingMode(int fitting_mode)
+{
+  // CM Sets the fitting mode if an appropriate value is provided.
+  if (fitting_mode == -1 || fitting_mode == 1 || fitting_mode == 2 || fitting_mode == 3)
+    {
+      _fitting_mode = fitting_mode;
+    }
+  //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept).
+  else if (fitting_mode != 0)
+    std::cout << "CM ERROR!!! The fitting mode provided has an inappropriate value. It should be an int between -1 ; 1 ; 2 ; 3, but its value is :" << fitting_mode << ". The default value will be set instead, i.e. Pixel transformation (3)." <<  std::endl;
+  //EO CM
+}
+
+//----------------------------------------------------------------------------
+int ColorLayerImageViewPanel::GetFittingMode()
+{
+  return _fitting_mode;
+}
+
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 {