1 /*=========================================================================
4 Module: $RCSfile: wxMPRWidget.cxx,v $
6 Date: $Date: 2009/05/04 15:06:42 $
7 Version: $Revision: 1.12 $
9 Copyright: (c) 2002, 2003
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notice for more information.
16 =========================================================================*/
19 #include <vtkObjectFactory.h>
20 #include <vtkInteractorStyleSwitch.h>
21 #include <vtkCamera.h>
22 #include <vtkImageActor.h>
23 #include <vtkRenderer.h>
24 #include <vtkRenderWindowInteractor.h>
25 #include <vtkRenderWindow.h>
27 #include <vtkRenderer.h>
28 #include <vtkImageViewer2.h>
29 #include <vtkInteractorStyleImage.h>
31 #include <vtkProperty.h>
32 #include <vtkPolyData.h>
33 #include <vtkDataSet.h>
34 #include <vtkStripper.h>
35 #include <vtkCellArray.h>
36 #include <vtkPointData.h>
37 #include <vtkInteractorStyleTrackballCamera.h>
39 #include <vtkPlanes.h>
40 #include <vtkProbeFilter.h>
42 #include <vtkPointPicker.h>
45 #include "vtkClosePolyData.h"
46 #include <vtkTriangleFilter.h>
47 #include <vtkSTLWriter.h>
48 #include <vtkPolyDataConnectivityFilter.h>
50 // EED 25 Janvier 2007 - TestLoic
51 #include <vtkCutter.h>
52 #include <vtkWindowLevelLookupTable.h>
53 #include <vtkLookupTable.h>
54 #include <vtkMetaImageWriter.h>
58 #include "wxMPRWidget.h"
59 #include "wxVTKRenderWindowInteractor.h"
60 #include "UtilVtk3DGeometriSelection.h"
61 #include "../kernel/marDicomBase.h"
65 #include <wx/notebook.h>
66 #include <wx/colordlg.h>
74 #include "pPlotter/HistogramDialog.h"
76 //-------------------------------------------------------------------
77 //-------------------------------------------------------------------
78 //-------------------------------------------------------------------
80 idAlBeRa::idAlBeRa(int id, double radio,int deltavoxel)
84 _deltavoxel = deltavoxel;
88 //-------------------------------------------------------------------
89 //-------------------------------------------------------------------
90 //-------------------------------------------------------------------
92 vtkInteractorStyleSphere::vtkInteractorStyleSphere()
98 //---------------------------------------------------------------------------
100 vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
105 //---------------------------------------------------------------------------
107 bool vtkInteractorStyleSphere::OnRightButtonDown()
109 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
112 //_fordwareX = this->Interactor->GetEventPosition()[0];
113 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
115 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
117 _radio = wxsphereview->GetRadio();
123 //---------------------------------------------------------------------------
125 bool vtkInteractorStyleSphere::OnRightButtonUp()
127 if (_stateRadio==true)
129 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
130 wxsphereview->SetDeltaVoxel(1);
131 double radio=wxsphereview->GetRadio();
132 wxsphereview->GetIdOfImage(radio+0.1);
133 wxsphereview->GetIdOfImage(radio+0.2);
134 wxsphereview->GetIdOfImage(radio-0.1);
135 wxsphereview->GetIdOfImage(radio-0.2);
137 wxsphereview->RefreshView();
143 //---------------------------------------------------------------------------
145 bool vtkInteractorStyleSphere::OnLeftButtonDown()
148 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
149 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
154 //---------------------------------------------------------------------------
156 bool vtkInteractorStyleSphere::OnLeftButtonUp()
158 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
159 if (_stateRotate==true){
160 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
161 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
163 if ((_fordwareX==fx)&&(_fordwareY==fy)){
164 double x=fx,y=fy,z=1;
165 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
166 wxsphereview->SetXYZtoParent(x,y);
167 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
168 wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
170 wxsphereview->RotationEnd();
172 wxsphereview->RefreshView();
173 _stateRotate = false;
180 //---------------------------------------------------------------------------
182 bool vtkInteractorStyleSphere::OnMouseMove ()
184 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
185 if (_stateRotate==true)
190 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
194 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
198 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
199 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
200 wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
201 wxsphereview->RefreshView();
203 if (_stateRadio==true)
205 //int fx = this->Interactor->GetEventPosition()[0];
206 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
207 double dif=(fy-_fordwareY) / 10.0;
208 wxsphereview->SetRadio( _radio + dif );
209 wxsphereview->SetDeltaVoxel(3);
210 wxsphereview->RefreshView();
218 //-------------------------------------------------------------------
219 //-------------------------------------------------------------------
220 //-------------------------------------------------------------------
222 wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData )
223 : wxVtk2DBaseView(parent)
226 _vtkmprbasedata = vtkmprbasedata;
227 _imageDataOriginal = imageData;
229 _imageSphere = vtkImageData::New();
230 _imageSphere->SetDimensions (150,150,500);
231 _imageSphere->SetScalarTypeToUnsignedShort();
232 _imageSphere->AllocateScalars();
233 _imageSphere->Update();
236 vtkBaseData *vtkbasedata = new vtkBaseData();
237 vtkbasedata->SetMarImageData( new marImageData(_imageSphere) );
238 this->SetVtkBaseData(vtkbasedata);
240 _transform = vtkTransform::New();
241 _transform1 = vtkTransform::New();
242 _transform2 = vtkTransform::New();
243 _transform ->Identity();
244 _transform1->Identity();
245 _transform2->Identity();
250 //-------------------------------------------------------------------
252 wxSphereView::~wxSphereView()
254 _transform -> Delete();
255 _transform1 -> Delete();
256 _transform2 -> Delete();
260 //----------------------------------------------------------------------------
262 double wxSphereView::GetRadio()
267 //----------------------------------------------------------------------------
269 void wxSphereView::SetRadio(double radio)
278 //----------------------------------------------------------------------------
280 void wxSphereView::Configure()
282 wxVtk2DBaseView::Configure();
284 _vtkinteractorstylesphere = new vtkInteractorStyleSphere();
285 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _vtkinteractorstylesphere );
288 // EED purify 12/sep/2006
302 //----------------------------------------------------------------------------
304 void wxSphereView::RefreshPoint()
306 double x = _vtkmprbasedata->GetX() - _centerX;
307 double y = _vtkmprbasedata->GetY() - _centerY;
308 double z = _vtkmprbasedata->GetZ() - _centerZ;
309 double alpha= atan2(x,z);
310 double beta = atan2( y , sqrt(z*z+x*x) );
312 alpha = alpha*180/3.1416;
313 beta = beta*180/3.1416;
315 _transform1->Identity();
316 _transform1->RotateY(alpha);
317 _transform1->RotateX(-beta);
319 _radio= sqrt(x*x + y*y +z*z);
324 //----------------------------------------------------------------------------
326 void wxSphereView::RefreshView()
329 wxVtk2DBaseView::Refresh();
332 //----------------------------------------------------------------------------
334 void wxSphereView::RotationEnd()
336 _transform1->RotateWXYZ(_ang,_vxb,_vyb,0);
337 _transform2->Identity();
342 //----------------------------------------------------------------------------
344 void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang)
348 _ang = -sqrt( vx*vx + vy*vy ) / 1.0;
356 _transform2->Identity();
357 _transform2->RotateWXYZ(_ang,_vxb,_vyb,0);
362 //----------------------------------------------------------------------------
364 void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB)
370 vtkTransform *transform = vtkTransform::New();
371 transform->Identity();
372 transform->RotateX(angB);
373 transform->RotateZ(angA);
374 transform->TransformPoint(in,out);
381 //----------------------------------------------------------------------------
383 void wxSphereView::RotatePointOverTheSphere( double pp[3], double p[3],double cc[3])
387 _transform->TransformPoint(p,out);
388 pp[0] = out[0] + cc[0];
389 pp[1] = out[1] + cc[1];
390 pp[2] = out[2] + cc[2];
394 //----------------------------------------------------------------------------
396 void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image)
399 double difX = pp2[0]-pp1[0];
400 double difY = pp2[1]-pp1[1];
401 double difZ = pp2[2]-pp1[2];
408 _imageDataOriginal->GetDimensions(dimOrg);
409 image->GetDimensions(dimRes);
415 int xx=-1,yy=-1,zz=-1;
420 xx = (int) (x1+t*difX);
421 yy = (int) (y1+t*difY);
422 zz = (int) (z1+t*difZ);
425 if ((xx>=0) && (xx<dimOrg[0]) && (yy>=0) && (yy<dimOrg[1]) && (zz>=0) && (zz<dimOrg[2]) &&
426 (AngX>=0) && (AngX<dimRes[0]) && (AngY>=0) && (AngY<dimRes[1]) && (z>=0) && (z<dimRes[2]) )
428 unsigned short *pOrg=(unsigned short*)_imageDataOriginal->GetScalarPointer (xx,yy,zz);
429 unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z );
435 //----------------------------------------------------------------------------
437 void wxSphereView::ResetlstId()
439 int i,size=_lstId.size();
440 for (i=size-1;i>=0;i--)
447 //----------------------------------------------------------------------------
449 int wxSphereView::GetIdOfImage(double radio)
453 _imageSphere->GetDimensions(dim);
454 int sizeMaxList = dim[2];
455 // Search in list >> alpha beta radio
456 int i,size=_lstId.size();
457 for (i=0; i<size;i++)
459 //idAlBeRa *tmp=_lstId[i]; // JPRx
460 if ((_lstId[i]->_radio==radio) && (_lstId[i]->_deltavoxel==_delta))
462 return _lstId[i]->_id;
465 if (size>sizeMaxList)
467 delete _lstId[size-1];
472 id = id % sizeMaxList;
477 FiltreImage(id,radio);
478 _lstId.insert(_lstId.begin(),1,new idAlBeRa(id,radio,_delta) );
483 //----------------------------------------------------------------------------
485 void wxSphereView::DefineImageSphere()
488 id=GetIdOfImage( _radio );
489 GetVtkBaseData()->SetZ( id );
493 //----------------------------------------------------------------------------
494 void wxSphereView::SetDeltaVoxel(int delta)
499 //----------------------------------------------------------------------------
500 void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned short gris)
503 unsigned short *pRes;
505 _imageSphere->GetDimensions(dimRes);
508 for ( ii=(int)(i-delta2) ; ii<=(int)(i+delta2) ; ii++ )
510 for ( jj=(int)(j-delta2) ; jj<=(int)(j+delta2) ; jj++ )
512 if ( (ii>=0)&&(ii<dimRes[0]) &&
513 (jj>=0)&&(jj<dimRes[1]) )
515 pRes = (unsigned short*)_imageSphere->GetScalarPointer( ii , jj , (int)id );
523 //----------------------------------------------------------------------------
525 void wxSphereView::SetXYZtoParent(double i, double j)
528 double factor = 0.75;
529 double radio2 = _radio*_radio;
530 double pxx,pyy,d2x,d2y;
531 double cc[3],p[3],pp[3];
536 int dimRes[3],dimOrig[3];
537 _imageSphere->GetDimensions(dimRes);
540 _imageDataOriginal->GetDimensions(dimOrig);
542 p[0] = (i - d2x)*factor;
544 p[1] = (j - d2y)*factor;
550 RotatePointOverTheSphere( pp, p,cc);
551 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
552 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
553 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
555 if (_vtkmprbasedata){
556 _vtkmprbasedata->SetX(pp[0]);
557 _vtkmprbasedata->SetY(pp[1]);
558 _vtkmprbasedata->SetZ(pp[2]);
565 //----------------------------------------------------------------------------
567 void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP)
569 double factor = 0.75;
570 double radioB = radio/3;
571 double radio2 = radio*radio;
572 double pxx,pyy,d2x,d2y;
573 double cc[3],p[3],pp[3];
578 unsigned short *pOrig;
579 int dimRes[3],dimOrig[3];
582 _imageSphere->GetExtent(ext);
583 _imageSphere->GetDimensions(dimRes);
585 //_imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
586 _imageSphere->SetExtent(ext);
590 // double deltaTMP=_delta;
591 _imageDataOriginal->GetDimensions(dimOrig);
595 limitA = (int) ( (-radioB/factor)+d2x );
596 limitB = (int) ( (radioB/factor)+d2x );
605 for ( i=start ; i<end ; i=i+deltaTMP )
607 p[0] = (i - d2x)*factor;
609 for (j=start;j<end;j=j+deltaTMP)
611 p[1] = (j - d2y)*factor;
615 if (( ((ok==false) && (!((i>limitA) && (i<limitB) && (j>limitA) && (j<limitB)))) )
622 RotatePointOverTheSphere( pp, p,cc);
623 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
624 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
625 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
627 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) );
628 SetVoxel(i,j,deltaTMP,id,*pOrig);
630 SetVoxel(i,j,deltaTMP,id,2000);
633 SetVoxel(i,j,deltaTMP,id,0);
639 _imageSphere->Modified();
640 _imageSphere->Update();
646 //----------------------------------------------------------------------------
648 void wxSphereView::FiltreImage(int id, double radio)
651 _transform -> Identity();
652 _transform -> Concatenate(_transform1);
653 _transform -> Concatenate(_transform2);
655 FiltreImageB(id,radio,false, _delta);
656 FiltreImageB(id,radio,true, 1);
660 //----------------------------------------------------------------------------
663 void wxSphereView::FiltreImage(int id, double radio)
665 double radio2 = radio*radio;
666 double radio2TMP= (radio/2)*(radio/2);
667 double pxx,pyy,d2x,d2y;
668 double cc[3],p[3],pp[3];
673 unsigned short *pOrig;
674 int dimRes[3],dimOrig[3];
676 _imageSphere->GetDimensions(dimRes);
677 _imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
680 double deltaTMP=_delta;
681 _imageDataOriginal->GetDimensions(dimOrig);
683 for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
685 p[0] = (i - d2x)*0.75;
687 for (j=0;j<dimRes[1];j=j+deltaTMP)
689 p[1] = (j - d2y)*0.75;
698 RotatePointOverTheSphere( pp, p,cc);
699 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
700 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
701 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
703 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
704 SetVoxel(i,j,deltaTMP,id,*pOrig);
706 SetVoxel(i,j,deltaTMP,id,2000);
709 SetVoxel(i,j,deltaTMP,id,0);
717 for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
719 p[0] = (i - d2x)*0.75;
721 for (j=0;j<dimRes[1];j=j+deltaTMP)
723 p[1] = (j - d2y)*0.75;
731 RotatePointOverTheSphere( pp, p,cc);
732 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
733 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
734 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
736 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
737 SetVoxel(i,j,deltaTMP,id,*pOrig);
739 SetVoxel(i,j,deltaTMP,id,2000);
742 SetVoxel(i,j,deltaTMP,id,0);
748 _imageSphere->Modified();
749 _imageSphere->Update();
753 void wxSphereView::FiltreImage(vtkImageData *imageSphere)
756 imageSphere->GetDimensions(dim);
757 for (i=0;i<dim[0];i++)
759 for (j=0;j<dim[1];j++)
761 for (k=0;k<dim[2];k++)
763 unsigned short *pRes=(unsigned short*)imageSphere->GetScalarPointer (i,j,k);
770 double cc[3],p1[3],p2[3],pp1[3],pp2[3];
774 double r1 = _sl_radio->GetValue() - _sl_thickness->GetValue()/2;
775 double r2 = _sl_radio->GetValue() + _sl_thickness->GetValue()/2;
780 double alpha= _sl_alpha->GetValue();
781 double beta = _sl_beta->GetValue();
784 for (angA=-deltaA;angA<deltaA;angA++)
786 for (angB=-deltaA;angB<deltaA;angB++)
788 GetPointSphere(p1,r1,angA,angB);
789 GetPointSphere(p2,r2,angA,angB);
790 RotatePointOverTheSphere( pp1, alpha, beta, p1 ,cc );
791 RotatePointOverTheSphere( pp2, alpha, beta, p2 ,cc );
792 TransferePoints(pp1,pp2,angA+alpha+180,angB+beta+90,imageSphere);
799 //----------------------------------------------------------------------------
801 void wxSphereView::InitSphere(double points[4][3])
804 double r = SphereFindCenter(points,cc); // 4-points , center
807 _centerX = (int)(cc[0]);
808 _centerY = (int)(cc[1]);
809 _centerZ = (int)(cc[2]);
812 _imageDataOriginal->GetDimensions(dim);
813 _centerX = (int)(dim[0]/2);
814 _centerY = (int)(dim[1]/2);
815 _centerZ = (int)(dim[2]/2);
819 //----------------------------------------------------------------------------
821 // Calculate center and radius of sphere given four points
822 // http://home.att.net/~srschmitt/script_sphere_solver.html
823 // source code HTML <script language=JavaScript>
824 double wxSphereView::SphereFindCenter(double P[4][3], double cc[3])
827 double r, m11, m12, m13, m14, m15;
830 for (i = 0; i < 4; i++) // find minor 11
837 m11 = determinant( a, 4 );
839 for (i = 0; i < 4; i++) // find minor 12
841 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
846 m12 = determinant( a, 4 );
848 for (i = 0; i < 4; i++) // find minor 13
850 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
855 m13 = determinant( a, 4 );
857 for (i = 0; i < 4; i++) // find minor 14
859 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
864 m14 = determinant( a, 4 );
867 for (i = 0; i < 4; i++) // find minor 15
869 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
874 m15 = determinant( a, 4 );
883 cc[0] = 0.5*m12/m11; //cx
884 cc[1] = -0.5*m13/m11; //cy
885 cc[2] = 0.5*m14/m11; //cz
887 r = sqrt( cc[0]*cc[0] + cc[1]*cc[1] + cc[2]*cc[2] - m15/m11 );
890 return r; // the radius
892 //----------------------------------------------------------------------------
894 // Recursive definition of determinate using expansion by minors.
895 double wxSphereView::determinant(double a[4][4], int n)
909 if (n == 2) // terminate recursion
911 d = a[0][0]*a[1][1] - a[1][0]*a[0][1];
916 for (j1 = 0; j1 < n; j1++ ) // do each column
918 for (i = 1; i < n; i++) // create minor
921 for (j = 0; j < n; j++)
923 if (j == j1) continue;
924 m[i-1][j2] = a[i][j];
929 // sum (+/-)cofactor * minor
930 d = d + pow(-1.0, j1)*a[0][j1]*determinant( m, n-1 );
940 //-------------------------------------------------------------------
941 //-------------------------------------------------------------------
942 //-------------------------------------------------------------------
944 vtkInteractorStylePlane2D::vtkInteractorStylePlane2D()
948 //---------------------------------------------------------------------------
949 vtkInteractorStylePlane2D::~vtkInteractorStylePlane2D()
953 //---------------------------------------------------------------------------
954 bool vtkInteractorStylePlane2D::GetStateRotate()
959 //---------------------------------------------------------------------------
960 bool vtkInteractorStylePlane2D::OnLeftButtonDown() // vitual
963 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
964 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
965 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
966 vtkplane2Dview->RotationStart();
971 //---------------------------------------------------------------------------
972 bool vtkInteractorStylePlane2D::OnLeftButtonUp() // virtual
974 if (_stateRotate==true)
976 _stateRotate = false;
977 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
978 vtkplane2Dview->ResetBack();
979 // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
985 //---------------------------------------------------------------------------
986 bool vtkInteractorStylePlane2D::OnRightButtonUp() // virtual
988 if (_stateRotate==true){
989 //vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); // JPRx
992 // vtkplane2Dview->RotationEnd();
994 _stateRotate = false;
999 //---------------------------------------------------------------------------
1000 bool vtkInteractorStylePlane2D::OnMouseMove () // virtual
1003 if (_stateRotate==true){
1006 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
1010 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
1014 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1015 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1016 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1017 vtkplane2Dview->RotationDrag( fx - _fordwareX , fy - _fordwareY , ok_v , ok_ang);
1018 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1022 //-------------------------------------------------------------------
1023 bool vtkInteractorStylePlane2D::OnLeftDClick() // virtual
1025 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1026 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1031 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1032 vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
1034 vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
1036 vtkmprbasedata->SetX( xx );
1037 vtkmprbasedata->SetY( yy );
1038 vtkmprbasedata->SetZ( zz );
1039 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1043 //-------------------------------------------------------------------
1044 //-------------------------------------------------------------------
1045 //-------------------------------------------------------------------
1047 vtkPlane2DView::vtkPlane2DView( wxWindow *parent)
1048 : wxVtk2DBaseView(parent)
1055 _backOrient[0] = -99999;
1056 _backOrient[1] = -99999;
1057 _backOrient[2] = -99999;
1058 _backOrient[3] = -99999;
1061 _mip_visualization = true;
1064 _transform1 = vtkTransform::New();
1065 _transform2 = vtkTransform::New();
1066 _transform1->Identity();
1067 _transform2->Identity();
1075 _imageResult = NULL;
1083 _interactorstyleplane2D = false;
1085 //-------------------------------------------------------------------
1086 vtkPlane2DView::~vtkPlane2DView()
1091 if (_pts != NULL) { _pts -> Delete(); }
1092 if (_lineActor != NULL) { _lineActor -> Delete(); }
1093 if (_lineMapper != NULL) { _lineMapper -> Delete(); }
1094 if (_pd != NULL) { _pd -> Delete(); }
1096 _transform1 -> Delete();
1097 _transform2 -> Delete();
1100 //-------------------------------------------------------------------
1101 void vtkPlane2DView::ResetBack()
1112 //-------------------------------------------------------------------
1113 void vtkPlane2DView::ResetPlane(){
1114 if (_pSource !=NULL) { _pSource -> Delete(); }
1115 if (_3Dslices !=NULL) { _3Dslices -> Delete(); }
1116 if (_stPoints !=NULL) { _stPoints -> Delete(); }
1117 if (_change !=NULL) { _change -> Delete(); }
1119 //-------------------------------------------------------------------
1120 vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
1122 return (vtkMPRBaseData*)GetVtkBaseData();
1125 //-------------------------------------------------------------------
1126 void vtkPlane2DView::SetPSource(int sizeIma){
1127 int dimIma = sizeIma;
1129 double x = GetVtkmprbasedata()->GetX();
1130 double y = GetVtkmprbasedata()->GetY();
1131 double z = GetVtkmprbasedata()->GetZ();
1134 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1135 imagedata->GetSpacing(spc);
1141 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1142 vtkTransform *transform = mprbasedata->GetTransformOrientation();
1144 double in[3]; // temp
1147 in[0]=1; in[1]=0; in[2]=0;
1148 transform->TransformPoint(in,_n);
1150 in[0]=0; in[1]=dimIma-1; in[2] = 0;
1151 transform->TransformPoint(in,pA);
1153 in[0]=0; in[1]=0; in[2]=dimIma-1;
1154 transform->TransformPoint(in,pB);
1156 _pSource -> SetPoint1( pA );
1157 _pSource -> SetPoint2( pB );
1159 _pSource -> SetOrigin( 0 , 0 , 0 );
1160 _pSource -> SetResolution( sizeIma-1 , sizeIma -1 );
1161 _pSource -> Update();
1162 _pSource -> SetCenter( x, y, z );
1163 _pSource -> SetNormal( _n );
1164 _pSource -> Update( );
1167 // transform->Delete();
1171 //-------------------------------------------------------------------
1172 void vtkPlane2DView::ExtractPlane()
1175 double x = GetVtkmprbasedata()->GetX();
1176 double y = GetVtkmprbasedata()->GetY();
1177 double z = GetVtkmprbasedata()->GetZ();
1180 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1181 imagedata->GetSpacing(spc);
1186 vtkTransform *transform = GetVtkmprbasedata()->GetTransformOrientation();
1187 double orientation[4];
1188 transform->GetOrientationWXYZ(orientation);
1190 bool okOrientation=true;
1191 if ((orientation[0]!=_backOrient[0]) || (orientation[1]!=_backOrient[1]) ||
1192 (orientation[2]!=_backOrient[2]) || (orientation[3]!=_backOrient[3]))
1194 okOrientation=false;
1197 bool okPosicion=true;
1198 if ( (x!=_backX) || (y!=_backY) || (z!=_backZ) )
1203 if ((okPosicion==false) || (okOrientation==false) ) {
1208 if ( _mip_visualization==true )
1210 if (_interactorstyleplane2D!=NULL)
1212 if (_interactorstyleplane2D->GetStateRotate()==false )
1222 Extract_MIP_PlaneVTK();
1224 Extract_One_PlaneVTK();
1231 _backOrient[0]=orientation[0];
1232 _backOrient[1]=orientation[1];
1233 _backOrient[2]=orientation[2];
1234 _backOrient[3]=orientation[3];
1235 } //okPosition okOrientation
1238 //-------------------------------------------------------------------
1240 void vtkPlane2DView::Extract_One_PlaneVTK()
1242 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1243 SetPSource(_sizeIma);
1244 _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
1245 _3Dslices -> SetSource( imagedata );
1246 _3Dslices -> Update( );
1247 _stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() );
1248 _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
1249 _stPoints -> SetScalarType( imagedata->GetScalarType() );
1250 _stPoints -> SetScalarTypeToShort();
1251 _stPoints -> Update();
1252 // _change -> SetInput( _stPoints );
1253 // _change -> Update(); //important
1254 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
1255 // _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
1256 // vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
1259 //-------------------------------------------------------------------
1261 void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
1266 int sizeWidth = (_mip_width*2)+1 ;
1268 int iWidth,itmp,tmpSizeWith;
1271 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1272 SetPSource(_sizeIma);
1273 imagedata->GetSpacing(spc);
1275 bool heightDefinition=false;
1278 heightDefinition=true;
1281 if (heightDefinition==true)
1283 mipWidth = _mip_width;
1288 tmpSizeWith = (mipWidth*2) + 1;
1289 sp = (spc[0]*sizeWidth)/tmpSizeWith;
1290 sizeWidth = tmpSizeWith;
1296 std::vector< vtkProbeFilter* > slicesLST;
1298 _pSource->Push( -mipWidth * sp );
1301 for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
1303 vtkProbeFilter *slice = vtkProbeFilter::New();
1304 slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
1305 slice -> SetSource( imagedata );
1307 slicesLST.push_back( slice );
1308 _pSource->Push( sp );
1311 if (_imageResult ==NULL)
1313 _imageResult = vtkImageData::New();
1314 _imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
1315 _imageResult -> SetSpacing(1,1,1);
1316 _imageResult -> SetScalarType( imagedata->GetScalarType() );
1317 _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
1318 _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
1319 _imageResult -> AllocateScalars();
1320 _imageResult -> Update();
1323 unsigned short *pTemp;
1324 unsigned short *pResult;
1325 pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
1327 int iPixels , sizePixels = _sizeIma*_sizeIma;
1328 for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
1331 pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
1333 pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
1334 pResult[iPixels] = pTemp[iPixels];
1336 for (iWidth=1;iWidth<sizeWidth;iWidth++)
1338 pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
1340 if (pResult[iPixels]< pTemp[iPixels])
1342 pResult[iPixels] = pTemp[iPixels];
1348 for (itmp=1;itmp<deltaPixel;itmp++)
1350 pResult[iPixels+itmp] = pResult[iPixels];
1356 for (iWidth=0;iWidth<sizeWidth;iWidth++)
1358 slicesLST[iWidth]->Delete();
1361 _imageResult->Modified();
1362 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult );
1366 //-------------------------------------------------------------------
1367 void vtkPlane2DView::Configure( )
1369 wxVtk2DBaseView::Configure(false);
1375 _pSource = vtkPlaneSource::New( );
1376 _3Dslices = vtkProbeFilter::New( ) ;
1377 _stPoints = vtkStructuredPoints::New( );
1378 _change = vtkImageChangeInformation::New();
1380 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1382 // SetActive(false);
1383 _imageViewer2XYZ -> GetVtkImageViewer2() -> SetupInteractor ( iren );
1385 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1387 _interactorstyleplane2D = new vtkInteractorStylePlane2D();
1388 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstyleplane2D );
1390 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
1392 camera->SetViewUp ( 0 , 1 , 0 );
1393 camera->SetPosition ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 10000 );
1395 camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
1396 camera->SetClippingRange(0.01, 100000);
1397 camera->ComputeViewPlaneNormal();
1398 camera->SetParallelScale( _sizeIma/3.0 );
1400 // text information over the graphic window
1401 _vtkInfoTextImage = new vtkInfoTextImage();
1402 _vtkInfoTextImageInteractorPlane2D = new vtkInfoTextImageInteractorPlane2D();
1403 _vtkInfoTextImage->SetWxVtk2DBaseView(this);
1404 _vtkInfoTextImage->SetMarImageData( GetVtkmprbasedata()->GetMarImageData() );
1405 _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);
1406 _vtkInfoTextImage->Configure();
1407 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
1412 //-------------------------------------------------------------------
1413 void vtkPlane2DView::HorizontalLine()
1416 _pts = vtkPoints::New();
1417 _pts->SetNumberOfPoints(2);
1418 _pts->SetPoint(0, -1000 , -1000 , -1000 );
1419 _pts->SetPoint(1, 1000 , 1000 , 1000 );
1420 vtkCellArray *lines = vtkCellArray::New();
1421 lines->InsertNextCell(2);
1422 lines->InsertCellPoint(0);
1423 lines->InsertCellPoint(1);
1424 _pd = vtkPolyData::New();
1425 _pd->SetPoints( _pts );
1426 _pd->SetLines( lines );
1427 lines->Delete(); //do not delete lines ??
1428 _lineActor = vtkActor::New();
1429 _lineMapper = vtkPolyDataMapper::New();
1430 _lineMapper->SetInput(_pd);
1431 _lineMapper->ImmediateModeRenderingOn();
1432 _lineActor->SetMapper(_lineMapper);
1433 _lineActor->GetProperty()->BackfaceCullingOn();
1434 _lineActor->GetProperty()->SetDiffuseColor(0,0,1);
1435 _lineActor->GetProperty()->SetLineWidth(2);
1436 _lineActor->GetProperty()->SetOpacity(0);
1437 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineActor );
1440 //-------------------------------------------------------------------
1441 void vtkPlane2DView::RotationStart()
1443 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1444 vtkTransform *transform = mprbasedata->GetTransformOrientation();
1445 _transform1->SetMatrix( transform->GetMatrix() );
1447 //-------------------------------------------------------------------
1448 void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
1452 _ang =sqrt( vx*vx + vy*vy ) / 1.5;
1459 _transform2->Identity();
1460 _transform2->RotateWXYZ(_ang,0,_vxb,_vyb);
1462 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1463 vtkTransform *transform = vtkTransform::New();
1464 transform->Identity();
1465 transform->Concatenate(_transform1);
1466 transform->Concatenate(_transform2);
1467 mprbasedata->InitTransformOrientation(transform);
1468 transform->Delete();
1470 // Refresh Horizontal Line
1471 _pts->SetPoint( 0 , (_sizeIma/2) - _vxb*2 , (_sizeIma/2) - _vyb*2 , 1 );
1472 _pts->SetPoint( 1 , (_sizeIma/2) + _vxb*2 , (_sizeIma/2) + _vyb*2 , 1 );
1473 // RefreshCircleLine();
1476 //-------------------------------------------------------------------
1477 void vtkPlane2DView::Refresh( )
1480 wxVtkBaseView::Refresh();
1482 //-------------------------------------------------------------------
1483 void vtkPlane2DView::SetImgSize( int imgSize )
1487 //-------------------------------------------------------------------
1488 int vtkPlane2DView::GetImgSize()
1492 //-------------------------------------------------------------------
1493 int vtkPlane2DView::GetActualSlice() // virtual
1495 _cx = GetVtkmprbasedata()->GetX();
1496 _cy = GetVtkmprbasedata()->GetY();
1497 _cz = GetVtkmprbasedata()->GetZ();
1501 //-------------------------------------------------------------------
1503 bool vtkPlane2DView::GetMipVisualization()
1505 return _mip_visualization;
1508 //-------------------------------------------------------------------
1509 int vtkPlane2DView::GetMipWidth()
1514 //-------------------------------------------------------------------
1515 void vtkPlane2DView::SetActualSlice(int slice) // Virtual
1517 double dir=(double)slice/3.0;
1518 GetVtkmprbasedata()->SetX( _cx + (_n[0]*dir) );
1519 GetVtkmprbasedata()->SetY( _cy + (_n[1]*dir) );
1520 GetVtkmprbasedata()->SetZ( _cz + (_n[2]*dir) );
1522 //---------------------------------------------------------------------------
1523 vtkInteractorStylePlane2D *vtkPlane2DView::GetInteractorstyleplane2D()
1525 return this->_interactorstyleplane2D;
1527 //---------------------------------------------------------------------------
1528 void vtkPlane2DView::SetActive(bool active)
1533 //---------------------------------------------------------------------------
1535 void vtkPlane2DView::SetMipVisualization(bool ok)
1537 _mip_visualization=ok;
1540 //---------------------------------------------------------------------------
1542 void vtkPlane2DView::SetMipWidth(int value)
1547 //---------------------------------------------------------------------------
1548 void vtkPlane2DView::SetVisibleLine(bool ok)
1557 _lineActor->GetProperty()->SetOpacity(opacity);
1559 // ----------------------------------------------------------------------------
1560 void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z)
1563 GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
1569 TransfromeCoordScreenToWorld(xx,yy,zz);
1572 vtkTransform *transf1 = vtkTransform::New();
1573 transf1->Identity();
1574 vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
1575 transf1->Concatenate(transf2->GetMatrix());
1576 double in[4], out[4];
1577 double center = GetImgSize() / 2;
1579 in[1] = xx - center;
1580 in[2] = yy - center;
1583 transf1->MultiplyPoint(in,out);
1586 X = out[0] + GetVtkmprbasedata()->GetX() ;
1587 Y = out[1] + GetVtkmprbasedata()->GetY() ;
1588 Z = out[2] + GetVtkmprbasedata()->GetZ() ;
1592 //-------------------------------------------------------------------
1593 //-------------------------------------------------------------------
1594 //-------------------------------------------------------------------
1595 vtkInfoTextImageInteractorPlane2D::vtkInfoTextImageInteractorPlane2D()
1598 //-------------------------------------------------------------------
1599 vtkInfoTextImageInteractorPlane2D::~vtkInfoTextImageInteractorPlane2D()
1602 //-------------------------------------------------------------------
1603 bool vtkInfoTextImageInteractorPlane2D::OnMouseMove()
1606 wxVTKRenderWindowInteractor *wxVTKiren;
1607 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1608 wxVTKiren->GetEventPosition(X,Y);
1610 int z = (int) (_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1611 double xx=X,yy=Y,zz=z;
1614 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
1615 vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
1617 GetVtkInfoTextImage()->PutWindowLevel();
1618 GetVtkInfoTextImage()->PutColorLevel();
1619 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1620 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1622 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1626 // ----------------------------------------------------------------------------
1627 // ----------------------------------------------------------------------------
1628 // ----------------------------------------------------------------------------
1629 manualViewPerpPlaneContour::manualViewPerpPlaneContour()
1632 // ----------------------------------------------------------------------------
1633 manualViewPerpPlaneContour::~manualViewPerpPlaneContour()
1638 // ----------------------------------------------------------------------------
1639 manualViewPerpPlaneContour * manualViewPerpPlaneContour :: Clone()
1641 manualViewPerpPlaneContour * clone = new manualViewPerpPlaneContour();
1642 CopyAttributesTo(clone);
1646 // ---------------------------------------------------------------------------
1648 void manualViewPerpPlaneContour::CopyAttributesTo( manualViewPerpPlaneContour * cloneObject)
1651 manualViewContour::CopyAttributesTo(cloneObject);
1657 // ----------------------------------------------------------------------------
1658 void manualViewPerpPlaneContour::UpdateViewPoint(int id)
1661 manualPoint *mp = _manContModel->GetManualPoint(id);
1665 FilterCordinateXYZ(x,y,z);
1667 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
1668 if ((z>=-1) && (z<=1))
1670 _lstViewPoints[id]->GetVtkActor()->VisibilityOn();
1672 _lstViewPoints[id]->GetVtkActor()->VisibilityOff();
1675 // ----------------------------------------------------------------------------
1676 void manualViewPerpPlaneContour::FilterCordinateXYZ (double &x, double &y, double &z)
1678 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1679 vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
1680 vtkTransform *transf1 = vtkTransform::New();
1681 vtkTransform *transf2 = vtkmprbasedata->GetTransformOrientation();
1682 transf1->SetMatrix( transf2->GetMatrix() );
1685 double in[4], out[4];
1686 double center = vtkplane2Dview->GetImgSize() / 2;
1688 in[0] = x - vtkmprbasedata->GetX();
1689 in[1] = y - vtkmprbasedata->GetY();
1690 in[2] = z - vtkmprbasedata->GetZ();
1693 transf1->MultiplyPoint(in,out);
1699 this->GetWxVtkBaseView()->GetSpacing(spc);
1707 // ----------------------------------------------------------------------------
1708 void manualViewPerpPlaneContour::TransfromeCoordViewWorld( double &X,double &Y,double &Z,int type )
1711 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1712 vtkplane2Dview->TransfromeCoordViewWorld2(X,Y,Z);
1716 // ----------------------------------------------------------------------------
1717 void manualViewPerpPlaneContour::RefreshContour() // virtual
1719 // manualViewContour::RefreshContour();
1725 // JSTG 25-02-08 ----------------------------------------------------------
1727 //--------------------------------------------------------
1733 double dist,distMin = 99999999;
1735 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1736 double center = vtkplane2Dview->GetImgSize() / 2;
1739 np = GetNumberOfPoints( );
1741 //JSTG 25-02-08 ------------------------------------------
1743 //nps = GetNumberOfPointsSpline();
1744 nps = _manContModel->GetNumberOfPointsSpline();
1745 //delta = ( double ) ( np ) / ( double ) ( nps-1 );
1746 _manContModel->UpdateSpline();
1747 //--------------------------------------------------------
1751 for( i = 0; i < nps; i++ )
1753 // JSTG 25-02-08 ----------------------------------------------------------
1754 //t = delta * (double)i ;
1755 //tt = delta * (double)(i+1) ;
1756 //_manContModel->GetSplinePoint(t ,pp1[0],pp1[1],pp1[2]);
1757 //_manContModel->GetSplinePoint(tt,pp2[0],pp2[1],pp2[2]);
1758 _manContModel->GetSpline_i_Point(i ,&pp1[0],&pp1[1],&pp1[2]);
1759 _manContModel->GetSpline_i_Point(i+1,&pp2[0],&pp2[1],&pp2[2]);
1760 //--------------------------------------------------------------------------
1761 FilterCordinateXYZ(pp1[0],pp1[1],pp1[2]);
1762 FilterCordinateXYZ(pp2[0],pp2[1],pp2[2]);
1763 if (pp2[2]*pp1[2]<=0)
1765 if (pp1[2]-pp2[2]!=0) {
1766 u = -pp2[2] / (pp1[2]-pp2[2]);
1770 pp[0] = ( pp1[0]-pp2[0] )*u + pp2[0];
1771 pp[1] = ( pp1[1]-pp2[1] )*u + pp2[1];
1772 pp[2] = ( pp1[2]-pp2[2] )*u + pp2[2];
1773 ppC[0] = pp[0] - center;
1774 ppC[1] = pp[1] - center;
1776 dist = sqrt( ppC[0]*ppC[0] + ppC[1]*ppC[1] + ppC[2]*ppC[2] );
1788 _pts->SetPoint(0, 0 , 0 , 0);
1789 _pts->SetPoint(1, 0 , 0 , 0);
1793 ppB[0]=ppB[0]*_spc[0];
1794 ppB[1]=ppB[1]*_spc[1];
1796 _pts->SetPoint( 0, ppB[0] , ppB[1]+1 , 1 );
1797 _pts->SetPoint( 1, ppB[0] , ppB[1]-1 , 1 );
1798 _pts->SetPoint( 2, ppB[0] , ppB[1] , 1 );
1799 _pts->SetPoint( 3, ppB[0]-1 , ppB[1] , 1 );
1800 _pts->SetPoint( 4, ppB[0]+1 , ppB[1] , 1 );
1803 for( i = 5; i < nps; i++ )
1805 _pts->SetPoint( i, ppB[0] , ppB[1] , 1 );
1810 //---------------------------------------------------------------------------
1811 bool manualViewPerpPlaneContour::ifTouchContour( int x, int y, int z)
1814 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1818 vtkplane2Dview->TransfromeCoordScreenToWorld(X,Y,Z);
1820 _pts->GetPoint(0, ppA);
1821 if (sqrt( (ppA[0]-X)*(ppA[0]-X) + (ppA[1]-Y)*(ppA[1]-Y) ) <=2)
1829 //---------------------------------------------------------------------------
1830 //---------------------------------------------------------------------------
1831 //---------------------------------------------------------------------------
1832 vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
1834 _stateMoveAxisX = false;
1835 _stateMoveAxisY = false;
1836 _stateMoveAxisZ = false;
1838 //---------------------------------------------------------------------------
1839 vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
1844 //---------------------------------------------------------------------------
1845 bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual
1847 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1848 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1849 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1851 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1852 wxvtkmpr2Dview->MoveX(x,y,z);
1853 wxvtkmpr2Dview->MoveY(x,y,z);
1854 wxvtkmpr2Dview->MoveZ(x,y,z);
1855 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1856 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1857 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1858 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1862 //---------------------------------------------------------------------------
1863 bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
1865 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1866 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1867 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1869 //double xx = x; // JPRx
1870 //double yy = y; // JPRx
1871 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1874 if ((_xBack==xx) && (_yBack==yy))
1876 wxvtkmpr2Dview->MoveX(x,y,z);
1877 wxvtkmpr2Dview->MoveY(x,y,z);
1878 wxvtkmpr2Dview->MoveZ(x,y,z);
1879 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1880 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1881 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1882 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1889 _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
1890 _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
1891 _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
1895 //---------------------------------------------------------------------------
1896 bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
1898 if (_stateMoveAxisX==true)
1900 _stateMoveAxisX=false;
1902 if (_stateMoveAxisY==true)
1904 _stateMoveAxisY=false;
1906 if (_stateMoveAxisZ==true)
1908 _stateMoveAxisZ=false;
1912 //---------------------------------------------------------------------------
1913 bool vtkInteractorStyleMPRView::OnMouseMove ()
1915 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1916 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1919 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1920 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1921 // wxvtkmpr2Dview->TransfromeCoordViewWorld(x,y,z);
1923 wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
1925 if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
1927 if (_stateMoveAxisX==true)
1929 wxvtkmpr2Dview-> MoveX(x,y,z);
1931 if (_stateMoveAxisY==true)
1933 wxvtkmpr2Dview->MoveY(x,y,z);
1935 if (_stateMoveAxisZ==true)
1937 wxvtkmpr2Dview->MoveZ(x,y,z);
1940 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1944 //-------------------------------------------------------------------
1945 //-------------------------------------------------------------------
1946 //-------------------------------------------------------------------
1947 wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction)
1948 :wxVtk2DBaseView(parent)
1953 _direction = direction;
1956 _lineAMapper = NULL;
1960 _lineBMapper = NULL;
1964 //-------------------------------------------------------------------
1965 wxVtkMPR2DView::~wxVtkMPR2DView()
1967 if (_ptsA!=NULL) { _ptsA -> Delete(); }
1968 if (_lineAActor!=NULL) { _lineAActor -> Delete(); }
1969 if (_lineAMapper!=NULL) { _lineAMapper -> Delete(); }
1970 if (_pdA!=NULL) { _pdA -> Delete(); }
1971 if (_ptsB!=NULL) { _ptsB -> Delete(); }
1972 if (_lineBActor!=NULL) { _lineBActor -> Delete(); }
1973 if (_lineBMapper!=NULL) { _lineBMapper -> Delete(); }
1974 if (_pdB!=NULL) { _pdB -> Delete(); }
1976 //-------------------------------------------------------------------
1977 vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
1979 return (vtkMPRBaseData*)GetVtkBaseData();
1981 //-------------------------------------------------------------------
1982 void wxVtkMPR2DView::Configure(){
1983 wxVtk2DBaseView::Configure();
1985 _interactorstylemprview = new vtkInteractorStyleMPRView();
1986 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstylemprview );
1988 int x1,x2,y1,y2,z1,z2;
1989 GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
1992 vtkImageData* img = GetVtkmprbasedata()->GetImageData();
1994 img->GetSpacing(spc);
1995 x1 = (int)(x1*spc[0]);
1996 y1 = (int)(y1*spc[1]);
1997 z1 = (int)(z1*spc[2]);
1999 x2 = (int)(x2*spc[0]);
2000 y2 = (int)(y2*spc[1]);
2001 z2 = (int)(z2*spc[2]);
2003 _visibleAxis = true;
2006 _ptsA = vtkPoints::New();
2007 _ptsA->SetNumberOfPoints(2);
2008 _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
2009 _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
2010 vtkCellArray *linesA;
2011 linesA = vtkCellArray::New();
2012 linesA->InsertNextCell(2);
2013 linesA->InsertCellPoint(0);
2014 linesA->InsertCellPoint(1);
2015 _pdA = vtkPolyData::New();
2016 _pdA->SetPoints( _ptsA );
2017 _pdA->SetLines( linesA );
2018 linesA->Delete(); //do not delete lines ??
2019 _lineAActor = vtkActor::New();
2020 _lineAMapper = vtkPolyDataMapper::New();
2021 _lineAMapper->SetInput(_pdA);
2022 _lineAMapper->ImmediateModeRenderingOn();
2023 _lineAActor->SetMapper(_lineAMapper);
2024 // _lineAActor->GetProperty()->BackfaceCullingOn();
2025 _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
2026 _lineAActor->GetProperty()->SetLineWidth(2);
2027 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2030 _ptsB = vtkPoints::New();
2031 _ptsB->SetNumberOfPoints(2);
2032 _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
2033 _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
2034 vtkCellArray *linesB;
2035 linesB = vtkCellArray::New();
2036 linesB->InsertNextCell(2);
2037 linesB->InsertCellPoint(0);
2038 linesB->InsertCellPoint(1);
2039 _pdB = vtkPolyData::New();
2040 _pdB->SetPoints( _ptsB );
2041 _pdB->SetLines( linesB );
2042 linesB->Delete(); //do not delete lines ??
2043 _lineBActor = vtkActor::New();
2044 _lineBMapper = vtkPolyDataMapper::New();
2045 _lineBMapper->SetInput(_pdB);
2046 _lineBMapper->ImmediateModeRenderingOn();
2047 _lineBActor->SetMapper(_lineBMapper);
2048 // _lineBActor->GetProperty()->BackfaceCullingOn();
2049 _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
2050 _lineBActor->GetProperty()->SetLineWidth(2);
2051 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2054 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
2058 if (_direction==0) {
2059 camera->SetViewUp ( 0 , -1 , 0 );
2060 camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
2061 camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
2062 camera->SetParallelScale( (z2-z1)/3.0 );
2065 if (_direction==1) {
2066 camera->SetViewUp ( 0 , 0 , -1 );
2067 camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
2068 camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
2069 camera->SetParallelScale( (x2-x1)/3.0 );
2072 if (_direction==2) {
2073 camera->SetViewUp ( 0 , -1 , 0 );
2074 camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
2075 camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
2076 camera->SetParallelScale( (x2-x1)/3.0 );
2080 if (_direction==0) {
2081 camera->SetViewUp ( 0 , 1 , 0 );
2082 camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 );
2083 camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
2084 camera->SetParallelScale( (z2-z1)/3.0 );
2087 if (_direction==1) {
2088 camera->SetViewUp ( 0 , 0 , -1 );
2089 camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
2090 camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
2091 camera->SetParallelScale( (x2-x1)/3.0 );
2094 if (_direction==2) {
2095 camera->SetViewUp ( 0 , 1 , 0 );
2096 camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000);
2097 camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
2098 camera->SetParallelScale( (x2-x1)/3.0 );
2105 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
2106 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
2110 void wxVtkMPR2DView::SetVisibleAxis(bool ok)
2112 if (ok!=_visibleAxis)
2115 if (_visibleAxis==true)
2117 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2118 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2120 if (_visibleAxis==false)
2122 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
2123 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
2129 //-------------------------------------------------------------------
2130 void wxVtkMPR2DView::Refresh()
2132 //wxVtk2DBaseView::Refresh();
2135 //vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2(); // JPRx
2136 //vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); // JPRx
2140 int x1,x2,y1,y2,z1,z2;
2141 GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
2144 vtkImageData* img = GetVtkmprbasedata()->GetImageData();
2146 img->GetSpacing(spc);
2147 x1 = (int)(x1*spc[0]);
2148 y1 = (int)(y1*spc[1]);
2149 z1 = (int)(z1*spc[2]);
2151 x2 = (int)(x2*spc[0]);
2152 y2 = (int)(y2*spc[1]);
2153 z2 = (int)(z2*spc[2]);
2155 int x = (int)(GetVtkmprbasedata()->GetX());
2156 int y = (int)(GetVtkmprbasedata()->GetY());
2157 int z = (int)(GetVtkmprbasedata()->GetZ());
2159 x = (int)(x*spc[0]);
2160 y = (int)(y*spc[1]);
2161 z = (int)(z*spc[2]);
2165 if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
2167 if (_direction==0) {
2168 _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
2169 _ptsA->SetPoint(0, -x2, y1 , z );
2170 _ptsA->SetPoint(1, -x2, y2 , z );
2171 _ptsB->SetPoint(0, -x2, y , z1);
2172 _ptsB->SetPoint(1, -x2, y , z2);
2174 if (_direction==1) {
2175 _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
2176 _ptsA->SetPoint(0, x1 , y2 , z );
2177 _ptsA->SetPoint(1, x2 , y2 , z );
2178 _ptsB->SetPoint(0, x , y2 , z1);
2179 _ptsB->SetPoint(1, x , y2 , z2);
2181 if (_direction==2) {
2182 _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
2183 _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
2184 // _ptsA->SetPoint(0, x1 , y , -z2 );
2185 // _ptsA->SetPoint(1, x2 , y , -z2 );
2186 // _ptsB->SetPoint(0, x , y1, -z2 );
2187 // _ptsB->SetPoint(1, x , y2, -z2 );
2189 _ptsA->SetPoint(0, x1 , y , z2 );
2190 _ptsA->SetPoint(1, x2 , y , z2 );
2191 _ptsB->SetPoint(0, x , y1, z2 );
2192 _ptsB->SetPoint(1, x , y2, z2 );
2198 wxVtkBaseView::Refresh();
2201 //-------------------------------------------------------------------
2202 int wxVtkMPR2DView::GetActualSlice() // virtual
2207 result = (int)(GetVtkmprbasedata()->GetX());
2211 result = (int)(GetVtkmprbasedata()->GetY());
2215 result = (int)(GetVtkmprbasedata()->GetZ());
2219 //-------------------------------------------------------------------
2220 void wxVtkMPR2DView::SetActualSlice(int slice) // virtual
2224 GetVtkmprbasedata()->SetX(slice);
2228 GetVtkmprbasedata()->SetY(slice);
2232 GetVtkmprbasedata()->SetZ(slice);
2235 //-------------------------------------------------------------------
2236 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
2245 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2252 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2259 //-------------------------------------------------------------------
2260 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
2266 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2276 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2283 //-------------------------------------------------------------------
2284 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
2290 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2297 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2307 //-------------------------------------------------------------------
2308 void wxVtkMPR2DView::MoveX(double x, double y, double z)
2315 GetVtkmprbasedata()->SetX(x);
2319 GetVtkmprbasedata()->SetX(x);
2322 //-------------------------------------------------------------------
2323 void wxVtkMPR2DView::MoveY(double x, double y, double z)
2327 GetVtkmprbasedata()->SetY(y);
2334 GetVtkmprbasedata()->SetY(y);
2337 //-------------------------------------------------------------------
2338 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
2342 GetVtkmprbasedata()->SetZ(z);
2346 GetVtkmprbasedata()->SetZ(z);
2352 //-------------------------------------------------------------------
2353 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
2355 double c1r=1,c1g=1,c1b=0;
2356 double c2r=1,c2g=0,c2b=0;
2360 if (IfMouseTouchY(x,y,z)==true)
2362 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2364 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2366 if (IfMouseTouchZ(x,y,z)==true)
2368 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2370 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2376 if (IfMouseTouchX(x,y,z)==true)
2378 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2380 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2382 if (IfMouseTouchZ(x,y,z)==true)
2384 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2386 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2392 if (IfMouseTouchX(x,y,z)==true)
2394 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2396 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2398 if (IfMouseTouchY(x,y,z)==true)
2400 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2402 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2407 //-------------------------------------------------------------------
2408 void wxVtkMPR2DView::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
2410 wxVtkBaseView::TransfromeCoordScreenToWorld(X,Y,Z,_direction);
2414 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
2418 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
2422 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
2425 //-------------------------------------------------------------------
2426 //-------------------------------------------------------------------
2427 //-------------------------------------------------------------------
2428 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2429 // if (eventId==vtkCommand::StartInteractionEvent){
2430 // _renWin->SetDesiredUpdateRate(10);
2432 // if (eventId==vtkCommand::InteractionEvent){
2433 // _renWin->SetDesiredUpdateRate(0.001);
2435 // if (eventId==vtkCommand::EndInteractionEvent){
2436 // vtkPlanes *planes = vtkPlanes::New();
2437 // vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2438 // boxwidget->GetPlanes(planes);
2439 // _volumeMapper->SetClippingPlanes(planes);
2440 // planes -> Delete();
2444 //-------------------------------------------------------------------
2445 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
2446 // _renWin = renWin;
2448 //-------------------------------------------------------------------
2449 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
2450 // _volumeMapper = volumeMapper;
2455 //-------------------------------------------------------------------
2456 //-------------------------------------------------------------------
2457 //-------------------------------------------------------------------
2459 void boxSurfaceObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2460 vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2461 boxwidget->GetPlanes(_planes);
2463 if ( _vtkVolumeRayCastMapper != NULL )
2465 _vtkVolumeRayCastMapper->RemoveAllClippingPlanes();
2466 // vtkPlanes *planes = vtkPlanes::New();
2467 // boxwidget->GetPlanes(planes);
2468 // _vtkVolumeRayCastMapper->SetClippingPlanes(planes);
2469 _vtkVolumeRayCastMapper->SetClippingPlanes(_planes);
2472 // _actor->VisibilityOn();
2475 //-------------------------------------------------------------------
2476 void boxSurfaceObserver::SetPlanes(vtkPlanes *planes){
2479 //-------------------------------------------------------------------
2480 void boxSurfaceObserver::SetActor(vtkProp *actor){
2484 //-------------------------------------------------------------------
2485 void boxSurfaceObserver::SetvtkVolumeRayCastMapper(vtkVolumeRayCastMapper *vtkvolumeraycastmapper)
2487 _vtkVolumeRayCastMapper = vtkvolumeraycastmapper;
2491 //-------------------------------------------------------------------
2492 //-------------------------------------------------------------------
2493 //-------------------------------------------------------------------
2495 wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DView *wxvtkmpr3Dview )
2496 : wxPanel(parent, -1)
2499 wxPanel *panel = this;
2500 _wxvtkmpr3Dview = wxvtkmpr3Dview;
2502 /*int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2503 int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2504 int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();*/
2510 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,_T("X "));
2511 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2512 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
2513 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2514 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,_T("Z "));
2515 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2516 wxButton *btnColorTable = new wxButton (panel, -1, _T("Edit Color Table") );
2518 _ckBoxXYZ = new wxCheckBox(panel,-1,_T("XYZ "));
2519 _ckBoxPlane = new wxCheckBox(panel,-1,_T("Plane"));
2521 ckBoxX->SetValue(false);
2522 ckBoxY->SetValue(false);
2523 ckBoxZ->SetValue(false);
2524 _ckBoxXYZ->SetValue(false);
2525 _ckBoxPlane->SetValue(false);
2527 _positionX->SetSize(400,20);
2528 _positionY->SetSize(400,20);
2529 _positionZ->SetSize(400,20);
2531 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2532 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2533 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2534 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2535 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2536 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2537 Connect(btnColorTable->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnEditColorTable );
2539 Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
2540 Connect(_ckBoxPlane->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
2543 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2544 // wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
2546 // wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL);
2547 wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10);
2548 wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10);
2553 // wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10);
2554 // wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10);
2556 // sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2557 // sizerH4->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2558 // sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
2560 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2561 // sizerH5->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2562 // sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
2564 // sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2565 // sizerH6->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2566 // sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
2568 // sizerH7->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2569 // sizerH7->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2571 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
2572 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2573 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
2574 // sizer->Add( sizerH7 , 1, wxALL|wxEXPAND, 2);
2576 sizerH4->Add( _positionX ,1,wxGROW , 0 );
2577 sizerH4->Add( ckBoxX ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2578 sizerH4->Add( _positionY ,1,wxGROW , 0 );
2579 sizerH4->Add( ckBoxY ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2580 sizerH4->Add( _positionZ ,1,wxGROW , 0 );
2581 sizerH4->Add( ckBoxZ ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2582 sizerH4->Add( btnColorTable ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2584 sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2585 sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2586 sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2587 // sizerH5->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2588 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2589 // sizerH5->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2591 sizer->Add( sizerH4 , 1, wxALL|wxGROW, 2);
2592 sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2595 panel->SetSize(400,50);
2596 panel->SetAutoLayout(true);
2597 panel->SetSizer(sizer);
2600 panel->SetEventHandler((wxEvtHandler*)this);
2602 //this->UpdateControlPanel();
2605 void wxVtkMPR3DViewCntrlPanel::UpdateControlPanel()
2608 vtkMPRBaseData* basedata = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData();
2609 if(basedata != NULL){
2611 /*int maxX = basedata->GetMaxPositionX();
2612 int maxY = basedata->GetMaxPositionY();
2613 int maxZ = basedata->GetMaxPositionZ();*/
2614 int x0,x1,y0,y1,z0,z1;
2616 basedata->GetDimensionExtention(&x0,&x1,&y0,&y1,&z0,&z1);
2617 /*int maxX = x1-x0;//basedata->GetMaxPositionX();
2618 int maxY = y1-y0;//basedata->GetMaxPositionY();
2619 int maxZ = z1-z0;//basedata->GetMaxPositionZ();*/
2623 //std::cout<<"wxVtkMPR3DViewCntrlPanel::UpdateControlPanel() maxX="<<maxX<<" maxY="<<maxY<<" maxZ="<<maxZ<<std::endl;
2624 /*_positionX->SetRange(0,maxX);
2625 _positionY->SetRange(0,maxY);
2626 _positionZ->SetRange(0,maxZ);*/
2627 _positionX->SetRange(x0,x1);
2628 _positionY->SetRange(y0,y1);
2629 _positionZ->SetRange(z0,z1);
2631 _positionX->SetValue((x0+x1)/2);
2632 _positionY->SetValue((y0+y1)/2);
2633 _positionZ->SetValue((z0+z1)/2);
2635 _positionX->Update();
2636 _positionY->Update();
2637 _positionZ->Update();
2642 //-------------------------------------------------------------------
2643 wxVtkMPR3DViewCntrlPanel::~wxVtkMPR3DViewCntrlPanel()
2646 //-------------------------------------------------------------------
2647 void wxVtkMPR3DViewCntrlPanel::Refresh()
2649 // wxPanel::Refresh();
2650 _positionX->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX( )) );
2651 _positionY->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY( )) );
2652 _positionZ->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ( )) );
2655 //-------------------------------------------------------------------
2656 int wxVtkMPR3DViewCntrlPanel::GetIdTissue()
2659 if (_surfA->GetValue()==true)
2663 if (_surfB->GetValue()==true)
2667 if (_surfC->GetValue()==true)
2671 if (_surfD->GetValue()==true)
2680 //-------------------------------------------------------------------
2681 void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event)
2684 vtkColorTransferFunction *ctfun = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetvtkColorTransferFunction();
2685 std::vector<double> *ctfunVectorPoint = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorPoint();
2686 std::vector<double> *ctfunVectorRed = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorRed();
2687 std::vector<double> *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
2688 std::vector<double> *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
2690 //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
2695 vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2697 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2);
2700 hDlg->erasePointsTransferenceFunction();
2701 int ctfSize=ctfunVectorRed->size();
2704 // MACHETE OJO Eduardo
2708 double gr = (*ctfunVectorPoint)[i];
2709 double r = (*ctfunVectorRed)[i];
2710 double g = (*ctfunVectorGreen)[i];
2711 double b = (*ctfunVectorBlue)[i];
2713 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
2719 // when the user had changed the transference Function
2722 //setting variables if the user wants to do refresh
2724 hDlg->setCTF(ctfun);
2725 hDlg->setMPR3Dview(_wxvtkmpr3Dview);
2727 if(hDlg->ShowModal()== wxID_OK )
2730 // -- vtkColorTransferFunction --
2731 ctfun->RemoveAllPoints ();
2733 ctfunVectorPoint->clear();
2734 ctfunVectorRed->clear();
2735 ctfunVectorGreen->clear();
2736 ctfunVectorBlue->clear();
2738 int nCTFpoints=hDlg->getSizeBarColor();
2739 // Machete .. Ojo Eduardo
2743 hDlg->getDataBarColorPoint(i,xi,r,g,b);
2747 hDlg->getDataBarColorPoint(1,xi,r,g,b);
2751 hDlg->getDataBarColorPoint(i-1,xi,r,g,b);
2754 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
2755 ctfunVectorPoint->push_back(xi);
2756 ctfunVectorRed->push_back(r/255.0);
2757 ctfunVectorGreen->push_back(g/255.0);
2758 ctfunVectorBlue->push_back(b/255.0);
2768 if(hDlg->getRefreshed())
2770 // -- vtkColorTransferFunction --
2771 ctfun->RemoveAllPoints ();
2774 int size=ctfunVectorPoint->size();
2778 double grey2=(*ctfunVectorPoint)[i];
2779 double red =(*ctfunVectorRed)[i];
2780 double green =(*ctfunVectorGreen)[i];
2781 double blue = (*ctfunVectorBlue)[i];
2782 ctfun->AddRGBPoint(grey2,red,green,blue);
2792 //-------------------------------------------------------------------
2793 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
2795 _wxvtkmpr3Dview->VisibleImageActor(0, event.IsChecked() );
2796 _wxvtkmpr3Dview->Refresh();
2798 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2801 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2803 std::cout<<e<<std::endl;
2807 //-------------------------------------------------------------------
2808 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
2810 _wxvtkmpr3Dview->VisibleImageActor(1, event.IsChecked() );
2811 _wxvtkmpr3Dview->Refresh();
2813 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2814 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2817 //-------------------------------------------------------------------
2818 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
2820 _wxvtkmpr3Dview->VisibleImageActor(2, event.IsChecked() );
2821 _wxvtkmpr3Dview->Refresh();
2823 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2824 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2827 //-------------------------------------------------------------------
2828 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event)
2830 _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked());
2833 //-------------------------------------------------------------------
2834 void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event)
2836 _wxvtkmpr3Dview->VisiblePlaneWidget(event.IsChecked());
2840 //-------------------------------------------------------------------
2841 void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event)
2843 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() );
2844 _wxvtkmpr3Dview->RefreshView();
2845 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2846 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2848 //-------------------------------------------------------------------
2849 void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event)
2851 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() );
2852 _wxvtkmpr3Dview->RefreshView();
2853 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2854 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2856 //-------------------------------------------------------------------
2857 void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event)
2859 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() );
2860 _wxvtkmpr3Dview->RefreshView();
2861 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2862 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2866 //-------------------------------------------------------------------
2867 //-------------------------------------------------------------------
2868 //-------------------------------------------------------------------
2870 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
2871 : wxPanel(parent, -1)
2873 wxPanel *panel = this;
2874 _wxvtkclipping3Dview = wxvtkclipping3Dview;
2877 // wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
2878 // wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
2880 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2881 _surfB = new wxRadioButton(panel,-1,_T("B"));
2882 _surfC = new wxRadioButton(panel,-1,_T("C"));
2883 _surfD = new wxRadioButton(panel,-1,_T("D"));
2885 wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
2886 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
2887 wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
2889 _color = new wxButton(panel,-1,_T(""));
2890 _visible = new wxCheckBox(panel,-1,_T("Vis"));
2891 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
2893 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
2894 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
2897 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2898 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
2902 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2903 vtkimagedata->GetScalarRange( range );
2904 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
2905 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
2908 _isoValue->SetTickFreq(25,0);
2910 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
2911 _isoValueSpin->SetRange(1,8);
2912 _isoValueSpin->SetValue(5);
2913 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
2915 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
2916 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
2918 wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
2921 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
2922 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
2923 Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
2926 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
2927 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
2931 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2932 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2933 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2934 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
2935 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2936 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
2937 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2938 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
2939 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2942 // ckVolum->Enable(false);
2943 ckBoxSurface->SetValue(false);
2944 ckBoxVolume->SetValue(false);
2945 _color->SetSize(40,20);
2946 _opacity->SetSize(370,20);
2947 // ckBoxX->SetValue(true);
2948 // ckBoxY->SetValue(true);
2949 // ckBoxZ->SetValue(true);
2950 _surfA->SetValue(true);
2951 _wireFrameRep->SetValue(false);
2952 _surfaceRep->SetValue(true);
2953 _visible->SetValue(false);
2954 // _positionX->SetSize(400,20);
2955 // _positionY->SetSize(400,20);
2956 // _positionZ->SetSize(400,20);
2958 Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
2959 Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
2961 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2962 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2963 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2964 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2965 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
2967 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2968 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2970 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
2971 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
2972 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
2975 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2976 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2979 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2980 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2981 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2982 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2983 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2984 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2987 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2988 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
2989 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
2990 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
2991 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
2992 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
2993 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
2994 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
2996 sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
2997 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2998 sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
2999 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3000 sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
3001 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3002 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
3005 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
3006 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3007 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
3008 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3009 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
3010 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3011 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
3012 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3013 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
3014 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3015 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
3016 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3017 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
3020 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
3021 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
3022 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3023 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
3024 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3027 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
3028 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3029 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
3030 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3032 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
3035 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
3036 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
3037 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
3040 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
3041 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
3042 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
3044 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
3045 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
3046 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
3048 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
3049 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
3050 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
3052 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
3053 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
3054 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
3055 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
3056 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
3057 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
3058 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
3060 panel->SetSize(300,60);
3061 panel->SetAutoLayout(true);
3062 panel->SetSizer(sizer);
3065 panel->SetEventHandler((wxEvtHandler*)this);
3068 //-------------------------------------------------------------------
3069 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
3072 //-------------------------------------------------------------------
3073 void wxVtkClipping3DViewCntrlPanel::Refresh()
3075 // wxPanel::Refresh();
3077 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
3078 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
3079 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
3082 //-------------------------------------------------------------------
3083 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
3086 if (_surfA->GetValue()==true)
3090 if (_surfB->GetValue()==true)
3094 if (_surfC->GetValue()==true)
3098 if (_surfD->GetValue()==true)
3106 //-------------------------------------------------------------------
3107 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
3109 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
3110 _wxvtkclipping3Dview->Refresh();
3112 //-------------------------------------------------------------------
3113 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
3115 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
3116 _wxvtkclipping3Dview->Refresh();
3118 //-------------------------------------------------------------------
3119 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
3121 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
3122 _wxvtkclipping3Dview->Refresh();
3126 //-------------------------------------------------------------------
3127 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
3129 int idTissue=GetIdTissue();
3134 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3136 tmpActor->GetProperty()->GetColor( rgb );
3137 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
3138 _color->SetBackgroundColour(colour);
3141 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
3144 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
3146 // Representation Type WireFrame / Surface
3147 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3148 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3151 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
3152 _isoValue->SetValue(isoValue);
3157 //-------------------------------------------------------------------
3158 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
3160 int idTissue=GetIdTissue();
3163 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
3165 _wxvtkclipping3Dview->Refresh();
3167 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3168 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3173 //-------------------------------------------------------------------
3174 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
3176 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
3177 _wxvtkclipping3Dview->Refresh();
3179 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3180 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3182 //-------------------------------------------------------------------
3183 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
3185 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
3186 _wxvtkclipping3Dview->Refresh();
3188 //-------------------------------------------------------------------
3189 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
3191 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
3192 _wxvtkclipping3Dview->Refresh();
3194 //-------------------------------------------------------------------
3195 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
3197 int idTissue=GetIdTissue();
3200 // EED 17 Janvier 2007
3201 wxColourDialog dlgColour(this);
3202 // dlgColour.ShowModal();
3203 if( dlgColour.ShowModal( ) == wxID_OK )
3206 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3207 float r=dlgColour.GetColourData().GetColour().Red()/255;
3208 float g=dlgColour.GetColourData().GetColour().Green()/255;
3209 float b=dlgColour.GetColourData().GetColour().Blue()/255;
3210 tmpActor->GetProperty()->SetColor( r , g , b );
3211 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
3213 _wxvtkclipping3Dview->Refresh();
3215 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3216 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3220 //-------------------------------------------------------------------
3221 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
3223 int idTissue=GetIdTissue();
3226 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
3228 _wxvtkclipping3Dview->Refresh();
3230 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3231 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3234 //-------------------------------------------------------------------
3235 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
3237 int idTissue=GetIdTissue();
3241 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3242 float opacity=_opacity->GetValue();
3243 tmpActor->GetProperty()->SetOpacity( opacity/100 );
3245 _wxvtkclipping3Dview->Refresh();
3247 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3248 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3252 //----------------------------------------------------------------------------
3253 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
3255 int value = _isoValue->GetValue();
3256 int delta= (int)pow( 4 , _isoValueSpin->GetValue() );
3257 int min=value - delta/2;
3258 int max=value + delta/2;
3264 _isoValue->SetRange(min,max);
3268 //------------------------------------------------------------------------
3269 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
3273 int idTissue=GetIdTissue();
3276 int isoValue=_isoValue->GetValue();
3277 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
3279 // tmpStr.Printf("%d",isoValue);
3281 _wxvtkclipping3Dview->Refresh();
3283 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3284 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3288 //-------------------------------------------------------------------
3289 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
3292 int idTissue=GetIdTissue();
3299 wxString dirSTL = wxGetHomeDir( ) ;
3300 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
3302 if( dialog.ShowModal( ) == wxID_OK )
3306 // ------------------------------------------------------------------------
3307 // 1. GENERATE STL FILES
3308 // ------------------------------------------------------------------------
3309 // const char* fileprefix = "c:\\Creatis\\";
3310 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
3311 std::string filename;
3313 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
3315 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
3318 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
3319 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
3320 pdcf->SetInput( filtro->GetOutput() );
3321 vtkClosePolyData *cpd = vtkClosePolyData::New();
3322 cpd->SetInput( pdcf->GetOutput() );
3324 // 1.2 se escribe a disco el archivo stl de la superficie interna
3326 vtkSTLWriter *writer = vtkSTLWriter::New();
3327 writer->SetInput( cpd->GetOutput() );
3329 writer->SetFileName(filename.c_str());
3330 writer->SetFileTypeToASCII();
3342 //EED 30 Janvier 2007
3343 //-------------------------------------------------------------------
3344 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
3346 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
3347 if (dialog.ShowModal() == wxID_OK)
3349 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
3350 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
3351 float rescalaSlope = 1;
3352 float rescalaIntercept = 0;
3353 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
3354 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
3356 vtkimagedata->GetDimensions(dim);
3364 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
3365 marRAW2Files marraw2;
3366 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
3370 //EED 22 Fevrier 2007
3371 //-------------------------------------------------------------------
3372 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
3375 int /*i=0,*/ xi,yi,r,g,b; // JPRx
3376 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
3377 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
3378 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
3379 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
3380 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
3381 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
3382 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
3383 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
3384 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3386 //use for update in the refresh
3388 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
3389 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
3394 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
3395 if (dialog.ShowModal() == wxID_OK)
3397 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
3403 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
3407 int tfSize=gtf->size();
3411 hDlg->erasePointsTransferenceFunction();
3415 double in=(*itf)[i];
3416 hDlg->addPointToTransferenceFunction(g,in*100);
3422 int ctfSize=rctf->size();
3428 double gr=(*greyctf)[i];
3429 double r=(*rctf)[i];
3430 double g=(*gctf)[i];
3431 double b=(*bctf)[i];
3432 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
3436 //setting variables if the user wants to do refresh
3437 hDlg->setCTF(ctfun);
3439 hDlg->setClipping3DView(_wxvtkclipping3Dview);
3441 hDlg->setVolume(newvol);
3442 hDlg->setVolumeMapper(volumeMapper);
3445 // when the user had changed the transference Function
3447 if(hDlg->ShowModal()== wxID_OK )
3449 // -- vtkPiecewiseFunction --
3450 tfun->RemoveAllPoints();
3454 int nTFPoints=hDlg->getSizeTransferenceFunction();
3458 hDlg->getTransferenceFunctionPoint(i,xi,yi);
3459 tfun->AddPoint( xi , yi/100.0 );
3461 itf->push_back(yi/100.0);
3464 // -- vtkColorTransferFunction --
3465 ctfun->RemoveAllPoints ();
3472 int nCTFpoints=hDlg->getSizeBarColor();
3476 hDlg->getDataBarColorPoint(i,xi,r,g,b);
3477 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
3478 rctf->push_back(r/255.0);
3479 gctf->push_back(g/255.0);
3480 bctf->push_back(b/255.0);
3481 greyctf->push_back(xi);
3484 //---------------------------------
3485 // Refreshing and sending the event
3486 //---------------------------------
3487 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3488 _wxvtkclipping3Dview->Refresh();
3489 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3490 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3493 volumeMapper->Update();
3501 if(hDlg->getRefreshed())
3504 //--Transference Function----
3505 tfun->RemoveAllPoints();
3510 double grey1=(*gtf)[i];
3511 double in2=(*itf)[i];
3512 tfun->AddPoint( grey1 , in2 );
3515 // -- vtkColorTransferFunction --
3516 ctfun->RemoveAllPoints ();
3519 size=greyctf->size();
3522 double grey2=(*greyctf)[i];
3523 double red =(*rctf)[i];
3524 double green =(*gctf)[i];
3525 double blue = (*bctf)[i];
3526 ctfun->AddRGBPoint(grey2,red,green,blue);
3529 //---------------------------------
3530 // Refreshing and sending the event
3531 //---------------------------------
3532 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3533 _wxvtkclipping3Dview->Refresh();
3534 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3535 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3538 volumeMapper->Update();
3544 //destroy the dialog
3549 //-------------------------------------------------------------------
3550 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
3552 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
3553 if (dialog.ShowModal() == wxID_OK)
3555 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
3556 _wxvtkclipping3Dview->Refresh();
3557 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3558 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3563 //-------------------------------------------------------------------
3564 //-------------------------------------------------------------------
3565 //-------------------------------------------------------------------
3568 wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
3570 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3571 _vtkmpr3Ddataviewer = NULL;
3572 _wxvtkmpr3DviewCntrlPanel = NULL;
3578 _contourMapper=NULL;
3580 void wxVtkMPR3DView::RemoveActor(vtkActor* actor){
3582 _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
3586 void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
3589 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
3590 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3592 /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
3593 double y = (spc[1])*(origin[1]+(double)ext[3]);
3594 double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
3595 /*double x0=(spc[0])*((double)ext[0]+origin[0]);
3596 double x1=(spc[0])*((double)ext[1]+origin[0]);
3597 double y0=(spc[1])*((double)ext[2]+origin[1]);
3598 double y1=(spc[1])*((double)ext[3]+origin[1]);
3599 double z0=(spc[2])*((double)ext[4]+origin[2]);
3600 double z1=(spc[2])*((double)ext[5]+origin[2]);*/
3601 double x0=(spc[0])*((double)ext[0]);
3602 double x1=(spc[0])*((double)ext[1]);
3603 double y0=(spc[1])*((double)ext[2]);
3604 double y1=(spc[1])*((double)ext[3]);
3605 double z0=(spc[2])*((double)ext[4]);
3606 double z1=(spc[2])*((double)ext[5]);
3608 _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
3609 //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
3610 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3613 void wxVtkMPR3DView::Configure(){
3616 _wxvtk3Dbaseview->Configure();
3617 _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
3618 _wxvtk3Dbaseview->GetRenderer()->Clear();
3620 // Actors are added to the renderer.
3621 vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
3622 _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
3623 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
3624 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
3625 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
3628 // An initial camera view is created. The Dolly() method moves
3629 // the camera towards the FocalPoint, thereby enlarging the image.
3630 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
3631 this->ResetCamera();
3634 // Set a background color for the renderer and set the size of the
3635 // render window (expressed in pixels).
3636 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
3637 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
3639 // Note that when camera movement occurs (as it does in the Dolly()
3640 // method), the clipping planes often need adjusting. Clipping planes
3641 // consist of two planes: near and far along the view direction. The
3642 // near plane clips out objects in front of the plane; the far plane
3643 // clips out objects behind the plane. This way only what is drawn
3644 // between the planes is actually rendered.
3645 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
3649 if(_myCallback!=NULL){
3650 _myCallback->Delete();
3653 _myCallback = vtkmyPWCallback_3DPointWidget::New();
3654 _myCallback->SetWxVtkMPR3DView(this);
3656 if(_pointWidget!=NULL){
3657 _pointWidget->Delete();
3659 _pointWidget = vtkPointWidget::New();
3660 _myCallback->SetVtkPointWidget(_pointWidget);
3661 _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3662 _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3664 _pointWidget->AllOff();
3666 _pointWidget->PlaceWidget();
3667 // _pointWidget->SetPosition( x,y,z );
3670 // MACOS probleme vtk-window out of wx-window
3671 // _pointWidget->On();
3673 _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3677 if(_planeWidget!=NULL){
3678 _planeWidget->Delete();
3680 _planeWidget = vtkPlaneWidget::New();
3681 _myCallback->SetVtkPlaneWidget(_planeWidget);
3682 _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3683 _planeWidget->NormalToXAxisOn();
3684 _planeWidget->SetResolution(50);
3685 _planeWidget->SetRepresentationToOutline();
3687 GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
3692 _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
3695 if(_vtkplane==NULL){
3696 _vtkplane = vtkPolyData::New();
3698 _probe = vtkProbeFilter::New();
3699 _probe->SetInput(_vtkplane);
3701 _contourMapper = vtkPolyDataMapper::New();
3703 _contourMapper->SetInput( _probe->GetPolyDataOutput() );
3705 _contourPlaneActor = vtkActor::New();
3706 _contourPlaneActor->SetMapper(_contourMapper);
3708 _contourPlaneActor->VisibilityOff();
3710 _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3711 _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3713 _planeWidget->Off();
3714 _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
3719 _planeWidget->GetPolyData(_vtkplane);
3722 vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3723 _probe->SetSource( imageData );
3726 _contourMapper->SetScalarRange( imageData->GetScalarRange() );
3732 //-------------------------------------------------------------------
3733 wxVtkMPR3DView::~wxVtkMPR3DView()
3737 //-------------------------------------------------------------------
3738 void wxVtkMPR3DView::Refresh() // virtual
3740 _vtkmpr3Ddataviewer -> Refresh();
3741 if (_wxvtkmpr3DviewCntrlPanel!=NULL)
3743 _wxvtkmpr3DviewCntrlPanel->Refresh();
3747 //-------------------------------------------------------------------
3748 void wxVtkMPR3DView::RefreshView() // virtual
3751 this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
3753 //double nx=1,ny=0,nz=0; // JPRx
3755 double x=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetX();
3756 double y=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetY();
3757 double z=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetZ();
3763 _pointWidget->SetPosition( x,y,z );
3768 vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
3769 in[0]=1; in[1]=0; in[2]=0;
3770 transform->TransformPoint(in,normal);
3771 _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
3774 _planeWidget->SetCenter( x,y,z );
3775 _planeWidget->UpdatePlacement();
3776 _planeWidget->GetPolyData(_vtkplane);
3778 //-------------------------------------------------------------------
3779 wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent)
3781 _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this);
3782 return _wxvtkmpr3DviewCntrlPanel;
3784 //-------------------------------------------------------------------
3785 vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
3787 return _vtkmpr3Ddataviewer;
3789 //-------------------------------------------------------------------
3790 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
3792 if(_wxvtk3Dbaseview==NULL){
3793 throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
3795 return _wxvtk3Dbaseview;
3797 //-------------------------------------------------------------------
3799 //-------------------------------------------------------------------
3800 void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
3801 if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
3802 if (visible==false){
3803 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3805 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3807 _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
3812 //-------------------------------------------------------------------
3813 void wxVtkMPR3DView::VisiblePointWidget( bool visible )
3819 _pointWidget->Off();
3823 //-------------------------------------------------------------------
3824 void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
3829 _contourPlaneActor->VisibilityOn();
3832 _planeWidget->Off();
3833 _contourPlaneActor->VisibilityOff();
3837 //-------------------------------------------------------------------
3838 void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer)
3840 _vtkmpr3Ddataviewer = vtkmpr3Ddataviewer;
3843 //-------------------------------------------------------------------
3844 void wxVtkMPR3DView::InitOrientationPointWidget()
3846 this->_planeWidget->SetNormal(1,0,0);
3852 //-------------------------------------------------------------------
3853 // EED 25 Janvier 2007 testLoic
3854 void wxVtkMPR3DView::TestLoic1()
3858 double dimIma = sizeIma*2;
3860 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3863 vtkimagedata->GetSpacing(spc);
3865 vtkimagedata->Update();
3869 this->_planeWidget->GetOrigin(p);
3870 this->_planeWidget->GetNormal(n);
3874 vtkPlaneSource* pSource = vtkPlaneSource::New( );
3875 pSource->SetResolution( sizeIma - 1, sizeIma - 1 );
3876 pSource->SetOrigin( p[ 0 ], p[ 1 ], p[ 2 ] );
3877 pSource->SetPoint1( p[ 0 ] + dimIma - 1.0, p[ 1 ], p[ 2 ] );
3878 pSource->SetPoint2( p[ 0 ], p[ 1 ]+ dimIma - 1.0 , p[ 2 ] );
3880 pSource->SetCenter( p[ 0 ], p[ 1 ], p[ 2 ] );
3881 pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
3884 vtkProbeFilter* slices = vtkProbeFilter::New();
3885 slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
3886 slices->SetSource( vtkimagedata );
3890 vtkStructuredPoints *stPoints = vtkStructuredPoints::New();
3891 stPoints -> GetPointData( )->SetScalars( slices->GetOutput()->GetPointData()->GetScalars() );
3892 stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
3893 stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
3894 stPoints -> SetScalarTypeToShort();
3895 stPoints -> Update();
3897 vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
3898 change -> SetInput( stPoints );
3899 change -> Update(); //important
3902 vtkimagedata->GetScalarRange(_range);
3903 vtkWindowLevelLookupTable *_bwlookup = vtkWindowLevelLookupTable::New( );
3904 _bwlookup->SetHueRange( 0 , 1 );
3905 _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
3906 _bwlookup->SetTableRange( _range[0] , _range[1] );
3907 _bwlookup->SetSaturationRange( 0 , 0 );
3908 _bwlookup->SetValueRange( 0 , 1 );
3909 _bwlookup->SetAlphaRange( 1 , 1 );
3910 _bwlookup->Build( );
3912 vtkLookupTable * _collookup = vtkLookupTable::New( );
3913 _collookup->SetNumberOfColors( 256 );
3914 _collookup->SetTableRange( 0 , 255 );
3915 _collookup->Build( );
3916 _collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
3917 _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
3918 _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
3921 vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
3922 writer->SetInput( stPoints );
3923 writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
3924 writer->SetFileDimensionality( 2 );
3929 vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
3930 _3DSliceMapper->SetInput(change->GetOutput( ) );
3931 _3DSliceMapper->SetLookupTable( _bwlookup );
3932 _3DSliceMapper->SetScalarRange( _range );
3933 _3DSliceMapper->ImmediateModeRenderingOn( );
3935 vtkActor *_3DSliceActor = vtkActor::New( );
3936 _3DSliceActor->SetMapper( _3DSliceMapper );
3938 // The usual rendering stuff.
3939 vtkCamera *camera = vtkCamera::New();
3940 camera->SetPosition(1,1,1);
3941 camera->SetFocalPoint(0,0,0);
3943 vtkRenderer *renderer = vtkRenderer::New();
3944 vtkRenderWindow *renWin = vtkRenderWindow::New();
3945 renWin->AddRenderer(renderer);
3947 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3948 iren->SetRenderWindow(renWin);
3950 renderer->AddActor( _3DSliceActor );
3951 renderer->SetActiveCamera(camera);
3952 renderer->ResetCamera();
3953 renderer->SetBackground(1,1,1);
3955 renWin->SetSize(300,300);
3957 // interact with data
3967 //-------------------------------------------------------------------
3968 // EED 25 Janvier 2007 testLoic
3969 void wxVtkMPR3DView::TestLoic2()
3972 vtkVectorNorm *vecMagnitude = vtkVectorNorm::New();
3973 vecMagnitude->SetInput(VtkMainGrid);
3974 vecMagnitude->NormalizeOff();
3975 vecMagnitude->Update();
3978 vtkPlane *slicePlane = vtkPlane::New();
3979 this->_planeWidget->GetPlane( slicePlane );
3982 vtkCutter* sliceCutter = vtkCutter::New();
3983 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3984 sliceCutter->SetInput( vtkimagedata );
3985 sliceCutter->SetCutFunction( slicePlane );
3988 // vtkLookupTable *lut = BuildHueWeightBaseMap();
3991 vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
3992 slice->SetInput( sliceCutter->GetOutput() );
3996 vtkimagedata->GetScalarRange(range);
3997 // vecMagnitude->GetOutput()->GetScalarRange( range );
3998 // range[1] *= 0.7; // reduce the upper range by 30%
3999 // slice->SetScalarRange( range );
4000 // slice->SetLookupTable( lut );
4002 // vtkActor *sliceActor = vtkActor::New();
4003 // sliceActor->SetMapper( slice );
4005 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
4006 contourMapper->SetInput( sliceCutter->GetOutput() );
4007 contourMapper->SetScalarRange( range );
4008 // contourMapper->SetLookupTable( lut );
4011 vtkActor *contourActor = vtkActor::New();
4012 contourActor->SetMapper( contourMapper );
4016 // The usual rendering stuff.
4017 vtkCamera *camera = vtkCamera::New();
4018 camera->SetPosition(1,1,1);
4019 camera->SetFocalPoint(0,0,0);
4021 vtkRenderer *renderer = vtkRenderer::New();
4022 vtkRenderWindow *renWin = vtkRenderWindow::New();
4023 renWin->AddRenderer(renderer);
4025 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
4026 iren->SetRenderWindow(renWin);
4028 renderer->AddActor( contourActor );
4029 // renderer->AddActor(cubeActor);
4030 renderer->SetActiveCamera(camera);
4031 renderer->ResetCamera();
4032 renderer->SetBackground(1,1,1);
4034 renWin->SetSize(300,300);
4036 // interact with data
4043 //-------------------------------------------------------------------
4044 //-------------------------------------------------------------------
4045 //-------------------------------------------------------------------
4047 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
4049 _wxvtk3Dbaseview = wxvtk3Dbaseview;
4050 _vtkclipping3Ddataviewer = NULL;
4051 _wxvtkclipping3DviewCntrlPanel = NULL;
4053 _boxWidgetVolume = NULL;
4054 _boxWidgetS1 = NULL;
4057 //-------------------------------------------------------------------
4058 wxVtkClipping3DView::~wxVtkClipping3DView(){
4059 if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
4060 if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
4061 if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
4062 if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
4064 //-------------------------------------------------------------------
4065 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
4070 _boxWidgetS1->Off();
4073 //-------------------------------------------------------------------
4074 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
4076 if (_boxWidgetVolume!=NULL){
4078 _boxWidgetVolume->On();
4080 _boxWidgetVolume->Off();
4084 //-------------------------------------------------------------------
4085 void wxVtkClipping3DView::Refresh()
4087 _vtkclipping3Ddataviewer->Refresh();
4088 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
4090 _wxvtkclipping3DviewCntrlPanel->Refresh();
4093 //-------------------------------------------------------------------
4094 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
4096 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
4097 return _wxvtkclipping3DviewCntrlPanel;
4099 //-------------------------------------------------------------------
4100 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
4102 return _vtkclipping3Ddataviewer;
4104 //-------------------------------------------------------------------
4105 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
4106 if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
4107 if (visTissue==false){
4108 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
4110 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
4111 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
4112 // _actor->VisibilityOn();
4114 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
4117 //-------------------------------------------------------------------
4118 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
4121 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
4123 if (representationType==false){
4124 tmpActor->GetProperty()->SetRepresentationToWireframe();
4126 tmpActor->GetProperty()->SetRepresentationToSurface();
4129 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
4132 //-------------------------------------------------------------------
4133 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
4134 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
4135 if (visVolume==false){
4137 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4138 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4141 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4142 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4144 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
4147 //-------------------------------------------------------------------
4148 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
4150 if(_wxvtk3Dbaseview==NULL){
4151 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
4153 return _wxvtk3Dbaseview;
4155 //-------------------------------------------------------------------
4156 void wxVtkClipping3DView::Configure(){
4157 _wxvtk3Dbaseview->Configure();
4159 // Actors are added to the renderer.
4160 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
4162 _boxWidgetS1 = vtkBoxWidget::New();
4163 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4164 _boxWidgetS1->SetPlaceFactor(1.25);
4168 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
4169 vtkPolyData *polydata= stripper->GetOutput();
4172 _boxWidgetS1->SetInput( polydata );
4173 _boxWidgetS1->PlaceWidget();
4176 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
4178 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
4184 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
4185 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
4187 VisibleActor(0, false );
4188 VisibleActor(1, false );
4189 VisibleActor(2, false );
4190 VisibleActor(3, false );
4192 _boxWidgetS1->HandlesOn ();
4195 // _boxWidgetS1->On();
4197 _boxWidgetS1->Off();
4199 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
4200 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
4201 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
4202 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
4206 _boxWidgetVolume = vtkBoxWidget::New();
4207 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4208 _boxWidgetVolume->SetPlaceFactor(1.25);
4210 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
4211 _boxWidgetVolume->PlaceWidget();
4213 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
4215 _boxWidgetVolume->HandlesOn ();
4218 // _boxWidgetVolume->On();
4220 _boxWidgetVolume->Off();
4223 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
4224 // _boxWidgetVolume->GetPlanes( vtkplanes );
4227 // An initial camera view is created. The Dolly() method moves
4228 // the camera towards the FocalPoint, thereby enlarging the image.
4229 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
4230 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
4231 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
4233 // Set a background color for the renderer and set the size of the
4234 // render window (expressed in pixels).
4235 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
4236 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
4238 // Note that when camera movement occurs (as it does in the Dolly()
4239 // method), the clipping planes often need adjusting. Clipping planes
4240 // consist of two planes: near and far along the view direction. The
4241 // near plane clips out objects in front of the plane; the far plane
4242 // clips out objects behind the plane. This way only what is drawn
4243 // between the planes is actually rendered.
4244 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
4246 //-------------------------------------------------------------------
4247 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
4249 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4253 //---------------------------------------------------------------------------
4254 //---------------------------------------------------------------------------
4255 //---------------------------------------------------------------------------
4256 vtkInteractorStyle3DView::vtkInteractorStyle3DView()
4259 //---------------------------------------------------------------------------
4260 vtkInteractorStyle3DView::~vtkInteractorStyle3DView()
4263 //---------------------------------------------------------------------------
4264 bool vtkInteractorStyle3DView::OnLeftDClick()
4266 SelectMarchibCubePoint();
4269 //---------------------------------------------------------------------------
4270 bool vtkInteractorStyle3DView::SelectMarchibCubePoint()
4273 gtm::TVector< double > pO( 3 ), pF( 3 ), pp( 3 ), cp( 3 );
4274 gtm::TVector< double > xc( 3 );
4275 gtm::TVector< double > x1( 3 ), n1( 3 );
4276 gtm::TVector< double > x2( 3 ), n2( 3 );
4278 double pickPoint[ 3 ], cameraPos[ 3 ];
4280 vtkPointPicker* picker = vtkPointPicker::New( );
4281 eventrwi[0]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
4282 eventrwi[1]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
4283 vtkRenderer *pRenderer = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetRenderer();
4284 picker->Pick( eventrwi[0], eventrwi[1], 0.0, pRenderer );
4285 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
4286 picker->GetPickPosition( pickPoint );
4289 pp( 0 ) = pickPoint[ 0 ]; pp( 1 ) = pickPoint[ 1 ]; pp( 2 ) = pickPoint[ 2 ];
4290 cp( 0 ) = cameraPos[ 0 ]; cp( 1 ) = cameraPos[ 1 ]; cp( 2 ) = cameraPos[ 2 ];
4293 //EED 27 sep 2006 (1/2)
4294 // wxVtkMPR3DView *wxvtkmpr3Dview = (wxVtkMPR3DView *)_vtkInteractorStyleBaseView->GetWxVtk3DBaseView();
4296 // wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetSpacing(spc);
4299 vtkImageData *imageData = GetWxVtkMPR3DView()->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
4302 imageData->GetDimensions(dim);
4303 imageData->GetSpacing(spc);
4306 vtkMarchingCubes *mcubes = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetMCubes(0);
4309 UtilVtk3DGeometriSelection utilVtk3DGeometriSelection;
4310 utilVtk3DGeometriSelection.SetDimentions(dim[0],dim[1],dim[2]);
4312 utilVtk3DGeometriSelection.SetMarchingCube(mcubes);
4315 fac = GTM_MAX( dim[0], dim[2] );
4318 if( utilVtk3DGeometriSelection.FindCubePointsFromPoints(
4319 pO.GetAnsiRef( ), pF.GetAnsiRef( ),
4320 pp.GetAnsiRef( ), cp.GetAnsiRef( ) ) )
4323 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4324 x1.GetAnsiRef( ), n1.GetAnsiRef( ),
4325 pO.GetAnsiRef( ), pF.GetAnsiRef( ) ) )
4327 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4328 x2.GetAnsiRef( ), n2.GetAnsiRef( ),
4329 ( x1 - n1 ).GetAnsiRef( ), ( x1 - ( n1 * fac ) ).GetAnsiRef( ) ) )
4331 xc = ( x2 + x1 ) * 0.5;
4332 //EED 27 sep 2006 (2/2)
4333 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX(xc(0)/spc[0]);
4334 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xc(1)/spc[1]);
4335 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xc(2)/spc[2]);
4336 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4337 this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4346 //-------------------------------------------------------------------
4347 void vtkInteractorStyle3DView::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4349 _wxvtkmpr3Dview = wxvtkmpr3Dview;
4351 //-------------------------------------------------------------------
4352 wxVtkMPR3DView *vtkInteractorStyle3DView::GetWxVtkMPR3DView()
4354 return _wxvtkmpr3Dview;
4356 //-------------------------------------------------------------------
4357 wxVtkClipping3DView *vtkInteractorStyle3DView::GetWxVtkClipping3DView()
4359 return _wxvtkclipping3Dview;
4361 //-------------------------------------------------------------------
4362 void vtkInteractorStyle3DView::SetWxVtkClipping3DView( wxVtkClipping3DView *wxvtkclipping3Dview)
4364 _wxvtkclipping3Dview = wxvtkclipping3Dview;
4369 //-------------------------------------------------------------------
4370 //-------------------------------------------------------------------
4371 //-------------------------------------------------------------------
4372 void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
4376 double delta = 0.000000001;
4378 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4380 if (caller==_pointWidget)
4382 _pointWidget->GetPosition(p);
4384 if (caller==_planeWidget)
4386 _planeWidget->GetCenter(p);
4387 _planeWidget->GetNormal(n);
4388 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
4392 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
4397 // Orientation change
4398 if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
4400 _backNormal[0] = n[0];
4401 _backNormal[1] = n[1];
4402 _backNormal[2] = n[2];
4403 isbv->SetParent_refresh_waiting();
4408 double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
4409 double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
4410 double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
4413 if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
4415 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
4416 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
4417 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
4418 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4419 isbv->BlockRefresh();
4420 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
4421 isbv->SetParent_refresh_waiting();
4422 isbv->vtkInteractorStyleBaseView::OnMouseMove();
4423 isbv->UnBlockRefresh();
4425 isbv->EvaluateToRefresh();
4427 //-------------------------------------------------------------------
4428 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4430 _wxvtkmpr3Dview=wxvtkmpr3Dview;
4432 //-------------------------------------------------------------------
4433 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
4435 _pointWidget=pointWidget;
4437 //-------------------------------------------------------------------
4438 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
4440 _planeWidget=planeWidget;
4442 //-------------------------------------------------------------------
4443 //-------------------------------------------------------------------
4444 //-------------------------------------------------------------------
4446 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
4447 : wxPanel( parent, -1)
4450 _histogrammeVector=NULL;
4451 _wxvtk3Dbaseview=NULL;
4452 _wxvtkbaseView=NULL;
4455 Create3DViewObjects();
4458 //-------------------------------------------------------------------
4459 wxPanelCuttingImageData::~wxPanelCuttingImageData()
4464 delete _modelSphere;
4465 delete _modelCylinder;
4466 _vtkcube -> Delete();
4467 _vtksphere -> Delete();
4468 _vtkcylinder -> Delete();
4469 _cubeMapper -> Delete();
4470 _sphereMapper -> Delete();
4471 _cylinderMapper -> Delete();
4472 _cubeActor -> Delete();
4473 _sphereActor -> Delete();
4474 _cylinderActor -> Delete();
4475 // _xyplot->RemoveAllInputs();
4476 _xyplot -> Delete();
4477 _histogrammeVector->Delete();
4478 _renplotter->Delete();
4480 if(_wxvtkbaseView!=NULL){
4481 delete _wxvtkbaseView;
4483 //delete _vtkclipping3Ddataviewer;
4490 //-------------------------------------------------------------------
4491 void wxPanelCuttingImageData::RemoveActors()
4493 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4497 //-------------------------------------------------------------------
4498 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
4500 _wxvtk3Dbaseview=wxvtk3Dbaseview;
4503 //-------------------------------------------------------------------
4505 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
4507 this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4510 //-------------------------------------------------------------------
4511 void wxPanelCuttingImageData::Create3DViewObjects()
4514 _vtksphere = vtkSphereSource::New();
4515 _vtksphere->SetThetaResolution (20);
4516 _vtksphere->SetPhiResolution (20);
4517 _sphereMapper = vtkPolyDataMapper::New();
4518 _sphereMapper->SetInput( _vtksphere->GetOutput() );
4519 _sphereActor = vtkActor::New();
4520 _sphereActor->SetMapper(_sphereMapper);
4521 _sphereActor->SetOrigin(0, 0, 0);
4522 _sphereActor->SetPosition(0, 0, 0);
4523 _sphereActor->GetProperty()->SetColor(1, 0, 0);
4524 _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );
4527 _vtkcube = vtkCubeSource::New();
4528 _vtkcube->SetXLength (1);
4529 _vtkcube->SetYLength (1);
4530 _vtkcube->SetZLength (1);
4531 _cubeMapper = vtkPolyDataMapper::New();
4532 _cubeMapper->SetInput( _vtkcube->GetOutput() );
4533 _cubeActor = vtkActor::New();
4534 _cubeActor->SetMapper(_cubeMapper);
4535 _cubeActor->SetOrigin(0, 0, 0);
4536 _cubeActor->SetPosition(0, 0, 0);
4537 _cubeActor->GetProperty()->SetColor(1, 0, 0);
4538 _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );
4541 _vtkcylinder = vtkCylinderSource::New();
4542 _vtkcylinder->SetResolution(20);
4543 _cylinderMapper = vtkPolyDataMapper::New();
4544 _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
4545 _cylinderActor = vtkActor::New();
4546 _cylinderActor->SetMapper(_cylinderMapper);
4547 _cylinderActor->SetOrigin(0, 0, 0);
4548 _cylinderActor->SetPosition(0, 0, 0);
4549 _cylinderActor->GetProperty()->SetColor(1, 0, 0);
4550 _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );
4555 //-------------------------------------------------------------------
4556 void wxPanelCuttingImageData::CreateModel()
4558 _modelCube = new figureCuttingCubeModel();
4559 _modelSphere = new figureCuttingSphereModel();
4560 _modelCylinder = new figureCuttingCylinderModel();
4562 // _modelCube->SetVtkTransform( _modelCube->GetVtkTransform() );
4563 // _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform() );
4564 // _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform() );
4567 //-------------------------------------------------------------------
4569 void wxPanelCuttingImageData::InitHistogramme()
4572 if (_imageData==NULL)
4576 _imageData->GetScalarRange(rangeA);
4578 _xyplot->RemoveAllInputs();
4580 if ( _histogrammeVector!=NULL )
4582 _histogrammeVector -> Delete();
4585 _histogrammeVector = vtkImageData::New();
4586 _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
4587 _histogrammeVector -> SetScalarTypeToUnsignedShort();
4588 _histogrammeVector -> AllocateScalars();
4589 _histogrammeVector -> Update();
4591 unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4592 int i,size = (int) (rangeA[1]);
4593 for (i=0; i < size; i++)
4598 _xyplot->SetXRange(0, rangeA[1]);
4599 _xyplot->SetYRange(0, 10);
4600 _xyplot->AddInput( _histogrammeVector );
4603 //-------------------------------------------------------------------
4604 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
4606 _xyplot = vtkXYPlotActor::New();
4608 _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
4609 _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
4610 _xyplot->SetXValuesToArcLength();
4611 _xyplot->SetNumberOfXLabels(6);
4613 _xyplot->SetTitle("Histogramme");
4614 _xyplot->SetXTitle("Gray level");
4615 _xyplot->SetYTitle("Occurrences ");
4616 _xyplot->GetProperty()->SetColor(1, 0, 0);
4617 _xyplot->GetProperty()->SetPointSize(2);
4618 vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
4619 tprop->SetColor( 1,0,1 );
4621 _xyplot->SetAxisTitleTextProperty(tprop);
4622 _xyplot->SetAxisLabelTextProperty(tprop);
4623 _xyplot->PlotPointsOn();
4624 _xyplot->GetProperty()->SetPointSize(3);
4626 _wxvtkbaseView = new wxVtkBaseView(this);
4627 _wxvtkbaseView->Configure();
4629 _renplotter = vtkRenderer::New();
4630 vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
4631 renWin->AddRenderer( _renplotter );
4632 _renplotter->AddActor2D( _xyplot );
4634 return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
4637 //-------------------------------------------------------------------
4639 void wxPanelCuttingImageData::CreateInterface()
4642 wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); // Principal sizer
4644 wxBoxSizer *sizerH0 = new wxBoxSizer(wxHORIZONTAL ); // type of segmentation figure
4645 wxBoxSizer *sizerH2 = new wxBoxSizer(wxHORIZONTAL ); // scale
4646 wxBoxSizer *sizerH3 = new wxBoxSizer(wxHORIZONTAL ); // rotation
4647 wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL ); // intern extern
4648 wxBoxSizer *sizerH5 = new wxBoxSizer(wxHORIZONTAL ); // Isovalue
4649 wxBoxSizer *sizerH6 = new wxBoxSizer(wxHORIZONTAL ); // Buttons
4650 wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(2 ); // Volumic information
4653 _typeFig = new wxChoice(this,-1);
4654 _opacityFig = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4656 _scaleX = new wxSlider(this,-1,6,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4657 _scaleY = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4658 _scaleZ = new wxSlider(this,-1,7,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4660 _rotationX = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4661 _rotationY = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4662 _rotationZ = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4664 _volIntern = new wxRadioButton(this,-1, _T("Volume intern " ));
4665 _volExtern = new wxRadioButton(this,-1, _T("Volume extern " ));
4667 _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
4669 _isoValue = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4670 _valueBeforeIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4671 _valueAfterIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4673 wxButton *btnExtract = new wxButton(this, -1,_T("Extract"));
4675 _infoToVo = new wxStaticText(this,-1,_T("########################"));
4676 _infoSuVoA = new wxStaticText(this,-1,_T("############"));
4677 _infoSuVo = new wxStaticText(this,-1,_T("############"));
4678 _infoPixLe = new wxStaticText(this,-1,_T("############"));
4679 _infoPixHi = new wxStaticText(this,-1,_T("############"));
4684 _typeFig->Append(_T("Cylindre"));
4685 _typeFig->Append(_T("Cube"));
4686 _typeFig->Append(_T("Sphere"));
4687 _typeFig->SetSelection(0);
4688 _volIntern->SetValue(true);
4690 Connect(_typeFig->GetId() , wxEVT_COMMAND_CHOICE_SELECTED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig );
4692 Connect(_opacityFig->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig );
4693 Connect(_rotationX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4694 Connect(_rotationY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4695 Connect(_rotationZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4696 Connect(_scaleX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4697 Connect(_scaleY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4698 Connect(_scaleZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4699 Connect(btnExtract->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract );
4702 // wxStaticText *text=new wxStaticText(this,-1, " ");
4704 sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type: "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL ,0);
4705 sizerH0 -> Add( _typeFig ,1,wxALL ,0);
4706 sizerH0 -> Add( _opacityFig ,1,wxALL|wxEXPAND ,0);
4708 sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale : ")) ,1,wxALL ,0);
4709 sizerH2 -> Add( _scaleX ,1,wxALL | wxEXPAND ,0 );
4710 sizerH2 -> Add( _scaleY ,1,wxALL | wxEXPAND ,0 );
4711 sizerH2 -> Add( _scaleZ ,1,wxALL | wxEXPAND ,0 );
4713 sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation : ")) ,1,wxALL ,0);
4714 sizerH3 -> Add( _rotationX ,1,wxALL | wxEXPAND ,0 );
4715 sizerH3 -> Add( _rotationY ,1,wxALL | wxEXPAND ,0 );
4716 sizerH3 -> Add( _rotationZ ,1,wxALL | wxEXPAND ,0 );
4719 sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern : ")) ,1,wxALL ,0);
4720 sizerH4 -> Add( _volIntern ,1,wxALL ,0);
4721 sizerH4 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4722 sizerH4 -> Add( _volExtern ,1,wxALL ,0);
4724 sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue ")) ,1,wxALL ,0);
4725 sizerH5 -> Add( _isoValue ,1,wxALL | wxEXPAND ,0 );
4726 sizerH5 -> Add( _valueBeforeIsoValue ,1,wxALL | wxEXPAND ,0 );
4727 sizerH5 -> Add( _valueAfterIsoValue ,1,wxALL | wxEXPAND ,0 );
4729 sizerH6 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4730 sizerH6 -> Add( btnExtract ,1,wxALL ,0);
4732 sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4733 sizerH7 -> Add( _infoToVo , 1 , wxALL ,0);
4734 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume: "), wxDefaultPosition, wxSize(200,12) ) , 1 , wxALL ,0);
4735 sizerH7 -> Add( _infoSuVo , 1 , wxALL ,0);
4736 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4737 sizerH7 -> Add( _infoSuVoA , 1 , wxALL ,0);
4738 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue: ") , wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4739 sizerH7 -> Add( _infoPixLe , 1 , wxALL ,0);
4740 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4741 sizerH7 -> Add( _infoPixHi , 1 , wxALL ,0);
4742 // sizerH7 -> SetMinSize(300, 120);
4745 topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND ,0);
4748 topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND ,0);
4751 topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND ,0);
4754 topsizer -> Add( sizerH4 ,1,wxALL ,0);
4758 topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
4761 topsizer -> Add( sizerH6 , 1 , wxALL ,0);
4764 topsizer -> Add( _histogrammeAccumulated ,1, wxALL ,0);
4766 // Volumic information
4767 topsizer -> Add( sizerH7 , 1 , wxALL|wxEXPAND ,0);
4771 // wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
4772 wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
4773 sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
4776 wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
4777 sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
4780 this->SetAutoLayout(true);
4781 this->SetSizer( sizerHor );
4784 // this->FitInside();
4787 //-------------------------------------------------------------------
4789 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
4794 bool volInt, volExt;
4796 unsigned short *pOrg;
4797 unsigned short *p_histogramme;
4800 long int contAfter = 0;
4801 long int contBefor = 0;
4803 double min=999999999;
4804 double max=-999999999;
4806 volExt=_volExtern->GetValue();
4807 volInt=_volIntern->GetValue();
4808 int isoValue = _isoValue->GetValue();
4809 int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue();
4810 int valueAfterIsoValue = _valueAfterIsoValue ->GetValue();
4813 p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4815 _imageData->GetDimensions(dim);
4816 _imageData->GetSpacing(spc);
4817 _actualCuttingModel->CalculeInversMatrix();
4819 for (xx=0;xx<dim[0]; xx++)
4821 for (yy=0;yy<dim[1]; yy++)
4823 for (zz=0;zz<dim[2];zz++)
4825 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
4826 if ( ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
4828 pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz);
4830 if ((*pOrg)<isoValue)
4833 if (valueBeforeIsoValue!=-1)
4835 *pOrg=valueBeforeIsoValue;
4839 if (valueAfterIsoValue!=-1)
4841 *pOrg=valueAfterIsoValue;
4845 p_histogramme[*pOrg]++;
4846 if (*pOrg<min) min=*pOrg;
4847 if (*pOrg>max) max=*pOrg;
4861 double volumeUnit = spc[0]*spc[1]*spc[2];
4862 long int totalSubVolume = contBefor + contAfter;
4863 double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
4864 double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
4865 infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
4866 infoSuVo.Printf(_T("%ld") , totalSubVolume);
4867 infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
4868 infoPixLe.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
4869 infoPixHi.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
4871 _infoToVo->SetLabel(infoToVo);
4872 _infoSuVo->SetLabel(infoSuVo);
4873 _infoSuVoA->SetLabel(infoSuVoA);
4874 _infoPixLe->SetLabel(infoPixLe);
4875 _infoPixHi->SetLabel(infoPixHi);
4878 if ( _histogrammeAccumulated->GetValue()==true )
4881 _histogrammeVector -> GetDimensions ( dimHist );
4883 int i,size=dimHist[0];
4884 for (i=1; i<=size; i++)
4886 p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
4890 _histogrammeVector->Update();
4891 _histogrammeVector->GetScalarRange(range);
4892 _xyplot->SetYRange( 0 , range[1] );
4893 _xyplot->SetXRange( min , max );
4895 _vtkclipping3Ddataviewer->RefreshSurface();
4896 _wxvtkbaseView->Refresh();
4898 // _wxvtkbaseView->RefreshView();
4899 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4900 _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4904 //-------------------------------------------------------------------
4905 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
4907 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4909 if (_typeFig->GetSelection()==0){
4910 _actualCuttingModel=_modelCylinder;
4911 _actualActor=_cylinderActor;
4913 if (_typeFig->GetSelection()==1){
4914 _actualCuttingModel=_modelCube;
4915 _actualActor=_cubeActor;
4917 if (_typeFig->GetSelection()==2){
4918 _actualCuttingModel=_modelSphere;
4919 _actualActor=_sphereActor;
4921 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4926 //-------------------------------------------------------------------
4927 void wxPanelCuttingImageData::RefreshOpacity()
4929 double op= _opacityFig->GetValue()/100.0;
4930 _actualActor->GetProperty()->SetOpacity( op );
4933 //-------------------------------------------------------------------
4934 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
4939 //-------------------------------------------------------------------
4940 void wxPanelCuttingImageData::RefreshView()
4942 SetParamsOfTransformation( );
4945 //-------------------------------------------------------------------
4946 void wxPanelCuttingImageData::Refresh()
4948 _wxvtk3Dbaseview->Refresh();
4951 //-------------------------------------------------------------------
4952 void wxPanelCuttingImageData::SetParamsOfTransformation( )
4955 vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
4956 vtkimagedata->GetSpacing(spc);
4957 int px = (int) (_vtkmprbasedata->GetX() );
4958 int py = (int) (_vtkmprbasedata->GetY() );
4959 int pz = (int) (_vtkmprbasedata->GetZ() );
4960 int sx = (int) (_scaleX->GetValue() * spc[0] );
4961 int sy = (int) (_scaleY->GetValue() * spc[1] );
4962 int sz = (int) (_scaleZ->GetValue() * spc[2] );
4963 _actualCuttingModel -> SetScale ( sx , sy , sz );
4964 _actualCuttingModel -> SetPosition ( px , py , pz );
4965 _actualCuttingModel -> SetRotation ( _rotationX->GetValue() , _rotationY->GetValue() , _rotationZ->GetValue() );
4966 _actualCuttingModel -> SetSpacing ( spc[0] , spc[1] , spc[2] );
4967 _actualCuttingModel -> CalculeMatrix();
4970 //-------------------------------------------------------------------
4972 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
4977 //-------------------------------------------------------------------
4978 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
4980 _vtkmprbasedata = vtkmprbasedata;
4981 _imageData = _vtkmprbasedata->GetImageData();
4984 //-------------------------------------------------------------------
4986 void wxPanelCuttingImageData::Configure()
4988 _actualCuttingModel=_modelCylinder;
4989 _actualActor=_cylinderActor;
4990 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4991 SetParamsOfTransformation();
4997 //-------------------------------------------------------------------
4998 //-------------------------------------------------------------------
4999 //-------------------------------------------------------------------
5002 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
5003 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
5006 //-------------------------------------------------------------------
5008 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
5009 : wxSplitterWindow( parent , -1)
5012 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
5013 this->SetMinimumPaneSize(50);
5015 //-------------------------------------------------------------------
5016 wxWidgetMesure2D::~wxWidgetMesure2D()
5019 //-------------------------------------------------------------------
5020 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
5022 wxPanel *panel = new wxPanel(parent,-1);
5024 _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
5025 _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
5026 _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
5027 _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
5029 _cb_mt_visible->SetValue(true);
5030 _cb_closeContour->SetValue(true);
5031 _cb_visibleText->SetValue(true);
5033 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
5035 sizer->Add(_cb_messuretool);
5036 sizer->Add(_cb_mt_visible);
5037 sizer->Add(_cb_closeContour);
5038 sizer->Add(_cb_visibleText);
5040 panel->SetAutoLayout(true);
5041 panel->SetSizer(sizer);
5042 panel->SetSize(400,30);
5045 // panel->FitInside();
5047 Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
5048 Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
5049 Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
5050 Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
5055 //-------------------------------------------------------------------
5056 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5058 _wxvtk2Dbaseview = wxvtk2Dbaseview;
5061 _manContourControl_1 = new manualContourControler();
5062 _mContourModel_1 = new manualContourModel();
5063 _mViewContour_1 = new manualViewContour();
5064 _mViewContour_1->SetModel( _mContourModel_1 );
5065 _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
5066 _mViewContour_1->SetRange( 1 );
5070 // _wxvtk2Dbaseview->GetSpacing( spc );
5071 // _mViewContour_1->SetSpacing( spc );
5075 _manContourControl_1->SetZ( 1000 );
5076 _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
5077 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 );
5078 _manContourControl_1->CreateNewManualContour();
5079 _manContourControl_1->SetActive( false );
5080 _mViewContour_1->RefreshContour();
5084 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
5085 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
5086 // CreateWin1a(this->GetWindow1() );
5088 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5089 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
5090 this->GetWindow1()->SetSizer(sizerA);
5091 this->SetAutoLayout(true);
5094 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
5095 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
5096 this->GetWindow2()->SetSizer(sizerB);
5097 this->SetAutoLayout(true);
5101 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
5105 // this->FitInside();
5109 //-------------------------------------------------------------------
5110 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
5112 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->SetActiveAllInteractors(!ok);
5113 _manContourControl_1->SetActive( ok );
5116 //-------------------------------------------------------------------
5117 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
5119 ActiveMessureTool( _cb_messuretool->GetValue() );
5120 if ( _cb_messuretool->GetValue() == true )
5122 _cb_mt_visible->SetValue(true);
5123 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
5124 _cb_closeContour->Enable(true);
5125 _cb_visibleText->Enable(true);
5127 _cb_closeContour->Enable(false);
5128 _cb_visibleText->Enable(false);
5130 _wxvtk2Dbaseview->Refresh();
5131 _wxvtk2Dbaseview->RefreshView();
5134 //-------------------------------------------------------------------
5135 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
5137 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
5138 if (_cb_messuretool->GetValue()==true)
5140 _cb_closeContour->Enable(true);
5141 _cb_visibleText->Enable(true);
5143 ActiveMessureTool( _cb_messuretool->GetValue() );
5144 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
5145 _mViewContour_1->Refresh();
5146 _wxvtk2Dbaseview->Refresh();
5147 _wxvtk2Dbaseview->RefreshView();
5150 //-------------------------------------------------------------------
5151 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
5153 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
5154 _mViewContour_1->Refresh();
5155 _wxvtk2Dbaseview->Refresh();
5156 _wxvtk2Dbaseview->RefreshView();
5159 //-------------------------------------------------------------------
5160 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
5162 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
5163 _mViewContour_1->Refresh();
5164 _wxvtk2Dbaseview->Refresh();
5165 _wxvtk2Dbaseview->RefreshView();
5167 //-------------------------------------------------------------------
5168 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
5170 _mViewContour_1->SetMesureScale(mesureScale);
5172 //-------------------------------------------------------------------
5173 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
5175 return _mContourModel_1;
5178 //-------------------------------------------------------------------
5179 //-------------------------------------------------------------------
5180 //-------------------------------------------------------------------
5182 wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
5183 : wxWidgetMesure2D(parent)
5187 _circle1Actor = NULL;
5188 _circle1Mapper = NULL;
5192 _circle2Actor = NULL;
5193 _circle2Mapper = NULL;
5196 _ptsLineRef1 = NULL;
5197 _lineRef1Actor = NULL;
5198 _lineRef1Mapper = NULL;
5201 _ptsLineRef2 = NULL;
5202 _lineRef2Actor = NULL;
5203 _lineRef2Mapper = NULL;
5208 //-------------------------------------------------------------------
5210 wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
5213 if ( _ptsCircle1 != NULL){ _ptsCircle1 -> Delete(); }
5214 if ( _circle1Actor != NULL){ _circle1Actor -> Delete(); }
5215 if ( _circle1Mapper != NULL){ _circle1Mapper -> Delete(); }
5216 if ( _pdCircle1 != NULL){ _pdCircle1 -> Delete(); }
5218 if ( _ptsCircle2 != NULL){ _ptsCircle2 -> Delete(); }
5219 if ( _circle2Actor != NULL){ _circle2Actor -> Delete(); }
5220 if ( _circle2Mapper != NULL){ _circle2Mapper -> Delete(); }
5221 if ( _pdCircle2 != NULL){ _pdCircle2 -> Delete(); }
5223 if ( _ptsLineRef1 != NULL){ _ptsLineRef1 -> Delete(); }
5224 if ( _lineRef1Actor != NULL){ _lineRef1Actor -> Delete(); }
5225 if ( _lineRef1Mapper != NULL){ _lineRef1Mapper -> Delete(); }
5226 if ( _pdLineRef1 != NULL){ _pdLineRef1 -> Delete(); }
5228 if ( _ptsLineRef2 != NULL){ _ptsLineRef2 -> Delete(); }
5229 if ( _lineRef2Actor != NULL){ _lineRef2Actor -> Delete(); }
5230 if ( _lineRef2Mapper != NULL){ _lineRef2Mapper -> Delete(); }
5231 if ( _pdLineRef2 != NULL){ _pdLineRef2 -> Delete(); }
5234 //-------------------------------------------------------------------
5236 wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
5238 wxPanel *panel = new wxPanel(parent,-1);
5240 _cb_circle = new wxCheckBox(panel,-1,_T("Circle "));
5241 _cb_line = new wxCheckBox(panel,-1,_T("Rotation Axe "));
5244 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5245 sizerA->Add(_cb_circle);
5246 sizerA->Add(_cb_line);
5249 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5250 sizer->Add( sizerA );
5251 sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
5253 panel->SetAutoLayout(true);
5254 panel->SetSizer(sizer);
5255 panel->SetSize(400,30);
5258 // panel->FitInside();
5260 Connect(_cb_line->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine );
5261 Connect(_cb_circle->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle );
5267 //-------------------------------------------------------------------
5268 void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
5270 SetVisibleCircle( _cb_circle->GetValue() );
5271 _wxvtk2Dbaseview->RefreshView();
5274 //-------------------------------------------------------------------
5275 void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
5284 _lineRef1Actor->GetProperty()->SetOpacity( opacity );
5285 _lineRef2Actor->GetProperty()->SetOpacity( opacity );
5286 _circle1Actor->GetProperty()->SetOpacity( opacity );
5287 _circle2Actor->GetProperty()->SetOpacity( opacity );
5289 //-------------------------------------------------------------------
5290 void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
5292 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5293 vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
5294 _wxvtk2Dbaseview->RefreshView();
5298 //-------------------------------------------------------------------
5299 void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5301 wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
5303 ConfigureCircleLine();
5304 SetVisibleCircle(false);
5308 //-------------------------------------------------------------------
5309 void wxWidgetMesure2D_Plane::ConfigureCircleLine()
5313 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5314 int sizeIma = vtkplane2Dview->GetImgSize();
5317 double k=(360/(maxPts-1)) * (3.1416/180);
5318 double x,y,r1=5,r2=10,r3=15;
5319 for (i=0;i<maxPts;i++)
5323 _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1 , (sizeIma/2) + y*r1 , 1 );
5324 _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2 , (sizeIma/2) + y*r2 , 1 );
5328 ang=(45) * (3.1416/180);
5331 _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5333 ang=(45+180) * (3.1416/180);
5336 _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5339 ang=(135) * (3.1416/180);
5342 _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5344 ang=(135+180) * (3.1416/180);
5347 _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5352 //-------------------------------------------------------------------
5353 void wxWidgetMesure2D_Plane::CircleLine()
5356 vtkCellArray *lines;
5358 vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
5361 // Circle 1 Horizontal
5362 _ptsCircle1 = vtkPoints::New();
5363 _ptsCircle1->SetNumberOfPoints(maxPts);
5364 lines = vtkCellArray::New();
5365 lines->InsertNextCell(maxPts);
5366 for (i=0;i<maxPts;i++)
5368 lines->InsertCellPoint(i);
5369 _ptsCircle1->SetPoint(i, 0 , 0 , 0 );
5371 lines->InsertCellPoint(0);
5372 _ptsCircle1->SetPoint(0, -1000 , -1000 , -1000 );
5373 _ptsCircle1->SetPoint(1, 1000 , 1000 , 1000 );
5375 _pdCircle1 = vtkPolyData::New();
5376 _pdCircle1->SetPoints( _ptsCircle1 );
5377 _pdCircle1->SetLines( lines );
5378 lines->Delete(); //do not delete lines ??
5379 _circle1Actor = vtkActor::New();
5380 _circle1Mapper = vtkPolyDataMapper::New();
5381 _circle1Mapper->SetInput(_pdCircle1);
5382 _circle1Mapper->ImmediateModeRenderingOn();
5383 _circle1Actor->SetMapper(_circle1Mapper);
5384 _circle1Actor->GetProperty()->BackfaceCullingOn();
5385 _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5386 _circle1Actor->GetProperty()->SetLineWidth(2);
5387 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
5389 // Circle 2 Horizontal
5390 _ptsCircle2 = vtkPoints::New();
5391 _ptsCircle2->SetNumberOfPoints(maxPts);
5392 lines = vtkCellArray::New();
5393 lines->InsertNextCell(maxPts);
5394 for (i=0;i<maxPts;i++)
5396 lines->InsertCellPoint(i);
5397 _ptsCircle2->SetPoint(i, 0 , 0 , 0 );
5399 _ptsCircle2->SetPoint(0, -1000 , -1000 , -1000 );
5400 _ptsCircle2->SetPoint(1, 1000 , 1000 , 1000 );
5402 _pdCircle2 = vtkPolyData::New();
5403 _pdCircle2->SetPoints( _ptsCircle2 );
5404 _pdCircle2->SetLines( lines );
5405 lines->Delete(); //do not delete lines ??
5406 _circle2Actor = vtkActor::New();
5407 _circle2Mapper = vtkPolyDataMapper::New();
5408 _circle2Mapper->SetInput(_pdCircle2);
5409 _circle2Mapper->ImmediateModeRenderingOn();
5410 _circle2Actor->SetMapper(_circle2Mapper);
5411 _circle2Actor->GetProperty()->BackfaceCullingOn();
5412 _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5413 _circle2Actor->GetProperty()->SetLineWidth(2);
5414 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
5417 _ptsLineRef1 = vtkPoints::New();
5418 _ptsLineRef1->SetNumberOfPoints(2);
5419 _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
5420 _ptsLineRef1->SetPoint(1, 1000 , 1000 , 1000 );
5421 lines = vtkCellArray::New();
5422 lines->InsertNextCell(2);
5423 lines->InsertCellPoint(0);
5424 lines->InsertCellPoint(1);
5426 _pdLineRef1 = vtkPolyData::New();
5427 _pdLineRef1->SetPoints( _ptsLineRef1 );
5428 _pdLineRef1->SetLines( lines );
5429 lines->Delete(); //do not delete lines ??
5430 _lineRef1Actor = vtkActor::New();
5431 _lineRef1Mapper = vtkPolyDataMapper::New();
5432 _lineRef1Mapper->SetInput(_pdLineRef1);
5433 _lineRef1Mapper->ImmediateModeRenderingOn();
5434 _lineRef1Actor->SetMapper(_lineRef1Mapper);
5435 _lineRef1Actor->GetProperty()->BackfaceCullingOn();
5436 _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5437 _lineRef1Actor->GetProperty()->SetLineWidth(2);
5438 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
5441 _ptsLineRef2 = vtkPoints::New();
5442 _ptsLineRef2->SetNumberOfPoints(2);
5443 _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
5444 _ptsLineRef2->SetPoint(1, 1000 , 1000 , 1000 );
5445 lines = vtkCellArray::New();
5446 lines->InsertNextCell(2);
5447 lines->InsertCellPoint(0);
5448 lines->InsertCellPoint(1);
5450 _pdLineRef2 = vtkPolyData::New();
5451 _pdLineRef2->SetPoints( _ptsLineRef2 );
5452 _pdLineRef2->SetLines( lines );
5453 lines->Delete(); //do not delete lines ??
5454 _lineRef2Actor = vtkActor::New();
5455 _lineRef2Mapper = vtkPolyDataMapper::New();
5456 _lineRef2Mapper->SetInput(_pdLineRef2);
5457 _lineRef2Mapper->ImmediateModeRenderingOn();
5458 _lineRef2Actor->SetMapper(_lineRef2Mapper);
5459 _lineRef2Actor->GetProperty()->BackfaceCullingOn();
5460 _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5461 _lineRef2Actor->GetProperty()->SetLineWidth(2);
5462 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
5468 //-------------------------------------------------------------------
5469 //-------------------------------------------------------------------
5470 //-------------------------------------------------------------------
5472 wxWidgetMesure2D_Plane_in_MPR::wxWidgetMesure2D_Plane_in_MPR(wxWindow *parent)
5473 :wxWidgetMesure2D_Plane(parent)
5475 _vtkplane2Dview=NULL;
5478 //-------------------------------------------------------------------
5480 wxWidgetMesure2D_Plane_in_MPR::~wxWidgetMesure2D_Plane_in_MPR()
5483 //-------------------------------------------------------------------
5484 void wxWidgetMesure2D_Plane_in_MPR::OnActiveLink(wxCommandEvent& event)
5486 if (_vtkplane2Dview!=NULL)
5488 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5489 _vtkplane2Dview->Refresh();
5490 _vtkplane2Dview->RefreshView();
5495 //-------------------------------------------------------------------
5496 void wxWidgetMesure2D_Plane_in_MPR::SetActiveLink(bool ok)
5498 _cb_link->SetValue(ok);
5499 if (_vtkplane2Dview!=NULL)
5501 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5504 //-------------------------------------------------------------------
5506 void wxWidgetMesure2D_Plane_in_MPR::SetVtkPlane2DView(vtkPlane2DView *vtkplane2Dview)
5508 _vtkplane2Dview = vtkplane2Dview;
5511 //-------------------------------------------------------------------
5513 wxWindow *wxWidgetMesure2D_Plane_in_MPR::CreateWin1a(wxWindow *parent) // virtual
5515 wxPanel *panel = new wxPanel(parent,-1);
5517 _cb_link = new wxCheckBox(panel,-1,_T("LINK "));
5518 _cb_link->SetValue(true);
5520 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5522 sizer->Add(_cb_link);
5524 sizer->Add( wxWidgetMesure2D_Plane::CreateWin1a(panel) );
5526 panel->SetAutoLayout(true);
5527 panel->SetSizer(sizer);
5528 panel->SetSize(400,30);
5532 // panel->FitInside();
5534 Connect(_cb_link->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxWidgetMesure2D_Plane_in_MPR::OnActiveLink );
5542 //-------------------------------------------------------------------
5543 //-------------------------------------------------------------------
5544 //-------------------------------------------------------------------
5546 BEGIN_EVENT_TABLE( wxMPRWidget, wxPanel )
5547 EVT_MENU( 12121, wxMPRWidget::OnRefreshView )
5548 EVT_MENU( 12122, wxMPRWidget::OnDClickLeft )
5553 wxMPRWidget::wxMPRWidget( wxWindow* parent,
5554 marImageData *marimageData , double voxelSize)
5555 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
5558 _vtkmpr2Dview[0] = NULL;
5559 _vtkmpr2Dview[1] = NULL;
5560 _vtkmpr2Dview[2] = NULL;
5561 _vtkplane2Dview = NULL;
5562 _widgetMesure = NULL;
5563 _wxsphereview = NULL;
5564 _wxvtk3Dbaseview_MPRClipping3D = NULL;
5565 _wxvtkmpr3Dview = NULL;
5566 _wxvtkclipping3Dview = NULL;
5567 _vtkplane2Dview_B = NULL;
5568 _widgetMesure_B = NULL;
5570 _vtkmpr2Dview_B[0] = NULL;
5571 _vtkmpr2Dview_B[1] = NULL;
5572 _vtkmpr2Dview_B[2] = NULL;
5573 _vtkplane2Dview_B = NULL;
5574 _widgetMesure_B = NULL;
5575 _wxsphereview_B = NULL;
5576 _wxvtk3Dbaseview_MPR3D_B = NULL;
5577 _wxvtkmpr3Dview_B = NULL;
5578 _wxvtk3Dbaseview_Clipping3D_BB = NULL;
5579 _wxvtkmpr3Dview_BB = NULL;
5580 _wxvtkclipping3Dview_BB = NULL;
5582 _vtkmprbasedata = NULL;
5586 _framePanelCutting = NULL;
5587 _panelCutting = NULL;
5590 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
5593 if(marimageData!=NULL){
5594 _marImageData = marimageData;
5595 _voxelSize = voxelSize;
5596 _vtkmprbasedata = new vtkMPRBaseData();
5597 _vtkmprbasedata->SetMarImageData(_marImageData);
5602 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5603 pnlSplitter -> SetMinimumPaneSize( 2 );
5605 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5606 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5607 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5609 sizer -> Add( pnlSplitter ,1,wxGROW ,0);
5614 //wxWindow *pp=this;
5615 //while (pp->GetParent()!=NULL) pp=pp->GetParent();
5616 //pp->GetSize(&ww,&hh);
5618 this -> SetAutoLayout( true );
5619 this -> SetSizer(sizer);
5620 // sizer -> Fit( this );
5625 void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize){
5627 if(_marImageData!=NULL){
5628 _marImageData->removeImageData(0);
5629 _marImageData->AddImageData(img);
5631 _marImageData = new marImageData(img);
5634 _voxelSize = voxelsize;
5636 if(_vtkmprbasedata==NULL){
5637 _vtkmprbasedata = new vtkMPRBaseData();
5638 _vtkmprbasedata->SetMarImageData(_marImageData);
5640 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5641 pnlSplitter -> SetMinimumPaneSize( 2 );
5643 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5644 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5645 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5647 this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0);
5653 //----------------------------------------------------------------------------
5655 wxMPRWidget::~wxMPRWidget( )
5658 if (_framePanelCutting!=NULL)
5660 _framePanelCutting->Close();
5663 if (_vtkmpr2Dview[0]!=NULL) { delete _vtkmpr2Dview[0]; }
5664 if (_vtkmpr2Dview[1]!=NULL) { delete _vtkmpr2Dview[1]; }
5665 if (_vtkmpr2Dview[2]!=NULL) { delete _vtkmpr2Dview[2]; }
5667 if (_vtkmpr2Dview_B[0]!=NULL) { delete _vtkmpr2Dview_B[0]; }
5669 if (_vtkmpr2Dview_B[1]!=NULL) { delete _vtkmpr2Dview_B[1]; }
5670 if (_vtkmpr2Dview_B[2]!=NULL) { delete _vtkmpr2Dview_B[2]; }
5672 if (_vtkmprbasedata!=NULL) { delete _vtkmprbasedata; }
5673 if (_vtkplane2Dview!=NULL) { delete _vtkplane2Dview; }
5674 if (_wxsphereview!=NULL) { delete _wxsphereview; }
5675 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL) { delete _wxvtk3Dbaseview_MPRClipping3D; }
5676 if (_wxvtkmpr3Dview!=NULL) { delete _wxvtkmpr3Dview; }
5677 if (_wxvtkclipping3Dview!=NULL) { delete _wxvtkclipping3Dview; }
5679 if (_vtkplane2Dview_B!=NULL) { delete _vtkplane2Dview_B; }
5680 if (_wxsphereview_B!=NULL) { delete _wxsphereview_B; }
5682 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) { delete _wxvtk3Dbaseview_MPR3D_B; }
5683 if (_wxvtkmpr3Dview_B!=NULL) { delete _wxvtkmpr3Dview_B; }
5685 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL) { delete _wxvtk3Dbaseview_Clipping3D_BB; }
5686 if (_wxvtkmpr3Dview_BB!=NULL) { delete _wxvtkmpr3Dview_BB; }
5687 if (_wxvtkclipping3Dview_BB!=NULL) { delete _wxvtkclipping3Dview_BB; }
5690 //----------------------------------------------------------------------------
5692 wxPanel* wxMPRWidget::CreateControlPanel(wxWindow *parent)
5695 wxPanel *panel=new wxPanel(parent,-1);
5698 // wxStaticText *tmpText = new wxStaticText(panel,-1,"");
5700 wxStaticText *help0Text = new wxStaticText(panel,-1,_T("General: \n middle click : contrast\n ctrl + middle click : rotate image\n shift + middle click: translate image\n ctrl + right click: zoom"));
5702 wxStaticText *help1Text = new wxStaticText(panel,-1,_T("mpr2D: \n double click : choose a point\n mouse right : change perpendicular slice\n drag axis: change slice"));
5704 wxStaticText *help2Text = new wxStaticText(panel,-1,_T("Plane: \n drag mouse: rotate\n ctrl + drag mouse : fix axis rotation\n \n mouse right: change perpendicular slice \n see split control \n - Active/Desactivet plane tool\n - Center market\n - Rotation axis market\n - 2D messure tool (open/close contour)"));
5706 wxStaticText *help3Text = new wxStaticText(panel,-1,
5707 _T("Sphere: \n drag mouse: rotation\n mouse right: change radio \n click: 3D point selection in MPR 2D \n double clicks in MPR: show surface sphere"));
5709 wxStaticText *help4Text = new wxStaticText(panel,-1,_T("MPR3D:\n see split control"));
5711 wxString text=_T("");
5712 text=text+_T("Clipping: \n");
5713 text=text+_T(" see split control \n");
5714 text=text+_T(" 4 MarchingCubes: \n");
5715 text=text+_T(" color, isovalue, opacity \n");
5716 text=text+_T(" Box:\n");
5717 text=text+_T(" mouse left drag (box): rotation\n");
5718 text=text+_T(" mouse left drag (sphere): size,position\n");
5719 text=text+_T(" mouse right drag (box): box size");
5720 text=text+_T(" Axis: 3D\n");
5721 text=text+_T(" mouse drag: translate\n");
5722 text=text+_T(" shift + mouse drag: translate 2 axis\n");
5723 text=text+_T(" mouse right: scale\n");
5724 text=text+_T(" Plane 3D:\n");
5725 text=text+_T(" mouse drag perpendicular axis: rotate plane\n");
5726 text=text+_T(" mouse drag spheres: size plane\n");
5727 text=text+_T(" ctrl +mouse right over the plane: size plane\n");
5728 text=text+_T(" mouse drag plane: translate\n");
5729 text=text+_T(" middle click perpendicular axis: translate\n");
5730 wxStaticText *help5Text = new wxStaticText(panel,-1, text );
5733 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5734 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5735 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5736 sizer->Add( help0Text );
5738 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5739 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5740 sizer->Add( help1Text );
5742 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5743 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5744 sizer->Add( help2Text );
5746 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5747 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5748 sizer->Add( help3Text );
5750 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5751 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5752 sizer->Add( help4Text );
5754 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5755 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5756 sizer->Add( help5Text );
5758 panel->SetSizer(sizer);
5759 panel->SetAutoLayout(true);
5760 panel->SetSize(350,500);
5765 //----------------------------------------------------------------------------
5767 void wxMPRWidget::OnPageAChanged(wxNotebookEvent & event)
5769 _refreshAPage=event.GetSelection();
5774 //----------------------------------------------------------------------------
5776 void wxMPRWidget::OnPageBChanged(wxNotebookEvent & event)
5778 _refreshBPage=event.GetSelection();
5784 //----------------------------------------------------------------------------
5786 wxPanel* wxMPRWidget::CreateView(int type,wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5789 wxPanel *panel=new wxPanel(parent,-1);
5793 _vtkmpr2Dview_B[0] = new wxVtkMPR2DView(panel,0);
5794 _vtkmpr2Dview_B[0]->SetVtkBaseData(vtkmprbasedata);
5795 wxwindow=_vtkmpr2Dview_B[0]->GetWxVTKRenderWindowInteractor();
5799 _vtkmpr2Dview_B[1] = new wxVtkMPR2DView(panel,1);
5800 _vtkmpr2Dview_B[1]->SetVtkBaseData(vtkmprbasedata);
5801 wxwindow=_vtkmpr2Dview_B[1]->GetWxVTKRenderWindowInteractor();
5805 _vtkmpr2Dview_B[2] = new wxVtkMPR2DView(panel,2);
5806 _vtkmpr2Dview_B[2]->SetVtkBaseData(vtkmprbasedata);
5807 wxwindow=_vtkmpr2Dview_B[2]->GetWxVTKRenderWindowInteractor();
5811 _widgetMesure_B = new wxWidgetMesure2D_Plane_in_MPR(panel);
5812 _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
5813 _widgetMesure_B->SetVtkPlane2DView( _vtkplane2Dview_B );
5814 _vtkplane2Dview_B->SetImgSize( 200 );
5815 _vtkplane2Dview_B->SetVtkBaseData(vtkmprbasedata);
5816 wxwindow = _widgetMesure_B;
5820 _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
5821 wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor();
5826 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( panel , -1);
5827 _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D );
5829 _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
5830 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5831 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5832 vtkmpr3Ddataviewer->Configure();
5833 _wxvtkmpr3Dview_B->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5835 wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
5836 wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D);
5839 panelMPR3D -> SetMinimumPaneSize( 5 );
5840 panelMPR3D -> SplitHorizontally( controlPanel3D,window3D,600 );
5842 wxwindow=panelMPR3D;
5847 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
5848 _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D );
5850 _wxvtkclipping3Dview_BB = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_BB);
5851 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5852 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5853 vtkclipping3Ddataviewer->Configure();
5854 _wxvtkclipping3Dview_BB->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5856 _wxvtkmpr3Dview_BB = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_BB );
5857 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5858 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5859 vtkmpr3Ddataviewer->Configure();
5860 _wxvtkmpr3Dview_BB->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5862 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
5864 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
5865 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl);
5866 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateControlPanel(panelControl);
5867 _btnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
5868 Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
5870 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5871 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5872 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5873 sizerCtrol->Add( _btnCutImageData , 1, wxALL, 2);
5875 panelControl->SetAutoLayout(true);
5876 panelControl->SetSizer(sizerCtrol);
5877 panelControl->SetSize(400,350);
5878 panelControl->Layout();
5880 // panelControl->FitInside();
5883 panelClipping3D -> SetMinimumPaneSize( 5 );
5884 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
5885 wxwindow=panelClipping3D;
5888 wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
5889 sizerH1->Add(wxwindow , 1, wxALL|wxGROW, 0);
5890 panel->SetAutoLayout(true);
5891 panel->SetSizer(sizerH1);
5892 panel->SetSize(400,400);
5898 //----------------------------------------------------------------------------
5900 wxPanel* wxMPRWidget::CreateMPRPanel(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5902 wxPanel *panel=new wxPanel(parent,-1);
5904 wxNotebook *notebook = new wxNotebook( panel, -1 );
5906 notebook->AddPage( CreateMPRPanel4View( notebook ,vtkmprbasedata), _T("4-View") );
5907 notebook->AddPage( CreateView(0,notebook,vtkmprbasedata) , _T("Axial") );
5908 notebook->AddPage( CreateView(1,notebook,vtkmprbasedata) , _T("Sagital") );
5909 notebook->AddPage( CreateView(2,notebook,vtkmprbasedata) , _T("Coronal") );
5910 notebook->AddPage( CreateView(3,notebook,vtkmprbasedata) , _T("Plane") );
5911 notebook->AddPage( CreateView(4,notebook,vtkmprbasedata) , _T("Sphere") );
5912 notebook->AddPage( CreateView(5,notebook,vtkmprbasedata) , _T("MPR 3D") );
5913 notebook->AddPage( CreateView(6,notebook,vtkmprbasedata) , _T("Clipping") );
5914 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageAChanged );
5916 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
5917 sizer->Add(notebook , 1, wxALL|wxGROW, 2);
5918 panel->SetAutoLayout(true);
5919 panel->SetSizer(sizer);
5920 panel->SetSize(400,400);
5924 // panel->FitInside();
5930 //----------------------------------------------------------------------------
5932 wxPanel* wxMPRWidget::CreateMPRPanel4View(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5934 wxPanel *panel=new wxPanel(parent,-1);
5937 _vtkmpr2Dview[0] = new wxVtkMPR2DView(panel,0);
5938 _vtkmpr2Dview[0]->SetVtkBaseData(vtkmprbasedata);
5939 wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
5942 _vtkmpr2Dview[1] = new wxVtkMPR2DView(panel,1);
5943 _vtkmpr2Dview[1]->SetVtkBaseData(vtkmprbasedata);
5944 wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
5947 _vtkmpr2Dview[2] = new wxVtkMPR2DView(panel,2);
5948 _vtkmpr2Dview[2]->SetVtkBaseData(vtkmprbasedata);
5949 wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
5952 wxNotebook *notebook = new wxNotebook( panel, -1 );
5953 notebook->SetSize(400,400);
5957 _widgetMesure = new wxWidgetMesure2D_Plane_in_MPR(notebook);
5958 _vtkplane2Dview = new vtkPlane2DView( _widgetMesure->GetWindow2() );
5959 _widgetMesure->SetVtkPlane2DView( _vtkplane2Dview );
5960 _vtkplane2Dview->SetImgSize( 200 );
5961 _vtkplane2Dview->SetVtkBaseData(vtkmprbasedata);
5962 notebook->AddPage( _widgetMesure, _T("Plane") );
5965 _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
5966 wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
5967 notebook->AddPage( iren3B, _T("Sphere") );
5971 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( notebook , -1);
5972 _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D );
5974 _wxvtkmpr3Dview = new wxVtkMPR3DView( _wxvtk3Dbaseview_MPRClipping3D );
5975 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5976 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5977 vtkmpr3Ddataviewer->Configure();
5978 _wxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5981 _wxvtkclipping3Dview = new wxVtkClipping3DView( _wxvtk3Dbaseview_MPRClipping3D );
5982 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5983 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5984 vtkclipping3Ddataviewer->Configure();
5985 _wxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5988 wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
5990 wxPanel *panelControl = new wxPanel(panelMPR3D,-1);
5991 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl);
5992 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateControlPanel(panelControl);
5997 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
5998 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5999 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
6000 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
6003 panelControl->SetAutoLayout(true);
6004 panelControl->SetSizer(sizerCtrol);
6005 panelControl->SetSize(400,150);
6006 panelControl->Layout();
6009 panelMPR3D -> SetMinimumPaneSize( 5 );
6011 panelMPR3D -> SplitHorizontally( panelControl,window3D,200 );
6013 notebook->AddPage( panelMPR3D, _T("MPR 3D - Clipping") );
6016 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageBChanged );
6018 wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
6019 wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
6020 wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
6021 sizerH1->Add(iren2 , 1, wxALL|wxEXPAND, 2);
6022 sizerH1->Add(iren0 , 1, wxALL|wxEXPAND, 2);
6023 sizerH2->Add(iren1 , 1, wxALL|wxEXPAND, 2);
6024 // sizerH2->Add(iren3 , 1, wxALL|wxEXPAND, 2);
6025 sizerH2->Add(notebook , 1, wxALL|wxEXPAND, 2);
6027 sizerV->Add(sizerH1, 1, wxALL|wxEXPAND, 0);
6028 sizerV->Add(sizerH2, 1, wxALL|wxEXPAND, 0);
6030 panel->SetAutoLayout(true);
6031 panel->SetSizer(sizerV);
6032 panel->SetSize(400,400);
6037 //----------------------------------------------------------------------------
6038 void wxMPRWidget::OnCutImagaData(wxCommandEvent &event)
6040 if (_btnCutImageData->GetValue()==true){
6042 _framePanelCutting = new wxFrame(this,-1,_T("Cutting Module"),wxDefaultPosition,wxDefaultSize,wxCAPTION|wxSTAY_ON_TOP| wxRESIZE_BORDER );
6044 _framePanelCutting->SetSize(550,400);
6046 _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
6047 if(_wxvtk3Dbaseview_Clipping3D_BB!=NULL){
6048 _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
6050 _panelCutting->SetVtkMPRBaseData( GetVtkMPRBaseData() );
6051 _panelCutting->SetVtkClipping3DDataViewer( this->_wxvtkclipping3Dview_BB->GetVtkClipping3DDataViewer() );
6052 _panelCutting->Configure( );
6054 wxBoxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL );
6055 topsizer -> Add( _panelCutting ,1,wxALL ,0);
6056 _framePanelCutting->SetAutoLayout(true);
6057 _framePanelCutting->SetSizer( topsizer ); // use the sizer for layout
6058 _framePanelCutting->Layout();
6060 // _framePanelCutting->FitInside();
6062 _framePanelCutting->Show();
6066 if (_framePanelCutting!=NULL){
6067 _panelCutting->RemoveActors();
6068 _framePanelCutting->Destroy();
6069 _framePanelCutting=NULL;
6075 //----------------------------------------------------------------------------
6076 void wxMPRWidget::ConfigureVTK(){
6079 if (_vtkmprbasedata!=NULL)
6081 _vtkmprbasedata->Configure();
6082 x=_vtkmprbasedata -> GetMaxPositionX()/2;
6083 y=_vtkmprbasedata -> GetMaxPositionY()/2;
6084 z=_vtkmprbasedata -> GetMaxPositionZ()/2;
6085 _vtkmprbasedata->SetX( x );
6086 _vtkmprbasedata->SetY( y );
6087 _vtkmprbasedata->SetZ( z );
6091 if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
6092 if(_vtkmpr2Dview[1]!=NULL) {_vtkmpr2Dview[1] -> Configure();}
6093 if(_vtkmpr2Dview[2]!=NULL) {_vtkmpr2Dview[2] -> Configure();}
6096 if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0] -> Configure(); }
6097 if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1] -> Configure(); }
6098 if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
6103 if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
6104 if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
6105 if (_widgetMesure!=NULL){_widgetMesure -> SetActiveLink(true);}
6106 if (_widgetMesure!=NULL){_widgetMesure -> SetMesureScale( _voxelSize );}
6107 if (_wxsphereview!=NULL){_wxsphereview -> Configure();}
6109 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D -> Configure();}
6110 if (_wxvtkmpr3Dview!=NULL){
6111 _wxvtkmpr3Dview -> Configure();
6113 if (_wxvtkclipping3Dview!=NULL){_wxvtkclipping3Dview -> Configure();}
6115 if (_vtkplane2Dview_B!=NULL){ _vtkplane2Dview_B -> Configure(); }
6116 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> ConfigureA( _vtkplane2Dview_B ); }
6117 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> SetActiveLink(true); }
6121 // vtkImageData *imageData = _vtkmprbasedata->GetImageData();
6122 // imageData->Update();
6123 // imageData->GetSpacing(spc);
6124 // _widgetMesure_B->SetMesureScale(spc[0]);
6126 if (_widgetMesure_B!=NULL) {_widgetMesure_B->SetMesureScale( _voxelSize );}
6129 if (_wxsphereview_B!=NULL) {_wxsphereview_B -> Configure();}
6131 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) {_wxvtk3Dbaseview_MPR3D_B -> Configure();}
6132 if (_wxvtkmpr3Dview_B!=NULL) {_wxvtkmpr3Dview_B -> Configure();}
6134 if ( _wxvtk3Dbaseview_Clipping3D_BB!=NULL) {_wxvtk3Dbaseview_Clipping3D_BB -> Configure(); }
6135 if ( _wxvtkmpr3Dview_BB!=NULL) {_wxvtkmpr3Dview_BB -> Configure(); }
6136 if ( _wxvtkclipping3Dview_BB!=NULL) {_wxvtkclipping3Dview_BB -> Configure(); }
6139 vtkInteractorStyle3DView *vtkinteractorstyle3Dview;
6140 if (_wxvtkmpr3Dview_BB!=NULL)
6142 vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
6143 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_BB);
6144 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_BB);
6147 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL)
6149 _wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
6153 // RefreshView(true);
6157 //----------------------------------------------------------------------------
6159 void wxMPRWidget::OnRefreshView(wxCommandEvent & event)
6163 //----------------------------------------------------------------------------
6164 void wxMPRWidget::OnDClickLeft(wxCommandEvent & event)
6166 if (_wxsphereview!=NULL) {
6167 _wxsphereview -> RefreshPoint();
6169 if (_wxsphereview_B!=NULL) {
6170 _wxsphereview_B -> RefreshPoint();
6173 //----------------------------------------------------------------------------
6174 void wxMPRWidget::RefreshView(bool firsttime){
6176 if (_refreshAPage == 0 )
6179 if ((_vtkmpr2Dview[0]!=NULL) && (_vtkmpr2Dview[1]!=NULL) && (_vtkmpr2Dview[2]!=NULL) )
6181 _vtkmpr2Dview[2] -> Refresh();
6182 _vtkmpr2Dview[1] -> Refresh();
6183 _vtkmpr2Dview[0] -> Refresh();
6185 if (firsttime==false)
6187 _vtkmpr2Dview[2] -> RefreshView();
6188 _vtkmpr2Dview[1] -> RefreshView();
6189 _vtkmpr2Dview[0] -> RefreshView();
6192 if (_refreshBPage == 0 )
6194 if (_vtkplane2Dview!=NULL)
6196 _vtkplane2Dview -> Refresh();
6197 if (firsttime==false)
6199 _vtkplane2Dview -> RefreshView();
6201 // _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6204 if (_refreshBPage == 1 )
6208 if (_refreshBPage == 2 )
6210 if ((_wxvtkmpr3Dview!=NULL) && (_wxvtk3Dbaseview_MPRClipping3D!=NULL) && (_wxvtkclipping3Dview!=NULL) )
6212 _wxvtkmpr3Dview -> RefreshView();
6213 _wxvtk3Dbaseview_MPRClipping3D -> Refresh();
6214 _wxvtkclipping3Dview -> Refresh();
6220 if (_refreshAPage == 1 )
6222 if (_vtkmpr2Dview_B[0] !=NULL){
6223 _vtkmpr2Dview_B[0] -> Refresh();
6226 if (_refreshAPage == 2 )
6228 if (_vtkmpr2Dview_B[1] !=NULL){
6229 _vtkmpr2Dview_B[1] -> Refresh();
6232 if (_refreshAPage == 3 )
6234 if (_vtkmpr2Dview_B[2] !=NULL){
6235 _vtkmpr2Dview_B[2] -> Refresh();
6238 if (_refreshAPage == 4 )
6240 if (_vtkplane2Dview_B!=NULL){
6241 _vtkplane2Dview_B -> Refresh();
6242 if (firsttime==false)
6244 _vtkplane2Dview_B -> RefreshView();
6249 if (_refreshAPage == 5 )
6253 if (_refreshAPage == 6 )
6255 if (_wxvtkmpr3Dview_B!=NULL){
6256 _wxvtkmpr3Dview_B -> Refresh();
6257 _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6260 if (_refreshAPage == 7 )
6262 if (_wxvtkmpr3Dview_BB!=NULL){
6263 _wxvtkmpr3Dview_BB -> RefreshView();
6264 _wxvtkclipping3Dview_BB -> Refresh();
6265 _wxvtk3Dbaseview_Clipping3D_BB -> Refresh();
6266 if (_panelCutting!=NULL)
6268 _panelCutting->RefreshView();
6274 //----------------------------------------------------------------------------
6275 vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
6276 return _vtkmprbasedata;
6278 //----------------------------------------------------------------------------
6279 vtkPlane2DView *wxMPRWidget::GetVtkPlane2DView()
6281 return _vtkplane2Dview;
6283 //----------------------------------------------------------------------------
6284 wxVtkMPR3DView *wxMPRWidget::GetWxvtkmpr3Dview_BB()
6286 return _wxvtkmpr3Dview_BB;
6288 //----------------------------------------------------------------------------
6289 wxVtkBaseView *wxMPRWidget::GetWxVtkBaseView(int page, int id)
6291 wxVtkBaseView *result=NULL;
6294 if ((id>=0) &&(id<=3)){
6295 result=_vtkmpr2Dview[id];
6299 result=_vtkplane2Dview;
6304 //----------------------------------------------------------------------------
6305 wxVtkMPR2DView *wxMPRWidget::GetWxvtkMPR2Dview(int direction)
6307 return _vtkmpr2Dview[direction];
6310 //----------------------------------------------------------------------------
6311 //----------------------------------------------------------------------------
6312 //----------------------------------------------------------------------------
6313 wxMPRWidget2::wxMPRWidget2(wxWindow* parent,marImageData *marimagedata,double voxelSize)
6314 : wxMPRWidget(parent,marimagedata,voxelSize)
6317 //----------------------------------------------------------------------------
6318 wxMPRWidget2::~wxMPRWidget2()
6321 //----------------------------------------------------------------------------
6322 void wxMPRWidget2::OnRefreshView(wxCommandEvent & event) // Virtual
6324 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
6325 this->GetParent()->ProcessEvent(newevent1);
6329 //----------------------------------------------------------------------------
6330 //----------------------------------------------------------------------------
6331 //----------------------------------------------------------------------------
6332 figureCuttingModel::figureCuttingModel()
6334 _inversModel = vtkTransform::New();
6335 _matrixModel = vtkTransform::New();
6336 _matrixVisual = vtkTransform::New();
6342 //----------------------------------------------------------------------------
6343 figureCuttingModel::~figureCuttingModel() // virtual
6345 _inversModel->Delete();
6347 //----------------------------------------------------------------------------
6348 void figureCuttingModel::SetPosition(double x,double y, double z)
6354 //----------------------------------------------------------------------------
6355 void figureCuttingModel::SetScale(double sx,double sy, double sz)
6361 //----------------------------------------------------------------------------
6362 void figureCuttingModel::SetRotation(double alfa,double beta, double teta)
6369 //----------------------------------------------------------------------------
6370 void figureCuttingModel::CalculeMatrix()
6372 _matrixModel->Identity();
6373 _matrixModel->Translate(_px,_py,_pz);
6374 _matrixModel->RotateY(_beta);
6375 _matrixModel->RotateX(_alfa);
6376 _matrixModel->RotateY(_teta);
6377 _matrixModel->Scale(_sx,_sy,_sz);
6379 _matrixVisual->Identity();
6380 _matrixVisual->Translate( _px*_spcX , _py*_spcY , _pz*_spcZ );
6381 _matrixVisual->RotateY(_beta);
6382 _matrixVisual->RotateX(_alfa);
6383 _matrixVisual->RotateY(_teta);
6384 _matrixVisual->Scale( _sx*_spcX , _sy*_spcY , _sz*_spcZ );
6389 //----------------------------------------------------------------------------
6390 void figureCuttingModel::CalculeInversMatrix()
6392 _inversModel->Identity ();
6393 _inversModel->Concatenate ( _matrixModel );
6394 _inversModel->Inverse();
6396 //----------------------------------------------------------------------------
6397 bool figureCuttingModel::IfPointInside(double x, double y, double z) // virtual
6402 //----------------------------------------------------------------------------
6403 vtkTransform *figureCuttingModel::GetVtkTransform()
6405 return _matrixVisual;
6408 //----------------------------------------------------------------------------
6409 //void figureCuttingModel::SetVtkTransform(vtkTransform *matrix)
6411 // _matrixModel = matrix;
6414 //----------------------------------------------------------------------------
6415 double figureCuttingModel::GetTheoricVolume() // virtual
6420 //----------------------------------------------------------------------------
6421 double figureCuttingModel::GetPositionX()
6425 //----------------------------------------------------------------------------
6426 double figureCuttingModel::GetPositionY()
6430 //----------------------------------------------------------------------------
6431 double figureCuttingModel::GetPositionZ()
6435 //----------------------------------------------------------------------------
6436 double figureCuttingModel::GetScaleX()
6440 //----------------------------------------------------------------------------
6441 double figureCuttingModel::GetScaleY()
6445 //----------------------------------------------------------------------------
6446 double figureCuttingModel::GetScaleZ()
6450 //----------------------------------------------------------------------------
6451 double figureCuttingModel::GetAngleAlfa()
6455 //----------------------------------------------------------------------------
6456 double figureCuttingModel::GetAngleBeta()
6460 //----------------------------------------------------------------------------
6461 double figureCuttingModel::GetAngleTeta()
6465 //----------------------------------------------------------------------------
6466 char *figureCuttingModel::GetName() // virtual
6471 //----------------------------------------------------------------------------
6472 void figureCuttingModel::SetSpacing(double spcX,double spcY, double spcZ)
6479 //----------------------------------------------------------------------------
6482 //----------------------------------------------------------------------------
6483 //----------------------------------------------------------------------------
6484 //----------------------------------------------------------------------------
6485 figureCuttingSphereModel::figureCuttingSphereModel()
6488 //----------------------------------------------------------------------------
6489 figureCuttingSphereModel::~figureCuttingSphereModel() // virtual
6492 //----------------------------------------------------------------------------
6493 bool figureCuttingSphereModel::IfPointInside(double x, double y, double z) // virtual
6495 double in[4],out[4];
6500 _inversModel->MultiplyPoint (in, out);
6503 if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
6509 //----------------------------------------------------------------------------
6510 double figureCuttingSphereModel::GetTheoricVolume() // virtual
6512 double piTMP=3.14159265;
6513 return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
6515 //----------------------------------------------------------------------------
6516 char *figureCuttingSphereModel::GetName() // virtual
6522 //----------------------------------------------------------------------------
6523 //----------------------------------------------------------------------------
6524 //----------------------------------------------------------------------------
6525 figureCuttingCubeModel::figureCuttingCubeModel()
6528 //----------------------------------------------------------------------------
6529 figureCuttingCubeModel::~figureCuttingCubeModel() // virtual
6532 //----------------------------------------------------------------------------
6533 bool figureCuttingCubeModel::IfPointInside(double x, double y, double z) // virtual
6535 double in[4],out[4];
6540 _inversModel->MultiplyPoint (in, out);
6543 if ((out[0]>-0.5) && (out[0]<0.5) && (out[1]>-0.5) && (out[1]<0.5) && (out[2]>-0.5) && (out[2]<0.5) )
6549 //----------------------------------------------------------------------------
6550 double figureCuttingCubeModel::GetTheoricVolume() // virtual
6552 return _sx * _sy * _sz;
6555 //----------------------------------------------------------------------------
6556 char *figureCuttingCubeModel::GetName() // virtual
6561 //----------------------------------------------------------------------------
6562 //----------------------------------------------------------------------------
6563 //----------------------------------------------------------------------------
6565 figureCuttingCylinderModel::figureCuttingCylinderModel()
6568 //----------------------------------------------------------------------------
6569 figureCuttingCylinderModel::~figureCuttingCylinderModel() // virtual
6572 //----------------------------------------------------------------------------
6573 bool figureCuttingCylinderModel::IfPointInside(double x, double y, double z) // virtual
6575 double in[4],out[4];
6580 _inversModel->MultiplyPoint (in, out);
6583 if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 ) && (out[1]>-0.5) && (out[1]<0.5) )
6589 //----------------------------------------------------------------------------
6590 double figureCuttingCylinderModel::GetTheoricVolume() // virtual
6592 double piTMP=3.14159265;
6593 return piTMP*(_sx/2)*(_sz/2)*_sy;
6595 //----------------------------------------------------------------------------
6596 char *figureCuttingCylinderModel::GetName() // virtual
6600 //----------------------------------------------------------------------------
6604 // EOF - wxMPRWidget.cxx