1 #include <vtkRenderer.h>
2 #include <vtkRenderWindowInteractor.h>
3 #include <vtkRenderWindow.h>
4 #include <vtkObjectFactory.h>
6 #include <vtkProperty.h>
8 #include <vtkInteractorStyleTrackballCamera.h>
9 #include <vtkInteractorStyleSwitch.h>
10 #include <vtkImageActor.h>
11 #include <vtkTextProperty.h>
12 #include <vtkImageMapToWindowLevelColors.h>
14 #include "wxVtkBaseView.h"
17 vtkStandardNewMacro(vtkInteractorStyleBaseView);
18 vtkStandardNewMacro(vtkInteractorStyleBaseView2D);
19 vtkStandardNewMacro(vtkInteractorStyleBaseView3D);
23 //-------------------------------------------------------------------
24 //-------------------------------------------------------------------
25 //-------------------------------------------------------------------
26 vtkImageViewer2_XYZ::vtkImageViewer2_XYZ()
28 _vtkimageviewer2= vtkImageViewer2::New();
30 //-------------------------------------------------------------------
31 vtkImageViewer2_XYZ::~vtkImageViewer2_XYZ()
33 _vtkimageviewer2->Delete();
35 //-------------------------------------------------------------------
36 void vtkImageViewer2_XYZ::SetExtentDimension(int x1,int x2,
47 //-------------------------------------------------------------------
48 void vtkImageViewer2_XYZ::SetXSlice(int slice)
50 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
51 imageActor->SetDisplayExtent(slice, slice, _y1, _y2, _z1, _z2 );
53 //-------------------------------------------------------------------
54 void vtkImageViewer2_XYZ::SetYSlice(int slice)
56 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
57 imageActor->SetDisplayExtent(_x1, _x2, slice, slice, _z1, _z2 );
59 //-------------------------------------------------------------------
60 void vtkImageViewer2_XYZ::SetZSlice(int slice)
62 #if (VTK_MAJOR_VERSION >= 5)
63 // _vtkimageviewer2->SetSlice( slice );
64 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
65 imageActor->SetDisplayExtent(_x1, _x2, _y1, _y2, slice, slice );
67 _vtkimageviewer2->SetZSlice( slice );
72 //-------------------------------------------------------------------
73 int vtkImageViewer2_XYZ::GetXSlice()
75 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
76 return imageActor->GetDisplayExtent()[0];
78 //-------------------------------------------------------------------
79 int vtkImageViewer2_XYZ::GetYSlice()
81 vtkImageActor *imageActor = _vtkimageviewer2->GetImageActor();
82 return imageActor->GetDisplayExtent()[2];
84 //-------------------------------------------------------------------
85 int vtkImageViewer2_XYZ::GetZSlice()
89 #if (VTK_MAJOR_VERSION >= 5)
90 result= _vtkimageviewer2->GetSlice( );
92 result= _vtkimageviewer2->GetZSlice( );
98 //-------------------------------------------------------------------
99 vtkImageViewer2 *vtkImageViewer2_XYZ::GetVtkImageViewer2()
101 return _vtkimageviewer2;
105 //-------------------------------------------------------------------
106 //-------------------------------------------------------------------
107 //-------------------------------------------------------------------
111 BEGIN_EVENT_TABLE( wxVTKRenderWindowInteractorPlus, wxVTKRenderWindowInteractor )
112 EVT_LEFT_DCLICK( wxVTKRenderWindowInteractorPlus::OnLeftDClick )
113 EVT_RIGHT_DCLICK( wxVTKRenderWindowInteractorPlus::OnRightDClick )
114 EVT_MIDDLE_DCLICK( wxVTKRenderWindowInteractorPlus::OnMiddleDClick )
115 EVT_MOUSEWHEEL( wxVTKRenderWindowInteractorPlus::OnMouseWheel )
118 //-------------------------------------------------------------------
119 wxVTKRenderWindowInteractorPlus::wxVTKRenderWindowInteractorPlus()
120 : wxVTKRenderWindowInteractor()
125 //-------------------------------------------------------------------
126 wxVTKRenderWindowInteractorPlus::wxVTKRenderWindowInteractorPlus(wxWindow *parent, wxVtkBaseView *wxvtkbaseview)
127 : wxVTKRenderWindowInteractor(parent, -1)
129 _wxvtkbaseview = wxvtkbaseview;
132 //-------------------------------------------------------------------
133 wxVTKRenderWindowInteractorPlus::~wxVTKRenderWindowInteractorPlus()
137 //---------------------------------------------------------------------------
138 wxVTKRenderWindowInteractorPlus * wxVTKRenderWindowInteractorPlus::New()
140 // we don't make use of the objectfactory, because we're not registered
141 return new wxVTKRenderWindowInteractorPlus;
144 //-------------------------------------------------------------------
145 void wxVTKRenderWindowInteractorPlus::OnLeftDClick( wxMouseEvent& event )
147 _wxvtkbaseview->GetInteractorStyleBaseView()->OnLeftDClick();
149 //-------------------------------------------------------------------
150 void wxVTKRenderWindowInteractorPlus::OnRightDClick( wxMouseEvent& event )
152 _wxvtkbaseview->GetInteractorStyleBaseView()->OnRightDClick();
154 //-------------------------------------------------------------------
155 void wxVTKRenderWindowInteractorPlus::OnMiddleDClick( wxMouseEvent& event )
157 _wxvtkbaseview->GetInteractorStyleBaseView()->OnMiddleDClick();
159 //-------------------------------------------------------------------
160 void wxVTKRenderWindowInteractorPlus::OnMouseWheel( wxMouseEvent& event )
162 _wxvtkbaseview->GetInteractorStyleBaseView()->OnMouseWheel();
167 //-------------------------------------------------------------------
168 //-------------------------------------------------------------------
169 //-------------------------------------------------------------------
170 wxVtkBaseView::wxVtkBaseView()
174 _interactorStyle = NULL;
177 //-------------------------------------------------------------------
179 wxVtkBaseView::wxVtkBaseView(wxWindow *parent)
182 _iren = new wxVTKRenderWindowInteractorPlus(_parent,this);
183 // _iren->UseCaptureMouseOn();
184 // _iren = new wxVTKRenderWindowInteractor(_parent,-1);
185 _interactorStyle = NULL;
190 //-------------------------------------------------------------------
191 wxVtkBaseView::~wxVtkBaseView()
195 //-------------------------------------------------------------------
196 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
200 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
204 //-------------------------------------------------------------------
205 void wxVtkBaseView::Configure() // virtual
208 //-------------------------------------------------------------------
209 void wxVtkBaseView::Refresh() // virtual
214 _iren->Refresh(false);
219 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
220 vri->vtkRenderWindowInteractor::Render();
227 //-------------------------------------------------------------------
228 void wxVtkBaseView::RefreshView() // virtual
233 GetRenWin()->Render();
235 //GetRenWin()->Render();
239 //---------------------------------------------------------------------------
240 vtkRenderer* wxVtkBaseView::GetRenderer() // virtual
244 //---------------------------------------------------------------------------
245 vtkRenderWindow* wxVtkBaseView::GetRenWin() // virtual
247 return _iren->GetRenderWindow();
250 //----------------------------------------------------------------------------
252 void wxVtkBaseView::TransfromeCoordScreenToWorld(double &X, double &Y, double &Z, int type) // virtual
254 GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
255 GetRenderer()->DisplayToWorld();
257 GetRenderer()->GetWorldPoint( fP );
265 this->GetInteractorStyleBaseView()->GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
281 //---------------------------------------------------------------------------
283 vtkInteractorStyleBaseView* wxVtkBaseView::GetInteractorStyleBaseView()
285 return _interactorStyle;
288 //---------------------------------------------------------------------------
290 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleBaseView* interactorStyle)
292 _interactorStyle = interactorStyle;
295 //---------------------------------------------------------------------------
297 void wxVtkBaseView::GetSpacing(double spc[3]) // virtual
305 //---------------------------------------------------------------------------
306 //---------------------------------------------------------------------------
307 //---------------------------------------------------------------------------
309 InteractorStyleMaracas::InteractorStyleMaracas()
312 _vtkInteractorStyleBaseView = NULL;
314 //---------------------------------------------------------------------------
315 InteractorStyleMaracas::~InteractorStyleMaracas()
319 // ----------------------------------------------------------------------------
320 InteractorStyleMaracas * InteractorStyleMaracas :: Clone() // virtual
322 InteractorStyleMaracas * clone = new InteractorStyleMaracas();
323 CopyAttributesTo(clone);
327 // ---------------------------------------------------------------------------
329 void InteractorStyleMaracas::CopyAttributesTo( InteractorStyleMaracas * cloneObject)
332 //<FATHERCLASS>::CopyAttributesTo(cloneObject);
334 cloneObject->SetActive( this->GetActive() );
338 //---------------------------------------------------------------------------
339 bool InteractorStyleMaracas::OnChar()
343 //---------------------------------------------------------------------------
344 bool InteractorStyleMaracas::OnMouseMove()
348 //---------------------------------------------------------------------------
349 bool InteractorStyleMaracas::OnLeftButtonDown()
353 //---------------------------------------------------------------------------
354 bool InteractorStyleMaracas::OnLeftButtonUp()
358 //---------------------------------------------------------------------------
359 bool InteractorStyleMaracas::OnLeftDClick()
363 //---------------------------------------------------------------------------
364 bool InteractorStyleMaracas::OnMiddleButtonDown()
368 //---------------------------------------------------------------------------
369 bool InteractorStyleMaracas::OnMiddleButtonUp()
373 //---------------------------------------------------------------------------
374 bool InteractorStyleMaracas::OnMiddleDClick()
378 //---------------------------------------------------------------------------
379 bool InteractorStyleMaracas::OnRightButtonDown()
383 //---------------------------------------------------------------------------
384 bool InteractorStyleMaracas::OnRightButtonUp()
388 //---------------------------------------------------------------------------
389 bool InteractorStyleMaracas::OnRightDClick()
393 //---------------------------------------------------------------------------
394 bool InteractorStyleMaracas::OnMouseWheel()
399 //---------------------------------------------------------------------------
400 void InteractorStyleMaracas::SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* vtkInteractorStyleBaseView)
402 _vtkInteractorStyleBaseView = vtkInteractorStyleBaseView;
405 //---------------------------------------------------------------------------
406 void InteractorStyleMaracas::RemoveVtkInteractorStyleBaseView()
408 _vtkInteractorStyleBaseView = NULL;
410 //---------------------------------------------------------------------------
411 void InteractorStyleMaracas::SetActive(bool active)
415 //---------------------------------------------------------------------------
416 bool InteractorStyleMaracas::GetActive()
423 //-------------------------------------------------------------------
424 //-------------------------------------------------------------------
425 //-------------------------------------------------------------------
427 manualInteractorWindowLevel::manualInteractorWindowLevel()
429 _stateWindowLevel = false;
436 //-------------------------------------------------------------------
438 manualInteractorWindowLevel::~manualInteractorWindowLevel()
442 //-------------------------------------------------------------------
444 bool manualInteractorWindowLevel::OnMouseMove() // virtual
447 if (_stateWindowLevel==true)
450 wxVTKRenderWindowInteractor *wxVTKiren;
451 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
452 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
453 int colorWin=_backWindow - 2*( _backPx - tmpPx );
454 int colorLev=_backLevel + 2*( _backPy - tmpPy );
473 vtkImageViewer2 *vtkimageviewer2;
474 vtkimageviewer2=_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
475 vtkimageviewer2->SetColorWindow(colorWin);
476 vtkimageviewer2->SetColorLevel(colorLev);
477 // vtkimageviewer2->Render();
482 //-------------------------------------------------------------------
484 bool manualInteractorWindowLevel::OnMiddleButtonDown() // virtual
486 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
487 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ){
489 _stateWindowLevel = true;
490 wxVTKRenderWindowInteractor *wxVTKiren;
491 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
492 wxVTKiren->GetEventPosition( _backPx , _backPy );
494 _backWindow = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorWindow());
495 _backLevel = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorLevel());
500 //-------------------------------------------------------------------
502 bool manualInteractorWindowLevel::OnMiddleButtonUp() // virtual
504 if (_stateWindowLevel==true)
506 _stateWindowLevel=false;
513 //---------------------------------------------------------------------------
514 //---------------------------------------------------------------------------
515 //---------------------------------------------------------------------------
517 vtkInteractorScrollZ::vtkInteractorScrollZ()
519 _stateFordware=false;
521 //---------------------------------------------------------------------------
522 vtkInteractorScrollZ::~vtkInteractorScrollZ()
525 //---------------------------------------------------------------------------
526 bool vtkInteractorScrollZ::OnRightButtonDown()
528 vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
529 if ((interactor->GetControlKey()==0) && (interactor->GetShiftKey()==0) ){
530 _stateFordware = true;
531 _fordwareX = interactor->GetEventPosition()[0];
532 _fordwareY = interactor->GetEventPosition()[1];
533 _sliceZ = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetActualSlice();
537 //---------------------------------------------------------------------------
538 bool vtkInteractorScrollZ::OnRightButtonUp()
540 _stateFordware=false;
543 //---------------------------------------------------------------------------
544 bool vtkInteractorScrollZ::OnMouseMove ()
546 if (_stateFordware==true){
547 //int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; // JPRx
548 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
549 int delta = (_fordwareY - fy)/3;
550 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->SetActualSlice( _sliceZ + delta);
552 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
554 // wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
555 // _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
557 //_wxvtk2Dbaseview->Refresh();
566 //---------------------------------------------------------------------------
567 //---------------------------------------------------------------------------
568 //---------------------------------------------------------------------------
570 vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
572 _refresh_waiting = false;
573 _parent_refresh_waiting = false;
574 _blockRefresh = false;
576 //---------------------------------------------------------------------------
577 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
580 //---------------------------------------------------------------------------
581 void vtkInteractorStyleBaseView::OnMouseMove() // virtual
583 CallLstInteractorStyleMaracas(3);
585 //---------------------------------------------------------------------------
586 void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual
588 CallLstInteractorStyleMaracas(4);
590 //---------------------------------------------------------------------------
591 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual
593 CallLstInteractorStyleMaracas(5);
596 //---------------------------------------------------------------------------
597 void vtkInteractorStyleBaseView::OnLeftDClick() // virtual
599 CallLstInteractorStyleMaracas( 11 );
602 //---------------------------------------------------------------------------
603 void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual
605 CallLstInteractorStyleMaracas(6);
607 //---------------------------------------------------------------------------
608 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual
610 CallLstInteractorStyleMaracas(7);
612 //---------------------------------------------------------------------------
613 void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual
615 CallLstInteractorStyleMaracas( 13 );
618 //---------------------------------------------------------------------------
619 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual
621 CallLstInteractorStyleMaracas(1);
623 //---------------------------------------------------------------------------
624 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual
626 CallLstInteractorStyleMaracas(2);
628 //---------------------------------------------------------------------------
629 void vtkInteractorStyleBaseView::OnRightDClick() // virtual
631 CallLstInteractorStyleMaracas( 12 );
633 //---------------------------------------------------------------------------
634 void vtkInteractorStyleBaseView::OnMouseWheel() // virtual
636 CallLstInteractorStyleMaracas( 14 );
638 //---------------------------------------------------------------------------
639 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
641 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
642 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
644 //---------------------------------------------------------------------------
645 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
647 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
648 int i, size = _lstInteractorStyleMaracas.size();
649 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
650 bool removed = false;
651 for (i=0; !removed && i<size; i++)
653 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
655 _lstInteractorStyleMaracas.erase(iter);
661 //---------------------------------------------------------------------------
662 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
664 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
665 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
667 //---------------------------------------------------------------------------
668 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
671 InteractorStyleMaracas *intStyMar;
673 int i,size=_lstInteractorStyleMaracas.size();
676 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
677 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
678 //for (i=0;i<size;i++)
680 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
688 intStyMar = _lstInteractorStyleMaracas[i];
689 if (intStyMar->GetActive()==true){
691 { // OnRightButtonDown
692 if (intStyMar->OnRightButtonDown()==false)
699 if (intStyMar->OnRightButtonUp()==false)
706 if (intStyMar->OnMouseMove()==false)
712 { // OnLeftButtonDown
713 if (intStyMar->OnLeftButtonDown()==false)
720 if (intStyMar->OnLeftButtonUp()==false)
726 { // OnMiddleButtonDown
727 if (intStyMar->OnMiddleButtonDown()==false)
733 { // OnMiddleButtonUp
734 if (intStyMar->OnMiddleButtonUp()==false)
740 { // OnMiddleButtonUp
741 if (intStyMar->OnChar()==false)
748 if (intStyMar->OnLeftDClick()==false)
755 if (intStyMar->OnRightDClick()==false)
762 if (intStyMar-> OnMiddleDClick()==false)
769 if (intStyMar->OnMouseWheel()==false)
779 //---------------------------------------------------------------------------
780 void vtkInteractorStyleBaseView::OnChar() // virtual
782 // char a=GetInteractor()->GetKeyCode();
783 CallLstInteractorStyleMaracas(10);
785 //---------------------------------------------------------------------------
786 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
788 vtkImageViewer2 *imageViewer = GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
790 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
791 imageViewer->GetRenderer()->DisplayToWorld();
793 imageViewer->GetRenderer()->GetWorldPoint( fP );
802 GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
808 //---------------------------------------------------------------------------
809 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
811 _wxvtkbaseview = wxvtkbaseview;
813 //---------------------------------------------------------------------------
814 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
816 return (wxVtk2DBaseView*)_wxvtkbaseview;
818 //---------------------------------------------------------------------------
819 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
821 return (wxVtk3DBaseView*)_wxvtkbaseview;
823 //---------------------------------------------------------------------------
824 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
826 InteractorStyleMaracas *intStyMar;
827 int i,size=_lstInteractorStyleMaracas.size();
830 intStyMar = _lstInteractorStyleMaracas[i];
831 intStyMar->SetActive(ok);
835 //---------------------------------------------------------------------------
836 void vtkInteractorStyleBaseView::SetRefresh_waiting()
838 _refresh_waiting=true;
840 //---------------------------------------------------------------------------
841 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
843 return _refresh_waiting;
845 //---------------------------------------------------------------------------
846 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
848 _parent_refresh_waiting=true;
850 //---------------------------------------------------------------------------
851 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
853 return _parent_refresh_waiting;
855 //---------------------------------------------------------------------------
856 void vtkInteractorStyleBaseView::EvaluateToRefresh()
859 if ( _blockRefresh==false )
861 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
863 _refresh_waiting = false;
864 this->_wxvtkbaseview->Refresh();
866 if (_parent_refresh_waiting==true)
868 _parent_refresh_waiting = false;
869 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
870 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
874 //---------------------------------------------------------------------------
875 void vtkInteractorStyleBaseView::BlockRefresh()
879 //---------------------------------------------------------------------------
880 void vtkInteractorStyleBaseView::UnBlockRefresh()
885 //---------------------------------------------------------------------------
886 //---------------------------------------------------------------------------
887 //---------------------------------------------------------------------------
891 //---------------------------------------------------------------------------
892 vtkInteractorStyleBaseView2D::vtkInteractorStyleBaseView2D()
894 _manualinteractorwindowlevel= new manualInteractorWindowLevel();
895 AddInteractorStyleMaracas( _manualinteractorwindowlevel );
897 _vtkInteractorScrollZ = new vtkInteractorScrollZ();
898 AddInteractorStyleMaracas(_vtkInteractorScrollZ);
901 //---------------------------------------------------------------------------
902 vtkInteractorStyleBaseView2D::~vtkInteractorStyleBaseView2D()
906 //---------------------------------------------------------------------------
907 void vtkInteractorStyleBaseView2D::OnRightButtonDown() // virtual
909 vtkInteractorStyleBaseView::OnRightButtonDown();
911 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
912 this->vtkInteractorStyleImage::OnRightButtonDown();
917 //---------------------------------------------------------------------------
918 void vtkInteractorStyleBaseView2D::OnRightButtonUp() // virtual
920 vtkInteractorStyleBaseView::OnRightButtonUp();
921 this->vtkInteractorStyleImage::OnRightButtonUp();
923 //---------------------------------------------------------------------------
924 void vtkInteractorStyleBaseView2D::OnMouseMove () // virtual
926 vtkInteractorStyleBaseView::OnMouseMove();
927 this->vtkInteractorStyleImage::OnMouseMove();
929 //---------------------------------------------------------------------------
930 void vtkInteractorStyleBaseView2D::OnLeftButtonDown() // virtual
932 vtkInteractorStyleBaseView::OnLeftButtonDown();
934 if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) )
936 this->vtkInteractorStyleImage::OnLeftButtonDown();
939 //---------------------------------------------------------------------------
940 void vtkInteractorStyleBaseView2D::OnLeftButtonUp () // virtual
942 vtkInteractorStyleBaseView::OnLeftButtonUp();
944 this->vtkInteractorStyleImage::OnLeftButtonUp();
946 //---------------------------------------------------------------------------
947 void vtkInteractorStyleBaseView2D::OnMiddleButtonDown () // virtual
949 vtkInteractorStyleBaseView::OnMiddleButtonDown();
951 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
953 this->vtkInteractorStyleImage::OnLeftButtonDown();
956 //---------------------------------------------------------------------------
957 void vtkInteractorStyleBaseView2D::OnMiddleButtonUp () // virtual
959 vtkInteractorStyleBaseView::OnMiddleButtonUp();
961 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
963 this->vtkInteractorStyleImage::OnLeftButtonUp();
969 //-------------------------------------------------------------------
970 //-------------------------------------------------------------------
971 //-------------------------------------------------------------------
974 //---------------------------------------------------------------------------
975 vtkInteractorStyleBaseView3D::vtkInteractorStyleBaseView3D(){
977 //---------------------------------------------------------------------------
978 vtkInteractorStyleBaseView3D::~vtkInteractorStyleBaseView3D(){
980 //---------------------------------------------------------------------------
981 void vtkInteractorStyleBaseView3D::OnRightButtonDown ()
983 vtkInteractorStyleBaseView::OnRightButtonDown();
986 if (GetInteractor()->GetControlKey()==1 ){
987 this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
990 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
991 this->Interactor->GetEventPosition()[1]);
993 if (this->CurrentRenderer == NULL)
998 if (this->Interactor->GetControlKey()) {
1003 //---------------------------------------------------------------------------
1004 void vtkInteractorStyleBaseView3D::OnRightButtonUp ()
1006 vtkInteractorStyleBaseView::OnRightButtonUp();
1009 if (GetInteractor()->GetControlKey()==1 ){
1010 this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
1015 switch (this->State)
1022 //---------------------------------------------------------------------------
1023 void vtkInteractorStyleBaseView3D::OnMouseMove ()
1025 vtkInteractorStyleBaseView::OnMouseMove();
1027 // this->vtkInteractorStyleTrackballCamera::OnMouseMove();
1029 // int x = this->Interactor->GetEventPosition()[0]; // JPRx
1030 // int y = this->Interactor->GetEventPosition()[1]; // JPRx
1033 // vtkRenderWindowInteractor *rwi = this->Interactor;
1035 // int lx = rwi->GetLastEventPosition()[0]; // JPRx
1036 // int ly = rwi->GetLastEventPosition()[1]; // JPRx
1037 // int dx = rwi->GetEventPosition()[0] ; // JPRx
1038 // int dy = rwi->GetEventPosition()[1] ; // JPRx
1041 switch (this->State)
1044 // this->FindPokedRenderer(x, y);
1046 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1050 // this->FindPokedRenderer(x, y);
1052 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1056 // this->FindPokedRenderer(x, y);
1058 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1062 // this->FindPokedRenderer(x, y);
1064 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1071 //---------------------------------------------------------------------------
1072 void vtkInteractorStyleBaseView3D::OnLeftButtonDown ()
1074 vtkInteractorStyleBaseView::OnLeftButtonDown();
1076 if (GetInteractor()->GetControlKey()==1 ){
1077 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1079 this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
1084 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1085 this->Interactor->GetEventPosition()[1]);
1086 if (this->CurrentRenderer == NULL)
1091 if (this->Interactor->GetControlKey()) {
1094 this->StartRotate();
1098 if (this->Interactor->GetShiftKey())
1100 if (this->Interactor->GetControlKey())
1111 if (this->Interactor->GetControlKey())
1117 this->StartRotate();
1124 //---------------------------------------------------------------------------
1125 void vtkInteractorStyleBaseView3D::OnLeftButtonUp ()
1127 vtkInteractorStyleBaseView::OnLeftButtonUp();
1130 if (GetInteractor()->GetControlKey()==1 ){
1131 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1133 this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
1136 switch (this->State)
1148 //---------------------------------------------------------------------------
1149 void vtkInteractorStyleBaseView3D::OnMiddleButtonDown ()
1151 vtkInteractorStyleBaseView::OnMiddleButtonDown();
1152 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1154 //---------------------------------------------------------------------------
1155 void vtkInteractorStyleBaseView3D::OnMiddleButtonUp ()
1157 vtkInteractorStyleBaseView::OnMiddleButtonUp();
1159 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1163 //-------------------------------------------------------------------
1164 //-------------------------------------------------------------------
1165 //-------------------------------------------------------------------
1167 vtkInfoTextImage::vtkInfoTextImage()
1169 _vtkText_WindowLevel = NULL;
1170 _vtkText_ColorLevel = NULL;
1171 _vtkText_position = NULL;
1172 _vtkText_pixelIntensity = NULL;
1173 _marimagedata = NULL;
1176 //-------------------------------------------------------------------
1178 vtkInfoTextImage::~vtkInfoTextImage()
1182 //-------------------------------------------------------------------
1184 void vtkInfoTextImage::Configure()
1186 _vtkText_WindowLevel = Create_Text_Label( 10 , 55 );
1187 _vtkText_ColorLevel = Create_Text_Label( 10 , 40 );
1188 _vtkText_position = Create_Text_Label( 10 , 25 );
1189 _vtkText_pixelIntensity = Create_Text_Label( 10 , 10 );
1193 //-------------------------------------------------------------------
1195 void vtkInfoTextImage::SetMarImageData(marImageData *marimagedata)
1197 _marimagedata=marimagedata;
1200 //-------------------------------------------------------------------
1202 void vtkInfoTextImage::SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview)
1204 _wxvtk2Dbaseview=wxvtk2Dbaseview;
1207 //-------------------------------------------------------------------
1209 vtkTextActor *vtkInfoTextImage::Create_Text_Label(int px, int py )
1211 // Text Window Level
1212 vtkTextActor *textActor = vtkTextActor::New();
1213 textActor->SetDisplayPosition(px, py);
1214 textActor->SetInput("0");
1216 // Set coordinates to match the old vtkScaledTextActor default value
1217 textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
1218 textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
1220 vtkTextProperty *tprop = textActor->GetTextProperty();
1221 tprop->SetFontSize(14);
1222 tprop->SetFontFamilyToArial();
1223 tprop->SetColor(1, 1, 0);
1224 _wxvtk2Dbaseview->GetRenderer()->AddActor2D(textActor);
1229 //-------------------------------------------------------------------
1231 void vtkInfoTextImage::PutWindowLevel()
1233 int value = (int)( _wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetWindow() );
1235 char resultText[50];
1237 strcpy(resultText,"w:");
1240 //ltoa ( (long)value , zTzxt , 10 );
1241 sprintf(zTzxt,"%d",value);
1243 strcat(resultText,zTzxt);
1244 _vtkText_WindowLevel -> SetInput(resultText);
1247 //-------------------------------------------------------------------
1249 void vtkInfoTextImage::PutColorLevel()
1251 int value = (int)(_wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetLevel());
1253 char resultText[50];
1255 strcpy(resultText,"c:");
1257 // itoa (value,zTzxt,10);
1258 sprintf(zTzxt,"%d",value);
1260 strcat(resultText,zTzxt);
1261 _vtkText_ColorLevel -> SetInput(resultText);
1264 //-------------------------------------------------------------------
1266 void vtkInfoTextImage::PutPosition(int xx,int yy, int zz)
1271 // _imagedata->GetSpacing(spa);
1272 // xx=xx*(1/spa[0]);
1273 // yy=yy*(1/spa[1]);
1277 char resultText[50];
1278 strcpy(resultText,"p: ");
1279 // itoa ((int)xx,zTzxt,10);
1280 sprintf(zTzxt,"%d",xx);
1282 strcat(resultText,zTzxt);
1283 strcat(resultText," , ");
1285 // itoa ((int)yy,zTzxt,10);
1286 sprintf(zTzxt,"%d",yy);
1288 strcat(resultText,zTzxt);
1289 strcat(resultText," , ");
1291 // itoa ((int)zz,zTzxt,10);
1292 sprintf(zTzxt,"%d",zz);
1294 strcat(resultText,zTzxt);
1298 int nX = _marimagedata->GetXOriginal(xx);
1299 int nY = _marimagedata->GetYOriginal(yy);
1300 int nZ = _marimagedata->GetZOriginal(zz);
1302 strcat(resultText," (");
1303 // ltoa ((int)nX,zTzxt,10);
1304 sprintf(zTzxt,"%d",nX);
1306 strcat(resultText,zTzxt);
1307 strcat(resultText,",");
1309 // ltoa ((int)nY,zTzxt,10);
1310 sprintf(zTzxt,"%d",nY);
1312 strcat(resultText,zTzxt);
1313 strcat(resultText,",");
1315 // ltoa ((int)nZ,zTzxt,10);
1316 sprintf(zTzxt,"%d",nZ);
1318 strcat(resultText,zTzxt);
1319 strcat(resultText,")");
1324 _vtkText_position -> SetInput(resultText);
1327 //-------------------------------------------------------------------
1329 void vtkInfoTextImage::PutPixelIntensity(int xx, int yy, int zz)
1337 vtkImageData *imagedata = _marimagedata->GetImageData();
1338 imagedata->GetDimensions(dim);
1339 imagedata->GetSpacing(spa);
1342 // xx=xx*(1/spa[0]);
1343 // yy=yy*(1/spa[1]);
1346 if ( (xx<0) || (xx>=dim[0]) || (yy<0) || (yy>=dim[1]) || (zz<0) || (zz>=dim[2]) )
1353 char resultText[50];
1354 strcpy(resultText,"GL: ");
1357 if (imagedata->GetScalarType()==VTK_BIT)
1359 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1360 // itoa (*pOrg,zTzxt,10);
1363 sprintf(zTzxt,"%d",0);
1367 sprintf(zTzxt,"%d",1);
1371 if (imagedata->GetScalarType()==VTK_CHAR)
1373 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1374 // itoa (*pOrg,zTzxt,10);
1376 sprintf(zTzxt,"%d",tmp);
1379 if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
1381 signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1382 // itoa (*pOrg,zTzxt,10);
1384 sprintf(zTzxt,"%d",tmp);
1387 if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
1389 unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1390 // itoa (*pOrg,zTzxt,10);
1392 sprintf(zTzxt,"%d",tmp);
1395 if (imagedata->GetScalarType()==VTK_SHORT)
1397 short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1398 // itoa (*pOrg,zTzxt,10);
1400 sprintf(zTzxt,"%d",tmp);
1403 if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
1405 unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1406 // itoa (*pOrg,zTzxt,10);
1408 sprintf(zTzxt,"%d",tmp);
1411 if (imagedata->GetScalarType()==VTK_INT)
1413 int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1414 // itoa (*pOrg,zTzxt,10);
1415 sprintf(zTzxt,"%d",*pOrg);
1418 if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
1420 unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1421 // itoa (*pOrg,zTzxt,10);
1423 sprintf(zTzxt,"%d",tmp);
1426 if (imagedata->GetScalarType()==VTK_LONG)
1428 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1429 // itoa (*pOrg,zTzxt,10);
1431 sprintf(zTzxt,"%3.2f",tmp);
1434 if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
1436 unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1437 // itoa (*pOrg,zTzxt,10);
1439 sprintf(zTzxt,"%3.2f",tmp);
1442 if (imagedata->GetScalarType()==VTK_FLOAT)
1444 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1445 // itoa (*pOrg,zTzxt,10);
1447 sprintf(zTzxt,"%3.2f",tmp);
1450 if (imagedata->GetScalarType()==VTK_DOUBLE)
1452 double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1453 // itoa (*pOrg,zTzxt,10);
1455 sprintf(zTzxt,"%3.2f",tmp);
1460 strcpy(zTzxt,"---");
1462 strcat(resultText,zTzxt);
1463 _vtkText_pixelIntensity -> SetInput(resultText);
1468 //-------------------------------------------------------------------
1469 //-------------------------------------------------------------------
1470 //-------------------------------------------------------------------
1472 vtkInfoTextImageInteractor::vtkInfoTextImageInteractor()
1476 //-------------------------------------------------------------------
1477 vtkInfoTextImageInteractor::~vtkInfoTextImageInteractor()
1481 //-------------------------------------------------------------------
1483 void vtkInfoTextImageInteractor::SetModelVtkInfoTextImage(vtkInfoTextImage *vtkinfotextimage)
1485 _vtkinfotextimage = vtkinfotextimage;
1488 //-------------------------------------------------------------------
1489 bool vtkInfoTextImageInteractor::OnMouseMove()
1492 wxVTKRenderWindowInteractor *wxVTKiren;
1493 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1494 wxVTKiren->GetEventPosition(X,Y);
1496 int z = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1497 double xx=X,yy=Y,zz=z;
1498 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransfromeCoordScreenToWorld(xx,yy,zz);
1500 GetVtkInfoTextImage()->PutWindowLevel();
1501 GetVtkInfoTextImage()->PutColorLevel();
1502 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1503 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1505 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1509 //-------------------------------------------------------------------
1510 vtkInfoTextImage *vtkInfoTextImageInteractor::GetVtkInfoTextImage()
1512 return _vtkinfotextimage;
1516 //-------------------------------------------------------------------
1517 //-------------------------------------------------------------------
1518 //-------------------------------------------------------------------
1521 wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent)
1522 :wxVtkBaseView(parent)
1524 _imageViewer2XYZ = NULL;
1525 _vtkIinfoTextImage = NULL;
1528 //-------------------------------------------------------------------
1529 wxVtk2DBaseView::~wxVtk2DBaseView()
1531 if (_imageViewer2XYZ!=NULL) {
1532 delete _imageViewer2XYZ;
1535 if (_imageViewer2XYZ!=NULL) {
1536 delete _vtkIinfoTextImage;
1541 //-------------------------------------------------------------------
1542 void wxVtk2DBaseView::TransformCoordinate_spacing_ViewToModel(double &X,double &Y, double &Z) // virtual
1546 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1547 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1555 //-------------------------------------------------------------------
1556 void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double &Y, double &Z) // virtual
1560 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1561 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1569 //-------------------------------------------------------------------
1570 void wxVtk2DBaseView::ResetView()
1573 int x1,x2,y1,y2,z1,z2;
1574 wxVtkBaseView::Configure();
1576 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1577 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1578 imageData->UpdateInformation();
1579 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1580 imageData->Update();
1582 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1583 imageData->GetSpacing (spx,spy,spz);
1584 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1585 _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
1586 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1588 _imageViewer2XYZ->GetVtkImageViewer2()->Render();
1590 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1595 //-------------------------------------------------------------------
1596 void wxVtk2DBaseView::Configure(bool okimage)
1599 int x1,x2,y1,y2,z1,z2;
1600 wxVtkBaseView::Configure();
1603 if (_imageViewer2XYZ==NULL)
1605 _imageViewer2XYZ = new vtkImageViewer2_XYZ();
1606 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1607 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1608 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1612 vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
1613 if (imageData!=NULL){
1614 imageData->UpdateInformation();
1615 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1616 imageData->Update();
1618 imageData->GetSpacing (spx,spy,spz);
1619 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1622 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1623 _imageViewer2XYZ->SetExtentDimension(x1,x2,y1,y2,z1,z2);
1625 imageData->GetScalarRange(range);
1626 if (range[1]<20000){
1627 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( (range[1]-range[0])/2 );
1628 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( (range[1]+range[0])/4 );
1630 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
1631 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
1633 // EED 31 Janvier 2007
1634 //vtkImageActor *vtkimageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor ();
1635 //vtkimageactor->InterpolateOff ();
1636 //vtkLookupTable * _collookup = vtkLookupTable::New( );
1637 //_collookup->SetNumberOfColors( 256 );
1638 //_collookup->SetTableRange( 0 , 255 );
1639 //_collookup->Build( );
1640 //_collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
1641 //_collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
1642 //_collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
1643 //_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel ()->SetLookupTable(_collookup );
1647 // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1650 vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2();
1651 vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera();
1655 camera->SetViewUp ( spx*0 , -spy*1 , spz*0 );
1656 camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000 );
1657 camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
1659 camera->SetViewUp ( spx*0 , spy*1 , spz*0 );
1660 camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*10000 );
1661 camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
1664 camera->SetClippingRange( 0.01 , 1000000 );
1665 camera->ComputeViewPlaneNormal();
1666 camera->SetParallelScale( spx*(x2-x1)/3.0 );
1668 // text information over the graphic window
1669 _vtkIinfoTextImage = new vtkInfoTextImage();
1670 _vtkIinfoTextImageInteractor = new vtkInfoTextImageInteractor();
1671 _vtkIinfoTextImage->SetWxVtk2DBaseView(this);
1672 _vtkIinfoTextImage->SetMarImageData( GetVtkBaseData()->GetMarImageData() );
1673 _vtkIinfoTextImageInteractor->SetModelVtkInfoTextImage(_vtkIinfoTextImage);
1674 _vtkIinfoTextImage->Configure();
1675 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkIinfoTextImageInteractor);
1681 //-------------------------------------------------------------------
1683 int wxVtk2DBaseView::GetActualSlice() // virtual
1685 return (int)(_vtkbasedata->GetZ());
1688 //-------------------------------------------------------------------
1689 void wxVtk2DBaseView::SetActualSlice(int slice) // Virtual
1691 _vtkbasedata->SetZ(slice);
1694 //-------------------------------------------------------------------
1696 vtkBaseData *wxVtk2DBaseView::GetVtkBaseData()
1698 return _vtkbasedata;
1701 //-------------------------------------------------------------------
1703 void wxVtk2DBaseView::SetVtkBaseData(vtkBaseData *vtkbasedata)
1705 _vtkbasedata=vtkbasedata;
1708 //-------------------------------------------------------------------
1710 void wxVtk2DBaseView::Refresh()
1712 int z = (int)(GetVtkBaseData()->GetZ());
1713 _imageViewer2XYZ->SetZSlice( z );
1715 wxVtkBaseView::Refresh();
1718 //-------------------------------------------------------------------
1720 void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview)
1722 SetInteractorStyleBaseView(interactorstylebaseview);
1724 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1725 interactorstylebaseview->SetInteractor ( iren );
1726 iren->SetInteractorStyle(interactorstylebaseview);
1727 interactorstylebaseview->SetwxVtkBaseView(this);
1729 vtkMaracasImageViewer2Callback *cbk = vtkMaracasImageViewer2Callback::New();
1730 cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
1731 interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
1732 interactorstylebaseview->AddObserver( vtkCommand::StartWindowLevelEvent, cbk );
1733 interactorstylebaseview->AddObserver( vtkCommand::ResetWindowLevelEvent, cbk );
1737 //---------------------------------------------------------------------------
1738 vtkRenderer* wxVtk2DBaseView::GetRenderer() // virtual
1740 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer();
1742 //---------------------------------------------------------------------------
1743 vtkRenderWindow* wxVtk2DBaseView::GetRenWin() // virtual
1745 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderWindow();
1748 //-------------------------------------------------------------------
1750 void wxVtk2DBaseView::GetSpacing(double spc[3]) // virtual
1752 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1753 imageData->GetSpacing(spc);
1756 //-------------------------------------------------------------------
1757 //-------------------------------------------------------------------
1758 //-------------------------------------------------------------------
1763 wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent)
1764 :wxVtkBaseView( parent )
1771 //-------------------------------------------------------------------
1772 wxVtk3DBaseView::~wxVtk3DBaseView()
1774 if (_aCamera!=NULL) { _aCamera -> Delete(); }
1775 if (_aRenderer!=NULL) { _aRenderer -> Delete(); }
1776 if (_renWin!=NULL) { _renWin -> Delete(); }
1778 //-------------------------------------------------------------------
1779 vtkCamera* wxVtk3DBaseView::GetCamera()
1783 //-------------------------------------------------------------------
1784 vtkRenderer* wxVtk3DBaseView::GetRenderer() // virtual
1788 //-------------------------------------------------------------------
1789 vtkRenderWindow* wxVtk3DBaseView::GetRenWin() // virtual
1793 //-------------------------------------------------------------------
1794 void wxVtk3DBaseView::Refresh()
1796 // _renWin->Render();
1797 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
1798 vri->vtkRenderWindowInteractor::Render();
1800 //-------------------------------------------------------------------
1801 void wxVtk3DBaseView::Configure()
1803 if (_configure==false)
1806 //wxVtkBaseView::Configure();
1807 _aRenderer = vtkRenderer::New();
1808 _renWin = vtkRenderWindow::New();
1809 _renWin->AddRenderer(_aRenderer);
1812 // _renWin->SetStereoCapableWindow(1);
1813 // // //renderwindow->SetStereoTypeToCrystalEyes();
1814 // _renWin->SetStereoTypeToRedBlue();
1815 // _renWin->SetStereoRender(1);
1817 GetWxVTKRenderWindowInteractor()->SetRenderWindow(_renWin);
1821 // vtkInteractorStyle3DMaracas *interactorStyle3DMaracas = vtkInteractorStyle3DMaracas::New();
1822 vtkInteractorStyleBaseView3D *interactorStyleBaseView3D = vtkInteractorStyleBaseView3D::New();
1824 SetInteractorStyleBaseView( interactorStyleBaseView3D );
1825 interactorStyleBaseView3D->SetInteractor ( GetWxVTKRenderWindowInteractor() );
1826 GetWxVTKRenderWindowInteractor()->SetInteractorStyle( interactorStyleBaseView3D );
1827 interactorStyleBaseView3D->SetwxVtkBaseView(this);
1831 vtkInteractorStyleSwitch *iss = dynamic_cast<vtkInteractorStyleSwitch*>(_iren->GetInteractorStyle());
1832 iss->SetCurrentStyleToTrackballCamera();
1835 // It is convenient to create an initial view of the data. The
1836 // FocalPoint and Position form a vector direction. Later on
1837 // (ResetCamera() method) this vector is used to position the camera
1838 // to look at the data in this direction.
1839 _aCamera = vtkCamera::New();
1843 _aCamera->SetViewUp (0, 0, -1);
1844 _aCamera->SetPosition (0, 1, 0);
1846 _aCamera->SetViewUp (0, 1, 0);
1847 _aCamera->SetPosition (0, 0, 1);
1849 _aCamera->SetFocalPoint (0, 0, 0);
1850 _aCamera->ComputeViewPlaneNormal();
1854 //-------------------------------------------------------------------
1856 void wxVtk3DBaseView::GetSpacing(double spc[3])