From b80b4dcc301c1c2c63c0f76cd06b0a434350f7a7 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 7 Sep 2016 16:03:28 +0200 Subject: [PATCH] #3012 creaMaracasVisu Bug New Normal - Update Image in ViewerNV --- .../widgets/InteractorStyleMaracas.cxx | 11 +- .../widgets/manualInteractorWindowLevel.cxx | 2 + .../widgets/vtkClipping3DDataViewer.cxx | 46 ++-- .../widgets/vtkClipping3DDataViewer.h | 3 +- .../widgets/vtkInteractorStyleBaseView2D.cxx | 8 +- .../widgets/vtkInteractorStylePlane2D.cxx | 2 - .../widgets/vtkInteractorStyleSphere.cxx | 30 ++- .../wxWindows/widgets/vtkMPR3DDataViewer.cxx | 12 +- .../wxWindows/widgets/vtkMPR3DDataViewer.h | 1 + .../wxWindows/widgets/vtkPlane2DView.cxx | 49 +--- .../wxWindows/widgets/wxMPRBaseData.h | 12 +- .../wxWindows/widgets/wxMPRWidget.cxx | 26 +- .../widgets/wxMaracas_ViewerWidget.cxx | 69 ++++-- .../wxWindows/widgets/wxSphereView.cxx | 222 +++++++++--------- .../wxWindows/widgets/wxSphereView.h | 20 +- .../wxWindows/widgets/wxVtk2DBaseView.cxx | 16 +- .../wxWindows/widgets/wxVtk2DBaseView.h | 4 - .../wxWindows/widgets/wxVtk3DBaseView.cxx | 11 +- .../wxWindows/widgets/wxVtk3DBaseView.h | 20 +- .../wxWindows/widgets/wxVtkBaseView.cxx | 2 - .../wxWindows/widgets/wxVtkBaseView.h | 3 - .../wxWindows/widgets/wxVtkClipping3DView.h | 2 +- .../wxWindows/widgets/wxVtkMPR2DView.cxx | 2 - .../wxWindows/widgets/wxVtkMPR3DView.cxx | 21 +- .../wxWindows/widgets/wxVtkMPR3DView.h | 2 + 25 files changed, 300 insertions(+), 296 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx index c26493e..d4c495c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/InteractorStyleMaracas.cxx @@ -40,7 +40,7 @@ InteractorStyleMaracas::~InteractorStyleMaracas() } // ---------------------------------------------------------------------------- -InteractorStyleMaracas * InteractorStyleMaracas :: Clone() // virtual +InteractorStyleMaracas * InteractorStyleMaracas::Clone() // virtual { InteractorStyleMaracas * clone = new InteractorStyleMaracas(); CopyAttributesTo(clone); @@ -114,28 +114,21 @@ bool InteractorStyleMaracas::OnRightDClick() //virtual return true; } - - //--------------------------------------------------------------------------- bool InteractorStyleMaracas::OnMouseWheelForward() //virtual { return true; } - //--------------------------------------------------------------------------- bool InteractorStyleMaracas::OnMouseWheelBackward() //virtual { return true; } - //--------------------------------------------------------------------------- - - void InteractorStyleMaracas::SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* vtkInteractorStyleBaseView) +void InteractorStyleMaracas::SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* vtkInteractorStyleBaseView) { _vtkInteractorStyleBaseView = vtkInteractorStyleBaseView; } - - //--------------------------------------------------------------------------- void InteractorStyleMaracas::RemoveVtkInteractorStyleBaseView() { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx index 19b4cd0..f058df7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx @@ -115,6 +115,8 @@ bool manualInteractorWindowLevel::OnMouseMove() // virtual // vtkimageviewer2->Render(); } + + return true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx index 335af08..a888215 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx @@ -201,46 +201,49 @@ void vtkClipping3DDataViewer::SetVisibleVolumeBox(bool visibleBox) _visibleVolumeBox = visibleBox; } + //------------------------------------------------------------------- -void vtkClipping3DDataViewer::Configure_Tissue() +void vtkClipping3DDataViewer::SetImage() { + int i; + vtkImageData *imagedata=_vtkmprbasedata->GetImageData(); + for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++) + { + _mCubes[i]->SetInput( imagedata ); + } // for + _volumeMapper->SetInput( imagedata ); + _volumerendererdata->SetImageData( imagedata ); +} - double range[2]; +//------------------------------------------------------------------- +void vtkClipping3DDataViewer::Configure_Tissue() +{ int i; - for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){ + double range[2]; + vtkImageData *imagedata=_vtkmprbasedata->GetImageData(); + imagedata->GetScalarRange( range ); + for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++) + { // Visualisation - original volume - vtkImageData *imagedata=_vtkmprbasedata->GetImageData(); - imagedata->GetScalarRange( range ); _mCubes[i] = vtkMarchingCubes::New( ); _mCubes[i]->SetInput( imagedata ); - _mCubes[i]->SetValue( 0, range[1]*(4+i) / 8 ); // _mCubes[i]->SetValue( 0, 1500 ); - _tissueStripper[i] = vtkStripper::New(); _tissueStripper[i]->SetInput( _mCubes[i]->GetOutput( ) ); - - - _tissuePlanes[i] = vtkPlanes::New(); - int x1,x2,y1,y2,z1,z2; imagedata->GetExtent(x1,x2,y1,y2,z1,z2); _tissuePlanes[i]->SetBounds (x1,x2,y1,y2,z1,z2); - _tissueClipper[i] = vtkClipPolyData::New(); _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() ); _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] ); _tissueClipper[i]->InsideOutOn( ); - _tissueMapper[i] = vtkPolyDataMapper::New( ); _tissueMapper[i]->SetInput( _tissueClipper[i]->GetOutput() ); _tissueMapper[i]->ScalarVisibilityOff( ); // _tissueMapper[i]->Update(); - - } - - + } // for i // vtkActor tissue for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++){ @@ -384,6 +387,7 @@ void vtkClipping3DDataViewer::Configure_Volume() _observerV->SetvtkVolumeRayCastMapper( _volumeMapper ); } +//----------------------------------------------------------------------------- void vtkClipping3DDataViewer::Configure_VolumeBox() { @@ -401,12 +405,15 @@ void vtkClipping3DDataViewer::Configure_VolumeBox() //_volumerendererdata->BoundingBoxChanged(event.IsChecked() ); } +//----------------------------------------------------------------------------- + void vtkClipping3DDataViewer::SetRenderer(vtkRenderer* renderer) { _volumerendererdata->SetRenderer(renderer); } +//----------------------------------------------------------------------------- void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interactor) { @@ -414,6 +421,7 @@ void vtkClipping3DDataViewer::SetInteractor(vtkRenderWindowInteractor* interacto } +//----------------------------------------------------------------------------- void vtkClipping3DDataViewer::BoxActorChanged(bool changed) { vector *gv = this->GetGreyValuesTransferenceFVector(); @@ -425,6 +433,7 @@ void vtkClipping3DDataViewer::BoxActorChanged(bool changed) } +//----------------------------------------------------------------------------- void vtkClipping3DDataViewer::UpdateVolumeBox(vector gf, vector vf, vtkColorTransferFunction* ctfun) { _volumerendererdata->SetLookUpTable((vtkLookupTable*)(ctfun)); @@ -432,6 +441,7 @@ void vtkClipping3DDataViewer::UpdateVolumeBox(vector gf, vector } +//----------------------------------------------------------------------------- void vtkClipping3DDataViewer::updateVolume() { @@ -481,7 +491,7 @@ void vtkClipping3DDataViewer::Configure() //EED 4 nov 2015 Estelle // _mapOutline->SetInput(_outlineData->GetOutput()); - _outline = vtkActor::New(); + _outline = vtkActor::New(); _outline->SetMapper(_mapOutline); _outline->GetProperty()->SetColor(0,0,0); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h index 1461beb..2822ca3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h @@ -73,7 +73,8 @@ public: virtual void Configure(); void Configure_Tissue(); void Configure_Volume(); - + void SetImage(); + void SetIsovalue(int idTissue, int isoValue); double GetIsovalue(int idTissue); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView2D.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView2D.cxx index e077370..940b06f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView2D.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleBaseView2D.cxx @@ -71,7 +71,8 @@ void vtkInteractorStyleBaseView2D::OnRightButtonDown() // virtual { vtkInteractorStyleBaseView::OnRightButtonDown(); - if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){ + if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ) + { this->vtkInteractorStyleImage::OnRightButtonDown(); } } @@ -82,12 +83,14 @@ void vtkInteractorStyleBaseView2D::OnRightButtonUp() // virtual vtkInteractorStyleBaseView::OnRightButtonUp(); this->vtkInteractorStyleImage::OnRightButtonUp(); } + //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView2D::OnMouseMove () // virtual { vtkInteractorStyleBaseView::OnMouseMove(); this->vtkInteractorStyleImage::OnMouseMove(); } + //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView2D::OnLeftButtonDown() // virtual { @@ -98,6 +101,7 @@ void vtkInteractorStyleBaseView2D::OnLeftButtonDown() // virtual this->vtkInteractorStyleImage::OnLeftButtonDown(); } } + //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView2D::OnLeftButtonUp () // virtual { @@ -105,6 +109,7 @@ void vtkInteractorStyleBaseView2D::OnLeftButtonUp () // virtual this->vtkInteractorStyleImage::OnLeftButtonUp(); } + //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView2D::OnMiddleButtonDown () // virtual { @@ -115,6 +120,7 @@ void vtkInteractorStyleBaseView2D::OnMiddleButtonDown () // virtual this->vtkInteractorStyleImage::OnLeftButtonDown(); } } + //--------------------------------------------------------------------------- void vtkInteractorStyleBaseView2D::OnMiddleButtonUp () // virtual { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStylePlane2D.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStylePlane2D.cxx index 40729bc..959bcf6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStylePlane2D.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStylePlane2D.cxx @@ -51,7 +51,6 @@ bool vtkInteractorStylePlane2D::OnLeftButtonDown() // vitual _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); vtkplane2Dview->RotationStart(); - return true; } @@ -65,7 +64,6 @@ bool vtkInteractorStylePlane2D::OnLeftButtonUp() // virtual vtkplane2Dview->ResetBack(); // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); } - return true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleSphere.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleSphere.cxx index e57cb65..54a7f73 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleSphere.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorStyleSphere.cxx @@ -35,14 +35,11 @@ vtkInteractorStyleSphere::vtkInteractorStyleSphere() } //--------------------------------------------------------------------------- - vtkInteractorStyleSphere::~vtkInteractorStyleSphere() { } - -//--------------------------------------------------------------------------- - +//-------------------------------------------------------------------------- bool vtkInteractorStyleSphere::OnRightButtonDown() { if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ) @@ -50,17 +47,13 @@ bool vtkInteractorStyleSphere::OnRightButtonDown() _stateRadio = true; //_fordwareX = this->Interactor->GetEventPosition()[0]; _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; - wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); - _radio = wxsphereview->GetRadio(); } - return true; } //--------------------------------------------------------------------------- - bool vtkInteractorStyleSphere::OnRightButtonUp() { if (_stateRadio==true) @@ -72,15 +65,13 @@ bool vtkInteractorStyleSphere::OnRightButtonUp() wxsphereview->GetIdOfImage(radio+0.2); wxsphereview->GetIdOfImage(radio-0.1); wxsphereview->GetIdOfImage(radio-0.2); - wxsphereview->RefreshView(); _stateRadio = false; } - return true; } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- bool vtkInteractorStyleSphere::OnLeftButtonDown() { _stateRotate = true; @@ -89,9 +80,7 @@ bool vtkInteractorStyleSphere::OnLeftButtonDown() return true; } - //--------------------------------------------------------------------------- - bool vtkInteractorStyleSphere::OnLeftButtonUp() { wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); @@ -111,16 +100,15 @@ bool vtkInteractorStyleSphere::OnLeftButtonUp() wxsphereview->RefreshView(); _stateRotate = false; } - return true; } //--------------------------------------------------------------------------- - bool vtkInteractorStyleSphere::OnMouseMove () { wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); + if (_stateRotate==true) { bool ok_v, ok_ang; @@ -141,13 +129,23 @@ bool vtkInteractorStyleSphere::OnMouseMove () } if (_stateRadio==true) { + //int fx = this->Interactor->GetEventPosition()[0]; int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; double dif=(fy-_fordwareY) / 10.0; wxsphereview->SetRadio( _radio + dif ); wxsphereview->SetDeltaVoxel(3); + wxsphereview->RefreshView(); } - return true; } + + + + + + + + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx index ff72cc5..cdfc991 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.cxx @@ -139,6 +139,14 @@ std::vector* vtkMPR3DDataViewer::GetctFunVectorBlue() return &_ctFunVectorBlue; } +//------------------------------------------------------------------- +void vtkMPR3DDataViewer::SetImage() +{ + _saggitalColors->SetInput( _vtkmprbasedata->GetImageData() ); + _axialColors->SetInput( _vtkmprbasedata->GetImageData() ); + _coronalColors->SetInput( _vtkmprbasedata->GetImageData() ); +} + //------------------------------------------------------------------- void vtkMPR3DDataViewer::Configure() { @@ -175,8 +183,7 @@ void vtkMPR3DDataViewer::Configure() { _vtkmprbasedata->GetImageData()->GetScalarRange(range); delta = range[1]-range[0]; - - + _ctFunVectorPoint.clear(); _ctFunVectorPoint.push_back( range[0] + delta*0/4 ); _ctFunVectorPoint.push_back( range[0] + delta*1/4 ); @@ -205,7 +212,6 @@ void vtkMPR3DDataViewer::Configure() _ctFunVectorBlue.push_back(0.0); _ctFunVectorBlue.push_back(0.0); - if(_ctfun==NULL) { _ctfun = vtkColorTransferFunction::New(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h index d968ff3..38c2a0f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkMPR3DDataViewer.h @@ -50,6 +50,7 @@ public: vtkActor* GetOutlineActor(); virtual void Refresh(); virtual void Configure(); + void SetImage(); void SetVisiblePosition(int idPosition, bool visible); bool GetVisiblePosition(int idPosition); vtkImageActor* GetvtkActor_saggital(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx index f0cbc97..b957195 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx @@ -62,10 +62,10 @@ vtkPlane2DView::vtkPlane2DView( wxWindow *parent) _imageResult = NULL; // line horizontal - _pts = NULL; - _lineActor = NULL; - _lineMapper = NULL; - _pd = NULL; + _pts = NULL; + _lineActor = NULL; + _lineMapper = NULL; + _pd = NULL; _interactorstyleplane2D = false; } @@ -73,13 +73,11 @@ vtkPlane2DView::vtkPlane2DView( wxWindow *parent) vtkPlane2DView::~vtkPlane2DView() { ResetPlane(); - // Horizontal Line if (_pts != NULL) { _pts -> Delete(); } if (_lineActor != NULL) { _lineActor -> Delete(); } if (_lineMapper != NULL) { _lineMapper -> Delete(); } if (_pd != NULL) { _pd -> Delete(); } - _transform1 -> Delete(); _transform2 -> Delete(); } @@ -97,12 +95,14 @@ void vtkPlane2DView::ResetBack() } //------------------------------------------------------------------- -void vtkPlane2DView::ResetPlane(){ +void vtkPlane2DView::ResetPlane() +{ if (_pSource !=NULL) { _pSource -> Delete(); } if (_3Dslices !=NULL) { _3Dslices -> Delete(); } if (_stPoints !=NULL) { _stPoints -> Delete(); } if (_change !=NULL) { _change -> Delete(); } } + //------------------------------------------------------------------- vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata() { @@ -158,7 +158,6 @@ void vtkPlane2DView::SetPSource(int sizeIma){ //------------------------------------------------------------------- void vtkPlane2DView::ExtractPlane() { - double x = GetVtkmprbasedata()->GetX(); double y = GetVtkmprbasedata()->GetY(); double z = GetVtkmprbasedata()->GetZ(); @@ -223,7 +222,6 @@ void vtkPlane2DView::ExtractPlane() } //------------------------------------------------------------------- - void vtkPlane2DView::Extract_One_PlaneVTK() { vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData(); @@ -244,27 +242,22 @@ void vtkPlane2DView::Extract_One_PlaneVTK() } //------------------------------------------------------------------- - void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) { - int mipWidth; double sp; int sizeWidth = (_mip_width*2)+1 ; int deltaPixel; int iWidth,itmp,tmpSizeWith; - double spc[3]; vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData(); SetPSource(_sizeIma); imagedata->GetSpacing(spc); - bool heightDefinition=false; if (_mip_width<3) { heightDefinition=true; } - if (heightDefinition==true) { mipWidth = _mip_width; @@ -277,14 +270,9 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) sizeWidth = tmpSizeWith; deltaPixel = 4; } - - - std::vector< vtkProbeFilter* > slicesLST; - _pSource->Push( -mipWidth * sp ); _pSource->Update(); - for ( iWidth=0 ; iWidthPush( sp ); } - if (_imageResult ==NULL) { _imageResult = vtkImageData::New(); @@ -306,20 +293,15 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) _imageResult -> AllocateScalars(); _imageResult -> Update(); } - unsigned short *pTemp; unsigned short *pResult; pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); - int iPixels , sizePixels = _sizeIma*_sizeIma; for(iPixels=0 ; iPixelsGetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0); - pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); pResult[iPixels] = pTemp[iPixels]; - for (iWidth=1;iWidthGetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0); @@ -329,7 +311,6 @@ void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ ) pResult[iPixels] = pTemp[iPixels]; } } - if (deltaPixel!=1) { for (itmp=1;itmpDelete(); } - _imageResult->Modified(); _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult ); - } //------------------------------------------------------------------- @@ -377,13 +354,10 @@ void vtkPlane2DView::Configure( ) // // Actual version vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New(); - manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel(); style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel ); - vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); - SetInteractorStyleImage( style2D ); // RaC @@ -447,6 +421,7 @@ void vtkPlane2DView::RotationStart() vtkTransform *transform = mprbasedata->GetTransformOrientation(); _transform1->SetMatrix( transform->GetMatrix() ); } + //------------------------------------------------------------------- void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang) { @@ -480,6 +455,7 @@ void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang) void vtkPlane2DView::Refresh( ) { ExtractPlane(); + UpdateColorWindowLevel(); wxVtkBaseView::Refresh(); } //------------------------------------------------------------------- @@ -559,19 +535,16 @@ void vtkPlane2DView::SetVisibleLine(bool ok) } _lineActor->GetProperty()->SetOpacity(opacity); } + // ---------------------------------------------------------------------------- void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z) { double spc[3]; GetVtkmprbasedata()->GetImageData()->GetSpacing(spc); - double xx = X; double yy = Y; double zz = 0; - TransFromCoordScreenToWorld(xx,yy,zz); - - vtkTransform *transf1 = vtkTransform::New(); transf1->Identity(); vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation(); @@ -582,10 +555,8 @@ void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z) in[1] = xx - center; in[2] = yy - center; in[3] = 0; - transf1->MultiplyPoint(in,out); transf1->Delete(); - X = out[0] + GetVtkmprbasedata()->GetX() ; Y = out[1] + GetVtkmprbasedata()->GetY() ; Z = out[2] + GetVtkmprbasedata()->GetZ() ; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.h index 76ea0a1..a77e08e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRBaseData.h @@ -89,19 +89,19 @@ class creaMaracasVisu_EXPORT vtkMPRBaseData: public vtkBaseData{ public: vtkMPRBaseData(); - virtual ~vtkMPRBaseData(); + virtual ~vtkMPRBaseData(); virtual void Configure(); int GetMaxPositionX( ); int GetMaxPositionY( ); int GetMaxPositionZ( ); double GetX(); double GetY(); - void SetX(double x); - void SetY(double y); - void GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2); + void SetX(double x); + void SetY(double y); + void GetDimensionExtention(int *x1,int *x2,int *y1,int *y2,int *z1,int *z2); vtkTransform* GetTransformOrientation(); - void SetNormal(double nx, double ny, double nz); - void InitTransformOrientation(vtkTransform *trans); + void SetNormal(double nx, double ny, double nz); + void InitTransformOrientation(vtkTransform *trans); protected: int _x1,_x2,_y1,_y2,_z1,_z2; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx index e1901a1..218e424 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMPRWidget.cxx @@ -191,38 +191,38 @@ wxMPRWidget::wxMPRWidget( wxWindow* parent, _refreshBPage=0; } -void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize){ + +//---------------------------------------------------------------------------- +void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize) +{ if(_marImageData!=NULL){ _marImageData->removeImageData(0); _marImageData->AddImageData(img); }else{ - _marImageData = new marImageData(img); + _marImageData = new marImageData(img); } - _voxelSize = voxelsize; + _voxelSize = voxelsize; if(_vtkmprbasedata==NULL){ _vtkmprbasedata = new vtkMPRBaseData(); _vtkmprbasedata->SetMarImageData(_marImageData); - wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1); + wxSplitterWindow *pnlSplitter= new wxSplitterWindow( this , -1); pnlSplitter -> SetMinimumPaneSize( 2 ); //RaC Nov2012 Correctly resize internal panels with the window resize event pnlSplitter->SetSashGravity(0.5); - wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata); + wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata); wxPanel *controlPanel = CreateControlPanel(pnlSplitter); pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 ); this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0); } - - - } -//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- wxMPRWidget::~wxMPRWidget( ) { //EEDxx2.4 DELETE @@ -388,7 +388,9 @@ wxPanel* wxMPRWidget::CreateView(int type,wxWindow *parent, vtkMPRBaseData *vtkm } if (type==4) { - _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() ); +//EED +// _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() ); + _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata ); wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor(); } @@ -537,7 +539,9 @@ wxPanel* wxMPRWidget::CreateMPRPanel4View(wxWindow *parent, vtkMPRBaseData *vtkm notebook->AddPage( _widgetMesure, _T("Plane") ); // view 3.1 - _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData()); +// EED +// _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData()); + _wxsphereview = new wxSphereView( notebook , vtkmprbasedata ); wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor(); notebook->AddPage( iren3B, _T("Sphere") ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx index f5cce00..9fee226 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx @@ -72,9 +72,9 @@ if (vtkmprbasedata==NULL) { - minternalVtkmprbasedata = true; - mvtkmprbasedata = new vtkMPRBaseData(); - marImageData *marimagedata = new marImageData( imagedata ); + minternalVtkmprbasedata = true; + mvtkmprbasedata = new vtkMPRBaseData(); + marImageData *marimagedata = new marImageData( imagedata ); mvtkmprbasedata->SetMarImageData(marimagedata); } else { minternalVtkmprbasedata = false; @@ -123,20 +123,21 @@ wxwindow = mwidgetMesure; }else if (type==4) { - mwxsphereview = new wxSphereView( panel , mvtkmprbasedata, mvtkmprbasedata->GetImageData() ); +//EED +// mwxsphereview = new wxSphereView( panel , mvtkmprbasedata , mvtkmprbasedata->GetImageData() ); + mwxsphereview = new wxSphereView( panel , mvtkmprbasedata ); wxwindow=mwxsphereview->GetWxVTKRenderWindowInteractor(); }else if (type==5) { panelClipping3D = new wxSplitterWindow( panel , -1); - mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D , vtkmprbasedata); - - mwxvtkclipping3Dview = new wxVtkClipping3DView(mwxvtk3Dbaseview_Clipping3D); - vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer(); + mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D , vtkmprbasedata); + mwxvtkclipping3Dview = new wxVtkClipping3DView(mwxvtk3Dbaseview_Clipping3D); + vtkClipping3DDataViewer *vtkclipping3Ddataviewer= new vtkClipping3DDataViewer(); vtkclipping3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata); vtkclipping3Ddataviewer->Configure(); mwxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer); - mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D ); + mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D ); vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer(); vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata); vtkmpr3Ddataviewer->Configure(); @@ -145,10 +146,10 @@ window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor(); //-- - wxNotebook *notebook = new wxNotebook(panelClipping3D, -1); + wxNotebook *notebook = new wxNotebook(panelClipping3D, -1); // First tab - controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(notebook, true); + controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(notebook, true); notebook->AddPage(controlPanelMPR3D, _T("Planes") ); // Second Tab @@ -187,13 +188,13 @@ } else if (type==6) { panelClipping3D = new wxSplitterWindow( panel , -1); - mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D , vtkmprbasedata); + mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D , vtkmprbasedata); mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D ); vtkmpr3Ddataviewer = new vtkMPR3DDataViewer(); wxWindow *window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor(); wxPanel *panelControl = new wxPanel(panelClipping3D,-1); - wxPanel *controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(panelControl, true); - wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1); + wxPanel *controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(panelControl, true); + wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1); sizerCtrol->Add(controlPanelMPR3D, 1, wxALL|wxEXPAND, 2); panelControl->SetAutoLayout(true); @@ -365,7 +366,7 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) 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 (mwxsphereview !=NULL ){ mwxsphereview ->RefreshView(); } if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview->RefreshView(); } if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview->Refresh(); } if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D->Refresh(); } @@ -400,6 +401,9 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) return wxvtkbaseview ; } + + +//------------------------------------------------------------------------- void wxMaracas_ViewerWidget::SetImage( vtkImageData *image ) { if(mvtkmprbasedata !=NULL) @@ -408,40 +412,51 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) mar->removeImageData(0); mar->AddImageData(image); } - if (mvtk2Dbaseview!=NULL) { mvtk2Dbaseview->SetImageToVtkViewer(image); } - if (mvtkmpr2Dview_X!=NULL){ + if (mvtkmpr2Dview_X!=NULL) + { mvtkmpr2Dview_X->SetImageToVtkViewer(image); } - if (mvtkmpr2Dview_Y!=NULL){ + if (mvtkmpr2Dview_Y!=NULL) + { mvtkmpr2Dview_Y->SetImageToVtkViewer(image); } - if (mvtkmpr2Dview_Z!=NULL){ + if (mvtkmpr2Dview_Z!=NULL) + { mvtkmpr2Dview_Z->SetImageToVtkViewer(image); } - if (mvtkplane2Dview!=NULL){ + if (mvtkplane2Dview!=NULL) + { // ??? EED 10 oct 2012 } - if (mwxsphereview!=NULL){ - // ??? EED 10 oct 2012 + if (mwxsphereview!=NULL) + { + mwxsphereview->SetImage(); } - if (mwxvtk3Dbaseview_Clipping3D!=NULL){ - // ??? EED 10 oct 2012 + if (mwxvtkclipping3Dview!=NULL) + { + mwxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetImage(); } - + if (mwxvtkmpr3Dview!=NULL) + { + mwxvtkmpr3Dview->SetImage(); + } //EED 26/11/2009 // ConfigureVTK(); // RefreshView(); + } + //------------------------------------------------------------------------- + double wxMaracas_ViewerWidget :: GetX() { double value = -1; @@ -452,6 +467,8 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) return value; } + //------------------------------------------------------------------------- + double wxMaracas_ViewerWidget::GetY() { double value = -1; @@ -462,6 +479,8 @@ void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) return value; } + //------------------------------------------------------------------------- + double wxMaracas_ViewerWidget::GetZ() { double value = -1; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx index bfe896e..9619181 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.cxx @@ -25,24 +25,31 @@ #include "wxSphereView.h" - -wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData ) +wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata/*, vtkImageData *imageData */) : wxVtk2DBaseView(parent) { _delta = 1; _vtkmprbasedata = vtkmprbasedata; - _imageDataOriginal = imageData; +//EED 2016-08-31 +// _imageDataOriginal = imageData; + + SetImage(); _imageSphere = vtkImageData::New(); _imageSphere->SetDimensions (150,150,500); - _imageSphere->SetScalarTypeToUnsignedShort(); + +//EED +// _imageSphere->SetScalarTypeToUnsignedShort(); + _imageSphere->SetScalarType( _imageDataOriginal->GetScalarType() ); + _imageSphere->AllocateScalars(); _imageSphere->Update(); - - vtkBaseData *vtkbasedata = new vtkBaseData(); - vtkbasedata->SetMarImageData( new marImageData(_imageSphere) ); - this->SetVtkBaseData(vtkbasedata); +//EED ???? vtkBaseData no esta compartido con los otros objetos .. PLOP +// vtkBaseData *vtkbasedata = new vtkBaseData(); +// vtkbasedata->SetMarImageData( new marImageData(_imageSphere) ); +// this->SetVtkBaseData(vtkbasedata); + this->SetVtkBaseData(_vtkmprbasedata); _transform = vtkTransform::New(); _transform1 = vtkTransform::New(); @@ -50,12 +57,10 @@ wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vt _transform ->Identity(); _transform1->Identity(); _transform2->Identity(); - _radio=25; } //------------------------------------------------------------------- - wxSphereView::~wxSphereView() { _transform -> Delete(); @@ -65,33 +70,46 @@ wxSphereView::~wxSphereView() } //---------------------------------------------------------------------------- +void wxSphereView::SetImage() +{ + ResetlstId(); + _imageDataOriginal=_vtkmprbasedata->GetImageData(); +} +//---------------------------------------------------------------------------- double wxSphereView::GetRadio() { return _radio; } //---------------------------------------------------------------------------- - void wxSphereView::SetRadio(double radio) { if (radio<0) { radio=0; - } + } // if _radio=radio; } //---------------------------------------------------------------------------- - void wxSphereView::Configure() { wxVtk2DBaseView::Configure(); + + vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New(); + manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel(); + style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel ); +// vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ(); +// style2D->SetInteractorScrollZ(_vtkInteractorScrollZ); + SetInteractorStyleImage( style2D ); + + + _vtkinteractorstylesphere = new vtkInteractorStyleSphere(); ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _vtkinteractorstylesphere ); double points[4][3]; - // EED purify 12/sep/2006 int i,j; for (i=0;i<4;i++) @@ -99,15 +117,15 @@ void wxSphereView::Configure() for (j=0;j<3;j++) { points[i][j]=0; - } - } - + } // for + } // for InitSphere(points); + + DefineImageSphere(); } //---------------------------------------------------------------------------- - void wxSphereView::RefreshPoint() { double x = _vtkmprbasedata->GetX() - _centerX; @@ -115,29 +133,39 @@ void wxSphereView::RefreshPoint() double z = _vtkmprbasedata->GetZ() - _centerZ; double alpha= atan2(x,z); double beta = atan2( y , sqrt(z*z+x*x) ); - alpha = alpha*180/3.1416; beta = beta*180/3.1416; - _transform1->Identity(); _transform1->RotateY(alpha); _transform1->RotateX(-beta); - _radio= sqrt(x*x + y*y +z*z); - RefreshView(); } -//---------------------------------------------------------------------------- + +//------------------------------------------------------------------- +void wxSphereView::Refresh( ) +{ +// ExtractPlane(); + UpdateColorWindowLevel(); + wxVtkBaseView::Refresh(); +} + + + +//---------------------------------------------------------------------------- void wxSphereView::RefreshView() { +//EED + _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageSphere ); DefineImageSphere(); - wxVtk2DBaseView::Refresh(); +// UpdateColorWindowLevel(); +// wxVtk2DBaseView::Refresh(); + Refresh(); } //---------------------------------------------------------------------------- - void wxSphereView::RotationEnd() { _transform1->RotateWXYZ(_ang,_vxb,_vyb,0); @@ -147,19 +175,16 @@ void wxSphereView::RotationEnd() } //---------------------------------------------------------------------------- - void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang) { if (ok_ang==false) { _ang = -sqrt( vx*vx + vy*vy ) / 1.0; - } - + } // if ok_ang if (ok_v==false){ _vxb=-vy; _vyb=vx; - } - + } // if ok_v _transform2->Identity(); _transform2->RotateWXYZ(_ang,_vxb,_vyb,0); SetDeltaVoxel(3); @@ -167,7 +192,6 @@ void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang) } //---------------------------------------------------------------------------- - void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB) { double in[3],out[3]; @@ -186,61 +210,16 @@ void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB) } //---------------------------------------------------------------------------- - void wxSphereView::RotatePointOverTheSphere( double pp[3], double p[3],double cc[3]) { - double out[3]; _transform->TransformPoint(p,out); pp[0] = out[0] + cc[0]; pp[1] = out[1] + cc[1]; pp[2] = out[2] + cc[2]; - } //---------------------------------------------------------------------------- - -void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image) -{ - double t; - double difX = pp2[0]-pp1[0]; - double difY = pp2[1]-pp1[1]; - double difZ = pp2[2]-pp1[2]; - - double max = 200; - - int dimOrg[3]; - int dimRes[3]; - int z; - _imageDataOriginal->GetDimensions(dimOrg); - image->GetDimensions(dimRes); - - int i; - double x1=pp1[0]; - double y1=pp1[1]; - double z1=pp1[2]; - int xx=-1,yy=-1,zz=-1; - - for (i=0;i=0) && (xx=0) && (yy=0) && (zz=0) && (AngX=0) && (AngY=0) && (zGetScalarPointer (xx,yy,zz); - unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z ); - *pRes=*pOrg; - } - } -} - -//---------------------------------------------------------------------------- - void wxSphereView::ResetlstId() { int i,size=_lstId.size(); @@ -252,7 +231,6 @@ void wxSphereView::ResetlstId() } //---------------------------------------------------------------------------- - int wxSphereView::GetIdOfImage(double radio) { int id=0; @@ -280,22 +258,21 @@ int wxSphereView::GetIdOfImage(double radio) } else { id = 0; } - FiltreImage(id,radio); _lstId.insert(_lstId.begin(),1,new idAlBeRa(id,radio,_delta) ); - return id; } //---------------------------------------------------------------------------- - void wxSphereView::DefineImageSphere() { int id; id=GetIdOfImage( _radio ); - GetVtkBaseData()->SetZ( id ); -} +//EED +// GetVtkBaseData()->SetZ( id ); + _imageViewer2XYZ->GetVtkImageViewer2()->SetSlice ( id ); +} //---------------------------------------------------------------------------- void wxSphereView::SetDeltaVoxel(int delta) @@ -304,7 +281,7 @@ void wxSphereView::SetDeltaVoxel(int delta) } //---------------------------------------------------------------------------- -void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned short gris) +void wxSphereView::SetVoxel(double i, double j, int delta,double id, double gris) { int ii,jj,delta2; unsigned short *pRes; @@ -319,16 +296,16 @@ void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned s if ( (ii>=0)&&(ii=0)&&(jjGetScalarPointer( ii , jj , (int)id ); - *pRes=gris; +//EED +// pRes = (unsigned short*)_imageSphere->GetScalarPointer( ii , jj , (int)id ); +// *pRes=gris; + _imageSphere->SetScalarComponentFromDouble( ii , jj , (int)id , 0, gris ); } - } - } - + } // for jj + } // for ii } //---------------------------------------------------------------------------- - void wxSphereView::SetXYZtoParent(double i, double j) { @@ -345,7 +322,6 @@ void wxSphereView::SetXYZtoParent(double i, double j) d2x=dimRes[0]/2; d2y=dimRes[1]/2; _imageDataOriginal->GetDimensions(dimOrig); - p[0] = (i - d2x)*factor; pxx=p[0]*p[0]; p[1] = (j - d2y)*factor; @@ -364,15 +340,14 @@ void wxSphereView::SetXYZtoParent(double i, double j) _vtkmprbasedata->SetY(pp[1]); _vtkmprbasedata->SetZ(pp[2]); } - } - } + } // if pp + } // if radio } - //---------------------------------------------------------------------------- - void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) { + double value; double factor = 0.75; double radioB = radio/3; double radio2 = radio*radio; @@ -394,9 +369,7 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) //JCP 24 - 04 -09 d2x=dimRes[0]/2; d2y=dimRes[1]/2; -// double deltaTMP=_delta; _imageDataOriginal->GetDimensions(dimOrig); - int start,end; int limitA,limitB; limitA = (int) ( (-radioB/factor)+d2x ); @@ -431,8 +404,11 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) (pp[1]>=0) && (pp[1]=0) && (pp[2]GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) ); - SetVoxel(i,j,deltaTMP,id,*pOrig); +//EED +// pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) ); +// SetVoxel(i,j,deltaTMP,id,*pOrig); + value=_imageDataOriginal->GetScalarComponentAsDouble( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]), 0); + SetVoxel(i,j,deltaTMP,id,value); } else { SetVoxel(i,j,deltaTMP,id,2000); } @@ -442,28 +418,20 @@ void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP) } } } - _imageSphere->Modified(); _imageSphere->Update(); } - - - //---------------------------------------------------------------------------- - void wxSphereView::FiltreImage(int id, double radio) { - _transform -> Identity(); _transform -> Concatenate(_transform1); _transform -> Concatenate(_transform2); - FiltreImageB(id,radio,false, _delta); FiltreImageB(id,radio,true, 1); } - //---------------------------------------------------------------------------- /* @@ -600,6 +568,48 @@ void wxSphereView::FiltreImage(vtkImageData *imageSphere) } } } + + +//---------------------------------------------------------------------------- + +void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image) +{ + double t; + double difX = pp2[0]-pp1[0]; + double difY = pp2[1]-pp1[1]; + double difZ = pp2[2]-pp1[2]; + double max = 200; + int dimOrg[3]; + int dimRes[3]; + int z; + _imageDataOriginal->GetDimensions(dimOrg); + image->GetDimensions(dimRes); + int i; + double x1=pp1[0]; + double y1=pp1[1]; + double z1=pp1[2]; + int xx=-1,yy=-1,zz=-1; + for (i=0;i=0) && (xx=0) && (yy=0) && (zz=0) && (AngX=0) && (AngY=0) && (zGetScalarPointer (xx,yy,zz); + unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z ); + *pRes=*pOrg; + } + } +} + + + + */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.h index 8a022bd..a99cb87 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxSphereView.h @@ -37,13 +37,17 @@ class wxMPRBaseData; class wxSphereView : public wxVtk2DBaseView { public: - wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData); + wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata /*, vtkImageData *imageData*/); ~wxSphereView(); virtual void Configure(); + void SetImage(); + void RotationEnd(); void RotationStart(double vx, double vy, bool ok_v, bool ok_ang); virtual void RefreshView(); - virtual void SetVoxel(double i, double j, int delta, double id, unsigned short gris); + virtual void Refresh(); + + virtual void SetVoxel(double i, double j, int delta, double id, double gris); void SetDeltaVoxel(int delta); double GetRadio(); void SetRadio(double radio); @@ -52,25 +56,19 @@ public: void RefreshPoint(); private: - std::vector _lstId; - + std::vector _lstId; int _centerX; int _centerY; int _centerZ; double _radio; - double _ang; double _vxb; double _vyb; - int _delta; - vtkImageData *_imageDataOriginal; vtkImageData *_imageSphere; - vtkMPRBaseData *_vtkmprbasedata; vtkInteractorStyleSphere *_vtkinteractorstylesphere; - vtkTransform *_transform; vtkTransform *_transform1; vtkTransform *_transform2; @@ -79,14 +77,12 @@ private: void FiltreImageB(int id, double radio, bool ok,int deltaTMP); void DefineImageSphere(); void ResetlstId(); - void InitSphere(double points[4][3]); double SphereFindCenter(double P[4][3], double cc[3]); double determinant(double a[4][4], int n); - void GetPointSphere(double p[3],double r1,double angA,double angB); void RotatePointOverTheSphere( double pp[3], double p[3],double cc[3]); - void TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image); +// void TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image); }; #endif /*WXSPHEREVIEW_H_*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx index 6e9a593..bd26d12 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx @@ -95,7 +95,6 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double & X=X*spc[0]; Y=Y*spc[1]; Z=Z*spc[2]; - } //------------------------------------------------------------------- @@ -117,7 +116,6 @@ void wxVtk2DBaseView::ResetView() imageData->GetExtent (x1,x2,y1,y2,z1,z2); } - _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2); _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren ); @@ -148,8 +146,6 @@ void wxVtk2DBaseView::ResetView() } - - //------------------------------------------------------------------- void wxVtk2DBaseView::SetImageToVtkViewer(vtkImageData *imageData) { @@ -159,7 +155,6 @@ void wxVtk2DBaseView::SetImageToVtkViewer(vtkImageData *imageData) } // if _imageViewer2XYZ } - //------------------------------------------------------------------- void wxVtk2DBaseView::Configure(bool okimage) { @@ -195,7 +190,6 @@ void wxVtk2DBaseView::Configure(bool okimage) ////////////// } - vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData(); if (imageData!=NULL) { @@ -232,11 +226,9 @@ void wxVtk2DBaseView::Configure(bool okimage) //_collookup->SetTableValue(255 , 0 , 1 , 0 , 1 ); //_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel ()->SetLookupTable(_collookup ); - // EED 17 Oct 2007 // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() ); - vtkImageViewer2 *IV2 = _imageViewer2XYZ->GetVtkImageViewer2(); vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); @@ -275,7 +267,7 @@ void wxVtk2DBaseView::Configure(bool okimage) //------------------------------------------------------------------- -int wxVtk2DBaseView::GetActualSlice() // virtual +int wxVtk2DBaseView::GetActualSlice() // virtual { return (int)(GetVtkBaseData()->GetZ()); } @@ -286,7 +278,6 @@ void wxVtk2DBaseView::SetActualSlice(int slice) // Virtual GetVtkBaseData()->SetZ(slice); } - //------------------------------------------------------------------- void wxVtk2DBaseView::UpdateColorWindowLevel() { @@ -295,7 +286,6 @@ void wxVtk2DBaseView::UpdateColorWindowLevel() // vtkImageViewer2 *vtkimageviewer2 = _imageViewer2XYZ->GetVtkImageViewer2(); - vtkImageMapToWindowLevelColors* imagemaptowindowlevel = _imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel(); imagemaptowindowlevel->SetWindow( GetVtkBaseData()->GetColorWindow() ); imagemaptowindowlevel->SetLevel( GetVtkBaseData()->GetColorLevel() ); @@ -311,11 +301,9 @@ void wxVtk2DBaseView::Refresh() { int z = (int)(GetVtkBaseData()->GetZ()); _imageViewer2XYZ->SetZSlice( z ); - //EED 2016/02/19 vtkImageActor *imageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor(); imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() ); - //EED 01nov2012 UpdateColorWindowLevel(); wxVtkBaseView::Refresh(); @@ -325,12 +313,10 @@ void wxVtk2DBaseView::Refresh() void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview) { SetInteractorStyleBaseView(interactorstylebaseview); - wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor(); interactorstylebaseview->SetInteractor ( iren ); iren->SetInteractorStyle(interactorstylebaseview); interactorstylebaseview->SetwxVtkBaseView(this); - vtkMaracasImageViewer2Callback * cbk = vtkMaracasImageViewer2Callback::New(); cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2(); interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h index d1874f1..66d7518 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.h @@ -35,8 +35,6 @@ class vtkInfoTextImage; class vtkInfoTextImageInteractor; - - //------------------------------------------------------------------ class creaMaracasVisu_EXPORT wxVtk2DBaseView: public wxVtkBaseView{ @@ -46,7 +44,6 @@ public: virtual void Configure(bool okimage=true); vtkImageViewer2_XYZ* _imageViewer2XYZ; - virtual void Refresh(); virtual void ResetView(); virtual int GetActualSlice(); @@ -69,7 +66,6 @@ public: //EED 01nov2012 void UpdateColorWindowLevel(); - private: vtkInfoTextImage *_vtkIinfoTextImage; vtkInfoTextImageInteractor *_vtkIinfoTextImageInteractor; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx index 75d6c1e..7a15860 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx @@ -37,7 +37,7 @@ wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent, vtkBaseData* vtkbasedata) _configure = false; _aRenderer = NULL; _renWin = NULL; - _aCamera = NULL; + _aCamera = NULL; } //------------------------------------------------------------------- wxVtk3DBaseView::~wxVtk3DBaseView() @@ -45,10 +45,12 @@ wxVtk3DBaseView::~wxVtk3DBaseView() if (_aCamera!=NULL) { _aCamera -> Delete(); _aCamera=NULL;} if (_aRenderer!=NULL) { _aRenderer -> Delete(); _aRenderer=NULL;} - if (_renWin!=NULL) { + if (_renWin!=NULL) + { if(_renWin->GetReferenceCount()==0) { - _renWin -> Delete(); _renWin=NULL; + _renWin->Delete(); + _renWin=NULL; } } } @@ -200,10 +202,9 @@ void wxVtk3DBaseView::Configure() GetCamera()->Roll(180); GetCamera()->Yaw(180+30); GetCamera()->Pitch(-22); - - } } + //------------------------------------------------------------------- //EED 27 sep 2006 void wxVtk3DBaseView::GetSpacing(double spc[3]) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.h index db9804e..f4fc33e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.h @@ -42,20 +42,20 @@ class creaMaracasVisu_EXPORT wxVtk3DBaseView: public wxVtkBaseView public: wxVtk3DBaseView( wxWindow *parent, vtkBaseData* vtkbasedata ); virtual ~wxVtk3DBaseView(); - vtkCamera* GetCamera(); - virtual vtkRenderer* GetRenderer(); + vtkCamera* GetCamera(); + virtual vtkRenderer* GetRenderer(); virtual vtkRenderWindow* GetRenWin(); - void Refresh(); - void Configure(); - virtual void GetSpacing(double spc[3]); - void SetStereo(int type); - void ResetCamera(int *ext=NULL,double* spc=NULL); + void Refresh(); + void Configure(); + virtual void GetSpacing(double spc[3]); + void SetStereo(int type); + void ResetCamera(int *ext=NULL,double* spc=NULL); private: - bool _configure; - vtkRenderer *_aRenderer; + bool _configure; + vtkRenderer *_aRenderer; vtkRenderWindow *_renWin; - vtkCamera *_aCamera; + vtkCamera *_aCamera; protected: }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx index 2cd9da1..50354ae 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.cxx @@ -84,7 +84,6 @@ void wxVtkBaseView::Refresh() // virtual vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor(); vri->vtkRenderWindowInteractor::Render(); - //_iren->Refresh(); #endif @@ -100,7 +99,6 @@ void wxVtkBaseView::RefreshView() // virtual #else //GetRenWin()->Render(); #endif - } //--------------------------------------------------------------------------- vtkRenderer* wxVtkBaseView::GetRenderer() // virtual diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h index 79391aa..0ecedb5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkBaseView.h @@ -91,12 +91,9 @@ public: vtkInteractorStyleImage* GetInteractorStyleBaseView(); virtual void GetSpacing(double spc[3]); virtual int GetDirection(); - - vtkBaseData* GetVtkBaseData(); void SetVtkBaseData(vtkBaseData *vtkbasedata); - private: wxWindow *_parent; wxVTKRenderWindowInteractor *_iren; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h index c3c2451..dcff3c9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h @@ -42,11 +42,11 @@ public: virtual void Refresh(); virtual void Configure(); void SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer ); + vtkClipping3DDataViewer* GetVtkClipping3DDataViewer(); wxPanel* CreateSurfControlPanel(wxWindow *parent); wxPanel* CreateVolControlPanel(wxWindow *parent); - vtkClipping3DDataViewer* GetVtkClipping3DDataViewer(); void VisibleActor(int idTissue, bool visTissue); void VisibleVolumeActor( bool visVolume ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx index 5fbab3e..bee80ab 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx @@ -97,11 +97,9 @@ void wxVtkMPR2DView::Configure() x1 = (int)(x1*spc[0]); y1 = (int)(y1*spc[1]); z1 = (int)(z1*spc[2]); - x2 = (int)(x2*spc[0]); y2 = (int)(y2*spc[1]); z2 = (int)(z2*spc[2]); - _visibleAxis = true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx index 378dade..108b591 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.cxx @@ -343,6 +343,20 @@ void wxVtkMPR3DView::ConfigureFreePlanes() _planeWidgetZ->AddObserver(vtkCommand::InteractionEvent, wlipwc ); } + +//------------------------------------------------------------------- +void wxVtkMPR3DView::SetImage() +{ + vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); + // Orthogonal planes B&W + _planeWidgetX->SetInput( imageData ); + _planeWidgetY->SetInput( imageData ); + _planeWidgetZ->SetInput( imageData ); + // -- Plane widget + _probe->SetSource( imageData ); + _vtkmpr3Ddataviewer->SetImage(); +} + //------------------------------------------------------------------- vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker) { @@ -390,9 +404,6 @@ vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, //------------------------------------------------------------------- void wxVtkMPR3DView::SetFreePlanesOrtho() { - - - _planeWidgetX->SetPlaneOrientationToXAxes(); _planeWidgetY->SetPlaneOrientationToYAxes(); _planeWidgetZ->SetPlaneOrientationToZAxes(); @@ -480,7 +491,6 @@ void wxVtkMPR3DView::Refresh() // virtual { _wxvtkmpr3DviewCntrlPanel->Refresh(); } - } //------------------------------------------------------------------- @@ -489,7 +499,8 @@ void wxVtkMPR3DView::RefreshView() // virtual double spc[3]; vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData(); - if(image){ + if(image) + { image->GetSpacing(spc); }else{ spc[0] = 0; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h index f02d7d8..a46afe6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR3DView.h @@ -53,6 +53,8 @@ public: virtual void Refresh(); virtual void RefreshView(); virtual void Configure(); + void SetImage(); + void SetBackGroundType(int type); void SetVtkMPR3DDataViewer( vtkMPR3DDataViewer *vtkmpr3Ddataviewer ); wxPanel* CreateControlPanel(wxWindow *parent, bool align); -- 2.45.0