From: Eduardo Davila Date: Wed, 22 Jul 2009 14:46:11 +0000 (+0000) Subject: no message X-Git-Tag: EED.02Oct2009~14 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=42ef0b76d65a1b4cdde710db14ada2eed990a63b;p=creaMaracasVisu.git no message --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index 7989c0d..4e32b1e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -315,7 +315,11 @@ void ContourExtractData::ResetImageResult(int z) int ext[6]; imagedataValueResult->GetExtent(ext); - int i,size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); + int size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); + memset(pValue,0,size*2); + memset(pMask,0,size*2); + /* + int i; for(i=0; iModified(); imagedataMaskResult->Modified(); - } + imagedataValueResult->Update(); + imagedataMaskResult->Update(); + } // if } @@ -439,6 +447,7 @@ vtkImageData *ContourExtractData::GetVtkImageMaskResult() // ------------------------------------------------------------------------ void ContourExtractData::InitVtkImagesResult() { + printf("EED ContourExtractData::InitVtkImagesResult\n"); int ext[6]; int newDim[3]; double spc[3]; @@ -472,6 +481,7 @@ void ContourExtractData::InitVtkImagesResult() imagedataMaskResult->SetSpacing(spc); imagedataMaskResult->SetDimensions( newDim ); imagedataMaskResult->AllocateScalars(); + printf("EED ContourExtractData::InitVtkImagesResult %p %p\n", imagedataValueResult, imagedataMaskResult); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h index d857d50..658f5d4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h @@ -44,6 +44,7 @@ double *vol_minValue, double *vol_maxValue, double *vol_average, double *vol_standardeviation); + void ResetImageResult(int z); private: @@ -67,7 +68,6 @@ int y, manualContourModel *manualcontourmodel ); double GetDataValue(int x, int y, int z); - void ResetImageResult(int z); void PutVtkImageDataResultValue( int x, int y,int z, double value ); void InitVtkImagesResult(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx index 426bf80..693b7d8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx @@ -12,7 +12,18 @@ //========================================================================= ThresholdImageView::ThresholdImageView( ) { - _actorPresent = false; + _actorPresent = false; + _Z = 0; + _minValue = 0; + _maxValue = 1000; + _image = NULL; + _imageReslicer = NULL; + _thresholdTable = NULL; + _thresholdMapper = NULL; + _thresholdActor = NULL; + _baseColorR = 1; + _baseColorG = 0; + _baseColorB = 0; } //========================================================================= @@ -25,6 +36,7 @@ //---------------------------------------------------------------------------- void ThresholdImageView::SetImage(vtkImageData* image) { + printf("ThresholdImageView::SetImage %p\n", image); _image = image; } @@ -34,6 +46,12 @@ void ThresholdImageView::SetwxVtkBaseView(wxVtkBaseView *baseview) _baseView = baseview; } +//---------------------------------------------------------------------------- +wxVtkBaseView *ThresholdImageView::GetwxVtkBaseView() +{ + return _baseView; +} + //---------------------------------------------------------------------------- void ThresholdImageView::SetZ(int z) { @@ -41,10 +59,10 @@ void ThresholdImageView::SetZ(int z) } //---------------------------------------------------------------------------- -void ThresholdImageView::SetminMax(int min, int max) +void ThresholdImageView::SetminMaxValue(int min, int max) { - _min = min; - _max = max; + _minValue = min; + _maxValue = max; } //---------------------------------------------------------------------------- @@ -55,14 +73,19 @@ void ThresholdImageView::onThreshold() vtkImageData *img = _image; img->GetScalarRange(range); + if (range[1]==0) + { + range[1]=255; + } + int minTot = floor (range[0]); int maxTot = ceil (range[1]); -//EED _pannew->onThresholdInstantChange(minMax); - int minVal = floor (_min); - int maxVal = floor (_max); + int minVal = floor (_minValue); + int maxVal = floor (_maxValue); + if (!_actorPresent) { @@ -70,7 +93,7 @@ void ThresholdImageView::onThreshold() { _imageReslicer = vtkImageReslice::New(); _imageReslicer->SetInput( img ); - _imageReslicer->SetInformationInput(img); + _imageReslicer->SetInformationInput(img); _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1); _imageReslicer->SetOutputDimensionality(2); _imageReslicer->SetInterpolationModeToLinear(); @@ -102,7 +125,7 @@ void ThresholdImageView::onThreshold() { if( i >= minVal && i <= maxVal ) { - _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); + _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1); } else if( i >= minTot && i < minVal ) { @@ -154,7 +177,7 @@ void ThresholdImageView::onThreshold() { if( i >= minVal && i <= maxVal ) { - _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1); + _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1); } else if( i >= minTot && i < minVal ) { @@ -175,15 +198,6 @@ void ThresholdImageView::onThreshold() _thresholdMapper->SetInput( img ); _thresholdActor->SetInput( _thresholdMapper->GetOutput() ); } - /* - vtkImageViewer2* viewer = vtkImageViewer2::New(); - viewer->SetInput( upperImageActor->GetInput() ); - viewer->SetColorLevel((range[1]-range[0])/2); - viewer->SetColorWindow(range[1]); - viewer->GetRenderer()->AddActor( upperImageActor ); - viewer->Render(); - */ -//EED _theViewPanel->RefreshInterface(); } @@ -240,6 +254,13 @@ void ThresholdImageView::onThresholdRemove() } +//---------------------------------------------------------------------------- +void ThresholdImageView::SetBaseColor(double r, double g, double b) +{ + _baseColorR = r; + _baseColorG = g; + _baseColorB = b; +} // EOF diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h index 56dd8a6..5ca77b5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.h @@ -36,14 +36,19 @@ class ThresholdImageView void SetImage(vtkImageData* image); void SetwxVtkBaseView(wxVtkBaseView *baseview); + wxVtkBaseView *GetwxVtkBaseView(); + void SetBaseColor(double r, double g, double b); void SetZ(int z); - void SetminMax(int min, int max); + void SetminMaxValue(int min, int max); private: int _Z; - double _min; - double _max; + double _baseColorR; + double _baseColorG; + double _baseColorB; + double _minValue; + double _maxValue; bool _actorPresent; vtkImageData *_image; vtkImageReslice *_imageReslicer; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx index 4ad0d44..7d2dd8c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.cxx @@ -13,47 +13,62 @@ /** ** Begin of the threshold panel **/ -ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent) +ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type) : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN) { _thresholdImageView = new ThresholdImageView(); - wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) ); +// wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) ); + + _thresholdGo = true; + _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") ); + _cb_ShowHide->SetValue(_thresholdGo); + _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") ); _interpolationCheckBox->SetValue(true); _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator); - _thresholdGo = false; - double range[2]; +// double range[2]; // interfMainPanel::getInstance()->getImageRange(range); - int min = (int)floor (range[0]); - int max = (int)ceil (range[1]); +// int min = (int)floor (range[0]); +// int max = (int)ceil (range[1]); + + if (type==0) + { + } + + if (type==1) + { + _mBarThreshold = new mBarRange(this,70,65); + _mBarThreshold->SetMin(0); + _mBarThreshold->SetStart(0); + _mBarThreshold-> SetOrientation( true ); + _mBarThreshold-> setActiveStateTo(true); + _mBarThreshold-> setVisibleLabels( true ); + _mBarThreshold-> setDeviceEndMargin(10); + _mBarThreshold-> setRepresentedValues( min , max ); + _mBarThreshold-> setDeviceBlitStart(10,10); + _mBarThreshold-> setIfWithActualDrawed( false ); + _mBarThreshold-> SetStart( min ); + _mBarThreshold-> SetEnd( max ); + } - _mBarThreshold = new mBarRange(this,70,65); - _mBarThreshold->SetMin(0); - _mBarThreshold->SetStart(0); - _mBarThreshold-> SetOrientation( true ); - _mBarThreshold-> setActiveStateTo(true); - _mBarThreshold-> setVisibleLabels( true ); - _mBarThreshold-> setDeviceEndMargin(10); - _mBarThreshold-> setRepresentedValues( min , max ); - _mBarThreshold-> setDeviceBlitStart(10,10); - _mBarThreshold-> setIfWithActualDrawed( false ); - _mBarThreshold-> SetStart( min ); - _mBarThreshold-> SetEnd( max ); - Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdGo ); + Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow ); Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation ); wxFlexGridSizer * sizer = new wxFlexGridSizer(1); - sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW ); - sizer -> Add( _mBarThreshold, 1, wxGROW ); - sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + if (type==1) + { + sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW ); + sizer -> Add( _mBarThreshold, 1, wxGROW ); + sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); + } sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW ); sizer -> Add( _opacity, 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); - sizer -> Add( thresholdGoBtn, 1, wxGROW ); + sizer -> Add( _cb_ShowHide, 1, wxGROW ); sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW ); sizer -> Add( _interpolationCheckBox, 1, wxGROW ); @@ -63,7 +78,8 @@ ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent) } //---------------------------------------------------------------------------- -ThresholdImageViewPanel::~ThresholdImageViewPanel(){ +ThresholdImageViewPanel::~ThresholdImageViewPanel() +{ } @@ -79,25 +95,26 @@ void ThresholdImageViewPanel::onThresholdChange(wxCommandEvent& event) { if (_thresholdGo) { + _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() ); _thresholdImageView->onThresholdChange(); - + _thresholdImageView->GetwxVtkBaseView()->Refresh(); //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl; } } //---------------------------------------------------------------------------- -void ThresholdImageViewPanel::onThresholdGo(wxCommandEvent& event) +void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event) { - if (!_thresholdGo) + _thresholdGo = _cb_ShowHide->GetValue(); + if (_thresholdGo) { _thresholdImageView->onThreshold(); - _thresholdGo=true; } else { _thresholdImageView->onThresholdRemove( ); - _thresholdGo=false; } + _thresholdImageView->GetwxVtkBaseView()->Refresh(); } //---------------------------------------------------------------------------- @@ -110,17 +127,12 @@ void ThresholdImageViewPanel::onThresholdStop() } } -//---------------------------------------------------------------------------- -void ThresholdImageViewPanel::onThresholdInstantChange(double range[]) -{ - range[0] = _mBarThreshold->GetStart(); - range[1] = _mBarThreshold->GetEnd(); -} - //---------------------------------------------------------------------------- void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event) { _thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue()); + _thresholdImageView->GetwxVtkBaseView()->Refresh(); + } //---------------------------------------------------------------------------- @@ -128,9 +140,16 @@ void ThresholdImageViewPanel::onChangeOpacity(wxScrollEvent& event) { int opacity = _opacity->GetValue(); _thresholdImageView->onThresholdChangeOpacity(opacity); + _thresholdImageView->GetwxVtkBaseView()->Refresh(); } +//---------------------------------------------------------------------------- +bool ThresholdImageViewPanel::IsVisible() +{ + return _thresholdGo; +} + BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel) EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h index 54d9985..a5380c2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageViewPanel.h @@ -23,11 +23,11 @@ : public wxPanel { public: - ThresholdImageViewPanel(wxWindow * parent); + ThresholdImageViewPanel(wxWindow * parent, int min, int max, int type); ~ThresholdImageViewPanel(); void onThresholdStop(); - void onThresholdInstantChange(double range[]); void SetThresholdImageView(ThresholdImageView* thresholdImageView); + bool IsVisible(); private: @@ -36,12 +36,12 @@ mBarRange *_mBarThreshold; wxSlider *_opacity; wxCheckBox *_interpolationCheckBox; + wxCheckBox *_cb_ShowHide; void onThresholdChange(wxCommandEvent& event); - void onThresholdGo(wxCommandEvent& event); + void onThresholdShow(wxCommandEvent& event); void onThresholdInterpolation(wxCommandEvent& event); void onChangeOpacity(wxScrollEvent& event); - DECLARE_EVENT_TABLE() };