From 08ce916eba56a6111014712fc931a1cce7e8f877 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 7 Sep 2017 15:16:55 +0200 Subject: [PATCH] #3107 BBTK Bug New Normal - branch vtk7itk4 compilation with vtk7 --- packages/vtk/src/bbvtkMaskPoint.h | 2 +- packages/vtk/src/bbvtkPiecewiseFunction.cxx | 11 +- packages/vtk/src/bbvtkPolyDataWriterPlus.cxx | 27 +- packages/vtk/src/bbvtkPolyDataWriterPlus.h | 2 +- packages/vtk/src/bbvtkSphereList.cxx | 1 + packages/vtk/src/bbvtkSphereList.h | 4 +- packages/vtk/src/bbvtkTemporalPicker.h | 2 +- packages/wxvtk/src/bbwxvtkViewer2D.cxx | 289 ++++++++++-------- packages/wxvtk/src/bbwxvtkViewer2D.h | 2 - .../wxvtk/src/wxVTKRenderWindowInteractor.cxx | 42 +-- .../wxvtk/src/wxVTKRenderWindowInteractor.h | 22 +- packages/wxvtk/src/wxvtkImageViewer2.h | 9 +- 12 files changed, 227 insertions(+), 186 deletions(-) diff --git a/packages/vtk/src/bbvtkMaskPoint.h b/packages/vtk/src/bbvtkMaskPoint.h index 6e0d094..28c9a2c 100644 --- a/packages/vtk/src/bbvtkMaskPoint.h +++ b/packages/vtk/src/bbvtkMaskPoint.h @@ -40,7 +40,7 @@ class bbvtk_EXPORT MaskPoint BBTK_BEGIN_DESCRIBE_BLACK_BOX(MaskPoint,bbtk::AtomicBlackBox); BBTK_NAME("MaskPoint"); BBTK_AUTHOR("ED at InfoDev Creatis"); -BBTK_DESCRIPTION("vtkMaskPoint"); +BBTK_DESCRIPTION("vtkMaskPoint. See Vectors/Tensors Examples"); BBTK_CATEGORY("empty"); BBTK_INPUT(MaskPoint,In,"vtkImageData",vtkImageData*,""); BBTK_INPUT(MaskPoint,Ratio,"Ratio",int,""); diff --git a/packages/vtk/src/bbvtkPiecewiseFunction.cxx b/packages/vtk/src/bbvtkPiecewiseFunction.cxx index c667b6e..6d77609 100644 --- a/packages/vtk/src/bbvtkPiecewiseFunction.cxx +++ b/packages/vtk/src/bbvtkPiecewiseFunction.cxx @@ -92,11 +92,9 @@ namespace bbvtk ( bbGetInputStatus("Y") != bbtk::UPTODATE ) ) { if ( bbGetInputX().size() != bbGetInputY().size() ) - bbtkError(bbGetFullName() - <<" : input vectors X and Y do not have the same size"); + bbtkError(bbGetFullName() <<" : input vectors X and Y do not have the same size"); if ( bbGetInputX().size() < 2 ) - bbtkError(bbGetFullName() - <<" : input vectors X and Y have a size < 2"); + bbtkError(bbGetFullName() <<" : input vectors X and Y have a size < 2"); bbGetOutputOut()->RemoveAllPoints (); // std::cout << bbGetInputX().size()<< ","<< bbGetInputY().size()<< std::endl; std::vector::const_iterator x,y; @@ -108,10 +106,11 @@ namespace bbvtk { // std::cout << *x << " -> " << *y << std::endl; bbGetOutputOut()->AddPoint(*x,*y); - } - } + } // for x ,y + } // if InputX } + }//namespace bbtk #endif // _USE_VTK_ diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx b/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx index 0c9de87..e960ef4 100755 --- a/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx +++ b/packages/vtk/src/bbvtkPolyDataWriterPlus.cxx @@ -32,9 +32,10 @@ namespace bbvtk BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PolyDataWriterPlus) BBTK_BLACK_BOX_IMPLEMENTATION(PolyDataWriterPlus,bbtk::AtomicBlackBox); + void PolyDataWriterPlus::Process() { - std::cout << "[" << this << "]" << "PolyDataWriterPlus::Process()..." << std::endl; +// std::cout << "[" << this << "]" << "PolyDataWriterPlus::Process()..." << std::endl; //Review the observers... if (!HasObserver(OBS_PRE_WRITER_1) && bbGetInputInPrePersistObs1() != NULL) @@ -59,32 +60,25 @@ void PolyDataWriterPlus::Process() { std::cout << "Set In." << std::endl; return; + } else { + vtkProp3D* actor = bbGetInputIn2(); + vtkPolyDataMapper* mapper = ((vtkPolyDataMapper*)((vtkActor*)actor)->GetMapper()); + cosa = mapper->GetInput(); } - else - { - vtkProp3D* actor = bbGetInputIn2(); - vtkPolyDataMapper* mapper = ((vtkPolyDataMapper*)((vtkActor*)actor)->GetMapper()); - cosa = mapper->GetInput(); - } - } - else - { + } else { cosa = bbGetInputIn(); } std::string nuevo_nombre = guessName(bbGetInputInPath()); - vtkPolyData* entrada = cosa; - std::cout << "Before writing" << std::endl; - entrada->Print(std::cout); +// std::cout << "Before writing" << std::endl; +// entrada->Print(std::cout); std::vector< std::string > partes = StringSplit(nuevo_nombre, "."); std::string extension = partes.at(partes.size()-1); - std::cout << "Extension (vtk, vtp o stl?) => " << extension << std::endl; - - +// std::cout << "Extension (vtk, vtp o stl?) => " << extension << std::endl; vtkDataSetSurfaceFilter* surfaceFilter = vtkDataSetSurfaceFilter::New(); @@ -152,6 +146,7 @@ void PolyDataWriterPlus::Process() InvokeEvent(OBS_POST_WRITER_1); } + void PolyDataWriterPlus::bbUserSetDefaultValues() { diff --git a/packages/vtk/src/bbvtkPolyDataWriterPlus.h b/packages/vtk/src/bbvtkPolyDataWriterPlus.h index 7e2ec11..be65433 100755 --- a/packages/vtk/src/bbvtkPolyDataWriterPlus.h +++ b/packages/vtk/src/bbvtkPolyDataWriterPlus.h @@ -74,7 +74,7 @@ BBTK_DESCRIPTION("_description_"); BBTK_CATEGORY("__CATEGORY__"); BBTK_INPUT(PolyDataWriterPlus,InPrePersistObs1,"Who will be notified before persist", vtkCommand*,""); BBTK_INPUT(PolyDataWriterPlus,InPostPersistObs1,"Who will be notified after persist", vtkCommand*,""); -BBTK_INPUT(PolyDataWriterPlus,InPath,"Path to the file to be created or rewrited",std::string,""); +BBTK_INPUT(PolyDataWriterPlus,InPath,"Path to the file to be created or rewrited (.vtk file)",std::string,""); BBTK_INPUT(PolyDataWriterPlus,In,"Information to be saved", vtkPolyData*,""); BBTK_INPUT(PolyDataWriterPlus,In2,"Information to be saved", vtkProp3D*,""); BBTK_END_DESCRIBE_BLACK_BOX(PolyDataWriterPlus); diff --git a/packages/vtk/src/bbvtkSphereList.cxx b/packages/vtk/src/bbvtkSphereList.cxx index 24538a7..5664b47 100644 --- a/packages/vtk/src/bbvtkSphereList.cxx +++ b/packages/vtk/src/bbvtkSphereList.cxx @@ -140,6 +140,7 @@ void SphereList::Process() #if VTK_MAJOR_VERSION <= 5 newMapper -> SetInput( newSphere -> GetOutput() ); #else + newSphere -> Update(); newMapper -> SetInputData( newSphere -> GetOutput() ); #endif diff --git a/packages/vtk/src/bbvtkSphereList.h b/packages/vtk/src/bbvtkSphereList.h index fdc775a..070da95 100644 --- a/packages/vtk/src/bbvtkSphereList.h +++ b/packages/vtk/src/bbvtkSphereList.h @@ -80,8 +80,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(SphereList,bbtk::AtomicBlackBox); BBTK_INPUT(SphereList,lstPointY,"List of Y coordinates. Requirement: same size as vector X and vector Z.",std::vector,""); BBTK_INPUT(SphereList,lstPointZ,"List of Z coordinates. Requirement: same size as vector X and vector Y.",std::vector,""); BBTK_INPUT(SphereList,lstRadio,"List of Radio values",std::vector,""); - BBTK_INPUT(SphereList,Colour,"Colour RGB values for the spheres (3 first values of the vector for the first sphere, following values for the second sphere, etc.)",std::vector,""); - BBTK_INPUT(SphereList,Opacity,"Opacity of the spheres",double,""); + BBTK_INPUT(SphereList,Colour,"Colour RGB values for the spheres (default [1 0 0]) (3 first values of the vector for the first sphere, following values for the second sphere, etc.)",std::vector,""); + BBTK_INPUT(SphereList,Opacity,"Opacity of the spheres (default 1)",double,""); BBTK_INPUT(SphereList,Spacing,"(default [1 1 1]) Spacing vector [sx sy sz]",std::vector,""); BBTK_INPUT(SphereList,Transform,"vtkTransform",vtkLinearTransform*,""); diff --git a/packages/vtk/src/bbvtkTemporalPicker.h b/packages/vtk/src/bbvtkTemporalPicker.h index da74b90..f41e642 100644 --- a/packages/vtk/src/bbvtkTemporalPicker.h +++ b/packages/vtk/src/bbvtkTemporalPicker.h @@ -62,7 +62,7 @@ class bbvtk_EXPORT TemporalPicker BBTK_BEGIN_DESCRIBE_BLACK_BOX(TemporalPicker,bbtk::AtomicBlackBox); BBTK_NAME("TemporalPicker"); BBTK_AUTHOR("Info-Dev"); - BBTK_DESCRIPTION("Pick vector in Z direction"); + BBTK_DESCRIPTION("Pick vector in Z direction (2D+t => 3D)"); BBTK_CATEGORY(""); BBTK_INPUT(TemporalPicker,In,"Input image",vtkImageData*,""); BBTK_INPUT(TemporalPicker,SizeRegion,"Size region (default 1)",int,""); diff --git a/packages/wxvtk/src/bbwxvtkViewer2D.cxx b/packages/wxvtk/src/bbwxvtkViewer2D.cxx index bd675d5..23cd7d2 100644 --- a/packages/wxvtk/src/bbwxvtkViewer2D.cxx +++ b/packages/wxvtk/src/bbwxvtkViewer2D.cxx @@ -53,6 +53,18 @@ #include #include #include +#include + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + #include "wxvtkImageViewer2.h" +#else + #include +#endif + + +#include "wxVTKRenderWindowInteractor.h" + namespace bbwxvtk { //-------------------------------------------------------------------------- @@ -62,22 +74,28 @@ namespace bbwxvtk Viewer2DWidget(Viewer2D* box, wxWindow *parent); ~Viewer2DWidget(); void UpdateView(); - vtkRenderer *GetRenderer(); - vtkImageActor *GetImageActor(); + vtkRenderer *GetRenderer(); + vtkImageActor *GetImageActor(); private: - bool mFirstTime; - Viewer2D *mBox; - wxvtkImageViewer2 *imageViewer; - vtkImageData *backImageData; - vtkImageData *mDefaultImage; + bool mFirstTime; + Viewer2D *mBox; + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + wxvtkImageViewer2 *imageViewer; +#else + vtkImageViewer2 *imageViewer; +#endif + + vtkImageData *backImageData; + vtkImageData *mDefaultImage; wxVTKRenderWindowInteractor *wxvtkrenderwindowinteractor; bool mUpdateCamera; vtkImplicitPlaneWidget * maPlane1, * maPlane2, * mbPlane1, * mbPlane2; }; - Viewer2DWidget::Viewer2DWidget(Viewer2D* box, - wxWindow *parent) + Viewer2DWidget::Viewer2DWidget(Viewer2D* box, wxWindow *parent) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), mFirstTime(true), @@ -88,7 +106,13 @@ namespace bbwxvtk wxvtkrenderwindowinteractor = new wxVTKRenderWindowInteractor(panel,-1); wxvtkrenderwindowinteractor->UseCaptureMouseOn(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageViewer = wxvtkImageViewer2::New(); +#else + imageViewer = vtkImageViewer2::New(); +#endif + imageViewer->SetSlice( 1 ); imageViewer->SetupInteractor ( wxvtkrenderwindowinteractor ); @@ -109,48 +133,56 @@ namespace bbwxvtk mDefaultImage->AllocateScalars(VTK_UNSIGNED_CHAR,1); #endif - for (int i=0;iSetScalarComponentFromFloat(i,j,k,0,0); - - for (int i=0;iSetScalarComponentFromFloat(i,0,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-1,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(0,i,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(dim[0]-1,i,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,0,1,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-1,1,0,255); - mDefaultImage->SetScalarComponentFromFloat(0,i,1,0,255); - mDefaultImage->SetScalarComponentFromFloat(dim[0]-1,i,1,0,255); - */ - mDefaultImage->SetScalarComponentFromFloat(i,i,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-i-1,0,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,i,1,0,255); - mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-i-1,1,0,255); - } + int i,j,k; + for (i=0;iSetScalarComponentFromFloat(i,j,k,0,0); + } // for k + }// for j + } // for i + + for (i=0;iSetScalarComponentFromFloat(i,0,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-1,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(0,i,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(dim[0]-1,i,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,0,1,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-1,1,0,255); + mDefaultImage->SetScalarComponentFromFloat(0,i,1,0,255); + mDefaultImage->SetScalarComponentFromFloat(dim[0]-1,i,1,0,255); + */ + mDefaultImage->SetScalarComponentFromFloat(i,i,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-i-1,0,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,i,1,0,255); + mDefaultImage->SetScalarComponentFromFloat(i,dim[1]-i-1,1,0,255); + } // for i mDefaultImage->Modified(); - backImageData = mDefaultImage; + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 imageViewer->SetInput( backImageData ); - mUpdateCamera = true; +#else + imageViewer->SetInputData( backImageData ); +#endif + mUpdateCamera = true; wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); sizer->Add( wxvtkrenderwindowinteractor, 1, wxEXPAND, 0); panel->SetSizer(sizer); panel->SetAutoLayout(true); panel->Layout(); - - // wxvtkrenderwindowinteractor->Refresh(); // wxvtkrenderwindowinteractor->Render(); // imageViewer->GetRenderer()->ResetCameraClippingRange(); - imageViewer->GetRenderer()->SetBackground(0.1,0.1,0.2); - } //------------------------------------------------------------------------- @@ -165,98 +197,94 @@ namespace bbwxvtk mDefaultImage->Delete(); if (backImageData) - { - // backImageData->UnRegister(NULL); - } + { +// backImageData->UnRegister(NULL); + } if (imageViewer) - { - imageViewer->Delete(); - } + { + imageViewer->Delete(); + } delete wxvtkrenderwindowinteractor; // std::cout << "Viewer2DWidget::~Viewer2DWidget() OK" << std::endl; } //------------------------------------------------------------------------- - - void Viewer2DWidget::UpdateView() { // std::cout << "Viewer2DWidget::UpdateView() " << std::endl; // std::cout << "slice="<bbGetInputSlice()<bbGetInputIn() == NULL ) && - ( backImageData != mDefaultImage ) ) - { - // - // std::cout << "** Viewer2DWidget::UpdateView() : NULL Input (reset)" <bbGetInputIn() != NULL ) && + if ( ( mBox->bbGetInputIn() == NULL ) && ( backImageData != mDefaultImage ) ) + { + // + // std::cout << "** Viewer2DWidget::UpdateView() : NULL Input (reset)" <bbGetInputIn() != NULL ) && (( mBox->bbGetInputStatus("In") != bbtk::UPTODATE ) || ( mFirstTime)) ) //(backImageData != mBox->bbGetInputIn()) ) - { - // std::cout << "** Viewer2DWidget::UpdateView() : Input changed" <bbGetInputIn()) // Don't update if just Slice changed - { - backImageData = mBox->bbGetInputIn(); -//EED 2017-01-01 Migration VTK7 -#if VTK_MAJOR_VERSION <= 5 - backImageData->Update(); -#else - // .. -#endif - imageViewer->SetInput( backImageData ); - mUpdateCamera = true; - } - } + { + // std::cout << "** Viewer2DWidget::UpdateView() : Input changed" <bbGetInputIn()) // Don't update if just Slice changed + { + backImageData = mBox->bbGetInputIn(); + //EED 2017-01-01 Migration VTK7 + #if VTK_MAJOR_VERSION <= 5 + backImageData->Update(); + imageViewer->SetInput( backImageData ); + #else + imageViewer->SetInputData( backImageData ); + #endif + mUpdateCamera = true; + } // if BackImageData + } // if BoxInputIn if (mUpdateCamera) - { - // std::cout << "** Viewer2DWidget::UpdateView() : Update Camera" - // <GetSpacing(spx,spy,spz); - backImageData->GetExtent (x1,x2,y1,y2,z1,z2); + { + // std::cout << "** Viewer2DWidget::UpdateView() : Update Camera" + // <GetSpacing(spx,spy,spz); + backImageData->GetExtent (x1,x2,y1,y2,z1,z2); - double *range = backImageData->GetScalarRange(); - imageViewer->SetColorWindow(range[1] - range[0]); - imageViewer->SetColorLevel(0.5 * (range[1] + range[0])); - - imageViewer->GetRenderer()->ResetCamera(); - double bounds[6]; - imageViewer->GetRenderer()->ComputeVisiblePropBounds(bounds); - imageViewer->GetRenderer()->ResetCameraClippingRange(bounds); + double *range = backImageData->GetScalarRange(); + imageViewer->SetColorWindow(range[1] - range[0]); + imageViewer->SetColorLevel(0.5 * (range[1] + range[0])); + + imageViewer->GetRenderer()->ResetCamera(); + double bounds[6]; + imageViewer->GetRenderer()->ComputeVisiblePropBounds(bounds); + imageViewer->GetRenderer()->ResetCameraClippingRange(bounds); - // bbtkMessage("Output",2,"Viewer2D '"<bbGetName()<<"' - Image :"<GetRenderer()->GetActiveCamera(); - - camera->SetViewUp ( spx*0, -spy*1, spz*0 ); - camera->SetPosition ( spx*(x1+x2)/2, spy*(y1+y2)/2, -spz*10000000 ); - camera->SetFocalPoint( spx*(x1+x2)/2, spy*(y1+y2)/2, spz*0 ); - - camera->ComputeViewPlaneNormal(); - camera->SetParallelScale( spx*(x2-x1)/2.0 ); - // - // imageViewer->GetRenderer()->ResetCamera(x1,x2,y1,y2,z1,z2); - mUpdateCamera = false; - // std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl; - imageViewer->SetColorWindow(512); - imageViewer->SetColorLevel(256); - */ - /* - for (int i=0;i<10;i++) - for (int j=0;j<10;j++) - std::cout << mBox->bbGetInputIn()->GetScalarComponentAsFloat(i,j,0,0) - << std::endl; - */ + // bbtkMessage("Output",2,"Viewer2D '"<bbGetName()<<"' - Image :"<GetRenderer()->GetActiveCamera(); + + camera->SetViewUp ( spx*0, -spy*1, spz*0 ); + camera->SetPosition ( spx*(x1+x2)/2, spy*(y1+y2)/2, -spz*10000000 ); + camera->SetFocalPoint( spx*(x1+x2)/2, spy*(y1+y2)/2, spz*0 ); + + camera->ComputeViewPlaneNormal(); + camera->SetParallelScale( spx*(x2-x1)/2.0 ); + // + // imageViewer->GetRenderer()->ResetCamera(x1,x2,y1,y2,z1,z2); + mUpdateCamera = false; + // std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl; + imageViewer->SetColorWindow(512); + imageViewer->SetColorLevel(256); + */ + /* + for (int i=0;i<10;i++) + for (int j=0;j<10;j++) + std::cout << mBox->bbGetInputIn()->GetScalarComponentAsFloat(i,j,0,0) + << std::endl; + */ } // std::cout << "OW = "<< mBox->bbGetWindow() << std::endl; @@ -265,13 +293,15 @@ namespace bbwxvtk bool interp = mBox->bbGetInputInterpolate(); if ( interp ) + { imageViewer->GetImageActor()->InterpolateOn(); - else + } else { imageViewer->GetImageActor()->InterpolateOff(); - + } int orientation = mBox->bbGetInputOrientation(); - if (orientation<0 || orientation>2) { + if (orientation<0 || orientation>2) + { bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 "<bbIsShown() is necessary to be sure that the wxWindow is already // created and displayed. // Else when slice != 0 we get an X Window System error with wxGTK - if ( - (backImageData!=NULL)&& - (mBox->bbIsShown())) + if ( (backImageData!=NULL) && (mBox->bbIsShown()) ) { int z = mBox->bbGetInputSlice(); int ext[6]; @@ -320,21 +348,30 @@ namespace bbwxvtk bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 (shouldn't arrive here!"<Refresh(); +#else + //wxRect *rect=new wxRect(0, 0, 50, 50); + //wxvtkrenderwindowinteractor->Refresh(true, rect); + // .. +#endif + wxvtkrenderwindowinteractor->Render(); bbtkDebugMessage("Output",3,"Viewer2D : slice = "<SetSliceOrientation (orientation); imageViewer->SetSlice( z ); - } - } + } // if backImageData - vtkRenderer * Viewer2DWidget::GetRenderer() - { - return imageViewer->GetRenderer(); - } - +} + //-------------------------------------------------------------------------- +vtkRenderer * Viewer2DWidget::GetRenderer() +{ + return imageViewer->GetRenderer(); +} //-------------------------------------------------------------------------- //------------------------------------------------------------------------- @@ -375,9 +412,9 @@ namespace bbwxvtk // std::cout << "Slice="<UpdateView(); - } + { + w->UpdateView(); + } bbSetOutputOut( bbGetInputSlice() ); } diff --git a/packages/wxvtk/src/bbwxvtkViewer2D.h b/packages/wxvtk/src/bbwxvtkViewer2D.h index f63399f..8400ae0 100644 --- a/packages/wxvtk/src/bbwxvtkViewer2D.h +++ b/packages/wxvtk/src/bbwxvtkViewer2D.h @@ -56,11 +56,9 @@ #define __bbwxvtkViewer2D_h__ #include "vtkImageData.h" -#include "wxvtkImageViewer2.h" #include "vtkImplicitPlaneWidget.h" #include "bbtkWxBlackBox.h" -#include "wxVTKRenderWindowInteractor.h" namespace bbwxvtk { diff --git a/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx b/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx index 0435d9f..2e58ec6 100644 --- a/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx +++ b/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx @@ -193,9 +193,12 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor() : wxWindow(), vtkRend #ifdef VTK_DEBUG_LEAKS vtkDebugLeaks::ConstructClass("wxVTKRenderWindowInteractor"); #endif + this->RenderWindow = NULL; this->SetRenderWindow(vtkRenderWindow::New()); this->RenderWindow->Delete(); + this->SetBackgroundStyle( wxBG_STYLE_COLOUR ); + this->SetBackgroundColour( wxColor(0,0,0,0) ); } //--------------------------------------------------------------------------- wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent, @@ -229,6 +232,8 @@ wxVTKRenderWindowInteractor::wxVTKRenderWindowInteractor(wxWindow *parent, // so we update the size information of the interactor/renderwindow here this->UpdateSize(size.x, size.y); #endif + this->SetBackgroundStyle( wxBG_STYLE_COLOUR ); + this->SetBackgroundColour( wxColor(0,0,0,0) ); } //--------------------------------------------------------------------------- wxVTKRenderWindowInteractor::~wxVTKRenderWindowInteractor() @@ -311,15 +316,17 @@ void wxVTKRenderWindowInteractor::UpdateSize(int x, int y) Size[1] = y; // and our RenderWindow's size RenderWindow->SetSize(x, y); - } - } + } // if x y + } // if RenderWindow } //--------------------------------------------------------------------------- int wxVTKRenderWindowInteractor::CreateTimer(int WXUNUSED(timertype)) { // it's a one shot timer if (!timer.Start(10, TRUE)) - assert(false); + { + assert(false); + } return 1; @@ -333,9 +340,11 @@ int wxVTKRenderWindowInteractor::DestroyTimer() //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnTimer(wxTimerEvent& WXUNUSED(event)) { - if (!Enabled) - return; - + if (!Enabled) + { + return; + } + #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style InvokeEvent(vtkCommand::TimerEvent, NULL); @@ -417,6 +426,7 @@ void wxVTKRenderWindowInteractor::OnPaint(wxPaintEvent& WXUNUSED(event)) rwin->UpdateGLRegion(); } #endif + } //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnEraseBackground(wxEraseEvent &event) @@ -445,18 +455,17 @@ void wxVTKRenderWindowInteractor::OnSize(wxSizeEvent& WXUNUSED(event)) //--------------------------------------------------------------------------- void wxVTKRenderWindowInteractor::OnMotion(wxMouseEvent &event) { - if (!Enabled) + this->Render(); + + if (!Enabled) { - return; + return; } #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) - SetEventInformationFlipY(event.GetX(), event.GetY(), - event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); - + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); InvokeEvent(vtkCommand::MouseMoveEvent, NULL); #else - InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(), - event.GetX(), Size[1] - event.GetY() - 1); + InteractorStyle->OnMouseMove(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); #endif } //--------------------------------------------------------------------------- @@ -470,14 +479,11 @@ void wxVTKRenderWindowInteractor::OnEnter(wxMouseEvent &event) #if VTK_MAJOR_VERSION > 4 || (VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION > 0) // new style - SetEventInformationFlipY(event.GetX(), event.GetY(), - event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); - + SetEventInformationFlipY(event.GetX(), event.GetY(), event.ControlDown(), event.ShiftDown(), '\0', 0, NULL); InvokeEvent(vtkCommand::EnterEvent, NULL); #else // old style - InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(), - event.GetX(), Size[1] - event.GetY() - 1); + InteractorStyle->OnEnter(event.ControlDown(), event.ShiftDown(), event.GetX(), Size[1] - event.GetY() - 1); #endif } //--------------------------------------------------------------------------- diff --git a/packages/wxvtk/src/wxVTKRenderWindowInteractor.h b/packages/wxvtk/src/wxVTKRenderWindowInteractor.h index 230ef56..2487c23 100644 --- a/packages/wxvtk/src/wxVTKRenderWindowInteractor.h +++ b/packages/wxvtk/src/wxVTKRenderWindowInteractor.h @@ -148,8 +148,8 @@ class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInter void Disable(); void Start(); void UpdateSize(int x, int y); - int CreateTimer(int timertype); - int DestroyTimer(); + int CreateTimer(int timertype); + int DestroyTimer(); void TerminateApp() {}; // event handlers @@ -188,17 +188,17 @@ class wxVTKRenderWindowInteractor : public wxWindow, public vtkRenderWindowInter vtkBooleanMacro(UseCaptureMouse,int); protected: - wxTimer timer; - int ActiveButton; - int RenderAllowed; - long GetHandleHack(); - int Stereo; + wxTimer timer; + int ActiveButton; + int RenderAllowed; + long GetHandleHack(); + int Stereo; private: - long Handle; - bool Created; - int RenderWhenDisabled; - int UseCaptureMouse; + long Handle; + bool Created; + int RenderWhenDisabled; + int UseCaptureMouse; DECLARE_EVENT_TABLE() }; diff --git a/packages/wxvtk/src/wxvtkImageViewer2.h b/packages/wxvtk/src/wxvtkImageViewer2.h index 8592ee3..4786758 100644 --- a/packages/wxvtk/src/wxvtkImageViewer2.h +++ b/packages/wxvtk/src/wxvtkImageViewer2.h @@ -164,7 +164,9 @@ public: virtual int GetSliceMin(); virtual int GetSliceMax(); virtual void GetSliceRange(int range[2]) - { this->GetSliceRange(range[0], range[1]); } + { + this->GetSliceRange(range[0], range[1]); + } virtual void GetSliceRange(int &min, int &max); virtual int* GetSliceRange(); @@ -185,7 +187,10 @@ public: // Set/Get the position in screen coordinates of the rendering window. virtual int* GetPosition(); virtual void SetPosition(int a,int b); - virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); } + virtual void SetPosition(int a[2]) + { + this->SetPosition(a[0],a[1]); + } // Description: // Set/Get the size of the window in screen coordinates in pixels. -- 2.47.1