From f050938d3947f6b785289da6d58f8fec2da57421 Mon Sep 17 00:00:00 2001 From: Claire Mouton Date: Fri, 14 Sep 2012 12:12:57 +0000 Subject: [PATCH] Feature #1606 Add a new entry to ColorLayerImageView to select the fitting mode between the two overlaid images. --- .../bbcreaMaracasVisuColorLayerImageView.cxx | 1 + .../bbcreaMaracasVisuColorLayerImageView.h | 2 + .../ColorLayerImageViewPanel.cxx | 64 ++++++++++++++----- .../ColorLayerImageViewPanel.h | 4 ++ 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index 87241b8..e7e051a 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -26,6 +26,7 @@ void ColorLayerImageView::Process() clivp->GetColorLayerImageView()->SetGreyLevelBoundaries( grey_level_boundaries ); clivp->GetColorLayerImageView()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() ); + clivp->SetFittingMode( bbGetInputFittingMode() ); clivp->SetImage( bbGetInputIn() ); diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h index 580684c..b6d5f29 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h @@ -25,6 +25,7 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView BBTK_DECLARE_INPUT(lstBaseColor,std::vector); BBTK_DECLARE_INPUT(lstGreyLevelBoundaries,std::vector); 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,""); 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,""); 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.. diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index fb4d6ab..92d9fcb 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -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) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h index 526cb1d..4b8bd82 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h @@ -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]; -- 2.45.1