From 40dfa1616e1203ecccb8163e7722c76769eddfe3 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Thu, 11 Oct 2012 10:45:15 +0000 Subject: [PATCH] Bug #1679 Refresh ViewerNV (initialice window level, color level, camera settings) --- bbtk/src/bbmaracasvisuDrawAxe3D.cxx | 5 -- bbtk/src/bbmaracasvisuViewerNV.cxx | 79 ++++++++----------- bbtk/src/bbmaracasvisuViewerNV.h | 11 ++- .../manualContour/manualViewContour.cpp | 3 +- .../widgets/wxMaracas_N_ViewersWidget.cxx | 9 ++- .../widgets/wxMaracas_ViewerWidget.cxx | 52 +++++++++--- .../wxWindows/widgets/wxVtk2DBaseView.cxx | 22 ++++-- .../wxWindows/widgets/wxVtk2DBaseView.h | 1 + .../wxWindows/widgets/wxVtkBaseView.cxx | 3 +- .../wxWindows/widgets/wxVtkMPR2DView.cxx | 9 ++- 10 files changed, 109 insertions(+), 85 deletions(-) diff --git a/bbtk/src/bbmaracasvisuDrawAxe3D.cxx b/bbtk/src/bbmaracasvisuDrawAxe3D.cxx index cd9997b..5736969 100644 --- a/bbtk/src/bbmaracasvisuDrawAxe3D.cxx +++ b/bbtk/src/bbmaracasvisuDrawAxe3D.cxx @@ -15,8 +15,6 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxe3D) BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox); void DrawAxe3D::Process() { - printf("EED DrawAxe3D::Process start \n"); - std::vector< double > vectx = bbGetInputlstPointX(); std::vector< double > vecty = bbGetInputlstPointY(); std::vector< double > vectz = bbGetInputlstPointZ(); @@ -61,9 +59,6 @@ void DrawAxe3D::Process() firsttime=false; bbGetInputRenderer()->AddActor( mvtkactor ); } - - printf("EED DrawAxe3D::Process end \n"); - } void DrawAxe3D::bbUserSetDefaultValues() diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 137b012..c8e287f 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -31,12 +31,12 @@ bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget() void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) { //printf("CPR: bbwxMaracas_N_ViewersWidget::OnRefreshView -> actualiza X, Y y Z\n"); - mbbViewerNV->point.clear(); + mbbViewerNV->_point.clear(); - mbbViewerNV->point.push_back( (int)GetX() ); - mbbViewerNV->point.push_back( (int)GetY() ); - mbbViewerNV->point.push_back( (int)GetZ() ); - mbbViewerNV->bbSetOutputPoint( mbbViewerNV->point ); + mbbViewerNV->_point.push_back( (int)GetX() ); + mbbViewerNV->_point.push_back( (int)GetY() ); + mbbViewerNV->_point.push_back( (int)GetZ() ); + mbbViewerNV->bbSetOutputPoint( mbbViewerNV->_point ); mbbViewerNV->bbSignalOutputModification(std::string("Point")); wxMaracas_N_ViewersWidget::OnRefreshView(event); @@ -60,9 +60,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox); //------------------------------------------------------------- void ViewerNV::Process() { - - printf("EED ViewerNV::Process start \n"); - vtkImageData* img = bbGetInputIn(); /* double spc[3]; @@ -78,38 +75,31 @@ void ViewerNV::Process() std::vector type = bbGetInputnTypeView(); - if(img != NULL && mwxwidget != NULL){ - if(!compareVectors(type, currenttype)){ - mwxwidget->SetType(&type); - mwxwidget->UpdateLayout(img); - }else if (img != currentimg){ - mwxwidget->SetImage(img); - //mwxwidget->UpdateLayout(img); + if(img != NULL && _mwxwidget != NULL){ + if(!compareVectors(type, _currenttype)){ + _mwxwidget->SetType(&type); + _mwxwidget->UpdateLayout(img); + }else if (img != _currentimg){ + _mwxwidget->SetImage(img); } -// if (firsttime==true) // EED 21 aout 2010 -// { -// firsttime=false; -// mwxwidget->ConfigureVTK(); -// } + _mwxwidget->RefreshView(); - mwxwidget->RefreshView(); + _currenttype = type; + _currentimg = img; - currenttype = type; - currentimg = img; - - point.clear(); - point.push_back((int)mwxwidget->GetX()); - point.push_back((int)mwxwidget->GetY()); - point.push_back((int)mwxwidget->GetZ()); - bbSetOutputPoint(point); + _point.clear(); + _point.push_back((int)_mwxwidget->GetX()); + _point.push_back((int)_mwxwidget->GetY()); + _point.push_back((int)_mwxwidget->GetZ()); + bbSetOutputPoint(_point); // WxBlackBox::Process(); // mwxwidget->SetImage(img ); - wxVtkBaseView *wvbv1 = mwxwidget->GetwxVtkBaseView(1); - wxVtkBaseView *wvbv2 = mwxwidget->GetwxVtkBaseView(2); - wxVtkBaseView *wvbv3 = mwxwidget->GetwxVtkBaseView(3); - wxVtkBaseView *wvbv4 = mwxwidget->GetwxVtkBaseView(4); + wxVtkBaseView *wvbv1 = _mwxwidget->GetwxVtkBaseView(1); + wxVtkBaseView *wvbv2 = _mwxwidget->GetwxVtkBaseView(2); + wxVtkBaseView *wvbv3 = _mwxwidget->GetwxVtkBaseView(3); + wxVtkBaseView *wvbv4 = _mwxwidget->GetwxVtkBaseView(4); //wxwidget->RefreshView(); @@ -130,12 +120,12 @@ void ViewerNV::Process() if(bbGetInputColorFunction()!=NULL) { - mwxwidget->setColorTransferFunction(bbGetInputColorFunction()); + _mwxwidget->setColorTransferFunction(bbGetInputColorFunction()); } if(bbGetInputWindowLevel()!=-1) { - mwxwidget->setWindowLevel(bbGetInputWindowLevel()); + _mwxwidget->setWindowLevel(bbGetInputWindowLevel()); } if(bbGetInputColorLevel()!=-1) @@ -143,28 +133,21 @@ void ViewerNV::Process() if(bbGetInputColorLevel() == 0) { std::cout<<"colorlevel "<setColorLevel(0.1); + _mwxwidget->setColorLevel(0.1); }else{ - mwxwidget->setColorLevel(bbGetInputColorLevel()); + _mwxwidget->setColorLevel(bbGetInputColorLevel()); } } }// mwxwidget != NULL - - printf("EED ViewerNV::Process end\n"); } //------------------------------------------------------------- void ViewerNV::CreateWidget(wxWindow* parent) { - printf("EED ViewerNV::CreateWidget start\n"); - bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<bbSignalOutputModification(); //Process(); } @@ -172,8 +155,8 @@ void ViewerNV::CreateWidget(wxWindow* parent) //------------------------------------------------------------- void ViewerNV::bbUserSetDefaultValues() { -// firsttime=true; - mwxwidget = NULL; + _currentimg = NULL; + _mwxwidget = NULL; bbSetInputIn(NULL); bbSetInputObs1(NULL); diff --git a/bbtk/src/bbmaracasvisuViewerNV.h b/bbtk/src/bbmaracasvisuViewerNV.h index b255c0c..8f0d4e3 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.h +++ b/bbtk/src/bbmaracasvisuViewerNV.h @@ -72,14 +72,13 @@ class /*BBTK_EXPORT*/ ViewerNV BBTK_CREATE_WIDGET(CreateWidget); void CreateWidget(wxWindow* parent); - std::vector point; + std::vector _point; private: -// bool firsttime; - - vtkImageData* currentimg; - std::vector currenttype; - wxMaracas_N_ViewersWidget *mwxwidget; + vtkImageData *_currentimg; + std::vector _currenttype; + wxMaracas_N_ViewersWidget *_mwxwidget; + bool compareVectors(std::vector type,std::vector currenttype); void updateObservers(); }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index bff37c3..636641c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -225,11 +225,10 @@ bool manualViewContour::ifTouchContour(int x,int y,int z) nps_t = nps-1; } // if close - printf("EED manualViewContour::ifTouchContour \n"); +printf("EED Warning manualViewContour::ifTouchContour \n"); for( i = 0; i < nps_t; i++ ) { -printf("%d ", i); _pts->GetPoint(i%nps, ppA); _pts->GetPoint((i+1)%nps, ppB); d1 = sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz)); 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 53d7a4b..b139433 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx @@ -3,8 +3,8 @@ Program: wxMaracas Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $ Language: C++ - Date: $Date: 2012/05/30 17:23:12 $ - Version: $Revision: 1.21 $ + Date: $Date: 2012/10/11 10:45:16 $ + Version: $Revision: 1.22 $ Copyright: (c) 2002, 2003 License: @@ -307,10 +307,11 @@ if (wxwindow2!=NULL) { wxwindow2->SetImage(image); } if (wxwindow3!=NULL) { wxwindow3->SetImage(image); } if (wxwindow4!=NULL) { wxwindow4->SetImage(image); } - ConfigureVTK(); - + +// ConfigureVTK(); } + //----------------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::ConfigureVTK() { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx index 62d2fc7..a0ca639 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx @@ -3,8 +3,8 @@ Program: wxMaracas Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $ Language: C++ - Date: $Date: 2012/05/30 17:23:12 $ - Version: $Revision: 1.35 $ + Date: $Date: 2012/10/11 10:45:16 $ + Version: $Revision: 1.36 $ Copyright: (c) 2002, 2003 License: @@ -313,7 +313,6 @@ if (mwxvtkmpr3Dview !=NULL) { mwxvtkmpr3Dview->Configure(); -printf("EED wxMaracas_ViewerWidget::ConfigureVTK \n"); //EED??? mwxvtkmpr3Dview->ResetCamera(ext,org,spc); } @@ -341,16 +340,15 @@ printf("EED wxMaracas_ViewerWidget::ConfigureVTK \n"); //------------------------------------------------------------------------- void wxMaracas_ViewerWidget::RefreshView() { - if (mvtk2Dbaseview !=NULL ){ mvtk2Dbaseview->Refresh(); } - if (mvtkmpr2Dview_X !=NULL ){ mvtkmpr2Dview_X->Refresh(); } - if (mvtkmpr2Dview_Y !=NULL ){ mvtkmpr2Dview_Y->Refresh(); } - if (mvtkmpr2Dview_Z !=NULL ){ mvtkmpr2Dview_Z->Refresh(); } - if (mvtkplane2Dview !=NULL ){ mvtkplane2Dview->Refresh(); } - if (mwxsphereview !=NULL ){ mwxsphereview ->Refresh(); } - - if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview->RefreshView(); } - if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview->Refresh(); } - if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D->Refresh();} + if (mvtk2Dbaseview !=NULL ){ mvtk2Dbaseview->Refresh(); } + if (mvtkmpr2Dview_X !=NULL ){ mvtkmpr2Dview_X->Refresh(); } + if (mvtkmpr2Dview_Y !=NULL ){ mvtkmpr2Dview_Y->Refresh(); } + if (mvtkmpr2Dview_Z !=NULL ){ mvtkmpr2Dview_Z->Refresh(); } + if (mvtkplane2Dview !=NULL ){ mvtkplane2Dview->Refresh(); } + if (mwxsphereview !=NULL ){ mwxsphereview ->Refresh(); } + if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview->RefreshView(); } + if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview->Refresh(); } + if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D->Refresh(); } } //------------------------------------------------------------------------- @@ -391,6 +389,34 @@ printf("EED wxMaracas_ViewerWidget::ConfigureVTK \n"); mar->AddImageData(image); } + + if (mvtk2Dbaseview!=NULL) + { + mvtk2Dbaseview->SetImageToVtkViewer(image); + } + + if (mvtkmpr2Dview_X!=NULL){ + mvtkmpr2Dview_X->SetImageToVtkViewer(image); + } + if (mvtkmpr2Dview_Y!=NULL){ + mvtkmpr2Dview_Y->SetImageToVtkViewer(image); + } + if (mvtkmpr2Dview_Z!=NULL){ + mvtkmpr2Dview_Z->SetImageToVtkViewer(image); + } + + if (mvtkplane2Dview!=NULL){ + // ??? EED 10 oct 2012 + } + if (mwxsphereview!=NULL){ + // ??? EED 10 oct 2012 + } + if (mwxvtk3Dbaseview_Clipping3D!=NULL){ + // ??? EED 10 oct 2012 + } + + + //EED 26/11/2009 // ConfigureVTK(); // RefreshView(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx index 90f4bf0..61607c3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx @@ -75,6 +75,7 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double & //------------------------------------------------------------------- void wxVtk2DBaseView::ResetView() { + printf("EED wxVtk2DBaseView::ResetView"); double spx = 0,spy = 0,spz = 0; int x1 = 1,x2 = 1,y1 = 1,y2 = 1,z1 = 1,z2 = 1; wxVtkBaseView::Configure(); @@ -122,6 +123,17 @@ void wxVtk2DBaseView::ResetView() } + +//------------------------------------------------------------------- +void wxVtk2DBaseView::SetImageToVtkViewer(vtkImageData *imageData) +{ + if (_imageViewer2XYZ!=NULL) + { + _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( imageData ); + } // if _imageViewer2XYZ +} + + //------------------------------------------------------------------- void wxVtk2DBaseView::Configure(bool okimage) { @@ -159,15 +171,15 @@ void wxVtk2DBaseView::Configure(bool okimage) vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData(); - if (imageData!=NULL){ - + if (imageData!=NULL) + { imageData->UpdateInformation(); imageData->SetUpdateExtent( imageData->GetWholeExtent()); imageData->Update(); if (okimage==true){ imageData->GetSpacing (spx,spy,spz); imageData->GetExtent (x1,x2,y1,y2,z1,z2); - _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData ); + SetImageToVtkViewer(imageData); _imageViewer2XYZ->SetExtentDimension(x1,x2,y1,y2,z1,z2); double range[2]; imageData->GetScalarRange(range); @@ -195,8 +207,8 @@ void wxVtk2DBaseView::Configure(bool okimage) // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() ); - vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2(); - vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); + vtkImageViewer2 *IV2 = _imageViewer2XYZ->GetVtkImageViewer2(); + vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); //EED 17Avril2009 //EED 21 mars 2012 FLIP problem ..PLOP.. diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h index 6903109..7a3e47b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h @@ -41,6 +41,7 @@ public: void setColorLevel(double level); virtual int GetDirection(); + void SetImageToVtkViewer(vtkImageData *imageData); private: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx index 00cfbdc..6bba28c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx @@ -48,8 +48,8 @@ void wxVtkBaseView::Configure() // virtual //------------------------------------------------------------------- void wxVtkBaseView::Refresh() // virtual { + // EED 10 Oct 2007 - #if defined(WIN32) _iren->Refresh(false); #else @@ -67,6 +67,7 @@ void wxVtkBaseView::Refresh() // virtual //------------------------------------------------------------------- void wxVtkBaseView::RefreshView() // virtual { + printf("EED wxVtkBaseView::RefreshView() \n"); // EED 10 Oct 2007 #if defined(WIN32) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx index 849a6e7..0bd418b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx @@ -44,7 +44,10 @@ vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata() return (vtkMPRBaseData*)GetVtkBaseData(); } //------------------------------------------------------------------- -void wxVtkMPR2DView::Configure(){ +void wxVtkMPR2DView::Configure() +{ + printf("EED wxVtkMPR2DView::Configure"); + wxVtk2DBaseView::Configure(); @@ -225,6 +228,7 @@ void wxVtkMPR2DView::SetVisibleAxis(bool ok) void wxVtkMPR2DView::Refresh() { + printf("wxVtkMPR2DView::Refresh start\n"); //wxVtk2DBaseView::Refresh(); @@ -346,6 +350,9 @@ void wxVtkMPR2DView::Refresh() _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->Modified(); wxVtkBaseView::Refresh(); + + printf("wxVtkMPR2DView::Refresh end\n"); + } } //------------------------------------------------------------------- -- 2.47.1