From: Eduardo DAVILA Date: Tue, 1 Mar 2016 11:16:13 +0000 (+0100) Subject: #2864 creaMaracasVisu Feature New Normal - Manual Paint , modifies external image... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=86048e9a60b41a8e2dcc1f7554835d16e74f2b2e;p=creaMaracasVisu.git #2864 creaMaracasVisu Feature New Normal - Manual Paint , modifies external image #2855 creaMaracasVisu Bug New Normal - ColorLayer box spacing size not identified --- diff --git a/bbtk/src/bbcreaMaracasVisuBitmapButtonIcon.cxx b/bbtk/src/bbcreaMaracasVisuBitmapButtonIcon.cxx index b02d67c..840cdfb 100644 --- a/bbtk/src/bbcreaMaracasVisuBitmapButtonIcon.cxx +++ b/bbtk/src/bbcreaMaracasVisuBitmapButtonIcon.cxx @@ -21,11 +21,11 @@ void BitmapButtonIcon::Process() wxBitmap icon4(four_xpm); wxBitmap icon5(five_xpm); - if(index==1){ bbSetOutputIcon( icon1 );} - if(index==2){ bbSetOutputIcon( icon2 );} - if(index==3){ bbSetOutputIcon( icon3 );} - if(index==4){ bbSetOutputIcon( icon4 );} - if(index==5){ bbSetOutputIcon( icon5 );} + if(index==1){ bbSetOutputIcon( icon1 ); } + if(index==2){ bbSetOutputIcon( icon2 ); } + if(index==3){ bbSetOutputIcon( icon3 ); } + if(index==4){ bbSetOutputIcon( icon4 ); } + if(index==5){ bbSetOutputIcon( icon5 ); } } //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx index f29e5e1..ba69264 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx @@ -83,67 +83,49 @@ printf("ManualPaint::Process start\n"); { firsttime=false; - ManualPaintModel *mpModel = new ManualPaintModel(); - mpModel->SetImage( bbGetInputIn() ); + ManualPaintModel *mpModel = new ManualPaintModel(); + mpModel->SetImages( bbGetInputIn() , bbGetInputIn2() ); - wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); -printf("ManualPaint::Process 1\n"); + wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); mpPanel->SetManualPaintModel(mpModel); -printf("ManualPaint::Process 2 %p\n", mpPanel); if (bbGetInputWxVtkBaseView1()!=NULL) { ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); -printf("ManualPaint::Process 3\n"); mpControler->SetManualPaintPanel(mpPanel); -printf("ManualPaint::Process 4\n"); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView1() ); -printf("ManualPaint::Process 5 %p \n",bbGetInputWxVtkBaseView1() ); mpControler->Config(); -printf("ManualPaint::Process 6\n"); } if (bbGetInputWxVtkBaseView2()!=NULL) { -printf("ManualPaint::Process 7\n"); ManualPaintControler *mpControler = new ManualPaintControler(); -printf("ManualPaint::Process 7.1\n"); mpControler->SetManualPaintModel(mpModel); -printf("ManualPaint::Process 7.2\n"); mpControler->SetManualPaintPanel(mpPanel); -printf("ManualPaint::Process 7.3\n"); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView2() ); -printf("ManualPaint::Process 7.4 %p\n", bbGetInputWxVtkBaseView2() ); mpControler->Config(); -printf("ManualPaint::Process 8\n"); } if (bbGetInputWxVtkBaseView3()!=NULL) { -printf("ManualPaint::Process 9\n"); ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView3() ); mpControler->Config(); -printf("ManualPaint::Process 10\n"); } if (bbGetInputWxVtkBaseView4()!=NULL) { -printf("ManualPaint::Process 11\n"); ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView4() ); mpControler->Config(); -printf("ManualPaint::Process 12\n"); } -printf("ManualPaint::Process 13\n"); - } -printf("ManualPaint::Process end\n"); + } // firsttime } //===== diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.h b/bbtk/src/bbcreaMaracasVisuManualPaint.h index b489775..0e66ac2 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint.h +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.h @@ -49,6 +49,7 @@ class bbcreaMaracasVisu_EXPORT ManualPaint // Don't edit this file. This file is generated from xml description.. //===== BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_INPUT(In2,vtkImageData*); BBTK_DECLARE_INPUT(WxVtkBaseView1,wxVtkBaseView*); BBTK_DECLARE_INPUT(WxVtkBaseView2,wxVtkBaseView*); BBTK_DECLARE_INPUT(WxVtkBaseView3,wxVtkBaseView*); @@ -65,15 +66,18 @@ class bbcreaMaracasVisu_EXPORT ManualPaint }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualPaint,bbtk::WxBlackBox); -BBTK_NAME("ManualPaint"); -BBTK_AUTHOR("eduardo davila (Creatis)"); -BBTK_DESCRIPTION("Voxel manual paint"); -BBTK_CATEGORY("widget"); -BBTK_INPUT(ManualPaint,In,"Input image to be modified",vtkImageData*,""); -BBTK_INPUT(ManualPaint,WxVtkBaseView1,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); -BBTK_INPUT(ManualPaint,WxVtkBaseView2,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); -BBTK_INPUT(ManualPaint,WxVtkBaseView3,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); -BBTK_INPUT(ManualPaint,WxVtkBaseView4,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); + BBTK_NAME("ManualPaint"); + BBTK_AUTHOR("eduardo davila (Creatis)"); + BBTK_DESCRIPTION("Voxel manual paint"); + BBTK_CATEGORY("widget"); + + BBTK_INPUT(ManualPaint,In,"Input Image / image result",vtkImageData*,""); + BBTK_INPUT(ManualPaint,In2,"Image result",vtkImageData*,""); + BBTK_INPUT(ManualPaint,WxVtkBaseView1,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); + BBTK_INPUT(ManualPaint,WxVtkBaseView2,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); + BBTK_INPUT(ManualPaint,WxVtkBaseView3,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); + BBTK_INPUT(ManualPaint,WxVtkBaseView4,"creaMaracasVisu viewer 2D",wxVtkBaseView*,""); + BBTK_END_DESCRIBE_BLACK_BOX(ManualPaint); //===== // Don't edit this file. This file is generated from xml description.. diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx index 87c4312..de2b946 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx @@ -33,7 +33,7 @@ void ManualPaint_Model::Process() manualpaintmodel->SetActive( bbGetInputActive() ); manualpaintmodel->SetTool( bbGetInputTool() ); manualpaintmodel->Set2D3D( bbGetInput2D3D() ); - manualpaintmodel->SetImage( bbGetInputImage() ); + manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() ); manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() ); manualpaintmodel->SetDirection( bbGetInputDirection() ); manualpaintmodel->SetBrushSize( bbGetInputBrushSize() ); @@ -67,6 +67,7 @@ void ManualPaint_Model::bbUserSetDefaultValues() bbSetInputTool(1); // Paint bbSetInput2D3D(1); // 3D bbSetInputImage(NULL); + bbSetInputImage2(NULL); bbSetInputGrayLevel(100); bbSetInputDirection(2); // XY bbSetInputBrushSize(3); diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h index ed8279a..e19ab05 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.h @@ -24,6 +24,7 @@ class bbcreaMaracasVisu_EXPORT ManualPaint_Model BBTK_DECLARE_INPUT(Tool,int); BBTK_DECLARE_INPUT(2D3D,int); BBTK_DECLARE_INPUT(Image,vtkImageData*); + BBTK_DECLARE_INPUT(Image2,vtkImageData*); BBTK_DECLARE_INPUT(GrayLevel,double); BBTK_DECLARE_INPUT(Direction,int); BBTK_DECLARE_INPUT(BrushSize,int); @@ -55,7 +56,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualPaint_Model,bbtk::AtomicBlackBox); BBTK_INPUT(ManualPaint_Model,Active,"true (default) , false",bool,""); BBTK_INPUT(ManualPaint_Model,Tool,"0=Brush, 1=Paint(default)",int,""); BBTK_INPUT(ManualPaint_Model,2D3D,"0=2D, 1=3D (default)",int,""); - BBTK_INPUT(ManualPaint_Model,Image,"Image input",vtkImageData*,""); + BBTK_INPUT(ManualPaint_Model,Image,"Image input / image result",vtkImageData*,""); + BBTK_INPUT(ManualPaint_Model,Image2,"Image result",vtkImageData*,""); BBTK_INPUT(ManualPaint_Model,GrayLevel,"Fill gray level (100 default)",double,""); BBTK_INPUT(ManualPaint_Model,Direction,"Used in the 2D mode. 0=YZ , 1=XY , 2=XY(default) ",int,""); BBTK_INPUT(ManualPaint_Model,BrushSize,"default 3",int,""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx index 20a8c38..b478c25 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx @@ -72,6 +72,12 @@ void ColorLayerImageViewManager::SetwxVtkBaseView(int id, wxVtkBaseView *basevie } +wxVtkBaseView* ColorLayerImageViewManager::GetwxVtkBaseView(int id) +{ + return _colorLayerImageViewLst[id]->GetwxVtkBaseView(); +} + + //---------------------------------------------------------------------------- void ColorLayerImageViewManager::SetX2(int x2) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h index b006930..3c2fd26 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h @@ -44,29 +44,30 @@ class ColorLayerImageViewManager public: ColorLayerImageViewManager( ); ~ColorLayerImageViewManager( ); - void SetX2(int x2); - void SetY2(int y2); - void SetZ2(int z2); - virtual int GetX(); - virtual int GetY(); - virtual int GetZ(); - void SetwxVtkBaseView(int id, wxVtkBaseView *baseview); - void SetBaseColors(std::vector & base_color); - double GetBaseColors(unsigned int index); - void SetGreyLevelBoundaries(std::vector & grey_level_boundary); - void SetBaseTransparence(std::vector & base_transparence); - void SetRangeForColorBar(std::vector & range); - double GetGreyLevelBoundaries(unsigned int index); - void SetPlainOrGradientColor(bool color_type); - int GetBaseColorNb(); - void Refresh(); - void onThreshold(); - void onThresholdRemove(); - void onThresholdChange(); - void onThresholdInterpolation( bool interpolation ); - void SetSliceFixDynamic( bool fixdin ); - void onThresholdChangeOpacity( int opacity ); - void SetImage( vtkImageData* img ); + void SetX2(int x2); + void SetY2(int y2); + void SetZ2(int z2); + virtual int GetX(); + virtual int GetY(); + virtual int GetZ(); + void SetwxVtkBaseView(int id, wxVtkBaseView *baseview); + wxVtkBaseView* GetwxVtkBaseView(int id); + void SetBaseColors(std::vector & base_color); + double GetBaseColors(unsigned int index); + void SetGreyLevelBoundaries(std::vector & grey_level_boundary); + void SetBaseTransparence(std::vector & base_transparence); + void SetRangeForColorBar(std::vector & range); + double GetGreyLevelBoundaries(unsigned int index); + void SetPlainOrGradientColor(bool color_type); + int GetBaseColorNb(); + void Refresh(); + void onThreshold(); + void onThresholdRemove(); + void onThresholdChange(); + void onThresholdInterpolation( bool interpolation ); + void SetSliceFixDynamic( bool fixdin ); + void onThresholdChangeOpacity( int opacity ); + void SetImage( vtkImageData* img ); private: std::vector< ColorLayerImageView* > _colorLayerImageViewLst; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index 7763924..371951c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -304,6 +304,15 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _sl_SliceImageZ->SetRange( 0 , dim[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); + + 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]) ) @@ -316,7 +325,7 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) 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,spc,spc,dim,dim,msg,typeOfTransformation,transformOkDlg); + dlg.GetTransformType(this,_spcBase,spc,_dimBase,dim,msg,typeOfTransformation,transformOkDlg); // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value. if (transformOkDlg == false) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h index cb4564f..a263438 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h @@ -88,25 +88,25 @@ class ColorLayerImageViewPanel void SetActive(bool active); private: - bool _active; - int _fitting_mode; - int _dimBase[3]; - double _spcBase[3]; - double _spcOrg[3]; - bool _thresholdGo; + bool _active; + int _fitting_mode; + int _dimBase[3]; + double _spcBase[3]; + double _spcOrg[3]; + bool _thresholdGo; ColorLayerImageViewManager *_colorLayerImageViewManager; - wxButton *_btn_ReadImage; - wxSlider *_opacity; - wxCheckBox *_interpolationCheckBox; - wxCheckBox *_cb_ShowHide; - wxCheckBox *_cb_SliceFixDinamic; - wxSlider *_sl_SliceImageX; - wxSlider *_sl_SliceImageY; - wxSlider *_sl_SliceImageZ; + wxButton *_btn_ReadImage; + wxSlider *_opacity; + wxCheckBox *_interpolationCheckBox; + wxCheckBox *_cb_ShowHide; + wxCheckBox *_cb_SliceFixDinamic; + wxSlider *_sl_SliceImageX; + wxSlider *_sl_SliceImageY; + wxSlider *_sl_SliceImageZ; //Borrame -// mBarRange2 *_barrange2; - Histogram* _histogram; +// mBarRange2 *_barrange2; + Histogram* _histogram; HistogramMinMaxLevel* _histogramMinMaxLevel; void onReadImage(wxCommandEvent& event); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp index ce9bf01..7e5e76e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp @@ -101,6 +101,9 @@ void BrushFilter::FindMinMaxBrush(int &minX, int &maxX, int &minY, int &maxY, //--------------------------------------------------------------------------- void BrushFilter::Run() // virtual { + +printf("EED nBrushFilter::Run _RangeMax %d \n",_RangeMax); + if (_image != NULL) { float value = (float) _graylevel; @@ -111,43 +114,55 @@ void BrushFilter::Run() // virtual FindMinMaxBrush(minX, maxX, minY, maxY, minZ, maxZ, size); double xx, yy, zz, rr = size * size; + float scalarComponent; + bool pixelModify; -printf("EED BrushFilter::Run() %d %d\n", _RangeMin, _RangeMax); - - for (i = minX; i <= maxX; i++) { + for (i = minX; i <= maxX; i++) + { xx = _px - i; xx = xx * xx; - for (j = minY; j <= maxY; j++) { + for (j = minY; j <= maxY; j++) + { yy = _py - j; yy = yy * yy; - for (k = minZ; k <= maxZ; k++) { -// if ((i>=_minX) && (i<=_maxX) && (j>=_minY) && (j<=_maxY) && (k>=_minZ) && (k<=_maxZ)) -// { - - float scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0); + for (k = minZ; k <= maxZ; k++) + { + pixelModify=false; + scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0); if ((_RangeMin <= scalarComponent) - && (scalarComponent <= _RangeMax )) { + && (scalarComponent <= _RangeMax )) + { if (_brushform == 0) { - this->_IMManager->AddModifiedPixel(i, j, k); //DFCH - _image->SetScalarComponentFromFloat(i, j, k, 0,value); + pixelModify=true; +// this->_IMManager->AddModifiedPixel(i, j, k); //DFCH +// _image->SetScalarComponentFromFloat(i, j, k, 0,value); } // _brushform 0 if (_brushform == 1) { zz = _pz - k; zz = zz * zz; if ((xx + yy + zz) <= rr) { - this->_IMManager->AddModifiedPixel(i, j, k); //DFCH - _image->SetScalarComponentFromFloat(i, j, k, 0,value); + pixelModify=true; +// this->_IMManager->AddModifiedPixel(i, j, k); //DFCH +// _image->SetScalarComponentFromFloat(i, j, k, 0,value); } } // _brushform 1 + if (pixelModify==true) + { + this->_IMManager->AddModifiedPixel(i, j, k); //DFCH + if (_image2!=NULL) + { + _image2->SetScalarComponentFromFloat(i, j, k, 0,value); + }else { + _image->SetScalarComponentFromFloat(i, j, k, 0,value); + } + } // if pixelModify } // GetRangeMin && GetRangeMax -// } //if _minX _maxX _minY _maxY _minZ _maxZ - - } //k - } //j - } //i + } //for k + } //for j + } //for i _image->Modified(); } else { printf( @@ -156,37 +171,21 @@ printf("EED BrushFilter::Run() %d %d\n", _RangeMin, _RangeMax); } //--------------------------------------------------------------------------- -void BrushFilter::SetBrushSize(int brushsize) { +void BrushFilter::SetBrushSize(int brushsize) +{ _brushsize = brushsize; } //--------------------------------------------------------------------------- -void BrushFilter::SetBrushForm(int brushform) { +void BrushFilter::SetBrushForm(int brushform) +{ _brushform = brushform; } //--------------------------------------------------------------------------- -void BrushFilter::SetBrushTool(int brushtool) { +void BrushFilter::SetBrushTool(int brushtool) +{ _brushtool = brushtool; } -//--------------------------------------------------------------------------- -void BrushFilter::SetRangeMin(int min) { - _RangeMin = min; -} - -//--------------------------------------------------------------------------- -void BrushFilter::SetRangeMax(int max) { - _RangeMax = max; -} - -//--------------------------------------------------------------------------- -int BrushFilter::GetRangeMin() { - return _RangeMin; -} - -//--------------------------------------------------------------------------- -int BrushFilter::GetRangeMax() { - return _RangeMax; -} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h index d13d868..3e35c34 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.h @@ -36,10 +36,6 @@ public: void SetBrushSize( int brushsize ); void SetBrushForm( int brushform ); void SetBrushTool( int brushtool ); - void SetRangeMin( int min );//DFCH - void SetRangeMax( int max );//DFCH - int GetRangeMin( ); //DFCH - int GetRangeMax( ); //DFCH void FindMinMaxBrush(int &minxX,int &maxX,int &minY,int &maxY,int &minZ,int &maxZ,int &size); virtual void Run(); @@ -48,9 +44,6 @@ private: int _brushsize; int _brushform; int _brushtool; - int _RangeMin; - int _RangeMax; - protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index 197b07e..afdaf48 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -25,15 +25,17 @@ #include "FillFilter.h" -FillFilter::FillFilter() { - _tolerancefill = 50; - _distancefill = 500; +FillFilter::FillFilter() +{ + _tolerancefill = 50; + _distancefill = 500; _limitRecursionFill = 50000; - _auxImageFill = NULL; + _auxImageFill = NULL; } //--------------------------------------------------------------------------- -FillFilter::~FillFilter() { +FillFilter::~FillFilter() +{ if (_auxImageFill != NULL) { _auxImageFill->Delete(); @@ -41,9 +43,9 @@ FillFilter::~FillFilter() { } //--------------------------------------------------------------------------- -void FillFilter::SetImage(vtkImageData *image) // virtual - { - baseFilterManualPaint::SetImage(image); +void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual +{ + baseFilterManualPaint::SetImages(image,image2); if (_auxImageFill != NULL) { _auxImageFill->Delete(); @@ -102,25 +104,36 @@ void FillFilter::Run() // virtual } //--------------------------------------------------------------------------- -void FillFilter::FillToolRecursive(int px, int py, int pz) { +void FillFilter::FillToolRecursive(int px, int py, int pz) +{ _countRecursiveFill++; _countProgressingFill++; - if (_countProgressingFill > 200000) { + if (_countProgressingFill > 200000) + { printf("R %ld \n", _countRecursiveFill); _countProgressingFill = 0; } if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY) - && (pz >= _minZ) && (pz <= _maxZ)) { - if (_usingAuxImageFill == true) { + && (pz >= _minZ) && (pz <= _maxZ)) + { + if (_usingAuxImageFill == true) + { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH _auxImageFill->SetScalarComponentFromFloat(px, py, pz, 0, 0); } _tmpDistfill = (px - _pxfill) * (px - _pxfill) + (py - _pyfill) * (py - _pyfill) + (pz - _pzfill) * (pz - _pzfill); - _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); + _tmpiglfill = _image->GetScalarComponentAsDouble(px, py, pz, 0); + + if (_image2!=NULL) + { + _tmpiglfill2 = _image2->GetScalarComponentAsDouble(px, py, pz, 0); + } else { + _tmpiglfill2 = _tmpiglfill; + } float grayLBFMTOL = _graylevelbasefill - _tolerancefill; float grayLBFPTOL = _graylevelbasefill + _tolerancefill; @@ -144,31 +157,40 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { isInRange = true; } //fi esle - if (isInRange) { + if (isInRange) + { _auxGrayLevelValidationFill = (_tmpiglfill != _graylevel) + && (_tmpiglfill2 != _graylevel) && (_tmpiglfill >= grayLBFMTOL) && (_tmpiglfill <= grayLBFPTOL) && (_tmpDistfill <= _distbasefill); //DFCH - } //fi - else { + } else { _auxGrayLevelValidationFill = false; - } //esle + } // if isInRange + //DFCH /*_auxGrayLevelValidationFill = (_tmpiglfill!=_graylevel) && (_tmpiglfill>=_graylevelbasefill-_tolerancefill) && (_tmpiglfill<=_graylevelbasefill+_tolerancefill) && (_tmpDistfill<=_distbasefill);*/ //DFCH - if (_auxGrayLevelValidationFill == true) { + + if (_auxGrayLevelValidationFill == true) + { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH - _image->SetScalarComponentFromFloat(px, py, pz, 0, - (float) _graylevel); + if (_image2!=NULL) + { + _image2->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); + } else { + _image->SetScalarComponentFromFloat(px, py, pz, 0,(float) _graylevel); + } - if (_countRecursiveFill < _limitRecursionFill) { + if (_countRecursiveFill < _limitRecursionFill) + { if (_2D3D == 0) //2D - { + { if (_direction == 0) // YZ - { + { //FillToolRecursive(px+1,py,pz); //FillToolRecursive(px-1,py,pz); FillToolRecursive(px, py + 1, pz); @@ -208,7 +230,8 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { } // _graylevel if ((_auxGrayLevelValidationFill == true) - && (_countRecursiveFill >= _limitRecursionFill)) { + && (_countRecursiveFill >= _limitRecursionFill)) + { _countRecursiveFillProblem++; if (_2D3D == 0) //2D @@ -259,7 +282,8 @@ void FillFilter::FillToolRecursive(int px, int py, int pz) { } //--------------------------------------------------------------------------- -void FillFilter::SetAuxImageFill(int px, int py, int pz) { +void FillFilter::SetAuxImageFill(int px, int py, int pz) +{ if ((px >= _minX) && (px <= _maxX) && (py >= _minY) && (py <= _maxY) && (pz >= _minZ) && (pz <= _maxZ)) { this->_IMManager->AddModifiedPixel(px, py, pz); //DFCH @@ -268,31 +292,15 @@ void FillFilter::SetAuxImageFill(int px, int py, int pz) { } //--------------------------------------------------------------------------- -void FillFilter::SetToleranceFill(double tolerancefill) { +void FillFilter::SetToleranceFill(double tolerancefill) +{ _tolerancefill = tolerancefill; } //--------------------------------------------------------------------------- -void FillFilter::SetDistanceFill(int distancefill) { +void FillFilter::SetDistanceFill(int distancefill) +{ _distancefill = distancefill; } -//--------------------------------------------------------------------------- -void FillFilter::SetRangeMin(int min) { - _RangeMin = min; -} - -//--------------------------------------------------------------------------- -void FillFilter::SetRangeMax(int max) { - _RangeMax = max; -} - -//--------------------------------------------------------------------------- -int FillFilter::GetRangeMin() { - return (_RangeMin); -} -//--------------------------------------------------------------------------- -int FillFilter::GetRangeMax() { - return (_RangeMax); -} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h index 9bf7796..dc118a8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.h @@ -33,16 +33,12 @@ public: FillFilter(); virtual ~FillFilter(); - void Run(); - void FillToolRecursive(int px,int py, int pz); + void Run(); + void FillToolRecursive(int px,int py, int pz); - void SetToleranceFill(double tolerancefill); - void SetDistanceFill(int distancefill); - void SetRangeMin( int min );//DFCH - void SetRangeMax( int max );//DFCH - int GetRangeMin( ); //DFCH - int GetRangeMax( ); //DFCH - virtual void SetImage(vtkImageData *image); + void SetToleranceFill(double tolerancefill); + void SetDistanceFill(int distancefill); + virtual void SetImages(vtkImageData *image,vtkImageData *image2); private: double _tolerancefill; @@ -55,16 +51,17 @@ private: double _distbasefill; double _tmpDistfill; double _tmpiglfill; + double _tmpiglfill2; long int _countRecursiveFill; long int _countRecursiveFillProblem; vtkImageData *_auxImageFill; - bool _usingAuxImageFill; - bool _auxGrayLevelValidationFill; + bool _usingAuxImageFill; + bool _auxGrayLevelValidationFill; long int _countProgressingFill; long int _limitRecursionFill; - int _RangeMin; - int _RangeMax; - void SetAuxImageFill(int px,int py, int pz); + + + void SetAuxImageFill(int px,int py, int pz); protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index f0de5e2..0b81afa 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -82,12 +82,12 @@ void ManualPaintModel::Set2D3D(int dim2D3D) } //--------------------------------------------------------------------------- -void ManualPaintModel::SetImage(vtkImageData *image) +void ManualPaintModel::SetImages(vtkImageData *image,vtkImageData *image2) { if (image!=NULL) { - _brushfilter->SetImage(image); - _fillfilter->SetImage(image); + _brushfilter -> SetImages(image,image2); + _fillfilter -> SetImages(image,image2); _imageUndoRedo->SetImage(image); } else { printf("EED Warning image=NULL in ManualPaintModel::SetImage(image)\n "); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h index 8ec61e2..1a552e7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h @@ -44,7 +44,7 @@ public: void SetActive(bool active); void SetTool(int tool); void Set2D3D(int dim2D3D); - void SetImage(vtkImageData *image); + void SetImages(vtkImageData *image,vtkImageData *image2); void SetGrayLevel(double graylevel); void SetDirection(int direction); void SetBrushSize(int brushsize); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp index f326ff5..0a9f995 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.cpp @@ -25,25 +25,31 @@ #include "baseFilterManualPaint.h" -baseFilterManualPaint::baseFilterManualPaint() { +baseFilterManualPaint::baseFilterManualPaint() +{ _IMManager = new ImageMManager(); _IMManager->CleanModifiedRegion(); - _graylevel = 0.0; - _2D3D = 1; // 0 2D , 1 true 3D - _direction = 0; // 1 XZ , 0 YZ , 2 XY - _minX = 0; - _minY = 0; - _minZ = 0; - _maxX = 0; - _maxY = 0; - _maxZ = 0; - - _pMinX = 0; - _pMinY = 0; - _pMinZ = 0; - _pMaxX = 0; - _pMaxY = 0; - _pMaxZ = 0; + _graylevel = 0.0; + _2D3D = 1; // 0 2D , 1 true 3D + _direction = 0; // 1 XZ , 0 YZ , 2 XY + _image = NULL; + _image2 = NULL; + _minX = 0; + _minY = 0; + _minZ = 0; + _maxX = 0; + _maxY = 0; + _maxZ = 0; + + _pMinX = 0; + _pMinY = 0; + _pMinZ = 0; + _pMaxX = 0; + _pMaxY = 0; + _pMaxZ = 0; + + _RangeMin = 0; + _RangeMax = 6000; } //--------------------------------------------------------------------------- @@ -79,18 +85,32 @@ void baseFilterManualPaint::SetPoint(int px, int py, int pz) { } //--------------------------------------------------------------------------- -void baseFilterManualPaint::SetImage(vtkImageData *image) { +void baseFilterManualPaint::SetImages(vtkImageData *image, vtkImageData *image2) +{ + _image = image; + _image2 = image2; + int ext[6]; - _image = image; _image->GetWholeExtent(ext); _minX = 0; _minY = 0; _minZ = 0; - _maxX = ext[1] - ext[0]; - _maxY = ext[3] - ext[2]; - _maxZ = ext[5] - ext[4]; + + if (_image2!=NULL) + { + int extB[6]; + _image2->GetWholeExtent(extB); + _maxX = std::min( ext[1]-ext[0] , extB[1]-extB[0] ); + _maxY = std::min( ext[3]-ext[2] , extB[3]-extB[2] ); + _maxZ = std::min( ext[5]-ext[4] , extB[5]-extB[4] ); + } else { + _maxX = ext[1]-ext[0]; + _maxY = ext[3]-ext[2]; + _maxZ = ext[5]-ext[4]; + } // if } + //--------------------------------------------------------------------------- void baseFilterManualPaint::ResetGeneralMinMax() { _pMinX = 10000; @@ -135,10 +155,43 @@ void baseFilterManualPaint::GetScalarRange(double * range) { range = this->_image->GetScalarRange(); } +//--------------------------------------------------------------------------- ImageMManager* baseFilterManualPaint::GetImageMManager() { return (this->_IMManager); } //DFCH + +//--------------------------------------------------------------------------- void baseFilterManualPaint::CleanImageMManager() { this->_IMManager->CleanModifiedRegion(); } //DFCH + + + +//--------------------------------------------------------------------------- +void baseFilterManualPaint::SetRangeMin(int min) +{ + _RangeMin = min; +} + +//--------------------------------------------------------------------------- +void baseFilterManualPaint::SetRangeMax(int max) +{ + _RangeMax = max; +} + +//--------------------------------------------------------------------------- +int baseFilterManualPaint::GetRangeMin() +{ + return _RangeMin; +} + +//--------------------------------------------------------------------------- +int baseFilterManualPaint::GetRangeMax() +{ + return _RangeMax; +} + + + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h index 32319a5..bdb76a4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/baseFilterManualPaint.h @@ -39,15 +39,20 @@ public: baseFilterManualPaint(); virtual ~baseFilterManualPaint(); - virtual void SetImage(vtkImageData *image); + virtual void SetImages(vtkImageData *image,vtkImageData *image2); void SetPoint(int px, int py, int pz); void Set2D3D(int dim2D3D); void SetGrayLevel(double graylevel); void SetDirection(int direction); void ResetGeneralMinMax(); - void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ, - int maxZ); + void SetGeneralMinMax(int minX, int maxX, int minY, int maxY, int minZ, int maxZ); void GetScalarRange(double * range); + + void SetRangeMin( int min );//DFCH + void SetRangeMax( int max );//DFCH + int GetRangeMin( ); //DFCH + int GetRangeMax( ); //DFCH + ImageMManager* GetImageMManager(); //DFCH void CleanImageMManager(); //DFCH virtual void Run(); @@ -55,26 +60,31 @@ public: private: protected: - ImageMManager *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ). - vtkImageData *_image; - int _direction; - int _px; // start point of the brush - int _py; - int _pz; - int _pMinX; // General min max of many brush actions - int _pMinY; - int _pMinZ; - int _pMaxX; - int _pMaxY; - int _pMaxZ; - int _minX; // min max of the image - int _maxX; - int _minY; - int _maxY; - int _minZ; - int _maxZ; - bool _2D3D; - double _graylevel; + ImageMManager *_IMManager; //Saves the last modified region (MinX, MaxX, MinY, MaxY, MinZ, MaxZ). + vtkImageData *_image; + vtkImageData *_image2; + int _direction; + int _px; // start point of the brush + int _py; + int _pz; + int _pMinX; // General min max of many brush actions + int _pMinY; + int _pMinZ; + int _pMaxX; + int _pMaxY; + int _pMaxZ; + int _minX; // min max of the image + int _maxX; + int _minY; + int _maxY; + int _minZ; + int _maxZ; + bool _2D3D; + double _graylevel; + int _RangeMin; + int _RangeMax; + + }; #endif // _BASE_FILTER_MANUAL_PAINT_H_ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp index 4e8a54c..ab311ae 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp @@ -37,7 +37,7 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) //Title sizer->Add( tittleText ); //giving some blank spaces - sizer->Add( new wxStaticText( this, -1, _T(" ") ) ); + sizer->Add( new wxStaticText( this, -1, _T(" key A : Enable/Disable ") ) ); this->ConfigureActiveCBButton( ); this->ConfigureBrushToolRadioButton( ); @@ -61,8 +61,7 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) this->_gConfigSizer = new wxFlexGridSizer( 1 ); //BrushTool Radio Button //giving blank space - this->_gConfigSizer->Add( - new wxStaticText( this, -1, _T(" ") ) ); + this->_gConfigSizer->Add( new wxStaticText( this, -1, _T(" ") ) ); //end of blank space this->_gConfigSizer->Add( _rbBrushTool, 1, wxGROW ); //2D/3D Radio Button