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()
193 // _iren -> Delete();
196 //-------------------------------------------------------------------
197 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor() throw (char*)
201 throw "wxVtkBaseView::GetWxVTKRenderWindowInteractor() _iren wxVTKRenderWindowInteractorPlus =NULL";
205 //-------------------------------------------------------------------
206 void wxVtkBaseView::Configure() // virtual
209 //-------------------------------------------------------------------
210 void wxVtkBaseView::Refresh() // virtual
215 _iren->Refresh(false);
220 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
221 vri->vtkRenderWindowInteractor::Render();
228 //-------------------------------------------------------------------
229 void wxVtkBaseView::RefreshView() // virtual
234 GetRenWin()->Render();
236 //GetRenWin()->Render();
240 //---------------------------------------------------------------------------
241 vtkRenderer* wxVtkBaseView::GetRenderer() // virtual
245 //---------------------------------------------------------------------------
246 vtkRenderWindow* wxVtkBaseView::GetRenWin() // virtual
248 return _iren->GetRenderWindow();
251 //----------------------------------------------------------------------------
253 void wxVtkBaseView::TransfromeCoordScreenToWorld(double &X, double &Y, double &Z, int type) // virtual
255 GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
256 GetRenderer()->DisplayToWorld();
258 GetRenderer()->GetWorldPoint( fP );
266 this->GetInteractorStyleBaseView()->GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
282 //---------------------------------------------------------------------------
284 vtkInteractorStyleBaseView* wxVtkBaseView::GetInteractorStyleBaseView()
286 return _interactorStyle;
289 //---------------------------------------------------------------------------
291 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleBaseView* interactorStyle)
293 _interactorStyle = interactorStyle;
296 //---------------------------------------------------------------------------
298 void wxVtkBaseView::GetSpacing(double spc[3]) // virtual
306 //---------------------------------------------------------------------------
307 //---------------------------------------------------------------------------
308 //---------------------------------------------------------------------------
310 InteractorStyleMaracas::InteractorStyleMaracas()
313 _vtkInteractorStyleBaseView = NULL;
315 //---------------------------------------------------------------------------
316 InteractorStyleMaracas::~InteractorStyleMaracas()
320 // ----------------------------------------------------------------------------
321 InteractorStyleMaracas * InteractorStyleMaracas :: Clone() // virtual
323 InteractorStyleMaracas * clone = new InteractorStyleMaracas();
324 CopyAttributesTo(clone);
328 // ---------------------------------------------------------------------------
330 void InteractorStyleMaracas::CopyAttributesTo( InteractorStyleMaracas * cloneObject)
333 //<FATHERCLASS>::CopyAttributesTo(cloneObject);
335 cloneObject->SetActive( this->GetActive() );
339 //---------------------------------------------------------------------------
340 bool InteractorStyleMaracas::OnChar()
344 //---------------------------------------------------------------------------
345 bool InteractorStyleMaracas::OnMouseMove()
349 //---------------------------------------------------------------------------
350 bool InteractorStyleMaracas::OnLeftButtonDown()
354 //---------------------------------------------------------------------------
355 bool InteractorStyleMaracas::OnLeftButtonUp()
359 //---------------------------------------------------------------------------
360 bool InteractorStyleMaracas::OnLeftDClick()
364 //---------------------------------------------------------------------------
365 bool InteractorStyleMaracas::OnMiddleButtonDown()
369 //---------------------------------------------------------------------------
370 bool InteractorStyleMaracas::OnMiddleButtonUp()
374 //---------------------------------------------------------------------------
375 bool InteractorStyleMaracas::OnMiddleDClick()
379 //---------------------------------------------------------------------------
380 bool InteractorStyleMaracas::OnRightButtonDown()
384 //---------------------------------------------------------------------------
385 bool InteractorStyleMaracas::OnRightButtonUp()
389 //---------------------------------------------------------------------------
390 bool InteractorStyleMaracas::OnRightDClick()
394 //---------------------------------------------------------------------------
395 bool InteractorStyleMaracas::OnMouseWheel()
400 //---------------------------------------------------------------------------
401 void InteractorStyleMaracas::SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* vtkInteractorStyleBaseView)
403 _vtkInteractorStyleBaseView = vtkInteractorStyleBaseView;
406 //---------------------------------------------------------------------------
407 void InteractorStyleMaracas::RemoveVtkInteractorStyleBaseView()
409 _vtkInteractorStyleBaseView = NULL;
411 //---------------------------------------------------------------------------
412 void InteractorStyleMaracas::SetActive(bool active)
416 //---------------------------------------------------------------------------
417 bool InteractorStyleMaracas::GetActive()
424 //-------------------------------------------------------------------
425 //-------------------------------------------------------------------
426 //-------------------------------------------------------------------
428 manualInteractorWindowLevel::manualInteractorWindowLevel()
430 _stateWindowLevel = false;
437 //-------------------------------------------------------------------
439 manualInteractorWindowLevel::~manualInteractorWindowLevel()
443 //-------------------------------------------------------------------
445 bool manualInteractorWindowLevel::OnMouseMove() // virtual
448 if (_stateWindowLevel==true)
451 wxVTKRenderWindowInteractor *wxVTKiren;
452 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
453 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
454 int colorWin=_backWindow - 2*( _backPx - tmpPx );
455 int colorLev=_backLevel + 2*( _backPy - tmpPy );
474 vtkImageViewer2 *vtkimageviewer2;
475 vtkimageviewer2=_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
476 vtkimageviewer2->SetColorWindow(colorWin);
477 vtkimageviewer2->SetColorLevel(colorLev);
478 // vtkimageviewer2->Render();
483 //-------------------------------------------------------------------
485 bool manualInteractorWindowLevel::OnMiddleButtonDown() // virtual
487 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
488 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ){
490 _stateWindowLevel = true;
491 wxVTKRenderWindowInteractor *wxVTKiren;
492 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
493 wxVTKiren->GetEventPosition( _backPx , _backPy );
495 _backWindow = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorWindow());
496 _backLevel = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorLevel());
501 //-------------------------------------------------------------------
503 bool manualInteractorWindowLevel::OnMiddleButtonUp() // virtual
505 if (_stateWindowLevel==true)
507 _stateWindowLevel=false;
514 //---------------------------------------------------------------------------
515 //---------------------------------------------------------------------------
516 //---------------------------------------------------------------------------
518 vtkInteractorScrollZ::vtkInteractorScrollZ()
520 _stateFordware=false;
522 //---------------------------------------------------------------------------
523 vtkInteractorScrollZ::~vtkInteractorScrollZ()
526 //---------------------------------------------------------------------------
527 bool vtkInteractorScrollZ::OnRightButtonDown()
529 vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
530 if ((interactor->GetControlKey()==0) && (interactor->GetShiftKey()==0) ){
531 _stateFordware = true;
532 _fordwareX = interactor->GetEventPosition()[0];
533 _fordwareY = interactor->GetEventPosition()[1];
534 _sliceZ = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetActualSlice();
538 //---------------------------------------------------------------------------
539 bool vtkInteractorScrollZ::OnRightButtonUp()
541 _stateFordware=false;
544 //---------------------------------------------------------------------------
545 bool vtkInteractorScrollZ::OnMouseMove ()
547 if (_stateFordware==true){
548 //int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; // JPRx
549 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
550 int delta = (_fordwareY - fy)/3;
551 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->SetActualSlice( _sliceZ + delta);
553 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
555 // wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
556 // _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
558 //_wxvtk2Dbaseview->Refresh();
567 //---------------------------------------------------------------------------
568 //---------------------------------------------------------------------------
569 //---------------------------------------------------------------------------
571 vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
573 _refresh_waiting = false;
574 _parent_refresh_waiting = false;
575 _blockRefresh = false;
577 //---------------------------------------------------------------------------
578 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
581 //---------------------------------------------------------------------------
582 void vtkInteractorStyleBaseView::OnMouseMove() // virtual
584 CallLstInteractorStyleMaracas(3);
586 //---------------------------------------------------------------------------
587 void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual
589 CallLstInteractorStyleMaracas(4);
591 //---------------------------------------------------------------------------
592 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual
594 CallLstInteractorStyleMaracas(5);
597 //---------------------------------------------------------------------------
598 void vtkInteractorStyleBaseView::OnLeftDClick() // virtual
600 CallLstInteractorStyleMaracas( 11 );
603 //---------------------------------------------------------------------------
604 void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual
606 CallLstInteractorStyleMaracas(6);
608 //---------------------------------------------------------------------------
609 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual
611 CallLstInteractorStyleMaracas(7);
613 //---------------------------------------------------------------------------
614 void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual
616 CallLstInteractorStyleMaracas( 13 );
619 //---------------------------------------------------------------------------
620 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual
622 CallLstInteractorStyleMaracas(1);
624 //---------------------------------------------------------------------------
625 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual
627 CallLstInteractorStyleMaracas(2);
629 //---------------------------------------------------------------------------
630 void vtkInteractorStyleBaseView::OnRightDClick() // virtual
632 CallLstInteractorStyleMaracas( 12 );
634 //---------------------------------------------------------------------------
635 void vtkInteractorStyleBaseView::OnMouseWheel() // virtual
637 CallLstInteractorStyleMaracas( 14 );
639 //---------------------------------------------------------------------------
640 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
642 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
643 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
645 //---------------------------------------------------------------------------
646 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
648 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
649 int i, size = _lstInteractorStyleMaracas.size();
650 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
651 bool removed = false;
652 for (i=0; !removed && i<size; i++)
654 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
656 _lstInteractorStyleMaracas.erase(iter);
662 //---------------------------------------------------------------------------
663 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
665 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
666 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
668 //---------------------------------------------------------------------------
669 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
672 InteractorStyleMaracas *intStyMar;
674 int i,size=_lstInteractorStyleMaracas.size();
677 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
678 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
679 //for (i=0;i<size;i++)
681 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
689 intStyMar = _lstInteractorStyleMaracas[i];
690 if (intStyMar->GetActive()==true){
692 { // OnRightButtonDown
693 if (intStyMar->OnRightButtonDown()==false)
700 if (intStyMar->OnRightButtonUp()==false)
707 if (intStyMar->OnMouseMove()==false)
713 { // OnLeftButtonDown
714 if (intStyMar->OnLeftButtonDown()==false)
721 if (intStyMar->OnLeftButtonUp()==false)
727 { // OnMiddleButtonDown
728 if (intStyMar->OnMiddleButtonDown()==false)
734 { // OnMiddleButtonUp
735 if (intStyMar->OnMiddleButtonUp()==false)
741 { // OnMiddleButtonUp
742 if (intStyMar->OnChar()==false)
749 if (intStyMar->OnLeftDClick()==false)
756 if (intStyMar->OnRightDClick()==false)
763 if (intStyMar-> OnMiddleDClick()==false)
770 if (intStyMar->OnMouseWheel()==false)
780 //---------------------------------------------------------------------------
781 void vtkInteractorStyleBaseView::OnChar() // virtual
783 // char a=GetInteractor()->GetKeyCode();
784 CallLstInteractorStyleMaracas(10);
786 //---------------------------------------------------------------------------
787 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
789 vtkImageViewer2 *imageViewer = GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
791 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
792 imageViewer->GetRenderer()->DisplayToWorld();
794 imageViewer->GetRenderer()->GetWorldPoint( fP );
803 GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
809 //---------------------------------------------------------------------------
810 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
812 _wxvtkbaseview = wxvtkbaseview;
814 //---------------------------------------------------------------------------
815 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
817 return (wxVtk2DBaseView*)_wxvtkbaseview;
819 //---------------------------------------------------------------------------
820 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
822 return (wxVtk3DBaseView*)_wxvtkbaseview;
824 //---------------------------------------------------------------------------
825 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
827 InteractorStyleMaracas *intStyMar;
828 int i,size=_lstInteractorStyleMaracas.size();
831 intStyMar = _lstInteractorStyleMaracas[i];
832 intStyMar->SetActive(ok);
836 //---------------------------------------------------------------------------
837 void vtkInteractorStyleBaseView::SetRefresh_waiting()
839 _refresh_waiting=true;
841 //---------------------------------------------------------------------------
842 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
844 return _refresh_waiting;
846 //---------------------------------------------------------------------------
847 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
849 _parent_refresh_waiting=true;
851 //---------------------------------------------------------------------------
852 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
854 return _parent_refresh_waiting;
856 //---------------------------------------------------------------------------
857 void vtkInteractorStyleBaseView::EvaluateToRefresh()
860 if ( _blockRefresh==false )
862 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
864 _refresh_waiting = false;
865 this->_wxvtkbaseview->Refresh();
867 if (_parent_refresh_waiting==true)
869 _parent_refresh_waiting = false;
870 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
871 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
875 //---------------------------------------------------------------------------
876 void vtkInteractorStyleBaseView::BlockRefresh()
880 //---------------------------------------------------------------------------
881 void vtkInteractorStyleBaseView::UnBlockRefresh()
886 //---------------------------------------------------------------------------
887 //---------------------------------------------------------------------------
888 //---------------------------------------------------------------------------
892 //---------------------------------------------------------------------------
893 vtkInteractorStyleBaseView2D::vtkInteractorStyleBaseView2D()
895 _manualinteractorwindowlevel= new manualInteractorWindowLevel();
896 AddInteractorStyleMaracas( _manualinteractorwindowlevel );
898 _vtkInteractorScrollZ = new vtkInteractorScrollZ();
899 AddInteractorStyleMaracas(_vtkInteractorScrollZ);
902 //---------------------------------------------------------------------------
903 vtkInteractorStyleBaseView2D::~vtkInteractorStyleBaseView2D()
907 //---------------------------------------------------------------------------
908 void vtkInteractorStyleBaseView2D::OnRightButtonDown() // virtual
910 vtkInteractorStyleBaseView::OnRightButtonDown();
912 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
913 this->vtkInteractorStyleImage::OnRightButtonDown();
918 //---------------------------------------------------------------------------
919 void vtkInteractorStyleBaseView2D::OnRightButtonUp() // virtual
921 vtkInteractorStyleBaseView::OnRightButtonUp();
922 this->vtkInteractorStyleImage::OnRightButtonUp();
924 //---------------------------------------------------------------------------
925 void vtkInteractorStyleBaseView2D::OnMouseMove () // virtual
927 vtkInteractorStyleBaseView::OnMouseMove();
928 this->vtkInteractorStyleImage::OnMouseMove();
930 //---------------------------------------------------------------------------
931 void vtkInteractorStyleBaseView2D::OnLeftButtonDown() // virtual
933 vtkInteractorStyleBaseView::OnLeftButtonDown();
935 if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) )
937 this->vtkInteractorStyleImage::OnLeftButtonDown();
940 //---------------------------------------------------------------------------
941 void vtkInteractorStyleBaseView2D::OnLeftButtonUp () // virtual
943 vtkInteractorStyleBaseView::OnLeftButtonUp();
945 this->vtkInteractorStyleImage::OnLeftButtonUp();
947 //---------------------------------------------------------------------------
948 void vtkInteractorStyleBaseView2D::OnMiddleButtonDown () // virtual
950 vtkInteractorStyleBaseView::OnMiddleButtonDown();
952 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
954 this->vtkInteractorStyleImage::OnLeftButtonDown();
957 //---------------------------------------------------------------------------
958 void vtkInteractorStyleBaseView2D::OnMiddleButtonUp () // virtual
960 vtkInteractorStyleBaseView::OnMiddleButtonUp();
962 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
964 this->vtkInteractorStyleImage::OnLeftButtonUp();
970 //-------------------------------------------------------------------
971 //-------------------------------------------------------------------
972 //-------------------------------------------------------------------
975 //---------------------------------------------------------------------------
976 vtkInteractorStyleBaseView3D::vtkInteractorStyleBaseView3D(){
978 //---------------------------------------------------------------------------
979 vtkInteractorStyleBaseView3D::~vtkInteractorStyleBaseView3D(){
981 //---------------------------------------------------------------------------
982 void vtkInteractorStyleBaseView3D::OnRightButtonDown ()
984 vtkInteractorStyleBaseView::OnRightButtonDown();
987 if (GetInteractor()->GetControlKey()==1 ){
988 this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
991 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
992 this->Interactor->GetEventPosition()[1]);
994 if (this->CurrentRenderer == NULL)
999 if (this->Interactor->GetControlKey()) {
1004 //---------------------------------------------------------------------------
1005 void vtkInteractorStyleBaseView3D::OnRightButtonUp ()
1007 vtkInteractorStyleBaseView::OnRightButtonUp();
1010 if (GetInteractor()->GetControlKey()==1 ){
1011 this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
1016 switch (this->State)
1023 //---------------------------------------------------------------------------
1024 void vtkInteractorStyleBaseView3D::OnMouseMove ()
1026 vtkInteractorStyleBaseView::OnMouseMove();
1028 // this->vtkInteractorStyleTrackballCamera::OnMouseMove();
1030 // int x = this->Interactor->GetEventPosition()[0]; // JPRx
1031 // int y = this->Interactor->GetEventPosition()[1]; // JPRx
1034 // vtkRenderWindowInteractor *rwi = this->Interactor;
1036 // int lx = rwi->GetLastEventPosition()[0]; // JPRx
1037 // int ly = rwi->GetLastEventPosition()[1]; // JPRx
1038 // int dx = rwi->GetEventPosition()[0] ; // JPRx
1039 // int dy = rwi->GetEventPosition()[1] ; // JPRx
1042 switch (this->State)
1045 // this->FindPokedRenderer(x, y);
1047 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1051 // this->FindPokedRenderer(x, y);
1053 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1057 // this->FindPokedRenderer(x, y);
1059 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1063 // this->FindPokedRenderer(x, y);
1065 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1072 //---------------------------------------------------------------------------
1073 void vtkInteractorStyleBaseView3D::OnLeftButtonDown ()
1075 vtkInteractorStyleBaseView::OnLeftButtonDown();
1077 if (GetInteractor()->GetControlKey()==1 ){
1078 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1080 this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
1085 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1086 this->Interactor->GetEventPosition()[1]);
1087 if (this->CurrentRenderer == NULL)
1092 if (this->Interactor->GetControlKey()) {
1095 this->StartRotate();
1099 if (this->Interactor->GetShiftKey())
1101 if (this->Interactor->GetControlKey())
1112 if (this->Interactor->GetControlKey())
1118 this->StartRotate();
1125 //---------------------------------------------------------------------------
1126 void vtkInteractorStyleBaseView3D::OnLeftButtonUp ()
1128 vtkInteractorStyleBaseView::OnLeftButtonUp();
1131 if (GetInteractor()->GetControlKey()==1 ){
1132 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1134 this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
1137 switch (this->State)
1149 //---------------------------------------------------------------------------
1150 void vtkInteractorStyleBaseView3D::OnMiddleButtonDown ()
1152 vtkInteractorStyleBaseView::OnMiddleButtonDown();
1153 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1155 //---------------------------------------------------------------------------
1156 void vtkInteractorStyleBaseView3D::OnMiddleButtonUp ()
1158 vtkInteractorStyleBaseView::OnMiddleButtonUp();
1160 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1164 //-------------------------------------------------------------------
1165 //-------------------------------------------------------------------
1166 //-------------------------------------------------------------------
1168 vtkInfoTextImage::vtkInfoTextImage()
1170 _vtkText_WindowLevel = NULL;
1171 _vtkText_ColorLevel = NULL;
1172 _vtkText_position = NULL;
1173 _vtkText_pixelIntensity = NULL;
1174 _marimagedata = NULL;
1177 //-------------------------------------------------------------------
1179 vtkInfoTextImage::~vtkInfoTextImage()
1183 //-------------------------------------------------------------------
1185 void vtkInfoTextImage::Configure()
1187 _vtkText_WindowLevel = Create_Text_Label( 10 , 55 );
1188 _vtkText_ColorLevel = Create_Text_Label( 10 , 40 );
1189 _vtkText_position = Create_Text_Label( 10 , 25 );
1190 _vtkText_pixelIntensity = Create_Text_Label( 10 , 10 );
1194 //-------------------------------------------------------------------
1196 void vtkInfoTextImage::SetMarImageData(marImageData *marimagedata)
1198 _marimagedata=marimagedata;
1201 //-------------------------------------------------------------------
1203 void vtkInfoTextImage::SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview)
1205 _wxvtk2Dbaseview=wxvtk2Dbaseview;
1208 //-------------------------------------------------------------------
1210 vtkTextActor *vtkInfoTextImage::Create_Text_Label(int px, int py )
1212 // Text Window Level
1213 vtkTextActor *textActor = vtkTextActor::New();
1214 textActor->SetDisplayPosition(px, py);
1215 textActor->SetInput("0");
1217 // Set coordinates to match the old vtkScaledTextActor default value
1218 textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
1219 textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
1221 vtkTextProperty *tprop = textActor->GetTextProperty();
1222 tprop->SetFontSize(14);
1223 tprop->SetFontFamilyToArial();
1224 tprop->SetColor(1, 1, 0);
1225 _wxvtk2Dbaseview->GetRenderer()->AddActor2D(textActor);
1230 //-------------------------------------------------------------------
1232 void vtkInfoTextImage::PutWindowLevel()
1234 int value = (int)( _wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetWindow() );
1236 char resultText[50];
1238 strcpy(resultText,"w:");
1241 //ltoa ( (long)value , zTzxt , 10 );
1242 sprintf(zTzxt,"%d",value);
1244 strcat(resultText,zTzxt);
1245 _vtkText_WindowLevel -> SetInput(resultText);
1248 //-------------------------------------------------------------------
1250 void vtkInfoTextImage::PutColorLevel()
1252 int value = (int)(_wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetLevel());
1254 char resultText[50];
1256 strcpy(resultText,"c:");
1258 // itoa (value,zTzxt,10);
1259 sprintf(zTzxt,"%d",value);
1261 strcat(resultText,zTzxt);
1262 _vtkText_ColorLevel -> SetInput(resultText);
1265 //-------------------------------------------------------------------
1267 void vtkInfoTextImage::PutPosition(int xx,int yy, int zz)
1272 // _imagedata->GetSpacing(spa);
1273 // xx=xx*(1/spa[0]);
1274 // yy=yy*(1/spa[1]);
1278 char resultText[50];
1279 strcpy(resultText,"p: ");
1280 // itoa ((int)xx,zTzxt,10);
1281 sprintf(zTzxt,"%d",xx);
1283 strcat(resultText,zTzxt);
1284 strcat(resultText," , ");
1286 // itoa ((int)yy,zTzxt,10);
1287 sprintf(zTzxt,"%d",yy);
1289 strcat(resultText,zTzxt);
1290 strcat(resultText," , ");
1292 // itoa ((int)zz,zTzxt,10);
1293 sprintf(zTzxt,"%d",zz);
1295 strcat(resultText,zTzxt);
1299 int nX = _marimagedata->GetXOriginal(xx);
1300 int nY = _marimagedata->GetYOriginal(yy);
1301 int nZ = _marimagedata->GetZOriginal(zz);
1303 strcat(resultText," (");
1304 // ltoa ((int)nX,zTzxt,10);
1305 sprintf(zTzxt,"%d",nX);
1307 strcat(resultText,zTzxt);
1308 strcat(resultText,",");
1310 // ltoa ((int)nY,zTzxt,10);
1311 sprintf(zTzxt,"%d",nY);
1313 strcat(resultText,zTzxt);
1314 strcat(resultText,",");
1316 // ltoa ((int)nZ,zTzxt,10);
1317 sprintf(zTzxt,"%d",nZ);
1319 strcat(resultText,zTzxt);
1320 strcat(resultText,")");
1325 _vtkText_position -> SetInput(resultText);
1328 //-------------------------------------------------------------------
1330 void vtkInfoTextImage::PutPixelIntensity(int xx, int yy, int zz)
1338 vtkImageData *imagedata = _marimagedata->GetImageData();
1339 imagedata->GetDimensions(dim);
1340 imagedata->GetSpacing(spa);
1343 // xx=xx*(1/spa[0]);
1344 // yy=yy*(1/spa[1]);
1347 if ( (xx<0) || (xx>=dim[0]) || (yy<0) || (yy>=dim[1]) || (zz<0) || (zz>=dim[2]) )
1354 char resultText[50];
1355 strcpy(resultText,"GL: ");
1358 if (imagedata->GetScalarType()==VTK_BIT)
1360 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1361 // itoa (*pOrg,zTzxt,10);
1364 sprintf(zTzxt,"%d",0);
1368 sprintf(zTzxt,"%d",1);
1372 if (imagedata->GetScalarType()==VTK_CHAR)
1374 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1375 // itoa (*pOrg,zTzxt,10);
1377 sprintf(zTzxt,"%d",tmp);
1380 if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
1382 signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1383 // itoa (*pOrg,zTzxt,10);
1385 sprintf(zTzxt,"%d",tmp);
1388 if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
1390 unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1391 // itoa (*pOrg,zTzxt,10);
1393 sprintf(zTzxt,"%d",tmp);
1396 if (imagedata->GetScalarType()==VTK_SHORT)
1398 short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1399 // itoa (*pOrg,zTzxt,10);
1401 sprintf(zTzxt,"%d",tmp);
1404 if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
1406 unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1407 // itoa (*pOrg,zTzxt,10);
1409 sprintf(zTzxt,"%d",tmp);
1412 if (imagedata->GetScalarType()==VTK_INT)
1414 int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1415 // itoa (*pOrg,zTzxt,10);
1416 sprintf(zTzxt,"%d",*pOrg);
1419 if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
1421 unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1422 // itoa (*pOrg,zTzxt,10);
1424 sprintf(zTzxt,"%d",tmp);
1427 if (imagedata->GetScalarType()==VTK_LONG)
1429 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1430 // itoa (*pOrg,zTzxt,10);
1432 sprintf(zTzxt,"%3.2f",tmp);
1435 if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
1437 unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1438 // itoa (*pOrg,zTzxt,10);
1440 sprintf(zTzxt,"%3.2f",tmp);
1443 if (imagedata->GetScalarType()==VTK_FLOAT)
1445 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1446 // itoa (*pOrg,zTzxt,10);
1448 sprintf(zTzxt,"%3.2f",tmp);
1451 if (imagedata->GetScalarType()==VTK_DOUBLE)
1453 double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1454 // itoa (*pOrg,zTzxt,10);
1456 sprintf(zTzxt,"%3.2f",tmp);
1461 strcpy(zTzxt,"---");
1463 strcat(resultText,zTzxt);
1464 _vtkText_pixelIntensity -> SetInput(resultText);
1469 //-------------------------------------------------------------------
1470 //-------------------------------------------------------------------
1471 //-------------------------------------------------------------------
1473 vtkInfoTextImageInteractor::vtkInfoTextImageInteractor()
1477 //-------------------------------------------------------------------
1478 vtkInfoTextImageInteractor::~vtkInfoTextImageInteractor()
1482 //-------------------------------------------------------------------
1484 void vtkInfoTextImageInteractor::SetModelVtkInfoTextImage(vtkInfoTextImage *vtkinfotextimage)
1486 _vtkinfotextimage = vtkinfotextimage;
1489 //-------------------------------------------------------------------
1490 bool vtkInfoTextImageInteractor::OnMouseMove()
1493 wxVTKRenderWindowInteractor *wxVTKiren;
1494 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1495 wxVTKiren->GetEventPosition(X,Y);
1497 int z = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1498 double xx=X,yy=Y,zz=z;
1499 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransfromeCoordScreenToWorld(xx,yy,zz);
1501 GetVtkInfoTextImage()->PutWindowLevel();
1502 GetVtkInfoTextImage()->PutColorLevel();
1503 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1504 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1506 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1510 //-------------------------------------------------------------------
1511 vtkInfoTextImage *vtkInfoTextImageInteractor::GetVtkInfoTextImage()
1513 return _vtkinfotextimage;
1517 //-------------------------------------------------------------------
1518 //-------------------------------------------------------------------
1519 //-------------------------------------------------------------------
1522 wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent)
1523 :wxVtkBaseView(parent)
1525 _imageViewer2XYZ = NULL;
1526 _vtkIinfoTextImage = NULL;
1530 //-------------------------------------------------------------------
1531 wxVtk2DBaseView::~wxVtk2DBaseView()
1533 if (_vtkIinfoTextImage!=NULL)
1535 delete _vtkIinfoTextImage;
1538 if (_imageViewer2XYZ!=NULL)
1540 delete _imageViewer2XYZ;
1544 //-------------------------------------------------------------------
1545 void wxVtk2DBaseView::TransformCoordinate_spacing_ViewToModel(double &X,double &Y, double &Z) // virtual
1549 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1550 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1558 //-------------------------------------------------------------------
1559 void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double &Y, double &Z) // virtual
1563 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1564 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1572 //-------------------------------------------------------------------
1573 void wxVtk2DBaseView::ResetView()
1576 int x1,x2,y1,y2,z1,z2;
1577 wxVtkBaseView::Configure();
1579 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1580 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1581 imageData->UpdateInformation();
1582 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1583 imageData->Update();
1585 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1586 imageData->GetSpacing (spx,spy,spz);
1587 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1588 _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
1589 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1591 _imageViewer2XYZ->GetVtkImageViewer2()->Render();
1592 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1597 //-------------------------------------------------------------------
1598 void wxVtk2DBaseView::Configure(bool okimage)
1601 int x1,x2,y1,y2,z1,z2;
1602 wxVtkBaseView::Configure();
1605 if (_imageViewer2XYZ==NULL)
1607 _imageViewer2XYZ = new vtkImageViewer2_XYZ();
1608 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1609 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1610 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1614 vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
1615 if (imageData!=NULL){
1616 imageData->UpdateInformation();
1617 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1618 imageData->Update();
1620 imageData->GetSpacing (spx,spy,spz);
1621 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1624 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1625 _imageViewer2XYZ->SetExtentDimension(x1,x2,y1,y2,z1,z2);
1627 imageData->GetScalarRange(range);
1628 if (range[1]<20000){
1629 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( (range[1]-range[0])/2 );
1630 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( (range[1]+range[0])/4 );
1632 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
1633 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
1635 // EED 31 Janvier 2007
1636 //vtkImageActor *vtkimageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor ();
1637 //vtkimageactor->InterpolateOff ();
1638 //vtkLookupTable * _collookup = vtkLookupTable::New( );
1639 //_collookup->SetNumberOfColors( 256 );
1640 //_collookup->SetTableRange( 0 , 255 );
1641 //_collookup->Build( );
1642 //_collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
1643 //_collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
1644 //_collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
1645 //_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel ()->SetLookupTable(_collookup );
1649 // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1652 vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2();
1653 vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera();
1657 camera->SetViewUp ( spx*0 , -spy*1 , spz*0 );
1658 camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000 );
1659 camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
1661 camera->SetViewUp ( spx*0 , spy*1 , spz*0 );
1662 camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*10000 );
1663 camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
1666 camera->SetClippingRange( 0.01 , 1000000 );
1667 camera->ComputeViewPlaneNormal();
1668 camera->SetParallelScale( spx*(x2-x1)/3.0 );
1670 // text information over the graphic window
1671 _vtkIinfoTextImage = new vtkInfoTextImage();
1672 _vtkIinfoTextImageInteractor = new vtkInfoTextImageInteractor();
1673 _vtkIinfoTextImage->SetWxVtk2DBaseView(this);
1674 _vtkIinfoTextImage->SetMarImageData( GetVtkBaseData()->GetMarImageData() );
1675 _vtkIinfoTextImageInteractor->SetModelVtkInfoTextImage(_vtkIinfoTextImage);
1676 _vtkIinfoTextImage->Configure();
1677 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkIinfoTextImageInteractor);
1683 //-------------------------------------------------------------------
1685 int wxVtk2DBaseView::GetActualSlice() // virtual
1687 return (int)(_vtkbasedata->GetZ());
1690 //-------------------------------------------------------------------
1691 void wxVtk2DBaseView::SetActualSlice(int slice) // Virtual
1693 _vtkbasedata->SetZ(slice);
1696 //-------------------------------------------------------------------
1698 vtkBaseData *wxVtk2DBaseView::GetVtkBaseData()
1700 return _vtkbasedata;
1703 //-------------------------------------------------------------------
1705 void wxVtk2DBaseView::SetVtkBaseData(vtkBaseData *vtkbasedata)
1707 _vtkbasedata=vtkbasedata;
1710 //-------------------------------------------------------------------
1712 void wxVtk2DBaseView::Refresh()
1714 int z = (int)(GetVtkBaseData()->GetZ());
1715 _imageViewer2XYZ->SetZSlice( z );
1717 wxVtkBaseView::Refresh();
1720 //-------------------------------------------------------------------
1722 void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview)
1724 SetInteractorStyleBaseView(interactorstylebaseview);
1726 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1727 interactorstylebaseview->SetInteractor ( iren );
1728 iren->SetInteractorStyle(interactorstylebaseview);
1729 interactorstylebaseview->SetwxVtkBaseView(this);
1731 vtkMaracasImageViewer2Callback * cbk = vtkMaracasImageViewer2Callback::New();
1732 cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
1733 interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
1734 interactorstylebaseview->AddObserver( vtkCommand::StartWindowLevelEvent, cbk );
1735 interactorstylebaseview->AddObserver( vtkCommand::ResetWindowLevelEvent, cbk );
1739 //---------------------------------------------------------------------------
1740 vtkRenderer* wxVtk2DBaseView::GetRenderer() // virtual
1742 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer();
1744 //---------------------------------------------------------------------------
1745 vtkRenderWindow* wxVtk2DBaseView::GetRenWin() // virtual
1747 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderWindow();
1750 //-------------------------------------------------------------------
1752 void wxVtk2DBaseView::GetSpacing(double spc[3]) // virtual
1754 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1755 imageData->GetSpacing(spc);
1758 //-------------------------------------------------------------------
1759 //-------------------------------------------------------------------
1760 //-------------------------------------------------------------------
1765 wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent)
1766 :wxVtkBaseView( parent )
1773 //-------------------------------------------------------------------
1774 wxVtk3DBaseView::~wxVtk3DBaseView()
1776 if (_aCamera!=NULL) { _aCamera -> Delete(); }
1777 if (_aRenderer!=NULL) { _aRenderer -> Delete(); }
1778 if (_renWin!=NULL) { _renWin -> Delete(); }
1780 //-------------------------------------------------------------------
1781 vtkCamera* wxVtk3DBaseView::GetCamera()
1785 //-------------------------------------------------------------------
1786 vtkRenderer* wxVtk3DBaseView::GetRenderer() // virtual
1790 //-------------------------------------------------------------------
1791 vtkRenderWindow* wxVtk3DBaseView::GetRenWin() // virtual
1795 //-------------------------------------------------------------------
1796 void wxVtk3DBaseView::Refresh()
1798 // _renWin->Render();
1799 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
1800 vri->vtkRenderWindowInteractor::Render();
1802 //-------------------------------------------------------------------
1803 void wxVtk3DBaseView::Configure()
1805 if (_configure==false)
1808 //wxVtkBaseView::Configure();
1809 _aRenderer = vtkRenderer::New();
1810 _renWin = vtkRenderWindow::New();
1811 _renWin->AddRenderer(_aRenderer);
1814 // _renWin->SetStereoCapableWindow(1);
1815 // // //renderwindow->SetStereoTypeToCrystalEyes();
1816 // _renWin->SetStereoTypeToRedBlue();
1817 // _renWin->SetStereoRender(1);
1819 GetWxVTKRenderWindowInteractor()->SetRenderWindow(_renWin);
1823 // vtkInteractorStyle3DMaracas *interactorStyle3DMaracas = vtkInteractorStyle3DMaracas::New();
1824 vtkInteractorStyleBaseView3D *interactorStyleBaseView3D = vtkInteractorStyleBaseView3D::New();
1826 SetInteractorStyleBaseView( interactorStyleBaseView3D );
1827 interactorStyleBaseView3D->SetInteractor ( GetWxVTKRenderWindowInteractor() );
1828 GetWxVTKRenderWindowInteractor()->SetInteractorStyle( interactorStyleBaseView3D );
1829 interactorStyleBaseView3D->SetwxVtkBaseView(this);
1833 vtkInteractorStyleSwitch *iss = dynamic_cast<vtkInteractorStyleSwitch*>(_iren->GetInteractorStyle());
1834 iss->SetCurrentStyleToTrackballCamera();
1837 // It is convenient to create an initial view of the data. The
1838 // FocalPoint and Position form a vector direction. Later on
1839 // (ResetCamera() method) this vector is used to position the camera
1840 // to look at the data in this direction.
1841 _aCamera = vtkCamera::New();
1845 _aCamera->SetViewUp (0, 0, -1);
1846 _aCamera->SetPosition (0, 1, 0);
1848 _aCamera->SetViewUp (0, 1, 0);
1849 _aCamera->SetPosition (0, 0, 1);
1851 _aCamera->SetFocalPoint (0, 0, 0);
1852 _aCamera->ComputeViewPlaneNormal();
1856 //-------------------------------------------------------------------
1858 void wxVtk3DBaseView::GetSpacing(double spc[3])