From ef92674006375c4fe7b842ce834590c5b6d9683f Mon Sep 17 00:00:00 2001 From: davila Date: Thu, 13 Mar 2014 14:09:50 +0100 Subject: [PATCH] 2339 creaMaracasVisu Feature New Normal ColorLayer in perpendicular planes --- .../bbcreaMaracasVisuColorLayerImageView.cxx | 13 +- .../bbcreaMaracasVisuColorLayerImageView.h | 6 +- .../ColorLayerImageView.cxx | 47 +++ .../ThresholdImageView/ColorLayerImageView.h | 6 +- .../ColorLayerImageViewManager.cxx | 354 ++++++++++++++++++ .../ColorLayerImageViewManager.h | 76 ++++ .../ColorLayerImageViewPanel.cxx | 199 ++++++---- .../ColorLayerImageViewPanel.h | 17 +- .../ThresholdImageView/LayerImageBase.cxx | 123 +++++- .../ThresholdImageView/LayerImageBase.h | 8 +- 10 files changed, 753 insertions(+), 96 deletions(-) create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx index 707658d..66a99f7 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.cxx @@ -42,15 +42,18 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ColorLayerImageView,bbtk::WxBlackBox); void ColorLayerImageView::Process() { ColorLayerImageViewPanel *clivp = (ColorLayerImageViewPanel*)bbGetOutputWidget(); - clivp->GetColorLayerImageView()->SetwxVtkBaseView( bbGetInputWxVtkBaseView() ); + clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 0 , bbGetInputWxVtkBaseView() ); + clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 1 , bbGetInputWxVtkBaseView1() ); + clivp->GetColorLayerImageViewManager()->SetwxVtkBaseView( 2 , bbGetInputWxVtkBaseView2() ); + std::vector base_color = bbGetInputlstBaseColor(); - clivp->GetColorLayerImageView()->SetBaseColors( base_color ); + clivp->GetColorLayerImageViewManager()->SetBaseColors( base_color ); std::vector grey_level_boundaries = bbGetInputlstGreyLevelBoundaries(); - clivp->GetColorLayerImageView()->SetGreyLevelBoundaries( grey_level_boundaries ); + clivp->GetColorLayerImageViewManager()->SetGreyLevelBoundaries( grey_level_boundaries ); - clivp->GetColorLayerImageView()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() ); + clivp->GetColorLayerImageViewManager()->SetPlainOrGradientColor( bbGetInputPlainOrGradientColor() ); clivp->SetFittingMode( bbGetInputFittingMode() ); clivp->SetImage( bbGetInputIn() ); @@ -80,6 +83,8 @@ void ColorLayerImageView::bbUserSetDefaultValues() { bbSetInputIn(NULL); bbSetInputWxVtkBaseView(NULL); + bbSetInputWxVtkBaseView1(NULL); + bbSetInputWxVtkBaseView2(NULL); } //===== // Don't edit this file. This file is generated from xml description.. diff --git a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h index 9147260..a7ab2d0 100644 --- a/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h +++ b/bbtk/src/bbcreaMaracasVisuColorLayerImageView.h @@ -46,6 +46,8 @@ class bbcreaMaracasVisu_EXPORT ColorLayerImageView // Don't edit this file. This file is generated from xml description.. //===== BBTK_DECLARE_INPUT(WxVtkBaseView,wxVtkBaseView *); + BBTK_DECLARE_INPUT(WxVtkBaseView1,wxVtkBaseView *); + BBTK_DECLARE_INPUT(WxVtkBaseView2,wxVtkBaseView *); BBTK_DECLARE_INPUT(In,vtkImageData*); BBTK_DECLARE_INPUT(lstBaseColor,std::vector); BBTK_DECLARE_INPUT(lstGreyLevelBoundaries,std::vector); @@ -66,7 +68,9 @@ BBTK_NAME("ColorLayerImageView"); BBTK_AUTHOR("Eduardo DAVILA (Creatis)"); BBTK_DESCRIPTION("Color Layer Image View"); BBTK_CATEGORY("__CategoryBlackBox__"); -BBTK_INPUT(ColorLayerImageView,WxVtkBaseView,"creaMaracasVisuViewer viewer",wxVtkBaseView*,""); +BBTK_INPUT(ColorLayerImageView,WxVtkBaseView," 0 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); +BBTK_INPUT(ColorLayerImageView,WxVtkBaseView1," 1 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); +BBTK_INPUT(ColorLayerImageView,WxVtkBaseView2," 2 creaMaracasVisuViewer viewer XY,YZ ou XZ",wxVtkBaseView*,""); 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 (grey level outside the color boundaries will not be disayed). 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,""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx index 5e940da..28c473d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx @@ -63,12 +63,59 @@ void ColorLayerImageView::SetSliceFixDynamic(bool fix_dynamic) _fix_dynamic = fix_dynamic; } +//---------------------------------------------------------------------------- +void ColorLayerImageView::SetX2(int x2) +{ + _x2 = x2; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageView::SetY2(int y2) +{ + _y2 = y2; +} + + //---------------------------------------------------------------------------- void ColorLayerImageView::SetZ2(int z2) { _z2 = z2; } + + +//---------------------------------------------------------------------------- +int ColorLayerImageView::GetX() // virtual +{ + int result=0; + if (_fix_dynamic==false) + { + result = _x2; + } + else + { + result = LayerImageBase::GetX(); + } + + return result; +} + +//---------------------------------------------------------------------------- +int ColorLayerImageView::GetY() // virtual +{ + int result=0; + if (_fix_dynamic==false) + { + result = _y2; + } + else + { + result = LayerImageBase::GetY(); + } + + return result; +} + //---------------------------------------------------------------------------- int ColorLayerImageView::GetZ() // virtual { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h index 6126438..e9adb4f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.h @@ -45,7 +45,11 @@ class ColorLayerImageView : public LayerImageBase ColorLayerImageView( ); ~ColorLayerImageView( ); void SetSliceFixDynamic(bool fix_dynamic); + void SetX2(int x2); + void SetY2(int y2); void SetZ2(int z2); + virtual int GetX(); + virtual int GetY(); virtual int GetZ(); /** @@ -89,7 +93,7 @@ class ColorLayerImageView : public LayerImageBase private: - int _z2; + int _x2, _y2, _z2; bool _fix_dynamic; void SetDefaultGreyLevelBoundary(); void SetDefaultBaseColorAndGreyLevelBoundary(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx new file mode 100644 index 0000000..2e5b403 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx @@ -0,0 +1,354 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + +/** + * \file + * \author Eduardo Davila and Claire Mouton. + * \brief Class bbtk::ThresholdImageView. + * \date September 2012 + */ + +#include "ColorLayerImageViewManager.h" + + + +//========================================================================= +//========================================================================= +//========================================================================= +//========================================================================= +ColorLayerImageViewManager::ColorLayerImageViewManager( ) +{ + _colorLayerImageViewLst.push_back(NULL); // 0 + _colorLayerImageViewLst.push_back(NULL); // 1 + _colorLayerImageViewLst.push_back(NULL); // 2 +} + +//========================================================================= +ColorLayerImageViewManager::~ColorLayerImageViewManager() +{ +} +//========================================================================= + + + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetwxVtkBaseView(int id, wxVtkBaseView *baseview) +{ + if (baseview!=NULL) + { + int size =_colorLayerImageViewLst.size(); + if ( (id>=0) && (id<=size) ) + { + if (_colorLayerImageViewLst[id]==NULL) + { + _colorLayerImageViewLst[id] = new ColorLayerImageView(); + } + _colorLayerImageViewLst[id]->SetwxVtkBaseView(baseview); + + } // if id + } // baseview +} + + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetX2(int x2) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetX2( x2 ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetY2(int y2) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetY2( y2 ); + } // if + } // for + +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetZ2(int z2) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetZ2( z2 ); + } // if + } // for + +} + + + +//---------------------------------------------------------------------------- +int ColorLayerImageViewManager::GetX() +{ + int result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetX(); + } // if + } // for + return result; +} + +//---------------------------------------------------------------------------- +int ColorLayerImageViewManager::GetY() +{ + int result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetY(); + } // if + } // for + return result; +} + + + +//---------------------------------------------------------------------------- +int ColorLayerImageViewManager::GetZ() // virtual +{ + int result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetZ(); + } // if + } // for + return result; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetBaseColors(std::vector & base_color) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetBaseColors( base_color ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +double ColorLayerImageViewManager::GetBaseColors(unsigned int index) +{ + double result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetBaseColors( index ); + } // if + } // for + return result; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetGreyLevelBoundaries(std::vector & grey_level_boundary) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetGreyLevelBoundaries( grey_level_boundary ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +double ColorLayerImageViewManager::GetGreyLevelBoundaries(unsigned int index) +{ + double result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetGreyLevelBoundaries( index ); + } // if + } // for + return result; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetPlainOrGradientColor(bool color_type) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetPlainOrGradientColor( color_type ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +int ColorLayerImageViewManager::GetBaseColorNb() +{ + int result; + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iGetBaseColorNb(); + } // if + } // for + return result; +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::Refresh() +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iRefresh(); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::onThreshold() +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;ionThreshold(); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::onThresholdChange() +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;ionThresholdChange(); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::onThresholdRemove() +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;ionThresholdRemove(); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::onThresholdInterpolation(bool interpolation) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;ionThresholdInterpolation( interpolation ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetSliceFixDynamic( bool fixdyn ) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetSliceFixDynamic( fixdyn ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;ionThresholdChangeOpacity( opacity ); + } // if + } // for +} + +//---------------------------------------------------------------------------- +void ColorLayerImageViewManager::SetImage( vtkImageData* img ) +{ + int i, size=_colorLayerImageViewLst.size(); + for (i=0;iSetImage( img ); + } // if + } // for +} + +// EOF + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h new file mode 100644 index 0000000..0d6a6a8 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.h @@ -0,0 +1,76 @@ +/*# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sant�) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ */ + +/** + * \file + * \brief Class ThresholdImageView . + */ + +/** + * \class ThresholdImageView + * \brief + */ + +#ifndef __ColorLayerImageViewManager_h__ +#define __ColorLayerImageViewManager_h__ + +#include "ColorLayerImageView.h" + + +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); + 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; + + protected: + }; + +#endif + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index a70c96d..963a51c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -95,7 +95,9 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in _spcBase[0] = _spcBase[1] = _spcBase[2] = 0; _dimBase[0] = _dimBase[1] = _dimBase[2] = 0; - _colorLayerImageView = new ColorLayerImageView(); +//EED01 _colorLayerImageView = new ColorLayerImageView(); + _colorLayerImageViewManager = new ColorLayerImageViewManager(); + _btn_ReadImage = new wxButton(this, wxID_ANY, _T("Read Image") ); _thresholdGo = true; _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide Layer") ); @@ -104,8 +106,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Fixed/Dynamic Slice") ); _cb_SliceFixDinamic->SetValue(true); - _sl_SliceImage = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - _sl_SliceImage->Enable(false); + _sl_SliceImageX = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _sl_SliceImageY = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _sl_SliceImageZ = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); + _sl_SliceImageX->Enable(false); + _sl_SliceImageY->Enable(false); + _sl_SliceImageZ->Enable(false); _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") ); _interpolationCheckBox->SetValue(true); @@ -125,11 +131,25 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation ); Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity ); Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic ); - Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); - Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); - Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); - Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); - Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + + Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + + Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + + Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage ); + wxFlexGridSizer * sizer = new wxFlexGridSizer(1); @@ -148,7 +168,9 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T("Slice ")) , 1, wxGROW ); - sizer -> Add( _sl_SliceImage, 1, wxGROW ); + sizer -> Add( _sl_SliceImageX, 1, wxGROW ); + sizer -> Add( _sl_SliceImageY, 1, wxGROW ); + sizer -> Add( _sl_SliceImageZ, 1, wxGROW ); sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW ); this->SetSizer( sizer ); @@ -166,16 +188,23 @@ ColorLayerImageViewPanel::~ColorLayerImageViewPanel() } -//---------------------------------------------------------------------------- -void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView) -{ - _colorLayerImageView = colorLayerImageView; -} +//EED01 +//EED01 //---------------------------------------------------------------------------- +//EED01 void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView) +//EED01 { +//EED01 _colorLayerImageView = colorLayerImageView; +//EED01 } +//EED01 +//EED01 //---------------------------------------------------------------------------- +//EED01 ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView() +//EED01 { +//EED01 return _colorLayerImageView; +//EED01 } -//---------------------------------------------------------------------------- -ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView() + +ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager() { - return _colorLayerImageView; + return _colorLayerImageViewManager; } @@ -212,7 +241,7 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) { if (img!=NULL) { - _colorLayerImageView->SetImage( img ); + _colorLayerImageViewManager->SetImage( img ); double spc[3]; img->GetSpacing(spc); @@ -223,7 +252,9 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) dim[0] = ext[1]-ext[0]; dim[1] = ext[3]-ext[2]; dim[2] = ext[5]-ext[4]; - _sl_SliceImage->SetRange( 0 , dim[2] ); + _sl_SliceImageX->SetRange( 0 , dim[0] ); + _sl_SliceImageY->SetRange( 0 , dim[1] ); + _sl_SliceImageZ->SetRange( 0 , dim[2] ); 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]) @@ -273,16 +304,24 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) img->SetSpacing(spc); } // spc !_spcBase dim!__dimBase - if (_colorLayerImageView!=NULL) - { - _colorLayerImageView->onThreshold(); - _colorLayerImageView->Refresh(); - } +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { +//EED01 _colorLayerImageView->onThreshold(); + _colorLayerImageViewManager->onThreshold(); + RefreshView(); +//EED01 } } } + +void ColorLayerImageViewPanel::RefreshView() +{ +//EED01 _colorLayerImageView->Refresh(); + _colorLayerImageViewManager->Refresh(); +} + //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::SetFittingMode(int fitting_mode) { @@ -318,93 +357,111 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event) { - if (_colorLayerImageView!=NULL) - { - if (_thresholdGo) - { - _colorLayerImageView->onThresholdChange(); - _colorLayerImageView->Refresh(); - //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; - } // _threshold - }//_colorLayerImageView +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { + if (_thresholdGo) + { +//EED01 _colorLayerImageView->onThresholdChange(); + _colorLayerImageViewManager->onThresholdChange(); + RefreshView(); + //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; + } // _thresholdGo +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event) { - if (_colorLayerImageView!=NULL) - { +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { _thresholdGo = _cb_ShowHide->GetValue(); if (_thresholdGo) { - _colorLayerImageView->onThreshold(); +//EED01 _colorLayerImageView->onThreshold(); + _colorLayerImageViewManager->onThreshold(); }else{ - _colorLayerImageView->onThresholdRemove( ); +//EED01 _colorLayerImageView->onThresholdRemove( ); + _colorLayerImageViewManager->onThresholdRemove( ); } - _colorLayerImageView->Refresh(); - }//_colorLayerImageView + RefreshView(); +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdStop() { - if (_colorLayerImageView!=NULL) - { - if (_thresholdGo) - { - _colorLayerImageView->onThresholdRemove( ); - _thresholdGo=false; - } - }//_colorLayerImageView +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { + if (_thresholdGo) + { +//EED01 _colorLayerImageView->onThresholdRemove( ); + _colorLayerImageViewManager->onThresholdRemove( ); + _thresholdGo=false; + } +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) { - if (_colorLayerImageView!=NULL) - { - _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); - _colorLayerImageView->Refresh(); - }//_colorLayerImageView +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { +//EED01 _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + RefreshView(); +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event) { - if (_colorLayerImageView!=NULL) - { +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { bool fixdin = _cb_SliceFixDinamic->GetValue(); - _colorLayerImageView->SetSliceFixDynamic( fixdin ); +//EED01 _colorLayerImageView->SetSliceFixDynamic( fixdin ); + _colorLayerImageViewManager->SetSliceFixDynamic( fixdin ); if (fixdin==false) { - _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); +//EED01 _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); + _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() ); + _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() ); + _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() ); } - _sl_SliceImage->Enable(!fixdin); - _colorLayerImageView->onThreshold(); - _colorLayerImageView->Refresh(); - }//_colorLayerImageView + _sl_SliceImageX->Enable(!fixdin); + _sl_SliceImageY->Enable(!fixdin); + _sl_SliceImageZ->Enable(!fixdin); +//EED01 _colorLayerImageView->onThreshold(); + _colorLayerImageViewManager->onThreshold(); + RefreshView(); +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event) { - if (_colorLayerImageView!=NULL) - { - _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); - _colorLayerImageView->onThreshold(); - _colorLayerImageView->Refresh(); - }//_colorLayerImageView +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { +//EED01 _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() ); +//EED01 _colorLayerImageView->onThreshold(); +//EED01 RefreshView(); + _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() ); + _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() ); + _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() ); + _colorLayerImageViewManager->onThreshold(); + RefreshView(); +//EED01 }//_colorLayerImageView } //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event) { - if (_colorLayerImageView!=NULL) - { +//EED01 if (_colorLayerImageView!=NULL) +//EED01 { int opacity = _opacity->GetValue(); - _colorLayerImageView->onThresholdChangeOpacity(opacity); - _colorLayerImageView->Refresh(); - }//_colorLayerImageView +//EED01 _colorLayerImageView->onThresholdChangeOpacity(opacity); + _colorLayerImageViewManager->onThresholdChangeOpacity(opacity); + RefreshView(); +//EED01 }//_colorLayerImageView } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h index ad52674..da8489c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.h @@ -39,7 +39,7 @@ #include #include -#include "ColorLayerImageView.h" +#include "ColorLayerImageViewManager.h" @@ -65,8 +65,9 @@ class ColorLayerImageViewPanel ColorLayerImageViewPanel(wxWindow * parent, int min, int max, int type); ~ColorLayerImageViewPanel(); void onThresholdStop(); - ColorLayerImageView* GetColorLayerImageView(); - void SetColorLayerImageView(ColorLayerImageView* colorLayerImageView); + ColorLayerImageViewManager* GetColorLayerImageViewManager(); +//EED01 ColorLayerImageView* GetColorLayerImageView(); +//EED01 void SetColorLayerImageView(ColorLayerImageView* colorLayerImageView); bool IsVisible(); void SetBaseSpacing(double spc[3]); void SetBaseDimension(int dim[3]); @@ -83,13 +84,16 @@ class ColorLayerImageViewPanel double _spcOrg[3]; bool _thresholdGo; - ColorLayerImageView *_colorLayerImageView; + ColorLayerImageViewManager *_colorLayerImageViewManager; +// ColorLayerImageView *_colorLayerImageView; wxButton *_btn_ReadImage; wxSlider *_opacity; wxCheckBox *_interpolationCheckBox; wxCheckBox *_cb_ShowHide; wxCheckBox *_cb_SliceFixDinamic; - wxSlider *_sl_SliceImage; + wxSlider *_sl_SliceImageX; + wxSlider *_sl_SliceImageY; + wxSlider *_sl_SliceImageZ; void onReadImage(wxCommandEvent& event); void onThresholdChange(wxCommandEvent& event); void onThresholdShow(wxCommandEvent& event); @@ -98,6 +102,9 @@ class ColorLayerImageViewPanel void onSliceFixDinamic(wxCommandEvent& event); void onSliceImage(wxScrollEvent& event); + void RefreshView(); + + }; #endif diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index 0a2ccf9..f8c6693 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -73,6 +73,8 @@ bool ColorLayerImageBasevtkInteractor::OnMouseMove() // vitual // _manualPaintControler->PaintImage((int) X, (int) Y, (int) Z); + _layerImageBase->SetX( (int)X ); + _layerImageBase->SetY( (int)Y ); _layerImageBase->SetZ( (int)Z ); _layerImageBase->onThreshold(); // _layerImageBase->Refresh(); @@ -114,6 +116,8 @@ bool ColorLayerImageBasevtkInteractor::OnRightButtonUp() // virtual LayerImageBase::LayerImageBase() { _actorPresent = false; + _X = 0; + _Y = 0; _Z = 0; _thresholdTable = NULL; _thresholdMapper = NULL; @@ -129,18 +133,42 @@ LayerImageBase::LayerImageBase() { } +//---------------------------------------------------------------------------- +void LayerImageBase::SetX(int x) +{ + _X = x; +} + +//---------------------------------------------------------------------------- +void LayerImageBase::SetY(int y) +{ + _Y = y; +} + //---------------------------------------------------------------------------- void LayerImageBase::SetZ(int z) { _Z = z; } +//---------------------------------------------------------------------------- +int LayerImageBase::GetX() // virtual +{ + return _X; +} + +//---------------------------------------------------------------------------- +int LayerImageBase::GetY() // virtual +{ + return _Y; +} //---------------------------------------------------------------------------- int LayerImageBase::GetZ() // virtual { return _Z; } + //---------------------------------------------------------------------------- vtkImageData* LayerImageBase::GetImage() { @@ -165,12 +193,12 @@ void LayerImageBase::SetImage(vtkImageData* image) void LayerImageBase::SetwxVtkBaseView(wxVtkBaseView *baseview) { printf("EED LayerImageBase::SetwxVtkBaseView start baseview:%p \n", baseview); - - _baseView = baseview; - - vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView()); - isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) ); - + if (_baseView==NULL) + { + _baseView = baseview; + vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(_baseView->GetInteractorStyleBaseView()); + isbv->AddInteractorStyleMaracas( new ColorLayerImageBasevtkInteractor(this) ); + } // if _baseView printf("EED LayerImageBase::SetwxVtkBaseView end \n"); } @@ -198,22 +226,42 @@ vtkLookupTable* LayerImageBase::GetThresholdTable() } //---------------------------------------------------------------------------- -int LayerImageBase::CleanZ(int z) +void LayerImageBase::CleanXYZ(double &x, double &y, double &z) { int ext[6]; _image->GetWholeExtent(ext); + if (x<0) + { + x=0; + } + + if (y<0) + { + y=0; + } + if (z<0) { z=0; } + if ( x > (ext[1]-ext[0]) ) + { + z=ext[1]-ext[0]; + } + + if ( y > (ext[3]-ext[2]) ) + { + z=ext[3]-ext[2]; + } + if ( z > (ext[5]-ext[4]) ) { z=ext[5]-ext[4]; } - return z; + } //---------------------------------------------------------------------------- @@ -226,12 +274,30 @@ void LayerImageBase::onThreshold() { double spc[3]; GetImage()-> GetSpacing(spc); - double z = CleanZ( GetZ() ); - z = z*spc[2]; + double x=GetX(); + double y=GetY(); + double z=GetZ(); + CleanXYZ(x,y,z); + + x = x*spc[0]; + y = y*spc[1]; + z = z*spc[2]; + printf("EED LayerImageBase::onThreshold z = %d spcZ%f\n" , z, spc[2]); + vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera(); + int directionViewer=0; + if (camera->GetParallelProjection()==1) + { + wxVtk2DBaseView *wxvtk2dbasevie = (wxVtk2DBaseView *)_baseView; + directionViewer = wxvtk2dbasevie->GetDirection(); + } // ParallelProjection + +printf("EED LayerImageBase::onThreshold projection = %d\n" , camera->GetParallelProjection() ); +printf("EED LayerImageBase::onThreshold direction = %d\n" , directionViewer ); + if (!GetActorPresent()) { @@ -251,7 +317,20 @@ void LayerImageBase::onThreshold() _thresholdActor = vtkImageActor::New( ); _thresholdActor->SetOpacity( 0.6 ); _thresholdActor->InterpolateOn( ); - _thresholdActor->SetPosition( 0,0, -900-1 ); + if (directionViewer==0) + { + _thresholdActor->SetPosition( 900-1,0,0 ); + _thresholdActor->RotateY( -90 ); + } + if (directionViewer==1) + { + _thresholdActor->SetPosition( 0,-900-1, 0 ); + _thresholdActor->RotateX( 90 ); + } + if (directionViewer==2) + { + _thresholdActor->SetPosition( 0,0, -900-1 ); + } } // _thresholdActor _baseView->GetRenderer()->AddActor( _thresholdActor ); _actorPresent = true; @@ -260,11 +339,29 @@ void LayerImageBase::onThreshold() ConfigLookupTable(); // virtual method _imageReslicer->SetInput( GetImage() ); _imageReslicer->SetInformationInput( GetImage() ); - _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); + + if (directionViewer==0) + { + _imageReslicer->SetResliceAxesDirectionCosines( 0,0,1, 0,1,0, -1,0,0 ); + _imageReslicer->SetResliceAxesOrigin(x,0,0); + } + + if (directionViewer==1) + { + _imageReslicer->SetResliceAxesDirectionCosines( 1,0,0 ,0,0,1, 0,-1,0 ); + _imageReslicer->SetResliceAxesOrigin(0,y,0); + } + + if (directionViewer==2) + { + _imageReslicer->SetResliceAxesDirectionCosines( 1,0,0, 0,1,0 ,0,0,1 ); + _imageReslicer->SetResliceAxesOrigin(0,0,z); + } + + _imageReslicer->SetOutputDimensionality(2); // _imageReslicer->SetInterpolationModeToLinear(); _imageReslicer->SetInterpolationModeToNearestNeighbor(); - _imageReslicer->SetResliceAxesOrigin(0,0,z); vtkImageData *img = _imageReslicer->GetOutput(); // img->Update(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h index c96d748..1781373 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h @@ -79,6 +79,8 @@ class LayerImageBase public: LayerImageBase(); virtual ~LayerImageBase(); + void SetX(int x); + void SetY(int y); void SetZ(int z); void SetImage(vtkImageData* image); void SetwxVtkBaseView(wxVtkBaseView *baseview); @@ -92,9 +94,13 @@ class LayerImageBase void Refresh(); vtkLookupTable *GetvtkLookupTable(); vtkImageReslice *GetvtkImageReslice(); + virtual int GetX(); + virtual int GetY(); virtual int GetZ(); private: + int _X; + int _Y; int _Z; bool _actorPresent; vtkImageData *_image; @@ -106,7 +112,7 @@ class LayerImageBase virtual void ConfigLookupTable() = 0; bool GetActorPresent(); - int CleanZ(int z); + void CleanXYZ(double &x, double &y, double &z); protected: -- 2.47.1