From b0230890274e619c44f9ac7e1fd277ef28c18108 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Thu, 21 Oct 2010 16:23:04 +0000 Subject: [PATCH] *** empty log message *** --- bbtk/src/bbcreaMaracasVisuManualPaint.cxx | 15 +- .../widgets/vtkInteractorScrollZ.cxx | 22 +- .../wxWindows/widgets/wxVtkMPR2DView.cxx | 246 +++++++++--------- 3 files changed, 141 insertions(+), 142 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx index f84fe8f..3ff6fbe 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx @@ -56,11 +56,11 @@ void ManualPaint::Process() { firsttime=false; - ManualPaintPanel *mpPanel = (ManualPaintPanel*)bbGetOutputWidget(); - ManualPaintModel *mpModel = new ManualPaintModel(); mpModel->SetImage( bbGetInputIn() ); + wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); + mpPanel->SetManualPaintModel(mpModel); ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); @@ -69,17 +69,6 @@ void ManualPaint::Process() mpControler->Config(); } - -/* - if (_imp==NULL) - { - _imp=new vtkInteractorManualPaint(); - _imp->SetImage( bbGetInputIn() ); - vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(bbGetInputWxVtkBaseView()->GetInteractorStyleBaseView()); - isbv->AddInteractorStyleMaracas(_imp); - } -*/ - } //===== // Don't edit this file. This file is generated from xml description.. diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorScrollZ.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorScrollZ.cxx index 9dae456..29f81ac 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorScrollZ.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkInteractorScrollZ.cxx @@ -9,13 +9,15 @@ vtkInteractorScrollZ::vtkInteractorScrollZ() { _stateFordware=false; } + //--------------------------------------------------------------------------- vtkInteractorScrollZ::~vtkInteractorScrollZ() { } + //--------------------------------------------------------------------------- bool vtkInteractorScrollZ::OnRightButtonDown() -{ +{ vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor(); if ((interactor->GetControlKey()==0) && (interactor->GetShiftKey()==0) ){ _stateFordware = true; @@ -28,31 +30,35 @@ bool vtkInteractorScrollZ::OnRightButtonDown() } return true; } + //--------------------------------------------------------------------------- -bool vtkInteractorScrollZ::OnRightButtonUp() +bool vtkInteractorScrollZ::OnRightButtonUp() { _stateFordware=false; return true; } + //--------------------------------------------------------------------------- -bool vtkInteractorScrollZ::OnMouseMove () +bool vtkInteractorScrollZ::OnMouseMove () { if (_stateFordware==true){ //int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; // JPRx - int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; - int delta = (_fordwareY - fy)/3; + int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1]; + double delta = (_fordwareY - fy)/3.0; /*JCP 14/05/2009 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->SetActualSlice( _sliceZ + delta); */ - ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->SetActualSlice( _sliceZ + delta); + ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->SetActualSlice( _sliceZ + (int)delta ); this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); // wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent); - //_wxvtk2Dbaseview->Refresh(); - } +//EED 21 oct 2010 +//printf("EED vtkInteractorScrollZ::OnMouseMove \n"); +// ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->Refresh(); + } return true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx index 247113e..bbceacf 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx @@ -25,14 +25,14 @@ wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction) //------------------------------------------------------------------- wxVtkMPR2DView::~wxVtkMPR2DView() { - if (_ptsA!=NULL) { _ptsA -> Delete(); } + if (_ptsA!=NULL) { _ptsA -> Delete(); } if (_lineAActor!=NULL) { _lineAActor -> Delete(); } if (_lineAMapper!=NULL) { _lineAMapper -> Delete(); } - if (_pdA!=NULL) { _pdA -> Delete(); } - if (_ptsB!=NULL) { _ptsB -> Delete(); } + if (_pdA!=NULL) { _pdA -> Delete(); } + if (_ptsB!=NULL) { _ptsB -> Delete(); } if (_lineBActor!=NULL) { _lineBActor -> Delete(); } if (_lineBMapper!=NULL) { _lineBMapper -> Delete(); } - if (_pdB!=NULL) { _pdB -> Delete(); } + if (_pdB!=NULL) { _pdB -> Delete(); } } //------------------------------------------------------------------- vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata() @@ -42,19 +42,19 @@ vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata() //------------------------------------------------------------------- void wxVtkMPR2DView::Configure(){ wxVtk2DBaseView::Configure(); - + int x1,x2,y1,y2,z1,z2; GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2); double spc[3]; vtkImageData* img = GetVtkmprbasedata()->GetImageData(); - if(_interactorstylemprview==NULL) + if(_interactorstylemprview==NULL) { _interactorstylemprview = new vtkInteractorStyleMPRView(); ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview ); } - + if(img!=NULL){ double* origin = img->GetOrigin(); img->GetExtent(x1,x2,y1,y2,z1,z2); @@ -74,31 +74,31 @@ void wxVtkMPR2DView::Configure(){ z2 = (int)(z2*spc[2]); _visibleAxis = true; - - - + + + } - + // Axe A if(_lineAActor==NULL){ _lineAActor = vtkActor::New(); _lineAActor->GetProperty()->SetDiffuseColor(1,0,0); _lineAActor->GetProperty()->SetLineWidth(2); - + _ptsA = vtkPoints::New(); _ptsA->SetNumberOfPoints(2); _ptsA->SetPoint(0, -1000 , -1000 , -1000 ); _ptsA->SetPoint(1, 1000 , 1000 , 1000 ); - + _pdA = vtkPolyData::New(); - + _lineAMapper = vtkPolyDataMapper::New(); - + _lineAMapper->SetInput(_pdA); _lineAMapper->ImmediateModeRenderingOn(); _lineAActor->SetMapper(_lineAMapper); - } - + } + vtkCellArray *linesA = vtkCellArray::New(); linesA->InsertNextCell(2); linesA->InsertCellPoint(0); @@ -107,24 +107,24 @@ void wxVtkMPR2DView::Configure(){ _pdA->SetLines( linesA ); linesA->Delete(); //do not delete lines ?? // _lineAActor->GetProperty()->BackfaceCullingOn(); - + // Axe B if(_lineBActor==NULL){ _lineBActor = vtkActor::New(); _lineBActor->GetProperty()->SetDiffuseColor(1,0,0); _lineBActor->GetProperty()->SetLineWidth(2); - _lineBMapper = vtkPolyDataMapper::New(); + _lineBMapper = vtkPolyDataMapper::New(); _lineBActor->SetMapper(_lineBMapper); - + _ptsB = vtkPoints::New(); _ptsB->SetNumberOfPoints(2); _ptsB->SetPoint(0, -1000 , -1000 , -1000 ); _ptsB->SetPoint(1, 1000 , 1000 , 1000 ); - + // _lineBActor->GetProperty()->BackfaceCullingOn(); } - + vtkCellArray *linesB; linesB = vtkCellArray::New(); linesB->InsertNextCell(2); @@ -134,8 +134,8 @@ void wxVtkMPR2DView::Configure(){ _pdB->SetPoints( _ptsB ); _pdB->SetLines( linesB ); linesB->Delete(); //do not delete lines ?? - - + + _lineBMapper->SetInput(_pdB); _lineBMapper->ImmediateModeRenderingOn(); @@ -144,52 +144,52 @@ void wxVtkMPR2DView::Configure(){ _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor ); _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor ); vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera(); - + //EED 17Avril2009 - /* + /* if (_direction==0) { camera->SetViewUp ( 0 , -1 , 0 ); - camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 ); + camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 ); camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 ); camera->SetParallelScale( (z2-z1)/3.0 ); } - if (_direction==1) { + if (_direction==1) { camera->SetViewUp ( 0 , 0 , -1 ); - camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 ); + camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 ); camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 ); camera->SetParallelScale( (x2-x1)/3.0 ); } - if (_direction==2) { + if (_direction==2) { camera->SetViewUp ( 0 , -1 , 0 ); - camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000); - camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 ); + camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000); + camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 ); camera->SetParallelScale( (x2-x1)/3.0 ); } */ if (_direction==0) { // YZ camera->SetViewUp ( 0 , 1 , 0 ); - camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 ); + camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 ); camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 ); camera->SetParallelScale( (z2-z1)/3.0 ); } - + if (_direction==1) { // XZ camera->SetViewUp ( 0 , 0 , -1 ); - camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 ); + camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 ); camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 ); camera->SetParallelScale( (x2-x1)/3.0 ); } - + if (_direction==2) { // XY camera->SetViewUp ( 0 , 1 , 0 ); - camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000); - camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 ); + camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000); + camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 ); camera->SetParallelScale( (x2-x1)/3.0 ); } - + // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160); // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800); @@ -217,8 +217,10 @@ void wxVtkMPR2DView::SetVisibleAxis(bool ok) } //------------------------------------------------------------------- -void wxVtkMPR2DView::Refresh() +void wxVtkMPR2DView::Refresh() { + + //wxVtk2DBaseView::Refresh(); @@ -227,14 +229,16 @@ void wxVtkMPR2DView::Refresh() - int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0, x = 0, y = 0, z = 0; - double *spc = 0; - double *origin = 0; - - + int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0; + int x = 0, y = 0, z = 0; + int xx = 0, yy = 0, zz = 0; + double *spc = 0; + double *origin = 0; + + //GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2); - - + + vtkImageData* img = GetVtkmprbasedata()->GetImageData(); if(img!=NULL){ origin = img->GetOrigin(); @@ -254,19 +258,19 @@ void wxVtkMPR2DView::Refresh() y2 = (int)(y2*spc[1]); z2 = (int)(z2*spc[2]); - x = (int)(GetVtkmprbasedata()->GetX()); - y = (int)(GetVtkmprbasedata()->GetY()); - z = (int)(GetVtkmprbasedata()->GetZ()); + xx = (int)(GetVtkmprbasedata()->GetX()); + yy = (int)(GetVtkmprbasedata()->GetY()); + zz = (int)(GetVtkmprbasedata()->GetZ()); - x = (int)(x*spc[0]); - y = (int)(y*spc[1]); - z = (int)(z*spc[2]); + x = round(xx*spc[0]); + y = round(yy*spc[1]); + z = round(zz*spc[2]); - if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) { + if ((xx!=_backX) || (yy!=_backY) || (zz!=_backZ)) { - if (_direction==0) { // YZ + if (_direction==0) { // YZ if(_imageViewer2XYZ) - _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) ); + _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) ); _ptsA->SetPoint(0, x2, y1 , z ); _ptsA->SetPoint(1, x2, y2 , z ); _ptsB->SetPoint(0, x2, y , z1); @@ -274,7 +278,7 @@ void wxVtkMPR2DView::Refresh() } if (_direction==1) { // XZ if(_imageViewer2XYZ) - _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) ); + _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) ); _ptsA->SetPoint(0, x1 , y2 , z ); _ptsA->SetPoint(1, x2 , y2 , z ); _ptsB->SetPoint(0, x , y2 , z1); @@ -282,20 +286,20 @@ void wxVtkMPR2DView::Refresh() } if (_direction==2) { // XY if(_imageViewer2XYZ) - _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) ); + _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) ); // _ptsA->SetPoint(0, x1 , y , -z2 ); // _ptsA->SetPoint(1, x2 , y , -z2 ); // _ptsB->SetPoint(0, x , y1, -z2 ); // _ptsB->SetPoint(1, x , y2, -z2 ); - + _ptsA->SetPoint(0, x1 , y , z2 ); _ptsA->SetPoint(1, x2 , y , z2 ); _ptsB->SetPoint(0, x , y1, z2 ); _ptsB->SetPoint(1, x , y2, z2 ); } - _backX=x; - _backY=y; - _backZ=z; + _backX=xx; + _backY=yy; + _backZ=zz; } wxVtkBaseView::Refresh(); } @@ -304,16 +308,16 @@ void wxVtkMPR2DView::Refresh() int wxVtkMPR2DView::GetActualSlice() // virtual { int result; - if (_direction==0) - { + if (_direction==0) + { result = (int)(GetVtkmprbasedata()->GetX()); } - if (_direction==1) - { + if (_direction==1) + { result = (int)(GetVtkmprbasedata()->GetY()); } - if (_direction==2) - { + if (_direction==2) + { result = (int)(GetVtkmprbasedata()->GetZ()); } return result; @@ -321,16 +325,16 @@ int wxVtkMPR2DView::GetActualSlice() // virtual //------------------------------------------------------------------- void wxVtkMPR2DView::SetActualSlice(int slice) // virtual { - if (_direction==0) - { + if (_direction==0) + { GetVtkmprbasedata()->SetX(slice); } - if (_direction==1) - { + if (_direction==1) + { GetVtkmprbasedata()->SetY(slice); } - if (_direction==2) - { + if (_direction==2) + { GetVtkmprbasedata()->SetZ(slice); } } @@ -339,18 +343,18 @@ bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z) { double delta=5; bool result=false; - if (_direction==0) - { + if (_direction==0) + { } - if (_direction==1) - { + if (_direction==1) + { if (( xGetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta )) { result = true; } } - if (_direction==2) - { + if (_direction==2) + { if (( xGetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta )) { result = true; @@ -363,18 +367,18 @@ bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z) { double delta=5; bool result=false; - if (_direction==0) - { + if (_direction==0) + { if (( yGetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta )) { result = true; } } - if (_direction==1) - { + if (_direction==1) + { } - if (_direction==2) - { + if (_direction==2) + { if (( yGetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta )) { result = true; @@ -387,68 +391,68 @@ bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z) { double delta=5; bool result=false; - if (_direction==0) - { + if (_direction==0) + { if (( zGetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta )) { result = true; } } - if (_direction==1) - { + if (_direction==1) + { if (( zGetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta )) { result = true; } } - if (_direction==2) - { + if (_direction==2) + { } return result; } //------------------------------------------------------------------- void wxVtkMPR2DView::MoveX(double x, double y, double z) { - if (_direction==0) - { + if (_direction==0) + { } - if (_direction==1) - { + if (_direction==1) + { GetVtkmprbasedata()->SetX(x); } - if (_direction==2) - { + if (_direction==2) + { GetVtkmprbasedata()->SetX(x); } } //------------------------------------------------------------------- void wxVtkMPR2DView::MoveY(double x, double y, double z) { - if (_direction==0) - { + if (_direction==0) + { GetVtkmprbasedata()->SetY(y); } - if (_direction==1) - { + if (_direction==1) + { } - if (_direction==2) - { + if (_direction==2) + { GetVtkmprbasedata()->SetY(y); } } //------------------------------------------------------------------- void wxVtkMPR2DView::MoveZ(double x, double y, double z) { - if (_direction==0) - { + if (_direction==0) + { GetVtkmprbasedata()->SetZ(z); } - if (_direction==1) - { + if (_direction==1) + { GetVtkmprbasedata()->SetZ(z); } - if (_direction==2) - { + if (_direction==2) + { } } //------------------------------------------------------------------- @@ -457,8 +461,8 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) double c1r=1,c1g=1,c1b=0; double c2r=1,c2g=0,c2b=0; - if (_direction==0) - { + if (_direction==0) + { if (IfMouseTouchY(x,y,z)==true) { _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b); @@ -473,8 +477,8 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) } } - if (_direction==1) - { + if (_direction==1) + { if (IfMouseTouchX(x,y,z)==true) { _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b); @@ -489,8 +493,8 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) } } - if (_direction==2) - { + if (_direction==2) + { if (IfMouseTouchX(x,y,z)==true) { _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b); @@ -509,27 +513,27 @@ void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z) //EED 5 juin 2009 -//void wxVtkMPR2DView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual +//void wxVtkMPR2DView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual void wxVtkMPR2DView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2 { - + wxVtkBaseView::TransFromCoordScreenToWorld(X,Y,Z,keepNormalDirection,_direction); if ((_direction==0) && (keepNormalDirection==true) ) { X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX(); } - + if ((_direction==1) && (keepNormalDirection==true) ) { Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY(); } - + if ((_direction==2) && (keepNormalDirection==true) ) { Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ(); } - + } -- 2.45.1