]> Creatis software - creaMaracasVisu.git/commitdiff
Feature #1606 Add a new entry to ColorLayerImageView to select the fitting mode betwe...
authorClaire Mouton <Claire.Mouton@creatis.insa-lyon.fr>
Fri, 14 Sep 2012 12:12:57 +0000 (12:12 +0000)
committerClaire Mouton <Claire.Mouton@creatis.insa-lyon.fr>
Fri, 14 Sep 2012 12:12:57 +0000 (12:12 +0000)
bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx
bbtk/src/bbcreaMaracasVisuColorLayerImageView.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h

index 87241b839579c504ae93c37c91221d6a0b87a0a4..e7e051a7d8d6aa4d7751a82ba575f5a880c4100c 100644 (file)
@@ -26,6 +26,7 @@ void ColorLayerImageView::Process()
     clivp->GetColorLayerImageView()->SetGreyLevelBoundaries( grey_level_boundaries );
  
     clivp->GetColorLayerImageView()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() );
+    clivp->SetFittingMode( bbGetInputFittingMode() );
 
     clivp->SetImage( bbGetInputIn() );
 
index 580684c41b07585085b4ee02414972e0e60e73e7..b6d5f29fff8a5f0d9f5b896fb8d5531208278f55 100644 (file)
@@ -25,6 +25,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView
   BBTK_DECLARE_INPUT(lstBaseColor,std::vector<double>);
   BBTK_DECLARE_INPUT(lstGreyLevelBoundaries,std::vector<double>);
   BBTK_DECLARE_INPUT(PlainOrGradientColor,bool);
+  BBTK_DECLARE_INPUT(FittingMode,int);
   BBTK_PROCESS(Process);
   void Process();
   BBTK_CREATE_WIDGET(CreateWidget);
@@ -45,6 +46,7 @@ BBTK_INPUT(ColorLayerImageView,In,"Input Image",vtkImageData*,"");
 BBTK_INPUT(ColorLayerImageView,lstBaseColor,"List of Base Colors in RGB format to define the color map. Requirement: must be of a size being a multiple of 3, with values between 0 and 1. For example, for 2 colors: \"1 0 0 0 0 1\". If not provided as required, the histogram is equally split into three areas, blue, yellow and red.",std::vector<double>,"");
 BBTK_INPUT(ColorLayerImageView,lstGreyLevelBoundaries,"List of the Grey Level Boundaries to define the color map. Requirement: Must have one more element than the number of colours. For example, for 2 colors: \"50 150 250\". If not provided as required, the histogram is equally split into areas, which number corresponds to the number of colors provided (3 by default).",std::vector<double>,"");
 BBTK_INPUT(ColorLayerImageView,PlainOrGradientColor,"Choose between Plain (true) or Gradient (false) colors. Default is 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_END_DESCRIBE_BLACK_BOX(ColorLayerImageView);
 //=====
 // Don't edit this file. This file is generated from xml description..
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)
 {
index 526cb1d66b6218054702ed3bd0ff9d6b56ed71c3..4b8bd82627e401f5facf0cf285ad4d51c4ea6df6 100644 (file)
@@ -47,8 +47,12 @@ class ColorLayerImageViewPanel
                        void SetBaseDimension(int dim[3]);
                        void SetOriginalSpacing(double spc[3]);
                        void SetImage(vtkImageData *img);
+                       void SetFittingMode(int fitting_mode);
+                       int GetFittingMode();
 
                private:
+                       int                             _fitting_mode;
+
                        int                             _dimBase[3];
                        double                          _spcBase[3];
                        double                          _spcOrg[3];