From 22f291ff6afce66933c2a8fe97097692680d186b Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Tue, 28 Jan 2020 12:35:31 +0100 Subject: [PATCH] #3351 creaMaracas Visu Bug New Normal - Refresh ViewerNV --- bbtk/src/bbmaracasvisuViewerNV.cxx | 40 +++++++------- .../wxWindows/widgets/vtkMPR3DDataViewer.cxx | 53 ++++++++++-------- .../wxWindows/widgets/vtkMPR3DDataViewer.h | 10 ---- .../widgets/wxMaracas_ViewerWidget.cxx | 8 +-- .../wxWindows/widgets/wxVtkMPR3DView.cxx | 54 ++++++++++++------- .../wxWindows/widgets/wxVtkMPR3DView.h | 17 +++--- 6 files changed, 99 insertions(+), 83 deletions(-) diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 262107d..b5a0e89 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -94,7 +94,7 @@ void ViewerNV::Process() }else if (img != _currentimg){ _mwxwidget->SetImage(img); } - _mwxwidget->RefreshView(); +// _mwxwidget->RefreshView(); _currenttype = type; _currentimg = img; _point.clear(); @@ -135,7 +135,6 @@ void ViewerNV::Process() } } _mwxwidget->SetInterpolate( bbGetInputInterpolate() ); - /* Borrame if (wvbv1!=NULL) { @@ -149,10 +148,6 @@ void ViewerNV::Process() } */ - - - - }// mwxwidget != NULL } @@ -213,29 +208,32 @@ void ViewerNV::bbUserFinalizeProcessing() //----------------------------------------------------------------- - - -bool ViewerNV::compareVectors(std::vector type,std::vector currenttype){ - +bool ViewerNV::compareVectors(std::vector type,std::vector currenttype) +{ bool ret = true; - - if(type.size()==currenttype.size()){ - for(int i = 0; i < (int)(type.size()) && ret; i++){ - if(type[i]!=currenttype[i]){ + if(type.size()==currenttype.size()) + { + for(int i = 0; i < (int)(type.size()) && ret; i++) + { + if(type[i]!=currenttype[i]) + { ret = false; - } - } + } // if + } // for }else{ ret=false; - } + } // type size return ret; } -void ViewerNV::updateObservers(){ +void ViewerNV::updateObservers() +{ vtkRenderWindowInteractor* interactor; interactor = bbGetOutputInteractor1(); - if(interactor){ - if (bbGetInputObs1()!=NULL){ + if(interactor) + { + if (bbGetInputObs1()!=NULL) + { bbGetInputObs1()->SetInteractor(interactor); bbGetInputObs1()->EnabledOn(); } @@ -259,7 +257,7 @@ void ViewerNV::updateObservers(){ bbGetInputObs5()->SetInteractor(interactor); bbGetInputObs5()->EnabledOn(); } - } + } // if interactor } } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx index cb1dc1e..189bdfa 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx @@ -48,27 +48,27 @@ vtkMPR3DDataViewer::vtkMPR3DDataViewer() //------------------------------------------------------------------- vtkMPR3DDataViewer::~vtkMPR3DDataViewer() { - if(_outlineData) {_outlineData-> Delete();} - if(_mapOutline) {_mapOutline-> Delete();} - if(_outline) {_outline-> Delete();} - -// if (_bwLut) _bwLut->Delete(); -// if (_hueLut) _hueLut->Delete(); -// if (_satLut) _satLut->Delete(); - if (_ctfun) _ctfun->Delete(); - if (_saggitalColors) _saggitalColors ->Delete(); - if (_saggital) _saggital->Delete(); - if (_axialColors) _axialColors->Delete(); - if (_axial) _axial->Delete(); - if (_coronalColors) _coronalColors->Delete(); - if (_coronal) _coronal->Delete(); - + if(_outlineData) {_outlineData -> Delete();} + if(_mapOutline) {_mapOutline -> Delete();} + if(_outline) {_outline -> Delete();} +// if (_bwLut) {_bwLut -> Delete();} +// if (_hueLut) {_hueLut -> Delete();} +// if (_satLut) {_satLut -> Delete();} + if (_ctfun) {_ctfun -> Delete();} + if (_saggitalColors) {_saggitalColors -> Delete();} + if (_saggital) {_saggital -> Delete();} + if (_axialColors) {_axialColors -> Delete();} + if (_axial) {_axial -> Delete();} + if (_coronalColors) {_coronalColors -> Delete();} + if (_coronal) {_coronal -> Delete();} } + //------------------------------------------------------------------- vtkActor* vtkMPR3DDataViewer::GetOutlineActor() { return _outline; } + //------------------------------------------------------------------- vtkImageActor* vtkMPR3DDataViewer::GetImageActor(int id) { @@ -143,18 +143,25 @@ void vtkMPR3DDataViewer::SetImage() { //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 - _saggitalColors ->SetInput( _vtkmprbasedata->GetImageData() ); - _axialColors ->SetInput( _vtkmprbasedata->GetImageData() ); - _coronalColors ->SetInput( _vtkmprbasedata->GetImageData() ); - _outlineData ->SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() ); + _saggitalColors -> SetInput( _vtkmprbasedata->GetImageData() ); + _axialColors -> SetInput( _vtkmprbasedata->GetImageData() ); + _coronalColors -> SetInput( _vtkmprbasedata->GetImageData() ); + _outlineData -> SetInput((vtkDataSet *) _vtkmprbasedata->GetImageData() ); #else - _saggitalColors ->SetInputData( _vtkmprbasedata->GetImageData() ); - _axialColors ->SetInputData( _vtkmprbasedata->GetImageData() ); - _coronalColors ->SetInputData( _vtkmprbasedata->GetImageData() ); - _outlineData ->SetInputData((vtkDataSet *) _vtkmprbasedata->GetImageData() ); + _saggitalColors -> SetInputData( _vtkmprbasedata->GetImageData() ); + _axialColors -> SetInputData( _vtkmprbasedata->GetImageData() ); + _coronalColors -> SetInputData( _vtkmprbasedata->GetImageData() ); + +//EED 2020-01-27 this is to slow ??? how can we accelerated +// _saggitalColors -> Update(); +// _axialColors -> Update(); +// _coronalColors -> Update(); + + _outlineData -> SetInputData((vtkDataSet *) _vtkmprbasedata->GetImageData() ); #endif } + //------------------------------------------------------------------- void vtkMPR3DDataViewer::Configure() { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h index 38c2a0f..bdd59c2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h @@ -61,35 +61,27 @@ public: void SetPositionZ(int pos); void SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata); vtkMPRBaseData* GetVtkMPRBaseData(); - vtkColorTransferFunction *GetvtkColorTransferFunction(); std::vector *GetctFunVectorPoint(); std::vector *GetctFunVectorRed(); std::vector *GetctFunVectorGreen(); std::vector *GetctFunVectorBlue(); - void setColorTransferFunction(vtkColorTransferFunction* colortable); - private: - bool _visiblePosition[3]; - // outline vtkOutlineFilter *_outlineData; vtkPolyDataMapper *_mapOutline; vtkActor *_outline; - // vtkColorTransferFunction *_ctfun; std::vector _ctFunVectorPoint; std::vector _ctFunVectorRed; std::vector _ctFunVectorGreen; std::vector _ctFunVectorBlue; - // vtkLookupTable *_bwLut; // vtkLookupTable *_hueLut; // vtkLookupTable *_satLut; - vtkImageMapToColors *_saggitalColors; vtkImageActor *_saggital; vtkImageMapToColors *_axialColors; @@ -97,8 +89,6 @@ private: vtkImageMapToColors *_coronalColors; vtkImageActor *_coronal; vtkMPRBaseData *_vtkmprbasedata; - - }; #endif /*VTKMPR3DDATAVIEWER_H_*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx index b1cdee3..b8aac46 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx @@ -446,14 +446,14 @@ void wxMaracas_ViewerWidget::SetImage( vtkImageData *image ) { mwxsphereview->SetImage(); } - if (mwxvtkclipping3Dview!=NULL) - { - mwxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetImage(); - } if (mwxvtkmpr3Dview!=NULL) { mwxvtkmpr3Dview->SetImage(); } + if (mwxvtkclipping3Dview!=NULL) + { + mwxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetImage(); + } //EED 26/11/2009 // ConfigureVTK(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx index ff657c2..1537162 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx @@ -330,9 +330,35 @@ void wxVtkMPR3DView::SetImage() // -- Plane widget _probe->SetSource( imageData ); #else + + + double colorWindow = _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorWindow(); + double colorLevel = _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorLevel(); + + double spc[3]; + vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); + if(image) + { + image->GetSpacing(spc); + }else{ + spc[0] = 0; + spc[1] = 0; + spc[2] = 0; + } + double x = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX(); + double y = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY(); + double z = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ(); + _planeWidgetX->SetInputData( imageData ); + _planeWidgetX->SetWindowLevel(colorWindow,colorLevel,1); + _planeWidgetX->SetSlicePosition( x*spc[0] ); _planeWidgetY->SetInputData( imageData ); + _planeWidgetY->SetWindowLevel(colorWindow,colorLevel,1); + _planeWidgetY->SetSlicePosition( y*spc[1] ); _planeWidgetZ->SetInputData( imageData ); + _planeWidgetZ->SetWindowLevel(colorWindow,colorLevel,1); + _planeWidgetZ->SetSlicePosition( z*spc[2] ); + // -- Plane widget _probe->SetSourceData( imageData ); #endif @@ -342,9 +368,8 @@ void wxVtkMPR3DView::SetImage() //------------------------------------------------------------------- vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker) { - vtkProperty* prop1 = 0; - vtkImagePlaneWidget* planeWidget = 0; - planeWidget = vtkImagePlaneWidget::New(); + vtkProperty* prop1 = NULL; + vtkImagePlaneWidget* planeWidget = vtkImagePlaneWidget::New(); planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() ); planeWidget->EnabledOff(); vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); @@ -486,7 +511,6 @@ void wxVtkMPR3DView::RefreshView() // virtual { double spc[3]; vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); - if(image) { image->GetSpacing(spc); @@ -505,9 +529,6 @@ void wxVtkMPR3DView::RefreshView() // virtual double y = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY(); double z = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ(); - SetColorWindow( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorWindow() ); - SetColorLevel( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetColorLevel() ); - double normal[3]; // FreePlaneX _planeWidgetX->GetNormal(normal); @@ -536,7 +557,7 @@ void wxVtkMPR3DView::RefreshView() // virtual _planeWidgetZ->GetReslice()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() ); _planeWidgetZ->GetTexture()->SetInterpolate( _vtkmpr3Ddataviewer->GetVtkMPRBaseData()->GetInterpolate() ); } - + x=x*spc[0]; y=y*spc[1]; z=z*spc[2]; @@ -598,7 +619,8 @@ wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*) //------------------------------------------------------------------- //------------------------------------------------------------------- -void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){ +void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible) +{ /*if(visible == false) printf("CPR: wxVtkMPR3DView::VisibleImageActor-> visibleActor == false \n"); else @@ -608,7 +630,8 @@ void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){ } */ if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){ - if (visible==false){ + if (visible==false) + { _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) ); } else { //EED 21/07/2013 @@ -707,18 +730,13 @@ void wxVtkMPR3DView::InitOrientationPointWidget() } //------------------------------------------------------------------- -void wxVtkMPR3DView::SetColorWindow(double colorWindow) +void wxVtkMPR3DView::SetWindowColorLevel(double colorWindow , double colorLevel) { - double colorLevel = _planeWidgetX->GetLevel(); _planeWidgetX->SetWindowLevel(colorWindow,colorLevel); + _planeWidgetY->SetWindowLevel(colorWindow,colorLevel); + _planeWidgetZ->SetWindowLevel(colorWindow,colorLevel); } -//------------------------------------------------------------------- -void wxVtkMPR3DView::SetColorLevel(double colorLevel) -{ - double colorWindow = _planeWidgetX->GetWindow(); - _planeWidgetX->SetWindowLevel(colorWindow,colorLevel); -} //------------------------------------------------------------------- // EED 25 Janvier 2007 testLoic diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h index 5ab97aa..4eb27ee 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h @@ -70,13 +70,16 @@ public: //Free planes //------------------------------------------------------------------- - void ConfigureFreePlanes(); - vtkImagePlaneWidget* GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker); - void FreePlaneVisible(int plane, bool ok); - void FreePlaneInteraction(bool ok); - void SetFreePlanesOrtho(); - void SetColorWindow(double colorWindow); - void SetColorLevel(double colorLevel); + void ConfigureFreePlanes(); + vtkImagePlaneWidget* GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker); + void FreePlaneVisible(int plane, bool ok); + void FreePlaneInteraction(bool ok); + void SetFreePlanesOrtho(); +/*Borrame + void SetColorWindow(double colorWindow); + void SetColorLevel(double colorLevel); +*/ + void SetWindowColorLevel(double colorWindow , double colorLevel); private: wxVtk3DBaseView *_wxvtk3Dbaseview; -- 2.47.1