1 /*=========================================================================
4 Module: $RCSfile: wxMPRWidget.cxx,v $
6 Date: $Date: 2009/04/23 10:15:56 $
7 Version: $Revision: 1.10 $
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>
72 #include "pPlotter/HistogramDialog.h"
74 //-------------------------------------------------------------------
75 //-------------------------------------------------------------------
76 //-------------------------------------------------------------------
78 idAlBeRa::idAlBeRa(int id, double radio,int deltavoxel)
82 _deltavoxel = deltavoxel;
86 //-------------------------------------------------------------------
87 //-------------------------------------------------------------------
88 //-------------------------------------------------------------------
90 vtkInteractorStyleSphere::vtkInteractorStyleSphere()
96 //---------------------------------------------------------------------------
98 vtkInteractorStyleSphere::~vtkInteractorStyleSphere()
103 //---------------------------------------------------------------------------
105 bool vtkInteractorStyleSphere::OnRightButtonDown()
107 if ((_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) && (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
110 //_fordwareX = this->Interactor->GetEventPosition()[0];
111 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
113 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
115 _radio = wxsphereview->GetRadio();
121 //---------------------------------------------------------------------------
123 bool vtkInteractorStyleSphere::OnRightButtonUp()
125 if (_stateRadio==true)
127 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
128 wxsphereview->SetDeltaVoxel(1);
129 double radio=wxsphereview->GetRadio();
130 wxsphereview->GetIdOfImage(radio+0.1);
131 wxsphereview->GetIdOfImage(radio+0.2);
132 wxsphereview->GetIdOfImage(radio-0.1);
133 wxsphereview->GetIdOfImage(radio-0.2);
135 wxsphereview->RefreshView();
141 //---------------------------------------------------------------------------
143 bool vtkInteractorStyleSphere::OnLeftButtonDown()
146 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
147 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
152 //---------------------------------------------------------------------------
154 bool vtkInteractorStyleSphere::OnLeftButtonUp()
156 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
157 if (_stateRotate==true){
158 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
159 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
161 if ((_fordwareX==fx)&&(_fordwareY==fy)){
162 double x=fx,y=fy,z=1;
163 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
164 wxsphereview->SetXYZtoParent(x,y);
165 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121);
166 wxsphereview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent);
168 wxsphereview->RotationEnd();
170 wxsphereview->RefreshView();
171 _stateRotate = false;
178 //---------------------------------------------------------------------------
180 bool vtkInteractorStyleSphere::OnMouseMove ()
182 wxSphereView *wxsphereview = (wxSphereView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
183 if (_stateRotate==true)
188 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
192 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
196 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
197 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
198 wxsphereview->RotationStart( fx - _fordwareX , -(fy - _fordwareY) , ok_v, ok_ang);
199 wxsphereview->RefreshView();
201 if (_stateRadio==true)
203 //int fx = this->Interactor->GetEventPosition()[0];
204 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
205 double dif=(fy-_fordwareY) / 10.0;
206 wxsphereview->SetRadio( _radio + dif );
207 wxsphereview->SetDeltaVoxel(3);
208 wxsphereview->RefreshView();
216 //-------------------------------------------------------------------
217 //-------------------------------------------------------------------
218 //-------------------------------------------------------------------
220 wxSphereView::wxSphereView( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata, vtkImageData *imageData )
221 : wxVtk2DBaseView(parent)
224 _vtkmprbasedata = vtkmprbasedata;
225 _imageDataOriginal = imageData;
227 _imageSphere = vtkImageData::New();
228 _imageSphere->SetDimensions (150,150,500);
229 _imageSphere->SetScalarTypeToUnsignedShort();
230 _imageSphere->AllocateScalars();
231 _imageSphere->Update();
234 vtkBaseData *vtkbasedata = new vtkBaseData();
235 vtkbasedata->SetMarImageData( new marImageData(_imageSphere) );
236 this->SetVtkBaseData(vtkbasedata);
238 _transform = vtkTransform::New();
239 _transform1 = vtkTransform::New();
240 _transform2 = vtkTransform::New();
241 _transform ->Identity();
242 _transform1->Identity();
243 _transform2->Identity();
248 //-------------------------------------------------------------------
250 wxSphereView::~wxSphereView()
252 _transform -> Delete();
253 _transform1 -> Delete();
254 _transform2 -> Delete();
258 //----------------------------------------------------------------------------
260 double wxSphereView::GetRadio()
265 //----------------------------------------------------------------------------
267 void wxSphereView::SetRadio(double radio)
276 //----------------------------------------------------------------------------
278 void wxSphereView::Configure()
280 wxVtk2DBaseView::Configure();
282 _vtkinteractorstylesphere = new vtkInteractorStyleSphere();
283 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _vtkinteractorstylesphere );
286 // EED purify 12/sep/2006
300 //----------------------------------------------------------------------------
302 void wxSphereView::RefreshPoint()
304 double x = _vtkmprbasedata->GetX() - _centerX;
305 double y = _vtkmprbasedata->GetY() - _centerY;
306 double z = _vtkmprbasedata->GetZ() - _centerZ;
307 double alpha= atan2(x,z);
308 double beta = atan2( y , sqrt(z*z+x*x) );
310 alpha = alpha*180/3.1416;
311 beta = beta*180/3.1416;
313 _transform1->Identity();
314 _transform1->RotateY(alpha);
315 _transform1->RotateX(-beta);
317 _radio= sqrt(x*x + y*y +z*z);
322 //----------------------------------------------------------------------------
324 void wxSphereView::RefreshView()
327 wxVtk2DBaseView::Refresh();
330 //----------------------------------------------------------------------------
332 void wxSphereView::RotationEnd()
334 _transform1->RotateWXYZ(_ang,_vxb,_vyb,0);
335 _transform2->Identity();
340 //----------------------------------------------------------------------------
342 void wxSphereView::RotationStart(double vx, double vy, bool ok_v, bool ok_ang)
346 _ang = -sqrt( vx*vx + vy*vy ) / 1.0;
354 _transform2->Identity();
355 _transform2->RotateWXYZ(_ang,_vxb,_vyb,0);
360 //----------------------------------------------------------------------------
362 void wxSphereView::GetPointSphere(double p[3],double r1,double angA,double angB)
368 vtkTransform *transform = vtkTransform::New();
369 transform->Identity();
370 transform->RotateX(angB);
371 transform->RotateZ(angA);
372 transform->TransformPoint(in,out);
379 //----------------------------------------------------------------------------
381 void wxSphereView::RotatePointOverTheSphere( double pp[3], double p[3],double cc[3])
385 _transform->TransformPoint(p,out);
386 pp[0] = out[0] + cc[0];
387 pp[1] = out[1] + cc[1];
388 pp[2] = out[2] + cc[2];
392 //----------------------------------------------------------------------------
394 void wxSphereView::TransferePoints(double pp1[3],double pp2[3],double AngX,double AngY,vtkImageData *image)
397 double difX = pp2[0]-pp1[0];
398 double difY = pp2[1]-pp1[1];
399 double difZ = pp2[2]-pp1[2];
406 _imageDataOriginal->GetDimensions(dimOrg);
407 image->GetDimensions(dimRes);
413 int xx=-1,yy=-1,zz=-1;
418 xx = (int) (x1+t*difX);
419 yy = (int) (y1+t*difY);
420 zz = (int) (z1+t*difZ);
423 if ((xx>=0) && (xx<dimOrg[0]) && (yy>=0) && (yy<dimOrg[1]) && (zz>=0) && (zz<dimOrg[2]) &&
424 (AngX>=0) && (AngX<dimRes[0]) && (AngY>=0) && (AngY<dimRes[1]) && (z>=0) && (z<dimRes[2]) )
426 unsigned short *pOrg=(unsigned short*)_imageDataOriginal->GetScalarPointer (xx,yy,zz);
427 unsigned short *pRes=(unsigned short*)image->GetScalarPointer( (int)AngX , (int)AngY , z );
433 //----------------------------------------------------------------------------
435 void wxSphereView::ResetlstId()
437 int i,size=_lstId.size();
438 for (i=size-1;i>=0;i--)
445 //----------------------------------------------------------------------------
447 int wxSphereView::GetIdOfImage(double radio)
451 _imageSphere->GetDimensions(dim);
452 int sizeMaxList = dim[2];
453 // Search in list >> alpha beta radio
454 int i,size=_lstId.size();
455 for (i=0; i<size;i++)
457 //idAlBeRa *tmp=_lstId[i]; // JPRx
458 if ((_lstId[i]->_radio==radio) && (_lstId[i]->_deltavoxel==_delta))
460 return _lstId[i]->_id;
463 if (size>sizeMaxList)
465 delete _lstId[size-1];
470 id = id % sizeMaxList;
475 FiltreImage(id,radio);
476 _lstId.insert(_lstId.begin(),1,new idAlBeRa(id,radio,_delta) );
481 //----------------------------------------------------------------------------
483 void wxSphereView::DefineImageSphere()
486 id=GetIdOfImage( _radio );
487 GetVtkBaseData()->SetZ( id );
491 //----------------------------------------------------------------------------
492 void wxSphereView::SetDeltaVoxel(int delta)
497 //----------------------------------------------------------------------------
498 void wxSphereView::SetVoxel(double i, double j, int delta,double id, unsigned short gris)
501 unsigned short *pRes;
503 _imageSphere->GetDimensions(dimRes);
506 for ( ii=(int)(i-delta2) ; ii<=(int)(i+delta2) ; ii++ )
508 for ( jj=(int)(j-delta2) ; jj<=(int)(j+delta2) ; jj++ )
510 if ( (ii>=0)&&(ii<dimRes[0]) &&
511 (jj>=0)&&(jj<dimRes[1]) )
513 pRes = (unsigned short*)_imageSphere->GetScalarPointer( ii , jj , (int)id );
521 //----------------------------------------------------------------------------
523 void wxSphereView::SetXYZtoParent(double i, double j)
526 double factor = 0.75;
527 double radio2 = _radio*_radio;
528 double pxx,pyy,d2x,d2y;
529 double cc[3],p[3],pp[3];
534 int dimRes[3],dimOrig[3];
535 _imageSphere->GetDimensions(dimRes);
538 _imageDataOriginal->GetDimensions(dimOrig);
540 p[0] = (i - d2x)*factor;
542 p[1] = (j - d2y)*factor;
548 RotatePointOverTheSphere( pp, p,cc);
549 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
550 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
551 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
553 if (_vtkmprbasedata){
554 _vtkmprbasedata->SetX(pp[0]);
555 _vtkmprbasedata->SetY(pp[1]);
556 _vtkmprbasedata->SetZ(pp[2]);
563 //----------------------------------------------------------------------------
565 void wxSphereView::FiltreImageB(int id, double radio, bool ok,int deltaTMP)
567 double factor = 0.75;
568 double radioB = radio/3;
569 double radio2 = radio*radio;
570 double pxx,pyy,d2x,d2y;
571 double cc[3],p[3],pp[3];
576 unsigned short *pOrig;
577 int dimRes[3],dimOrig[3];
579 _imageSphere->GetDimensions(dimRes);
580 _imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
583 // double deltaTMP=_delta;
584 _imageDataOriginal->GetDimensions(dimOrig);
588 limitA = (int) ( (-radioB/factor)+d2x );
589 limitB = (int) ( (radioB/factor)+d2x );
598 for ( i=start ; i<end ; i=i+deltaTMP )
600 p[0] = (i - d2x)*factor;
602 for (j=start;j<end;j=j+deltaTMP)
604 p[1] = (j - d2y)*factor;
608 if (( ((ok==false) && (!((i>limitA) && (i<limitB) && (j>limitA) && (j<limitB)))) )
615 RotatePointOverTheSphere( pp, p,cc);
616 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
617 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
618 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
620 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( (int)(pp[0]) , (int)(pp[1]) , (int)(pp[2]) );
621 SetVoxel(i,j,deltaTMP,id,*pOrig);
623 SetVoxel(i,j,deltaTMP,id,2000);
626 SetVoxel(i,j,deltaTMP,id,0);
632 _imageSphere->Modified();
633 _imageSphere->Update();
639 //----------------------------------------------------------------------------
641 void wxSphereView::FiltreImage(int id, double radio)
644 _transform -> Identity();
645 _transform -> Concatenate(_transform1);
646 _transform -> Concatenate(_transform2);
648 FiltreImageB(id,radio,false, _delta);
649 FiltreImageB(id,radio,true, 1);
653 //----------------------------------------------------------------------------
656 void wxSphereView::FiltreImage(int id, double radio)
658 double radio2 = radio*radio;
659 double radio2TMP= (radio/2)*(radio/2);
660 double pxx,pyy,d2x,d2y;
661 double cc[3],p[3],pp[3];
666 unsigned short *pOrig;
667 int dimRes[3],dimOrig[3];
669 _imageSphere->GetDimensions(dimRes);
670 _imageSphere->SetExtent(0,dimRes[0]-1,0,dimRes[1]-1,0,dimRes[2]-1);
673 double deltaTMP=_delta;
674 _imageDataOriginal->GetDimensions(dimOrig);
676 for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
678 p[0] = (i - d2x)*0.75;
680 for (j=0;j<dimRes[1];j=j+deltaTMP)
682 p[1] = (j - d2y)*0.75;
691 RotatePointOverTheSphere( pp, p,cc);
692 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
693 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
694 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
696 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
697 SetVoxel(i,j,deltaTMP,id,*pOrig);
699 SetVoxel(i,j,deltaTMP,id,2000);
702 SetVoxel(i,j,deltaTMP,id,0);
710 for ( i=0 ; i<dimRes[0] ; i=i+deltaTMP )
712 p[0] = (i - d2x)*0.75;
714 for (j=0;j<dimRes[1];j=j+deltaTMP)
716 p[1] = (j - d2y)*0.75;
724 RotatePointOverTheSphere( pp, p,cc);
725 if ( (pp[0]>=0) && (pp[0]<dimOrig[0]) &&
726 (pp[1]>=0) && (pp[1]<dimOrig[1]) &&
727 (pp[2]>=0) && (pp[2]<dimOrig[2]) )
729 pOrig=(unsigned short*)_imageDataOriginal->GetScalarPointer( pp[0] , pp[1] , pp[2] );
730 SetVoxel(i,j,deltaTMP,id,*pOrig);
732 SetVoxel(i,j,deltaTMP,id,2000);
735 SetVoxel(i,j,deltaTMP,id,0);
741 _imageSphere->Modified();
742 _imageSphere->Update();
746 void wxSphereView::FiltreImage(vtkImageData *imageSphere)
749 imageSphere->GetDimensions(dim);
750 for (i=0;i<dim[0];i++)
752 for (j=0;j<dim[1];j++)
754 for (k=0;k<dim[2];k++)
756 unsigned short *pRes=(unsigned short*)imageSphere->GetScalarPointer (i,j,k);
763 double cc[3],p1[3],p2[3],pp1[3],pp2[3];
767 double r1 = _sl_radio->GetValue() - _sl_thickness->GetValue()/2;
768 double r2 = _sl_radio->GetValue() + _sl_thickness->GetValue()/2;
773 double alpha= _sl_alpha->GetValue();
774 double beta = _sl_beta->GetValue();
777 for (angA=-deltaA;angA<deltaA;angA++)
779 for (angB=-deltaA;angB<deltaA;angB++)
781 GetPointSphere(p1,r1,angA,angB);
782 GetPointSphere(p2,r2,angA,angB);
783 RotatePointOverTheSphere( pp1, alpha, beta, p1 ,cc );
784 RotatePointOverTheSphere( pp2, alpha, beta, p2 ,cc );
785 TransferePoints(pp1,pp2,angA+alpha+180,angB+beta+90,imageSphere);
792 //----------------------------------------------------------------------------
794 void wxSphereView::InitSphere(double points[4][3])
797 double r = SphereFindCenter(points,cc); // 4-points , center
800 _centerX = (int)(cc[0]);
801 _centerY = (int)(cc[1]);
802 _centerZ = (int)(cc[2]);
805 _imageDataOriginal->GetDimensions(dim);
806 _centerX = (int)(dim[0]/2);
807 _centerY = (int)(dim[1]/2);
808 _centerZ = (int)(dim[2]/2);
812 //----------------------------------------------------------------------------
814 // Calculate center and radius of sphere given four points
815 // http://home.att.net/~srschmitt/script_sphere_solver.html
816 // source code HTML <script language=JavaScript>
817 double wxSphereView::SphereFindCenter(double P[4][3], double cc[3])
820 double r, m11, m12, m13, m14, m15;
823 for (i = 0; i < 4; i++) // find minor 11
830 m11 = determinant( a, 4 );
832 for (i = 0; i < 4; i++) // find minor 12
834 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
839 m12 = determinant( a, 4 );
841 for (i = 0; i < 4; i++) // find minor 13
843 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
848 m13 = determinant( a, 4 );
850 for (i = 0; i < 4; i++) // find minor 14
852 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
857 m14 = determinant( a, 4 );
860 for (i = 0; i < 4; i++) // find minor 15
862 a[i][0] = P[i][0]*P[i][0] + P[i][1]*P[i][1] + P[i][2]*P[i][2];
867 m15 = determinant( a, 4 );
876 cc[0] = 0.5*m12/m11; //cx
877 cc[1] = -0.5*m13/m11; //cy
878 cc[2] = 0.5*m14/m11; //cz
880 r = sqrt( cc[0]*cc[0] + cc[1]*cc[1] + cc[2]*cc[2] - m15/m11 );
883 return r; // the radius
885 //----------------------------------------------------------------------------
887 // Recursive definition of determinate using expansion by minors.
888 double wxSphereView::determinant(double a[4][4], int n)
902 if (n == 2) // terminate recursion
904 d = a[0][0]*a[1][1] - a[1][0]*a[0][1];
909 for (j1 = 0; j1 < n; j1++ ) // do each column
911 for (i = 1; i < n; i++) // create minor
914 for (j = 0; j < n; j++)
916 if (j == j1) continue;
917 m[i-1][j2] = a[i][j];
922 // sum (+/-)cofactor * minor
923 d = d + pow(-1.0, j1)*a[0][j1]*determinant( m, n-1 );
933 //-------------------------------------------------------------------
934 //-------------------------------------------------------------------
935 //-------------------------------------------------------------------
937 vtkInteractorStylePlane2D::vtkInteractorStylePlane2D()
941 //---------------------------------------------------------------------------
942 vtkInteractorStylePlane2D::~vtkInteractorStylePlane2D()
946 //---------------------------------------------------------------------------
947 bool vtkInteractorStylePlane2D::GetStateRotate()
952 //---------------------------------------------------------------------------
953 bool vtkInteractorStylePlane2D::OnLeftButtonDown() // vitual
956 _fordwareX = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
957 _fordwareY = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
958 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
959 vtkplane2Dview->RotationStart();
964 //---------------------------------------------------------------------------
965 bool vtkInteractorStylePlane2D::OnLeftButtonUp() // virtual
967 if (_stateRotate==true)
969 _stateRotate = false;
970 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
971 vtkplane2Dview->ResetBack();
972 // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
978 //---------------------------------------------------------------------------
979 bool vtkInteractorStylePlane2D::OnRightButtonUp() // virtual
981 if (_stateRotate==true){
982 //vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()); // JPRx
985 // vtkplane2Dview->RotationEnd();
987 _stateRotate = false;
992 //---------------------------------------------------------------------------
993 bool vtkInteractorStylePlane2D::OnMouseMove () // virtual
996 if (_stateRotate==true){
999 if (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==1)
1003 if (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==1)
1007 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1008 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1009 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1010 vtkplane2Dview->RotationDrag( fx - _fordwareX , fy - _fordwareY , ok_v , ok_ang);
1011 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1015 //-------------------------------------------------------------------
1016 bool vtkInteractorStylePlane2D::OnLeftDClick() // virtual
1018 int fx = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1019 int fy = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1024 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1025 vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
1027 vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
1029 vtkmprbasedata->SetX( xx );
1030 vtkmprbasedata->SetY( yy );
1031 vtkmprbasedata->SetZ( zz );
1032 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1036 //-------------------------------------------------------------------
1037 //-------------------------------------------------------------------
1038 //-------------------------------------------------------------------
1040 vtkPlane2DView::vtkPlane2DView( wxWindow *parent)
1041 : wxVtk2DBaseView(parent)
1048 _backOrient[0] = -99999;
1049 _backOrient[1] = -99999;
1050 _backOrient[2] = -99999;
1051 _backOrient[3] = -99999;
1054 _mip_visualization = true;
1057 _transform1 = vtkTransform::New();
1058 _transform2 = vtkTransform::New();
1059 _transform1->Identity();
1060 _transform2->Identity();
1068 _imageResult = NULL;
1076 _interactorstyleplane2D = false;
1078 //-------------------------------------------------------------------
1079 vtkPlane2DView::~vtkPlane2DView()
1084 if (_pts != NULL) { _pts -> Delete(); }
1085 if (_lineActor != NULL) { _lineActor -> Delete(); }
1086 if (_lineMapper != NULL) { _lineMapper -> Delete(); }
1087 if (_pd != NULL) { _pd -> Delete(); }
1089 _transform1 -> Delete();
1090 _transform2 -> Delete();
1093 //-------------------------------------------------------------------
1094 void vtkPlane2DView::ResetBack()
1105 //-------------------------------------------------------------------
1106 void vtkPlane2DView::ResetPlane(){
1107 if (_pSource !=NULL) { _pSource -> Delete(); }
1108 if (_3Dslices !=NULL) { _3Dslices -> Delete(); }
1109 if (_stPoints !=NULL) { _stPoints -> Delete(); }
1110 if (_change !=NULL) { _change -> Delete(); }
1112 //-------------------------------------------------------------------
1113 vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
1115 return (vtkMPRBaseData*)GetVtkBaseData();
1118 //-------------------------------------------------------------------
1119 void vtkPlane2DView::SetPSource(int sizeIma){
1120 int dimIma = sizeIma;
1122 double x = GetVtkmprbasedata()->GetX();
1123 double y = GetVtkmprbasedata()->GetY();
1124 double z = GetVtkmprbasedata()->GetZ();
1127 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1128 imagedata->GetSpacing(spc);
1134 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1135 vtkTransform *transform = mprbasedata->GetTransformOrientation();
1137 double in[3]; // temp
1140 in[0]=1; in[1]=0; in[2]=0;
1141 transform->TransformPoint(in,_n);
1143 in[0]=0; in[1]=dimIma-1; in[2] = 0;
1144 transform->TransformPoint(in,pA);
1146 in[0]=0; in[1]=0; in[2]=dimIma-1;
1147 transform->TransformPoint(in,pB);
1149 _pSource -> SetPoint1( pA );
1150 _pSource -> SetPoint2( pB );
1152 _pSource -> SetOrigin( 0 , 0 , 0 );
1153 _pSource -> SetResolution( sizeIma-1 , sizeIma -1 );
1154 _pSource -> Update();
1155 _pSource -> SetCenter( x, y, z );
1156 _pSource -> SetNormal( _n );
1157 _pSource -> Update( );
1160 // transform->Delete();
1164 //-------------------------------------------------------------------
1165 void vtkPlane2DView::ExtractPlane()
1168 double x = GetVtkmprbasedata()->GetX();
1169 double y = GetVtkmprbasedata()->GetY();
1170 double z = GetVtkmprbasedata()->GetZ();
1173 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1174 imagedata->GetSpacing(spc);
1179 vtkTransform *transform = GetVtkmprbasedata()->GetTransformOrientation();
1180 double orientation[4];
1181 transform->GetOrientationWXYZ(orientation);
1183 bool okOrientation=true;
1184 if ((orientation[0]!=_backOrient[0]) || (orientation[1]!=_backOrient[1]) ||
1185 (orientation[2]!=_backOrient[2]) || (orientation[3]!=_backOrient[3]))
1187 okOrientation=false;
1190 bool okPosicion=true;
1191 if ( (x!=_backX) || (y!=_backY) || (z!=_backZ) )
1196 if ((okPosicion==false) || (okOrientation==false) ) {
1201 if ( _mip_visualization==true )
1203 if (_interactorstyleplane2D!=NULL)
1205 if (_interactorstyleplane2D->GetStateRotate()==false )
1215 Extract_MIP_PlaneVTK();
1217 Extract_One_PlaneVTK();
1224 _backOrient[0]=orientation[0];
1225 _backOrient[1]=orientation[1];
1226 _backOrient[2]=orientation[2];
1227 _backOrient[3]=orientation[3];
1228 } //okPosition okOrientation
1231 //-------------------------------------------------------------------
1233 void vtkPlane2DView::Extract_One_PlaneVTK()
1235 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1236 SetPSource(_sizeIma);
1237 _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
1238 _3Dslices -> SetSource( imagedata );
1239 _3Dslices -> Update( );
1240 _stPoints -> GetPointData( )->SetScalars( _3Dslices->GetOutput()->GetPointData()->GetScalars() );
1241 _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
1242 _stPoints -> SetScalarType( imagedata->GetScalarType() );
1243 _stPoints -> SetScalarTypeToShort();
1244 _stPoints -> Update();
1245 // _change -> SetInput( _stPoints );
1246 // _change -> Update(); //important
1247 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
1248 // _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
1249 // vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
1252 //-------------------------------------------------------------------
1254 void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
1259 int sizeWidth = (_mip_width*2)+1 ;
1261 int iWidth,itmp,tmpSizeWith;
1264 vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
1265 SetPSource(_sizeIma);
1266 imagedata->GetSpacing(spc);
1268 bool heightDefinition=false;
1271 heightDefinition=true;
1274 if (heightDefinition==true)
1276 mipWidth = _mip_width;
1281 tmpSizeWith = (mipWidth*2) + 1;
1282 sp = (spc[0]*sizeWidth)/tmpSizeWith;
1283 sizeWidth = tmpSizeWith;
1289 std::vector< vtkProbeFilter* > slicesLST;
1291 _pSource->Push( -mipWidth * sp );
1294 for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
1296 vtkProbeFilter *slice = vtkProbeFilter::New();
1297 slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
1298 slice -> SetSource( imagedata );
1300 slicesLST.push_back( slice );
1301 _pSource->Push( sp );
1304 if (_imageResult ==NULL)
1306 _imageResult = vtkImageData::New();
1307 _imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
1308 _imageResult -> SetSpacing(1,1,1);
1309 _imageResult -> SetScalarType( imagedata->GetScalarType() );
1310 _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
1311 _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
1312 _imageResult -> AllocateScalars();
1313 _imageResult -> Update();
1316 unsigned short *pTemp;
1317 unsigned short *pResult;
1318 pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
1320 int iPixels , sizePixels = _sizeIma*_sizeIma;
1321 for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
1324 pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
1326 pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 );
1327 pResult[iPixels] = pTemp[iPixels];
1329 for (iWidth=1;iWidth<sizeWidth;iWidth++)
1331 pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
1333 if (pResult[iPixels]< pTemp[iPixels])
1335 pResult[iPixels] = pTemp[iPixels];
1341 for (itmp=1;itmp<deltaPixel;itmp++)
1343 pResult[iPixels+itmp] = pResult[iPixels];
1349 for (iWidth=0;iWidth<sizeWidth;iWidth++)
1351 slicesLST[iWidth]->Delete();
1354 _imageResult->Modified();
1355 _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _imageResult );
1359 //-------------------------------------------------------------------
1360 void vtkPlane2DView::Configure( )
1362 wxVtk2DBaseView::Configure(false);
1368 _pSource = vtkPlaneSource::New( );
1369 _3Dslices = vtkProbeFilter::New( ) ;
1370 _stPoints = vtkStructuredPoints::New( );
1371 _change = vtkImageChangeInformation::New();
1373 wxVTKRenderWindowInteractor *iren = GetWxVTKRenderWindowInteractor();
1375 // SetActive(false);
1376 _imageViewer2XYZ -> GetVtkImageViewer2() -> SetupInteractor ( iren );
1378 SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
1380 _interactorstyleplane2D = new vtkInteractorStylePlane2D();
1381 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstyleplane2D );
1383 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
1385 camera->SetViewUp ( 0 , 1 , 0 );
1386 camera->SetPosition ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 10000 );
1388 camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
1389 camera->SetClippingRange(0.01, 100000);
1390 camera->ComputeViewPlaneNormal();
1391 camera->SetParallelScale( _sizeIma/3.0 );
1393 // text information over the graphic window
1394 _vtkInfoTextImage = new vtkInfoTextImage();
1395 _vtkInfoTextImageInteractorPlane2D = new vtkInfoTextImageInteractorPlane2D();
1396 _vtkInfoTextImage->SetWxVtk2DBaseView(this);
1397 _vtkInfoTextImage->SetMarImageData( GetVtkmprbasedata()->GetMarImageData() );
1398 _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);
1399 _vtkInfoTextImage->Configure();
1400 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
1405 //-------------------------------------------------------------------
1406 void vtkPlane2DView::HorizontalLine()
1409 _pts = vtkPoints::New();
1410 _pts->SetNumberOfPoints(2);
1411 _pts->SetPoint(0, -1000 , -1000 , -1000 );
1412 _pts->SetPoint(1, 1000 , 1000 , 1000 );
1413 vtkCellArray *lines = vtkCellArray::New();
1414 lines->InsertNextCell(2);
1415 lines->InsertCellPoint(0);
1416 lines->InsertCellPoint(1);
1417 _pd = vtkPolyData::New();
1418 _pd->SetPoints( _pts );
1419 _pd->SetLines( lines );
1420 lines->Delete(); //do not delete lines ??
1421 _lineActor = vtkActor::New();
1422 _lineMapper = vtkPolyDataMapper::New();
1423 _lineMapper->SetInput(_pd);
1424 _lineMapper->ImmediateModeRenderingOn();
1425 _lineActor->SetMapper(_lineMapper);
1426 _lineActor->GetProperty()->BackfaceCullingOn();
1427 _lineActor->GetProperty()->SetDiffuseColor(0,0,1);
1428 _lineActor->GetProperty()->SetLineWidth(2);
1429 _lineActor->GetProperty()->SetOpacity(0);
1430 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineActor );
1433 //-------------------------------------------------------------------
1434 void vtkPlane2DView::RotationStart()
1436 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1437 vtkTransform *transform = mprbasedata->GetTransformOrientation();
1438 _transform1->SetMatrix( transform->GetMatrix() );
1440 //-------------------------------------------------------------------
1441 void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
1445 _ang =sqrt( vx*vx + vy*vy ) / 1.5;
1452 _transform2->Identity();
1453 _transform2->RotateWXYZ(_ang,0,_vxb,_vyb);
1455 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1456 vtkTransform *transform = vtkTransform::New();
1457 transform->Identity();
1458 transform->Concatenate(_transform1);
1459 transform->Concatenate(_transform2);
1460 mprbasedata->InitTransformOrientation(transform);
1461 transform->Delete();
1463 // Refresh Horizontal Line
1464 _pts->SetPoint( 0 , (_sizeIma/2) - _vxb*2 , (_sizeIma/2) - _vyb*2 , 1 );
1465 _pts->SetPoint( 1 , (_sizeIma/2) + _vxb*2 , (_sizeIma/2) + _vyb*2 , 1 );
1466 // RefreshCircleLine();
1469 //-------------------------------------------------------------------
1470 void vtkPlane2DView::Refresh( )
1473 wxVtkBaseView::Refresh();
1475 //-------------------------------------------------------------------
1476 void vtkPlane2DView::SetImgSize( int imgSize )
1480 //-------------------------------------------------------------------
1481 int vtkPlane2DView::GetImgSize()
1485 //-------------------------------------------------------------------
1486 int vtkPlane2DView::GetActualSlice() // virtual
1488 _cx = GetVtkmprbasedata()->GetX();
1489 _cy = GetVtkmprbasedata()->GetY();
1490 _cz = GetVtkmprbasedata()->GetZ();
1494 //-------------------------------------------------------------------
1496 bool vtkPlane2DView::GetMipVisualization()
1498 return _mip_visualization;
1501 //-------------------------------------------------------------------
1502 int vtkPlane2DView::GetMipWidth()
1507 //-------------------------------------------------------------------
1508 void vtkPlane2DView::SetActualSlice(int slice) // Virtual
1510 double dir=(double)slice/3.0;
1511 GetVtkmprbasedata()->SetX( _cx + (_n[0]*dir) );
1512 GetVtkmprbasedata()->SetY( _cy + (_n[1]*dir) );
1513 GetVtkmprbasedata()->SetZ( _cz + (_n[2]*dir) );
1515 //---------------------------------------------------------------------------
1516 vtkInteractorStylePlane2D *vtkPlane2DView::GetInteractorstyleplane2D()
1518 return this->_interactorstyleplane2D;
1520 //---------------------------------------------------------------------------
1521 void vtkPlane2DView::SetActive(bool active)
1526 //---------------------------------------------------------------------------
1528 void vtkPlane2DView::SetMipVisualization(bool ok)
1530 _mip_visualization=ok;
1533 //---------------------------------------------------------------------------
1535 void vtkPlane2DView::SetMipWidth(int value)
1540 //---------------------------------------------------------------------------
1541 void vtkPlane2DView::SetVisibleLine(bool ok)
1550 _lineActor->GetProperty()->SetOpacity(opacity);
1552 // ----------------------------------------------------------------------------
1553 void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z)
1556 GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
1562 TransfromeCoordScreenToWorld(xx,yy,zz);
1565 vtkTransform *transf1 = vtkTransform::New();
1566 transf1->Identity();
1567 vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
1568 transf1->Concatenate(transf2->GetMatrix());
1569 double in[4], out[4];
1570 double center = GetImgSize() / 2;
1572 in[1] = xx - center;
1573 in[2] = yy - center;
1576 transf1->MultiplyPoint(in,out);
1579 X = out[0] + GetVtkmprbasedata()->GetX() ;
1580 Y = out[1] + GetVtkmprbasedata()->GetY() ;
1581 Z = out[2] + GetVtkmprbasedata()->GetZ() ;
1585 //-------------------------------------------------------------------
1586 //-------------------------------------------------------------------
1587 //-------------------------------------------------------------------
1588 vtkInfoTextImageInteractorPlane2D::vtkInfoTextImageInteractorPlane2D()
1591 //-------------------------------------------------------------------
1592 vtkInfoTextImageInteractorPlane2D::~vtkInfoTextImageInteractorPlane2D()
1595 //-------------------------------------------------------------------
1596 bool vtkInfoTextImageInteractorPlane2D::OnMouseMove()
1599 wxVTKRenderWindowInteractor *wxVTKiren;
1600 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1601 wxVTKiren->GetEventPosition(X,Y);
1603 int z = (int) (_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1604 double xx=X,yy=Y,zz=z;
1607 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
1608 vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
1610 GetVtkInfoTextImage()->PutWindowLevel();
1611 GetVtkInfoTextImage()->PutColorLevel();
1612 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1613 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1615 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1619 // ----------------------------------------------------------------------------
1620 // ----------------------------------------------------------------------------
1621 // ----------------------------------------------------------------------------
1622 manualViewPerpPlaneContour::manualViewPerpPlaneContour()
1625 // ----------------------------------------------------------------------------
1626 manualViewPerpPlaneContour::~manualViewPerpPlaneContour()
1631 // ----------------------------------------------------------------------------
1632 manualViewPerpPlaneContour * manualViewPerpPlaneContour :: Clone()
1634 manualViewPerpPlaneContour * clone = new manualViewPerpPlaneContour();
1635 CopyAttributesTo(clone);
1639 // ---------------------------------------------------------------------------
1641 void manualViewPerpPlaneContour::CopyAttributesTo( manualViewPerpPlaneContour * cloneObject)
1644 manualViewContour::CopyAttributesTo(cloneObject);
1650 // ----------------------------------------------------------------------------
1651 void manualViewPerpPlaneContour::UpdateViewPoint(int id)
1654 manualPoint *mp = _manContModel->GetManualPoint(id);
1658 FilterCordinateXYZ(x,y,z);
1660 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
1661 if ((z>=-1) && (z<=1))
1663 _lstViewPoints[id]->GetVtkActor()->VisibilityOn();
1665 _lstViewPoints[id]->GetVtkActor()->VisibilityOff();
1668 // ----------------------------------------------------------------------------
1669 void manualViewPerpPlaneContour::FilterCordinateXYZ (double &x, double &y, double &z)
1671 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1672 vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
1673 vtkTransform *transf1 = vtkTransform::New();
1674 vtkTransform *transf2 = vtkmprbasedata->GetTransformOrientation();
1675 transf1->SetMatrix( transf2->GetMatrix() );
1678 double in[4], out[4];
1679 double center = vtkplane2Dview->GetImgSize() / 2;
1681 in[0] = x - vtkmprbasedata->GetX();
1682 in[1] = y - vtkmprbasedata->GetY();
1683 in[2] = z - vtkmprbasedata->GetZ();
1686 transf1->MultiplyPoint(in,out);
1692 this->GetWxVtkBaseView()->GetSpacing(spc);
1700 // ----------------------------------------------------------------------------
1701 void manualViewPerpPlaneContour::TransfromeCoordViewWorld( double &X,double &Y,double &Z,int type )
1704 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1705 vtkplane2Dview->TransfromeCoordViewWorld2(X,Y,Z);
1709 // ----------------------------------------------------------------------------
1710 void manualViewPerpPlaneContour::RefreshContour() // virtual
1712 // manualViewContour::RefreshContour();
1718 // JSTG 25-02-08 ----------------------------------------------------------
1720 //--------------------------------------------------------
1726 double dist,distMin = 99999999;
1728 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1729 double center = vtkplane2Dview->GetImgSize() / 2;
1732 np = GetNumberOfPoints( );
1734 //JSTG 25-02-08 ------------------------------------------
1736 //nps = GetNumberOfPointsSpline();
1737 nps = _manContModel->GetNumberOfPointsSpline();
1738 //delta = ( double ) ( np ) / ( double ) ( nps-1 );
1739 _manContModel->UpdateSpline();
1740 //--------------------------------------------------------
1744 for( i = 0; i < nps; i++ )
1746 // JSTG 25-02-08 ----------------------------------------------------------
1747 //t = delta * (double)i ;
1748 //tt = delta * (double)(i+1) ;
1749 //_manContModel->GetSplinePoint(t ,pp1[0],pp1[1],pp1[2]);
1750 //_manContModel->GetSplinePoint(tt,pp2[0],pp2[1],pp2[2]);
1751 _manContModel->GetSpline_i_Point(i ,&pp1[0],&pp1[1],&pp1[2]);
1752 _manContModel->GetSpline_i_Point(i+1,&pp2[0],&pp2[1],&pp2[2]);
1753 //--------------------------------------------------------------------------
1754 FilterCordinateXYZ(pp1[0],pp1[1],pp1[2]);
1755 FilterCordinateXYZ(pp2[0],pp2[1],pp2[2]);
1756 if (pp2[2]*pp1[2]<=0)
1758 if (pp1[2]-pp2[2]!=0) {
1759 u = -pp2[2] / (pp1[2]-pp2[2]);
1763 pp[0] = ( pp1[0]-pp2[0] )*u + pp2[0];
1764 pp[1] = ( pp1[1]-pp2[1] )*u + pp2[1];
1765 pp[2] = ( pp1[2]-pp2[2] )*u + pp2[2];
1766 ppC[0] = pp[0] - center;
1767 ppC[1] = pp[1] - center;
1769 dist = sqrt( ppC[0]*ppC[0] + ppC[1]*ppC[1] + ppC[2]*ppC[2] );
1781 _pts->SetPoint(0, 0 , 0 , 0);
1782 _pts->SetPoint(1, 0 , 0 , 0);
1786 ppB[0]=ppB[0]*_spc[0];
1787 ppB[1]=ppB[1]*_spc[1];
1789 _pts->SetPoint( 0, ppB[0] , ppB[1]+1 , 1 );
1790 _pts->SetPoint( 1, ppB[0] , ppB[1]-1 , 1 );
1791 _pts->SetPoint( 2, ppB[0] , ppB[1] , 1 );
1792 _pts->SetPoint( 3, ppB[0]-1 , ppB[1] , 1 );
1793 _pts->SetPoint( 4, ppB[0]+1 , ppB[1] , 1 );
1796 for( i = 5; i < nps; i++ )
1798 _pts->SetPoint( i, ppB[0] , ppB[1] , 1 );
1803 //---------------------------------------------------------------------------
1804 bool manualViewPerpPlaneContour::ifTouchContour( int x, int y, int z)
1807 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1811 vtkplane2Dview->TransfromeCoordScreenToWorld(X,Y,Z);
1813 _pts->GetPoint(0, ppA);
1814 if (sqrt( (ppA[0]-X)*(ppA[0]-X) + (ppA[1]-Y)*(ppA[1]-Y) ) <=2)
1822 //---------------------------------------------------------------------------
1823 //---------------------------------------------------------------------------
1824 //---------------------------------------------------------------------------
1825 vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
1827 _stateMoveAxisX = false;
1828 _stateMoveAxisY = false;
1829 _stateMoveAxisZ = false;
1831 //---------------------------------------------------------------------------
1832 vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
1837 //---------------------------------------------------------------------------
1838 bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual
1840 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1841 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1842 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1844 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1845 wxvtkmpr2Dview->MoveX(x,y,z);
1846 wxvtkmpr2Dview->MoveY(x,y,z);
1847 wxvtkmpr2Dview->MoveZ(x,y,z);
1848 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1849 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1850 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1851 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1855 //---------------------------------------------------------------------------
1856 bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
1858 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1859 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1860 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1862 //double xx = x; // JPRx
1863 //double yy = y; // JPRx
1864 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1867 if ((_xBack==xx) && (_yBack==yy))
1869 wxvtkmpr2Dview->MoveX(x,y,z);
1870 wxvtkmpr2Dview->MoveY(x,y,z);
1871 wxvtkmpr2Dview->MoveZ(x,y,z);
1872 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1873 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1874 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1875 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1882 _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
1883 _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
1884 _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
1888 //---------------------------------------------------------------------------
1889 bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
1891 if (_stateMoveAxisX==true)
1893 _stateMoveAxisX=false;
1895 if (_stateMoveAxisY==true)
1897 _stateMoveAxisY=false;
1899 if (_stateMoveAxisZ==true)
1901 _stateMoveAxisZ=false;
1905 //---------------------------------------------------------------------------
1906 bool vtkInteractorStyleMPRView::OnMouseMove ()
1908 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1909 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1912 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1913 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1914 // wxvtkmpr2Dview->TransfromeCoordViewWorld(x,y,z);
1916 wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
1918 if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
1920 if (_stateMoveAxisX==true)
1922 wxvtkmpr2Dview-> MoveX(x,y,z);
1924 if (_stateMoveAxisY==true)
1926 wxvtkmpr2Dview->MoveY(x,y,z);
1928 if (_stateMoveAxisZ==true)
1930 wxvtkmpr2Dview->MoveZ(x,y,z);
1933 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1937 //-------------------------------------------------------------------
1938 //-------------------------------------------------------------------
1939 //-------------------------------------------------------------------
1940 wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction)
1941 :wxVtk2DBaseView(parent)
1946 _direction = direction;
1949 _lineAMapper = NULL;
1953 _lineBMapper = NULL;
1957 //-------------------------------------------------------------------
1958 wxVtkMPR2DView::~wxVtkMPR2DView()
1960 if (_ptsA!=NULL) { _ptsA -> Delete(); }
1961 if (_lineAActor!=NULL) { _lineAActor -> Delete(); }
1962 if (_lineAMapper!=NULL) { _lineAMapper -> Delete(); }
1963 if (_pdA!=NULL) { _pdA -> Delete(); }
1964 if (_ptsB!=NULL) { _ptsB -> Delete(); }
1965 if (_lineBActor!=NULL) { _lineBActor -> Delete(); }
1966 if (_lineBMapper!=NULL) { _lineBMapper -> Delete(); }
1967 if (_pdB!=NULL) { _pdB -> Delete(); }
1969 //-------------------------------------------------------------------
1970 vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
1972 return (vtkMPRBaseData*)GetVtkBaseData();
1974 //-------------------------------------------------------------------
1975 void wxVtkMPR2DView::Configure(){
1976 wxVtk2DBaseView::Configure();
1978 _interactorstylemprview = new vtkInteractorStyleMPRView();
1979 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstylemprview );
1981 int x1,x2,y1,y2,z1,z2;
1982 GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
1985 vtkImageData* img = GetVtkmprbasedata()->GetImageData();
1987 img->GetSpacing(spc);
1988 x1 = (int)(x1*spc[0]);
1989 y1 = (int)(y1*spc[1]);
1990 z1 = (int)(z1*spc[2]);
1992 x2 = (int)(x2*spc[0]);
1993 y2 = (int)(y2*spc[1]);
1994 z2 = (int)(z2*spc[2]);
1996 _visibleAxis = true;
1999 _ptsA = vtkPoints::New();
2000 _ptsA->SetNumberOfPoints(2);
2001 _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
2002 _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
2003 vtkCellArray *linesA;
2004 linesA = vtkCellArray::New();
2005 linesA->InsertNextCell(2);
2006 linesA->InsertCellPoint(0);
2007 linesA->InsertCellPoint(1);
2008 _pdA = vtkPolyData::New();
2009 _pdA->SetPoints( _ptsA );
2010 _pdA->SetLines( linesA );
2011 linesA->Delete(); //do not delete lines ??
2012 _lineAActor = vtkActor::New();
2013 _lineAMapper = vtkPolyDataMapper::New();
2014 _lineAMapper->SetInput(_pdA);
2015 _lineAMapper->ImmediateModeRenderingOn();
2016 _lineAActor->SetMapper(_lineAMapper);
2017 // _lineAActor->GetProperty()->BackfaceCullingOn();
2018 _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
2019 _lineAActor->GetProperty()->SetLineWidth(2);
2020 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2023 _ptsB = vtkPoints::New();
2024 _ptsB->SetNumberOfPoints(2);
2025 _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
2026 _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
2027 vtkCellArray *linesB;
2028 linesB = vtkCellArray::New();
2029 linesB->InsertNextCell(2);
2030 linesB->InsertCellPoint(0);
2031 linesB->InsertCellPoint(1);
2032 _pdB = vtkPolyData::New();
2033 _pdB->SetPoints( _ptsB );
2034 _pdB->SetLines( linesB );
2035 linesB->Delete(); //do not delete lines ??
2036 _lineBActor = vtkActor::New();
2037 _lineBMapper = vtkPolyDataMapper::New();
2038 _lineBMapper->SetInput(_pdB);
2039 _lineBMapper->ImmediateModeRenderingOn();
2040 _lineBActor->SetMapper(_lineBMapper);
2041 // _lineBActor->GetProperty()->BackfaceCullingOn();
2042 _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
2043 _lineBActor->GetProperty()->SetLineWidth(2);
2044 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2047 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
2051 if (_direction==0) {
2052 camera->SetViewUp ( 0 , -1 , 0 );
2053 camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
2054 camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
2055 camera->SetParallelScale( (z2-z1)/3.0 );
2058 if (_direction==1) {
2059 camera->SetViewUp ( 0 , 0 , -1 );
2060 camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
2061 camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
2062 camera->SetParallelScale( (x2-x1)/3.0 );
2065 if (_direction==2) {
2066 camera->SetViewUp ( 0 , -1 , 0 );
2067 camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
2068 camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
2069 camera->SetParallelScale( (x2-x1)/3.0 );
2073 if (_direction==0) {
2074 camera->SetViewUp ( 0 , 1 , 0 );
2075 camera->SetPosition ( 10000,(y1+y2)/2 , (z1+z2)/2 );
2076 camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
2077 camera->SetParallelScale( (z2-z1)/3.0 );
2080 if (_direction==1) {
2081 camera->SetViewUp ( 0 , 0 , -1 );
2082 camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
2083 camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
2084 camera->SetParallelScale( (x2-x1)/3.0 );
2087 if (_direction==2) {
2088 camera->SetViewUp ( 0 , 1 , 0 );
2089 camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , 10000);
2090 camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
2091 camera->SetParallelScale( (x2-x1)/3.0 );
2098 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
2099 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
2103 void wxVtkMPR2DView::SetVisibleAxis(bool ok)
2105 if (ok!=_visibleAxis)
2108 if (_visibleAxis==true)
2110 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2111 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2113 if (_visibleAxis==false)
2115 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
2116 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
2122 //-------------------------------------------------------------------
2123 void wxVtkMPR2DView::Refresh()
2125 //wxVtk2DBaseView::Refresh();
2128 //vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2(); // JPRx
2129 //vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); // JPRx
2133 int x1,x2,y1,y2,z1,z2;
2134 GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
2137 vtkImageData* img = GetVtkmprbasedata()->GetImageData();
2139 img->GetSpacing(spc);
2140 x1 = (int)(x1*spc[0]);
2141 y1 = (int)(y1*spc[1]);
2142 z1 = (int)(z1*spc[2]);
2144 x2 = (int)(x2*spc[0]);
2145 y2 = (int)(y2*spc[1]);
2146 z2 = (int)(z2*spc[2]);
2148 int x = (int)(GetVtkmprbasedata()->GetX());
2149 int y = (int)(GetVtkmprbasedata()->GetY());
2150 int z = (int)(GetVtkmprbasedata()->GetZ());
2152 x = (int)(x*spc[0]);
2153 y = (int)(y*spc[1]);
2154 z = (int)(z*spc[2]);
2158 if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
2160 if (_direction==0) {
2161 _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
2162 _ptsA->SetPoint(0, -x2, y1 , z );
2163 _ptsA->SetPoint(1, -x2, y2 , z );
2164 _ptsB->SetPoint(0, -x2, y , z1);
2165 _ptsB->SetPoint(1, -x2, y , z2);
2167 if (_direction==1) {
2168 _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
2169 _ptsA->SetPoint(0, x1 , y2 , z );
2170 _ptsA->SetPoint(1, x2 , y2 , z );
2171 _ptsB->SetPoint(0, x , y2 , z1);
2172 _ptsB->SetPoint(1, x , y2 , z2);
2174 if (_direction==2) {
2175 _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
2176 _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
2177 // _ptsA->SetPoint(0, x1 , y , -z2 );
2178 // _ptsA->SetPoint(1, x2 , y , -z2 );
2179 // _ptsB->SetPoint(0, x , y1, -z2 );
2180 // _ptsB->SetPoint(1, x , y2, -z2 );
2182 _ptsA->SetPoint(0, x1 , y , z2 );
2183 _ptsA->SetPoint(1, x2 , y , z2 );
2184 _ptsB->SetPoint(0, x , y1, z2 );
2185 _ptsB->SetPoint(1, x , y2, z2 );
2191 wxVtkBaseView::Refresh();
2194 //-------------------------------------------------------------------
2195 int wxVtkMPR2DView::GetActualSlice() // virtual
2200 result = (int)(GetVtkmprbasedata()->GetX());
2204 result = (int)(GetVtkmprbasedata()->GetY());
2208 result = (int)(GetVtkmprbasedata()->GetZ());
2212 //-------------------------------------------------------------------
2213 void wxVtkMPR2DView::SetActualSlice(int slice) // virtual
2217 GetVtkmprbasedata()->SetX(slice);
2221 GetVtkmprbasedata()->SetY(slice);
2225 GetVtkmprbasedata()->SetZ(slice);
2228 //-------------------------------------------------------------------
2229 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
2238 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2245 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2252 //-------------------------------------------------------------------
2253 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
2259 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2269 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2276 //-------------------------------------------------------------------
2277 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
2283 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2290 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2300 //-------------------------------------------------------------------
2301 void wxVtkMPR2DView::MoveX(double x, double y, double z)
2308 GetVtkmprbasedata()->SetX(x);
2312 GetVtkmprbasedata()->SetX(x);
2315 //-------------------------------------------------------------------
2316 void wxVtkMPR2DView::MoveY(double x, double y, double z)
2320 GetVtkmprbasedata()->SetY(y);
2327 GetVtkmprbasedata()->SetY(y);
2330 //-------------------------------------------------------------------
2331 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
2335 GetVtkmprbasedata()->SetZ(z);
2339 GetVtkmprbasedata()->SetZ(z);
2345 //-------------------------------------------------------------------
2346 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
2348 double c1r=1,c1g=1,c1b=0;
2349 double c2r=1,c2g=0,c2b=0;
2353 if (IfMouseTouchY(x,y,z)==true)
2355 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2357 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2359 if (IfMouseTouchZ(x,y,z)==true)
2361 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2363 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2369 if (IfMouseTouchX(x,y,z)==true)
2371 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2373 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2375 if (IfMouseTouchZ(x,y,z)==true)
2377 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2379 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2385 if (IfMouseTouchX(x,y,z)==true)
2387 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2389 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2391 if (IfMouseTouchY(x,y,z)==true)
2393 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2395 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2400 //-------------------------------------------------------------------
2401 void wxVtkMPR2DView::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
2403 wxVtkBaseView::TransfromeCoordScreenToWorld(X,Y,Z,_direction);
2407 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
2411 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
2415 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
2418 //-------------------------------------------------------------------
2419 //-------------------------------------------------------------------
2420 //-------------------------------------------------------------------
2421 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2422 // if (eventId==vtkCommand::StartInteractionEvent){
2423 // _renWin->SetDesiredUpdateRate(10);
2425 // if (eventId==vtkCommand::InteractionEvent){
2426 // _renWin->SetDesiredUpdateRate(0.001);
2428 // if (eventId==vtkCommand::EndInteractionEvent){
2429 // vtkPlanes *planes = vtkPlanes::New();
2430 // vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2431 // boxwidget->GetPlanes(planes);
2432 // _volumeMapper->SetClippingPlanes(planes);
2433 // planes -> Delete();
2437 //-------------------------------------------------------------------
2438 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
2439 // _renWin = renWin;
2441 //-------------------------------------------------------------------
2442 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
2443 // _volumeMapper = volumeMapper;
2448 //-------------------------------------------------------------------
2449 //-------------------------------------------------------------------
2450 //-------------------------------------------------------------------
2452 void boxSurfaceObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2453 vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2454 boxwidget->GetPlanes(_planes);
2456 if ( _vtkVolumeRayCastMapper != NULL )
2458 _vtkVolumeRayCastMapper->RemoveAllClippingPlanes();
2459 // vtkPlanes *planes = vtkPlanes::New();
2460 // boxwidget->GetPlanes(planes);
2461 // _vtkVolumeRayCastMapper->SetClippingPlanes(planes);
2462 _vtkVolumeRayCastMapper->SetClippingPlanes(_planes);
2465 // _actor->VisibilityOn();
2468 //-------------------------------------------------------------------
2469 void boxSurfaceObserver::SetPlanes(vtkPlanes *planes){
2472 //-------------------------------------------------------------------
2473 void boxSurfaceObserver::SetActor(vtkProp *actor){
2477 //-------------------------------------------------------------------
2478 void boxSurfaceObserver::SetvtkVolumeRayCastMapper(vtkVolumeRayCastMapper *vtkvolumeraycastmapper)
2480 _vtkVolumeRayCastMapper = vtkvolumeraycastmapper;
2484 //-------------------------------------------------------------------
2485 //-------------------------------------------------------------------
2486 //-------------------------------------------------------------------
2488 wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DView *wxvtkmpr3Dview )
2489 : wxPanel(parent, -1)
2492 wxPanel *panel = this;
2493 _wxvtkmpr3Dview = wxvtkmpr3Dview;
2495 int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2496 int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2497 int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2498 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,_T("X "));
2499 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2500 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
2501 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2502 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,_T("Z "));
2503 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2504 wxButton *btnColorTable = new wxButton (panel, -1, _T("Edit Color Table") );
2506 _ckBoxXYZ = new wxCheckBox(panel,-1,_T("XYZ "));
2507 _ckBoxPlane = new wxCheckBox(panel,-1,_T("Plane"));
2509 ckBoxX->SetValue(false);
2510 ckBoxY->SetValue(false);
2511 ckBoxZ->SetValue(false);
2512 _ckBoxXYZ->SetValue(false);
2513 _ckBoxPlane->SetValue(false);
2515 _positionX->SetSize(400,20);
2516 _positionY->SetSize(400,20);
2517 _positionZ->SetSize(400,20);
2519 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2520 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2521 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2522 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2523 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2524 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2525 Connect(btnColorTable->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnEditColorTable );
2527 Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
2528 Connect(_ckBoxPlane->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
2531 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2532 // wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
2534 // wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL);
2535 wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10);
2536 wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10);
2541 // wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10);
2542 // wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10);
2544 // sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2545 // sizerH4->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2546 // sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
2548 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2549 // sizerH5->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2550 // sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
2552 // sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2553 // sizerH6->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2554 // sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
2556 // sizerH7->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2557 // sizerH7->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2559 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
2560 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2561 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
2562 // sizer->Add( sizerH7 , 1, wxALL|wxEXPAND, 2);
2564 sizerH4->Add( _positionX ,1,wxGROW , 0 );
2565 sizerH4->Add( ckBoxX ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2566 sizerH4->Add( _positionY ,1,wxGROW , 0 );
2567 sizerH4->Add( ckBoxY ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2568 sizerH4->Add( _positionZ ,1,wxGROW , 0 );
2569 sizerH4->Add( ckBoxZ ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2570 sizerH4->Add( btnColorTable ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2572 sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2573 sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2574 sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2575 // sizerH5->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2576 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2577 // sizerH5->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2579 sizer->Add( sizerH4 , 1, wxALL|wxGROW, 2);
2580 sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2583 panel->SetSize(400,50);
2584 panel->SetAutoLayout(true);
2585 panel->SetSizer(sizer);
2588 panel->SetEventHandler((wxEvtHandler*)this);
2591 //-------------------------------------------------------------------
2592 wxVtkMPR3DViewCntrlPanel::~wxVtkMPR3DViewCntrlPanel()
2595 //-------------------------------------------------------------------
2596 void wxVtkMPR3DViewCntrlPanel::Refresh()
2598 // wxPanel::Refresh();
2599 _positionX->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX( )) );
2600 _positionY->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY( )) );
2601 _positionZ->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ( )) );
2604 //-------------------------------------------------------------------
2605 int wxVtkMPR3DViewCntrlPanel::GetIdTissue()
2608 if (_surfA->GetValue()==true)
2612 if (_surfB->GetValue()==true)
2616 if (_surfC->GetValue()==true)
2620 if (_surfD->GetValue()==true)
2629 //-------------------------------------------------------------------
2630 void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event)
2633 vtkColorTransferFunction *ctfun = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetvtkColorTransferFunction();
2634 std::vector<double> *ctfunVectorPoint = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorPoint();
2635 std::vector<double> *ctfunVectorRed = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorRed();
2636 std::vector<double> *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
2637 std::vector<double> *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
2639 //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
2644 vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2646 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2);
2649 hDlg->erasePointsTransferenceFunction();
2650 int ctfSize=ctfunVectorRed->size();
2653 // MACHETE OJO Eduardo
2657 double gr = (*ctfunVectorPoint)[i];
2658 double r = (*ctfunVectorRed)[i];
2659 double g = (*ctfunVectorGreen)[i];
2660 double b = (*ctfunVectorBlue)[i];
2662 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
2668 // when the user had changed the transference Function
2671 //setting variables if the user wants to do refresh
2673 hDlg->setCTF(ctfun);
2674 hDlg->setMPR3Dview(_wxvtkmpr3Dview);
2676 if(hDlg->ShowModal()== wxID_OK )
2679 // -- vtkColorTransferFunction --
2680 ctfun->RemoveAllPoints ();
2682 ctfunVectorPoint->clear();
2683 ctfunVectorRed->clear();
2684 ctfunVectorGreen->clear();
2685 ctfunVectorBlue->clear();
2687 int nCTFpoints=hDlg->getSizeBarColor();
2688 // Machete .. Ojo Eduardo
2692 hDlg->getDataBarColorPoint(i,xi,r,g,b);
2696 hDlg->getDataBarColorPoint(1,xi,r,g,b);
2700 hDlg->getDataBarColorPoint(i-1,xi,r,g,b);
2703 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
2704 ctfunVectorPoint->push_back(xi);
2705 ctfunVectorRed->push_back(r/255.0);
2706 ctfunVectorGreen->push_back(g/255.0);
2707 ctfunVectorBlue->push_back(b/255.0);
2717 if(hDlg->getRefreshed())
2719 // -- vtkColorTransferFunction --
2720 ctfun->RemoveAllPoints ();
2723 int size=ctfunVectorPoint->size();
2727 double grey2=(*ctfunVectorPoint)[i];
2728 double red =(*ctfunVectorRed)[i];
2729 double green =(*ctfunVectorGreen)[i];
2730 double blue = (*ctfunVectorBlue)[i];
2731 ctfun->AddRGBPoint(grey2,red,green,blue);
2741 //-------------------------------------------------------------------
2742 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
2744 _wxvtkmpr3Dview->VisibleImageActor(0, event.IsChecked() );
2745 _wxvtkmpr3Dview->Refresh();
2747 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2748 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2751 //-------------------------------------------------------------------
2752 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
2754 _wxvtkmpr3Dview->VisibleImageActor(1, event.IsChecked() );
2755 _wxvtkmpr3Dview->Refresh();
2757 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2758 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2761 //-------------------------------------------------------------------
2762 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
2764 _wxvtkmpr3Dview->VisibleImageActor(2, event.IsChecked() );
2765 _wxvtkmpr3Dview->Refresh();
2767 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2768 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2771 //-------------------------------------------------------------------
2772 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event)
2774 _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked());
2777 //-------------------------------------------------------------------
2778 void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event)
2780 _wxvtkmpr3Dview->VisiblePlaneWidget(event.IsChecked());
2784 //-------------------------------------------------------------------
2785 void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event)
2787 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() );
2788 _wxvtkmpr3Dview->RefreshView();
2789 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2790 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2792 //-------------------------------------------------------------------
2793 void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event)
2795 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() );
2796 _wxvtkmpr3Dview->RefreshView();
2797 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2798 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2800 //-------------------------------------------------------------------
2801 void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event)
2803 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() );
2804 _wxvtkmpr3Dview->RefreshView();
2805 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2806 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2810 //-------------------------------------------------------------------
2811 //-------------------------------------------------------------------
2812 //-------------------------------------------------------------------
2814 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
2815 : wxPanel(parent, -1)
2817 wxPanel *panel = this;
2818 _wxvtkclipping3Dview = wxvtkclipping3Dview;
2821 // wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
2822 // wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
2824 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2825 _surfB = new wxRadioButton(panel,-1,_T("B"));
2826 _surfC = new wxRadioButton(panel,-1,_T("C"));
2827 _surfD = new wxRadioButton(panel,-1,_T("D"));
2829 wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
2830 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
2831 wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
2833 _color = new wxButton(panel,-1,_T(""));
2834 _visible = new wxCheckBox(panel,-1,_T("Vis"));
2835 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
2837 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
2838 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
2841 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2842 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
2846 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2847 vtkimagedata->GetScalarRange( range );
2848 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
2849 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
2852 _isoValue->SetTickFreq(25,0);
2854 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
2855 _isoValueSpin->SetRange(1,8);
2856 _isoValueSpin->SetValue(5);
2857 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
2859 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
2860 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
2862 wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
2865 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
2866 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
2867 Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
2870 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
2871 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
2875 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2876 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2877 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2878 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
2879 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2880 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
2881 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2882 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
2883 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2886 // ckVolum->Enable(false);
2887 ckBoxSurface->SetValue(false);
2888 ckBoxVolume->SetValue(false);
2889 _color->SetSize(40,20);
2890 _opacity->SetSize(370,20);
2891 // ckBoxX->SetValue(true);
2892 // ckBoxY->SetValue(true);
2893 // ckBoxZ->SetValue(true);
2894 _surfA->SetValue(true);
2895 _wireFrameRep->SetValue(false);
2896 _surfaceRep->SetValue(true);
2897 _visible->SetValue(false);
2898 // _positionX->SetSize(400,20);
2899 // _positionY->SetSize(400,20);
2900 // _positionZ->SetSize(400,20);
2902 Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
2903 Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
2905 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2906 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2907 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2908 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2909 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
2911 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2912 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2914 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
2915 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
2916 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
2919 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2920 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2923 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2924 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2925 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2926 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2927 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2928 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2931 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2932 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
2933 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
2934 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
2935 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
2936 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
2937 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
2938 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
2940 sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
2941 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2942 sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
2943 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2944 sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
2945 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2946 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
2949 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
2950 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2951 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
2952 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2953 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
2954 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2955 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
2956 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2957 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
2958 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2959 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
2960 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2961 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
2964 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
2965 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
2966 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2967 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
2968 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2971 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
2972 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2973 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
2974 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2976 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
2979 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
2980 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
2981 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
2984 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2985 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
2986 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
2988 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2989 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
2990 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
2992 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2993 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
2994 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
2996 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
2997 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
2998 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
2999 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
3000 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
3001 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
3002 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
3004 panel->SetSize(300,60);
3005 panel->SetAutoLayout(true);
3006 panel->SetSizer(sizer);
3009 panel->SetEventHandler((wxEvtHandler*)this);
3012 //-------------------------------------------------------------------
3013 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
3016 //-------------------------------------------------------------------
3017 void wxVtkClipping3DViewCntrlPanel::Refresh()
3019 // wxPanel::Refresh();
3021 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
3022 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
3023 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
3026 //-------------------------------------------------------------------
3027 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
3030 if (_surfA->GetValue()==true)
3034 if (_surfB->GetValue()==true)
3038 if (_surfC->GetValue()==true)
3042 if (_surfD->GetValue()==true)
3050 //-------------------------------------------------------------------
3051 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
3053 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
3054 _wxvtkclipping3Dview->Refresh();
3056 //-------------------------------------------------------------------
3057 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
3059 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
3060 _wxvtkclipping3Dview->Refresh();
3062 //-------------------------------------------------------------------
3063 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
3065 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
3066 _wxvtkclipping3Dview->Refresh();
3070 //-------------------------------------------------------------------
3071 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
3073 int idTissue=GetIdTissue();
3078 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3080 tmpActor->GetProperty()->GetColor( rgb );
3081 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
3082 _color->SetBackgroundColour(colour);
3085 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
3088 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
3090 // Representation Type WireFrame / Surface
3091 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3092 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3095 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
3096 _isoValue->SetValue(isoValue);
3101 //-------------------------------------------------------------------
3102 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
3104 int idTissue=GetIdTissue();
3107 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
3109 _wxvtkclipping3Dview->Refresh();
3111 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3112 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3117 //-------------------------------------------------------------------
3118 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
3120 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
3121 _wxvtkclipping3Dview->Refresh();
3123 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3124 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3126 //-------------------------------------------------------------------
3127 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
3129 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
3130 _wxvtkclipping3Dview->Refresh();
3132 //-------------------------------------------------------------------
3133 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
3135 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
3136 _wxvtkclipping3Dview->Refresh();
3138 //-------------------------------------------------------------------
3139 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
3141 int idTissue=GetIdTissue();
3144 // EED 17 Janvier 2007
3145 wxColourDialog dlgColour(this);
3146 // dlgColour.ShowModal();
3147 if( dlgColour.ShowModal( ) == wxID_OK )
3150 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3151 float r=dlgColour.GetColourData().GetColour().Red()/255;
3152 float g=dlgColour.GetColourData().GetColour().Green()/255;
3153 float b=dlgColour.GetColourData().GetColour().Blue()/255;
3154 tmpActor->GetProperty()->SetColor( r , g , b );
3155 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
3157 _wxvtkclipping3Dview->Refresh();
3159 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3160 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3164 //-------------------------------------------------------------------
3165 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
3167 int idTissue=GetIdTissue();
3170 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
3172 _wxvtkclipping3Dview->Refresh();
3174 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3175 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3178 //-------------------------------------------------------------------
3179 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
3181 int idTissue=GetIdTissue();
3185 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3186 float opacity=_opacity->GetValue();
3187 tmpActor->GetProperty()->SetOpacity( opacity/100 );
3189 _wxvtkclipping3Dview->Refresh();
3191 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3192 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3196 //----------------------------------------------------------------------------
3197 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
3199 int value = _isoValue->GetValue();
3200 int delta= (int)pow( 4 , _isoValueSpin->GetValue() );
3201 int min=value - delta/2;
3202 int max=value + delta/2;
3208 _isoValue->SetRange(min,max);
3212 //------------------------------------------------------------------------
3213 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
3217 int idTissue=GetIdTissue();
3220 int isoValue=_isoValue->GetValue();
3221 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
3223 // tmpStr.Printf("%d",isoValue);
3225 _wxvtkclipping3Dview->Refresh();
3227 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3228 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3232 //-------------------------------------------------------------------
3233 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
3236 int idTissue=GetIdTissue();
3243 wxString dirSTL = wxGetHomeDir( ) ;
3244 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
3246 if( dialog.ShowModal( ) == wxID_OK )
3250 // ------------------------------------------------------------------------
3251 // 1. GENERATE STL FILES
3252 // ------------------------------------------------------------------------
3253 // const char* fileprefix = "c:\\Creatis\\";
3254 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
3255 std::string filename;
3257 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
3259 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
3262 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
3263 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
3264 pdcf->SetInput( filtro->GetOutput() );
3265 vtkClosePolyData *cpd = vtkClosePolyData::New();
3266 cpd->SetInput( pdcf->GetOutput() );
3268 // 1.2 se escribe a disco el archivo stl de la superficie interna
3270 vtkSTLWriter *writer = vtkSTLWriter::New();
3271 writer->SetInput( cpd->GetOutput() );
3273 writer->SetFileName(filename.c_str());
3274 writer->SetFileTypeToASCII();
3286 //EED 30 Janvier 2007
3287 //-------------------------------------------------------------------
3288 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
3290 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
3291 if (dialog.ShowModal() == wxID_OK)
3293 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
3294 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
3295 float rescalaSlope = 1;
3296 float rescalaIntercept = 0;
3297 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
3298 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
3300 vtkimagedata->GetDimensions(dim);
3308 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
3309 marRAW2Files marraw2;
3310 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
3314 //EED 22 Fevrier 2007
3315 //-------------------------------------------------------------------
3316 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
3319 int /*i=0,*/ xi,yi,r,g,b; // JPRx
3320 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
3321 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
3322 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
3323 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
3324 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
3325 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
3326 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
3327 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
3328 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3330 //use for update in the refresh
3332 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
3333 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
3338 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
3339 if (dialog.ShowModal() == wxID_OK)
3341 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
3347 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
3351 int tfSize=gtf->size();
3355 hDlg->erasePointsTransferenceFunction();
3359 double in=(*itf)[i];
3360 hDlg->addPointToTransferenceFunction(g,in*100);
3366 int ctfSize=rctf->size();
3372 double gr=(*greyctf)[i];
3373 double r=(*rctf)[i];
3374 double g=(*gctf)[i];
3375 double b=(*bctf)[i];
3376 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
3380 //setting variables if the user wants to do refresh
3381 hDlg->setCTF(ctfun);
3383 hDlg->setClipping3DView(_wxvtkclipping3Dview);
3385 hDlg->setVolume(newvol);
3386 hDlg->setVolumeMapper(volumeMapper);
3389 // when the user had changed the transference Function
3391 if(hDlg->ShowModal()== wxID_OK )
3393 // -- vtkPiecewiseFunction --
3394 tfun->RemoveAllPoints();
3398 int nTFPoints=hDlg->getSizeTransferenceFunction();
3402 hDlg->getTransferenceFunctionPoint(i,xi,yi);
3403 tfun->AddPoint( xi , yi/100.0 );
3405 itf->push_back(yi/100.0);
3408 // -- vtkColorTransferFunction --
3409 ctfun->RemoveAllPoints ();
3416 int nCTFpoints=hDlg->getSizeBarColor();
3420 hDlg->getDataBarColorPoint(i,xi,r,g,b);
3421 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
3422 rctf->push_back(r/255.0);
3423 gctf->push_back(g/255.0);
3424 bctf->push_back(b/255.0);
3425 greyctf->push_back(xi);
3428 //---------------------------------
3429 // Refreshing and sending the event
3430 //---------------------------------
3431 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3432 _wxvtkclipping3Dview->Refresh();
3433 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3434 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3437 volumeMapper->Update();
3445 if(hDlg->getRefreshed())
3448 //--Transference Function----
3449 tfun->RemoveAllPoints();
3454 double grey1=(*gtf)[i];
3455 double in2=(*itf)[i];
3456 tfun->AddPoint( grey1 , in2 );
3459 // -- vtkColorTransferFunction --
3460 ctfun->RemoveAllPoints ();
3463 size=greyctf->size();
3466 double grey2=(*greyctf)[i];
3467 double red =(*rctf)[i];
3468 double green =(*gctf)[i];
3469 double blue = (*bctf)[i];
3470 ctfun->AddRGBPoint(grey2,red,green,blue);
3473 //---------------------------------
3474 // Refreshing and sending the event
3475 //---------------------------------
3476 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3477 _wxvtkclipping3Dview->Refresh();
3478 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3479 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3482 volumeMapper->Update();
3488 //destroy the dialog
3493 //-------------------------------------------------------------------
3494 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
3496 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
3497 if (dialog.ShowModal() == wxID_OK)
3499 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
3500 _wxvtkclipping3Dview->Refresh();
3501 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3502 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3507 //-------------------------------------------------------------------
3508 //-------------------------------------------------------------------
3509 //-------------------------------------------------------------------
3512 wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
3514 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3515 _vtkmpr3Ddataviewer = NULL;
3516 _wxvtkmpr3DviewCntrlPanel = NULL;
3519 //-------------------------------------------------------------------
3520 wxVtkMPR3DView::~wxVtkMPR3DView()
3524 //-------------------------------------------------------------------
3525 void wxVtkMPR3DView::Refresh() // virtual
3527 _vtkmpr3Ddataviewer -> Refresh();
3528 if (_wxvtkmpr3DviewCntrlPanel!=NULL)
3530 _wxvtkmpr3DviewCntrlPanel->Refresh();
3534 //-------------------------------------------------------------------
3535 void wxVtkMPR3DView::RefreshView() // virtual
3538 this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
3540 //double nx=1,ny=0,nz=0; // JPRx
3542 double x=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetX();
3543 double y=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetY();
3544 double z=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetZ();
3550 _pointWidget->SetPosition( x,y,z );
3555 vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
3556 in[0]=1; in[1]=0; in[2]=0;
3557 transform->TransformPoint(in,normal);
3558 _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
3561 _planeWidget->SetCenter( x,y,z );
3562 _planeWidget->UpdatePlacement();
3563 _planeWidget->GetPolyData(_vtkplane);
3565 //-------------------------------------------------------------------
3566 wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent)
3568 _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this);
3569 return _wxvtkmpr3DviewCntrlPanel;
3571 //-------------------------------------------------------------------
3572 vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
3574 return _vtkmpr3Ddataviewer;
3576 //-------------------------------------------------------------------
3577 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview()
3579 return _wxvtk3Dbaseview;
3581 //-------------------------------------------------------------------
3582 void wxVtkMPR3DView::Configure(){
3583 _wxvtk3Dbaseview->Configure();
3585 // Actors are added to the renderer.
3586 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetOutlineActor() );
3587 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
3588 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
3589 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
3592 // An initial camera view is created. The Dolly() method moves
3593 // the camera towards the FocalPoint, thereby enlarging the image.
3594 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
3595 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
3596 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3598 // Set a background color for the renderer and set the size of the
3599 // render window (expressed in pixels).
3600 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
3601 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
3603 // Note that when camera movement occurs (as it does in the Dolly()
3604 // method), the clipping planes often need adjusting. Clipping planes
3605 // consist of two planes: near and far along the view direction. The
3606 // near plane clips out objects in front of the plane; the far plane
3607 // clips out objects behind the plane. This way only what is drawn
3608 // between the planes is actually rendered.
3609 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
3613 _myCallback = vtkmyPWCallback_3DPointWidget::New();
3614 _myCallback->SetWxVtkMPR3DView(this);
3616 _pointWidget = vtkPointWidget::New();
3617 _myCallback->SetVtkPointWidget(_pointWidget);
3618 _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3619 _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3621 _pointWidget->AllOff();
3623 _pointWidget->PlaceWidget();
3624 // _pointWidget->SetPosition( x,y,z );
3627 // MACOS probleme vtk-window out of wx-window
3628 // _pointWidget->On();
3630 _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3634 _planeWidget = vtkPlaneWidget::New();
3635 _myCallback->SetVtkPlaneWidget(_planeWidget);
3636 _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3637 _planeWidget->NormalToXAxisOn();
3638 _planeWidget->SetResolution(50);
3639 _planeWidget->SetRepresentationToOutline();
3641 GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
3646 _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
3647 _vtkplane = vtkPolyData::New();
3648 _planeWidget->GetPolyData(_vtkplane);
3650 vtkProbeFilter *probe = vtkProbeFilter::New();
3651 probe->SetInput(_vtkplane);
3652 vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3653 probe->SetSource( imageData );
3655 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
3657 contourMapper->SetInput( probe->GetPolyDataOutput() );
3659 contourMapper->SetScalarRange( imageData->GetScalarRange() );
3660 _contourPlaneActor = vtkActor::New();
3661 _contourPlaneActor->SetMapper(contourMapper);
3663 _contourPlaneActor->VisibilityOff();
3665 _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3666 _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3668 _planeWidget->Off();
3669 _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
3671 //-------------------------------------------------------------------
3672 void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
3673 if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
3674 if (visible==false){
3675 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3677 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3679 _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
3684 //-------------------------------------------------------------------
3685 void wxVtkMPR3DView::VisiblePointWidget( bool visible )
3691 _pointWidget->Off();
3695 //-------------------------------------------------------------------
3696 void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
3701 _contourPlaneActor->VisibilityOn();
3704 _planeWidget->Off();
3705 _contourPlaneActor->VisibilityOff();
3709 //-------------------------------------------------------------------
3710 void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer)
3712 _vtkmpr3Ddataviewer = vtkmpr3Ddataviewer;
3715 //-------------------------------------------------------------------
3716 void wxVtkMPR3DView::InitOrientationPointWidget()
3718 this->_planeWidget->SetNormal(1,0,0);
3724 //-------------------------------------------------------------------
3725 // EED 25 Janvier 2007 testLoic
3726 void wxVtkMPR3DView::TestLoic1()
3730 double dimIma = sizeIma*2;
3732 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3735 vtkimagedata->GetSpacing(spc);
3737 vtkimagedata->Update();
3741 this->_planeWidget->GetOrigin(p);
3742 this->_planeWidget->GetNormal(n);
3746 vtkPlaneSource* pSource = vtkPlaneSource::New( );
3747 pSource->SetResolution( sizeIma - 1, sizeIma - 1 );
3748 pSource->SetOrigin( p[ 0 ], p[ 1 ], p[ 2 ] );
3749 pSource->SetPoint1( p[ 0 ] + dimIma - 1.0, p[ 1 ], p[ 2 ] );
3750 pSource->SetPoint2( p[ 0 ], p[ 1 ]+ dimIma - 1.0 , p[ 2 ] );
3752 pSource->SetCenter( p[ 0 ], p[ 1 ], p[ 2 ] );
3753 pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
3756 vtkProbeFilter* slices = vtkProbeFilter::New();
3757 slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
3758 slices->SetSource( vtkimagedata );
3762 vtkStructuredPoints *stPoints = vtkStructuredPoints::New();
3763 stPoints -> GetPointData( )->SetScalars( slices->GetOutput()->GetPointData()->GetScalars() );
3764 stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
3765 stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
3766 stPoints -> SetScalarTypeToShort();
3767 stPoints -> Update();
3769 vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
3770 change -> SetInput( stPoints );
3771 change -> Update(); //important
3774 vtkimagedata->GetScalarRange(_range);
3775 vtkWindowLevelLookupTable *_bwlookup = vtkWindowLevelLookupTable::New( );
3776 _bwlookup->SetHueRange( 0 , 1 );
3777 _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
3778 _bwlookup->SetTableRange( _range[0] , _range[1] );
3779 _bwlookup->SetSaturationRange( 0 , 0 );
3780 _bwlookup->SetValueRange( 0 , 1 );
3781 _bwlookup->SetAlphaRange( 1 , 1 );
3782 _bwlookup->Build( );
3784 vtkLookupTable * _collookup = vtkLookupTable::New( );
3785 _collookup->SetNumberOfColors( 256 );
3786 _collookup->SetTableRange( 0 , 255 );
3787 _collookup->Build( );
3788 _collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
3789 _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
3790 _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
3793 vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
3794 writer->SetInput( stPoints );
3795 writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
3796 writer->SetFileDimensionality( 2 );
3801 vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
3802 _3DSliceMapper->SetInput(change->GetOutput( ) );
3803 _3DSliceMapper->SetLookupTable( _bwlookup );
3804 _3DSliceMapper->SetScalarRange( _range );
3805 _3DSliceMapper->ImmediateModeRenderingOn( );
3807 vtkActor *_3DSliceActor = vtkActor::New( );
3808 _3DSliceActor->SetMapper( _3DSliceMapper );
3810 // The usual rendering stuff.
3811 vtkCamera *camera = vtkCamera::New();
3812 camera->SetPosition(1,1,1);
3813 camera->SetFocalPoint(0,0,0);
3815 vtkRenderer *renderer = vtkRenderer::New();
3816 vtkRenderWindow *renWin = vtkRenderWindow::New();
3817 renWin->AddRenderer(renderer);
3819 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3820 iren->SetRenderWindow(renWin);
3822 renderer->AddActor( _3DSliceActor );
3823 renderer->SetActiveCamera(camera);
3824 renderer->ResetCamera();
3825 renderer->SetBackground(1,1,1);
3827 renWin->SetSize(300,300);
3829 // interact with data
3839 //-------------------------------------------------------------------
3840 // EED 25 Janvier 2007 testLoic
3841 void wxVtkMPR3DView::TestLoic2()
3844 vtkVectorNorm *vecMagnitude = vtkVectorNorm::New();
3845 vecMagnitude->SetInput(VtkMainGrid);
3846 vecMagnitude->NormalizeOff();
3847 vecMagnitude->Update();
3850 vtkPlane *slicePlane = vtkPlane::New();
3851 this->_planeWidget->GetPlane( slicePlane );
3854 vtkCutter* sliceCutter = vtkCutter::New();
3855 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3856 sliceCutter->SetInput( vtkimagedata );
3857 sliceCutter->SetCutFunction( slicePlane );
3860 // vtkLookupTable *lut = BuildHueWeightBaseMap();
3863 vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
3864 slice->SetInput( sliceCutter->GetOutput() );
3868 vtkimagedata->GetScalarRange(range);
3869 // vecMagnitude->GetOutput()->GetScalarRange( range );
3870 // range[1] *= 0.7; // reduce the upper range by 30%
3871 // slice->SetScalarRange( range );
3872 // slice->SetLookupTable( lut );
3874 // vtkActor *sliceActor = vtkActor::New();
3875 // sliceActor->SetMapper( slice );
3877 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
3878 contourMapper->SetInput( sliceCutter->GetOutput() );
3879 contourMapper->SetScalarRange( range );
3880 // contourMapper->SetLookupTable( lut );
3883 vtkActor *contourActor = vtkActor::New();
3884 contourActor->SetMapper( contourMapper );
3888 // The usual rendering stuff.
3889 vtkCamera *camera = vtkCamera::New();
3890 camera->SetPosition(1,1,1);
3891 camera->SetFocalPoint(0,0,0);
3893 vtkRenderer *renderer = vtkRenderer::New();
3894 vtkRenderWindow *renWin = vtkRenderWindow::New();
3895 renWin->AddRenderer(renderer);
3897 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3898 iren->SetRenderWindow(renWin);
3900 renderer->AddActor( contourActor );
3901 // renderer->AddActor(cubeActor);
3902 renderer->SetActiveCamera(camera);
3903 renderer->ResetCamera();
3904 renderer->SetBackground(1,1,1);
3906 renWin->SetSize(300,300);
3908 // interact with data
3915 //-------------------------------------------------------------------
3916 //-------------------------------------------------------------------
3917 //-------------------------------------------------------------------
3919 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
3921 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3922 _vtkclipping3Ddataviewer = NULL;
3923 _wxvtkclipping3DviewCntrlPanel = NULL;
3925 _boxWidgetVolume = NULL;
3926 _boxWidgetS1 = NULL;
3929 //-------------------------------------------------------------------
3930 wxVtkClipping3DView::~wxVtkClipping3DView(){
3931 if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
3932 if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
3933 if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
3934 if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
3936 //-------------------------------------------------------------------
3937 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
3942 _boxWidgetS1->Off();
3945 //-------------------------------------------------------------------
3946 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
3948 if (_boxWidgetVolume!=NULL){
3950 _boxWidgetVolume->On();
3952 _boxWidgetVolume->Off();
3956 //-------------------------------------------------------------------
3957 void wxVtkClipping3DView::Refresh()
3959 _vtkclipping3Ddataviewer->Refresh();
3960 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
3962 _wxvtkclipping3DviewCntrlPanel->Refresh();
3965 //-------------------------------------------------------------------
3966 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
3968 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
3969 return _wxvtkclipping3DviewCntrlPanel;
3971 //-------------------------------------------------------------------
3972 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
3974 return _vtkclipping3Ddataviewer;
3976 //-------------------------------------------------------------------
3977 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
3978 if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
3979 if (visTissue==false){
3980 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
3982 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
3983 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
3984 // _actor->VisibilityOn();
3986 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
3989 //-------------------------------------------------------------------
3990 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
3993 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3995 if (representationType==false){
3996 tmpActor->GetProperty()->SetRepresentationToWireframe();
3998 tmpActor->GetProperty()->SetRepresentationToSurface();
4001 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
4004 //-------------------------------------------------------------------
4005 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
4006 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
4007 if (visVolume==false){
4009 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4010 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4013 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
4014 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
4016 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
4019 //-------------------------------------------------------------------
4020 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()
4022 return _wxvtk3Dbaseview;
4024 //-------------------------------------------------------------------
4025 void wxVtkClipping3DView::Configure(){
4026 _wxvtk3Dbaseview->Configure();
4028 // Actors are added to the renderer.
4029 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
4031 _boxWidgetS1 = vtkBoxWidget::New();
4032 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4033 _boxWidgetS1->SetPlaceFactor(1.25);
4037 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
4038 vtkPolyData *polydata= stripper->GetOutput();
4041 _boxWidgetS1->SetInput( polydata );
4042 _boxWidgetS1->PlaceWidget();
4045 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
4047 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
4053 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
4054 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
4056 VisibleActor(0, false );
4057 VisibleActor(1, false );
4058 VisibleActor(2, false );
4059 VisibleActor(3, false );
4061 _boxWidgetS1->HandlesOn ();
4064 // _boxWidgetS1->On();
4066 _boxWidgetS1->Off();
4068 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
4069 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
4070 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
4071 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
4075 _boxWidgetVolume = vtkBoxWidget::New();
4076 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4077 _boxWidgetVolume->SetPlaceFactor(1.25);
4079 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
4080 _boxWidgetVolume->PlaceWidget();
4082 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
4084 _boxWidgetVolume->HandlesOn ();
4087 // _boxWidgetVolume->On();
4089 _boxWidgetVolume->Off();
4092 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
4093 // _boxWidgetVolume->GetPlanes( vtkplanes );
4096 // An initial camera view is created. The Dolly() method moves
4097 // the camera towards the FocalPoint, thereby enlarging the image.
4098 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
4099 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
4100 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
4102 // Set a background color for the renderer and set the size of the
4103 // render window (expressed in pixels).
4104 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
4105 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
4107 // Note that when camera movement occurs (as it does in the Dolly()
4108 // method), the clipping planes often need adjusting. Clipping planes
4109 // consist of two planes: near and far along the view direction. The
4110 // near plane clips out objects in front of the plane; the far plane
4111 // clips out objects behind the plane. This way only what is drawn
4112 // between the planes is actually rendered.
4113 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
4115 //-------------------------------------------------------------------
4116 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
4118 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4122 //---------------------------------------------------------------------------
4123 //---------------------------------------------------------------------------
4124 //---------------------------------------------------------------------------
4125 vtkInteractorStyle3DView::vtkInteractorStyle3DView()
4128 //---------------------------------------------------------------------------
4129 vtkInteractorStyle3DView::~vtkInteractorStyle3DView()
4132 //---------------------------------------------------------------------------
4133 bool vtkInteractorStyle3DView::OnLeftDClick()
4135 SelectMarchibCubePoint();
4138 //---------------------------------------------------------------------------
4139 bool vtkInteractorStyle3DView::SelectMarchibCubePoint()
4142 gtm::TVector< double > pO( 3 ), pF( 3 ), pp( 3 ), cp( 3 );
4143 gtm::TVector< double > xc( 3 );
4144 gtm::TVector< double > x1( 3 ), n1( 3 );
4145 gtm::TVector< double > x2( 3 ), n2( 3 );
4147 double pickPoint[ 3 ], cameraPos[ 3 ];
4149 vtkPointPicker* picker = vtkPointPicker::New( );
4150 eventrwi[0]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
4151 eventrwi[1]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
4152 vtkRenderer *pRenderer = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetRenderer();
4153 picker->Pick( eventrwi[0], eventrwi[1], 0.0, pRenderer );
4154 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
4155 picker->GetPickPosition( pickPoint );
4158 pp( 0 ) = pickPoint[ 0 ]; pp( 1 ) = pickPoint[ 1 ]; pp( 2 ) = pickPoint[ 2 ];
4159 cp( 0 ) = cameraPos[ 0 ]; cp( 1 ) = cameraPos[ 1 ]; cp( 2 ) = cameraPos[ 2 ];
4162 //EED 27 sep 2006 (1/2)
4163 // wxVtkMPR3DView *wxvtkmpr3Dview = (wxVtkMPR3DView *)_vtkInteractorStyleBaseView->GetWxVtk3DBaseView();
4165 // wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetSpacing(spc);
4168 vtkImageData *imageData = GetWxVtkMPR3DView()->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
4171 imageData->GetDimensions(dim);
4172 imageData->GetSpacing(spc);
4175 vtkMarchingCubes *mcubes = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetMCubes(0);
4178 UtilVtk3DGeometriSelection utilVtk3DGeometriSelection;
4179 utilVtk3DGeometriSelection.SetDimentions(dim[0],dim[1],dim[2]);
4181 utilVtk3DGeometriSelection.SetMarchingCube(mcubes);
4184 fac = GTM_MAX( dim[0], dim[2] );
4187 if( utilVtk3DGeometriSelection.FindCubePointsFromPoints(
4188 pO.GetAnsiRef( ), pF.GetAnsiRef( ),
4189 pp.GetAnsiRef( ), cp.GetAnsiRef( ) ) )
4192 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4193 x1.GetAnsiRef( ), n1.GetAnsiRef( ),
4194 pO.GetAnsiRef( ), pF.GetAnsiRef( ) ) )
4196 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4197 x2.GetAnsiRef( ), n2.GetAnsiRef( ),
4198 ( x1 - n1 ).GetAnsiRef( ), ( x1 - ( n1 * fac ) ).GetAnsiRef( ) ) )
4200 xc = ( x2 + x1 ) * 0.5;
4201 //EED 27 sep 2006 (2/2)
4202 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX(xc(0)/spc[0]);
4203 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xc(1)/spc[1]);
4204 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xc(2)/spc[2]);
4205 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4206 this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4215 //-------------------------------------------------------------------
4216 void vtkInteractorStyle3DView::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4218 _wxvtkmpr3Dview = wxvtkmpr3Dview;
4220 //-------------------------------------------------------------------
4221 wxVtkMPR3DView *vtkInteractorStyle3DView::GetWxVtkMPR3DView()
4223 return _wxvtkmpr3Dview;
4225 //-------------------------------------------------------------------
4226 wxVtkClipping3DView *vtkInteractorStyle3DView::GetWxVtkClipping3DView()
4228 return _wxvtkclipping3Dview;
4230 //-------------------------------------------------------------------
4231 void vtkInteractorStyle3DView::SetWxVtkClipping3DView( wxVtkClipping3DView *wxvtkclipping3Dview)
4233 _wxvtkclipping3Dview = wxvtkclipping3Dview;
4238 //-------------------------------------------------------------------
4239 //-------------------------------------------------------------------
4240 //-------------------------------------------------------------------
4241 void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
4245 double delta = 0.000000001;
4247 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4249 if (caller==_pointWidget)
4251 _pointWidget->GetPosition(p);
4253 if (caller==_planeWidget)
4255 _planeWidget->GetCenter(p);
4256 _planeWidget->GetNormal(n);
4257 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
4261 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
4266 // Orientation change
4267 if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
4269 _backNormal[0] = n[0];
4270 _backNormal[1] = n[1];
4271 _backNormal[2] = n[2];
4272 isbv->SetParent_refresh_waiting();
4277 double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
4278 double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
4279 double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
4282 if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
4284 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
4285 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
4286 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
4287 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4288 isbv->BlockRefresh();
4289 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
4290 isbv->SetParent_refresh_waiting();
4291 isbv->vtkInteractorStyleBaseView::OnMouseMove();
4292 isbv->UnBlockRefresh();
4294 isbv->EvaluateToRefresh();
4296 //-------------------------------------------------------------------
4297 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4299 _wxvtkmpr3Dview=wxvtkmpr3Dview;
4301 //-------------------------------------------------------------------
4302 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
4304 _pointWidget=pointWidget;
4306 //-------------------------------------------------------------------
4307 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
4309 _planeWidget=planeWidget;
4311 //-------------------------------------------------------------------
4312 //-------------------------------------------------------------------
4313 //-------------------------------------------------------------------
4315 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
4316 : wxPanel( parent, -1)
4319 _histogrammeVector=NULL;
4322 Create3DViewObjects();
4325 //-------------------------------------------------------------------
4326 wxPanelCuttingImageData::~wxPanelCuttingImageData()
4330 delete _modelSphere;
4331 delete _modelCylinder;
4333 _vtkcube -> Delete();
4334 _vtksphere -> Delete();
4335 _vtkcylinder -> Delete();
4336 _cubeMapper -> Delete();
4337 _sphereMapper -> Delete();
4338 _cylinderMapper -> Delete();
4339 _cubeActor -> Delete();
4340 _sphereActor -> Delete();
4341 _cylinderActor -> Delete();
4342 // _xyplot->RemoveAllInputs();
4343 _xyplot -> Delete();
4344 _histogrammeVector->Delete();
4346 delete _wxvtkbaseView;
4350 //-------------------------------------------------------------------
4351 void wxPanelCuttingImageData::RemoveActors()
4353 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4357 //-------------------------------------------------------------------
4358 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
4360 _wxvtk3Dbaseview=wxvtk3Dbaseview;
4363 //-------------------------------------------------------------------
4365 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
4367 this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4370 //-------------------------------------------------------------------
4371 void wxPanelCuttingImageData::Create3DViewObjects()
4374 _vtksphere = vtkSphereSource::New();
4375 _vtksphere->SetThetaResolution (20);
4376 _vtksphere->SetPhiResolution (20);
4377 _sphereMapper = vtkPolyDataMapper::New();
4378 _sphereMapper->SetInput( _vtksphere->GetOutput() );
4379 _sphereActor = vtkActor::New();
4380 _sphereActor->SetMapper(_sphereMapper);
4381 _sphereActor->SetOrigin(0, 0, 0);
4382 _sphereActor->SetPosition(0, 0, 0);
4383 _sphereActor->GetProperty()->SetColor(1, 0, 0);
4384 _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );
4387 _vtkcube = vtkCubeSource::New();
4388 _vtkcube->SetXLength (1);
4389 _vtkcube->SetYLength (1);
4390 _vtkcube->SetZLength (1);
4391 _cubeMapper = vtkPolyDataMapper::New();
4392 _cubeMapper->SetInput( _vtkcube->GetOutput() );
4393 _cubeActor = vtkActor::New();
4394 _cubeActor->SetMapper(_cubeMapper);
4395 _cubeActor->SetOrigin(0, 0, 0);
4396 _cubeActor->SetPosition(0, 0, 0);
4397 _cubeActor->GetProperty()->SetColor(1, 0, 0);
4398 _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );
4401 _vtkcylinder = vtkCylinderSource::New();
4402 _vtkcylinder->SetResolution(20);
4403 _cylinderMapper = vtkPolyDataMapper::New();
4404 _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
4405 _cylinderActor = vtkActor::New();
4406 _cylinderActor->SetMapper(_cylinderMapper);
4407 _cylinderActor->SetOrigin(0, 0, 0);
4408 _cylinderActor->SetPosition(0, 0, 0);
4409 _cylinderActor->GetProperty()->SetColor(1, 0, 0);
4410 _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );
4415 //-------------------------------------------------------------------
4416 void wxPanelCuttingImageData::CreateModel()
4418 _modelCube = new figureCuttingCubeModel();
4419 _modelSphere = new figureCuttingSphereModel();
4420 _modelCylinder = new figureCuttingCylinderModel();
4422 // _modelCube->SetVtkTransform( _modelCube->GetVtkTransform() );
4423 // _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform() );
4424 // _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform() );
4427 //-------------------------------------------------------------------
4429 void wxPanelCuttingImageData::InitHistogramme()
4432 if (_imageData==NULL)
4436 _imageData->GetScalarRange(rangeA);
4438 _xyplot->RemoveAllInputs();
4440 if ( _histogrammeVector!=NULL )
4442 _histogrammeVector -> Delete();
4445 _histogrammeVector = vtkImageData::New();
4446 _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
4447 _histogrammeVector -> SetScalarTypeToUnsignedShort();
4448 _histogrammeVector -> AllocateScalars();
4449 _histogrammeVector -> Update();
4451 unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4452 int i,size = (int) (rangeA[1]);
4453 for (i=0; i < size; i++)
4458 _xyplot->SetXRange(0, rangeA[1]);
4459 _xyplot->SetYRange(0, 10);
4460 _xyplot->AddInput( _histogrammeVector );
4463 //-------------------------------------------------------------------
4464 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
4466 _xyplot = vtkXYPlotActor::New();
4468 _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
4469 _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
4470 _xyplot->SetXValuesToArcLength();
4471 _xyplot->SetNumberOfXLabels(6);
4473 _xyplot->SetTitle("Histogramme");
4474 _xyplot->SetXTitle("Gray level");
4475 _xyplot->SetYTitle("Occurrences ");
4476 _xyplot->GetProperty()->SetColor(1, 0, 0);
4477 _xyplot->GetProperty()->SetPointSize(2);
4478 vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
4479 tprop->SetColor( 1,0,1 );
4481 _xyplot->SetAxisTitleTextProperty(tprop);
4482 _xyplot->SetAxisLabelTextProperty(tprop);
4483 _xyplot->PlotPointsOn();
4484 _xyplot->GetProperty()->SetPointSize(3);
4486 _wxvtkbaseView = new wxVtkBaseView(this);
4487 _wxvtkbaseView->Configure();
4489 vtkRenderer *ren = vtkRenderer::New();
4490 vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
4491 renWin->AddRenderer( ren );
4492 ren->AddActor2D( _xyplot );
4494 return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
4497 //-------------------------------------------------------------------
4499 void wxPanelCuttingImageData::CreateInterface()
4502 wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); // Principal sizer
4504 wxBoxSizer *sizerH0 = new wxBoxSizer(wxHORIZONTAL ); // type of segmentation figure
4505 wxBoxSizer *sizerH2 = new wxBoxSizer(wxHORIZONTAL ); // scale
4506 wxBoxSizer *sizerH3 = new wxBoxSizer(wxHORIZONTAL ); // rotation
4507 wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL ); // intern extern
4508 wxBoxSizer *sizerH5 = new wxBoxSizer(wxHORIZONTAL ); // Isovalue
4509 wxBoxSizer *sizerH6 = new wxBoxSizer(wxHORIZONTAL ); // Buttons
4510 wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(2 ); // Volumic information
4513 _typeFig = new wxChoice(this,-1);
4514 _opacityFig = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4516 _scaleX = new wxSlider(this,-1,6,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4517 _scaleY = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4518 _scaleZ = new wxSlider(this,-1,7,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4520 _rotationX = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4521 _rotationY = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4522 _rotationZ = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4524 _volIntern = new wxRadioButton(this,-1, _T("Volume intern " ));
4525 _volExtern = new wxRadioButton(this,-1, _T("Volume extern " ));
4527 _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
4529 _isoValue = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4530 _valueBeforeIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4531 _valueAfterIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4533 wxButton *btnExtract = new wxButton(this, -1,_T("Extract"));
4535 _infoToVo = new wxStaticText(this,-1,_T("########################"));
4536 _infoSuVoA = new wxStaticText(this,-1,_T("############"));
4537 _infoSuVo = new wxStaticText(this,-1,_T("############"));
4538 _infoPixLe = new wxStaticText(this,-1,_T("############"));
4539 _infoPixHi = new wxStaticText(this,-1,_T("############"));
4542 wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
4544 _typeFig->Append(_T("Cylindre"));
4545 _typeFig->Append(_T("Cube"));
4546 _typeFig->Append(_T("Sphere"));
4547 _typeFig->SetSelection(0);
4548 _volIntern->SetValue(true);
4550 Connect(_typeFig->GetId() , wxEVT_COMMAND_CHOICE_SELECTED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig );
4552 Connect(_opacityFig->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig );
4553 Connect(_rotationX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4554 Connect(_rotationY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4555 Connect(_rotationZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4556 Connect(_scaleX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4557 Connect(_scaleY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4558 Connect(_scaleZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4559 Connect(btnExtract->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract );
4562 // wxStaticText *text=new wxStaticText(this,-1, " ");
4564 sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type: "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL ,0);
4565 sizerH0 -> Add( _typeFig ,1,wxALL ,0);
4566 sizerH0 -> Add( _opacityFig ,1,wxALL|wxEXPAND ,0);
4568 sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale : ")) ,1,wxALL ,0);
4569 sizerH2 -> Add( _scaleX ,1,wxALL | wxEXPAND ,0 );
4570 sizerH2 -> Add( _scaleY ,1,wxALL | wxEXPAND ,0 );
4571 sizerH2 -> Add( _scaleZ ,1,wxALL | wxEXPAND ,0 );
4573 sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation : ")) ,1,wxALL ,0);
4574 sizerH3 -> Add( _rotationX ,1,wxALL | wxEXPAND ,0 );
4575 sizerH3 -> Add( _rotationY ,1,wxALL | wxEXPAND ,0 );
4576 sizerH3 -> Add( _rotationZ ,1,wxALL | wxEXPAND ,0 );
4579 sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern : ")) ,1,wxALL ,0);
4580 sizerH4 -> Add( _volIntern ,1,wxALL ,0);
4581 sizerH4 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4582 sizerH4 -> Add( _volExtern ,1,wxALL ,0);
4584 sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue ")) ,1,wxALL ,0);
4585 sizerH5 -> Add( _isoValue ,1,wxALL | wxEXPAND ,0 );
4586 sizerH5 -> Add( _valueBeforeIsoValue ,1,wxALL | wxEXPAND ,0 );
4587 sizerH5 -> Add( _valueAfterIsoValue ,1,wxALL | wxEXPAND ,0 );
4589 sizerH6 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4590 sizerH6 -> Add( btnExtract ,1,wxALL ,0);
4592 sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4593 sizerH7 -> Add( _infoToVo , 1 , wxALL ,0);
4594 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume: "), wxDefaultPosition, wxSize(200,12) ) , 1 , wxALL ,0);
4595 sizerH7 -> Add( _infoSuVo , 1 , wxALL ,0);
4596 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4597 sizerH7 -> Add( _infoSuVoA , 1 , wxALL ,0);
4598 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue: ") , wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4599 sizerH7 -> Add( _infoPixLe , 1 , wxALL ,0);
4600 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4601 sizerH7 -> Add( _infoPixHi , 1 , wxALL ,0);
4602 // sizerH7 -> SetMinSize(300, 120);
4605 topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND ,0);
4608 topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND ,0);
4611 topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND ,0);
4614 topsizer -> Add( sizerH4 ,1,wxALL ,0);
4618 topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
4621 topsizer -> Add( sizerH6 , 1 , wxALL ,0);
4624 topsizer -> Add( _histogrammeAccumulated ,1, wxALL ,0);
4626 // Volumic information
4627 topsizer -> Add( sizerH7 , 1 , wxALL|wxEXPAND ,0);
4631 // wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
4632 wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
4633 sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
4634 sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
4637 this->SetAutoLayout(true);
4638 this->SetSizer( sizerHor );
4641 // this->FitInside();
4644 //-------------------------------------------------------------------
4646 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
4651 bool volInt, volExt;
4653 unsigned short *pOrg;
4654 unsigned short *p_histogramme;
4657 long int contAfter = 0;
4658 long int contBefor = 0;
4660 double min=999999999;
4661 double max=-999999999;
4663 volExt=_volExtern->GetValue();
4664 volInt=_volIntern->GetValue();
4665 int isoValue = _isoValue->GetValue();
4666 int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue();
4667 int valueAfterIsoValue = _valueAfterIsoValue ->GetValue();
4670 p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4672 _imageData->GetDimensions(dim);
4673 _imageData->GetSpacing(spc);
4674 _actualCuttingModel->CalculeInversMatrix();
4676 for (xx=0;xx<dim[0]; xx++)
4678 for (yy=0;yy<dim[1]; yy++)
4680 for (zz=0;zz<dim[2];zz++)
4682 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
4683 if ( ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
4685 pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz);
4687 if ((*pOrg)<isoValue)
4690 if (valueBeforeIsoValue!=-1)
4692 *pOrg=valueBeforeIsoValue;
4696 if (valueAfterIsoValue!=-1)
4698 *pOrg=valueAfterIsoValue;
4702 p_histogramme[*pOrg]++;
4703 if (*pOrg<min) min=*pOrg;
4704 if (*pOrg>max) max=*pOrg;
4718 double volumeUnit = spc[0]*spc[1]*spc[2];
4719 long int totalSubVolume = contBefor + contAfter;
4720 double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
4721 double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
4722 infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
4723 infoSuVo.Printf(_T("%ld") , totalSubVolume);
4724 infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
4725 infoPixLe.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
4726 infoPixHi.Printf(_T("%ld pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
4728 _infoToVo->SetLabel(infoToVo);
4729 _infoSuVo->SetLabel(infoSuVo);
4730 _infoSuVoA->SetLabel(infoSuVoA);
4731 _infoPixLe->SetLabel(infoPixLe);
4732 _infoPixHi->SetLabel(infoPixHi);
4735 if ( _histogrammeAccumulated->GetValue()==true )
4738 _histogrammeVector -> GetDimensions ( dimHist );
4740 int i,size=dimHist[0];
4741 for (i=1; i<=size; i++)
4743 p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
4747 _histogrammeVector->Update();
4748 _histogrammeVector->GetScalarRange(range);
4749 _xyplot->SetYRange( 0 , range[1] );
4750 _xyplot->SetXRange( min , max );
4752 _vtkclipping3Ddataviewer->RefreshSurface();
4753 _wxvtkbaseView->Refresh();
4755 // _wxvtkbaseView->RefreshView();
4756 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4757 _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4761 //-------------------------------------------------------------------
4762 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
4764 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4766 if (_typeFig->GetSelection()==0){
4767 _actualCuttingModel=_modelCylinder;
4768 _actualActor=_cylinderActor;
4770 if (_typeFig->GetSelection()==1){
4771 _actualCuttingModel=_modelCube;
4772 _actualActor=_cubeActor;
4774 if (_typeFig->GetSelection()==2){
4775 _actualCuttingModel=_modelSphere;
4776 _actualActor=_sphereActor;
4778 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4783 //-------------------------------------------------------------------
4784 void wxPanelCuttingImageData::RefreshOpacity()
4786 double op= _opacityFig->GetValue()/100.0;
4787 _actualActor->GetProperty()->SetOpacity( op );
4790 //-------------------------------------------------------------------
4791 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
4796 //-------------------------------------------------------------------
4797 void wxPanelCuttingImageData::RefreshView()
4799 SetParamsOfTransformation( );
4802 //-------------------------------------------------------------------
4803 void wxPanelCuttingImageData::Refresh()
4805 _wxvtk3Dbaseview->Refresh();
4808 //-------------------------------------------------------------------
4809 void wxPanelCuttingImageData::SetParamsOfTransformation( )
4812 vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
4813 vtkimagedata->GetSpacing(spc);
4814 int px = (int) (_vtkmprbasedata->GetX() );
4815 int py = (int) (_vtkmprbasedata->GetY() );
4816 int pz = (int) (_vtkmprbasedata->GetZ() );
4817 int sx = (int) (_scaleX->GetValue() * spc[0] );
4818 int sy = (int) (_scaleY->GetValue() * spc[1] );
4819 int sz = (int) (_scaleZ->GetValue() * spc[2] );
4820 _actualCuttingModel -> SetScale ( sx , sy , sz );
4821 _actualCuttingModel -> SetPosition ( px , py , pz );
4822 _actualCuttingModel -> SetRotation ( _rotationX->GetValue() , _rotationY->GetValue() , _rotationZ->GetValue() );
4823 _actualCuttingModel -> SetSpacing ( spc[0] , spc[1] , spc[2] );
4824 _actualCuttingModel -> CalculeMatrix();
4827 //-------------------------------------------------------------------
4829 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
4834 //-------------------------------------------------------------------
4835 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
4837 _vtkmprbasedata = vtkmprbasedata;
4838 _imageData = _vtkmprbasedata->GetImageData();
4841 //-------------------------------------------------------------------
4843 void wxPanelCuttingImageData::Configure()
4845 _actualCuttingModel=_modelCylinder;
4846 _actualActor=_cylinderActor;
4847 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4848 SetParamsOfTransformation();
4854 //-------------------------------------------------------------------
4855 //-------------------------------------------------------------------
4856 //-------------------------------------------------------------------
4859 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
4860 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
4863 //-------------------------------------------------------------------
4865 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
4866 : wxSplitterWindow( parent , -1)
4869 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
4870 this->SetMinimumPaneSize(50);
4872 //-------------------------------------------------------------------
4873 wxWidgetMesure2D::~wxWidgetMesure2D()
4876 //-------------------------------------------------------------------
4877 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
4879 wxPanel *panel = new wxPanel(parent,-1);
4881 _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
4882 _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
4883 _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
4884 _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
4886 _cb_mt_visible->SetValue(true);
4887 _cb_closeContour->SetValue(true);
4888 _cb_visibleText->SetValue(true);
4890 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
4892 sizer->Add(_cb_messuretool);
4893 sizer->Add(_cb_mt_visible);
4894 sizer->Add(_cb_closeContour);
4895 sizer->Add(_cb_visibleText);
4897 panel->SetAutoLayout(true);
4898 panel->SetSizer(sizer);
4899 panel->SetSize(400,30);
4902 // panel->FitInside();
4904 Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
4905 Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
4906 Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
4907 Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
4912 //-------------------------------------------------------------------
4913 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
4915 _wxvtk2Dbaseview = wxvtk2Dbaseview;
4918 _manContourControl_1 = new manualContourControler();
4919 _mContourModel_1 = new manualContourModel();
4920 _mViewContour_1 = new manualViewContour();
4921 _mViewContour_1->SetModel( _mContourModel_1 );
4922 _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
4923 _mViewContour_1->SetRange( 1 );
4927 // _wxvtk2Dbaseview->GetSpacing( spc );
4928 // _mViewContour_1->SetSpacing( spc );
4932 _manContourControl_1->SetZ( 1000 );
4933 _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
4934 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 );
4935 _manContourControl_1->CreateNewManualContour();
4936 _manContourControl_1->SetActive( false );
4937 _mViewContour_1->RefreshContour();
4941 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
4942 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
4943 // CreateWin1a(this->GetWindow1() );
4945 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
4946 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
4947 this->GetWindow1()->SetSizer(sizerA);
4948 this->SetAutoLayout(true);
4951 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
4952 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
4953 this->GetWindow2()->SetSizer(sizerB);
4954 this->SetAutoLayout(true);
4958 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
4962 // this->FitInside();
4966 //-------------------------------------------------------------------
4967 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
4969 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->SetActiveAllInteractors(!ok);
4970 _manContourControl_1->SetActive( ok );
4973 //-------------------------------------------------------------------
4974 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
4976 ActiveMessureTool( _cb_messuretool->GetValue() );
4977 if ( _cb_messuretool->GetValue() == true )
4979 _cb_mt_visible->SetValue(true);
4980 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
4981 _cb_closeContour->Enable(true);
4982 _cb_visibleText->Enable(true);
4984 _cb_closeContour->Enable(false);
4985 _cb_visibleText->Enable(false);
4987 _wxvtk2Dbaseview->Refresh();
4988 _wxvtk2Dbaseview->RefreshView();
4991 //-------------------------------------------------------------------
4992 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
4994 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
4995 if (_cb_messuretool->GetValue()==true)
4997 _cb_closeContour->Enable(true);
4998 _cb_visibleText->Enable(true);
5000 ActiveMessureTool( _cb_messuretool->GetValue() );
5001 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
5002 _mViewContour_1->Refresh();
5003 _wxvtk2Dbaseview->Refresh();
5004 _wxvtk2Dbaseview->RefreshView();
5007 //-------------------------------------------------------------------
5008 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
5010 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
5011 _mViewContour_1->Refresh();
5012 _wxvtk2Dbaseview->Refresh();
5013 _wxvtk2Dbaseview->RefreshView();
5016 //-------------------------------------------------------------------
5017 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
5019 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
5020 _mViewContour_1->Refresh();
5021 _wxvtk2Dbaseview->Refresh();
5022 _wxvtk2Dbaseview->RefreshView();
5024 //-------------------------------------------------------------------
5025 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
5027 _mViewContour_1->SetMesureScale(mesureScale);
5029 //-------------------------------------------------------------------
5030 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
5032 return _mContourModel_1;
5035 //-------------------------------------------------------------------
5036 //-------------------------------------------------------------------
5037 //-------------------------------------------------------------------
5039 wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
5040 : wxWidgetMesure2D(parent)
5044 _circle1Actor = NULL;
5045 _circle1Mapper = NULL;
5049 _circle2Actor = NULL;
5050 _circle2Mapper = NULL;
5053 _ptsLineRef1 = NULL;
5054 _lineRef1Actor = NULL;
5055 _lineRef1Mapper = NULL;
5058 _ptsLineRef2 = NULL;
5059 _lineRef2Actor = NULL;
5060 _lineRef2Mapper = NULL;
5065 //-------------------------------------------------------------------
5067 wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
5070 if ( _ptsCircle1 != NULL){ _ptsCircle1 -> Delete(); }
5071 if ( _circle1Actor != NULL){ _circle1Actor -> Delete(); }
5072 if ( _circle1Mapper != NULL){ _circle1Mapper -> Delete(); }
5073 if ( _pdCircle1 != NULL){ _pdCircle1 -> Delete(); }
5075 if ( _ptsCircle2 != NULL){ _ptsCircle2 -> Delete(); }
5076 if ( _circle2Actor != NULL){ _circle2Actor -> Delete(); }
5077 if ( _circle2Mapper != NULL){ _circle2Mapper -> Delete(); }
5078 if ( _pdCircle2 != NULL){ _pdCircle2 -> Delete(); }
5080 if ( _ptsLineRef1 != NULL){ _ptsLineRef1 -> Delete(); }
5081 if ( _lineRef1Actor != NULL){ _lineRef1Actor -> Delete(); }
5082 if ( _lineRef1Mapper != NULL){ _lineRef1Mapper -> Delete(); }
5083 if ( _pdLineRef1 != NULL){ _pdLineRef1 -> Delete(); }
5085 if ( _ptsLineRef2 != NULL){ _ptsLineRef2 -> Delete(); }
5086 if ( _lineRef2Actor != NULL){ _lineRef2Actor -> Delete(); }
5087 if ( _lineRef2Mapper != NULL){ _lineRef2Mapper -> Delete(); }
5088 if ( _pdLineRef2 != NULL){ _pdLineRef2 -> Delete(); }
5091 //-------------------------------------------------------------------
5093 wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
5095 wxPanel *panel = new wxPanel(parent,-1);
5097 _cb_circle = new wxCheckBox(panel,-1,_T("Circle "));
5098 _cb_line = new wxCheckBox(panel,-1,_T("Rotation Axe "));
5101 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5102 sizerA->Add(_cb_circle);
5103 sizerA->Add(_cb_line);
5106 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5107 sizer->Add( sizerA );
5108 sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
5110 panel->SetAutoLayout(true);
5111 panel->SetSizer(sizer);
5112 panel->SetSize(400,30);
5115 // panel->FitInside();
5117 Connect(_cb_line->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine );
5118 Connect(_cb_circle->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle );
5124 //-------------------------------------------------------------------
5125 void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
5127 SetVisibleCircle( _cb_circle->GetValue() );
5128 _wxvtk2Dbaseview->RefreshView();
5131 //-------------------------------------------------------------------
5132 void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
5141 _lineRef1Actor->GetProperty()->SetOpacity( opacity );
5142 _lineRef2Actor->GetProperty()->SetOpacity( opacity );
5143 _circle1Actor->GetProperty()->SetOpacity( opacity );
5144 _circle2Actor->GetProperty()->SetOpacity( opacity );
5146 //-------------------------------------------------------------------
5147 void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
5149 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5150 vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
5151 _wxvtk2Dbaseview->RefreshView();
5155 //-------------------------------------------------------------------
5156 void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5158 wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
5160 ConfigureCircleLine();
5161 SetVisibleCircle(false);
5165 //-------------------------------------------------------------------
5166 void wxWidgetMesure2D_Plane::ConfigureCircleLine()
5170 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5171 int sizeIma = vtkplane2Dview->GetImgSize();
5174 double k=(360/(maxPts-1)) * (3.1416/180);
5175 double x,y,r1=5,r2=10,r3=15;
5176 for (i=0;i<maxPts;i++)
5180 _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1 , (sizeIma/2) + y*r1 , 1 );
5181 _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2 , (sizeIma/2) + y*r2 , 1 );
5185 ang=(45) * (3.1416/180);
5188 _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5190 ang=(45+180) * (3.1416/180);
5193 _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5196 ang=(135) * (3.1416/180);
5199 _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5201 ang=(135+180) * (3.1416/180);
5204 _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5209 //-------------------------------------------------------------------
5210 void wxWidgetMesure2D_Plane::CircleLine()
5213 vtkCellArray *lines;
5215 vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
5218 // Circle 1 Horizontal
5219 _ptsCircle1 = vtkPoints::New();
5220 _ptsCircle1->SetNumberOfPoints(maxPts);
5221 lines = vtkCellArray::New();
5222 lines->InsertNextCell(maxPts);
5223 for (i=0;i<maxPts;i++)
5225 lines->InsertCellPoint(i);
5226 _ptsCircle1->SetPoint(i, 0 , 0 , 0 );
5228 lines->InsertCellPoint(0);
5229 _ptsCircle1->SetPoint(0, -1000 , -1000 , -1000 );
5230 _ptsCircle1->SetPoint(1, 1000 , 1000 , 1000 );
5232 _pdCircle1 = vtkPolyData::New();
5233 _pdCircle1->SetPoints( _ptsCircle1 );
5234 _pdCircle1->SetLines( lines );
5235 lines->Delete(); //do not delete lines ??
5236 _circle1Actor = vtkActor::New();
5237 _circle1Mapper = vtkPolyDataMapper::New();
5238 _circle1Mapper->SetInput(_pdCircle1);
5239 _circle1Mapper->ImmediateModeRenderingOn();
5240 _circle1Actor->SetMapper(_circle1Mapper);
5241 _circle1Actor->GetProperty()->BackfaceCullingOn();
5242 _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5243 _circle1Actor->GetProperty()->SetLineWidth(2);
5244 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
5246 // Circle 2 Horizontal
5247 _ptsCircle2 = vtkPoints::New();
5248 _ptsCircle2->SetNumberOfPoints(maxPts);
5249 lines = vtkCellArray::New();
5250 lines->InsertNextCell(maxPts);
5251 for (i=0;i<maxPts;i++)
5253 lines->InsertCellPoint(i);
5254 _ptsCircle2->SetPoint(i, 0 , 0 , 0 );
5256 _ptsCircle2->SetPoint(0, -1000 , -1000 , -1000 );
5257 _ptsCircle2->SetPoint(1, 1000 , 1000 , 1000 );
5259 _pdCircle2 = vtkPolyData::New();
5260 _pdCircle2->SetPoints( _ptsCircle2 );
5261 _pdCircle2->SetLines( lines );
5262 lines->Delete(); //do not delete lines ??
5263 _circle2Actor = vtkActor::New();
5264 _circle2Mapper = vtkPolyDataMapper::New();
5265 _circle2Mapper->SetInput(_pdCircle2);
5266 _circle2Mapper->ImmediateModeRenderingOn();
5267 _circle2Actor->SetMapper(_circle2Mapper);
5268 _circle2Actor->GetProperty()->BackfaceCullingOn();
5269 _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5270 _circle2Actor->GetProperty()->SetLineWidth(2);
5271 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
5274 _ptsLineRef1 = vtkPoints::New();
5275 _ptsLineRef1->SetNumberOfPoints(2);
5276 _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
5277 _ptsLineRef1->SetPoint(1, 1000 , 1000 , 1000 );
5278 lines = vtkCellArray::New();
5279 lines->InsertNextCell(2);
5280 lines->InsertCellPoint(0);
5281 lines->InsertCellPoint(1);
5283 _pdLineRef1 = vtkPolyData::New();
5284 _pdLineRef1->SetPoints( _ptsLineRef1 );
5285 _pdLineRef1->SetLines( lines );
5286 lines->Delete(); //do not delete lines ??
5287 _lineRef1Actor = vtkActor::New();
5288 _lineRef1Mapper = vtkPolyDataMapper::New();
5289 _lineRef1Mapper->SetInput(_pdLineRef1);
5290 _lineRef1Mapper->ImmediateModeRenderingOn();
5291 _lineRef1Actor->SetMapper(_lineRef1Mapper);
5292 _lineRef1Actor->GetProperty()->BackfaceCullingOn();
5293 _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5294 _lineRef1Actor->GetProperty()->SetLineWidth(2);
5295 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
5298 _ptsLineRef2 = vtkPoints::New();
5299 _ptsLineRef2->SetNumberOfPoints(2);
5300 _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
5301 _ptsLineRef2->SetPoint(1, 1000 , 1000 , 1000 );
5302 lines = vtkCellArray::New();
5303 lines->InsertNextCell(2);
5304 lines->InsertCellPoint(0);
5305 lines->InsertCellPoint(1);
5307 _pdLineRef2 = vtkPolyData::New();
5308 _pdLineRef2->SetPoints( _ptsLineRef2 );
5309 _pdLineRef2->SetLines( lines );
5310 lines->Delete(); //do not delete lines ??
5311 _lineRef2Actor = vtkActor::New();
5312 _lineRef2Mapper = vtkPolyDataMapper::New();
5313 _lineRef2Mapper->SetInput(_pdLineRef2);
5314 _lineRef2Mapper->ImmediateModeRenderingOn();
5315 _lineRef2Actor->SetMapper(_lineRef2Mapper);
5316 _lineRef2Actor->GetProperty()->BackfaceCullingOn();
5317 _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5318 _lineRef2Actor->GetProperty()->SetLineWidth(2);
5319 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
5325 //-------------------------------------------------------------------
5326 //-------------------------------------------------------------------
5327 //-------------------------------------------------------------------
5329 wxWidgetMesure2D_Plane_in_MPR::wxWidgetMesure2D_Plane_in_MPR(wxWindow *parent)
5330 :wxWidgetMesure2D_Plane(parent)
5332 _vtkplane2Dview=NULL;
5335 //-------------------------------------------------------------------
5337 wxWidgetMesure2D_Plane_in_MPR::~wxWidgetMesure2D_Plane_in_MPR()
5340 //-------------------------------------------------------------------
5341 void wxWidgetMesure2D_Plane_in_MPR::OnActiveLink(wxCommandEvent& event)
5343 if (_vtkplane2Dview!=NULL)
5345 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5346 _vtkplane2Dview->Refresh();
5347 _vtkplane2Dview->RefreshView();
5352 //-------------------------------------------------------------------
5353 void wxWidgetMesure2D_Plane_in_MPR::SetActiveLink(bool ok)
5355 _cb_link->SetValue(ok);
5356 if (_vtkplane2Dview!=NULL)
5358 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5361 //-------------------------------------------------------------------
5363 void wxWidgetMesure2D_Plane_in_MPR::SetVtkPlane2DView(vtkPlane2DView *vtkplane2Dview)
5365 _vtkplane2Dview = vtkplane2Dview;
5368 //-------------------------------------------------------------------
5370 wxWindow *wxWidgetMesure2D_Plane_in_MPR::CreateWin1a(wxWindow *parent) // virtual
5372 wxPanel *panel = new wxPanel(parent,-1);
5374 _cb_link = new wxCheckBox(panel,-1,_T("LINK "));
5375 _cb_link->SetValue(true);
5377 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5379 sizer->Add(_cb_link);
5381 sizer->Add( wxWidgetMesure2D_Plane::CreateWin1a(panel) );
5383 panel->SetAutoLayout(true);
5384 panel->SetSizer(sizer);
5385 panel->SetSize(400,30);
5389 // panel->FitInside();
5391 Connect(_cb_link->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxWidgetMesure2D_Plane_in_MPR::OnActiveLink );
5399 //-------------------------------------------------------------------
5400 //-------------------------------------------------------------------
5401 //-------------------------------------------------------------------
5403 BEGIN_EVENT_TABLE( wxMPRWidget, wxPanel )
5404 EVT_MENU( 12121, wxMPRWidget::OnRefreshView )
5405 EVT_MENU( 12122, wxMPRWidget::OnDClickLeft )
5410 wxMPRWidget::wxMPRWidget( wxWindow* parent,
5411 marImageData *marimageData , double voxelSize)
5412 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
5415 _vtkmpr2Dview[0] = NULL;
5416 _vtkmpr2Dview[1] = NULL;
5417 _vtkmpr2Dview[2] = NULL;
5418 _vtkplane2Dview = NULL;
5419 _widgetMesure = NULL;
5420 _wxsphereview = NULL;
5421 _wxvtk3Dbaseview_MPRClipping3D = NULL;
5422 _wxvtkmpr3Dview = NULL;
5423 _wxvtkclipping3Dview = NULL;
5424 _vtkplane2Dview_B = NULL;
5425 _widgetMesure_B = NULL;
5427 _vtkmpr2Dview_B[0] = NULL;
5428 _vtkmpr2Dview_B[1] = NULL;
5429 _vtkmpr2Dview_B[2] = NULL;
5430 _vtkplane2Dview_B = NULL;
5431 _widgetMesure_B = NULL;
5432 _wxsphereview_B = NULL;
5433 _wxvtk3Dbaseview_MPR3D_B = NULL;
5434 _wxvtkmpr3Dview_B = NULL;
5435 _wxvtk3Dbaseview_Clipping3D_BB = NULL;
5436 _wxvtkmpr3Dview_BB = NULL;
5437 _wxvtkclipping3Dview_BB = NULL;
5439 _vtkmprbasedata = NULL;
5443 _framePanelCutting = NULL;
5444 _panelCutting = NULL;
5447 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
5449 if(marimageData!=NULL){
5450 _marImageData = marimageData;
5451 _voxelSize = voxelSize;
5452 _vtkmprbasedata = new vtkMPRBaseData();
5453 _vtkmprbasedata->SetMarImageData(_marImageData);
5458 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5459 pnlSplitter -> SetMinimumPaneSize( 2 );
5461 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5462 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5463 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5465 sizer -> Add( pnlSplitter ,1,wxGROW ,0);
5470 //wxWindow *pp=this;
5471 //while (pp->GetParent()!=NULL) pp=pp->GetParent();
5472 //pp->GetSize(&ww,&hh);
5474 this -> SetAutoLayout( true );
5475 this -> SetSizer(sizer);
5476 // sizer -> Fit( this );
5481 void wxMPRWidget::setMarImage(marImageData *marimageData, double voxelsize){
5482 _marImageData = marimageData;
5483 _voxelSize = voxelsize;
5484 _vtkmprbasedata = new vtkMPRBaseData();
5485 _vtkmprbasedata->SetMarImageData(_marImageData);
5487 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5488 pnlSplitter -> SetMinimumPaneSize( 2 );
5490 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5491 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5492 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5494 this->GetSizer() -> Add( pnlSplitter ,1,wxGROW ,0);
5496 //----------------------------------------------------------------------------
5498 wxMPRWidget::~wxMPRWidget( )
5501 if (_framePanelCutting!=NULL)
5503 _framePanelCutting->Close();
5506 if (_vtkmpr2Dview[0]!=NULL) { delete _vtkmpr2Dview[0]; }
5507 if (_vtkmpr2Dview[1]!=NULL) { delete _vtkmpr2Dview[1]; }
5508 if (_vtkmpr2Dview[2]!=NULL) { delete _vtkmpr2Dview[2]; }
5510 if (_vtkmpr2Dview_B[0]!=NULL) { delete _vtkmpr2Dview_B[0]; }
5512 if (_vtkmpr2Dview_B[1]!=NULL) { delete _vtkmpr2Dview_B[1]; }
5513 if (_vtkmpr2Dview_B[2]!=NULL) { delete _vtkmpr2Dview_B[2]; }
5515 if (_vtkmprbasedata!=NULL) { delete _vtkmprbasedata; }
5516 if (_vtkplane2Dview!=NULL) { delete _vtkplane2Dview; }
5517 if (_wxsphereview!=NULL) { delete _wxsphereview; }
5518 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL) { delete _wxvtk3Dbaseview_MPRClipping3D; }
5519 if (_wxvtkmpr3Dview!=NULL) { delete _wxvtkmpr3Dview; }
5520 if (_wxvtkclipping3Dview!=NULL) { delete _wxvtkclipping3Dview; }
5522 if (_vtkplane2Dview_B!=NULL) { delete _vtkplane2Dview_B; }
5523 if (_wxsphereview_B!=NULL) { delete _wxsphereview_B; }
5525 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) { delete _wxvtk3Dbaseview_MPR3D_B; }
5526 if (_wxvtkmpr3Dview_B!=NULL) { delete _wxvtkmpr3Dview_B; }
5528 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL) { delete _wxvtk3Dbaseview_Clipping3D_BB; }
5529 if (_wxvtkmpr3Dview_BB!=NULL) { delete _wxvtkmpr3Dview_BB; }
5530 if (_wxvtkclipping3Dview_BB!=NULL) { delete _wxvtkclipping3Dview_BB; }
5533 //----------------------------------------------------------------------------
5535 wxPanel* wxMPRWidget::CreateControlPanel(wxWindow *parent)
5538 wxPanel *panel=new wxPanel(parent,-1);
5541 // wxStaticText *tmpText = new wxStaticText(panel,-1,"");
5543 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"));
5545 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"));
5547 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)"));
5549 wxStaticText *help3Text = new wxStaticText(panel,-1,
5550 _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"));
5552 wxStaticText *help4Text = new wxStaticText(panel,-1,_T("MPR3D:\n see split control"));
5554 wxString text=_T("");
5555 text=text+_T("Clipping: \n");
5556 text=text+_T(" see split control \n");
5557 text=text+_T(" 4 MarchingCubes: \n");
5558 text=text+_T(" color, isovalue, opacity \n");
5559 text=text+_T(" Box:\n");
5560 text=text+_T(" mouse left drag (box): rotation\n");
5561 text=text+_T(" mouse left drag (sphere): size,position\n");
5562 text=text+_T(" mouse right drag (box): box size");
5563 text=text+_T(" Axis: 3D\n");
5564 text=text+_T(" mouse drag: translate\n");
5565 text=text+_T(" shift + mouse drag: translate 2 axis\n");
5566 text=text+_T(" mouse right: scale\n");
5567 text=text+_T(" Plane 3D:\n");
5568 text=text+_T(" mouse drag perpendicular axis: rotate plane\n");
5569 text=text+_T(" mouse drag spheres: size plane\n");
5570 text=text+_T(" ctrl +mouse right over the plane: size plane\n");
5571 text=text+_T(" mouse drag plane: translate\n");
5572 text=text+_T(" middle click perpendicular axis: translate\n");
5573 wxStaticText *help5Text = new wxStaticText(panel,-1, text );
5576 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5577 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5578 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5579 sizer->Add( help0Text );
5581 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5582 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5583 sizer->Add( help1Text );
5585 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5586 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5587 sizer->Add( help2Text );
5589 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5590 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5591 sizer->Add( help3Text );
5593 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5594 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5595 sizer->Add( help4Text );
5597 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5598 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5599 sizer->Add( help5Text );
5601 panel->SetSizer(sizer);
5602 panel->SetAutoLayout(true);
5603 panel->SetSize(350,500);
5608 //----------------------------------------------------------------------------
5610 void wxMPRWidget::OnPageAChanged(wxNotebookEvent & event)
5612 _refreshAPage=event.GetSelection();
5617 //----------------------------------------------------------------------------
5619 void wxMPRWidget::OnPageBChanged(wxNotebookEvent & event)
5621 _refreshBPage=event.GetSelection();
5627 //----------------------------------------------------------------------------
5629 wxPanel* wxMPRWidget::CreateView(int type,wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5632 wxPanel *panel=new wxPanel(parent,-1);
5636 _vtkmpr2Dview_B[0] = new wxVtkMPR2DView(panel,0);
5637 _vtkmpr2Dview_B[0]->SetVtkBaseData(vtkmprbasedata);
5638 wxwindow=_vtkmpr2Dview_B[0]->GetWxVTKRenderWindowInteractor();
5642 _vtkmpr2Dview_B[1] = new wxVtkMPR2DView(panel,1);
5643 _vtkmpr2Dview_B[1]->SetVtkBaseData(vtkmprbasedata);
5644 wxwindow=_vtkmpr2Dview_B[1]->GetWxVTKRenderWindowInteractor();
5648 _vtkmpr2Dview_B[2] = new wxVtkMPR2DView(panel,2);
5649 _vtkmpr2Dview_B[2]->SetVtkBaseData(vtkmprbasedata);
5650 wxwindow=_vtkmpr2Dview_B[2]->GetWxVTKRenderWindowInteractor();
5654 _widgetMesure_B = new wxWidgetMesure2D_Plane_in_MPR(panel);
5655 _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
5656 _widgetMesure_B->SetVtkPlane2DView( _vtkplane2Dview_B );
5657 _vtkplane2Dview_B->SetImgSize( 200 );
5658 _vtkplane2Dview_B->SetVtkBaseData(vtkmprbasedata);
5659 wxwindow = _widgetMesure_B;
5663 _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
5664 wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor();
5669 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( panel , -1);
5670 _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D );
5672 _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
5673 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5674 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5675 vtkmpr3Ddataviewer->Configure();
5676 _wxvtkmpr3Dview_B->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5678 wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
5679 wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D);
5682 panelMPR3D -> SetMinimumPaneSize( 5 );
5683 panelMPR3D -> SplitHorizontally( controlPanel3D,window3D,600 );
5685 wxwindow=panelMPR3D;
5690 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
5691 _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D );
5693 _wxvtkclipping3Dview_BB = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_BB);
5694 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5695 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5696 vtkclipping3Ddataviewer->Configure();
5697 _wxvtkclipping3Dview_BB->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5699 _wxvtkmpr3Dview_BB = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_BB );
5700 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5701 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5702 vtkmpr3Ddataviewer->Configure();
5703 _wxvtkmpr3Dview_BB->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5705 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
5707 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
5708 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl);
5709 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateControlPanel(panelControl);
5710 _btnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
5711 Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
5713 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5714 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5715 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5716 sizerCtrol->Add( _btnCutImageData , 1, wxALL, 2);
5718 panelControl->SetAutoLayout(true);
5719 panelControl->SetSizer(sizerCtrol);
5720 panelControl->SetSize(400,350);
5721 panelControl->Layout();
5723 // panelControl->FitInside();
5726 panelClipping3D -> SetMinimumPaneSize( 5 );
5727 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
5728 wxwindow=panelClipping3D;
5731 wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
5732 sizerH1->Add(wxwindow , 1, wxALL|wxGROW, 0);
5733 panel->SetAutoLayout(true);
5734 panel->SetSizer(sizerH1);
5735 panel->SetSize(400,400);
5741 //----------------------------------------------------------------------------
5743 wxPanel* wxMPRWidget::CreateMPRPanel(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5745 wxPanel *panel=new wxPanel(parent,-1);
5747 wxNotebook *notebook = new wxNotebook( panel, -1 );
5749 notebook->AddPage( CreateMPRPanel4View( notebook ,vtkmprbasedata), _T("4-View") );
5750 notebook->AddPage( CreateView(0,notebook,vtkmprbasedata) , _T("Axial") );
5751 notebook->AddPage( CreateView(1,notebook,vtkmprbasedata) , _T("Sagital") );
5752 notebook->AddPage( CreateView(2,notebook,vtkmprbasedata) , _T("Coronal") );
5753 notebook->AddPage( CreateView(3,notebook,vtkmprbasedata) , _T("Plane") );
5754 notebook->AddPage( CreateView(4,notebook,vtkmprbasedata) , _T("Sphere") );
5755 notebook->AddPage( CreateView(5,notebook,vtkmprbasedata) , _T("MPR 3D") );
5756 notebook->AddPage( CreateView(6,notebook,vtkmprbasedata) , _T("Clipping") );
5757 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageAChanged );
5759 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
5760 sizer->Add(notebook , 1, wxALL|wxGROW, 2);
5761 panel->SetAutoLayout(true);
5762 panel->SetSizer(sizer);
5763 panel->SetSize(400,400);
5767 // panel->FitInside();
5773 //----------------------------------------------------------------------------
5775 wxPanel* wxMPRWidget::CreateMPRPanel4View(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5777 wxPanel *panel=new wxPanel(parent,-1);
5780 _vtkmpr2Dview[0] = new wxVtkMPR2DView(panel,0);
5781 _vtkmpr2Dview[0]->SetVtkBaseData(vtkmprbasedata);
5782 wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
5785 _vtkmpr2Dview[1] = new wxVtkMPR2DView(panel,1);
5786 _vtkmpr2Dview[1]->SetVtkBaseData(vtkmprbasedata);
5787 wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
5790 _vtkmpr2Dview[2] = new wxVtkMPR2DView(panel,2);
5791 _vtkmpr2Dview[2]->SetVtkBaseData(vtkmprbasedata);
5792 wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
5795 wxNotebook *notebook = new wxNotebook( panel, -1 );
5796 notebook->SetSize(400,400);
5800 _widgetMesure = new wxWidgetMesure2D_Plane_in_MPR(notebook);
5801 _vtkplane2Dview = new vtkPlane2DView( _widgetMesure->GetWindow2() );
5802 _widgetMesure->SetVtkPlane2DView( _vtkplane2Dview );
5803 _vtkplane2Dview->SetImgSize( 200 );
5804 _vtkplane2Dview->SetVtkBaseData(vtkmprbasedata);
5805 notebook->AddPage( _widgetMesure, _T("Plane") );
5808 _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
5809 wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
5810 notebook->AddPage( iren3B, _T("Sphere") );
5814 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( notebook , -1);
5815 _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D );
5817 _wxvtkmpr3Dview = new wxVtkMPR3DView( _wxvtk3Dbaseview_MPRClipping3D );
5818 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5819 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5820 vtkmpr3Ddataviewer->Configure();
5821 _wxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5824 _wxvtkclipping3Dview = new wxVtkClipping3DView( _wxvtk3Dbaseview_MPRClipping3D );
5825 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5826 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5827 vtkclipping3Ddataviewer->Configure();
5828 _wxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5831 wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
5833 wxPanel *panelControl = new wxPanel(panelMPR3D,-1);
5834 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl);
5835 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateControlPanel(panelControl);
5840 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
5841 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5842 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5843 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5846 panelControl->SetAutoLayout(true);
5847 panelControl->SetSizer(sizerCtrol);
5848 panelControl->SetSize(400,150);
5849 panelControl->Layout();
5852 panelMPR3D -> SetMinimumPaneSize( 5 );
5854 panelMPR3D -> SplitHorizontally( panelControl,window3D,200 );
5856 notebook->AddPage( panelMPR3D, _T("MPR 3D - Clipping") );
5859 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageBChanged );
5861 wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
5862 wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
5863 wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
5864 sizerH1->Add(iren2 , 1, wxALL|wxEXPAND, 2);
5865 sizerH1->Add(iren0 , 1, wxALL|wxEXPAND, 2);
5866 sizerH2->Add(iren1 , 1, wxALL|wxEXPAND, 2);
5867 // sizerH2->Add(iren3 , 1, wxALL|wxEXPAND, 2);
5868 sizerH2->Add(notebook , 1, wxALL|wxEXPAND, 2);
5870 sizerV->Add(sizerH1, 1, wxALL|wxEXPAND, 0);
5871 sizerV->Add(sizerH2, 1, wxALL|wxEXPAND, 0);
5873 panel->SetAutoLayout(true);
5874 panel->SetSizer(sizerV);
5875 panel->SetSize(400,400);
5880 //----------------------------------------------------------------------------
5881 void wxMPRWidget::OnCutImagaData(wxCommandEvent &event)
5883 if (_btnCutImageData->GetValue()==true){
5884 _framePanelCutting = new wxFrame(this,-1,_T("Cutting Module"),wxDefaultPosition,wxDefaultSize,wxCAPTION|wxSTAY_ON_TOP| wxRESIZE_BORDER );
5885 _framePanelCutting->SetSize(550,400);
5886 _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
5887 _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
5888 _panelCutting->SetVtkMPRBaseData( GetVtkMPRBaseData() );
5889 _panelCutting->SetVtkClipping3DDataViewer( this->_wxvtkclipping3Dview_BB->GetVtkClipping3DDataViewer() );
5890 _panelCutting->Configure( );
5892 wxBoxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL );
5893 topsizer -> Add( _panelCutting ,1,wxALL ,0);
5894 _framePanelCutting->SetAutoLayout(true);
5895 _framePanelCutting->SetSizer( topsizer ); // use the sizer for layout
5896 _framePanelCutting->Layout();
5898 // _framePanelCutting->FitInside();
5900 _framePanelCutting->Show();
5902 if (_framePanelCutting!=NULL){
5903 _panelCutting->RemoveActors();
5904 _framePanelCutting->Close();
5905 _framePanelCutting = NULL;
5906 _panelCutting = NULL;
5911 //----------------------------------------------------------------------------
5912 void wxMPRWidget::ConfigureVTK(){
5915 if (_vtkmprbasedata!=NULL)
5917 x=_vtkmprbasedata -> GetMaxPositionX()/2;
5918 y=_vtkmprbasedata -> GetMaxPositionY()/2;
5919 z=_vtkmprbasedata -> GetMaxPositionZ()/2;
5922 if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
5923 if(_vtkmpr2Dview[1]!=NULL) {_vtkmpr2Dview[1] -> Configure();}
5924 if(_vtkmpr2Dview[2]!=NULL) {_vtkmpr2Dview[2] -> Configure();}
5927 if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0] -> Configure(); }
5928 if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1] -> Configure(); }
5929 if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
5932 if (_vtkmprbasedata!=NULL)
5934 _vtkmprbasedata->SetX( x );
5935 _vtkmprbasedata->SetY( y );
5936 _vtkmprbasedata->SetZ( z );
5939 if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
5940 if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
5941 if (_widgetMesure!=NULL){_widgetMesure -> SetActiveLink(true);}
5942 if (_widgetMesure!=NULL){_widgetMesure -> SetMesureScale( _voxelSize );}
5943 if (_wxsphereview!=NULL){_wxsphereview -> Configure();}
5945 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D -> Configure();}
5946 if (_wxvtkmpr3Dview!=NULL){
5947 _wxvtkmpr3Dview -> Configure();
5949 if (_wxvtkclipping3Dview!=NULL){_wxvtkclipping3Dview -> Configure();}
5951 if (_vtkplane2Dview_B!=NULL){ _vtkplane2Dview_B -> Configure(); }
5952 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> ConfigureA( _vtkplane2Dview_B ); }
5953 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> SetActiveLink(true); }
5957 // vtkImageData *imageData = _vtkmprbasedata->GetImageData();
5958 // imageData->Update();
5959 // imageData->GetSpacing(spc);
5960 // _widgetMesure_B->SetMesureScale(spc[0]);
5962 if (_widgetMesure_B!=NULL) {_widgetMesure_B->SetMesureScale( _voxelSize );}
5965 if (_wxsphereview_B!=NULL) {_wxsphereview_B -> Configure();}
5967 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) {_wxvtk3Dbaseview_MPR3D_B -> Configure();}
5968 if (_wxvtkmpr3Dview_B!=NULL) {_wxvtkmpr3Dview_B -> Configure();}
5970 if ( _wxvtk3Dbaseview_Clipping3D_BB!=NULL) {_wxvtk3Dbaseview_Clipping3D_BB -> Configure(); }
5971 if ( _wxvtkmpr3Dview_BB!=NULL) {_wxvtkmpr3Dview_BB -> Configure(); }
5972 if ( _wxvtkclipping3Dview_BB!=NULL) {_wxvtkclipping3Dview_BB -> Configure(); }
5975 vtkInteractorStyle3DView *vtkinteractorstyle3Dview;
5976 if (_wxvtkmpr3Dview_BB!=NULL)
5978 vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
5979 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_BB);
5980 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_BB);
5983 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL)
5985 _wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
5989 // RefreshView(true);
5993 //----------------------------------------------------------------------------
5995 void wxMPRWidget::OnRefreshView(wxCommandEvent & event)
5999 //----------------------------------------------------------------------------
6000 void wxMPRWidget::OnDClickLeft(wxCommandEvent & event)
6002 if (_wxsphereview!=NULL) {
6003 _wxsphereview -> RefreshPoint();
6005 if (_wxsphereview_B!=NULL) {
6006 _wxsphereview_B -> RefreshPoint();
6009 //----------------------------------------------------------------------------
6010 void wxMPRWidget::RefreshView(bool firsttime){
6012 if (_refreshAPage == 0 )
6015 if ((_vtkmpr2Dview[0]!=NULL) && (_vtkmpr2Dview[1]!=NULL) && (_vtkmpr2Dview[2]!=NULL) )
6017 _vtkmpr2Dview[2] -> Refresh();
6018 _vtkmpr2Dview[1] -> Refresh();
6019 _vtkmpr2Dview[0] -> Refresh();
6021 if (firsttime==false)
6023 _vtkmpr2Dview[2] -> RefreshView();
6024 _vtkmpr2Dview[1] -> RefreshView();
6025 _vtkmpr2Dview[0] -> RefreshView();
6028 if (_refreshBPage == 0 )
6030 if (_vtkplane2Dview!=NULL)
6032 _vtkplane2Dview -> Refresh();
6033 if (firsttime==false)
6035 _vtkplane2Dview -> RefreshView();
6037 // _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6040 if (_refreshBPage == 1 )
6044 if (_refreshBPage == 2 )
6046 if ((_wxvtkmpr3Dview!=NULL) && (_wxvtk3Dbaseview_MPRClipping3D!=NULL) && (_wxvtkclipping3Dview!=NULL) )
6048 _wxvtkmpr3Dview -> RefreshView();
6049 _wxvtk3Dbaseview_MPRClipping3D -> Refresh();
6050 _wxvtkclipping3Dview -> Refresh();
6056 if (_refreshAPage == 1 )
6058 if (_vtkmpr2Dview_B[0] !=NULL){
6059 _vtkmpr2Dview_B[0] -> Refresh();
6062 if (_refreshAPage == 2 )
6064 if (_vtkmpr2Dview_B[1] !=NULL){
6065 _vtkmpr2Dview_B[1] -> Refresh();
6068 if (_refreshAPage == 3 )
6070 if (_vtkmpr2Dview_B[2] !=NULL){
6071 _vtkmpr2Dview_B[2] -> Refresh();
6074 if (_refreshAPage == 4 )
6076 if (_vtkplane2Dview_B!=NULL){
6077 _vtkplane2Dview_B -> Refresh();
6078 if (firsttime==false)
6080 _vtkplane2Dview_B -> RefreshView();
6085 if (_refreshAPage == 5 )
6089 if (_refreshAPage == 6 )
6091 if (_wxvtkmpr3Dview_B!=NULL){
6092 _wxvtkmpr3Dview_B -> Refresh();
6093 _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6096 if (_refreshAPage == 7 )
6098 if (_wxvtkmpr3Dview_BB!=NULL){
6099 _wxvtkmpr3Dview_BB -> RefreshView();
6100 _wxvtkclipping3Dview_BB -> Refresh();
6101 _wxvtk3Dbaseview_Clipping3D_BB -> Refresh();
6102 if (_panelCutting!=NULL)
6104 _panelCutting->RefreshView();
6110 //----------------------------------------------------------------------------
6111 vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
6112 return _vtkmprbasedata;
6114 //----------------------------------------------------------------------------
6115 vtkPlane2DView *wxMPRWidget::GetVtkPlane2DView()
6117 return _vtkplane2Dview;
6119 //----------------------------------------------------------------------------
6120 wxVtkMPR3DView *wxMPRWidget::GetWxvtkmpr3Dview_BB()
6122 return _wxvtkmpr3Dview_BB;
6124 //----------------------------------------------------------------------------
6125 wxVtkBaseView *wxMPRWidget::GetWxVtkBaseView(int page, int id)
6127 wxVtkBaseView *result=NULL;
6130 if ((id>=0) &&(id<=3)){
6131 result=_vtkmpr2Dview[id];
6135 result=_vtkplane2Dview;
6140 //----------------------------------------------------------------------------
6141 wxVtkMPR2DView *wxMPRWidget::GetWxvtkMPR2Dview(int direction)
6143 return _vtkmpr2Dview[direction];
6146 //----------------------------------------------------------------------------
6147 //----------------------------------------------------------------------------
6148 //----------------------------------------------------------------------------
6149 wxMPRWidget2::wxMPRWidget2(wxWindow* parent,marImageData *marimagedata,double voxelSize)
6150 : wxMPRWidget(parent,marimagedata,voxelSize)
6153 //----------------------------------------------------------------------------
6154 wxMPRWidget2::~wxMPRWidget2()
6157 //----------------------------------------------------------------------------
6158 void wxMPRWidget2::OnRefreshView(wxCommandEvent & event) // Virtual
6160 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
6161 this->GetParent()->ProcessEvent(newevent1);
6165 //----------------------------------------------------------------------------
6166 //----------------------------------------------------------------------------
6167 //----------------------------------------------------------------------------
6168 figureCuttingModel::figureCuttingModel()
6170 _inversModel = vtkTransform::New();
6171 _matrixModel = vtkTransform::New();
6172 _matrixVisual = vtkTransform::New();
6178 //----------------------------------------------------------------------------
6179 figureCuttingModel::~figureCuttingModel() // virtual
6181 _inversModel->Delete();
6183 //----------------------------------------------------------------------------
6184 void figureCuttingModel::SetPosition(double x,double y, double z)
6190 //----------------------------------------------------------------------------
6191 void figureCuttingModel::SetScale(double sx,double sy, double sz)
6197 //----------------------------------------------------------------------------
6198 void figureCuttingModel::SetRotation(double alfa,double beta, double teta)
6205 //----------------------------------------------------------------------------
6206 void figureCuttingModel::CalculeMatrix()
6208 _matrixModel->Identity();
6209 _matrixModel->Translate(_px,_py,_pz);
6210 _matrixModel->RotateY(_beta);
6211 _matrixModel->RotateX(_alfa);
6212 _matrixModel->RotateY(_teta);
6213 _matrixModel->Scale(_sx,_sy,_sz);
6215 _matrixVisual->Identity();
6216 _matrixVisual->Translate( _px*_spcX , _py*_spcY , _pz*_spcZ );
6217 _matrixVisual->RotateY(_beta);
6218 _matrixVisual->RotateX(_alfa);
6219 _matrixVisual->RotateY(_teta);
6220 _matrixVisual->Scale( _sx*_spcX , _sy*_spcY , _sz*_spcZ );
6225 //----------------------------------------------------------------------------
6226 void figureCuttingModel::CalculeInversMatrix()
6228 _inversModel->Identity ();
6229 _inversModel->Concatenate ( _matrixModel );
6230 _inversModel->Inverse();
6232 //----------------------------------------------------------------------------
6233 bool figureCuttingModel::IfPointInside(double x, double y, double z) // virtual
6238 //----------------------------------------------------------------------------
6239 vtkTransform *figureCuttingModel::GetVtkTransform()
6241 return _matrixVisual;
6244 //----------------------------------------------------------------------------
6245 //void figureCuttingModel::SetVtkTransform(vtkTransform *matrix)
6247 // _matrixModel = matrix;
6250 //----------------------------------------------------------------------------
6251 double figureCuttingModel::GetTheoricVolume() // virtual
6256 //----------------------------------------------------------------------------
6257 double figureCuttingModel::GetPositionX()
6261 //----------------------------------------------------------------------------
6262 double figureCuttingModel::GetPositionY()
6266 //----------------------------------------------------------------------------
6267 double figureCuttingModel::GetPositionZ()
6271 //----------------------------------------------------------------------------
6272 double figureCuttingModel::GetScaleX()
6276 //----------------------------------------------------------------------------
6277 double figureCuttingModel::GetScaleY()
6281 //----------------------------------------------------------------------------
6282 double figureCuttingModel::GetScaleZ()
6286 //----------------------------------------------------------------------------
6287 double figureCuttingModel::GetAngleAlfa()
6291 //----------------------------------------------------------------------------
6292 double figureCuttingModel::GetAngleBeta()
6296 //----------------------------------------------------------------------------
6297 double figureCuttingModel::GetAngleTeta()
6301 //----------------------------------------------------------------------------
6302 char *figureCuttingModel::GetName() // virtual
6307 //----------------------------------------------------------------------------
6308 void figureCuttingModel::SetSpacing(double spcX,double spcY, double spcZ)
6315 //----------------------------------------------------------------------------
6318 //----------------------------------------------------------------------------
6319 //----------------------------------------------------------------------------
6320 //----------------------------------------------------------------------------
6321 figureCuttingSphereModel::figureCuttingSphereModel()
6324 //----------------------------------------------------------------------------
6325 figureCuttingSphereModel::~figureCuttingSphereModel() // virtual
6328 //----------------------------------------------------------------------------
6329 bool figureCuttingSphereModel::IfPointInside(double x, double y, double z) // virtual
6331 double in[4],out[4];
6336 _inversModel->MultiplyPoint (in, out);
6339 if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
6345 //----------------------------------------------------------------------------
6346 double figureCuttingSphereModel::GetTheoricVolume() // virtual
6348 double piTMP=3.14159265;
6349 return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
6351 //----------------------------------------------------------------------------
6352 char *figureCuttingSphereModel::GetName() // virtual
6358 //----------------------------------------------------------------------------
6359 //----------------------------------------------------------------------------
6360 //----------------------------------------------------------------------------
6361 figureCuttingCubeModel::figureCuttingCubeModel()
6364 //----------------------------------------------------------------------------
6365 figureCuttingCubeModel::~figureCuttingCubeModel() // virtual
6368 //----------------------------------------------------------------------------
6369 bool figureCuttingCubeModel::IfPointInside(double x, double y, double z) // virtual
6371 double in[4],out[4];
6376 _inversModel->MultiplyPoint (in, out);
6379 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) )
6385 //----------------------------------------------------------------------------
6386 double figureCuttingCubeModel::GetTheoricVolume() // virtual
6388 return _sx * _sy * _sz;
6391 //----------------------------------------------------------------------------
6392 char *figureCuttingCubeModel::GetName() // virtual
6397 //----------------------------------------------------------------------------
6398 //----------------------------------------------------------------------------
6399 //----------------------------------------------------------------------------
6401 figureCuttingCylinderModel::figureCuttingCylinderModel()
6404 //----------------------------------------------------------------------------
6405 figureCuttingCylinderModel::~figureCuttingCylinderModel() // virtual
6408 //----------------------------------------------------------------------------
6409 bool figureCuttingCylinderModel::IfPointInside(double x, double y, double z) // virtual
6411 double in[4],out[4];
6416 _inversModel->MultiplyPoint (in, out);
6419 if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 ) && (out[1]>-0.5) && (out[1]<0.5) )
6425 //----------------------------------------------------------------------------
6426 double figureCuttingCylinderModel::GetTheoricVolume() // virtual
6428 double piTMP=3.14159265;
6429 return piTMP*(_sx/2)*(_sz/2)*_sy;
6431 //----------------------------------------------------------------------------
6432 char *figureCuttingCylinderModel::GetName() // virtual
6436 //----------------------------------------------------------------------------
6440 // EOF - wxMPRWidget.cxx