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();
195 //-------------------------------------------------------------------
196 wxVTKRenderWindowInteractor* wxVtkBaseView::GetWxVTKRenderWindowInteractor()
200 //-------------------------------------------------------------------
201 void wxVtkBaseView::Configure() // virtual
204 //-------------------------------------------------------------------
205 void wxVtkBaseView::Refresh() // virtual
210 _iren->Refresh(false);
215 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
216 vri->vtkRenderWindowInteractor::Render();
223 //-------------------------------------------------------------------
224 void wxVtkBaseView::RefreshView() // virtual
229 GetRenWin()->Render();
231 //GetRenWin()->Render();
235 //---------------------------------------------------------------------------
236 vtkRenderer* wxVtkBaseView::GetRenderer() // virtual
240 //---------------------------------------------------------------------------
241 vtkRenderWindow* wxVtkBaseView::GetRenWin() // virtual
243 return _iren->GetRenderWindow();
246 //----------------------------------------------------------------------------
248 void wxVtkBaseView::TransfromeCoordScreenToWorld(double &X, double &Y, double &Z, int type) // virtual
250 GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
251 GetRenderer()->DisplayToWorld();
253 GetRenderer()->GetWorldPoint( fP );
261 this->GetInteractorStyleBaseView()->GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel( fP[0] , fP[1] , fP[2] );
277 //---------------------------------------------------------------------------
279 vtkInteractorStyleBaseView* wxVtkBaseView::GetInteractorStyleBaseView()
281 return _interactorStyle;
284 //---------------------------------------------------------------------------
286 void wxVtkBaseView::SetInteractorStyleBaseView( vtkInteractorStyleBaseView* interactorStyle)
288 _interactorStyle = interactorStyle;
291 //---------------------------------------------------------------------------
293 void wxVtkBaseView::GetSpacing(double spc[3]) // virtual
301 //---------------------------------------------------------------------------
302 //---------------------------------------------------------------------------
303 //---------------------------------------------------------------------------
305 InteractorStyleMaracas::InteractorStyleMaracas()
308 _vtkInteractorStyleBaseView = NULL;
310 //---------------------------------------------------------------------------
311 InteractorStyleMaracas::~InteractorStyleMaracas()
315 // ----------------------------------------------------------------------------
316 InteractorStyleMaracas * InteractorStyleMaracas :: Clone() // virtual
318 InteractorStyleMaracas * clone = new InteractorStyleMaracas();
319 CopyAttributesTo(clone);
323 // ---------------------------------------------------------------------------
325 void InteractorStyleMaracas::CopyAttributesTo( InteractorStyleMaracas * cloneObject)
328 //<FATHERCLASS>::CopyAttributesTo(cloneObject);
330 cloneObject->SetActive( this->GetActive() );
334 //---------------------------------------------------------------------------
335 bool InteractorStyleMaracas::OnChar()
339 //---------------------------------------------------------------------------
340 bool InteractorStyleMaracas::OnMouseMove()
344 //---------------------------------------------------------------------------
345 bool InteractorStyleMaracas::OnLeftButtonDown()
349 //---------------------------------------------------------------------------
350 bool InteractorStyleMaracas::OnLeftButtonUp()
354 //---------------------------------------------------------------------------
355 bool InteractorStyleMaracas::OnLeftDClick()
359 //---------------------------------------------------------------------------
360 bool InteractorStyleMaracas::OnMiddleButtonDown()
364 //---------------------------------------------------------------------------
365 bool InteractorStyleMaracas::OnMiddleButtonUp()
369 //---------------------------------------------------------------------------
370 bool InteractorStyleMaracas::OnMiddleDClick()
374 //---------------------------------------------------------------------------
375 bool InteractorStyleMaracas::OnRightButtonDown()
379 //---------------------------------------------------------------------------
380 bool InteractorStyleMaracas::OnRightButtonUp()
384 //---------------------------------------------------------------------------
385 bool InteractorStyleMaracas::OnRightDClick()
389 //---------------------------------------------------------------------------
390 bool InteractorStyleMaracas::OnMouseWheel()
395 //---------------------------------------------------------------------------
396 void InteractorStyleMaracas::SetVtkInteractorStyleBaseView(vtkInteractorStyleBaseView* vtkInteractorStyleBaseView)
398 _vtkInteractorStyleBaseView = vtkInteractorStyleBaseView;
401 //---------------------------------------------------------------------------
402 void InteractorStyleMaracas::RemoveVtkInteractorStyleBaseView()
404 _vtkInteractorStyleBaseView = NULL;
406 //---------------------------------------------------------------------------
407 void InteractorStyleMaracas::SetActive(bool active)
411 //---------------------------------------------------------------------------
412 bool InteractorStyleMaracas::GetActive()
419 //-------------------------------------------------------------------
420 //-------------------------------------------------------------------
421 //-------------------------------------------------------------------
423 manualInteractorWindowLevel::manualInteractorWindowLevel()
425 _stateWindowLevel = false;
432 //-------------------------------------------------------------------
434 manualInteractorWindowLevel::~manualInteractorWindowLevel()
438 //-------------------------------------------------------------------
440 bool manualInteractorWindowLevel::OnMouseMove() // virtual
443 if (_stateWindowLevel==true)
446 wxVTKRenderWindowInteractor *wxVTKiren;
447 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
448 wxVTKiren->GetEventPosition( tmpPx , tmpPy );
449 int colorWin=_backWindow - 2*( _backPx - tmpPx );
450 int colorLev=_backLevel + 2*( _backPy - tmpPy );
469 vtkImageViewer2 *vtkimageviewer2;
470 vtkimageviewer2=_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
471 vtkimageviewer2->SetColorWindow(colorWin);
472 vtkimageviewer2->SetColorLevel(colorLev);
473 // vtkimageviewer2->Render();
478 //-------------------------------------------------------------------
480 bool manualInteractorWindowLevel::OnMiddleButtonDown() // virtual
482 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
483 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ){
485 _stateWindowLevel = true;
486 wxVTKRenderWindowInteractor *wxVTKiren;
487 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
488 wxVTKiren->GetEventPosition( _backPx , _backPy );
490 _backWindow = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorWindow());
491 _backLevel = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2()->GetColorLevel());
496 //-------------------------------------------------------------------
498 bool manualInteractorWindowLevel::OnMiddleButtonUp() // virtual
500 if (_stateWindowLevel==true)
502 _stateWindowLevel=false;
509 //---------------------------------------------------------------------------
510 //---------------------------------------------------------------------------
511 //---------------------------------------------------------------------------
513 vtkInteractorScrollZ::vtkInteractorScrollZ()
515 _stateFordware=false;
517 //---------------------------------------------------------------------------
518 vtkInteractorScrollZ::~vtkInteractorScrollZ()
521 //---------------------------------------------------------------------------
522 bool vtkInteractorScrollZ::OnRightButtonDown()
524 vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
525 if ((interactor->GetControlKey()==0) && (interactor->GetShiftKey()==0) ){
526 _stateFordware = true;
527 _fordwareX = interactor->GetEventPosition()[0];
528 _fordwareY = interactor->GetEventPosition()[1];
529 _sliceZ = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetActualSlice();
533 //---------------------------------------------------------------------------
534 bool vtkInteractorScrollZ::OnRightButtonUp()
536 _stateFordware=false;
539 //---------------------------------------------------------------------------
540 bool vtkInteractorScrollZ::OnMouseMove ()
542 if (_stateFordware==true){
543 //int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0]; // JPRx
544 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
545 int delta = (_fordwareY - fy)/3;
546 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->SetActualSlice( _sliceZ + delta);
548 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
550 // wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
551 // _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
553 //_wxvtk2Dbaseview->Refresh();
562 //---------------------------------------------------------------------------
563 //---------------------------------------------------------------------------
564 //---------------------------------------------------------------------------
566 vtkInteractorStyleBaseView::vtkInteractorStyleBaseView()
568 _refresh_waiting = false;
569 _parent_refresh_waiting = false;
570 _blockRefresh = false;
572 //---------------------------------------------------------------------------
573 vtkInteractorStyleBaseView::~vtkInteractorStyleBaseView()
576 //---------------------------------------------------------------------------
577 void vtkInteractorStyleBaseView::OnMouseMove() // virtual
579 CallLstInteractorStyleMaracas(3);
581 //---------------------------------------------------------------------------
582 void vtkInteractorStyleBaseView::OnLeftButtonDown() // virtual
584 CallLstInteractorStyleMaracas(4);
586 //---------------------------------------------------------------------------
587 void vtkInteractorStyleBaseView::OnLeftButtonUp() // virtual
589 CallLstInteractorStyleMaracas(5);
592 //---------------------------------------------------------------------------
593 void vtkInteractorStyleBaseView::OnLeftDClick() // virtual
595 CallLstInteractorStyleMaracas( 11 );
598 //---------------------------------------------------------------------------
599 void vtkInteractorStyleBaseView::OnMiddleButtonDown() // virtual
601 CallLstInteractorStyleMaracas(6);
603 //---------------------------------------------------------------------------
604 void vtkInteractorStyleBaseView::OnMiddleButtonUp() // virtual
606 CallLstInteractorStyleMaracas(7);
608 //---------------------------------------------------------------------------
609 void vtkInteractorStyleBaseView::OnMiddleDClick() // virtual
611 CallLstInteractorStyleMaracas( 13 );
614 //---------------------------------------------------------------------------
615 void vtkInteractorStyleBaseView::OnRightButtonDown() // virtual
617 CallLstInteractorStyleMaracas(1);
619 //---------------------------------------------------------------------------
620 void vtkInteractorStyleBaseView::OnRightButtonUp() // virtual
622 CallLstInteractorStyleMaracas(2);
624 //---------------------------------------------------------------------------
625 void vtkInteractorStyleBaseView::OnRightDClick() // virtual
627 CallLstInteractorStyleMaracas( 12 );
629 //---------------------------------------------------------------------------
630 void vtkInteractorStyleBaseView::OnMouseWheel() // virtual
632 CallLstInteractorStyleMaracas( 14 );
634 //---------------------------------------------------------------------------
635 void vtkInteractorStyleBaseView::AddInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
637 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
638 _lstInteractorStyleMaracas.push_back(interactorStyleMaracas);
640 //---------------------------------------------------------------------------
641 void vtkInteractorStyleBaseView::RemoveInteractorStyleMaracas(InteractorStyleMaracas* interactorStyleMaracas)
643 interactorStyleMaracas->RemoveVtkInteractorStyleBaseView();
644 int i, size = _lstInteractorStyleMaracas.size();
645 std::vector< InteractorStyleMaracas* >::iterator iter = _lstInteractorStyleMaracas.begin();
646 bool removed = false;
647 for (i=0; !removed && i<size; i++)
649 if ( _lstInteractorStyleMaracas[i] == interactorStyleMaracas )
651 _lstInteractorStyleMaracas.erase(iter);
657 //---------------------------------------------------------------------------
658 void vtkInteractorStyleBaseView::InsertInteractorStyleMaracas(int pos, InteractorStyleMaracas* interactorStyleMaracas)
660 interactorStyleMaracas->SetVtkInteractorStyleBaseView(this);
661 _lstInteractorStyleMaracas.insert(_lstInteractorStyleMaracas.begin()+pos,interactorStyleMaracas);
663 //---------------------------------------------------------------------------
664 void vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas(int type)
667 InteractorStyleMaracas *intStyMar;
669 int i,size=_lstInteractorStyleMaracas.size();
672 //FILE *ff = fopen("c:/temp/wxVtkBaseView_SceneManagerStadistics.txt","a+");
673 //fprintf(ff,"EED vtkInteractorStyleBaseView::CallLstInteractorStyleMaracas \n" );
674 //for (i=0;i<size;i++)
676 //fprintf(ff," %p\n" , _lstInteractorStyleMaracas[i] );
684 intStyMar = _lstInteractorStyleMaracas[i];
685 if (intStyMar->GetActive()==true){
687 { // OnRightButtonDown
688 if (intStyMar->OnRightButtonDown()==false)
695 if (intStyMar->OnRightButtonUp()==false)
702 if (intStyMar->OnMouseMove()==false)
708 { // OnLeftButtonDown
709 if (intStyMar->OnLeftButtonDown()==false)
716 if (intStyMar->OnLeftButtonUp()==false)
722 { // OnMiddleButtonDown
723 if (intStyMar->OnMiddleButtonDown()==false)
729 { // OnMiddleButtonUp
730 if (intStyMar->OnMiddleButtonUp()==false)
736 { // OnMiddleButtonUp
737 if (intStyMar->OnChar()==false)
744 if (intStyMar->OnLeftDClick()==false)
751 if (intStyMar->OnRightDClick()==false)
758 if (intStyMar-> OnMiddleDClick()==false)
765 if (intStyMar->OnMouseWheel()==false)
775 //---------------------------------------------------------------------------
776 void vtkInteractorStyleBaseView::OnChar() // virtual
778 // char a=GetInteractor()->GetKeyCode();
779 CallLstInteractorStyleMaracas(10);
781 //---------------------------------------------------------------------------
782 void vtkInteractorStyleBaseView::TransformCoordinate(double &X, double &Y, double &Z)
784 vtkImageViewer2 *imageViewer = GetWxVtk2DBaseView()->_imageViewer2XYZ->GetVtkImageViewer2();
786 imageViewer->GetRenderer()->SetDisplayPoint((int)X, (int)Y, (int)Z);
787 imageViewer->GetRenderer()->DisplayToWorld();
789 imageViewer->GetRenderer()->GetWorldPoint( fP );
798 GetWxVtk2DBaseView()->TransformCoordinate_spacing_ViewToModel(fP[0],fP[1],fP[2]);
804 //---------------------------------------------------------------------------
805 void vtkInteractorStyleBaseView::SetwxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
807 _wxvtkbaseview = wxvtkbaseview;
809 //---------------------------------------------------------------------------
810 wxVtk2DBaseView* vtkInteractorStyleBaseView::GetWxVtk2DBaseView()
812 return (wxVtk2DBaseView*)_wxvtkbaseview;
814 //---------------------------------------------------------------------------
815 wxVtk3DBaseView* vtkInteractorStyleBaseView::GetWxVtk3DBaseView()
817 return (wxVtk3DBaseView*)_wxvtkbaseview;
819 //---------------------------------------------------------------------------
820 void vtkInteractorStyleBaseView::SetActiveAllInteractors(bool ok)
822 InteractorStyleMaracas *intStyMar;
823 int i,size=_lstInteractorStyleMaracas.size();
826 intStyMar = _lstInteractorStyleMaracas[i];
827 intStyMar->SetActive(ok);
831 //---------------------------------------------------------------------------
832 void vtkInteractorStyleBaseView::SetRefresh_waiting()
834 _refresh_waiting=true;
836 //---------------------------------------------------------------------------
837 bool vtkInteractorStyleBaseView::GetRefresh_waiting()
839 return _refresh_waiting;
841 //---------------------------------------------------------------------------
842 void vtkInteractorStyleBaseView::SetParent_refresh_waiting()
844 _parent_refresh_waiting=true;
846 //---------------------------------------------------------------------------
847 bool vtkInteractorStyleBaseView::GetParent_refresh_waiting()
849 return _parent_refresh_waiting;
851 //---------------------------------------------------------------------------
852 void vtkInteractorStyleBaseView::EvaluateToRefresh()
855 if ( _blockRefresh==false )
857 if ( (_refresh_waiting==true) && (_parent_refresh_waiting==false))
859 _refresh_waiting = false;
860 this->_wxvtkbaseview->Refresh();
862 if (_parent_refresh_waiting==true)
864 _parent_refresh_waiting = false;
865 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
866 this->_wxvtkbaseview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
870 //---------------------------------------------------------------------------
871 void vtkInteractorStyleBaseView::BlockRefresh()
875 //---------------------------------------------------------------------------
876 void vtkInteractorStyleBaseView::UnBlockRefresh()
881 //---------------------------------------------------------------------------
882 //---------------------------------------------------------------------------
883 //---------------------------------------------------------------------------
887 //---------------------------------------------------------------------------
888 vtkInteractorStyleBaseView2D::vtkInteractorStyleBaseView2D()
890 _manualinteractorwindowlevel= new manualInteractorWindowLevel();
891 AddInteractorStyleMaracas( _manualinteractorwindowlevel );
893 _vtkInteractorScrollZ = new vtkInteractorScrollZ();
894 AddInteractorStyleMaracas(_vtkInteractorScrollZ);
897 //---------------------------------------------------------------------------
898 vtkInteractorStyleBaseView2D::~vtkInteractorStyleBaseView2D()
902 //---------------------------------------------------------------------------
903 void vtkInteractorStyleBaseView2D::OnRightButtonDown() // virtual
905 vtkInteractorStyleBaseView::OnRightButtonDown();
907 if ((GetInteractor()->GetControlKey()==1) && (GetInteractor()->GetShiftKey()==0) ){
908 this->vtkInteractorStyleImage::OnRightButtonDown();
913 //---------------------------------------------------------------------------
914 void vtkInteractorStyleBaseView2D::OnRightButtonUp() // virtual
916 vtkInteractorStyleBaseView::OnRightButtonUp();
917 this->vtkInteractorStyleImage::OnRightButtonUp();
919 //---------------------------------------------------------------------------
920 void vtkInteractorStyleBaseView2D::OnMouseMove () // virtual
922 vtkInteractorStyleBaseView::OnMouseMove();
923 this->vtkInteractorStyleImage::OnMouseMove();
925 //---------------------------------------------------------------------------
926 void vtkInteractorStyleBaseView2D::OnLeftButtonDown() // virtual
928 vtkInteractorStyleBaseView::OnLeftButtonDown();
930 if ((GetInteractor()->GetControlKey()==0) && (GetInteractor()->GetShiftKey()==1) )
932 this->vtkInteractorStyleImage::OnLeftButtonDown();
935 //---------------------------------------------------------------------------
936 void vtkInteractorStyleBaseView2D::OnLeftButtonUp () // virtual
938 vtkInteractorStyleBaseView::OnLeftButtonUp();
940 this->vtkInteractorStyleImage::OnLeftButtonUp();
942 //---------------------------------------------------------------------------
943 void vtkInteractorStyleBaseView2D::OnMiddleButtonDown () // virtual
945 vtkInteractorStyleBaseView::OnMiddleButtonDown();
947 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
949 this->vtkInteractorStyleImage::OnLeftButtonDown();
952 //---------------------------------------------------------------------------
953 void vtkInteractorStyleBaseView2D::OnMiddleButtonUp () // virtual
955 vtkInteractorStyleBaseView::OnMiddleButtonUp();
957 if ((GetInteractor()->GetControlKey()==1) || (GetInteractor()->GetShiftKey()==1) )
959 this->vtkInteractorStyleImage::OnLeftButtonUp();
965 //-------------------------------------------------------------------
966 //-------------------------------------------------------------------
967 //-------------------------------------------------------------------
970 //---------------------------------------------------------------------------
971 vtkInteractorStyleBaseView3D::vtkInteractorStyleBaseView3D(){
973 //---------------------------------------------------------------------------
974 vtkInteractorStyleBaseView3D::~vtkInteractorStyleBaseView3D(){
976 //---------------------------------------------------------------------------
977 void vtkInteractorStyleBaseView3D::OnRightButtonDown ()
979 vtkInteractorStyleBaseView::OnRightButtonDown();
982 if (GetInteractor()->GetControlKey()==1 ){
983 this->vtkInteractorStyleTrackballCamera::OnRightButtonDown();
986 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
987 this->Interactor->GetEventPosition()[1]);
989 if (this->CurrentRenderer == NULL)
994 if (this->Interactor->GetControlKey()) {
999 //---------------------------------------------------------------------------
1000 void vtkInteractorStyleBaseView3D::OnRightButtonUp ()
1002 vtkInteractorStyleBaseView::OnRightButtonUp();
1005 if (GetInteractor()->GetControlKey()==1 ){
1006 this->vtkInteractorStyleTrackballCamera::OnRightButtonUp();
1011 switch (this->State)
1018 //---------------------------------------------------------------------------
1019 void vtkInteractorStyleBaseView3D::OnMouseMove ()
1021 vtkInteractorStyleBaseView::OnMouseMove();
1023 // this->vtkInteractorStyleTrackballCamera::OnMouseMove();
1025 // int x = this->Interactor->GetEventPosition()[0]; // JPRx
1026 // int y = this->Interactor->GetEventPosition()[1]; // JPRx
1029 // vtkRenderWindowInteractor *rwi = this->Interactor;
1031 // int lx = rwi->GetLastEventPosition()[0]; // JPRx
1032 // int ly = rwi->GetLastEventPosition()[1]; // JPRx
1033 // int dx = rwi->GetEventPosition()[0] ; // JPRx
1034 // int dy = rwi->GetEventPosition()[1] ; // JPRx
1037 switch (this->State)
1040 // this->FindPokedRenderer(x, y);
1042 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1046 // this->FindPokedRenderer(x, y);
1048 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1052 // this->FindPokedRenderer(x, y);
1054 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1058 // this->FindPokedRenderer(x, y);
1060 // this->InvokeEvent(vtkCommand::InteractionEvent, NULL);
1067 //---------------------------------------------------------------------------
1068 void vtkInteractorStyleBaseView3D::OnLeftButtonDown ()
1070 vtkInteractorStyleBaseView::OnLeftButtonDown();
1072 if (GetInteractor()->GetControlKey()==1 ){
1073 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1075 this->vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
1080 this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
1081 this->Interactor->GetEventPosition()[1]);
1082 if (this->CurrentRenderer == NULL)
1087 if (this->Interactor->GetControlKey()) {
1090 this->StartRotate();
1094 if (this->Interactor->GetShiftKey())
1096 if (this->Interactor->GetControlKey())
1107 if (this->Interactor->GetControlKey())
1113 this->StartRotate();
1120 //---------------------------------------------------------------------------
1121 void vtkInteractorStyleBaseView3D::OnLeftButtonUp ()
1123 vtkInteractorStyleBaseView::OnLeftButtonUp();
1126 if (GetInteractor()->GetControlKey()==1 ){
1127 this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1129 this->vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
1132 switch (this->State)
1144 //---------------------------------------------------------------------------
1145 void vtkInteractorStyleBaseView3D::OnMiddleButtonDown ()
1147 vtkInteractorStyleBaseView::OnMiddleButtonDown();
1148 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
1150 //---------------------------------------------------------------------------
1151 void vtkInteractorStyleBaseView3D::OnMiddleButtonUp ()
1153 vtkInteractorStyleBaseView::OnMiddleButtonUp();
1155 // this->vtkInteractorStyleTrackballCamera::OnMiddleButtonUp();
1159 //-------------------------------------------------------------------
1160 //-------------------------------------------------------------------
1161 //-------------------------------------------------------------------
1163 vtkInfoTextImage::vtkInfoTextImage()
1165 _vtkText_WindowLevel = NULL;
1166 _vtkText_ColorLevel = NULL;
1167 _vtkText_position = NULL;
1168 _vtkText_pixelIntensity = NULL;
1169 _marimagedata = NULL;
1172 //-------------------------------------------------------------------
1174 vtkInfoTextImage::~vtkInfoTextImage()
1178 //-------------------------------------------------------------------
1180 void vtkInfoTextImage::Configure()
1182 _vtkText_WindowLevel = Create_Text_Label( 10 , 55 );
1183 _vtkText_ColorLevel = Create_Text_Label( 10 , 40 );
1184 _vtkText_position = Create_Text_Label( 10 , 25 );
1185 _vtkText_pixelIntensity = Create_Text_Label( 10 , 10 );
1189 //-------------------------------------------------------------------
1191 void vtkInfoTextImage::SetMarImageData(marImageData *marimagedata)
1193 _marimagedata=marimagedata;
1196 //-------------------------------------------------------------------
1198 void vtkInfoTextImage::SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview)
1200 _wxvtk2Dbaseview=wxvtk2Dbaseview;
1203 //-------------------------------------------------------------------
1205 vtkTextActor *vtkInfoTextImage::Create_Text_Label(int px, int py )
1207 // Text Window Level
1208 vtkTextActor *textActor = vtkTextActor::New();
1209 textActor->SetDisplayPosition(px, py);
1210 textActor->SetInput("0");
1212 // Set coordinates to match the old vtkScaledTextActor default value
1213 textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
1214 textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
1216 vtkTextProperty *tprop = textActor->GetTextProperty();
1217 tprop->SetFontSize(14);
1218 tprop->SetFontFamilyToArial();
1219 tprop->SetColor(1, 1, 0);
1220 _wxvtk2Dbaseview->GetRenderer()->AddActor2D(textActor);
1225 //-------------------------------------------------------------------
1227 void vtkInfoTextImage::PutWindowLevel()
1229 int value = (int)( _wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetWindow() );
1231 char resultText[50];
1233 strcpy(resultText,"w:");
1236 //ltoa ( (long)value , zTzxt , 10 );
1237 sprintf(zTzxt,"%d",value);
1239 strcat(resultText,zTzxt);
1240 _vtkText_WindowLevel -> SetInput(resultText);
1243 //-------------------------------------------------------------------
1245 void vtkInfoTextImage::PutColorLevel()
1247 int value = (int)(_wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel()->GetLevel());
1249 char resultText[50];
1251 strcpy(resultText,"c:");
1253 // itoa (value,zTzxt,10);
1254 sprintf(zTzxt,"%d",value);
1256 strcat(resultText,zTzxt);
1257 _vtkText_ColorLevel -> SetInput(resultText);
1260 //-------------------------------------------------------------------
1262 void vtkInfoTextImage::PutPosition(int xx,int yy, int zz)
1267 // _imagedata->GetSpacing(spa);
1268 // xx=xx*(1/spa[0]);
1269 // yy=yy*(1/spa[1]);
1273 char resultText[50];
1274 strcpy(resultText,"p: ");
1275 // itoa ((int)xx,zTzxt,10);
1276 sprintf(zTzxt,"%d",xx);
1278 strcat(resultText,zTzxt);
1279 strcat(resultText," , ");
1281 // itoa ((int)yy,zTzxt,10);
1282 sprintf(zTzxt,"%d",yy);
1284 strcat(resultText,zTzxt);
1285 strcat(resultText," , ");
1287 // itoa ((int)zz,zTzxt,10);
1288 sprintf(zTzxt,"%d",zz);
1290 strcat(resultText,zTzxt);
1294 int nX = _marimagedata->GetXOriginal(xx);
1295 int nY = _marimagedata->GetYOriginal(yy);
1296 int nZ = _marimagedata->GetZOriginal(zz);
1298 strcat(resultText," (");
1299 // ltoa ((int)nX,zTzxt,10);
1300 sprintf(zTzxt,"%d",nX);
1302 strcat(resultText,zTzxt);
1303 strcat(resultText,",");
1305 // ltoa ((int)nY,zTzxt,10);
1306 sprintf(zTzxt,"%d",nY);
1308 strcat(resultText,zTzxt);
1309 strcat(resultText,",");
1311 // ltoa ((int)nZ,zTzxt,10);
1312 sprintf(zTzxt,"%d",nZ);
1314 strcat(resultText,zTzxt);
1315 strcat(resultText,")");
1320 _vtkText_position -> SetInput(resultText);
1323 //-------------------------------------------------------------------
1325 void vtkInfoTextImage::PutPixelIntensity(int xx, int yy, int zz)
1333 vtkImageData *imagedata = _marimagedata->GetImageData();
1334 imagedata->GetDimensions(dim);
1335 imagedata->GetSpacing(spa);
1338 // xx=xx*(1/spa[0]);
1339 // yy=yy*(1/spa[1]);
1342 if ( (xx<0) || (xx>=dim[0]) || (yy<0) || (yy>=dim[1]) || (zz<0) || (zz>=dim[2]) )
1349 char resultText[50];
1350 strcpy(resultText,"GL: ");
1353 if (imagedata->GetScalarType()==VTK_BIT)
1355 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1356 // itoa (*pOrg,zTzxt,10);
1359 sprintf(zTzxt,"%d",0);
1363 sprintf(zTzxt,"%d",1);
1367 if (imagedata->GetScalarType()==VTK_CHAR)
1369 char *pOrg=(char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1370 // itoa (*pOrg,zTzxt,10);
1372 sprintf(zTzxt,"%d",tmp);
1375 if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
1377 signed char *pOrg=(signed char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1378 // itoa (*pOrg,zTzxt,10);
1380 sprintf(zTzxt,"%d",tmp);
1383 if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
1385 unsigned char *pOrg=(unsigned char*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1386 // itoa (*pOrg,zTzxt,10);
1388 sprintf(zTzxt,"%d",tmp);
1391 if (imagedata->GetScalarType()==VTK_SHORT)
1393 short *pOrg=(short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1394 // itoa (*pOrg,zTzxt,10);
1396 sprintf(zTzxt,"%d",tmp);
1399 if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
1401 unsigned short *pOrg=(unsigned short*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1402 // itoa (*pOrg,zTzxt,10);
1404 sprintf(zTzxt,"%d",tmp);
1407 if (imagedata->GetScalarType()==VTK_INT)
1409 int *pOrg=(int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1410 // itoa (*pOrg,zTzxt,10);
1411 sprintf(zTzxt,"%d",*pOrg);
1414 if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
1416 unsigned int *pOrg=(unsigned int*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1417 // itoa (*pOrg,zTzxt,10);
1419 sprintf(zTzxt,"%d",tmp);
1422 if (imagedata->GetScalarType()==VTK_LONG)
1424 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1425 // itoa (*pOrg,zTzxt,10);
1427 sprintf(zTzxt,"%3.2f",tmp);
1430 if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
1432 unsigned long *pOrg=(unsigned long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1433 // itoa (*pOrg,zTzxt,10);
1435 sprintf(zTzxt,"%3.2f",tmp);
1438 if (imagedata->GetScalarType()==VTK_FLOAT)
1440 long *pOrg=(long*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1441 // itoa (*pOrg,zTzxt,10);
1443 sprintf(zTzxt,"%3.2f",tmp);
1446 if (imagedata->GetScalarType()==VTK_DOUBLE)
1448 double *pOrg=(double*)imagedata->GetScalarPointer ((int)xx,(int)yy,(int)zz);
1449 // itoa (*pOrg,zTzxt,10);
1451 sprintf(zTzxt,"%3.2f",tmp);
1456 strcpy(zTzxt,"---");
1458 strcat(resultText,zTzxt);
1459 _vtkText_pixelIntensity -> SetInput(resultText);
1464 //-------------------------------------------------------------------
1465 //-------------------------------------------------------------------
1466 //-------------------------------------------------------------------
1468 vtkInfoTextImageInteractor::vtkInfoTextImageInteractor()
1472 //-------------------------------------------------------------------
1473 vtkInfoTextImageInteractor::~vtkInfoTextImageInteractor()
1477 //-------------------------------------------------------------------
1479 void vtkInfoTextImageInteractor::SetModelVtkInfoTextImage(vtkInfoTextImage *vtkinfotextimage)
1481 _vtkinfotextimage = vtkinfotextimage;
1484 //-------------------------------------------------------------------
1485 bool vtkInfoTextImageInteractor::OnMouseMove()
1488 wxVTKRenderWindowInteractor *wxVTKiren;
1489 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1490 wxVTKiren->GetEventPosition(X,Y);
1492 int z = (int)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1493 double xx=X,yy=Y,zz=z;
1494 _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->TransfromeCoordScreenToWorld(xx,yy,zz);
1496 GetVtkInfoTextImage()->PutWindowLevel();
1497 GetVtkInfoTextImage()->PutColorLevel();
1498 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1499 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1501 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1505 //-------------------------------------------------------------------
1506 vtkInfoTextImage *vtkInfoTextImageInteractor::GetVtkInfoTextImage()
1508 return _vtkinfotextimage;
1512 //-------------------------------------------------------------------
1513 //-------------------------------------------------------------------
1514 //-------------------------------------------------------------------
1517 wxVtk2DBaseView::wxVtk2DBaseView(wxWindow *parent)
1518 :wxVtkBaseView(parent)
1520 _imageViewer2XYZ = NULL;
1521 _vtkIinfoTextImage = NULL;
1524 //-------------------------------------------------------------------
1525 wxVtk2DBaseView::~wxVtk2DBaseView()
1527 if (_imageViewer2XYZ!=NULL) {
1528 delete _imageViewer2XYZ;
1531 if (_imageViewer2XYZ!=NULL) {
1532 delete _vtkIinfoTextImage;
1537 //-------------------------------------------------------------------
1538 void wxVtk2DBaseView::TransformCoordinate_spacing_ViewToModel(double &X,double &Y, double &Z) // virtual
1542 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1543 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1551 //-------------------------------------------------------------------
1552 void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double &Y, double &Z) // virtual
1556 // GetVtkBaseData()->GetImageData()->GetSpacing(spc);
1557 this->_imageViewer2XYZ->GetVtkImageViewer2()->GetInput()->GetSpacing(spc);
1565 //-------------------------------------------------------------------
1566 void wxVtk2DBaseView::ResetView()
1569 int x1,x2,y1,y2,z1,z2;
1570 wxVtkBaseView::Configure();
1572 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1573 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1574 imageData->UpdateInformation();
1575 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1576 imageData->Update();
1578 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1579 imageData->GetSpacing (spx,spy,spz);
1580 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1581 _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2);
1582 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1584 printf("EED wxVtk2DBaseView::ResetView podemos 01\n ");
1585 _imageViewer2XYZ->GetVtkImageViewer2()->Render();
1586 printf("EED wxVtk2DBaseView::ResetView podemos 02\n ");
1588 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1593 //-------------------------------------------------------------------
1594 void wxVtk2DBaseView::Configure(bool okimage)
1597 int x1,x2,y1,y2,z1,z2;
1598 wxVtkBaseView::Configure();
1601 if (_imageViewer2XYZ==NULL)
1603 _imageViewer2XYZ = new vtkImageViewer2_XYZ();
1604 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1605 _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren );
1606 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1610 vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
1611 if (imageData!=NULL){
1612 imageData->UpdateInformation();
1613 imageData->SetUpdateExtent( imageData->GetWholeExtent());
1614 imageData->Update();
1616 imageData->GetSpacing (spx,spy,spz);
1617 imageData->GetExtent (x1,x2,y1,y2,z1,z2);
1620 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput(imageData );
1621 _imageViewer2XYZ->SetExtentDimension(x1,x2,y1,y2,z1,z2);
1623 imageData->GetScalarRange(range);
1624 if (range[1]<20000){
1625 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( (range[1]-range[0])/2 );
1626 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( (range[1]+range[0])/4 );
1628 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
1629 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
1631 // EED 31 Janvier 2007
1632 //vtkImageActor *vtkimageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor ();
1633 //vtkimageactor->InterpolateOff ();
1634 //vtkLookupTable * _collookup = vtkLookupTable::New( );
1635 //_collookup->SetNumberOfColors( 256 );
1636 //_collookup->SetTableRange( 0 , 255 );
1637 //_collookup->Build( );
1638 //_collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
1639 //_collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
1640 //_collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
1641 //_imageViewer2XYZ->GetVtkImageViewer2()->GetWindowLevel ()->SetLookupTable(_collookup );
1645 // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1648 vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2();
1649 vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera();
1653 camera->SetViewUp ( spx*0 , -spy*1 , spz*0 );
1654 camera->SetPosition ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , -spz*10000 );
1655 camera->SetFocalPoint ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0 );
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 );
1662 camera->SetClippingRange( 0.01 , 1000000 );
1663 camera->ComputeViewPlaneNormal();
1664 camera->SetParallelScale( spx*(x2-x1)/3.0 );
1666 // text information over the graphic window
1667 _vtkIinfoTextImage = new vtkInfoTextImage();
1668 _vtkIinfoTextImageInteractor = new vtkInfoTextImageInteractor();
1669 _vtkIinfoTextImage->SetWxVtk2DBaseView(this);
1670 _vtkIinfoTextImage->SetMarImageData( GetVtkBaseData()->GetMarImageData() );
1671 _vtkIinfoTextImageInteractor->SetModelVtkInfoTextImage(_vtkIinfoTextImage);
1672 _vtkIinfoTextImage->Configure();
1673 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkIinfoTextImageInteractor);
1679 //-------------------------------------------------------------------
1681 int wxVtk2DBaseView::GetActualSlice() // virtual
1683 return (int)(_vtkbasedata->GetZ());
1686 //-------------------------------------------------------------------
1687 void wxVtk2DBaseView::SetActualSlice(int slice) // Virtual
1689 _vtkbasedata->SetZ(slice);
1692 //-------------------------------------------------------------------
1694 vtkBaseData *wxVtk2DBaseView::GetVtkBaseData()
1696 return _vtkbasedata;
1699 //-------------------------------------------------------------------
1701 void wxVtk2DBaseView::SetVtkBaseData(vtkBaseData *vtkbasedata)
1703 _vtkbasedata=vtkbasedata;
1706 //-------------------------------------------------------------------
1708 void wxVtk2DBaseView::Refresh()
1710 int z = (int)(GetVtkBaseData()->GetZ());
1711 _imageViewer2XYZ->SetZSlice( z );
1713 wxVtkBaseView::Refresh();
1716 //-------------------------------------------------------------------
1718 void wxVtk2DBaseView::SetInteractorStyleImage(vtkInteractorStyleBaseView *interactorstylebaseview)
1720 SetInteractorStyleBaseView(interactorstylebaseview);
1722 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1723 interactorstylebaseview->SetInteractor ( iren );
1724 iren->SetInteractorStyle(interactorstylebaseview);
1725 interactorstylebaseview->SetwxVtkBaseView(this);
1727 vtkMaracasImageViewer2Callback *cbk = vtkMaracasImageViewer2Callback::New();
1728 cbk->IV = _imageViewer2XYZ->GetVtkImageViewer2();
1729 interactorstylebaseview->AddObserver( vtkCommand::WindowLevelEvent, cbk );
1730 interactorstylebaseview->AddObserver( vtkCommand::StartWindowLevelEvent, cbk );
1731 interactorstylebaseview->AddObserver( vtkCommand::ResetWindowLevelEvent, cbk );
1735 //---------------------------------------------------------------------------
1736 vtkRenderer* wxVtk2DBaseView::GetRenderer() // virtual
1738 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer();
1740 //---------------------------------------------------------------------------
1741 vtkRenderWindow* wxVtk2DBaseView::GetRenWin() // virtual
1743 return _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderWindow();
1746 //-------------------------------------------------------------------
1748 void wxVtk2DBaseView::GetSpacing(double spc[3]) // virtual
1750 vtkImageData *imageData = GetVtkBaseData()->GetImageData();
1751 imageData->GetSpacing(spc);
1754 //-------------------------------------------------------------------
1755 //-------------------------------------------------------------------
1756 //-------------------------------------------------------------------
1761 wxVtk3DBaseView::wxVtk3DBaseView(wxWindow *parent)
1762 :wxVtkBaseView( parent )
1769 //-------------------------------------------------------------------
1770 wxVtk3DBaseView::~wxVtk3DBaseView()
1772 if (_aCamera!=NULL) { _aCamera -> Delete(); }
1773 if (_aRenderer!=NULL) { _aRenderer -> Delete(); }
1774 if (_renWin!=NULL) { _renWin -> Delete(); }
1776 //-------------------------------------------------------------------
1777 vtkCamera* wxVtk3DBaseView::GetCamera()
1781 //-------------------------------------------------------------------
1782 vtkRenderer* wxVtk3DBaseView::GetRenderer() // virtual
1786 //-------------------------------------------------------------------
1787 vtkRenderWindow* wxVtk3DBaseView::GetRenWin() // virtual
1791 //-------------------------------------------------------------------
1792 void wxVtk3DBaseView::Refresh()
1794 // _renWin->Render();
1795 vtkRenderWindowInteractor *vri = GetWxVTKRenderWindowInteractor();
1796 vri->vtkRenderWindowInteractor::Render();
1798 //-------------------------------------------------------------------
1799 void wxVtk3DBaseView::Configure()
1801 if (_configure==false)
1804 wxVtkBaseView::Configure();
1805 _aRenderer = vtkRenderer::New();
1806 _renWin = vtkRenderWindow::New();
1807 _renWin->AddRenderer(_aRenderer);
1810 // _renWin->SetStereoCapableWindow(1);
1811 // // //renderwindow->SetStereoTypeToCrystalEyes();
1812 // _renWin->SetStereoTypeToRedBlue();
1813 // _renWin->SetStereoRender(1);
1815 GetWxVTKRenderWindowInteractor()->SetRenderWindow(_renWin);
1819 // vtkInteractorStyle3DMaracas *interactorStyle3DMaracas = vtkInteractorStyle3DMaracas::New();
1820 vtkInteractorStyleBaseView3D *interactorStyleBaseView3D = vtkInteractorStyleBaseView3D::New();
1822 SetInteractorStyleBaseView( interactorStyleBaseView3D );
1823 interactorStyleBaseView3D->SetInteractor ( GetWxVTKRenderWindowInteractor() );
1824 GetWxVTKRenderWindowInteractor()->SetInteractorStyle( interactorStyleBaseView3D );
1825 interactorStyleBaseView3D->SetwxVtkBaseView(this);
1829 vtkInteractorStyleSwitch *iss = dynamic_cast<vtkInteractorStyleSwitch*>(_iren->GetInteractorStyle());
1830 iss->SetCurrentStyleToTrackballCamera();
1833 // It is convenient to create an initial view of the data. The
1834 // FocalPoint and Position form a vector direction. Later on
1835 // (ResetCamera() method) this vector is used to position the camera
1836 // to look at the data in this direction.
1837 _aCamera = vtkCamera::New();
1840 _aCamera->SetViewUp (0, 0, -1);
1841 _aCamera->SetPosition (0, 1, 0);
1843 _aCamera->SetViewUp (0, 1, 0);
1844 _aCamera->SetPosition (0, 0, 1);
1846 _aCamera->SetFocalPoint (0, 0, 0);
1847 _aCamera->ComputeViewPlaneNormal();
1850 //-------------------------------------------------------------------
1852 void wxVtk3DBaseView::GetSpacing(double spc[3])