From 8ea92967e26f1a77c53a82d2f62410437b56ea38 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Fri, 3 Jan 2025 11:53:44 +0100 Subject: [PATCH] #3570 refresh optimization vtkBaseView ColorLayer --- bbtk/src/bbcreaMaracasVisuSetPosition.cxx | 10 +- .../bbcreaMaracasVisuwxVtkBaseView_Info.cxx | 1 + bbtk/src/bbmaracasvisuViewerNV.cxx | 8 +- .../ThresholdImageView/LayerImageBase.cxx | 91 +++++++++++++------ .../ThresholdImageView/LayerImageBase.h | 8 +- .../manualContour/manualViewContour.cpp | 2 +- .../widgets/vtkInteractorStyleMPRView.cxx | 12 +-- .../widgets/wxMaracas_N_ViewersWidget.cxx | 15 +-- .../widgets/wxMaracas_ViewerWidget.cxx | 16 ++-- .../wxWindows/widgets/wxVtk2DBaseView.h | 3 +- .../wxWindows/widgets/wxVtkBaseView.cxx | 19 +++- .../wxWindows/widgets/wxVtkMPR2DView.cxx | 19 ++-- .../widgets/wxVtkMPR3DViewCntrlPanel.cxx | 85 ++--------------- 13 files changed, 123 insertions(+), 166 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuSetPosition.cxx b/bbtk/src/bbcreaMaracasVisuSetPosition.cxx index c4a8677..7d543f8 100644 --- a/bbtk/src/bbcreaMaracasVisuSetPosition.cxx +++ b/bbtk/src/bbcreaMaracasVisuSetPosition.cxx @@ -16,7 +16,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(SetPosition,bbtk::AtomicBlackBox); //===== void SetPosition::Process() { -auto start1 = std::chrono::high_resolution_clock::now(); + // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -30,6 +30,7 @@ auto start1 = std::chrono::high_resolution_clock::now(); // (the one provided in the attribute 'type' of the tag 'input') if (bbGetInputActive()==true) { +//auto start1 = std::chrono::high_resolution_clock::now(); if (bbGetInputwxVtkBaseView()!=NULL) { vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (bbGetInputwxVtkBaseView()->GetVtkBaseData()); @@ -57,10 +58,11 @@ auto start1 = std::chrono::high_resolution_clock::now(); vtkmprbasedata->SetFixAxis2D( tmpFixAxis ); } // if bbGetInputPosition } // bbGetInputwxVtkBaseView +//auto stop1 = std::chrono::high_resolution_clock::now(); +//auto duration1 = std::chrono::duration_cast(stop1 - start1); +//printf("EED SetPosition::Process time= %ld %s \n", duration1.count() , this->bbGetFullName().c_str() ); } // Active -auto stop1 = std::chrono::high_resolution_clock::now(); -auto duration1 = std::chrono::duration_cast(stop1 - start1); -printf("EED SetPosition::Process time= %ld \n", duration1.count() , this->bbGetFullName().c_str() ); + } //===== diff --git a/bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx b/bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx index a9e32f1..92f79a7 100644 --- a/bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx +++ b/bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx @@ -136,6 +136,7 @@ bool InteractorwxVtkBaseView::OnMouseMove() { if (_box!=NULL) { + // int intFlag; // if (flagDrag==true) intFlag=1; else intFlag=0; bool ok=false; diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 51c2edf..9eaa30e 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -61,6 +61,8 @@ bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget() //------------------------------------------------------------- void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) { + //EED2024-12-23 Refresh syncronisation (maracasvisu and bbtk) + wxMaracas_N_ViewersWidget::OnRefreshView(event); if ( (backX!=(int)GetX()) || (backY!=(int)GetY()) || (backZ!=(int)GetZ()) ) { backX = GetX(); @@ -76,15 +78,11 @@ void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) bool ok=true; if (mbbViewerNV->bbGetInputReactivityType()==0) { ok=false; } mbbViewerNV->bbSignalOutputModification(std::string("Point"),ok); - // if (mbbViewerNV->bbGetInputReactivityType()==1) // { // mbbViewerNV->bbSignalOutputModification(std::string("Point"),true); -// } // if type - +// } // if type } // if X Y Z - - wxMaracas_N_ViewersWidget::OnRefreshView(event); } //------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index bb46f4b..d09fbab 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -44,23 +44,19 @@ class ColorLayerObserver : public vtkCommand{ public: virtual char const *GetClassName() const { return "ColorLayerObserver";} - static ColorLayerObserver *New() { return new ColorLayerObserver; } - ColorLayerObserver() { _layerimagebase = NULL; } - - virtual void Execute(vtkObject *wdg, unsigned long event, void* calldata) + + virtual void Execute(vtkObject *wdg, unsigned long event, void* calldata) { if (_layerimagebase!= NULL) { - wxVtkBaseView *wxvtkbaseview = _layerimagebase->GetwxVtkBaseView(); if (wxvtkbaseview!=NULL) { - vtkMPRBaseData *vtkmprbasedata = (vtkMPRBaseData*)wxvtkbaseview->GetVtkBaseData(); if (vtkmprbasedata!=NULL) { @@ -69,16 +65,15 @@ class ColorLayerObserver : public vtkCommand{ _layerimagebase->SetZ( vtkmprbasedata->GetZ() ); _layerimagebase->onThresholdChange(); } // if basedata - } // if wxvtkbaseview } //if layerimagebase } - + void SetLayerImageBase(LayerImageBase* layerimagebase) { _layerimagebase = layerimagebase; } - + private: LayerImageBase* _layerimagebase; }; @@ -97,12 +92,16 @@ LayerImageBase::LayerImageBase() _X = -1; _Y = -1; _Z = -1; + _Xback = -9999; + _Yback = -9999; + _Zback = -9999; _opacity = 1; _thresholdTable = NULL; _thresholdMapper = NULL; _scalarbarActor = NULL; _thresholdActor = NULL; _image = NULL; + _imageBack = NULL; _baseView = NULL; _imageReslicer = vtkImageReslice::New(); _imageChangeInformation = vtkImageChangeInformation::New(); @@ -439,23 +438,59 @@ void LayerImageBase::CleanXYZ(double &x, double &y, double &z) //---------------------------------------------------------------------------- void LayerImageBase::onThreshold() { - if ((_image!=NULL) && (_baseView!=NULL)) + bool ok = false; + int directionViewer=0; + if (_baseView!=NULL) + { + vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera(); + if (camera->GetParallelProjection()==1) + { + wxVtk2DBaseView *wxvtk2dbasevie = (wxVtk2DBaseView *)_baseView; + directionViewer = wxvtk2dbasevie->GetDirection(); + } // ParallelProjection + + if (directionViewer==0) + { + if (GetX()!=_Xback) + { + _Xback = GetX(); + ok=true; + } // if _Yback + } + + if (directionViewer==1) + { + if (GetY()!=_Yback) + { + _Yback = GetY(); + ok=true; + } // if _Yback + } + + if (directionViewer==2) + { + if (GetZ()!=_Zback) + { + _Zback = GetZ(); + ok=true; + } // if _Yback + } + if (_image!=_imageBack) + { + _imageBack=_image; + ok=true; + } + } + + if ( (_image!=NULL) && (_baseView!=NULL) && (ok==true) ) { - double x=GetX(); - double y=GetY(); - double z=GetZ(); - x = x*_spcBase[0]; - y = y*_spcBase[1]; - z = z*_spcBase[2]; - CleanXYZ(x,y,z); - vtkCamera *camera = _baseView->GetRenderer()->GetActiveCamera(); - int directionViewer=0; - if (camera->GetParallelProjection()==1) - { - wxVtk2DBaseView *wxvtk2dbasevie = (wxVtk2DBaseView *)_baseView; - directionViewer = wxvtk2dbasevie->GetDirection(); - } // ParallelProjection - + double x = GetX(); + double y = GetY(); + double z = GetZ(); + x = x*_spcBase[0]; + y = y*_spcBase[1]; + z = z*_spcBase[2]; + CleanXYZ(x,y,z); if (!GetActorPresent()) { if (_thresholdTable==NULL) @@ -500,7 +535,7 @@ void LayerImageBase::onThreshold() } // !GetActorPresent() ConfigLookupTable(); // virtual method - + //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 _imageReslicer->SetInput( GetImage() ); @@ -569,13 +604,13 @@ void LayerImageBase::onThreshold() int fontsize = _scalarbarActor->GetLabelTextProperty()->GetFontSize(); _scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2); // _scalarbarActor->SetTextPad(4); ?? - } // if _image + } // if _image _baseView ok } //---------------------------------------------------------------------------- void LayerImageBase::onThresholdChange() { - if (_actorPresent) + if ( (_actorPresent) && (_opacity!=0) ) { onThreshold(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h index 482b6fa..e849c20 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.h @@ -72,13 +72,9 @@ protected: }; - //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- - - - class LayerImageBase { public: @@ -126,6 +122,9 @@ class LayerImageBase int _X; int _Y; int _Z; + int _Xback; + int _Yback; + int _Zback; bool _actorPresent; int _dimOriginalLayer[3]; double _spcOriginalLayer[3]; @@ -135,6 +134,7 @@ class LayerImageBase double _opacity; vtkImageData *_image; + vtkImageData *_imageBack; vtkImageChangeInformation *_imageChangeInformation; vtkImageReslice *_imageReslicer; vtkLookupTable *_thresholdTable; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index 24dada5..35f9655 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -362,7 +362,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z) d1 = sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz)); d2 = sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz)); d3 = sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2])); - if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) + if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*3.3) ) { result = true; i = nps; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx index 3dacf1a..6d0a498 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleMPRView.cxx @@ -38,7 +38,6 @@ vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView() { } - //--------------------------------------------------------------------------- bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual { @@ -61,11 +60,9 @@ bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1); wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent2); #endif - - - return true; } + //--------------------------------------------------------------------------- bool vtkInteractorStyleMPRView::OnLeftButtonDown () { @@ -121,14 +118,11 @@ bool vtkInteractorStyleMPRView::OnMouseMove () { double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; - double z=1; _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z); wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); -// wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z); - +// wxvtkmpr2Dview->TransfromCoordViewWorld(x,y,z); wxvtkmpr2Dview->ChangeAxisColor(x,y,z); - if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) ) { if (_stateMoveAxisX==true) @@ -143,9 +137,7 @@ bool vtkInteractorStyleMPRView::OnMouseMove () { wxvtkmpr2Dview->MoveZ(x,y,z); } - this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); } return true; } - diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx index 5c1d782..9890f92 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx @@ -160,6 +160,7 @@ { RefreshView(); } + //---------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event) { @@ -281,10 +282,8 @@ spliter->SetSashGravity(0.5); spliterA->SetSashGravity(0.5); spliterB->SetSashGravity(0.5); - spliter -> SplitVertically( spliterA , spliterB ); - //EED 21 mars 2012 FLIP probleme ..PLOP.. // wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0], mvtkmprbasedata); // wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1], mvtkmprbasedata); @@ -299,11 +298,9 @@ wxwindow4 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[3], mvtkmprbasedata,nTDxWindow==3); spliterA-> SplitHorizontally( wxwindow3 , wxwindow4 ); spliterB-> SplitHorizontally( wxwindow2 , wxwindow1 ); - wxwindow = spliter; } - //panel->SetDimension() sizer->Add( wxwindow , 1, wxGROW); @@ -336,8 +333,6 @@ void wxMaracas_N_ViewersWidget::SetTDxWindow(int tdxwindow) nTDxWindow = tdxwindow; } - - //----------------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image ) { @@ -348,7 +343,6 @@ void wxMaracas_N_ViewersWidget::SetTDxWindow(int tdxwindow) // ConfigureVTK(); } - //----------------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::ConfigureVTK() { @@ -374,7 +368,6 @@ double wxMaracas_N_ViewersWidget :: GetY() // return wxwindow1->GetY(); } - //----------------------------------------------------------------------------------- double wxMaracas_N_ViewersWidget :: GetZ() { @@ -399,17 +392,14 @@ void wxMaracas_N_ViewersWidget::setColorTransferFunction(vtkColorTransferFunctio { wxwindow1->setColorTransferFunction(colortable); } - if (wxwindow2!=NULL) { wxwindow2->setColorTransferFunction(colortable); } - if (wxwindow3!=NULL) { wxwindow3->setColorTransferFunction(colortable); } - if (wxwindow4!=NULL) { wxwindow4->setColorTransferFunction(colortable); @@ -423,17 +413,14 @@ void wxMaracas_N_ViewersWidget::SetColorWindowLevel(double colorWindow, double c { wxwindow1->SetColorWindowLevel(colorWindow, colorLevel); } - if (wxwindow2!=NULL) { wxwindow2->SetColorWindowLevel(colorWindow, colorLevel); } - if (wxwindow3!=NULL) { wxwindow3->SetColorWindowLevel(colorWindow, colorLevel); } - if (wxwindow4!=NULL) { wxwindow4->SetColorWindowLevel(colorWindow, colorLevel); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx index 2bb8a84..eaf3975 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx @@ -356,10 +356,9 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) wxPanel::Refresh(false); } - //------------------------------------------------------------------------- - void wxMaracas_ViewerWidget::RefreshView() - { -//printf("EED wxMaracas_ViewerWidget::RefreshView %p\n", this); +//------------------------------------------------------------------------- +void wxMaracas_ViewerWidget::RefreshView() +{ if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview ->RefreshView(); } if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview ->Refresh(); } if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D ->Refresh(); } @@ -369,12 +368,11 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) if (mvtkmpr2Dview_Z !=NULL ){ mvtkmpr2Dview_Z ->Refresh(); } if (mvtkplane2Dview !=NULL ){ mvtkplane2Dview ->Refresh(); } if (mwxsphereview !=NULL ){ mwxsphereview ->RefreshView(); } - } - - //------------------------------------------------------------------------- +} - wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView() - { +//------------------------------------------------------------------------- +wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView() +{ wxVtkBaseView *wxvtkbaseview=NULL; if (mvtk2Dbaseview!=NULL) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h index d322fff..20ab223 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h @@ -37,7 +37,8 @@ class vtkInfoTextImageInteractor; //------------------------------------------------------------------ -class creaMaracasVisu_EXPORT wxVtk2DBaseView: public wxVtkBaseView{ +class creaMaracasVisu_EXPORT wxVtk2DBaseView: public wxVtkBaseView +{ public: wxVtk2DBaseView(wxWindow *parent,bool TDxWindow=false); virtual ~wxVtk2DBaseView(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx index 99c7a36..81e2caa 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx @@ -31,6 +31,9 @@ #include "wxVtk2DBaseView.h" #include "wxVTKRenderWindowInteractorPlus.h" +#include +#include +#include wxVtkBaseView::wxVtkBaseView() @@ -88,8 +91,9 @@ crea::wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor void wxVtkBaseView::Configure() // virtual { } + //------------------------------------------------------------------- -void wxVtkBaseView::Refresh() // virtual +void wxVtkBaseView::Refresh() // virtual { // EED 10 Oct 2007 #if defined(WIN32) @@ -101,10 +105,19 @@ void wxVtkBaseView::Refresh() // virtual //EED 01Avril2009 // _iren->Render(); vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor(); - vri->vtkRenderWindowInteractor::Render(); + +//auto start1 = std::chrono::high_resolution_clock::now(); + + vri->vtkRenderWindowInteractor::Render(); + +//auto stop1 = std::chrono::high_resolution_clock::now(); +//auto duration1 = std::chrono::duration_cast(stop1 - start1); +//printf("EED wxVtkBaseView::Refresh time= %ld %p direction=%d \n", duration1.count() , vri , GetDirection() ); + //_iren->Refresh(); #endif } + //------------------------------------------------------------------- void wxVtkBaseView::RefreshView() // virtual { @@ -115,11 +128,13 @@ void wxVtkBaseView::RefreshView() // virtual //GetRenWin()->Render(); #endif } + //--------------------------------------------------------------------------- vtkRenderer* wxVtkBaseView::GetRenderer() // virtual { return NULL; } + //--------------------------------------------------------------------------- vtkRenderWindow* wxVtkBaseView::GetRenWin() // virtual { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx index afe7d1a..b467559 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx @@ -248,7 +248,6 @@ void wxVtkMPR2DView::SetVisibleAxis(bool ok) } // ok } - //------------------------------------------------------------------- void wxVtkMPR2DView::ResetBackXYZ() { @@ -257,7 +256,6 @@ void wxVtkMPR2DView::ResetBackXYZ() _backZ = -9999; } - //------------------------------------------------------------------- void wxVtkMPR2DView::Refresh() { @@ -299,9 +297,9 @@ void wxVtkMPR2DView::Refresh() xx = (int)(GetVtkmprbasedata()->GetX()); yy = (int)(GetVtkmprbasedata()->GetY()); zz = (int)(GetVtkmprbasedata()->GetZ()); - x = xx*spc[0]; - y = yy*spc[1]; - z = zz*spc[2]; + x = xx*spc[0]; + y = yy*spc[1]; + z = zz*spc[2]; fixAxis2D = GetVtkmprbasedata()->GetFixAxis2D(); opacityAxis = GetVtkmprbasedata()->GetOpacityAxis(); if ((xx!=_backX) || (yy!=_backY) || (zz!=_backZ) || (fixAxis2D!=_backFixAxis2D) || (opacityAxis!=_backOpacityAxis)) @@ -566,7 +564,6 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) { double c1r=1,c1g=1,c1b=0; double c2r=1,c2g=0,c2b=0; - if (_direction==0) { if (IfMouseTouchY(x,y,z)==true) @@ -581,8 +578,7 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) } else { _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b); } - } - + } // if _direction==0 if (_direction==1) { if (IfMouseTouchX(x,y,z)==true) @@ -597,8 +593,7 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) } else { _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b); } - } - + } // if _direction==1 if (_direction==2) { if (IfMouseTouchX(x,y,z)==true) @@ -613,8 +608,8 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) } else { _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b); } - } - Refresh(); + } // if _direction==2 +// Refresh(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx index 5541ae1..90b793d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DViewCntrlPanel.cxx @@ -96,8 +96,6 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV _ckBoxOutlinePlane = new wxCheckBox(panel,-1,_T("Outline Plane")); _ckBoxOutlinePlane->SetValue(true); - - // _ckBoxBackGroundBlack= new wxCheckBox(panel,-1,_T("Background Black"));; // _ckBoxBackGroundBlack->SetValue(false); // EED Borrame @@ -176,14 +174,11 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV wxFlexGridSizer *sizerH5; wxFlexGridSizer *sizerH6; wxFlexGridSizer *sizerH7; - if(align) { sizer = new wxFlexGridSizer(4); sizerH4 = new wxFlexGridSizer(3); - sizerH4a = new wxFlexGridSizer(3); - sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); sizerH4->Add( new wxStaticText(panel, -1,_T("GL")) ,1, wxALL|wxEXPAND , 0); sizerH4->Add( new wxStaticText(panel, -1,_T("Color ")),1, wxALL|wxEXPAND , 0); @@ -196,7 +191,6 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV sizerH4->Add( _positionZ ,1, wxGROW , 0); sizerH4->Add( _ckFreePlaneZ ,1, wxALL|wxEXPAND , 0); sizerH4->Add( _ckBoxZ ,0, wxALIGN_CENTER_VERTICAL|wxSHAPED , 0); - //EED 2016/02/19 sizerH4->Add( _ckBoxInterpolate ,1, wxALL|wxEXPAND , 0); sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); @@ -204,18 +198,13 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV // sizerH4->Add( _ckBoxXYZ ,1, wxALL|wxEXPAND , 0); // sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); // sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); - // sizerH4a->Add( new wxStaticText(panel, -1,_T("Axis 2D:")),1, wxALL|wxEXPAND , 0); sizerH4a->Add( _ckBoxXYZ ,1, wxALL|wxEXPAND , 0); sizerH4a->Add( _ckBoxFixAxis2D ,1, wxALL|wxEXPAND , 0); sizerH4a->Add( _opacityAxis ,1, wxALL|wxEXPAND , 0); - sizerH4->Add( sizerH4a ,1, wxALL|wxEXPAND , 0); sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); sizerH4->Add( new wxStaticText(panel, -1,_T(" ")) ,1, wxALL|wxEXPAND , 0); - - - sizerH5 = new wxFlexGridSizer(1); sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0); sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND , 0); @@ -227,34 +216,24 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV sizerH5->Add( btnColorTable , 0, wxALIGN_CENTER_VERTICAL|wxSHAPED , 0); sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0); sizerH5->Add( _cbStereo , 1, wxALL|wxEXPAND , 0); - sizerH6 = new wxFlexGridSizer(1); sizerH6->Add( _ckBoxOutlineBox , 1, wxALL|wxEXPAND , 0); sizerH6->Add( _ckBoxOutlinePlane , 1, wxALL|wxEXPAND , 0); - - - sizerH7 = new wxFlexGridSizer(1); panelH7->SetSizer(sizerH7); sizerH7->Add( _rdBackGroundGradient , 1, wxALL|wxEXPAND , 0); sizerH7->Add( _rdBackGroundBlack , 1, wxALL|wxEXPAND , 0); sizerH7->Add( _rdBackGroundWhite , 1, wxALL|wxEXPAND , 0); - - sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0); sizerH6->Add( panelH7 , 1, wxALL|wxEXPAND , 0); - sizer->Add( sizerH4, 1, wxALL|wxGROW, 2); sizer->Add( sizerH5, 1, wxALL|wxEXPAND,2); sizer->Add( sizerH6, 1, wxALL|wxEXPAND,2); - } else { sizer = new wxFlexGridSizer(1); - sizerH4 = new wxFlexGridSizer(10); sizerH5 = new wxFlexGridSizer(10); sizerH6 = new wxFlexGridSizer(10); - sizerH4->Add( _positionX , 1, wxGROW , 0 ); sizerH4->Add( _ckBoxX , 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 ); sizerH4->Add( _positionY , 1, wxGROW , 0 ); @@ -262,12 +241,10 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV sizerH4->Add( _positionZ , 1, wxGROW , 0 ); sizerH4->Add( _ckBoxZ , 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 ); sizerH4->Add( btnColorTable , 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 ); - sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0); sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0); ////EED 05Nov2012 sizerH5->Add( _ckBox_BW_Color_Plane , 1, wxALL|wxEXPAND, 0); sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0); - sizerH6 = new wxFlexGridSizer(10); sizerH6->Add( _ckFreePlaneX , 1, wxALL|wxEXPAND, 0); sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0); @@ -280,58 +257,40 @@ wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DV sizerH6->Add( btnFreePlanesOrtho , 0 , wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 ); sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0); sizerH6->Add( _cbStereo, 1, wxALL|wxEXPAND, 0); - sizer->Add( sizerH4, 1, wxALL|wxGROW, 2); sizer->Add( sizerH5, 1, wxALL|wxEXPAND,2); sizer->Add( sizerH6, 1, wxALL|wxEXPAND,2); } - - - - //EED 28 sep 2006 // wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10); - // sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0); // sizerH4->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0); // sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0); - // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0); // sizerH5->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0); // sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0); - // sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0); // sizerH6->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0); // sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0); - // sizerH7->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0); // sizerH7->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0); - // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2); // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2); // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2); // sizer->Add( sizerH7 , 1, wxALL|wxEXPAND, 2); - - // sizerH5->Add( ckBoxX , 1, wxALL|wxEXPAND, 0); // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0); // sizerH5->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0); - - panelH7->SetAutoLayout(true); panelH7->Layout(); - - panel->ClearBackground(); // panel->SetSize(400,50); // sizer->FitInside(panel); panel->SetSizer(sizer); panel->SetAutoLayout(true); panel->Layout(); - panel->SetEventHandler((wxEvtHandler*)this); - //this->UpdateControlPanel(); Layout(); } @@ -341,17 +300,14 @@ void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel(bool firsttime) { vtkMPRBaseData* basedata = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData(); if(basedata != NULL){ - vtkImageData* img = basedata->GetImageData(); int x0,x1,y0,y1,z0,z1; - if(img) { img->GetExtent(x0,x1,y0,y1,z0,z1); _positionX->SetRange(x0,x1); _positionY->SetRange(y0,y1); _positionZ->SetRange(z0,z1); - if (firsttime==true) { _positionX->SetValue((x0+x1)/2); @@ -365,9 +321,7 @@ void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel(bool firsttime) // _positionZ->Update(); // this->Update(); }//img - - }//basedata - + }//basedata } //------------------------------------------------------------------- @@ -420,7 +374,6 @@ int wxVtkMPR3DViewCntrlPanel::GetIdTissue() //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event) { - vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); if ( imagedata->GetScalarType()!=VTK_UNSIGNED_SHORT ) @@ -429,21 +382,14 @@ void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event) windowMessage1.ShowModal(); return; } - vtkColorTransferFunction *ctfun = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetvtkColorTransferFunction(); std::vector *ctfunVectorPoint = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorPoint(); std::vector *ctfunVectorRed = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorRed(); std::vector *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen(); std::vector *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue(); - //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx - - int i=0,xi,r,g,b; - HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2); - - hDlg->erasePointsTransferenceFunction(); int ctfSize=ctfunVectorRed->size(); if(ctfSize>0) @@ -455,23 +401,17 @@ void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event) double gr = (*ctfunVectorPoint)[i]; double r = (*ctfunVectorRed)[i]; double g = (*ctfunVectorGreen)[i]; - double b = (*ctfunVectorBlue)[i]; - + double b = (*ctfunVectorBlue)[i]; hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255)); - i++; } } - // // when the user had changed the transference Function // - //setting variables if the user wants to do refresh - hDlg->setCTF(ctfun); //hDlg->setMPR3Dview(_wxvtkmpr3Dview); - if(hDlg->ShowModal()== wxID_OK ) { // -- vtkColorTransferFunction -- @@ -521,14 +461,11 @@ void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event) double blue = (*ctfunVectorBlue)[i]; ctfun->AddRGBPoint(grey2,red,green,blue); } - } - + } } - hDlg->Destroy(); } - //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneX(wxCommandEvent& event) { @@ -543,7 +480,6 @@ void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneY(wxCommandEvent& event) _wxvtkmpr3Dview->FreePlaneInteraction( _ckFreePlaneInteraction->GetValue() ); } - //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneZ(wxCommandEvent& event) { @@ -551,7 +487,6 @@ void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneZ(wxCommandEvent& event) _wxvtkmpr3Dview->FreePlaneInteraction( _ckFreePlaneInteraction->GetValue() ); } - //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneInteraction(wxCommandEvent& event) { @@ -570,8 +505,6 @@ void wxVtkMPR3DViewCntrlPanel::OnSetStereo(wxCommandEvent& event) this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->SetStereo( _cbStereo->GetSelection() ); } - - //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event) { @@ -591,6 +524,7 @@ void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event) std::cout<GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1); #endif } + //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event) { @@ -622,7 +557,6 @@ void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event) //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event) { - _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked()); } @@ -635,9 +569,7 @@ void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event) //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event) { - _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() , true ); - _wxvtkmpr3Dview->RefreshView(); - + _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() , true ); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 #if wxMAJOR_VERSION <= 2 @@ -645,13 +577,13 @@ void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event) #else _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1); #endif + _wxvtkmpr3Dview->RefreshView(); } //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event) { _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() , true); - _wxvtkmpr3Dview->RefreshView(); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 #if wxMAJOR_VERSION <= 2 @@ -659,13 +591,13 @@ void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event) #else _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1); #endif + _wxvtkmpr3Dview->RefreshView(); } //------------------------------------------------------------------- void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event) { _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() , true ); - _wxvtkmpr3Dview->RefreshView(); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 #if wxMAJOR_VERSION <= 2 @@ -673,6 +605,7 @@ void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event) #else _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessWindowEvent(newevent1); #endif + _wxvtkmpr3Dview->RefreshView(); } //------------------------------------------------------------------- -- 2.49.0