From 9d8709b5e9d72b9f0034224bb4c00281264fb28d Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 21 Mar 2014 15:23:14 +0100 Subject: [PATCH] 2343 creaMaracasVisu Bug New Normal Interaction between ColorLayer and manualPaint --- bbtk/bbs/boxes/UnitLayerPaint.bbg | 241 ++++++++++++++++++ bbtk/bbs/boxes/UnitLayerPaint.bbs | 98 +++++++ .../bbcreaMaracasVisuColorLayerImageView.cxx | 4 + bbtk/src/bbcreaMaracasVisuManualPaint.cxx | 24 ++ .../ColorLayerImageView.cxx | 8 +- .../ThresholdImageView/LayerImageBase.cxx | 35 ++- .../ThresholdImageView/LayerImageBase.h | 8 +- .../widgets/manualPaint/BrushFilter.cpp | 32 +-- .../widgets/manualPaint/ManualPaintModel.cpp | 38 ++- .../widgets/manualPaint/ManualPaintModel.h | 2 + .../widgets/manualPaint/ManualPaintPanel.cpp | 12 + .../widgets/manualPaint/ManualPaintPanel.h | 1 + .../manualPaint/vtkInteractorManualPaint.cpp | 9 +- .../manualPaint/wxManualPaintPanel.cpp | 64 +++-- .../widgets/manualPaint/wxManualPaintPanel.h | 41 +-- .../widgets/vtkInteractorStyleBaseView.cxx | 8 +- 16 files changed, 547 insertions(+), 78 deletions(-) create mode 100644 bbtk/bbs/boxes/UnitLayerPaint.bbg create mode 100644 bbtk/bbs/boxes/UnitLayerPaint.bbs diff --git a/bbtk/bbs/boxes/UnitLayerPaint.bbg b/bbtk/bbs/boxes/UnitLayerPaint.bbg new file mode 100644 index 0000000..45b0ea3 --- /dev/null +++ b/bbtk/bbs/boxes/UnitLayerPaint.bbg @@ -0,0 +1,241 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBG BlackBox Diagram file +# - /home/davila/Creatis/All/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/UnitLayerPaint.bbg +# ---------------------------------- + +APP_START +CATEGORY: +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:TRUE +COMPLEXBOXNAME:UnitLayerPaint +PACKAGENAME:creaMaracasVisu +COMPLEXOUTPUTS:1 +COMPLEX_PORT +OutWidget +105.768851:-158.547510:-900.000000 +FIN_COMPLEX_PORT +COMPLEXINPUTS:5 +COMPLEX_PORT +InputImage +-86.663553:91.493751:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +wxVtkBaseView_01 +-16.800689:91.353745:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +wxVtkBaseView_02 +59.831313:91.913768:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +wxVtkBaseView_03 +105.100769:84.227173:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +TitleModule +124.916277:84.893462:-900.000000 +FIN_COMPLEX_PORT +BOXES:16 +BOX +creaMaracasVisu:ViewerNV:Box09 +ISEXEC:FALSE +33.629033:-1.576918:-900.000000 +94.269033:-11.576918:-900.000000 +PORT +nTypeView:"0" +FIN_BOX +BOX +creaMaracasVisu:ManualPaint:Box11 +ISEXEC:FALSE +-22.062493:7.255105:-900.000000 +23.512507:-2.744895:-900.000000 +PORT +WinTitle:"Paint" +FIN_BOX +BOX +wx:LayoutLine:Box13 +ISEXEC:FALSE +-92.239645:-52.736806:-900.000000 +-34.679645:-62.736806:-900.000000 +PORT +Orientation:"H" +FIN_BOX +BOX +wx:LayoutTab:Box15 +ISEXEC:FALSE +-115.371591:-25.436420:-900.000000 +-57.811591:-35.436420:-900.000000 +FIN_BOX +BOX +wx:LayoutTab:Box16 +ISEXEC:FALSE +-30.536965:-32.299285:-900.000000 +27.023035:-42.299285:-900.000000 +FIN_BOX +BOX +wx:LayoutLine:Box17 +ISEXEC:FALSE +-115.258808:-7.150446:-900.000000 +-57.698808:-17.150446:-900.000000 +PORT +WinTitle:"Color" +FIN_BOX +BOX +wx:LayoutLine:Box18 +ISEXEC:FALSE +-34.328234:-13.564862:-900.000000 +23.231766:-23.564862:-900.000000 +PORT +WinTitle:"Paint" +FIN_BOX +BOX +wx:LayoutSplit:Box19 +ISEXEC:FALSE +69.201144:-118.185923:-900.000000 +114.776144:-128.185923:-900.000000 +PORT +Proportion:"30" +FIN_BOX +BOX +toolsbbtk:SaveMHD-Button:Box20 +ISEXEC:FALSE +49.474783:-54.794924:-900.000000 +95.049783:-64.794924:-900.000000 +FIN_BOX +BOX +creaMaracasVisu:ColorLayerImageView:Box21 +ISEXEC:FALSE +-121.366653:10.167202:-900.000000 +-50.191653:0.167202:-900.000000 +PORT +WinTitle:"Color" +PORT +lstBaseColor:"1 0 0 1 1 0 0 0 1" +PORT +lstGreyLevelBoundaries:"500 1500 2500 5000" +FIN_BOX +BOX +vtk:vtkImageDataPointerRelay:Box23 +ISEXEC:FALSE +-95.762984:51.256292:-900.000000 +-24.587984:41.256292:-900.000000 +FIN_BOX +BOX +wx:LayoutTab:Box24 +ISEXEC:FALSE +-4.772832:-89.823842:-900.000000 +52.787168:-99.823842:-900.000000 +PORT +WinWidth:"0" +FIN_BOX +BOX +toolsbbtk:ImageVtkPropertiesWidget:Box25 +ISEXEC:FALSE +-28.977992:-53.163115:-900.000000 +42.197008:-63.163115:-900.000000 +FIN_BOX +BOX +std:MagicBox:Box26 +ISEXEC:FALSE +-14.647540:63.299675:-900.000000 +30.927460:53.299675:-900.000000 +FIN_BOX +BOX +std:MagicBox:Box27 +ISEXEC:FALSE +44.893581:65.273236:-900.000000 +90.468581:55.273236:-900.000000 +FIN_BOX +BOX +std:MagicBox:Box28 +ISEXEC:FALSE +99.534930:66.249067:-900.000000 +145.109930:56.249067:-900.000000 +FIN_BOX +CONNECTIONS:28 +CONNECTION +Box15:Widget:Box13:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box16:Widget:Box13:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box17:Widget:Box15:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box11:Widget:Box18:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box18:Widget:Box16:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box21:Widget:Box17:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box21:In +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box20:In +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box11:In +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box09:In +NumberOfControlPoints:0 +CONNECTION +InputImage:InputImage:Box23:In +NumberOfControlPoints:0 +CONNECTION +Box13:Widget:Box24:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box25:in +NumberOfControlPoints:0 +CONNECTION +wxVtkBaseView_01:wxVtkBaseView_01:Box26:In +NumberOfControlPoints:0 +CONNECTION +Box26:Out:Box21:WxVtkBaseView +NumberOfControlPoints:0 +CONNECTION +wxVtkBaseView_02:wxVtkBaseView_02:Box27:In +NumberOfControlPoints:0 +CONNECTION +wxVtkBaseView_03:wxVtkBaseView_03:Box28:In +NumberOfControlPoints:0 +CONNECTION +Box19:Widget:OutWidget:OutWidget +NumberOfControlPoints:0 +CONNECTION +Box26:Out:Box11:WxVtkBaseView1 +NumberOfControlPoints:0 +CONNECTION +Box27:Out:Box21:WxVtkBaseView1 +NumberOfControlPoints:0 +CONNECTION +Box27:Out:Box11:WxVtkBaseView2 +NumberOfControlPoints:0 +CONNECTION +Box28:Out:Box21:WxVtkBaseView2 +NumberOfControlPoints:0 +CONNECTION +Box28:Out:Box11:WxVtkBaseView3 +NumberOfControlPoints:0 +CONNECTION +TitleModule:TitleModule:Box19:WinTitle +NumberOfControlPoints:0 +CONNECTION +Box20:Widget:Box24:Widget3 +NumberOfControlPoints:0 +CONNECTION +Box25:widget:Box24:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box24:Widget:Box19:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box09:Widget:Box19:Widget1 +NumberOfControlPoints:0 +APP_END diff --git a/bbtk/bbs/boxes/UnitLayerPaint.bbs b/bbtk/bbs/boxes/UnitLayerPaint.bbs new file mode 100644 index 0000000..78fedf9 --- /dev/null +++ b/bbtk/bbs/boxes/UnitLayerPaint.bbs @@ -0,0 +1,98 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) +# - /home/davila/Creatis/All/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/UnitLayerPaint.bbs +# ---------------------------------- + +include std +include itkvtk +include creaMaracasVisu +include wx +include toolsbbtk +include vtk +include std + +define UnitLayerPaint creaMaracasVisu + +author "Author ??" +description "Description ??" + +category "" + +new ViewerNV Box09 + set Box09.nTypeView "0" + +new ManualPaint Box11 + set Box11.WinTitle "Paint" + +new LayoutLine Box13 + set Box13.Orientation "H" + +new LayoutTab Box15 + +new LayoutTab Box16 + +new LayoutLine Box17 + set Box17.WinTitle "Color" + +new LayoutLine Box18 + set Box18.WinTitle "Paint" + +new LayoutSplit Box19 + set Box19.Proportion "30" + +new SaveMHD-Button Box20 + +new ColorLayerImageView Box21 + set Box21.WinTitle "Color" + set Box21.lstBaseColor "1 0 0 1 1 0 0 0 1" + set Box21.lstGreyLevelBoundaries "500 1500 2500 5000" + +new vtkImageDataPointerRelay Box23 + +new LayoutTab Box24 + set Box24.WinWidth "0" + +new ImageVtkPropertiesWidget Box25 + +new MagicBox Box26 + +new MagicBox Box27 + +new MagicBox Box28 + + +connect Box15.Widget Box13.Widget1 +connect Box16.Widget Box13.Widget2 +connect Box17.Widget Box15.Widget1 +connect Box11.Widget Box18.Widget1 +connect Box18.Widget Box16.Widget1 +connect Box21.Widget Box17.Widget1 +connect Box23.Out Box21.In +connect Box23.Out Box20.In +connect Box23.Out Box11.In +connect Box23.Out Box09.In +connect Box13.Widget Box24.Widget1 +connect Box23.Out Box25.in +connect Box26.Out Box21.WxVtkBaseView +connect Box26.Out Box11.WxVtkBaseView1 +connect Box27.Out Box21.WxVtkBaseView1 +connect Box27.Out Box11.WxVtkBaseView2 +connect Box28.Out Box21.WxVtkBaseView2 +connect Box28.Out Box11.WxVtkBaseView3 +connect Box20.Widget Box24.Widget3 +connect Box25.widget Box24.Widget2 +connect Box24.Widget Box19.Widget2 +connect Box09.Widget Box19.Widget1 + +# Complex input ports +input InputImage Box23.In " " +input wxVtkBaseView_01 Box26.In " " +input wxVtkBaseView_02 Box27.In " " +input wxVtkBaseView_03 Box28.In " " +input TitleModule Box19.WinTitle " " + +# Complex output ports +output OutWidget Box19.Widget " " + + +endefine diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index 66a99f7..95b0409 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -41,6 +41,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ColorLayerImageView,bbtk::WxBlackBox); //===== void ColorLayerImageView::Process() { +printf("ColorLayerImageView::Process start\n"); + ColorLayerImageViewPanel *clivp = (ColorLayerImageViewPanel*)bbGetOutputWidget(); clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() ); @@ -67,6 +69,8 @@ void ColorLayerImageView::Process() // } // ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) ); +printf("ColorLayerImageView::Process end\n"); + } //===== // Don't edit this file. This file is generated from xml description.. diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx index 0fb6ed4..f29e5e1 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx @@ -52,6 +52,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint,bbtk::WxBlackBox); //===== void ManualPaint::Process() { +printf("ManualPaint::Process start\n"); + /* std::string msg; @@ -85,45 +87,63 @@ void ManualPaint::Process() mpModel->SetImage( bbGetInputIn() ); wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); +printf("ManualPaint::Process 1\n"); 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"); } //===== @@ -141,6 +161,10 @@ void ManualPaint::bbUserSetDefaultValues() { firsttime=true; bbSetInputIn(NULL); + bbSetInputWxVtkBaseView1(NULL); + bbSetInputWxVtkBaseView2(NULL); + bbSetInputWxVtkBaseView3(NULL); + bbSetInputWxVtkBaseView4(NULL); } //===== // Don't edit this file. This file is generated from xml description.. diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx index 28c473d..7685135 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx @@ -265,7 +265,13 @@ void ColorLayerImageView::ConfigLookupTable() // virtual { // CM // Grey level extrema retrieved from the image grey level extrema. - GetImage()->GetScalarRange(_range); + + +printf("ERROR: EED ColorLayerImageView::ConfigLookupTable ------_range----------------\n"); + _range[0]=0; + _range[1]=4000; +// GetImage()->GetScalarRange(_range); + // ------------------ Setting Default Values diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index f8c6693..a90e734 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -41,8 +41,9 @@ ColorLayerImageBasevtkInteractor::ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase) { _state=false; + _stateKey=false; _layerImageBase=layerImageBase; - + } //--------------------------------------------------------------------------------------------- @@ -50,15 +51,39 @@ ColorLayerImageBasevtkInteractor::~ColorLayerImageBasevtkInteractor() { } +//--------------------------------------------------------------------------------------------- +bool ColorLayerImageBasevtkInteractor::OnChar() +{ + return true; +} + //--------------------------------------------------------------------------------------------- bool ColorLayerImageBasevtkInteractor::OnMouseMove() // vitual { - printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove \n"); + printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove start \n"); + + vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor(); + + // For example in ManualPaint Action + // This is not working, because the order of insertion events mecanism (_vtkInteractorStyleBaseView) + // Layer first Paint after. + // the only way to make it works is to take the axes an paint. this force a first SetParent_refresh_waiting() +// if ( this->_vtkInteractorStyleBaseView->GetParent_refresh_waiting() == true ) + + if ( interactor->GetControlKey()==1 ) // EED This if for ManaulPaint Interaction compatibility + { + printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove need Refresh \n" ); + _layerImageBase->onThreshold(); + _layerImageBase->GetvtkImageReslice()->Modified(); + } + else { + printf("EED ColorLayerImageBasevtkInteractor::OnMouseMove NOT need Refresh \n" ); + } + if (_state==true) { - wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*) _vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); wxVTKRenderWindowInteractor *wxVTKiren = wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor(); int px, py; @@ -79,7 +104,6 @@ bool ColorLayerImageBasevtkInteractor::OnMouseMove() // vitual _layerImageBase->onThreshold(); // _layerImageBase->Refresh(); - this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); if (_vtkInteractorStyleBaseView->GetRefresh_waiting()==true) @@ -91,7 +115,7 @@ bool ColorLayerImageBasevtkInteractor::OnMouseMove() // vitual return true; } - +//--------------------------------------------------------------------------------------------- bool ColorLayerImageBasevtkInteractor::OnRightButtonDown() // virtual { printf("EED ColorLayerImageBasevtkInteractor::OnRightButtonDown \n"); @@ -99,6 +123,7 @@ bool ColorLayerImageBasevtkInteractor::OnRightButtonDown() // virtual return true; } +//--------------------------------------------------------------------------------------------- bool ColorLayerImageBasevtkInteractor::OnRightButtonUp() // virtual { printf("EED ColorLayerImageBasevtkInteractor::OnRightButtonUp \n"); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h index 1781373..d118348 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h @@ -55,12 +55,14 @@ public: ColorLayerImageBasevtkInteractor(LayerImageBase* layerImageBase); virtual ~ColorLayerImageBasevtkInteractor(); - virtual bool OnMouseMove(); - virtual bool OnRightButtonDown(); - virtual bool OnRightButtonUp(); + virtual bool OnChar(); + virtual bool OnMouseMove(); + virtual bool OnRightButtonDown(); + virtual bool OnRightButtonUp(); private: bool _state; + bool _stateKey; LayerImageBase* _layerImageBase; protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp index 8b53b3b..964e0e6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/BrushFilter.cpp @@ -112,6 +112,8 @@ void BrushFilter::Run() // virtual double xx, yy, zz, rr = size * size; +printf("EED BrushFilter::Run() %d %d\n", _RangeMin, _RangeMax); + for (i = minX; i <= maxX; i++) { xx = _px - i; xx = xx * xx; @@ -122,23 +124,23 @@ void BrushFilter::Run() // virtual // if ((i>=_minX) && (i<=_maxX) && (j>=_minY) && (j<=_maxY) && (k>=_minZ) && (k<=_maxZ)) // { - float scalarComponent = _image->GetScalarComponentAsFloat(i, - j, k, 0); - if ((this->GetRangeMin() <= scalarComponent) - && (scalarComponent <= this->GetRangeMax())) { - zz = _pz - k; - zz = zz * zz; - if (_brushform == 0) { + float scalarComponent = _image->GetScalarComponentAsFloat(i,j, k, 0); + if ((_RangeMin <= scalarComponent) + && (scalarComponent <= _RangeMax )) { + if (_brushform == 0) + { this->_IMManager->AddModifiedPixel(i, j, k); //DFCH - _image->SetScalarComponentFromFloat(i, j, k, 0, - value); - } else if (_brushform == 1) { + _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); + _image->SetScalarComponentFromFloat(i, j, k, 0,value); } - } // _brushform + } // _brushform 1 } // GetRangeMin && GetRangeMax // } //if _minX _maxX _minY _maxY _minZ _maxZ @@ -180,11 +182,11 @@ void BrushFilter::SetRangeMax(int max) { //--------------------------------------------------------------------------- int BrushFilter::GetRangeMin() { - return (_RangeMin); + return _RangeMin; } //--------------------------------------------------------------------------- int BrushFilter::GetRangeMax() { - return (_RangeMax); + return _RangeMax; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index 956fe6a..ac69465 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -26,28 +26,46 @@ #include "ManualPaintModel.h" ManualPaintModel::ManualPaintModel() { - _tool = 0; // 0 pencil , 1 fill - _brushfilter = new BrushFilter(); - _fillfilter = new FillFilter(); - _imageUndoRedo = new ImageUndoRedo(); + _active = true; + _tool = 0; // 0 pencil , 1 fill + _brushfilter = new BrushFilter(); + _fillfilter = new FillFilter(); + _imageUndoRedo = new ImageUndoRedo(); } //--------------------------------------------------------------------------- -ManualPaintModel::~ManualPaintModel() { +ManualPaintModel::~ManualPaintModel() +{ delete _brushfilter; delete _fillfilter; } + +//--------------------------------------------------------------------------- +void ManualPaintModel::SetActive( bool active ) +{ + _active = active; +} + //--------------------------------------------------------------------------- -void ManualPaintModel::PaintImage(int px, int py, int pz) { - if (_tool == 0) { +void ManualPaintModel::PaintImage(int px, int py, int pz) +{ +printf("EED ManualPaintModel::PaintImage\n"); + if (_active==true) + { + + if (_tool == 0) + { _brushfilter->SetPoint(px, py, pz); _brushfilter->Run(); - } - if (_tool == 1) { + } // _tool 2 + + if (_tool == 1) + { _fillfilter->SetPoint(px, py, pz); _fillfilter->Run(); - } + } // _tool 1 + } // _active } //--------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h index 8379103..8ec61e2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h @@ -41,6 +41,7 @@ public: ManualPaintModel(); virtual ~ManualPaintModel(); + void SetActive(bool active); void SetTool(int tool); void Set2D3D(int dim2D3D); void SetImage(vtkImageData *image); @@ -60,6 +61,7 @@ public: private: int _tool; + bool _active; BrushFilter *_brushfilter; FillFilter *_fillfilter; ImageUndoRedo *_imageUndoRedo; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp index dc1cf3e..d2fb292 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp @@ -144,6 +144,7 @@ void ManualPaintPanel::SetDistanceFill(int distancefill) } } +//--------------------------------------------------------------------------- void ManualPaintPanel::GetScalarRange( double * range ) { if (_manualPaintModel!=NULL) @@ -154,3 +155,14 @@ void ManualPaintPanel::GetScalarRange( double * range ) } } +//--------------------------------------------------------------------------- +void ManualPaintPanel::SetActive( bool active ) +{ + if (_manualPaintModel!=NULL) + { + _manualPaintModel->SetActive( active ); + } else { + printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); + } +} + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h index 0a1b8cc..e756fd3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h @@ -33,6 +33,7 @@ public: ManualPaintPanel(); virtual ~ManualPaintPanel(); + void SetActive( bool active ); void SetManualPaintModel(ManualPaintModel* manualPaintModel); void SetBrushSize( int brushsize ); void SetGrayLevel( double graylevel ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp index 5e67cd9..122eccf 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp @@ -41,9 +41,7 @@ vtkInteractorManualPaint::~vtkInteractorManualPaint() { //--------------------------------------------------------------------------- bool vtkInteractorManualPaint::OnChar() { - vtkRenderWindowInteractor *interactor = - _vtkInteractorStyleBaseView->GetInteractor(); - + vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor(); if (interactor->GetKeyCode() == 97) { _stateKey = !_stateKey; } @@ -71,7 +69,9 @@ bool vtkInteractorManualPaint::OnLeftButtonUp() { } //--------------------------------------------------------------------------- -bool vtkInteractorManualPaint::OnMouseMove() { +bool vtkInteractorManualPaint::OnMouseMove() +{ +printf("EED vtkInteractorManualPaint::OnMouseMove \n"); if ((_state == true) || (_stateKey == true)) { wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*) _vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); @@ -87,6 +87,7 @@ bool vtkInteractorManualPaint::OnMouseMove() { // 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(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp index 2a0e6d3..4e8a54c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp @@ -39,6 +39,7 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) //giving some blank spaces sizer->Add( new wxStaticText( this, -1, _T(" ") ) ); + this->ConfigureActiveCBButton( ); this->ConfigureBrushToolRadioButton( ); this->Configure2D3DRadioButton( ); this->ConfigureBrushFormRadioButton( ); @@ -52,7 +53,6 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) //Buttons wxStaticText *editButtonsText = new wxStaticText( this, -1, _T("Edit Buttons") ); - sizer->Add( editButtonsText ); this->_buttonsSizer = new wxFlexGridSizer( 4 ); this->_buttonsSizer->Add( _btnUndo, 1, wxGROW ); this->_buttonsSizer->Add( _btnRedo, 1, wxGROW ); @@ -116,6 +116,8 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) wxALIGN_BOTTOM | wxALIGN_LEFT | wxALL, 5 ); this->_FillSizer->Add( sizerDistance ); + sizer->Add( _activeCB ); + sizer->Add( editButtonsText ); sizer->Add( _buttonsSizer ); sizer->Add( _gConfigSizer ); sizer->Add( _brushSizer ); @@ -136,8 +138,16 @@ wxManualPaintPanel::~wxManualPaintPanel( ) } //-------------------------------------------------------------------------- +void wxManualPaintPanel::ConfigureActiveCBButton( ) +{ + _activeCB = new wxCheckBox (this, -1, _T("Active") ); + _activeCB->SetValue(true); + SetActive( _activeCB->GetValue() ); +} + //Panel Config +//-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureBrushToolRadioButton( ) { wxString lstBrushForm[ 2 ]; @@ -147,6 +157,7 @@ void wxManualPaintPanel::ConfigureBrushToolRadioButton( ) wxDefaultPosition, wxSize( 270, 45 ), 2, lstBrushForm, 2, wxRA_SPECIFY_COLS ); } + //-------------------------------------------------------------------------- void wxManualPaintPanel::Configure2D3DRadioButton( ) { @@ -191,29 +202,33 @@ void wxManualPaintPanel::ConfigureRangeBar( ) _mBarSlices->SetStart( min ); _mBarSlices->SetEnd( max ); _mBarSlices->Update( ); + + SetRangeMin( min ); + SetRangeMax( max ); + //DFCH -- End BarSlices } //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureGrayLevelSld( ) { _txtGrayLevel = new wxStaticText( this, -1, - wxString( _T(" Gray Level ") ) ); + wxString( _T(" Gray Level ") ) ); _sldGrayLevel = new wxSlider( this, -1, 0, 0, 255, wxDefaultPosition, - wxDefaultSize, wxSL_LABELS ); + wxDefaultSize, wxSL_LABELS ); _sldGrayLevel->SetMinSize( wxSize( 200, -1 ) ); _sldGrayLevel->SetMaxSize( wxSize( 200, -1 ) ); _graylevelCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); } //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureBrushSizeSld( ) { _txtBrushSize = new wxStaticText( this, -1, - wxString( _T(" Brush size ") ) ); + wxString( _T(" Brush size ") ) ); _sldBrushSize = new wxSlider( this, -1, 1, 1, 50, wxDefaultPosition, - wxDefaultSize, wxSL_LABELS ); + wxDefaultSize, wxSL_LABELS ); _BrushSizeCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); _sldBrushSize->SetMinSize( wxSize( 200, -1 ) ); _sldBrushSize->SetMaxSize( wxSize( 200, -1 ) ); } @@ -221,13 +236,13 @@ void wxManualPaintPanel::ConfigureBrushSizeSld( ) void wxManualPaintPanel::ConfigureDistanceFillSld( ) { _txtDistanceFill = new wxStaticText( this, -1, - wxString( _T(" Distance fill ") ) ); + wxString( _T(" Distance fill ") ) ); _sldDistanceFill = new wxSlider( this, -1, 50, 1, 500, wxDefaultPosition, - wxDefaultSize, wxSL_LABELS ); + wxDefaultSize, wxSL_LABELS ); _sldDistanceFill->SetMinSize( wxSize( 200, -1 ) ); _sldDistanceFill->SetMaxSize( wxSize( 200, -1 ) ); _distancefillCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 500, 50 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 500, 50 ); _txtDistanceFill->Disable( ); _sldDistanceFill->Disable( ); _distancefillCtrl->Disable( ); @@ -264,17 +279,14 @@ void wxManualPaintPanel::ConfigureEditButtons( ) */ void wxManualPaintPanel::ConnectComponents( ) //DFCH { - this->Connect( - _sldBrushSize->GetId( ), + this->Connect(_sldBrushSize->GetId( ), wxEVT_SCROLL_THUMBRELEASE, (wxObjectEventFunction) (void(wxPanel::*)( - wxScrollEvent& )) (&wxManualPaintPanel::OnBrushSize) );this ->Connect (_sldGrayLevel->GetId(), - wxEVT_SCROLL_THUMBRELEASE, - (wxObjectEventFunction) (void(wxPanel::*)( - wxScrollEvent&)) &wxManualPaintPanel::OnSldGrayLevel); - this->Connect - ( - _graylevelCtrl->GetId(), + wxScrollEvent& )) (&wxManualPaintPanel::OnBrushSize) );this ->Connect (_sldGrayLevel->GetId(), + wxEVT_SCROLL_THUMBRELEASE, + (wxObjectEventFunction) (void(wxPanel::*)( wxScrollEvent&)) &wxManualPaintPanel::OnSldGrayLevel); + + this->Connect( _graylevelCtrl->GetId(), wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction) (void(wxPanel::*)( wxCommandEvent&)) &wxManualPaintPanel::OnCtrTxtGrayLevel); @@ -363,9 +375,23 @@ void wxManualPaintPanel::ConnectComponents( ) //DFCH wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction) (void(wxPanel::*)( wxCommandEvent&)) &wxManualPaintPanel::OnCtrBrushSize); + this->Connect + ( + _activeCB->GetId(), + wxEVT_COMMAND_CHECKBOX_CLICKED, + (wxObjectEventFunction) (void (wxPanel::*)(wxCommandEvent&))&wxManualPaintPanel::OnActive); } + + //------------------------------------------------------------------------- + void wxManualPaintPanel::OnActive(wxCommandEvent& event) + { + printf("EED wxManualPaintPanel::OnActive \n"); + SetActive( _activeCB->GetValue() ); + } + + //--------------------------------------------------------------------------- void wxManualPaintPanel::OnBrushSize( wxScrollEvent& event ) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h index c50729a..e16fe00 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h @@ -41,6 +41,7 @@ public: wxManualPaintPanel( wxWindow * parent ); virtual ~wxManualPaintPanel( ); //Panel Config + void ConfigureActiveCBButton(); void ConfigureBrushToolRadioButton( ); void Configure2D3DRadioButton( ); void ConfigureBrushFormRadioButton( ); @@ -52,6 +53,7 @@ public: void ConfigureEditButtons( ); //Events void ConnectComponents( ); //DFCH + void OnActive(wxCommandEvent& event); void OnBrushSize( wxScrollEvent& event ); void OnSldGrayLevel( wxScrollEvent& event ); void OnCtrTxtGrayLevel( wxCommandEvent &event ); @@ -79,29 +81,30 @@ public: void onMovedBar( wxCommandEvent& event ); private: - wxStaticText *_txtBrushSize; - wxSlider *_sldBrushSize; - wxSpinCtrl *_BrushSizeCtrl; + wxCheckBox *_activeCB; + wxStaticText *_txtBrushSize; + wxSlider *_sldBrushSize; + wxSpinCtrl *_BrushSizeCtrl; - wxStaticText *_txtGrayLevel; - wxSlider *_sldGrayLevel; - wxSpinCtrl *_graylevelCtrl; - wxRadioBox *_rbBrushForm; - wxRadioBox *_rb2D3D; - wxRadioBox *_rbBrushTool; + wxStaticText *_txtGrayLevel; + wxSlider *_sldGrayLevel; + wxSpinCtrl *_graylevelCtrl; + wxRadioBox *_rbBrushForm; + wxRadioBox *_rb2D3D; + wxRadioBox *_rbBrushTool; - wxStaticText *_txtToleranceFill; - wxSlider *_sldToleranceFill; - wxSpinCtrl *_tolerancefillCtrl; + wxStaticText *_txtToleranceFill; + wxSlider *_sldToleranceFill; + wxSpinCtrl *_tolerancefillCtrl; - wxStaticText *_txtDistanceFill; - wxSlider *_sldDistanceFill; - wxSpinCtrl *_distancefillCtrl; + wxStaticText *_txtDistanceFill; + wxSlider *_sldDistanceFill; + wxSpinCtrl *_distancefillCtrl; - mBarRange * _mBarSlices; //DFCH - wxButton *_btnCopy; //DFCH - wxButton *_btnUndo; //DFCH - wxButton *_btnRedo; //DFCH + mBarRange *_mBarSlices; //DFCH + wxButton *_btnCopy; //DFCH + wxButton *_btnUndo; //DFCH + wxButton *_btnRedo; //DFCH wxFlexGridSizer *_buttonsSizer; //DFCH wxFlexGridSizer *_FillSizer; //DFCH diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView.cxx index a6991c4..c250f04 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView.cxx @@ -139,7 +139,7 @@ void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMa removed = true; } else { iter++; - } + } } } //--------------------------------------------------------------------------- @@ -152,6 +152,8 @@ void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, Interacto void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type) { + +printf("EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas Start --------\n"); InteractorStyleMaracas *intStyMar; int i,size=_lstInteractorStyleMaracas.size(); @@ -366,16 +368,18 @@ bool vtkInteractorStyleBaseView::GetParent_refresh_waiting() //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView::EvaluateToRefresh() { - +printf("EED vtkInteractorStyleBaseView::EvaluateToRefresh start 1\n"); if ( _blockRefresh==false ) { if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false)) { +printf("EED vtkInteractorStyleBaseView::EvaluateToRefresh start 2\n"); _refresh_waiting = false; this->_wxvtkbaseview->Refresh(); } if (_parent_refresh_waiting==true) { +printf("EED vtkInteractorStyleBaseView::EvaluateToRefresh start 3\n"); _parent_refresh_waiting = false; wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //CPR 13/01/2010 -- 2.47.1