1 /*=========================================================================
4 Module: $RCSfile: wxMPRWidget.cxx,v $
6 Date: $Date: 2009/05/07 15:35:46 $
7 Version: $Revision: 1.13 $
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 printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfun %p\n", this, ctfun);
2691 printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorPoint %p\n", this, ctfunVectorPoint);
2692 printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorRed %p\n", this, ctfunVectorRed);
2693 printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorGreen %p\n", this, ctfunVectorGreen);
2694 printf("EED %p wxVtkMPR3DViewCntrlPanel::OnEditColorTable ctfunVectorBlue %p\n", this, ctfunVectorBlue);
2697 //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
2702 vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2704 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2);
2707 hDlg->erasePointsTransferenceFunction();
2708 int ctfSize=ctfunVectorRed->size();
2711 // MACHETE OJO Eduardo
2715 double gr = (*ctfunVectorPoint)[i];
2716 double r = (*ctfunVectorRed)[i];
2717 double g = (*ctfunVectorGreen)[i];
2718 double b = (*ctfunVectorBlue)[i];
2720 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
2726 // when the user had changed the transference Function
2729 //setting variables if the user wants to do refresh
2731 hDlg->setCTF(ctfun);
2732 hDlg->setMPR3Dview(_wxvtkmpr3Dview);
2734 if(hDlg->ShowModal()== wxID_OK )
2737 // -- vtkColorTransferFunction --
2738 ctfun->RemoveAllPoints ();
2740 ctfunVectorPoint->clear();
2741 ctfunVectorRed->clear();
2742 ctfunVectorGreen->clear();
2743 ctfunVectorBlue->clear();
2745 int nCTFpoints=hDlg->getSizeBarColor();
2746 // Machete .. Ojo Eduardo
2750 hDlg->getDataBarColorPoint(i,xi,r,g,b);
2754 hDlg->getDataBarColorPoint(1,xi,r,g,b);
2758 hDlg->getDataBarColorPoint(i-1,xi,r,g,b);
2761 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
2762 ctfunVectorPoint->push_back(xi);
2763 ctfunVectorRed->push_back(r/255.0);
2764 ctfunVectorGreen->push_back(g/255.0);
2765 ctfunVectorBlue->push_back(b/255.0);
2775 if(hDlg->getRefreshed())
2777 // -- vtkColorTransferFunction --
2778 ctfun->RemoveAllPoints ();
2781 int size=ctfunVectorPoint->size();
2785 double grey2=(*ctfunVectorPoint)[i];
2786 double red =(*ctfunVectorRed)[i];
2787 double green =(*ctfunVectorGreen)[i];
2788 double blue = (*ctfunVectorBlue)[i];
2789 ctfun->AddRGBPoint(grey2,red,green,blue);
2799 //-------------------------------------------------------------------
2800 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
2802 _wxvtkmpr3Dview->VisibleImageActor(0, event.IsChecked() );
2803 _wxvtkmpr3Dview->Refresh();
2805 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2808 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2810 std::cout<<e<<std::endl;
2814 //-------------------------------------------------------------------
2815 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
2817 _wxvtkmpr3Dview->VisibleImageActor(1, event.IsChecked() );
2818 _wxvtkmpr3Dview->Refresh();
2820 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2821 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2824 //-------------------------------------------------------------------
2825 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
2827 _wxvtkmpr3Dview->VisibleImageActor(2, event.IsChecked() );
2828 _wxvtkmpr3Dview->Refresh();
2830 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2831 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2834 //-------------------------------------------------------------------
2835 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event)
2837 _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked());
2840 //-------------------------------------------------------------------
2841 void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event)
2843 _wxvtkmpr3Dview->VisiblePlaneWidget(event.IsChecked());
2847 //-------------------------------------------------------------------
2848 void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event)
2850 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() );
2851 _wxvtkmpr3Dview->RefreshView();
2852 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2853 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2855 //-------------------------------------------------------------------
2856 void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event)
2858 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() );
2859 _wxvtkmpr3Dview->RefreshView();
2860 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2861 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2863 //-------------------------------------------------------------------
2864 void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event)
2866 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() );
2867 _wxvtkmpr3Dview->RefreshView();
2868 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2869 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2873 //-------------------------------------------------------------------
2874 //-------------------------------------------------------------------
2875 //-------------------------------------------------------------------
2877 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
2878 : wxPanel(parent, -1)
2880 wxPanel *panel = this;
2881 _wxvtkclipping3Dview = wxvtkclipping3Dview;
2884 // wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
2885 // wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
2887 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2888 _surfB = new wxRadioButton(panel,-1,_T("B"));
2889 _surfC = new wxRadioButton(panel,-1,_T("C"));
2890 _surfD = new wxRadioButton(panel,-1,_T("D"));
2892 wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
2893 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
2894 wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
2896 _color = new wxButton(panel,-1,_T(""));
2897 _visible = new wxCheckBox(panel,-1,_T("Vis"));
2898 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
2900 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
2901 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
2904 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2905 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
2909 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2910 vtkimagedata->GetScalarRange( range );
2911 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
2912 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
2915 _isoValue->SetTickFreq(25,0);
2917 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
2918 _isoValueSpin->SetRange(1,8);
2919 _isoValueSpin->SetValue(5);
2920 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
2922 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
2923 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
2925 wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
2928 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
2929 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
2930 Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
2933 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
2934 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
2938 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2939 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2940 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2941 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
2942 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2943 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
2944 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2945 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
2946 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2949 // ckVolum->Enable(false);
2950 ckBoxSurface->SetValue(false);
2951 ckBoxVolume->SetValue(false);
2952 _color->SetSize(40,20);
2953 _opacity->SetSize(370,20);
2954 // ckBoxX->SetValue(true);
2955 // ckBoxY->SetValue(true);
2956 // ckBoxZ->SetValue(true);
2957 _surfA->SetValue(true);
2958 _wireFrameRep->SetValue(false);
2959 _surfaceRep->SetValue(true);
2960 _visible->SetValue(false);
2961 // _positionX->SetSize(400,20);
2962 // _positionY->SetSize(400,20);
2963 // _positionZ->SetSize(400,20);
2965 Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
2966 Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
2968 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2969 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2970 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2971 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2972 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
2974 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2975 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2977 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
2978 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
2979 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
2982 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2983 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2986 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2987 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2988 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2989 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2990 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2991 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2994 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2995 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
2996 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
2997 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
2998 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
2999 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
3000 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
3001 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
3003 sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
3004 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3005 sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
3006 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3007 sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
3008 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3009 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
3012 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
3013 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3014 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
3015 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3016 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
3017 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3018 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
3019 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3020 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
3021 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3022 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
3023 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3024 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
3027 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
3028 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
3029 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3030 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
3031 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3034 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
3035 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3036 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
3037 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
3039 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
3042 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
3043 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
3044 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
3047 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
3048 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
3049 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
3051 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
3052 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
3053 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
3055 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
3056 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
3057 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
3059 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
3060 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
3061 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
3062 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
3063 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
3064 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
3065 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
3067 panel->SetSize(300,60);
3068 panel->SetAutoLayout(true);
3069 panel->SetSizer(sizer);
3072 panel->SetEventHandler((wxEvtHandler*)this);
3075 //-------------------------------------------------------------------
3076 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
3079 //-------------------------------------------------------------------
3080 void wxVtkClipping3DViewCntrlPanel::Refresh()
3082 // wxPanel::Refresh();
3084 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
3085 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
3086 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
3089 //-------------------------------------------------------------------
3090 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
3093 if (_surfA->GetValue()==true)
3097 if (_surfB->GetValue()==true)
3101 if (_surfC->GetValue()==true)
3105 if (_surfD->GetValue()==true)
3113 //-------------------------------------------------------------------
3114 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
3116 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
3117 _wxvtkclipping3Dview->Refresh();
3119 //-------------------------------------------------------------------
3120 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
3122 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
3123 _wxvtkclipping3Dview->Refresh();
3125 //-------------------------------------------------------------------
3126 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
3128 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
3129 _wxvtkclipping3Dview->Refresh();
3133 //-------------------------------------------------------------------
3134 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
3136 int idTissue=GetIdTissue();
3141 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3143 tmpActor->GetProperty()->GetColor( rgb );
3144 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
3145 _color->SetBackgroundColour(colour);
3148 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
3151 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
3153 // Representation Type WireFrame / Surface
3154 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3155 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3158 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
3159 _isoValue->SetValue(isoValue);
3164 //-------------------------------------------------------------------
3165 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
3167 int idTissue=GetIdTissue();
3170 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
3172 _wxvtkclipping3Dview->Refresh();
3174 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3175 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3180 //-------------------------------------------------------------------
3181 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
3183 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
3184 _wxvtkclipping3Dview->Refresh();
3186 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3187 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3189 //-------------------------------------------------------------------
3190 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
3192 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
3193 _wxvtkclipping3Dview->Refresh();
3195 //-------------------------------------------------------------------
3196 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
3198 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
3199 _wxvtkclipping3Dview->Refresh();
3201 //-------------------------------------------------------------------
3202 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
3204 int idTissue=GetIdTissue();
3207 // EED 17 Janvier 2007
3208 wxColourDialog dlgColour(this);
3209 // dlgColour.ShowModal();
3210 if( dlgColour.ShowModal( ) == wxID_OK )
3213 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3214 float r=dlgColour.GetColourData().GetColour().Red()/255;
3215 float g=dlgColour.GetColourData().GetColour().Green()/255;
3216 float b=dlgColour.GetColourData().GetColour().Blue()/255;
3217 tmpActor->GetProperty()->SetColor( r , g , b );
3218 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
3220 _wxvtkclipping3Dview->Refresh();
3222 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3223 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3227 //-------------------------------------------------------------------
3228 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
3230 int idTissue=GetIdTissue();
3233 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
3235 _wxvtkclipping3Dview->Refresh();
3237 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3238 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3241 //-------------------------------------------------------------------
3242 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
3244 int idTissue=GetIdTissue();
3248 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3249 float opacity=_opacity->GetValue();
3250 tmpActor->GetProperty()->SetOpacity( opacity/100 );
3252 _wxvtkclipping3Dview->Refresh();
3254 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3255 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3259 //----------------------------------------------------------------------------
3260 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
3262 int value = _isoValue->GetValue();
3263 int delta= (int)pow( 4 , _isoValueSpin->GetValue() );
3264 int min=value - delta/2;
3265 int max=value + delta/2;
3271 _isoValue->SetRange(min,max);
3275 //------------------------------------------------------------------------
3276 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
3280 int idTissue=GetIdTissue();
3283 int isoValue=_isoValue->GetValue();
3284 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
3286 // tmpStr.Printf("%d",isoValue);
3288 _wxvtkclipping3Dview->Refresh();
3290 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3291 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3295 //-------------------------------------------------------------------
3296 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
3299 int idTissue=GetIdTissue();
3306 wxString dirSTL = wxGetHomeDir( ) ;
3307 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
3309 if( dialog.ShowModal( ) == wxID_OK )
3313 // ------------------------------------------------------------------------
3314 // 1. GENERATE STL FILES
3315 // ------------------------------------------------------------------------
3316 // const char* fileprefix = "c:\\Creatis\\";
3317 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
3318 std::string filename;
3320 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
3322 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
3325 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
3326 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
3327 pdcf->SetInput( filtro->GetOutput() );
3328 vtkClosePolyData *cpd = vtkClosePolyData::New();
3329 cpd->SetInput( pdcf->GetOutput() );
3331 // 1.2 se escribe a disco el archivo stl de la superficie interna
3333 vtkSTLWriter *writer = vtkSTLWriter::New();
3334 writer->SetInput( cpd->GetOutput() );
3336 writer->SetFileName(filename.c_str());
3337 writer->SetFileTypeToASCII();
3349 //EED 30 Janvier 2007
3350 //-------------------------------------------------------------------
3351 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
3353 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
3354 if (dialog.ShowModal() == wxID_OK)
3356 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
3357 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
3358 float rescalaSlope = 1;
3359 float rescalaIntercept = 0;
3360 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
3361 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
3363 vtkimagedata->GetDimensions(dim);
3371 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
3372 marRAW2Files marraw2;
3373 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
3377 //EED 22 Fevrier 2007
3378 //-------------------------------------------------------------------
3379 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
3382 int /*i=0,*/ xi,yi,r,g,b; // JPRx
3383 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
3384 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
3385 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
3386 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
3387 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
3388 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
3389 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
3390 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
3391 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3395 //use for update in the refresh
3397 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
3398 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
3403 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
3404 if (dialog.ShowModal() == wxID_OK)
3406 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
3412 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
3416 int tfSize=gtf->size();
3420 hDlg->erasePointsTransferenceFunction();
3424 double in=(*itf)[i];
3425 hDlg->addPointToTransferenceFunction(g,in*100);
3431 int ctfSize=rctf->size();
3437 double gr=(*greyctf)[i];
3438 double r=(*rctf)[i];
3439 double g=(*gctf)[i];
3440 double b=(*bctf)[i];
3441 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
3445 //setting variables if the user wants to do refresh
3446 hDlg->setCTF(ctfun);
3448 hDlg->setClipping3DView(_wxvtkclipping3Dview);
3450 hDlg->setVolume(newvol);
3451 hDlg->setVolumeMapper(volumeMapper);
3454 // when the user had changed the transference Function
3456 if(hDlg->ShowModal()== wxID_OK )
3458 // -- vtkPiecewiseFunction --
3459 tfun->RemoveAllPoints();
3463 int nTFPoints=hDlg->getSizeTransferenceFunction();
3467 hDlg->getTransferenceFunctionPoint(i,xi,yi);
3468 tfun->AddPoint( xi , yi/100.0 );
3470 itf->push_back(yi/100.0);
3473 // -- vtkColorTransferFunction --
3474 ctfun->RemoveAllPoints ();
3481 int nCTFpoints=hDlg->getSizeBarColor();
3485 hDlg->getDataBarColorPoint(i,xi,r,g,b);
3486 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
3487 rctf->push_back(r/255.0);
3488 gctf->push_back(g/255.0);
3489 bctf->push_back(b/255.0);
3490 greyctf->push_back(xi);
3493 //---------------------------------
3494 // Refreshing and sending the event
3495 //---------------------------------
3496 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3497 _wxvtkclipping3Dview->Refresh();
3498 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3499 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3502 volumeMapper->Update();
3510 if(hDlg->getRefreshed())
3513 //--Transference Function----
3514 tfun->RemoveAllPoints();
3519 double grey1=(*gtf)[i];
3520 double in2=(*itf)[i];
3521 tfun->AddPoint( grey1 , in2 );
3524 // -- vtkColorTransferFunction --
3525 ctfun->RemoveAllPoints ();
3528 size=greyctf->size();
3531 double grey2=(*greyctf)[i];
3532 double red =(*rctf)[i];
3533 double green =(*gctf)[i];
3534 double blue = (*bctf)[i];
3535 ctfun->AddRGBPoint(grey2,red,green,blue);
3538 //---------------------------------
3539 // Refreshing and sending the event
3540 //---------------------------------
3541 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3542 _wxvtkclipping3Dview->Refresh();
3543 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3544 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3547 volumeMapper->Update();
3553 //destroy the dialog
3558 //-------------------------------------------------------------------
3559 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
3561 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
3562 if (dialog.ShowModal() == wxID_OK)
3564 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
3565 _wxvtkclipping3Dview->Refresh();
3566 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3567 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3572 //-------------------------------------------------------------------
3573 //-------------------------------------------------------------------
3574 //-------------------------------------------------------------------
3577 wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
3579 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3580 _vtkmpr3Ddataviewer = NULL;
3581 _wxvtkmpr3DviewCntrlPanel = NULL;
3587 _contourMapper=NULL;
3589 void wxVtkMPR3DView::RemoveActor(vtkActor* actor){
3591 _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
3595 void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
3598 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
3599 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3601 /*double x = (spc[0])*(origin[0]+(((double)ext[1]-(double)ext[0])/2.0));
3602 double y = (spc[1])*(origin[1]+(double)ext[3]);
3603 double z = (spc[2])*(origin[2]+(((double)ext[5]-(double)ext[4])/2.0));*/
3604 /*double x0=(spc[0])*((double)ext[0]+origin[0]);
3605 double x1=(spc[0])*((double)ext[1]+origin[0]);
3606 double y0=(spc[1])*((double)ext[2]+origin[1]);
3607 double y1=(spc[1])*((double)ext[3]+origin[1]);
3608 double z0=(spc[2])*((double)ext[4]+origin[2]);
3609 double z1=(spc[2])*((double)ext[5]+origin[2]);*/
3610 double x0=(spc[0])*((double)ext[0]);
3611 double x1=(spc[0])*((double)ext[1]);
3612 double y0=(spc[1])*((double)ext[2]);
3613 double y1=(spc[1])*((double)ext[3]);
3614 double z0=(spc[2])*((double)ext[4]);
3615 double z1=(spc[2])*((double)ext[5]);
3617 _wxvtk3Dbaseview->GetRenderer()->ResetCamera(x0,x1,y0,y1,z0,z1);
3618 //_wxvtk3Dbaseview->GetCamera()->SetPosition(x,y,z);
3619 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3622 void wxVtkMPR3DView::Configure(){
3624 _wxvtk3Dbaseview->Configure();
3625 _wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
3627 //EED ?????? 07Mai2009
3628 // _wxvtk3Dbaseview->GetRenderer()->Clear();
3631 // Actors are added to the renderer.
3632 vtkActor* _outlineActor = _vtkmpr3Ddataviewer->GetOutlineActor();
3633 _wxvtk3Dbaseview->GetRenderer()->AddActor( _outlineActor );
3634 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
3635 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
3636 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
3639 // An initial camera view is created. The Dolly() method moves
3640 // the camera towards the FocalPoint, thereby enlarging the image.
3641 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
3642 this->ResetCamera();
3645 // Set a background color for the renderer and set the size of the
3646 // render window (expressed in pixels).
3647 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
3648 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
3650 // Note that when camera movement occurs (as it does in the Dolly()
3651 // method), the clipping planes often need adjusting. Clipping planes
3652 // consist of two planes: near and far along the view direction. The
3653 // near plane clips out objects in front of the plane; the far plane
3654 // clips out objects behind the plane. This way only what is drawn
3655 // between the planes is actually rendered.
3656 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
3660 if(_myCallback!=NULL){
3661 _myCallback->Delete();
3664 _myCallback = vtkmyPWCallback_3DPointWidget::New();
3665 _myCallback->SetWxVtkMPR3DView(this);
3667 if(_pointWidget!=NULL){
3668 _pointWidget->Delete();
3670 _pointWidget = vtkPointWidget::New();
3671 _myCallback->SetVtkPointWidget(_pointWidget);
3672 _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3673 _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3675 _pointWidget->AllOff();
3677 _pointWidget->PlaceWidget();
3678 // _pointWidget->SetPosition( x,y,z );
3681 // MACOS probleme vtk-window out of wx-window
3682 // _pointWidget->On();
3684 _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3688 if(_planeWidget!=NULL){
3689 _planeWidget->Delete();
3691 _planeWidget = vtkPlaneWidget::New();
3692 _myCallback->SetVtkPlaneWidget(_planeWidget);
3693 _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3694 _planeWidget->NormalToXAxisOn();
3695 _planeWidget->SetResolution(50);
3696 _planeWidget->SetRepresentationToOutline();
3698 GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
3703 _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
3706 if(_vtkplane==NULL){
3707 _vtkplane = vtkPolyData::New();
3709 _probe = vtkProbeFilter::New();
3710 _probe->SetInput(_vtkplane);
3712 _contourMapper = vtkPolyDataMapper::New();
3714 _contourMapper->SetInput( _probe->GetPolyDataOutput() );
3716 _contourPlaneActor = vtkActor::New();
3717 _contourPlaneActor->SetMapper(_contourMapper);
3719 _contourPlaneActor->VisibilityOff();
3721 _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3722 _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3724 _planeWidget->Off();
3725 _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
3730 _planeWidget->GetPolyData(_vtkplane);
3733 vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3734 _probe->SetSource( imageData );
3737 _contourMapper->SetScalarRange( imageData->GetScalarRange() );
3743 //-------------------------------------------------------------------
3744 wxVtkMPR3DView::~wxVtkMPR3DView()
3748 //-------------------------------------------------------------------
3749 void wxVtkMPR3DView::Refresh() // virtual
3751 _vtkmpr3Ddataviewer -> Refresh();
3752 if (_wxvtkmpr3DviewCntrlPanel!=NULL)
3754 _wxvtkmpr3DviewCntrlPanel->Refresh();
3758 //-------------------------------------------------------------------
3759 void wxVtkMPR3DView::RefreshView() // virtual
3762 this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
3764 //double nx=1,ny=0,nz=0; // JPRx
3766 double x=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetX();
3767 double y=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetY();
3768 double z=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetZ();
3774 _pointWidget->SetPosition( x,y,z );
3779 vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
3780 in[0]=1; in[1]=0; in[2]=0;
3781 transform->TransformPoint(in,normal);
3782 _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
3785 _planeWidget->SetCenter( x,y,z );
3786 _planeWidget->UpdatePlacement();
3787 _planeWidget->GetPolyData(_vtkplane);
3789 //-------------------------------------------------------------------
3790 wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent)
3792 _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this);
3793 return _wxvtkmpr3DviewCntrlPanel;
3795 //-------------------------------------------------------------------
3796 vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
3798 return _vtkmpr3Ddataviewer;
3800 //-------------------------------------------------------------------
3801 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() throw (char*)
3803 if(_wxvtk3Dbaseview==NULL){
3804 throw "wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
3806 return _wxvtk3Dbaseview;
3808 //-------------------------------------------------------------------
3810 //-------------------------------------------------------------------
3811 void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
3812 if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
3813 if (visible==false){
3814 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3816 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3818 _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
3823 //-------------------------------------------------------------------
3824 void wxVtkMPR3DView::VisiblePointWidget( bool visible )
3830 _pointWidget->Off();
3834 //-------------------------------------------------------------------
3835 void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
3840 _contourPlaneActor->VisibilityOn();
3843 _planeWidget->Off();
3844 _contourPlaneActor->VisibilityOff();
3848 //-------------------------------------------------------------------
3849 void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer)
3851 _vtkmpr3Ddataviewer = vtkmpr3Ddataviewer;
3854 //-------------------------------------------------------------------
3855 void wxVtkMPR3DView::InitOrientationPointWidget()
3857 this->_planeWidget->SetNormal(1,0,0);
3863 //-------------------------------------------------------------------
3864 // EED 25 Janvier 2007 testLoic
3865 void wxVtkMPR3DView::TestLoic1()
3869 double dimIma = sizeIma*2;
3871 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3874 vtkimagedata->GetSpacing(spc);
3876 vtkimagedata->Update();
3880 this->_planeWidget->GetOrigin(p);
3881 this->_planeWidget->GetNormal(n);
3885 vtkPlaneSource* pSource = vtkPlaneSource::New( );
3886 pSource->SetResolution( sizeIma - 1, sizeIma - 1 );
3887 pSource->SetOrigin( p[ 0 ], p[ 1 ], p[ 2 ] );
3888 pSource->SetPoint1( p[ 0 ] + dimIma - 1.0, p[ 1 ], p[ 2 ] );
3889 pSource->SetPoint2( p[ 0 ], p[ 1 ]+ dimIma - 1.0 , p[ 2 ] );
3891 pSource->SetCenter( p[ 0 ], p[ 1 ], p[ 2 ] );
3892 pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
3895 vtkProbeFilter* slices = vtkProbeFilter::New();
3896 slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
3897 slices->SetSource( vtkimagedata );
3901 vtkStructuredPoints *stPoints = vtkStructuredPoints::New();
3902 stPoints -> GetPointData( )->SetScalars( slices->GetOutput()->GetPointData()->GetScalars() );
3903 stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
3904 stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
3905 stPoints -> SetScalarTypeToShort();
3906 stPoints -> Update();
3908 vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
3909 change -> SetInput( stPoints );
3910 change -> Update(); //important
3913 vtkimagedata->GetScalarRange(_range);
3914 vtkWindowLevelLookupTable *_bwlookup = vtkWindowLevelLookupTable::New( );
3915 _bwlookup->SetHueRange( 0 , 1 );
3916 _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
3917 _bwlookup->SetTableRange( _range[0] , _range[1] );
3918 _bwlookup->SetSaturationRange( 0 , 0 );
3919 _bwlookup->SetValueRange( 0 , 1 );
3920 _bwlookup->SetAlphaRange( 1 , 1 );
3921 _bwlookup->Build( );
3923 vtkLookupTable * _collookup = vtkLookupTable::New( );
3924 _collookup->SetNumberOfColors( 256 );
3925 _collookup->SetTableRange( 0 , 255 );
3926 _collookup->Build( );
3927 _collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
3928 _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
3929 _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
3932 vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
3933 writer->SetInput( stPoints );
3934 writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
3935 writer->SetFileDimensionality( 2 );
3940 vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
3941 _3DSliceMapper->SetInput(change->GetOutput( ) );
3942 _3DSliceMapper->SetLookupTable( _bwlookup );
3943 _3DSliceMapper->SetScalarRange( _range );
3944 _3DSliceMapper->ImmediateModeRenderingOn( );
3946 vtkActor *_3DSliceActor = vtkActor::New( );
3947 _3DSliceActor->SetMapper( _3DSliceMapper );
3949 // The usual rendering stuff.
3950 vtkCamera *camera = vtkCamera::New();
3951 camera->SetPosition(1,1,1);
3952 camera->SetFocalPoint(0,0,0);
3954 vtkRenderer *renderer = vtkRenderer::New();
3955 vtkRenderWindow *renWin = vtkRenderWindow::New();
3956 renWin->AddRenderer(renderer);
3958 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3959 iren->SetRenderWindow(renWin);
3961 renderer->AddActor( _3DSliceActor );
3962 renderer->SetActiveCamera(camera);
3963 renderer->ResetCamera();
3964 renderer->SetBackground(1,1,1);
3966 renWin->SetSize(300,300);
3968 // interact with data
3978 //-------------------------------------------------------------------
3979 // EED 25 Janvier 2007 testLoic
3980 void wxVtkMPR3DView::TestLoic2()
3983 vtkVectorNorm *vecMagnitude = vtkVectorNorm::New();
3984 vecMagnitude->SetInput(VtkMainGrid);
3985 vecMagnitude->NormalizeOff();
3986 vecMagnitude->Update();
3989 vtkPlane *slicePlane = vtkPlane::New();
3990 this->_planeWidget->GetPlane( slicePlane );
3993 vtkCutter* sliceCutter = vtkCutter::New();
3994 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3995 sliceCutter->SetInput( vtkimagedata );
3996 sliceCutter->SetCutFunction( slicePlane );
3999 // vtkLookupTable *lut = BuildHueWeightBaseMap();
4002 vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
4003 slice->SetInput( sliceCutter->GetOutput() );
4007 vtkimagedata->GetScalarRange(range);
4008 // vecMagnitude->GetOutput()->GetScalarRange( range );
4009 // range[1] *= 0.7; // reduce the upper range by 30%
4010 // slice->SetScalarRange( range );
4011 // slice->SetLookupTable( lut );
4013 // vtkActor *sliceActor = vtkActor::New();
4014 // sliceActor->SetMapper( slice );
4016 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
4017 contourMapper->SetInput( sliceCutter->GetOutput() );
4018 contourMapper->SetScalarRange( range );
4019 // contourMapper->SetLookupTable( lut );
4022 vtkActor *contourActor = vtkActor::New();
4023 contourActor->SetMapper( contourMapper );
4027 // The usual rendering stuff.
4028 vtkCamera *camera = vtkCamera::New();
4029 camera->SetPosition(1,1,1);
4030 camera->SetFocalPoint(0,0,0);
4032 vtkRenderer *renderer = vtkRenderer::New();
4033 vtkRenderWindow *renWin = vtkRenderWindow::New();
4034 renWin->AddRenderer(renderer);
4036 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
4037 iren->SetRenderWindow(renWin);
4039 renderer->AddActor( contourActor );
4040 // renderer->AddActor(cubeActor);
4041 renderer->SetActiveCamera(camera);
4042 renderer->ResetCamera();
4043 renderer->SetBackground(1,1,1);
4045 renWin->SetSize(300,300);
4047 // interact with data
4054 //-------------------------------------------------------------------
4055 //-------------------------------------------------------------------
4056 //-------------------------------------------------------------------
4058 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
4060 _wxvtk3Dbaseview = wxvtk3Dbaseview;
4061 _vtkclipping3Ddataviewer = NULL;
4062 _wxvtkclipping3DviewCntrlPanel = NULL;
4064 _boxWidgetVolume = NULL;
4065 _boxWidgetS1 = NULL;
4068 //-------------------------------------------------------------------
4069 wxVtkClipping3DView::~wxVtkClipping3DView(){
4070 if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
4071 if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
4072 if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
4073 if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
4075 //-------------------------------------------------------------------
4076 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
4081 _boxWidgetS1->Off();
4084 //-------------------------------------------------------------------
4085 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
4087 if (_boxWidgetVolume!=NULL){
4089 _boxWidgetVolume->On();
4091 _boxWidgetVolume->Off();
4095 //-------------------------------------------------------------------
4096 void wxVtkClipping3DView::Refresh()
4098 _vtkclipping3Ddataviewer->Refresh();
4099 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
4101 _wxvtkclipping3DviewCntrlPanel->Refresh();
4104 //-------------------------------------------------------------------
4105 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
4107 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
4108 return _wxvtkclipping3DviewCntrlPanel;
4110 //-------------------------------------------------------------------
4111 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
4113 return _vtkclipping3Ddataviewer;
4115 //-------------------------------------------------------------------
4116 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
4117 if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
4118 if (visTissue==false){
4119 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
4121 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
4122 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
4123 // _actor->VisibilityOn();
4125 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
4128 //-------------------------------------------------------------------
4129 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
4132 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
4134 if (representationType==false){
4135 tmpActor->GetProperty()->SetRepresentationToWireframe();
4137 tmpActor->GetProperty()->SetRepresentationToSurface();
4140 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
4143 //-------------------------------------------------------------------
4144 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
4145 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
4146 if (visVolume==false){
4148 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4149 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4152 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4153 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4155 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
4158 //-------------------------------------------------------------------
4159 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
4161 if(_wxvtk3Dbaseview==NULL){
4162 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
4164 return _wxvtk3Dbaseview;
4166 //-------------------------------------------------------------------
4167 void wxVtkClipping3DView::Configure(){
4168 _wxvtk3Dbaseview->Configure();
4170 // Actors are added to the renderer.
4171 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
4173 _boxWidgetS1 = vtkBoxWidget::New();
4174 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4175 _boxWidgetS1->SetPlaceFactor(1.25);
4179 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
4180 vtkPolyData *polydata= stripper->GetOutput();
4183 _boxWidgetS1->SetInput( polydata );
4184 _boxWidgetS1->PlaceWidget();
4187 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
4189 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
4195 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
4196 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
4198 VisibleActor(0, false );
4199 VisibleActor(1, false );
4200 VisibleActor(2, false );
4201 VisibleActor(3, false );
4203 _boxWidgetS1->HandlesOn ();
4206 // _boxWidgetS1->On();
4208 _boxWidgetS1->Off();
4210 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
4211 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
4212 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
4213 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
4217 _boxWidgetVolume = vtkBoxWidget::New();
4218 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4219 _boxWidgetVolume->SetPlaceFactor(1.25);
4221 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
4222 _boxWidgetVolume->PlaceWidget();
4224 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
4226 _boxWidgetVolume->HandlesOn ();
4229 // _boxWidgetVolume->On();
4231 _boxWidgetVolume->Off();
4234 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
4235 // _boxWidgetVolume->GetPlanes( vtkplanes );
4238 // An initial camera view is created. The Dolly() method moves
4239 // the camera towards the FocalPoint, thereby enlarging the image.
4240 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
4241 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
4242 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
4244 // Set a background color for the renderer and set the size of the
4245 // render window (expressed in pixels).
4246 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
4247 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
4249 // Note that when camera movement occurs (as it does in the Dolly()
4250 // method), the clipping planes often need adjusting. Clipping planes
4251 // consist of two planes: near and far along the view direction. The
4252 // near plane clips out objects in front of the plane; the far plane
4253 // clips out objects behind the plane. This way only what is drawn
4254 // between the planes is actually rendered.
4255 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
4257 //-------------------------------------------------------------------
4258 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
4260 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4264 //---------------------------------------------------------------------------
4265 //---------------------------------------------------------------------------
4266 //---------------------------------------------------------------------------
4267 vtkInteractorStyle3DView::vtkInteractorStyle3DView()
4270 //---------------------------------------------------------------------------
4271 vtkInteractorStyle3DView::~vtkInteractorStyle3DView()
4274 //---------------------------------------------------------------------------
4275 bool vtkInteractorStyle3DView::OnLeftDClick()
4277 SelectMarchibCubePoint();
4280 //---------------------------------------------------------------------------
4281 bool vtkInteractorStyle3DView::SelectMarchibCubePoint()
4284 gtm::TVector< double > pO( 3 ), pF( 3 ), pp( 3 ), cp( 3 );
4285 gtm::TVector< double > xc( 3 );
4286 gtm::TVector< double > x1( 3 ), n1( 3 );
4287 gtm::TVector< double > x2( 3 ), n2( 3 );
4289 double pickPoint[ 3 ], cameraPos[ 3 ];
4291 vtkPointPicker* picker = vtkPointPicker::New( );
4292 eventrwi[0]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
4293 eventrwi[1]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
4294 vtkRenderer *pRenderer = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetRenderer();
4295 picker->Pick( eventrwi[0], eventrwi[1], 0.0, pRenderer );
4296 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
4297 picker->GetPickPosition( pickPoint );
4300 pp( 0 ) = pickPoint[ 0 ]; pp( 1 ) = pickPoint[ 1 ]; pp( 2 ) = pickPoint[ 2 ];
4301 cp( 0 ) = cameraPos[ 0 ]; cp( 1 ) = cameraPos[ 1 ]; cp( 2 ) = cameraPos[ 2 ];
4304 //EED 27 sep 2006 (1/2)
4305 // wxVtkMPR3DView *wxvtkmpr3Dview = (wxVtkMPR3DView *)_vtkInteractorStyleBaseView->GetWxVtk3DBaseView();
4307 // wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetSpacing(spc);
4310 vtkImageData *imageData = GetWxVtkMPR3DView()->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
4313 imageData->GetDimensions(dim);
4314 imageData->GetSpacing(spc);
4317 vtkMarchingCubes *mcubes = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetMCubes(0);
4320 UtilVtk3DGeometriSelection utilVtk3DGeometriSelection;
4321 utilVtk3DGeometriSelection.SetDimentions(dim[0],dim[1],dim[2]);
4323 utilVtk3DGeometriSelection.SetMarchingCube(mcubes);
4326 fac = GTM_MAX( dim[0], dim[2] );
4329 if( utilVtk3DGeometriSelection.FindCubePointsFromPoints(
4330 pO.GetAnsiRef( ), pF.GetAnsiRef( ),
4331 pp.GetAnsiRef( ), cp.GetAnsiRef( ) ) )
4334 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4335 x1.GetAnsiRef( ), n1.GetAnsiRef( ),
4336 pO.GetAnsiRef( ), pF.GetAnsiRef( ) ) )
4338 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4339 x2.GetAnsiRef( ), n2.GetAnsiRef( ),
4340 ( x1 - n1 ).GetAnsiRef( ), ( x1 - ( n1 * fac ) ).GetAnsiRef( ) ) )
4342 xc = ( x2 + x1 ) * 0.5;
4343 //EED 27 sep 2006 (2/2)
4344 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX(xc(0)/spc[0]);
4345 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xc(1)/spc[1]);
4346 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xc(2)/spc[2]);
4347 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4348 this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4357 //-------------------------------------------------------------------
4358 void vtkInteractorStyle3DView::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4360 _wxvtkmpr3Dview = wxvtkmpr3Dview;
4362 //-------------------------------------------------------------------
4363 wxVtkMPR3DView *vtkInteractorStyle3DView::GetWxVtkMPR3DView()
4365 return _wxvtkmpr3Dview;
4367 //-------------------------------------------------------------------
4368 wxVtkClipping3DView *vtkInteractorStyle3DView::GetWxVtkClipping3DView()
4370 return _wxvtkclipping3Dview;
4372 //-------------------------------------------------------------------
4373 void vtkInteractorStyle3DView::SetWxVtkClipping3DView( wxVtkClipping3DView *wxvtkclipping3Dview)
4375 _wxvtkclipping3Dview = wxvtkclipping3Dview;
4380 //-------------------------------------------------------------------
4381 //-------------------------------------------------------------------
4382 //-------------------------------------------------------------------
4383 void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
4387 double delta = 0.000000001;
4389 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4391 if (caller==_pointWidget)
4393 _pointWidget->GetPosition(p);
4395 if (caller==_planeWidget)
4397 _planeWidget->GetCenter(p);
4398 _planeWidget->GetNormal(n);
4399 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
4403 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
4408 // Orientation change
4409 if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
4411 _backNormal[0] = n[0];
4412 _backNormal[1] = n[1];
4413 _backNormal[2] = n[2];
4414 isbv->SetParent_refresh_waiting();
4419 double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
4420 double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
4421 double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
4424 if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
4426 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
4427 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
4428 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
4429 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4430 isbv->BlockRefresh();
4431 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
4432 isbv->SetParent_refresh_waiting();
4433 isbv->vtkInteractorStyleBaseView::OnMouseMove();
4434 isbv->UnBlockRefresh();
4436 isbv->EvaluateToRefresh();
4438 //-------------------------------------------------------------------
4439 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4441 _wxvtkmpr3Dview=wxvtkmpr3Dview;
4443 //-------------------------------------------------------------------
4444 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
4446 _pointWidget=pointWidget;
4448 //-------------------------------------------------------------------
4449 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
4451 _planeWidget=planeWidget;
4453 //-------------------------------------------------------------------
4454 //-------------------------------------------------------------------
4455 //-------------------------------------------------------------------
4457 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
4458 : wxPanel( parent, -1)
4461 _histogrammeVector=NULL;
4462 _wxvtk3Dbaseview=NULL;
4463 _wxvtkbaseView=NULL;
4466 Create3DViewObjects();
4469 //-------------------------------------------------------------------
4470 wxPanelCuttingImageData::~wxPanelCuttingImageData()
4475 delete _modelSphere;
4476 delete _modelCylinder;
4477 _vtkcube -> Delete();
4478 _vtksphere -> Delete();
4479 _vtkcylinder -> Delete();
4480 _cubeMapper -> Delete();
4481 _sphereMapper -> Delete();
4482 _cylinderMapper -> Delete();
4483 _cubeActor -> Delete();
4484 _sphereActor -> Delete();
4485 _cylinderActor -> Delete();
4486 // _xyplot->RemoveAllInputs();
4487 _xyplot -> Delete();
4488 _histogrammeVector->Delete();
4489 _renplotter->Delete();
4491 if(_wxvtkbaseView!=NULL){
4492 delete _wxvtkbaseView;
4494 //delete _vtkclipping3Ddataviewer;
4501 //-------------------------------------------------------------------
4502 void wxPanelCuttingImageData::RemoveActors()
4504 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4508 //-------------------------------------------------------------------
4509 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
4511 _wxvtk3Dbaseview=wxvtk3Dbaseview;
4514 //-------------------------------------------------------------------
4516 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
4518 this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4521 //-------------------------------------------------------------------
4522 void wxPanelCuttingImageData::Create3DViewObjects()
4525 _vtksphere = vtkSphereSource::New();
4526 _vtksphere->SetThetaResolution (20);
4527 _vtksphere->SetPhiResolution (20);
4528 _sphereMapper = vtkPolyDataMapper::New();
4529 _sphereMapper->SetInput( _vtksphere->GetOutput() );
4530 _sphereActor = vtkActor::New();
4531 _sphereActor->SetMapper(_sphereMapper);
4532 _sphereActor->SetOrigin(0, 0, 0);
4533 _sphereActor->SetPosition(0, 0, 0);
4534 _sphereActor->GetProperty()->SetColor(1, 0, 0);
4535 _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );
4538 _vtkcube = vtkCubeSource::New();
4539 _vtkcube->SetXLength (1);
4540 _vtkcube->SetYLength (1);
4541 _vtkcube->SetZLength (1);
4542 _cubeMapper = vtkPolyDataMapper::New();
4543 _cubeMapper->SetInput( _vtkcube->GetOutput() );
4544 _cubeActor = vtkActor::New();
4545 _cubeActor->SetMapper(_cubeMapper);
4546 _cubeActor->SetOrigin(0, 0, 0);
4547 _cubeActor->SetPosition(0, 0, 0);
4548 _cubeActor->GetProperty()->SetColor(1, 0, 0);
4549 _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );
4552 _vtkcylinder = vtkCylinderSource::New();
4553 _vtkcylinder->SetResolution(20);
4554 _cylinderMapper = vtkPolyDataMapper::New();
4555 _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
4556 _cylinderActor = vtkActor::New();
4557 _cylinderActor->SetMapper(_cylinderMapper);
4558 _cylinderActor->SetOrigin(0, 0, 0);
4559 _cylinderActor->SetPosition(0, 0, 0);
4560 _cylinderActor->GetProperty()->SetColor(1, 0, 0);
4561 _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );
4566 //-------------------------------------------------------------------
4567 void wxPanelCuttingImageData::CreateModel()
4569 _modelCube = new figureCuttingCubeModel();
4570 _modelSphere = new figureCuttingSphereModel();
4571 _modelCylinder = new figureCuttingCylinderModel();
4573 // _modelCube->SetVtkTransform( _modelCube->GetVtkTransform() );
4574 // _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform() );
4575 // _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform() );
4578 //-------------------------------------------------------------------
4580 void wxPanelCuttingImageData::InitHistogramme()
4583 if (_imageData==NULL)
4587 _imageData->GetScalarRange(rangeA);
4589 _xyplot->RemoveAllInputs();
4591 if ( _histogrammeVector!=NULL )
4593 _histogrammeVector -> Delete();
4596 _histogrammeVector = vtkImageData::New();
4597 _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
4598 _histogrammeVector -> SetScalarTypeToUnsignedShort();
4599 _histogrammeVector -> AllocateScalars();
4600 _histogrammeVector -> Update();
4602 unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4603 int i,size = (int) (rangeA[1]);
4604 for (i=0; i < size; i++)
4609 _xyplot->SetXRange(0, rangeA[1]);
4610 _xyplot->SetYRange(0, 10);
4611 _xyplot->AddInput( _histogrammeVector );
4614 //-------------------------------------------------------------------
4615 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
4617 _xyplot = vtkXYPlotActor::New();
4619 _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
4620 _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
4621 _xyplot->SetXValuesToArcLength();
4622 _xyplot->SetNumberOfXLabels(6);
4624 _xyplot->SetTitle("Histogramme");
4625 _xyplot->SetXTitle("Gray level");
4626 _xyplot->SetYTitle("Occurrences ");
4627 _xyplot->GetProperty()->SetColor(1, 0, 0);
4628 _xyplot->GetProperty()->SetPointSize(2);
4629 vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
4630 tprop->SetColor( 1,0,1 );
4632 _xyplot->SetAxisTitleTextProperty(tprop);
4633 _xyplot->SetAxisLabelTextProperty(tprop);
4634 _xyplot->PlotPointsOn();
4635 _xyplot->GetProperty()->SetPointSize(3);
4637 _wxvtkbaseView = new wxVtkBaseView(this);
4638 _wxvtkbaseView->Configure();
4640 _renplotter = vtkRenderer::New();
4641 vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
4642 renWin->AddRenderer( _renplotter );
4643 _renplotter->AddActor2D( _xyplot );
4645 return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
4648 //-------------------------------------------------------------------
4650 void wxPanelCuttingImageData::CreateInterface()
4653 wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); // Principal sizer
4655 wxBoxSizer *sizerH0 = new wxBoxSizer(wxHORIZONTAL ); // type of segmentation figure
4656 wxBoxSizer *sizerH2 = new wxBoxSizer(wxHORIZONTAL ); // scale
4657 wxBoxSizer *sizerH3 = new wxBoxSizer(wxHORIZONTAL ); // rotation
4658 wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL ); // intern extern
4659 wxBoxSizer *sizerH5 = new wxBoxSizer(wxHORIZONTAL ); // Isovalue
4660 wxBoxSizer *sizerH6 = new wxBoxSizer(wxHORIZONTAL ); // Buttons
4661 wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(2 ); // Volumic information
4664 _typeFig = new wxChoice(this,-1);
4665 _opacityFig = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4667 _scaleX = new wxSlider(this,-1,6,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4668 _scaleY = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4669 _scaleZ = new wxSlider(this,-1,7,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4671 _rotationX = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4672 _rotationY = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4673 _rotationZ = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4675 _volIntern = new wxRadioButton(this,-1, _T("Volume intern " ));
4676 _volExtern = new wxRadioButton(this,-1, _T("Volume extern " ));
4678 _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
4680 _isoValue = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4681 _valueBeforeIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4682 _valueAfterIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4684 wxButton *btnExtract = new wxButton(this, -1,_T("Extract"));
4686 _infoToVo = new wxStaticText(this,-1,_T("########################"));
4687 _infoSuVoA = new wxStaticText(this,-1,_T("############"));
4688 _infoSuVo = new wxStaticText(this,-1,_T("############"));
4689 _infoPixLe = new wxStaticText(this,-1,_T("############"));
4690 _infoPixHi = new wxStaticText(this,-1,_T("############"));
4695 _typeFig->Append(_T("Cylindre"));
4696 _typeFig->Append(_T("Cube"));
4697 _typeFig->Append(_T("Sphere"));
4698 _typeFig->SetSelection(0);
4699 _volIntern->SetValue(true);
4701 Connect(_typeFig->GetId() , wxEVT_COMMAND_CHOICE_SELECTED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig );
4703 Connect(_opacityFig->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig );
4704 Connect(_rotationX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4705 Connect(_rotationY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4706 Connect(_rotationZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4707 Connect(_scaleX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4708 Connect(_scaleY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4709 Connect(_scaleZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4710 Connect(btnExtract->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract );
4713 // wxStaticText *text=new wxStaticText(this,-1, " ");
4715 sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type: "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL ,0);
4716 sizerH0 -> Add( _typeFig ,1,wxALL ,0);
4717 sizerH0 -> Add( _opacityFig ,1,wxALL|wxEXPAND ,0);
4719 sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale : ")) ,1,wxALL ,0);
4720 sizerH2 -> Add( _scaleX ,1,wxALL | wxEXPAND ,0 );
4721 sizerH2 -> Add( _scaleY ,1,wxALL | wxEXPAND ,0 );
4722 sizerH2 -> Add( _scaleZ ,1,wxALL | wxEXPAND ,0 );
4724 sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation : ")) ,1,wxALL ,0);
4725 sizerH3 -> Add( _rotationX ,1,wxALL | wxEXPAND ,0 );
4726 sizerH3 -> Add( _rotationY ,1,wxALL | wxEXPAND ,0 );
4727 sizerH3 -> Add( _rotationZ ,1,wxALL | wxEXPAND ,0 );
4730 sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern : ")) ,1,wxALL ,0);
4731 sizerH4 -> Add( _volIntern ,1,wxALL ,0);
4732 sizerH4 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4733 sizerH4 -> Add( _volExtern ,1,wxALL ,0);
4735 sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue ")) ,1,wxALL ,0);
4736 sizerH5 -> Add( _isoValue ,1,wxALL | wxEXPAND ,0 );
4737 sizerH5 -> Add( _valueBeforeIsoValue ,1,wxALL | wxEXPAND ,0 );
4738 sizerH5 -> Add( _valueAfterIsoValue ,1,wxALL | wxEXPAND ,0 );
4740 sizerH6 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4741 sizerH6 -> Add( btnExtract ,1,wxALL ,0);
4743 sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4744 sizerH7 -> Add( _infoToVo , 1 , wxALL ,0);
4745 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume: "), wxDefaultPosition, wxSize(200,12) ) , 1 , wxALL ,0);
4746 sizerH7 -> Add( _infoSuVo , 1 , wxALL ,0);
4747 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4748 sizerH7 -> Add( _infoSuVoA , 1 , wxALL ,0);
4749 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue: ") , wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4750 sizerH7 -> Add( _infoPixLe , 1 , wxALL ,0);
4751 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4752 sizerH7 -> Add( _infoPixHi , 1 , wxALL ,0);
4753 // sizerH7 -> SetMinSize(300, 120);
4756 topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND ,0);
4759 topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND ,0);
4762 topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND ,0);
4765 topsizer -> Add( sizerH4 ,1,wxALL ,0);
4769 topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
4772 topsizer -> Add( sizerH6 , 1 , wxALL ,0);
4775 topsizer -> Add( _histogrammeAccumulated ,1, wxALL ,0);
4777 // Volumic information
4778 topsizer -> Add( sizerH7 , 1 , wxALL|wxEXPAND ,0);
4782 // wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
4783 wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
4784 sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
4787 wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
4788 sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
4791 this->SetAutoLayout(true);
4792 this->SetSizer( sizerHor );
4795 // this->FitInside();
4798 //-------------------------------------------------------------------
4800 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
4805 bool volInt, volExt;
4807 unsigned short *pOrg;
4808 unsigned short *p_histogramme;
4811 long int contAfter = 0;
4812 long int contBefor = 0;
4814 double min=999999999;
4815 double max=-999999999;
4817 volExt=_volExtern->GetValue();
4818 volInt=_volIntern->GetValue();
4819 int isoValue = _isoValue->GetValue();
4820 int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue();
4821 int valueAfterIsoValue = _valueAfterIsoValue ->GetValue();
4824 p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4826 _imageData->GetDimensions(dim);
4827 _imageData->GetSpacing(spc);
4828 _actualCuttingModel->CalculeInversMatrix();
4830 for (xx=0;xx<dim[0]; xx++)
4832 for (yy=0;yy<dim[1]; yy++)
4834 for (zz=0;zz<dim[2];zz++)
4836 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
4837 if ( ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
4839 pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz);
4841 if ((*pOrg)<isoValue)
4844 if (valueBeforeIsoValue!=-1)
4846 *pOrg=valueBeforeIsoValue;
4850 if (valueAfterIsoValue!=-1)
4852 *pOrg=valueAfterIsoValue;
4856 p_histogramme[*pOrg]++;
4857 if (*pOrg<min) min=*pOrg;
4858 if (*pOrg>max) max=*pOrg;
4872 double volumeUnit = spc[0]*spc[1]*spc[2];
4873 long int totalSubVolume = contBefor + contAfter;
4874 double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
4875 double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
4876 infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
4877 infoSuVo.Printf(_T("%ld") , totalSubVolume);
4878 infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
4879 infoPixLe.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
4880 infoPixHi.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
4882 _infoToVo->SetLabel(infoToVo);
4883 _infoSuVo->SetLabel(infoSuVo);
4884 _infoSuVoA->SetLabel(infoSuVoA);
4885 _infoPixLe->SetLabel(infoPixLe);
4886 _infoPixHi->SetLabel(infoPixHi);
4889 if ( _histogrammeAccumulated->GetValue()==true )
4892 _histogrammeVector -> GetDimensions ( dimHist );
4894 int i,size=dimHist[0];
4895 for (i=1; i<=size; i++)
4897 p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
4901 _histogrammeVector->Update();
4902 _histogrammeVector->GetScalarRange(range);
4903 _xyplot->SetYRange( 0 , range[1] );
4904 _xyplot->SetXRange( min , max );
4906 _vtkclipping3Ddataviewer->RefreshSurface();
4907 _wxvtkbaseView->Refresh();
4909 // _wxvtkbaseView->RefreshView();
4910 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4911 _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4915 //-------------------------------------------------------------------
4916 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
4918 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4920 if (_typeFig->GetSelection()==0){
4921 _actualCuttingModel=_modelCylinder;
4922 _actualActor=_cylinderActor;
4924 if (_typeFig->GetSelection()==1){
4925 _actualCuttingModel=_modelCube;
4926 _actualActor=_cubeActor;
4928 if (_typeFig->GetSelection()==2){
4929 _actualCuttingModel=_modelSphere;
4930 _actualActor=_sphereActor;
4932 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4937 //-------------------------------------------------------------------
4938 void wxPanelCuttingImageData::RefreshOpacity()
4940 double op= _opacityFig->GetValue()/100.0;
4941 _actualActor->GetProperty()->SetOpacity( op );
4944 //-------------------------------------------------------------------
4945 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
4950 //-------------------------------------------------------------------
4951 void wxPanelCuttingImageData::RefreshView()
4953 SetParamsOfTransformation( );
4956 //-------------------------------------------------------------------
4957 void wxPanelCuttingImageData::Refresh()
4959 _wxvtk3Dbaseview->Refresh();
4962 //-------------------------------------------------------------------
4963 void wxPanelCuttingImageData::SetParamsOfTransformation( )
4966 vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
4967 vtkimagedata->GetSpacing(spc);
4968 int px = (int) (_vtkmprbasedata->GetX() );
4969 int py = (int) (_vtkmprbasedata->GetY() );
4970 int pz = (int) (_vtkmprbasedata->GetZ() );
4971 int sx = (int) (_scaleX->GetValue() * spc[0] );
4972 int sy = (int) (_scaleY->GetValue() * spc[1] );
4973 int sz = (int) (_scaleZ->GetValue() * spc[2] );
4974 _actualCuttingModel -> SetScale ( sx , sy , sz );
4975 _actualCuttingModel -> SetPosition ( px , py , pz );
4976 _actualCuttingModel -> SetRotation ( _rotationX->GetValue() , _rotationY->GetValue() , _rotationZ->GetValue() );
4977 _actualCuttingModel -> SetSpacing ( spc[0] , spc[1] , spc[2] );
4978 _actualCuttingModel -> CalculeMatrix();
4981 //-------------------------------------------------------------------
4983 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
4988 //-------------------------------------------------------------------
4989 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
4991 _vtkmprbasedata = vtkmprbasedata;
4992 _imageData = _vtkmprbasedata->GetImageData();
4995 //-------------------------------------------------------------------
4997 void wxPanelCuttingImageData::Configure()
4999 _actualCuttingModel=_modelCylinder;
5000 _actualActor=_cylinderActor;
5001 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
5002 SetParamsOfTransformation();
5008 //-------------------------------------------------------------------
5009 //-------------------------------------------------------------------
5010 //-------------------------------------------------------------------
5013 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
5014 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
5017 //-------------------------------------------------------------------
5019 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
5020 : wxSplitterWindow( parent , -1)
5023 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
5024 this->SetMinimumPaneSize(50);
5026 //-------------------------------------------------------------------
5027 wxWidgetMesure2D::~wxWidgetMesure2D()
5030 //-------------------------------------------------------------------
5031 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
5033 wxPanel *panel = new wxPanel(parent,-1);
5035 _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
5036 _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
5037 _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
5038 _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
5040 _cb_mt_visible->SetValue(true);
5041 _cb_closeContour->SetValue(true);
5042 _cb_visibleText->SetValue(true);
5044 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
5046 sizer->Add(_cb_messuretool);
5047 sizer->Add(_cb_mt_visible);
5048 sizer->Add(_cb_closeContour);
5049 sizer->Add(_cb_visibleText);
5051 panel->SetAutoLayout(true);
5052 panel->SetSizer(sizer);
5053 panel->SetSize(400,30);
5056 // panel->FitInside();
5058 Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
5059 Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
5060 Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
5061 Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
5066 //-------------------------------------------------------------------
5067 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5069 _wxvtk2Dbaseview = wxvtk2Dbaseview;
5072 _manContourControl_1 = new manualContourControler();
5073 _mContourModel_1 = new manualContourModel();
5074 _mViewContour_1 = new manualViewContour();
5075 _mViewContour_1->SetModel( _mContourModel_1 );
5076 _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
5077 _mViewContour_1->SetRange( 1 );
5081 // _wxvtk2Dbaseview->GetSpacing( spc );
5082 // _mViewContour_1->SetSpacing( spc );
5086 _manContourControl_1->SetZ( 1000 );
5087 _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
5088 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 );
5089 _manContourControl_1->CreateNewManualContour();
5090 _manContourControl_1->SetActive( false );
5091 _mViewContour_1->RefreshContour();
5095 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
5096 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
5097 // CreateWin1a(this->GetWindow1() );
5099 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5100 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
5101 this->GetWindow1()->SetSizer(sizerA);
5102 this->SetAutoLayout(true);
5105 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
5106 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
5107 this->GetWindow2()->SetSizer(sizerB);
5108 this->SetAutoLayout(true);
5112 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
5116 // this->FitInside();
5120 //-------------------------------------------------------------------
5121 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
5123 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->SetActiveAllInteractors(!ok);
5124 _manContourControl_1->SetActive( ok );
5127 //-------------------------------------------------------------------
5128 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
5130 ActiveMessureTool( _cb_messuretool->GetValue() );
5131 if ( _cb_messuretool->GetValue() == true )
5133 _cb_mt_visible->SetValue(true);
5134 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
5135 _cb_closeContour->Enable(true);
5136 _cb_visibleText->Enable(true);
5138 _cb_closeContour->Enable(false);
5139 _cb_visibleText->Enable(false);
5141 _wxvtk2Dbaseview->Refresh();
5142 _wxvtk2Dbaseview->RefreshView();
5145 //-------------------------------------------------------------------
5146 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
5148 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
5149 if (_cb_messuretool->GetValue()==true)
5151 _cb_closeContour->Enable(true);
5152 _cb_visibleText->Enable(true);
5154 ActiveMessureTool( _cb_messuretool->GetValue() );
5155 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
5156 _mViewContour_1->Refresh();
5157 _wxvtk2Dbaseview->Refresh();
5158 _wxvtk2Dbaseview->RefreshView();
5161 //-------------------------------------------------------------------
5162 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
5164 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
5165 _mViewContour_1->Refresh();
5166 _wxvtk2Dbaseview->Refresh();
5167 _wxvtk2Dbaseview->RefreshView();
5170 //-------------------------------------------------------------------
5171 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
5173 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
5174 _mViewContour_1->Refresh();
5175 _wxvtk2Dbaseview->Refresh();
5176 _wxvtk2Dbaseview->RefreshView();
5178 //-------------------------------------------------------------------
5179 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
5181 _mViewContour_1->SetMesureScale(mesureScale);
5183 //-------------------------------------------------------------------
5184 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
5186 return _mContourModel_1;
5189 //-------------------------------------------------------------------
5190 //-------------------------------------------------------------------
5191 //-------------------------------------------------------------------
5193 wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
5194 : wxWidgetMesure2D(parent)
5198 _circle1Actor = NULL;
5199 _circle1Mapper = NULL;
5203 _circle2Actor = NULL;
5204 _circle2Mapper = NULL;
5207 _ptsLineRef1 = NULL;
5208 _lineRef1Actor = NULL;
5209 _lineRef1Mapper = NULL;
5212 _ptsLineRef2 = NULL;
5213 _lineRef2Actor = NULL;
5214 _lineRef2Mapper = NULL;
5219 //-------------------------------------------------------------------
5221 wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
5224 if ( _ptsCircle1 != NULL){ _ptsCircle1 -> Delete(); }
5225 if ( _circle1Actor != NULL){ _circle1Actor -> Delete(); }
5226 if ( _circle1Mapper != NULL){ _circle1Mapper -> Delete(); }
5227 if ( _pdCircle1 != NULL){ _pdCircle1 -> Delete(); }
5229 if ( _ptsCircle2 != NULL){ _ptsCircle2 -> Delete(); }
5230 if ( _circle2Actor != NULL){ _circle2Actor -> Delete(); }
5231 if ( _circle2Mapper != NULL){ _circle2Mapper -> Delete(); }
5232 if ( _pdCircle2 != NULL){ _pdCircle2 -> Delete(); }
5234 if ( _ptsLineRef1 != NULL){ _ptsLineRef1 -> Delete(); }
5235 if ( _lineRef1Actor != NULL){ _lineRef1Actor -> Delete(); }
5236 if ( _lineRef1Mapper != NULL){ _lineRef1Mapper -> Delete(); }
5237 if ( _pdLineRef1 != NULL){ _pdLineRef1 -> Delete(); }
5239 if ( _ptsLineRef2 != NULL){ _ptsLineRef2 -> Delete(); }
5240 if ( _lineRef2Actor != NULL){ _lineRef2Actor -> Delete(); }
5241 if ( _lineRef2Mapper != NULL){ _lineRef2Mapper -> Delete(); }
5242 if ( _pdLineRef2 != NULL){ _pdLineRef2 -> Delete(); }
5245 //-------------------------------------------------------------------
5247 wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
5249 wxPanel *panel = new wxPanel(parent,-1);
5251 _cb_circle = new wxCheckBox(panel,-1,_T("Circle "));
5252 _cb_line = new wxCheckBox(panel,-1,_T("Rotation Axe "));
5255 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5256 sizerA->Add(_cb_circle);
5257 sizerA->Add(_cb_line);
5260 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5261 sizer->Add( sizerA );
5262 sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
5264 panel->SetAutoLayout(true);
5265 panel->SetSizer(sizer);
5266 panel->SetSize(400,30);
5269 // panel->FitInside();
5271 Connect(_cb_line->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine );
5272 Connect(_cb_circle->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle );
5278 //-------------------------------------------------------------------
5279 void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
5281 SetVisibleCircle( _cb_circle->GetValue() );
5282 _wxvtk2Dbaseview->RefreshView();
5285 //-------------------------------------------------------------------
5286 void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
5295 _lineRef1Actor->GetProperty()->SetOpacity( opacity );
5296 _lineRef2Actor->GetProperty()->SetOpacity( opacity );
5297 _circle1Actor->GetProperty()->SetOpacity( opacity );
5298 _circle2Actor->GetProperty()->SetOpacity( opacity );
5300 //-------------------------------------------------------------------
5301 void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
5303 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5304 vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
5305 _wxvtk2Dbaseview->RefreshView();
5309 //-------------------------------------------------------------------
5310 void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5312 wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
5314 ConfigureCircleLine();
5315 SetVisibleCircle(false);
5319 //-------------------------------------------------------------------
5320 void wxWidgetMesure2D_Plane::ConfigureCircleLine()
5324 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5325 int sizeIma = vtkplane2Dview->GetImgSize();
5328 double k=(360/(maxPts-1)) * (3.1416/180);
5329 double x,y,r1=5,r2=10,r3=15;
5330 for (i=0;i<maxPts;i++)
5334 _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1 , (sizeIma/2) + y*r1 , 1 );
5335 _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2 , (sizeIma/2) + y*r2 , 1 );
5339 ang=(45) * (3.1416/180);
5342 _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5344 ang=(45+180) * (3.1416/180);
5347 _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5350 ang=(135) * (3.1416/180);
5353 _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5355 ang=(135+180) * (3.1416/180);
5358 _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5363 //-------------------------------------------------------------------
5364 void wxWidgetMesure2D_Plane::CircleLine()
5367 vtkCellArray *lines;
5369 vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
5372 // Circle 1 Horizontal
5373 _ptsCircle1 = vtkPoints::New();
5374 _ptsCircle1->SetNumberOfPoints(maxPts);
5375 lines = vtkCellArray::New();
5376 lines->InsertNextCell(maxPts);
5377 for (i=0;i<maxPts;i++)
5379 lines->InsertCellPoint(i);
5380 _ptsCircle1->SetPoint(i, 0 , 0 , 0 );
5382 lines->InsertCellPoint(0);
5383 _ptsCircle1->SetPoint(0, -1000 , -1000 , -1000 );
5384 _ptsCircle1->SetPoint(1, 1000 , 1000 , 1000 );
5386 _pdCircle1 = vtkPolyData::New();
5387 _pdCircle1->SetPoints( _ptsCircle1 );
5388 _pdCircle1->SetLines( lines );
5389 lines->Delete(); //do not delete lines ??
5390 _circle1Actor = vtkActor::New();
5391 _circle1Mapper = vtkPolyDataMapper::New();
5392 _circle1Mapper->SetInput(_pdCircle1);
5393 _circle1Mapper->ImmediateModeRenderingOn();
5394 _circle1Actor->SetMapper(_circle1Mapper);
5395 _circle1Actor->GetProperty()->BackfaceCullingOn();
5396 _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5397 _circle1Actor->GetProperty()->SetLineWidth(2);
5398 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
5400 // Circle 2 Horizontal
5401 _ptsCircle2 = vtkPoints::New();
5402 _ptsCircle2->SetNumberOfPoints(maxPts);
5403 lines = vtkCellArray::New();
5404 lines->InsertNextCell(maxPts);
5405 for (i=0;i<maxPts;i++)
5407 lines->InsertCellPoint(i);
5408 _ptsCircle2->SetPoint(i, 0 , 0 , 0 );
5410 _ptsCircle2->SetPoint(0, -1000 , -1000 , -1000 );
5411 _ptsCircle2->SetPoint(1, 1000 , 1000 , 1000 );
5413 _pdCircle2 = vtkPolyData::New();
5414 _pdCircle2->SetPoints( _ptsCircle2 );
5415 _pdCircle2->SetLines( lines );
5416 lines->Delete(); //do not delete lines ??
5417 _circle2Actor = vtkActor::New();
5418 _circle2Mapper = vtkPolyDataMapper::New();
5419 _circle2Mapper->SetInput(_pdCircle2);
5420 _circle2Mapper->ImmediateModeRenderingOn();
5421 _circle2Actor->SetMapper(_circle2Mapper);
5422 _circle2Actor->GetProperty()->BackfaceCullingOn();
5423 _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5424 _circle2Actor->GetProperty()->SetLineWidth(2);
5425 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
5428 _ptsLineRef1 = vtkPoints::New();
5429 _ptsLineRef1->SetNumberOfPoints(2);
5430 _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
5431 _ptsLineRef1->SetPoint(1, 1000 , 1000 , 1000 );
5432 lines = vtkCellArray::New();
5433 lines->InsertNextCell(2);
5434 lines->InsertCellPoint(0);
5435 lines->InsertCellPoint(1);
5437 _pdLineRef1 = vtkPolyData::New();
5438 _pdLineRef1->SetPoints( _ptsLineRef1 );
5439 _pdLineRef1->SetLines( lines );
5440 lines->Delete(); //do not delete lines ??
5441 _lineRef1Actor = vtkActor::New();
5442 _lineRef1Mapper = vtkPolyDataMapper::New();
5443 _lineRef1Mapper->SetInput(_pdLineRef1);
5444 _lineRef1Mapper->ImmediateModeRenderingOn();
5445 _lineRef1Actor->SetMapper(_lineRef1Mapper);
5446 _lineRef1Actor->GetProperty()->BackfaceCullingOn();
5447 _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5448 _lineRef1Actor->GetProperty()->SetLineWidth(2);
5449 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
5452 _ptsLineRef2 = vtkPoints::New();
5453 _ptsLineRef2->SetNumberOfPoints(2);
5454 _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
5455 _ptsLineRef2->SetPoint(1, 1000 , 1000 , 1000 );
5456 lines = vtkCellArray::New();
5457 lines->InsertNextCell(2);
5458 lines->InsertCellPoint(0);
5459 lines->InsertCellPoint(1);
5461 _pdLineRef2 = vtkPolyData::New();
5462 _pdLineRef2->SetPoints( _ptsLineRef2 );
5463 _pdLineRef2->SetLines( lines );
5464 lines->Delete(); //do not delete lines ??
5465 _lineRef2Actor = vtkActor::New();
5466 _lineRef2Mapper = vtkPolyDataMapper::New();
5467 _lineRef2Mapper->SetInput(_pdLineRef2);
5468 _lineRef2Mapper->ImmediateModeRenderingOn();
5469 _lineRef2Actor->SetMapper(_lineRef2Mapper);
5470 _lineRef2Actor->GetProperty()->BackfaceCullingOn();
5471 _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5472 _lineRef2Actor->GetProperty()->SetLineWidth(2);
5473 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
5479 //-------------------------------------------------------------------
5480 //-------------------------------------------------------------------
5481 //-------------------------------------------------------------------
5483 wxWidgetMesure2D_Plane_in_MPR::wxWidgetMesure2D_Plane_in_MPR(wxWindow *parent)
5484 :wxWidgetMesure2D_Plane(parent)
5486 _vtkplane2Dview=NULL;
5489 //-------------------------------------------------------------------
5491 wxWidgetMesure2D_Plane_in_MPR::~wxWidgetMesure2D_Plane_in_MPR()
5494 //-------------------------------------------------------------------
5495 void wxWidgetMesure2D_Plane_in_MPR::OnActiveLink(wxCommandEvent& event)
5497 if (_vtkplane2Dview!=NULL)
5499 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5500 _vtkplane2Dview->Refresh();
5501 _vtkplane2Dview->RefreshView();
5506 //-------------------------------------------------------------------
5507 void wxWidgetMesure2D_Plane_in_MPR::SetActiveLink(bool ok)
5509 _cb_link->SetValue(ok);
5510 if (_vtkplane2Dview!=NULL)
5512 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5515 //-------------------------------------------------------------------
5517 void wxWidgetMesure2D_Plane_in_MPR::SetVtkPlane2DView(vtkPlane2DView *vtkplane2Dview)
5519 _vtkplane2Dview = vtkplane2Dview;
5522 //-------------------------------------------------------------------
5524 wxWindow *wxWidgetMesure2D_Plane_in_MPR::CreateWin1a(wxWindow *parent) // virtual
5526 wxPanel *panel = new wxPanel(parent,-1);
5528 _cb_link = new wxCheckBox(panel,-1,_T("LINK "));
5529 _cb_link->SetValue(true);
5531 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5533 sizer->Add(_cb_link);
5535 sizer->Add( wxWidgetMesure2D_Plane::CreateWin1a(panel) );
5537 panel->SetAutoLayout(true);
5538 panel->SetSizer(sizer);
5539 panel->SetSize(400,30);
5543 // panel->FitInside();
5545 Connect(_cb_link->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxWidgetMesure2D_Plane_in_MPR::OnActiveLink );
5553 //-------------------------------------------------------------------
5554 //-------------------------------------------------------------------
5555 //-------------------------------------------------------------------
5557 BEGIN_EVENT_TABLE( wxMPRWidget, wxPanel )
5558 EVT_MENU( 12121, wxMPRWidget::OnRefreshView )
5559 EVT_MENU( 12122, wxMPRWidget::OnDClickLeft )
5564 wxMPRWidget::wxMPRWidget( wxWindow* parent,
5565 marImageData *marimageData , double voxelSize)
5566 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
5569 _vtkmpr2Dview[0] = NULL;
5570 _vtkmpr2Dview[1] = NULL;
5571 _vtkmpr2Dview[2] = NULL;
5572 _vtkplane2Dview = NULL;
5573 _widgetMesure = NULL;
5574 _wxsphereview = NULL;
5575 _wxvtk3Dbaseview_MPRClipping3D = NULL;
5576 _wxvtkmpr3Dview = NULL;
5577 _wxvtkclipping3Dview = NULL;
5578 _vtkplane2Dview_B = NULL;
5579 _widgetMesure_B = NULL;
5581 _vtkmpr2Dview_B[0] = NULL;
5582 _vtkmpr2Dview_B[1] = NULL;
5583 _vtkmpr2Dview_B[2] = NULL;
5584 _vtkplane2Dview_B = NULL;
5585 _widgetMesure_B = NULL;
5586 _wxsphereview_B = NULL;
5587 _wxvtk3Dbaseview_MPR3D_B = NULL;
5588 _wxvtkmpr3Dview_B = NULL;
5589 _wxvtk3Dbaseview_Clipping3D_BB = NULL;
5590 _wxvtkmpr3Dview_BB = NULL;
5591 _wxvtkclipping3Dview_BB = NULL;
5593 _vtkmprbasedata = NULL;
5597 _framePanelCutting = NULL;
5598 _panelCutting = NULL;
5601 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
5604 if(marimageData!=NULL){
5605 _marImageData = marimageData;
5606 _voxelSize = voxelSize;
5607 _vtkmprbasedata = new vtkMPRBaseData();
5608 _vtkmprbasedata->SetMarImageData(_marImageData);
5613 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5614 pnlSplitter -> SetMinimumPaneSize( 2 );
5616 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5617 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5618 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5620 sizer -> Add( pnlSplitter ,1,wxGROW ,0);
5625 //wxWindow *pp=this;
5626 //while (pp->GetParent()!=NULL) pp=pp->GetParent();
5627 //pp->GetSize(&ww,&hh);
5629 this -> SetAutoLayout( true );
5630 this -> SetSizer(sizer);
5631 // sizer -> Fit( this );
5636 void wxMPRWidget::setImageData(vtkImageData * img, double voxelsize){
5638 if(_marImageData!=NULL){
5639 _marImageData->removeImageData(0);
5640 _marImageData->AddImageData(img);
5642 _marImageData = new marImageData(img);
5645 _voxelSize = voxelsize;
5647 if(_vtkmprbasedata==NULL){
5648 _vtkmprbasedata = new vtkMPRBaseData();
5649 _vtkmprbasedata->SetMarImageData(_marImageData);
5651 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5652 pnlSplitter -> SetMinimumPaneSize( 2 );
5654 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5655 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5656 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5658 this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0);
5664 //----------------------------------------------------------------------------
5666 wxMPRWidget::~wxMPRWidget( )
5669 if (_framePanelCutting!=NULL)
5671 _framePanelCutting->Close();
5674 if (_vtkmpr2Dview[0]!=NULL) { delete _vtkmpr2Dview[0]; }
5675 if (_vtkmpr2Dview[1]!=NULL) { delete _vtkmpr2Dview[1]; }
5676 if (_vtkmpr2Dview[2]!=NULL) { delete _vtkmpr2Dview[2]; }
5678 if (_vtkmpr2Dview_B[0]!=NULL) { delete _vtkmpr2Dview_B[0]; }
5680 if (_vtkmpr2Dview_B[1]!=NULL) { delete _vtkmpr2Dview_B[1]; }
5681 if (_vtkmpr2Dview_B[2]!=NULL) { delete _vtkmpr2Dview_B[2]; }
5683 if (_vtkmprbasedata!=NULL) { delete _vtkmprbasedata; }
5684 if (_vtkplane2Dview!=NULL) { delete _vtkplane2Dview; }
5685 if (_wxsphereview!=NULL) { delete _wxsphereview; }
5686 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL) { delete _wxvtk3Dbaseview_MPRClipping3D; }
5687 if (_wxvtkmpr3Dview!=NULL) { delete _wxvtkmpr3Dview; }
5688 if (_wxvtkclipping3Dview!=NULL) { delete _wxvtkclipping3Dview; }
5690 if (_vtkplane2Dview_B!=NULL) { delete _vtkplane2Dview_B; }
5691 if (_wxsphereview_B!=NULL) { delete _wxsphereview_B; }
5693 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) { delete _wxvtk3Dbaseview_MPR3D_B; }
5694 if (_wxvtkmpr3Dview_B!=NULL) { delete _wxvtkmpr3Dview_B; }
5696 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL) { delete _wxvtk3Dbaseview_Clipping3D_BB; }
5697 if (_wxvtkmpr3Dview_BB!=NULL) { delete _wxvtkmpr3Dview_BB; }
5698 if (_wxvtkclipping3Dview_BB!=NULL) { delete _wxvtkclipping3Dview_BB; }
5701 //----------------------------------------------------------------------------
5703 wxPanel* wxMPRWidget::CreateControlPanel(wxWindow *parent)
5706 wxPanel *panel=new wxPanel(parent,-1);
5709 // wxStaticText *tmpText = new wxStaticText(panel,-1,"");
5711 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"));
5713 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"));
5715 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)"));
5717 wxStaticText *help3Text = new wxStaticText(panel,-1,
5718 _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"));
5720 wxStaticText *help4Text = new wxStaticText(panel,-1,_T("MPR3D:\n see split control"));
5722 wxString text=_T("");
5723 text=text+_T("Clipping: \n");
5724 text=text+_T(" see split control \n");
5725 text=text+_T(" 4 MarchingCubes: \n");
5726 text=text+_T(" color, isovalue, opacity \n");
5727 text=text+_T(" Box:\n");
5728 text=text+_T(" mouse left drag (box): rotation\n");
5729 text=text+_T(" mouse left drag (sphere): size,position\n");
5730 text=text+_T(" mouse right drag (box): box size");
5731 text=text+_T(" Axis: 3D\n");
5732 text=text+_T(" mouse drag: translate\n");
5733 text=text+_T(" shift + mouse drag: translate 2 axis\n");
5734 text=text+_T(" mouse right: scale\n");
5735 text=text+_T(" Plane 3D:\n");
5736 text=text+_T(" mouse drag perpendicular axis: rotate plane\n");
5737 text=text+_T(" mouse drag spheres: size plane\n");
5738 text=text+_T(" ctrl +mouse right over the plane: size plane\n");
5739 text=text+_T(" mouse drag plane: translate\n");
5740 text=text+_T(" middle click perpendicular axis: translate\n");
5741 wxStaticText *help5Text = new wxStaticText(panel,-1, text );
5744 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5745 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5746 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5747 sizer->Add( help0Text );
5749 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5750 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5751 sizer->Add( help1Text );
5753 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5754 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5755 sizer->Add( help2Text );
5757 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5758 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5759 sizer->Add( help3Text );
5761 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5762 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5763 sizer->Add( help4Text );
5765 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5766 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5767 sizer->Add( help5Text );
5769 panel->SetSizer(sizer);
5770 panel->SetAutoLayout(true);
5771 panel->SetSize(350,500);
5776 //----------------------------------------------------------------------------
5778 void wxMPRWidget::OnPageAChanged(wxNotebookEvent & event)
5780 _refreshAPage=event.GetSelection();
5785 //----------------------------------------------------------------------------
5787 void wxMPRWidget::OnPageBChanged(wxNotebookEvent & event)
5789 _refreshBPage=event.GetSelection();
5795 //----------------------------------------------------------------------------
5797 wxPanel* wxMPRWidget::CreateView(int type,wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5800 wxPanel *panel=new wxPanel(parent,-1);
5804 _vtkmpr2Dview_B[0] = new wxVtkMPR2DView(panel,0);
5805 _vtkmpr2Dview_B[0]->SetVtkBaseData(vtkmprbasedata);
5806 wxwindow=_vtkmpr2Dview_B[0]->GetWxVTKRenderWindowInteractor();
5810 _vtkmpr2Dview_B[1] = new wxVtkMPR2DView(panel,1);
5811 _vtkmpr2Dview_B[1]->SetVtkBaseData(vtkmprbasedata);
5812 wxwindow=_vtkmpr2Dview_B[1]->GetWxVTKRenderWindowInteractor();
5816 _vtkmpr2Dview_B[2] = new wxVtkMPR2DView(panel,2);
5817 _vtkmpr2Dview_B[2]->SetVtkBaseData(vtkmprbasedata);
5818 wxwindow=_vtkmpr2Dview_B[2]->GetWxVTKRenderWindowInteractor();
5822 _widgetMesure_B = new wxWidgetMesure2D_Plane_in_MPR(panel);
5823 _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
5824 _widgetMesure_B->SetVtkPlane2DView( _vtkplane2Dview_B );
5825 _vtkplane2Dview_B->SetImgSize( 200 );
5826 _vtkplane2Dview_B->SetVtkBaseData(vtkmprbasedata);
5827 wxwindow = _widgetMesure_B;
5831 _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
5832 wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor();
5837 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( panel , -1);
5838 _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D );
5840 _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
5841 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5842 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5843 vtkmpr3Ddataviewer->Configure();
5844 _wxvtkmpr3Dview_B->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5846 wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
5847 wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D);
5850 panelMPR3D -> SetMinimumPaneSize( 5 );
5851 panelMPR3D -> SplitHorizontally( controlPanel3D,window3D,600 );
5853 wxwindow=panelMPR3D;
5858 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
5859 _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D );
5861 _wxvtkclipping3Dview_BB = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_BB);
5862 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5863 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5864 vtkclipping3Ddataviewer->Configure();
5865 _wxvtkclipping3Dview_BB->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5867 _wxvtkmpr3Dview_BB = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_BB );
5868 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5869 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5870 vtkmpr3Ddataviewer->Configure();
5871 _wxvtkmpr3Dview_BB->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5873 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
5875 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
5876 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl);
5877 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateControlPanel(panelControl);
5878 _btnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
5879 Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
5881 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5882 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5883 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5884 sizerCtrol->Add( _btnCutImageData , 1, wxALL, 2);
5886 panelControl->SetAutoLayout(true);
5887 panelControl->SetSizer(sizerCtrol);
5888 panelControl->SetSize(400,350);
5889 panelControl->Layout();
5891 // panelControl->FitInside();
5894 panelClipping3D -> SetMinimumPaneSize( 5 );
5895 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
5896 wxwindow=panelClipping3D;
5899 wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
5900 sizerH1->Add(wxwindow , 1, wxALL|wxGROW, 0);
5901 panel->SetAutoLayout(true);
5902 panel->SetSizer(sizerH1);
5903 panel->SetSize(400,400);
5909 //----------------------------------------------------------------------------
5911 wxPanel* wxMPRWidget::CreateMPRPanel(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5913 wxPanel *panel=new wxPanel(parent,-1);
5915 wxNotebook *notebook = new wxNotebook( panel, -1 );
5917 notebook->AddPage( CreateMPRPanel4View( notebook ,vtkmprbasedata), _T("4-View") );
5918 notebook->AddPage( CreateView(0,notebook,vtkmprbasedata) , _T("Axial") );
5919 notebook->AddPage( CreateView(1,notebook,vtkmprbasedata) , _T("Sagital") );
5920 notebook->AddPage( CreateView(2,notebook,vtkmprbasedata) , _T("Coronal") );
5921 notebook->AddPage( CreateView(3,notebook,vtkmprbasedata) , _T("Plane") );
5922 notebook->AddPage( CreateView(4,notebook,vtkmprbasedata) , _T("Sphere") );
5923 notebook->AddPage( CreateView(5,notebook,vtkmprbasedata) , _T("MPR 3D") );
5924 notebook->AddPage( CreateView(6,notebook,vtkmprbasedata) , _T("Clipping") );
5925 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageAChanged );
5927 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
5928 sizer->Add(notebook , 1, wxALL|wxGROW, 2);
5929 panel->SetAutoLayout(true);
5930 panel->SetSizer(sizer);
5931 panel->SetSize(400,400);
5935 // panel->FitInside();
5941 //----------------------------------------------------------------------------
5943 wxPanel* wxMPRWidget::CreateMPRPanel4View(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5945 wxPanel *panel=new wxPanel(parent,-1);
5948 _vtkmpr2Dview[0] = new wxVtkMPR2DView(panel,0);
5949 _vtkmpr2Dview[0]->SetVtkBaseData(vtkmprbasedata);
5950 wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
5953 _vtkmpr2Dview[1] = new wxVtkMPR2DView(panel,1);
5954 _vtkmpr2Dview[1]->SetVtkBaseData(vtkmprbasedata);
5955 wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
5958 _vtkmpr2Dview[2] = new wxVtkMPR2DView(panel,2);
5959 _vtkmpr2Dview[2]->SetVtkBaseData(vtkmprbasedata);
5960 wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
5963 wxNotebook *notebook = new wxNotebook( panel, -1 );
5964 notebook->SetSize(400,400);
5968 _widgetMesure = new wxWidgetMesure2D_Plane_in_MPR(notebook);
5969 _vtkplane2Dview = new vtkPlane2DView( _widgetMesure->GetWindow2() );
5970 _widgetMesure->SetVtkPlane2DView( _vtkplane2Dview );
5971 _vtkplane2Dview->SetImgSize( 200 );
5972 _vtkplane2Dview->SetVtkBaseData(vtkmprbasedata);
5973 notebook->AddPage( _widgetMesure, _T("Plane") );
5976 _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
5977 wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
5978 notebook->AddPage( iren3B, _T("Sphere") );
5982 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( notebook , -1);
5983 _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D );
5985 _wxvtkmpr3Dview = new wxVtkMPR3DView( _wxvtk3Dbaseview_MPRClipping3D );
5986 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5987 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5988 vtkmpr3Ddataviewer->Configure();
5989 _wxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5992 _wxvtkclipping3Dview = new wxVtkClipping3DView( _wxvtk3Dbaseview_MPRClipping3D );
5993 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5994 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5995 vtkclipping3Ddataviewer->Configure();
5996 _wxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5999 wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
6001 wxPanel *panelControl = new wxPanel(panelMPR3D,-1);
6002 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl);
6003 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateControlPanel(panelControl);
6008 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
6009 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
6010 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
6011 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
6014 panelControl->SetAutoLayout(true);
6015 panelControl->SetSizer(sizerCtrol);
6016 panelControl->SetSize(400,150);
6017 panelControl->Layout();
6020 panelMPR3D -> SetMinimumPaneSize( 5 );
6022 panelMPR3D -> SplitHorizontally( panelControl,window3D,200 );
6024 notebook->AddPage( panelMPR3D, _T("MPR 3D - Clipping") );
6027 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageBChanged );
6029 wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
6030 wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
6031 wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
6032 sizerH1->Add(iren2 , 1, wxALL|wxEXPAND, 2);
6033 sizerH1->Add(iren0 , 1, wxALL|wxEXPAND, 2);
6034 sizerH2->Add(iren1 , 1, wxALL|wxEXPAND, 2);
6035 // sizerH2->Add(iren3 , 1, wxALL|wxEXPAND, 2);
6036 sizerH2->Add(notebook , 1, wxALL|wxEXPAND, 2);
6038 sizerV->Add(sizerH1, 1, wxALL|wxEXPAND, 0);
6039 sizerV->Add(sizerH2, 1, wxALL|wxEXPAND, 0);
6041 panel->SetAutoLayout(true);
6042 panel->SetSizer(sizerV);
6043 panel->SetSize(400,400);
6048 //----------------------------------------------------------------------------
6049 void wxMPRWidget::OnCutImagaData(wxCommandEvent &event)
6051 if (_btnCutImageData->GetValue()==true){
6053 _framePanelCutting = new wxFrame(this,-1,_T("Cutting Module"),wxDefaultPosition,wxDefaultSize,wxCAPTION|wxSTAY_ON_TOP| wxRESIZE_BORDER );
6055 _framePanelCutting->SetSize(550,400);
6057 _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
6058 if(_wxvtk3Dbaseview_Clipping3D_BB!=NULL){
6059 _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
6061 _panelCutting->SetVtkMPRBaseData( GetVtkMPRBaseData() );
6062 _panelCutting->SetVtkClipping3DDataViewer( this->_wxvtkclipping3Dview_BB->GetVtkClipping3DDataViewer() );
6063 _panelCutting->Configure( );
6065 wxBoxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL );
6066 topsizer -> Add( _panelCutting ,1,wxALL ,0);
6067 _framePanelCutting->SetAutoLayout(true);
6068 _framePanelCutting->SetSizer( topsizer ); // use the sizer for layout
6069 _framePanelCutting->Layout();
6071 // _framePanelCutting->FitInside();
6073 _framePanelCutting->Show();
6077 if (_framePanelCutting!=NULL){
6078 _panelCutting->RemoveActors();
6079 _framePanelCutting->Destroy();
6080 _framePanelCutting=NULL;
6086 //----------------------------------------------------------------------------
6087 void wxMPRWidget::ConfigureVTK(){
6090 if (_vtkmprbasedata!=NULL)
6092 _vtkmprbasedata->Configure();
6093 x=_vtkmprbasedata -> GetMaxPositionX()/2;
6094 y=_vtkmprbasedata -> GetMaxPositionY()/2;
6095 z=_vtkmprbasedata -> GetMaxPositionZ()/2;
6096 _vtkmprbasedata->SetX( x );
6097 _vtkmprbasedata->SetY( y );
6098 _vtkmprbasedata->SetZ( z );
6102 if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
6103 if(_vtkmpr2Dview[1]!=NULL) {_vtkmpr2Dview[1] -> Configure();}
6104 if(_vtkmpr2Dview[2]!=NULL) {_vtkmpr2Dview[2] -> Configure();}
6107 if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0] -> Configure(); }
6108 if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1] -> Configure(); }
6109 if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
6114 if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
6115 if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
6116 if (_widgetMesure!=NULL){_widgetMesure -> SetActiveLink(true);}
6117 if (_widgetMesure!=NULL){_widgetMesure -> SetMesureScale( _voxelSize );}
6118 if (_wxsphereview!=NULL){_wxsphereview -> Configure();}
6120 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D -> Configure();}
6121 if (_wxvtkmpr3Dview!=NULL){
6122 _wxvtkmpr3Dview -> Configure();
6124 if (_wxvtkclipping3Dview!=NULL){_wxvtkclipping3Dview -> Configure();}
6126 if (_vtkplane2Dview_B!=NULL){ _vtkplane2Dview_B -> Configure(); }
6127 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> ConfigureA( _vtkplane2Dview_B ); }
6128 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> SetActiveLink(true); }
6132 // vtkImageData *imageData = _vtkmprbasedata->GetImageData();
6133 // imageData->Update();
6134 // imageData->GetSpacing(spc);
6135 // _widgetMesure_B->SetMesureScale(spc[0]);
6137 if (_widgetMesure_B!=NULL) {_widgetMesure_B->SetMesureScale( _voxelSize );}
6140 if (_wxsphereview_B!=NULL) {_wxsphereview_B -> Configure();}
6142 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) {_wxvtk3Dbaseview_MPR3D_B -> Configure();}
6143 if (_wxvtkmpr3Dview_B!=NULL) {_wxvtkmpr3Dview_B -> Configure();}
6145 if ( _wxvtk3Dbaseview_Clipping3D_BB!=NULL) {_wxvtk3Dbaseview_Clipping3D_BB -> Configure(); }
6146 if ( _wxvtkmpr3Dview_BB!=NULL) {_wxvtkmpr3Dview_BB -> Configure(); }
6147 if ( _wxvtkclipping3Dview_BB!=NULL) {_wxvtkclipping3Dview_BB -> Configure(); }
6150 vtkInteractorStyle3DView *vtkinteractorstyle3Dview;
6151 if (_wxvtkmpr3Dview_BB!=NULL)
6153 vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
6154 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_BB);
6155 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_BB);
6158 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL)
6160 _wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
6164 // RefreshView(true);
6168 //----------------------------------------------------------------------------
6170 void wxMPRWidget::OnRefreshView(wxCommandEvent & event)
6174 //----------------------------------------------------------------------------
6175 void wxMPRWidget::OnDClickLeft(wxCommandEvent & event)
6177 if (_wxsphereview!=NULL) {
6178 _wxsphereview -> RefreshPoint();
6180 if (_wxsphereview_B!=NULL) {
6181 _wxsphereview_B -> RefreshPoint();
6184 //----------------------------------------------------------------------------
6185 void wxMPRWidget::RefreshView(bool firsttime){
6187 if (_refreshAPage == 0 )
6190 if ((_vtkmpr2Dview[0]!=NULL) && (_vtkmpr2Dview[1]!=NULL) && (_vtkmpr2Dview[2]!=NULL) )
6192 _vtkmpr2Dview[2] -> Refresh();
6193 _vtkmpr2Dview[1] -> Refresh();
6194 _vtkmpr2Dview[0] -> Refresh();
6196 if (firsttime==false)
6198 _vtkmpr2Dview[2] -> RefreshView();
6199 _vtkmpr2Dview[1] -> RefreshView();
6200 _vtkmpr2Dview[0] -> RefreshView();
6203 if (_refreshBPage == 0 )
6205 if (_vtkplane2Dview!=NULL)
6207 _vtkplane2Dview -> Refresh();
6208 if (firsttime==false)
6210 _vtkplane2Dview -> RefreshView();
6212 // _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6215 if (_refreshBPage == 1 )
6219 if (_refreshBPage == 2 )
6221 if ((_wxvtkmpr3Dview!=NULL) && (_wxvtk3Dbaseview_MPRClipping3D!=NULL) && (_wxvtkclipping3Dview!=NULL) )
6223 _wxvtkmpr3Dview -> RefreshView();
6224 _wxvtk3Dbaseview_MPRClipping3D -> Refresh();
6225 _wxvtkclipping3Dview -> Refresh();
6231 if (_refreshAPage == 1 )
6233 if (_vtkmpr2Dview_B[0] !=NULL){
6234 _vtkmpr2Dview_B[0] -> Refresh();
6237 if (_refreshAPage == 2 )
6239 if (_vtkmpr2Dview_B[1] !=NULL){
6240 _vtkmpr2Dview_B[1] -> Refresh();
6243 if (_refreshAPage == 3 )
6245 if (_vtkmpr2Dview_B[2] !=NULL){
6246 _vtkmpr2Dview_B[2] -> Refresh();
6249 if (_refreshAPage == 4 )
6251 if (_vtkplane2Dview_B!=NULL){
6252 _vtkplane2Dview_B -> Refresh();
6253 if (firsttime==false)
6255 _vtkplane2Dview_B -> RefreshView();
6260 if (_refreshAPage == 5 )
6264 if (_refreshAPage == 6 )
6266 if (_wxvtkmpr3Dview_B!=NULL){
6267 _wxvtkmpr3Dview_B -> Refresh();
6268 _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6271 if (_refreshAPage == 7 )
6273 if (_wxvtkmpr3Dview_BB!=NULL){
6274 _wxvtkmpr3Dview_BB -> RefreshView();
6275 _wxvtkclipping3Dview_BB -> Refresh();
6276 _wxvtk3Dbaseview_Clipping3D_BB -> Refresh();
6277 if (_panelCutting!=NULL)
6279 _panelCutting->RefreshView();
6285 //----------------------------------------------------------------------------
6286 vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
6287 return _vtkmprbasedata;
6289 //----------------------------------------------------------------------------
6290 vtkPlane2DView *wxMPRWidget::GetVtkPlane2DView()
6292 return _vtkplane2Dview;
6294 //----------------------------------------------------------------------------
6295 wxVtkMPR3DView *wxMPRWidget::GetWxvtkmpr3Dview_BB()
6297 return _wxvtkmpr3Dview_BB;
6299 //----------------------------------------------------------------------------
6300 wxVtkBaseView *wxMPRWidget::GetWxVtkBaseView(int page, int id)
6302 wxVtkBaseView *result=NULL;
6305 if ((id>=0) &&(id<=3)){
6306 result=_vtkmpr2Dview[id];
6310 result=_vtkplane2Dview;
6315 //----------------------------------------------------------------------------
6316 wxVtkMPR2DView *wxMPRWidget::GetWxvtkMPR2Dview(int direction)
6318 return _vtkmpr2Dview[direction];
6321 //----------------------------------------------------------------------------
6322 //----------------------------------------------------------------------------
6323 //----------------------------------------------------------------------------
6324 wxMPRWidget2::wxMPRWidget2(wxWindow* parent,marImageData *marimagedata,double voxelSize)
6325 : wxMPRWidget(parent,marimagedata,voxelSize)
6328 //----------------------------------------------------------------------------
6329 wxMPRWidget2::~wxMPRWidget2()
6332 //----------------------------------------------------------------------------
6333 void wxMPRWidget2::OnRefreshView(wxCommandEvent & event) // Virtual
6335 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
6336 this->GetParent()->ProcessEvent(newevent1);
6340 //----------------------------------------------------------------------------
6341 //----------------------------------------------------------------------------
6342 //----------------------------------------------------------------------------
6343 figureCuttingModel::figureCuttingModel()
6345 _inversModel = vtkTransform::New();
6346 _matrixModel = vtkTransform::New();
6347 _matrixVisual = vtkTransform::New();
6353 //----------------------------------------------------------------------------
6354 figureCuttingModel::~figureCuttingModel() // virtual
6356 _inversModel->Delete();
6358 //----------------------------------------------------------------------------
6359 void figureCuttingModel::SetPosition(double x,double y, double z)
6365 //----------------------------------------------------------------------------
6366 void figureCuttingModel::SetScale(double sx,double sy, double sz)
6372 //----------------------------------------------------------------------------
6373 void figureCuttingModel::SetRotation(double alfa,double beta, double teta)
6380 //----------------------------------------------------------------------------
6381 void figureCuttingModel::CalculeMatrix()
6383 _matrixModel->Identity();
6384 _matrixModel->Translate(_px,_py,_pz);
6385 _matrixModel->RotateY(_beta);
6386 _matrixModel->RotateX(_alfa);
6387 _matrixModel->RotateY(_teta);
6388 _matrixModel->Scale(_sx,_sy,_sz);
6390 _matrixVisual->Identity();
6391 _matrixVisual->Translate( _px*_spcX , _py*_spcY , _pz*_spcZ );
6392 _matrixVisual->RotateY(_beta);
6393 _matrixVisual->RotateX(_alfa);
6394 _matrixVisual->RotateY(_teta);
6395 _matrixVisual->Scale( _sx*_spcX , _sy*_spcY , _sz*_spcZ );
6400 //----------------------------------------------------------------------------
6401 void figureCuttingModel::CalculeInversMatrix()
6403 _inversModel->Identity ();
6404 _inversModel->Concatenate ( _matrixModel );
6405 _inversModel->Inverse();
6407 //----------------------------------------------------------------------------
6408 bool figureCuttingModel::IfPointInside(double x, double y, double z) // virtual
6413 //----------------------------------------------------------------------------
6414 vtkTransform *figureCuttingModel::GetVtkTransform()
6416 return _matrixVisual;
6419 //----------------------------------------------------------------------------
6420 //void figureCuttingModel::SetVtkTransform(vtkTransform *matrix)
6422 // _matrixModel = matrix;
6425 //----------------------------------------------------------------------------
6426 double figureCuttingModel::GetTheoricVolume() // virtual
6431 //----------------------------------------------------------------------------
6432 double figureCuttingModel::GetPositionX()
6436 //----------------------------------------------------------------------------
6437 double figureCuttingModel::GetPositionY()
6441 //----------------------------------------------------------------------------
6442 double figureCuttingModel::GetPositionZ()
6446 //----------------------------------------------------------------------------
6447 double figureCuttingModel::GetScaleX()
6451 //----------------------------------------------------------------------------
6452 double figureCuttingModel::GetScaleY()
6456 //----------------------------------------------------------------------------
6457 double figureCuttingModel::GetScaleZ()
6461 //----------------------------------------------------------------------------
6462 double figureCuttingModel::GetAngleAlfa()
6466 //----------------------------------------------------------------------------
6467 double figureCuttingModel::GetAngleBeta()
6471 //----------------------------------------------------------------------------
6472 double figureCuttingModel::GetAngleTeta()
6476 //----------------------------------------------------------------------------
6477 char *figureCuttingModel::GetName() // virtual
6482 //----------------------------------------------------------------------------
6483 void figureCuttingModel::SetSpacing(double spcX,double spcY, double spcZ)
6490 //----------------------------------------------------------------------------
6493 //----------------------------------------------------------------------------
6494 //----------------------------------------------------------------------------
6495 //----------------------------------------------------------------------------
6496 figureCuttingSphereModel::figureCuttingSphereModel()
6499 //----------------------------------------------------------------------------
6500 figureCuttingSphereModel::~figureCuttingSphereModel() // virtual
6503 //----------------------------------------------------------------------------
6504 bool figureCuttingSphereModel::IfPointInside(double x, double y, double z) // virtual
6506 double in[4],out[4];
6511 _inversModel->MultiplyPoint (in, out);
6514 if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
6520 //----------------------------------------------------------------------------
6521 double figureCuttingSphereModel::GetTheoricVolume() // virtual
6523 double piTMP=3.14159265;
6524 return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
6526 //----------------------------------------------------------------------------
6527 char *figureCuttingSphereModel::GetName() // virtual
6533 //----------------------------------------------------------------------------
6534 //----------------------------------------------------------------------------
6535 //----------------------------------------------------------------------------
6536 figureCuttingCubeModel::figureCuttingCubeModel()
6539 //----------------------------------------------------------------------------
6540 figureCuttingCubeModel::~figureCuttingCubeModel() // virtual
6543 //----------------------------------------------------------------------------
6544 bool figureCuttingCubeModel::IfPointInside(double x, double y, double z) // virtual
6546 double in[4],out[4];
6551 _inversModel->MultiplyPoint (in, out);
6554 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) )
6560 //----------------------------------------------------------------------------
6561 double figureCuttingCubeModel::GetTheoricVolume() // virtual
6563 return _sx * _sy * _sz;
6566 //----------------------------------------------------------------------------
6567 char *figureCuttingCubeModel::GetName() // virtual
6572 //----------------------------------------------------------------------------
6573 //----------------------------------------------------------------------------
6574 //----------------------------------------------------------------------------
6576 figureCuttingCylinderModel::figureCuttingCylinderModel()
6579 //----------------------------------------------------------------------------
6580 figureCuttingCylinderModel::~figureCuttingCylinderModel() // virtual
6583 //----------------------------------------------------------------------------
6584 bool figureCuttingCylinderModel::IfPointInside(double x, double y, double z) // virtual
6586 double in[4],out[4];
6591 _inversModel->MultiplyPoint (in, out);
6594 if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 ) && (out[1]>-0.5) && (out[1]<0.5) )
6600 //----------------------------------------------------------------------------
6601 double figureCuttingCylinderModel::GetTheoricVolume() // virtual
6603 double piTMP=3.14159265;
6604 return piTMP*(_sx/2)*(_sz/2)*_sy;
6606 //----------------------------------------------------------------------------
6607 char *figureCuttingCylinderModel::GetName() // virtual
6611 //----------------------------------------------------------------------------
6615 // EOF - wxMPRWidget.cxx