1 /*=========================================================================
4 Module: $RCSfile: wxMPRWidget.cxx,v $
6 Date: $Date: 2008/11/14 16:16:32 $
7 Version: $Revision: 1.4 $
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();
1384 camera->SetViewUp ( 0 , 1 , 0 );
1385 camera->SetFocalPoint ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 0 );
1386 camera->SetPosition ((0+_sizeIma)/2 , (0+_sizeIma)/2 , 10000 );
1387 camera->SetClippingRange(0.01, 100000);
1388 camera->ComputeViewPlaneNormal();
1389 camera->SetParallelScale( _sizeIma/3.0 );
1391 // text information over the graphic window
1392 _vtkInfoTextImage = new vtkInfoTextImage();
1393 _vtkInfoTextImageInteractorPlane2D = new vtkInfoTextImageInteractorPlane2D();
1394 _vtkInfoTextImage->SetWxVtk2DBaseView(this);
1395 _vtkInfoTextImage->SetMarImageData( GetVtkmprbasedata()->GetMarImageData() );
1396 _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);
1397 _vtkInfoTextImage->Configure();
1398 this->GetInteractorStyleBaseView()->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
1403 //-------------------------------------------------------------------
1404 void vtkPlane2DView::HorizontalLine()
1407 _pts = vtkPoints::New();
1408 _pts->SetNumberOfPoints(2);
1409 _pts->SetPoint(0, -1000 , -1000 , -1000 );
1410 _pts->SetPoint(1, 1000 , 1000 , 1000 );
1411 vtkCellArray *lines = vtkCellArray::New();
1412 lines->InsertNextCell(2);
1413 lines->InsertCellPoint(0);
1414 lines->InsertCellPoint(1);
1415 _pd = vtkPolyData::New();
1416 _pd->SetPoints( _pts );
1417 _pd->SetLines( lines );
1418 lines->Delete(); //do not delete lines ??
1419 _lineActor = vtkActor::New();
1420 _lineMapper = vtkPolyDataMapper::New();
1421 _lineMapper->SetInput(_pd);
1422 _lineMapper->ImmediateModeRenderingOn();
1423 _lineActor->SetMapper(_lineMapper);
1424 _lineActor->GetProperty()->BackfaceCullingOn();
1425 _lineActor->GetProperty()->SetDiffuseColor(0,0,1);
1426 _lineActor->GetProperty()->SetLineWidth(2);
1427 _lineActor->GetProperty()->SetOpacity(0);
1428 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineActor );
1431 //-------------------------------------------------------------------
1432 void vtkPlane2DView::RotationStart()
1434 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1435 vtkTransform *transform = mprbasedata->GetTransformOrientation();
1436 _transform1->SetMatrix( transform->GetMatrix() );
1438 //-------------------------------------------------------------------
1439 void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
1443 _ang =sqrt( vx*vx + vy*vy ) / 1.5;
1450 _transform2->Identity();
1451 _transform2->RotateWXYZ(_ang,0,_vxb,_vyb);
1453 vtkMPRBaseData *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
1454 vtkTransform *transform = vtkTransform::New();
1455 transform->Identity();
1456 transform->Concatenate(_transform1);
1457 transform->Concatenate(_transform2);
1458 mprbasedata->InitTransformOrientation(transform);
1459 transform->Delete();
1461 // Refresh Horizontal Line
1462 _pts->SetPoint( 0 , (_sizeIma/2) - _vxb*2 , (_sizeIma/2) - _vyb*2 , 1 );
1463 _pts->SetPoint( 1 , (_sizeIma/2) + _vxb*2 , (_sizeIma/2) + _vyb*2 , 1 );
1464 // RefreshCircleLine();
1467 //-------------------------------------------------------------------
1468 void vtkPlane2DView::Refresh( )
1471 wxVtkBaseView::Refresh();
1473 //-------------------------------------------------------------------
1474 void vtkPlane2DView::SetImgSize( int imgSize )
1478 //-------------------------------------------------------------------
1479 int vtkPlane2DView::GetImgSize()
1483 //-------------------------------------------------------------------
1484 int vtkPlane2DView::GetActualSlice() // virtual
1486 _cx = GetVtkmprbasedata()->GetX();
1487 _cy = GetVtkmprbasedata()->GetY();
1488 _cz = GetVtkmprbasedata()->GetZ();
1492 //-------------------------------------------------------------------
1494 bool vtkPlane2DView::GetMipVisualization()
1496 return _mip_visualization;
1499 //-------------------------------------------------------------------
1500 int vtkPlane2DView::GetMipWidth()
1505 //-------------------------------------------------------------------
1506 void vtkPlane2DView::SetActualSlice(int slice) // Virtual
1508 double dir=(double)slice/3.0;
1509 GetVtkmprbasedata()->SetX( _cx + (_n[0]*dir) );
1510 GetVtkmprbasedata()->SetY( _cy + (_n[1]*dir) );
1511 GetVtkmprbasedata()->SetZ( _cz + (_n[2]*dir) );
1513 //---------------------------------------------------------------------------
1514 vtkInteractorStylePlane2D *vtkPlane2DView::GetInteractorstyleplane2D()
1516 return this->_interactorstyleplane2D;
1518 //---------------------------------------------------------------------------
1519 void vtkPlane2DView::SetActive(bool active)
1524 //---------------------------------------------------------------------------
1526 void vtkPlane2DView::SetMipVisualization(bool ok)
1528 _mip_visualization=ok;
1531 //---------------------------------------------------------------------------
1533 void vtkPlane2DView::SetMipWidth(int value)
1538 //---------------------------------------------------------------------------
1539 void vtkPlane2DView::SetVisibleLine(bool ok)
1548 _lineActor->GetProperty()->SetOpacity(opacity);
1550 // ----------------------------------------------------------------------------
1551 void vtkPlane2DView::TransfromeCoordViewWorld2(double &X, double &Y, double &Z)
1554 GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
1560 TransfromeCoordScreenToWorld(xx,yy,zz);
1563 vtkTransform *transf1 = vtkTransform::New();
1564 transf1->Identity();
1565 vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
1566 transf1->Concatenate(transf2->GetMatrix());
1567 double in[4], out[4];
1568 double center = GetImgSize() / 2;
1570 in[1] = xx - center;
1571 in[2] = yy - center;
1574 transf1->MultiplyPoint(in,out);
1577 X = out[0] + GetVtkmprbasedata()->GetX() ;
1578 Y = out[1] + GetVtkmprbasedata()->GetY() ;
1579 Z = out[2] + GetVtkmprbasedata()->GetZ() ;
1583 //-------------------------------------------------------------------
1584 //-------------------------------------------------------------------
1585 //-------------------------------------------------------------------
1586 vtkInfoTextImageInteractorPlane2D::vtkInfoTextImageInteractorPlane2D()
1589 //-------------------------------------------------------------------
1590 vtkInfoTextImageInteractorPlane2D::~vtkInfoTextImageInteractorPlane2D()
1593 //-------------------------------------------------------------------
1594 bool vtkInfoTextImageInteractorPlane2D::OnMouseMove()
1597 wxVTKRenderWindowInteractor *wxVTKiren;
1598 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
1599 wxVTKiren->GetEventPosition(X,Y);
1601 int z = (int) (_vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetVtkBaseData()->GetZ());
1602 double xx=X,yy=Y,zz=z;
1605 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
1606 vtkplane2Dview->TransfromeCoordViewWorld2(xx,yy,zz);
1608 GetVtkInfoTextImage()->PutWindowLevel();
1609 GetVtkInfoTextImage()->PutColorLevel();
1610 GetVtkInfoTextImage()->PutPosition( (int)xx , (int)yy , (int)zz );
1611 GetVtkInfoTextImage()->PutPixelIntensity( (int)xx , (int)yy , (int)zz );
1613 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
1617 // ----------------------------------------------------------------------------
1618 // ----------------------------------------------------------------------------
1619 // ----------------------------------------------------------------------------
1620 manualViewPerpPlaneContour::manualViewPerpPlaneContour()
1623 // ----------------------------------------------------------------------------
1624 manualViewPerpPlaneContour::~manualViewPerpPlaneContour()
1629 // ----------------------------------------------------------------------------
1630 manualViewPerpPlaneContour * manualViewPerpPlaneContour :: Clone()
1632 manualViewPerpPlaneContour * clone = new manualViewPerpPlaneContour();
1633 CopyAttributesTo(clone);
1637 // ---------------------------------------------------------------------------
1639 void manualViewPerpPlaneContour::CopyAttributesTo( manualViewPerpPlaneContour * cloneObject)
1642 manualViewContour::CopyAttributesTo(cloneObject);
1648 // ----------------------------------------------------------------------------
1649 void manualViewPerpPlaneContour::UpdateViewPoint(int id)
1652 manualPoint *mp = _manContModel->GetManualPoint(id);
1656 FilterCordinateXYZ(x,y,z);
1658 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
1659 if ((z>=-1) && (z<=1))
1661 _lstViewPoints[id]->GetVtkActor()->VisibilityOn();
1663 _lstViewPoints[id]->GetVtkActor()->VisibilityOff();
1666 // ----------------------------------------------------------------------------
1667 void manualViewPerpPlaneContour::FilterCordinateXYZ (double &x, double &y, double &z)
1669 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1670 vtkMPRBaseData *vtkmprbasedata = vtkplane2Dview->GetVtkmprbasedata();
1671 vtkTransform *transf1 = vtkTransform::New();
1672 vtkTransform *transf2 = vtkmprbasedata->GetTransformOrientation();
1673 transf1->SetMatrix( transf2->GetMatrix() );
1676 double in[4], out[4];
1677 double center = vtkplane2Dview->GetImgSize() / 2;
1679 in[0] = x - vtkmprbasedata->GetX();
1680 in[1] = y - vtkmprbasedata->GetY();
1681 in[2] = z - vtkmprbasedata->GetZ();
1684 transf1->MultiplyPoint(in,out);
1690 this->GetWxVtkBaseView()->GetSpacing(spc);
1698 // ----------------------------------------------------------------------------
1699 void manualViewPerpPlaneContour::TransfromeCoordViewWorld( double &X,double &Y,double &Z,int type )
1702 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1703 vtkplane2Dview->TransfromeCoordViewWorld2(X,Y,Z);
1707 // ----------------------------------------------------------------------------
1708 void manualViewPerpPlaneContour::RefreshContour() // virtual
1710 // manualViewContour::RefreshContour();
1716 // JSTG 25-02-08 ----------------------------------------------------------
1718 //--------------------------------------------------------
1724 double dist,distMin = 99999999;
1726 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1727 double center = vtkplane2Dview->GetImgSize() / 2;
1730 np = GetNumberOfPoints( );
1732 //JSTG 25-02-08 ------------------------------------------
1734 //nps = GetNumberOfPointsSpline();
1735 nps = _manContModel->GetNumberOfPointsSpline();
1736 //delta = ( double ) ( np ) / ( double ) ( nps-1 );
1737 _manContModel->UpdateSpline();
1738 //--------------------------------------------------------
1742 for( i = 0; i < nps; i++ )
1744 // JSTG 25-02-08 ----------------------------------------------------------
1745 //t = delta * (double)i ;
1746 //tt = delta * (double)(i+1) ;
1747 //_manContModel->GetSplinePoint(t ,pp1[0],pp1[1],pp1[2]);
1748 //_manContModel->GetSplinePoint(tt,pp2[0],pp2[1],pp2[2]);
1749 _manContModel->GetSpline_i_Point(i ,&pp1[0],&pp1[1],&pp1[2]);
1750 _manContModel->GetSpline_i_Point(i+1,&pp2[0],&pp2[1],&pp2[2]);
1751 //--------------------------------------------------------------------------
1752 FilterCordinateXYZ(pp1[0],pp1[1],pp1[2]);
1753 FilterCordinateXYZ(pp2[0],pp2[1],pp2[2]);
1754 if (pp2[2]*pp1[2]<=0)
1756 if (pp1[2]-pp2[2]!=0) {
1757 u = -pp2[2] / (pp1[2]-pp2[2]);
1761 pp[0] = ( pp1[0]-pp2[0] )*u + pp2[0];
1762 pp[1] = ( pp1[1]-pp2[1] )*u + pp2[1];
1763 pp[2] = ( pp1[2]-pp2[2] )*u + pp2[2];
1764 ppC[0] = pp[0] - center;
1765 ppC[1] = pp[1] - center;
1767 dist = sqrt( ppC[0]*ppC[0] + ppC[1]*ppC[1] + ppC[2]*ppC[2] );
1779 _pts->SetPoint(0, 0 , 0 , 0);
1780 _pts->SetPoint(1, 0 , 0 , 0);
1784 ppB[0]=ppB[0]*_spc[0];
1785 ppB[1]=ppB[1]*_spc[1];
1787 _pts->SetPoint( 0, ppB[0] , ppB[1]+1 , 1 );
1788 _pts->SetPoint( 1, ppB[0] , ppB[1]-1 , 1 );
1789 _pts->SetPoint( 2, ppB[0] , ppB[1] , 1 );
1790 _pts->SetPoint( 3, ppB[0]-1 , ppB[1] , 1 );
1791 _pts->SetPoint( 4, ppB[0]+1 , ppB[1] , 1 );
1794 for( i = 5; i < nps; i++ )
1796 _pts->SetPoint( i, ppB[0] , ppB[1] , 1 );
1801 //---------------------------------------------------------------------------
1802 bool manualViewPerpPlaneContour::ifTouchContour( int x, int y, int z)
1805 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)( this->GetWxVtkBaseView() );
1809 vtkplane2Dview->TransfromeCoordScreenToWorld(X,Y,Z);
1811 _pts->GetPoint(0, ppA);
1812 if (sqrt( (ppA[0]-X)*(ppA[0]-X) + (ppA[1]-Y)*(ppA[1]-Y) ) <=2)
1820 //---------------------------------------------------------------------------
1821 //---------------------------------------------------------------------------
1822 //---------------------------------------------------------------------------
1823 vtkInteractorStyleMPRView::vtkInteractorStyleMPRView()
1825 _stateMoveAxisX = false;
1826 _stateMoveAxisY = false;
1827 _stateMoveAxisZ = false;
1829 //---------------------------------------------------------------------------
1830 vtkInteractorStyleMPRView::~vtkInteractorStyleMPRView()
1835 //---------------------------------------------------------------------------
1836 bool vtkInteractorStyleMPRView::OnLeftDClick () // virtual
1838 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1839 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1840 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1842 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1843 wxvtkmpr2Dview->MoveX(x,y,z);
1844 wxvtkmpr2Dview->MoveY(x,y,z);
1845 wxvtkmpr2Dview->MoveZ(x,y,z);
1846 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1847 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1848 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1849 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1853 //---------------------------------------------------------------------------
1854 bool vtkInteractorStyleMPRView::OnLeftButtonDown ()
1856 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1857 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1858 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1860 //double xx = x; // JPRx
1861 //double yy = y; // JPRx
1862 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1865 if ((_xBack==xx) && (_yBack==yy))
1867 wxvtkmpr2Dview->MoveX(x,y,z);
1868 wxvtkmpr2Dview->MoveY(x,y,z);
1869 wxvtkmpr2Dview->MoveZ(x,y,z);
1870 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
1871 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
1872 wxCommandEvent newevent2(wxEVT_COMMAND_MENU_SELECTED,12122); // Doble click
1873 wxvtkmpr2Dview->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent2);
1880 _stateMoveAxisX = wxvtkmpr2Dview->IfMouseTouchX(x,y,z);
1881 _stateMoveAxisY = wxvtkmpr2Dview->IfMouseTouchY(x,y,z);
1882 _stateMoveAxisZ = wxvtkmpr2Dview->IfMouseTouchZ(x,y,z);
1886 //---------------------------------------------------------------------------
1887 bool vtkInteractorStyleMPRView::OnLeftButtonUp ()
1889 if (_stateMoveAxisX==true)
1891 _stateMoveAxisX=false;
1893 if (_stateMoveAxisY==true)
1895 _stateMoveAxisY=false;
1897 if (_stateMoveAxisZ==true)
1899 _stateMoveAxisZ=false;
1903 //---------------------------------------------------------------------------
1904 bool vtkInteractorStyleMPRView::OnMouseMove ()
1906 double x = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
1907 double y = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
1910 _vtkInteractorStyleBaseView->TransformCoordinate(x,y,z);
1911 wxVtkMPR2DView *wxvtkmpr2Dview = (wxVtkMPR2DView*)(_vtkInteractorStyleBaseView->GetWxVtk2DBaseView());
1912 // wxvtkmpr2Dview->TransfromeCoordViewWorld(x,y,z);
1914 wxvtkmpr2Dview->ChangeAxisColor(x,y,z);
1916 if ((_stateMoveAxisX==true) || (_stateMoveAxisY==true) || (_stateMoveAxisZ==true) )
1918 if (_stateMoveAxisX==true)
1920 wxvtkmpr2Dview-> MoveX(x,y,z);
1922 if (_stateMoveAxisY==true)
1924 wxvtkmpr2Dview->MoveY(x,y,z);
1926 if (_stateMoveAxisZ==true)
1928 wxvtkmpr2Dview->MoveZ(x,y,z);
1931 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
1935 //-------------------------------------------------------------------
1936 //-------------------------------------------------------------------
1937 //-------------------------------------------------------------------
1938 wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction)
1939 :wxVtk2DBaseView(parent)
1944 _direction = direction;
1947 _lineAMapper = NULL;
1951 _lineBMapper = NULL;
1955 //-------------------------------------------------------------------
1956 wxVtkMPR2DView::~wxVtkMPR2DView()
1958 if (_ptsA!=NULL) { _ptsA -> Delete(); }
1959 if (_lineAActor!=NULL) { _lineAActor -> Delete(); }
1960 if (_lineAMapper!=NULL) { _lineAMapper -> Delete(); }
1961 if (_pdA!=NULL) { _pdA -> Delete(); }
1962 if (_ptsB!=NULL) { _ptsB -> Delete(); }
1963 if (_lineBActor!=NULL) { _lineBActor -> Delete(); }
1964 if (_lineBMapper!=NULL) { _lineBMapper -> Delete(); }
1965 if (_pdB!=NULL) { _pdB -> Delete(); }
1967 //-------------------------------------------------------------------
1968 vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
1970 return (vtkMPRBaseData*)GetVtkBaseData();
1972 //-------------------------------------------------------------------
1973 void wxVtkMPR2DView::Configure(){
1974 wxVtk2DBaseView::Configure();
1977 _interactorstylemprview = new vtkInteractorStyleMPRView();
1978 GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _interactorstylemprview );
1980 int x1,x2,y1,y2,z1,z2;
1981 GetVtkmprbasedata() -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
1984 GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
1985 x1 = (int)(x1*spc[0]);
1986 y1 = (int)(y1*spc[1]);
1987 z1 = (int)(z1*spc[2]);
1989 x2 = (int)(x2*spc[0]);
1990 y2 = (int)(y2*spc[1]);
1991 z2 = (int)(z2*spc[2]);
1993 _visibleAxis = true;
1996 _ptsA = vtkPoints::New();
1997 _ptsA->SetNumberOfPoints(2);
1998 _ptsA->SetPoint(0, -1000 , -1000 , -1000 );
1999 _ptsA->SetPoint(1, 1000 , 1000 , 1000 );
2000 vtkCellArray *linesA;
2001 linesA = vtkCellArray::New();
2002 linesA->InsertNextCell(2);
2003 linesA->InsertCellPoint(0);
2004 linesA->InsertCellPoint(1);
2005 _pdA = vtkPolyData::New();
2006 _pdA->SetPoints( _ptsA );
2007 _pdA->SetLines( linesA );
2008 linesA->Delete(); //do not delete lines ??
2009 _lineAActor = vtkActor::New();
2010 _lineAMapper = vtkPolyDataMapper::New();
2011 _lineAMapper->SetInput(_pdA);
2012 _lineAMapper->ImmediateModeRenderingOn();
2013 _lineAActor->SetMapper(_lineAMapper);
2014 _lineAActor->GetProperty()->BackfaceCullingOn();
2015 _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
2016 _lineAActor->GetProperty()->SetLineWidth(2);
2017 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2020 _ptsB = vtkPoints::New();
2021 _ptsB->SetNumberOfPoints(2);
2022 _ptsB->SetPoint(0, -1000 , -1000 , -1000 );
2023 _ptsB->SetPoint(1, 1000 , 1000 , 1000 );
2024 vtkCellArray *linesB;
2025 linesB = vtkCellArray::New();
2026 linesB->InsertNextCell(2);
2027 linesB->InsertCellPoint(0);
2028 linesB->InsertCellPoint(1);
2029 _pdB = vtkPolyData::New();
2030 _pdB->SetPoints( _ptsB );
2031 _pdB->SetLines( linesB );
2032 linesB->Delete(); //do not delete lines ??
2033 _lineBActor = vtkActor::New();
2034 _lineBMapper = vtkPolyDataMapper::New();
2035 _lineBMapper->SetInput(_pdB);
2036 _lineBMapper->ImmediateModeRenderingOn();
2037 _lineBActor->SetMapper(_lineBMapper);
2038 _lineBActor->GetProperty()->BackfaceCullingOn();
2039 _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
2040 _lineBActor->GetProperty()->SetLineWidth(2);
2041 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2043 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
2044 if (_direction==0) {
2045 camera->SetViewUp ( 0 , -1 , 0 );
2046 camera->SetPosition ( -10000,(y1+y2)/2 , (z1+z2)/2 );
2047 camera->SetFocalPoint ( 0 , (y1+y2)/2 , (z1+z2)/2 );
2048 camera->SetParallelScale( (z2-z1)/3.0 );
2051 if (_direction==1) {
2052 camera->SetViewUp ( 0 , 0 , -1 );
2053 camera->SetPosition ((x1+x2)/2 , 10000 , (z1+z2)/2 );
2054 camera->SetFocalPoint ((x1+x2)/2 , 0 , (z1+z2)/2 );
2055 camera->SetParallelScale( (x2-x1)/3.0 );
2058 if (_direction==2) {
2059 camera->SetViewUp ( 0 , -1 , 0 );
2060 camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000);
2061 camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 );
2062 camera->SetParallelScale( (x2-x1)/3.0 );
2067 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
2068 // _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
2072 void wxVtkMPR2DView::SetVisibleAxis(bool ok)
2074 if (ok!=_visibleAxis)
2077 if (_visibleAxis==true)
2079 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
2080 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
2082 if (_visibleAxis==false)
2084 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
2085 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
2091 //-------------------------------------------------------------------
2092 void wxVtkMPR2DView::Refresh()
2094 //wxVtk2DBaseView::Refresh();
2097 //vtkImageViewer2 *IV2=_imageViewer2XYZ->GetVtkImageViewer2(); // JPRx
2098 //vtkCamera *camera = IV2->GetRenderer()->GetActiveCamera(); // JPRx
2102 int x1,x2,y1,y2,z1,z2;
2103 GetVtkmprbasedata()->GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
2105 GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
2106 x1 = (int)(x1*spc[0]);
2107 y1 = (int)(y1*spc[1]);
2108 z1 = (int)(z1*spc[2]);
2110 x2 = (int)(x2*spc[0]);
2111 y2 = (int)(y2*spc[1]);
2112 z2 = (int)(z2*spc[2]);
2114 int x = (int)(GetVtkmprbasedata()->GetX());
2115 int y = (int)(GetVtkmprbasedata()->GetY());
2116 int z = (int)(GetVtkmprbasedata()->GetZ());
2118 x = (int)(x*spc[0]);
2119 y = (int)(y*spc[1]);
2120 z = (int)(z*spc[2]);
2124 if ((x!=_backX) || (y!=_backY) || (z!=_backZ)) {
2126 if (_direction==0) {
2127 _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
2128 _ptsA->SetPoint(0, -x2, y1 , z );
2129 _ptsA->SetPoint(1, -x2, y2 , z );
2130 _ptsB->SetPoint(0, -x2, y , z1);
2131 _ptsB->SetPoint(1, -x2, y , z2);
2133 if (_direction==1) {
2134 _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
2135 _ptsA->SetPoint(0, x1 , y2 , z );
2136 _ptsA->SetPoint(1, x2 , y2 , z );
2137 _ptsB->SetPoint(0, x , y2 , z1);
2138 _ptsB->SetPoint(1, x , y2 , z2);
2140 if (_direction==2) {
2141 _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
2142 _ptsA->SetPoint(0, x1 , y , -z2 );
2143 _ptsA->SetPoint(1, x2 , y , -z2 );
2144 _ptsB->SetPoint(0, x , y1, -z2 );
2145 _ptsB->SetPoint(1, x , y2, -z2 );
2151 wxVtkBaseView::Refresh();
2153 //-------------------------------------------------------------------
2154 int wxVtkMPR2DView::GetActualSlice() // virtual
2159 result = (int)(GetVtkmprbasedata()->GetX());
2163 result = (int)(GetVtkmprbasedata()->GetY());
2167 result = (int)(GetVtkmprbasedata()->GetZ());
2171 //-------------------------------------------------------------------
2172 void wxVtkMPR2DView::SetActualSlice(int slice) // virtual
2176 GetVtkmprbasedata()->SetX(slice);
2180 GetVtkmprbasedata()->SetY(slice);
2184 GetVtkmprbasedata()->SetZ(slice);
2187 //-------------------------------------------------------------------
2188 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
2197 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2204 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
2211 //-------------------------------------------------------------------
2212 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
2218 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2228 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
2235 //-------------------------------------------------------------------
2236 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
2242 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2249 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
2259 //-------------------------------------------------------------------
2260 void wxVtkMPR2DView::MoveX(double x, double y, double z)
2267 GetVtkmprbasedata()->SetX(x);
2271 GetVtkmprbasedata()->SetX(x);
2274 //-------------------------------------------------------------------
2275 void wxVtkMPR2DView::MoveY(double x, double y, double z)
2279 GetVtkmprbasedata()->SetY(y);
2286 GetVtkmprbasedata()->SetY(y);
2289 //-------------------------------------------------------------------
2290 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
2294 GetVtkmprbasedata()->SetZ(z);
2298 GetVtkmprbasedata()->SetZ(z);
2304 //-------------------------------------------------------------------
2305 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
2307 double c1r=1,c1g=1,c1b=0;
2308 double c2r=1,c2g=0,c2b=0;
2312 if (IfMouseTouchY(x,y,z)==true)
2314 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2316 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2318 if (IfMouseTouchZ(x,y,z)==true)
2320 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2322 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2328 if (IfMouseTouchX(x,y,z)==true)
2330 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2332 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2334 if (IfMouseTouchZ(x,y,z)==true)
2336 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2338 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2344 if (IfMouseTouchX(x,y,z)==true)
2346 _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2348 _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2350 if (IfMouseTouchY(x,y,z)==true)
2352 _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
2354 _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
2359 //-------------------------------------------------------------------
2360 void wxVtkMPR2DView::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
2362 wxVtkBaseView::TransfromeCoordScreenToWorld(X,Y,Z,_direction);
2366 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
2370 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
2374 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
2377 //-------------------------------------------------------------------
2378 //-------------------------------------------------------------------
2379 //-------------------------------------------------------------------
2380 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2381 // if (eventId==vtkCommand::StartInteractionEvent){
2382 // _renWin->SetDesiredUpdateRate(10);
2384 // if (eventId==vtkCommand::InteractionEvent){
2385 // _renWin->SetDesiredUpdateRate(0.001);
2387 // if (eventId==vtkCommand::EndInteractionEvent){
2388 // vtkPlanes *planes = vtkPlanes::New();
2389 // vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2390 // boxwidget->GetPlanes(planes);
2391 // _volumeMapper->SetClippingPlanes(planes);
2392 // planes -> Delete();
2396 //-------------------------------------------------------------------
2397 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
2398 // _renWin = renWin;
2400 //-------------------------------------------------------------------
2401 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
2402 // _volumeMapper = volumeMapper;
2407 //-------------------------------------------------------------------
2408 //-------------------------------------------------------------------
2409 //-------------------------------------------------------------------
2411 void boxSurfaceObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) { // virtual
2412 vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
2413 boxwidget->GetPlanes(_planes);
2415 if ( _vtkVolumeRayCastMapper != NULL )
2417 _vtkVolumeRayCastMapper->RemoveAllClippingPlanes();
2418 // vtkPlanes *planes = vtkPlanes::New();
2419 // boxwidget->GetPlanes(planes);
2420 // _vtkVolumeRayCastMapper->SetClippingPlanes(planes);
2421 _vtkVolumeRayCastMapper->SetClippingPlanes(_planes);
2424 // _actor->VisibilityOn();
2427 //-------------------------------------------------------------------
2428 void boxSurfaceObserver::SetPlanes(vtkPlanes *planes){
2431 //-------------------------------------------------------------------
2432 void boxSurfaceObserver::SetActor(vtkProp *actor){
2436 //-------------------------------------------------------------------
2437 void boxSurfaceObserver::SetvtkVolumeRayCastMapper(vtkVolumeRayCastMapper *vtkvolumeraycastmapper)
2439 _vtkVolumeRayCastMapper = vtkvolumeraycastmapper;
2443 //-------------------------------------------------------------------
2444 //-------------------------------------------------------------------
2445 //-------------------------------------------------------------------
2447 wxVtkMPR3DViewCntrlPanel::wxVtkMPR3DViewCntrlPanel(wxWindow *parent, wxVtkMPR3DView *wxvtkmpr3Dview )
2448 : wxPanel(parent, -1)
2451 wxPanel *panel = this;
2452 _wxvtkmpr3Dview = wxvtkmpr3Dview;
2454 int maxX = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2455 int maxY = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2456 int maxZ = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2457 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,_T("X "));
2458 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2459 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,_T("Y "));
2460 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2461 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,_T("Z "));
2462 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxSize(150,40), wxSL_HORIZONTAL | wxSL_LABELS);
2463 wxButton *btnColorTable = new wxButton (panel, -1, _T("Edit Color Table") );
2465 _ckBoxXYZ = new wxCheckBox(panel,-1,_T("XYZ "));
2466 _ckBoxPlane = new wxCheckBox(panel,-1,_T("Plane"));
2468 ckBoxX->SetValue(false);
2469 ckBoxY->SetValue(false);
2470 ckBoxZ->SetValue(false);
2471 _ckBoxXYZ->SetValue(true);
2472 _ckBoxPlane->SetValue(false);
2474 _positionX->SetSize(400,20);
2475 _positionY->SetSize(400,20);
2476 _positionZ->SetSize(400,20);
2478 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2479 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2480 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2481 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2482 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2483 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2484 Connect(btnColorTable->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnEditColorTable );
2486 Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
2487 Connect(_ckBoxPlane->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
2490 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2491 // wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
2493 // wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL);
2494 wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10);
2495 wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10);
2500 // wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10);
2501 // wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10);
2503 // sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2504 // sizerH4->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2505 // sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
2507 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2508 // sizerH5->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2509 // sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
2511 // sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2512 // sizerH6->Add( new wxStaticText(panel, -1," ") , 1, wxALL|wxEXPAND, 0);
2513 // sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
2515 // sizerH7->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2516 // sizerH7->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2518 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
2519 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2520 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
2521 // sizer->Add( sizerH7 , 1, wxALL|wxEXPAND, 2);
2523 sizerH4->Add( _positionX ,1,wxGROW , 0 );
2524 sizerH4->Add( ckBoxX ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2525 sizerH4->Add( _positionY ,1,wxGROW , 0 );
2526 sizerH4->Add( ckBoxY ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2527 sizerH4->Add( _positionZ ,1,wxGROW , 0 );
2528 sizerH4->Add( ckBoxZ ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2529 sizerH4->Add( btnColorTable ,0,wxALIGN_CENTER_VERTICAL|wxSHAPED , 0 );
2531 sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
2532 sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
2533 sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2534 // sizerH5->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2535 // sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2536 // sizerH5->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2538 sizer->Add( sizerH4 , 1, wxALL|wxGROW, 2);
2539 sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2542 panel->SetSize(400,50);
2543 panel->SetAutoLayout(true);
2544 panel->SetSizer(sizer);
2547 panel->SetEventHandler((wxEvtHandler*)this);
2550 //-------------------------------------------------------------------
2551 wxVtkMPR3DViewCntrlPanel::~wxVtkMPR3DViewCntrlPanel()
2554 //-------------------------------------------------------------------
2555 void wxVtkMPR3DViewCntrlPanel::Refresh()
2557 // wxPanel::Refresh();
2558 _positionX->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX( )) );
2559 _positionY->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY( )) );
2560 _positionZ->SetValue( (int)(_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ( )) );
2563 //-------------------------------------------------------------------
2564 int wxVtkMPR3DViewCntrlPanel::GetIdTissue()
2567 if (_surfA->GetValue()==true)
2571 if (_surfB->GetValue()==true)
2575 if (_surfC->GetValue()==true)
2579 if (_surfD->GetValue()==true)
2588 //-------------------------------------------------------------------
2589 void wxVtkMPR3DViewCntrlPanel::OnEditColorTable(wxCommandEvent& event)
2592 vtkColorTransferFunction *ctfun = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetvtkColorTransferFunction();
2593 std::vector<double> *ctfunVectorPoint = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorPoint();
2594 std::vector<double> *ctfunVectorRed = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorRed();
2595 std::vector<double> *ctfunVectorGreen = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorGreen();
2596 std::vector<double> *ctfunVectorBlue = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetctFunVectorBlue();
2598 //void *p=this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer(); // JPRx
2603 vtkImageData *imagedata = this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2605 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Color table"),imagedata,2);
2608 hDlg->erasePointsTransferenceFunction();
2609 int ctfSize=ctfunVectorRed->size();
2612 // MACHETE OJO Eduardo
2616 double gr = (*ctfunVectorPoint)[i];
2617 double r = (*ctfunVectorRed)[i];
2618 double g = (*ctfunVectorGreen)[i];
2619 double b = (*ctfunVectorBlue)[i];
2621 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
2627 // when the user had changed the transference Function
2630 //setting variables if the user wants to do refresh
2632 hDlg->setCTF(ctfun);
2633 hDlg->setMPR3Dview(_wxvtkmpr3Dview);
2635 if(hDlg->ShowModal()== wxID_OK )
2638 // -- vtkColorTransferFunction --
2639 ctfun->RemoveAllPoints ();
2641 ctfunVectorPoint->clear();
2642 ctfunVectorRed->clear();
2643 ctfunVectorGreen->clear();
2644 ctfunVectorBlue->clear();
2646 int nCTFpoints=hDlg->getSizeBarColor();
2647 // Machete .. Ojo Eduardo
2651 hDlg->getDataBarColorPoint(i,xi,r,g,b);
2655 hDlg->getDataBarColorPoint(1,xi,r,g,b);
2659 hDlg->getDataBarColorPoint(i-1,xi,r,g,b);
2662 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
2663 ctfunVectorPoint->push_back(xi);
2664 ctfunVectorRed->push_back(r/255.0);
2665 ctfunVectorGreen->push_back(g/255.0);
2666 ctfunVectorBlue->push_back(b/255.0);
2676 if(hDlg->getRefreshed())
2678 // -- vtkColorTransferFunction --
2679 ctfun->RemoveAllPoints ();
2682 int size=ctfunVectorPoint->size();
2686 double grey2=(*ctfunVectorPoint)[i];
2687 double red =(*ctfunVectorRed)[i];
2688 double green =(*ctfunVectorGreen)[i];
2689 double blue = (*ctfunVectorBlue)[i];
2690 ctfun->AddRGBPoint(grey2,red,green,blue);
2700 //-------------------------------------------------------------------
2701 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
2703 _wxvtkmpr3Dview->VisibleImageActor(0, event.IsChecked() );
2704 _wxvtkmpr3Dview->Refresh();
2706 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2707 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2710 //-------------------------------------------------------------------
2711 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
2713 _wxvtkmpr3Dview->VisibleImageActor(1, event.IsChecked() );
2714 _wxvtkmpr3Dview->Refresh();
2716 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2717 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2720 //-------------------------------------------------------------------
2721 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
2723 _wxvtkmpr3Dview->VisibleImageActor(2, event.IsChecked() );
2724 _wxvtkmpr3Dview->Refresh();
2726 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2727 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2730 //-------------------------------------------------------------------
2731 void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ(wxCommandEvent& event)
2733 _wxvtkmpr3Dview->VisiblePointWidget(event.IsChecked());
2736 //-------------------------------------------------------------------
2737 void wxVtkMPR3DViewCntrlPanel::OnVisiblePlane(wxCommandEvent& event)
2739 _wxvtkmpr3Dview->VisiblePlaneWidget(event.IsChecked());
2743 //-------------------------------------------------------------------
2744 void wxVtkMPR3DViewCntrlPanel::OnPositionX(wxScrollEvent& event)
2746 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( _positionX->GetValue() );
2747 _wxvtkmpr3Dview->RefreshView();
2748 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2749 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2751 //-------------------------------------------------------------------
2752 void wxVtkMPR3DViewCntrlPanel::OnPositionY(wxScrollEvent& event)
2754 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( _positionY->GetValue() );
2755 _wxvtkmpr3Dview->RefreshView();
2756 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2757 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2759 //-------------------------------------------------------------------
2760 void wxVtkMPR3DViewCntrlPanel::OnPositionZ(wxScrollEvent& event)
2762 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( _positionZ->GetValue() );
2763 _wxvtkmpr3Dview->RefreshView();
2764 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
2765 _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
2769 //-------------------------------------------------------------------
2770 //-------------------------------------------------------------------
2771 //-------------------------------------------------------------------
2773 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
2774 : wxPanel(parent, -1)
2776 wxPanel *panel = this;
2777 _wxvtkclipping3Dview = wxvtkclipping3Dview;
2780 // wxStaticText *text1 = new wxStaticText(panel, -1,_T(" "));
2781 // wxStaticText *text2 = new wxStaticText(panel, -1,_T(" "));
2783 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2784 _surfB = new wxRadioButton(panel,-1,_T("B"));
2785 _surfC = new wxRadioButton(panel,-1,_T("C"));
2786 _surfD = new wxRadioButton(panel,-1,_T("D"));
2788 wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol"));
2789 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
2790 wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box"));
2792 _color = new wxButton(panel,-1,_T(""));
2793 _visible = new wxCheckBox(panel,-1,_T("Vis"));
2794 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
2796 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
2797 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
2800 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
2801 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
2805 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
2806 vtkimagedata->GetScalarRange( range );
2807 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
2808 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
2811 _isoValue->SetTickFreq(25,0);
2813 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
2814 _isoValueSpin->SetRange(1,8);
2815 _isoValueSpin->SetValue(5);
2816 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
2818 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
2819 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
2821 wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions"));
2824 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
2825 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
2826 Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions );
2829 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
2830 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
2834 int maxX = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionX();
2835 int maxY = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionY();
2836 int maxZ = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetMaxPositionZ();
2837 wxCheckBox *ckBoxX = new wxCheckBox(panel,-1,"X");
2838 _positionX = new wxSlider(panel,-1,maxX/2,0,maxX, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2839 wxCheckBox *ckBoxY = new wxCheckBox(panel,-1,"Y");
2840 _positionY = new wxSlider(panel,-1,maxY/2,0,maxY, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2841 wxCheckBox *ckBoxZ = new wxCheckBox(panel,-1,"Z");
2842 _positionZ = new wxSlider(panel,-1,maxZ/2,0,maxZ, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL | wxSL_LABELS);
2845 // ckVolum->Enable(false);
2846 ckBoxSurface->SetValue(false);
2847 ckBoxVolume->SetValue(false);
2848 _color->SetSize(40,20);
2849 _opacity->SetSize(370,20);
2850 // ckBoxX->SetValue(true);
2851 // ckBoxY->SetValue(true);
2852 // ckBoxZ->SetValue(true);
2853 _surfA->SetValue(true);
2854 _wireFrameRep->SetValue(false);
2855 _surfaceRep->SetValue(true);
2856 _visible->SetValue(false);
2857 // _positionX->SetSize(400,20);
2858 // _positionY->SetSize(400,20);
2859 // _positionZ->SetSize(400,20);
2861 Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleVolume );
2862 Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume );
2864 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2865 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2866 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2867 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
2868 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
2870 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2871 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
2873 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
2874 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
2875 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
2878 // Connect(_isoValue->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2879 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
2882 Connect(ckBoxX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX );
2883 Connect(_positionX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionX );
2884 Connect(ckBoxY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisY );
2885 Connect(_positionY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionY );
2886 Connect(ckBoxZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisZ );
2887 Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
2890 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
2891 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
2892 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
2893 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
2894 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
2895 //wxFlexGridSizer *sizerH4 = new wxFlexGridSizer(10); // JPRx
2896 //wxFlexGridSizer *sizerH5 = new wxFlexGridSizer(10); // JPRx
2897 //wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10); // JPRx
2899 sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0);
2900 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2901 sizerH0->Add( ckBoxVolume , 1, wxALL|wxEXPAND, 0);
2902 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2903 sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0);
2904 sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2905 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
2908 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
2909 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2910 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
2911 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2912 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
2913 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2914 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
2915 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2916 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
2917 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2918 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
2919 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2920 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
2923 // sizerH2->Add( new wxStaticText(panel, -1,_T(" ") , 1, wxALL|wxEXPAND, 0);
2924 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
2925 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2926 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
2927 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2930 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
2931 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2932 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
2933 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
2935 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
2938 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
2939 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
2940 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
2943 sizerH4->Add( ckBoxX , 1, wxALL|wxEXPAND, 0);
2944 sizerH4->Add( text2 , 1, wxALL|wxEXPAND, 0);
2945 sizerH4->Add( _positionX , 1, wxALL|wxEXPAND, 0);
2947 sizerH5->Add( ckBoxY , 1, wxALL|wxEXPAND, 0);
2948 sizerH5->Add( text2 , 1, wxALL|wxEXPAND, 0);
2949 sizerH5->Add( _positionY , 1, wxALL|wxEXPAND, 0);
2951 sizerH6->Add( ckBoxZ , 1, wxALL|wxEXPAND, 0);
2952 sizerH6->Add( text2 , 1, wxALL|wxEXPAND, 0);
2953 sizerH6->Add( _positionZ , 1, wxALL|wxEXPAND, 0);
2955 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
2956 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
2957 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
2958 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
2959 // sizer->Add( sizerH4 , 1, wxALL|wxEXPAND, 2);
2960 // sizer->Add( sizerH5 , 1, wxALL|wxEXPAND, 2);
2961 // sizer->Add( sizerH6 , 1, wxALL|wxEXPAND, 2);
2963 panel->SetSize(300,60);
2964 panel->SetAutoLayout(true);
2965 panel->SetSizer(sizer);
2968 panel->SetEventHandler((wxEvtHandler*)this);
2971 //-------------------------------------------------------------------
2972 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
2975 //-------------------------------------------------------------------
2976 void wxVtkClipping3DViewCntrlPanel::Refresh()
2978 // wxPanel::Refresh();
2980 _positionX->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetX( ) );
2981 _positionY->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetY( ) );
2982 _positionZ->SetValue( _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetZ( ) );
2985 //-------------------------------------------------------------------
2986 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
2989 if (_surfA->GetValue()==true)
2993 if (_surfB->GetValue()==true)
2997 if (_surfC->GetValue()==true)
3001 if (_surfD->GetValue()==true)
3009 //-------------------------------------------------------------------
3010 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
3012 _wxvtkclipping3Dview->VisibleImageActor(0, event.IsChecked() );
3013 _wxvtkclipping3Dview->Refresh();
3015 //-------------------------------------------------------------------
3016 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisY(wxCommandEvent& event)
3018 _wxvtkclipping3Dview->VisibleImageActor(1, event.IsChecked() );
3019 _wxvtkclipping3Dview->Refresh();
3021 //-------------------------------------------------------------------
3022 void wxVtkClipping3DViewCntrlPanel::OnVisibleAxisZ(wxCommandEvent& event)
3024 _wxvtkclipping3Dview->VisibleImageActor(2, event.IsChecked() );
3025 _wxvtkclipping3Dview->Refresh();
3029 //-------------------------------------------------------------------
3030 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
3032 int idTissue=GetIdTissue();
3037 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3039 tmpActor->GetProperty()->GetColor( rgb );
3040 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
3041 _color->SetBackgroundColour(colour);
3044 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
3047 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
3049 // Representation Type WireFrame / Surface
3050 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3051 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
3054 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
3055 _isoValue->SetValue(isoValue);
3060 //-------------------------------------------------------------------
3061 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
3063 int idTissue=GetIdTissue();
3066 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
3068 _wxvtkclipping3Dview->Refresh();
3070 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3071 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3076 //-------------------------------------------------------------------
3077 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
3079 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
3080 _wxvtkclipping3Dview->Refresh();
3082 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3083 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3085 //-------------------------------------------------------------------
3086 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
3088 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
3089 _wxvtkclipping3Dview->Refresh();
3091 //-------------------------------------------------------------------
3092 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
3094 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
3095 _wxvtkclipping3Dview->Refresh();
3097 //-------------------------------------------------------------------
3098 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
3100 int idTissue=GetIdTissue();
3103 // EED 17 Janvier 2007
3104 wxColourDialog dlgColour(this);
3105 // dlgColour.ShowModal();
3106 if( dlgColour.ShowModal( ) == wxID_OK )
3109 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3110 float r=dlgColour.GetColourData().GetColour().Red()/255;
3111 float g=dlgColour.GetColourData().GetColour().Green()/255;
3112 float b=dlgColour.GetColourData().GetColour().Blue()/255;
3113 tmpActor->GetProperty()->SetColor( r , g , b );
3114 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
3116 _wxvtkclipping3Dview->Refresh();
3118 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3119 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3123 //-------------------------------------------------------------------
3124 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
3126 int idTissue=GetIdTissue();
3129 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
3131 _wxvtkclipping3Dview->Refresh();
3133 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3134 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3137 //-------------------------------------------------------------------
3138 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
3140 int idTissue=GetIdTissue();
3144 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3145 float opacity=_opacity->GetValue();
3146 tmpActor->GetProperty()->SetOpacity( opacity/100 );
3148 _wxvtkclipping3Dview->Refresh();
3150 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3151 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3155 //----------------------------------------------------------------------------
3156 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
3158 int value = _isoValue->GetValue();
3159 int delta= (int)pow( 4 , _isoValueSpin->GetValue() );
3160 int min=value - delta/2;
3161 int max=value + delta/2;
3167 _isoValue->SetRange(min,max);
3171 //------------------------------------------------------------------------
3172 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
3176 int idTissue=GetIdTissue();
3179 int isoValue=_isoValue->GetValue();
3180 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
3182 // tmpStr.Printf("%d",isoValue);
3184 _wxvtkclipping3Dview->Refresh();
3186 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3187 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3191 //-------------------------------------------------------------------
3192 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
3195 int idTissue=GetIdTissue();
3202 wxString dirSTL = wxGetHomeDir( ) ;
3203 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
3205 if( dialog.ShowModal( ) == wxID_OK )
3209 // ------------------------------------------------------------------------
3210 // 1. GENERATE STL FILES
3211 // ------------------------------------------------------------------------
3212 // const char* fileprefix = "c:\\Creatis\\";
3213 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
3214 std::string filename;
3216 // 1.1. Se hace un filtro triangular puesto que el stl writer solo recibe poligonos triangulares.
3218 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
3221 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
3222 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
3223 pdcf->SetInput( filtro->GetOutput() );
3224 vtkClosePolyData *cpd = vtkClosePolyData::New();
3225 cpd->SetInput( pdcf->GetOutput() );
3227 // 1.2 se escribe a disco el archivo stl de la superficie interna
3229 vtkSTLWriter *writer = vtkSTLWriter::New();
3230 writer->SetInput( cpd->GetOutput() );
3232 writer->SetFileName(filename.c_str());
3233 writer->SetFileTypeToASCII();
3245 //EED 30 Janvier 2007
3246 //-------------------------------------------------------------------
3247 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
3249 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
3250 if (dialog.ShowModal() == wxID_OK)
3252 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
3253 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
3254 float rescalaSlope = 1;
3255 float rescalaIntercept = 0;
3256 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
3257 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
3259 vtkimagedata->GetDimensions(dim);
3267 //EED 10 oct 2007 MaracasVisu pour bbMaracasvisu
3268 marRAW2Files marraw2;
3269 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
3273 //EED 22 Fevrier 2007
3274 //-------------------------------------------------------------------
3275 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
3278 int /*i=0,*/ xi,yi,r,g,b; // JPRx
3279 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
3280 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
3281 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
3282 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
3283 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
3284 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
3285 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
3286 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
3287 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3289 //use for update in the refresh
3291 vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
3292 vtkVolume* newvol =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
3297 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
3298 if (dialog.ShowModal() == wxID_OK)
3300 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
3306 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
3310 int tfSize=gtf->size();
3314 hDlg->erasePointsTransferenceFunction();
3318 double in=(*itf)[i];
3319 hDlg->addPointToTransferenceFunction(g,in*100);
3325 int ctfSize=rctf->size();
3331 double gr=(*greyctf)[i];
3332 double r=(*rctf)[i];
3333 double g=(*gctf)[i];
3334 double b=(*bctf)[i];
3335 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
3339 //setting variables if the user wants to do refresh
3340 hDlg->setCTF(ctfun);
3342 hDlg->setClipping3DView(_wxvtkclipping3Dview);
3344 hDlg->setVolume(newvol);
3345 hDlg->setVolumeMapper(volumeMapper);
3348 // when the user had changed the transference Function
3350 if(hDlg->ShowModal()== wxID_OK )
3352 // -- vtkPiecewiseFunction --
3353 tfun->RemoveAllPoints();
3357 int nTFPoints=hDlg->getSizeTransferenceFunction();
3361 hDlg->getTransferenceFunctionPoint(i,xi,yi);
3362 tfun->AddPoint( xi , yi/100.0 );
3364 itf->push_back(yi/100.0);
3367 // -- vtkColorTransferFunction --
3368 ctfun->RemoveAllPoints ();
3375 int nCTFpoints=hDlg->getSizeBarColor();
3379 hDlg->getDataBarColorPoint(i,xi,r,g,b);
3380 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
3381 rctf->push_back(r/255.0);
3382 gctf->push_back(g/255.0);
3383 bctf->push_back(b/255.0);
3384 greyctf->push_back(xi);
3387 //---------------------------------
3388 // Refreshing and sending the event
3389 //---------------------------------
3390 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3391 _wxvtkclipping3Dview->Refresh();
3392 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3393 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3396 volumeMapper->Update();
3404 if(hDlg->getRefreshed())
3407 //--Transference Function----
3408 tfun->RemoveAllPoints();
3413 double grey1=(*gtf)[i];
3414 double in2=(*itf)[i];
3415 tfun->AddPoint( grey1 , in2 );
3418 // -- vtkColorTransferFunction --
3419 ctfun->RemoveAllPoints ();
3422 size=greyctf->size();
3425 double grey2=(*greyctf)[i];
3426 double red =(*rctf)[i];
3427 double green =(*gctf)[i];
3428 double blue = (*bctf)[i];
3429 ctfun->AddRGBPoint(grey2,red,green,blue);
3432 //---------------------------------
3433 // Refreshing and sending the event
3434 //---------------------------------
3435 //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
3436 _wxvtkclipping3Dview->Refresh();
3437 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3438 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3441 volumeMapper->Update();
3447 //destroy the dialog
3452 //-------------------------------------------------------------------
3453 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
3455 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
3456 if (dialog.ShowModal() == wxID_OK)
3458 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
3459 _wxvtkclipping3Dview->Refresh();
3460 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
3461 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
3466 //-------------------------------------------------------------------
3467 //-------------------------------------------------------------------
3468 //-------------------------------------------------------------------
3471 wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
3473 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3474 _vtkmpr3Ddataviewer = NULL;
3475 _wxvtkmpr3DviewCntrlPanel = NULL;
3478 //-------------------------------------------------------------------
3479 wxVtkMPR3DView::~wxVtkMPR3DView()
3483 //-------------------------------------------------------------------
3484 void wxVtkMPR3DView::Refresh() // virtual
3486 _vtkmpr3Ddataviewer -> Refresh();
3487 if (_wxvtkmpr3DviewCntrlPanel!=NULL)
3489 _wxvtkmpr3DviewCntrlPanel->Refresh();
3493 //-------------------------------------------------------------------
3494 void wxVtkMPR3DView::RefreshView() // virtual
3497 this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
3499 //double nx=1,ny=0,nz=0; // JPRx
3501 double x=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetX();
3502 double y=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetY();
3503 double z=GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetZ();
3509 _pointWidget->SetPosition( x,y,z );
3514 vtkTransform *transform = GetVtkMPR3DDataViewer ()->GetVtkMPRBaseData()->GetTransformOrientation();
3515 in[0]=1; in[1]=0; in[2]=0;
3516 transform->TransformPoint(in,normal);
3517 _planeWidget->SetNormal( normal[0],normal[1],normal[2] );
3520 _planeWidget->SetCenter( x,y,z );
3521 _planeWidget->UpdatePlacement();
3522 _planeWidget->GetPolyData(_vtkplane);
3524 //-------------------------------------------------------------------
3525 wxPanel* wxVtkMPR3DView::CreateControlPanel(wxWindow *parent)
3527 _wxvtkmpr3DviewCntrlPanel = new wxVtkMPR3DViewCntrlPanel(parent,this);
3528 return _wxvtkmpr3DviewCntrlPanel;
3530 //-------------------------------------------------------------------
3531 vtkMPR3DDataViewer* wxVtkMPR3DView::GetVtkMPR3DDataViewer()
3533 return _vtkmpr3Ddataviewer;
3535 //-------------------------------------------------------------------
3536 wxVtk3DBaseView* wxVtkMPR3DView::GetWxvtk3Dbaseview()
3538 return _wxvtk3Dbaseview;
3540 //-------------------------------------------------------------------
3541 void wxVtkMPR3DView::Configure(){
3542 _wxvtk3Dbaseview->Configure();
3544 // Actors are added to the renderer.
3545 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetOutlineActor() );
3546 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(0) ); // _saggital
3547 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(1) ); // _axial
3548 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(2) ); // _coronal
3551 // An initial camera view is created. The Dolly() method moves
3552 // the camera towards the FocalPoint, thereby enlarging the image.
3553 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
3554 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
3555 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
3557 // Set a background color for the renderer and set the size of the
3558 // render window (expressed in pixels).
3559 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
3560 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
3562 // Note that when camera movement occurs (as it does in the Dolly()
3563 // method), the clipping planes often need adjusting. Clipping planes
3564 // consist of two planes: near and far along the view direction. The
3565 // near plane clips out objects in front of the plane; the far plane
3566 // clips out objects behind the plane. This way only what is drawn
3567 // between the planes is actually rendered.
3568 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
3573 _myCallback = vtkmyPWCallback_3DPointWidget::New();
3574 _myCallback->SetWxVtkMPR3DView(this);
3576 _pointWidget = vtkPointWidget::New();
3577 _myCallback->SetVtkPointWidget(_pointWidget);
3578 _pointWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3579 _pointWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3580 _pointWidget->AllOff();
3581 _pointWidget->PlaceWidget();
3582 // _pointWidget->SetPosition( x,y,z );
3584 _pointWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3588 _planeWidget = vtkPlaneWidget::New();
3589 _myCallback->SetVtkPlaneWidget(_planeWidget);
3590 _planeWidget->SetInput( GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
3591 _planeWidget->NormalToXAxisOn();
3592 _planeWidget->SetResolution(50);
3593 _planeWidget->SetRepresentationToOutline();
3595 GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetDimensions(dim);
3600 _planeWidget->PlaceWidget( px-dd , px+dd , py-dd , py+dd , pz-dd , pz+dd );
3601 _vtkplane = vtkPolyData::New();
3602 _planeWidget->GetPolyData(_vtkplane);
3604 vtkProbeFilter *probe = vtkProbeFilter::New();
3605 probe->SetInput(_vtkplane);
3606 vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3607 probe->SetSource( imageData );
3609 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
3611 contourMapper->SetInput( probe->GetPolyDataOutput() );
3613 contourMapper->SetScalarRange( imageData->GetScalarRange() );
3614 _contourPlaneActor = vtkActor::New();
3615 _contourPlaneActor->SetMapper(contourMapper);
3616 _contourPlaneActor->VisibilityOff();
3618 _planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
3619 _planeWidget->AddObserver(vtkCommand::InteractionEvent,_myCallback);
3620 _planeWidget->Off();
3621 _wxvtk3Dbaseview->GetRenderer()->AddActor( _contourPlaneActor );
3623 //-------------------------------------------------------------------
3624 void wxVtkMPR3DView::VisibleImageActor(int idPosition, bool visible){
3625 if (visible!=_vtkmpr3Ddataviewer->GetVisiblePosition(idPosition)){
3626 if (visible==false){
3627 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3629 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkmpr3Ddataviewer->GetImageActor(idPosition) );
3631 _vtkmpr3Ddataviewer->SetVisiblePosition(idPosition,visible);
3636 //-------------------------------------------------------------------
3637 void wxVtkMPR3DView::VisiblePointWidget( bool visible )
3643 _pointWidget->Off();
3647 //-------------------------------------------------------------------
3648 void wxVtkMPR3DView::VisiblePlaneWidget( bool visible )
3653 _contourPlaneActor->VisibilityOn();
3656 _planeWidget->Off();
3657 _contourPlaneActor->VisibilityOff();
3661 //-------------------------------------------------------------------
3662 void wxVtkMPR3DView::SetVtkMPR3DDataViewer(vtkMPR3DDataViewer *vtkmpr3Ddataviewer)
3664 _vtkmpr3Ddataviewer = vtkmpr3Ddataviewer;
3667 //-------------------------------------------------------------------
3668 void wxVtkMPR3DView::InitOrientationPointWidget()
3670 this->_planeWidget->SetNormal(1,0,0);
3676 //-------------------------------------------------------------------
3677 // EED 25 Janvier 2007 testLoic
3678 void wxVtkMPR3DView::TestLoic1()
3682 double dimIma = sizeIma*2;
3684 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3687 vtkimagedata->GetSpacing(spc);
3689 vtkimagedata->Update();
3693 this->_planeWidget->GetOrigin(p);
3694 this->_planeWidget->GetNormal(n);
3698 vtkPlaneSource* pSource = vtkPlaneSource::New( );
3699 pSource->SetResolution( sizeIma - 1, sizeIma - 1 );
3700 pSource->SetOrigin( p[ 0 ], p[ 1 ], p[ 2 ] );
3701 pSource->SetPoint1( p[ 0 ] + dimIma - 1.0, p[ 1 ], p[ 2 ] );
3702 pSource->SetPoint2( p[ 0 ], p[ 1 ]+ dimIma - 1.0 , p[ 2 ] );
3704 pSource->SetCenter( p[ 0 ], p[ 1 ], p[ 2 ] );
3705 pSource->SetNormal( n[ 0 ], n[ 1 ], n[ 2 ] );
3708 vtkProbeFilter* slices = vtkProbeFilter::New();
3709 slices->SetInput( ( vtkDataSet* )pSource->GetOutput( ) );
3710 slices->SetSource( vtkimagedata );
3714 vtkStructuredPoints *stPoints = vtkStructuredPoints::New();
3715 stPoints -> GetPointData( )->SetScalars( slices->GetOutput()->GetPointData()->GetScalars() );
3716 stPoints -> SetDimensions( sizeIma, sizeIma, 1 );
3717 stPoints -> SetScalarType( vtkimagedata->GetScalarType() );
3718 stPoints -> SetScalarTypeToShort();
3719 stPoints -> Update();
3721 vtkImageChangeInformation *change = vtkImageChangeInformation ::New();
3722 change -> SetInput( stPoints );
3723 change -> Update(); //important
3726 vtkimagedata->GetScalarRange(_range);
3727 vtkWindowLevelLookupTable *_bwlookup = vtkWindowLevelLookupTable::New( );
3728 _bwlookup->SetHueRange( 0 , 1 );
3729 _bwlookup->SetNumberOfColors( (int)(_range[1] - _range[0] + 1) );
3730 _bwlookup->SetTableRange( _range[0] , _range[1] );
3731 _bwlookup->SetSaturationRange( 0 , 0 );
3732 _bwlookup->SetValueRange( 0 , 1 );
3733 _bwlookup->SetAlphaRange( 1 , 1 );
3734 _bwlookup->Build( );
3736 vtkLookupTable * _collookup = vtkLookupTable::New( );
3737 _collookup->SetNumberOfColors( 256 );
3738 _collookup->SetTableRange( 0 , 255 );
3739 _collookup->Build( );
3740 _collookup->SetTableValue( 0 , 1 , 0 , 0 , 1 );
3741 _collookup->SetTableValue(128 , 0 , 0 , 1 , 1 );
3742 _collookup->SetTableValue(255 , 0 , 1 , 0 , 1 );
3745 vtkMetaImageWriter *writer = vtkMetaImageWriter::New( );
3746 writer->SetInput( stPoints );
3747 writer->SetFileName( "C:/Users/Images/temp_EED/image.mhd" );
3748 writer->SetFileDimensionality( 2 );
3753 vtkDataSetMapper *_3DSliceMapper = vtkDataSetMapper::New( );
3754 _3DSliceMapper->SetInput(change->GetOutput( ) );
3755 _3DSliceMapper->SetLookupTable( _bwlookup );
3756 _3DSliceMapper->SetScalarRange( _range );
3757 _3DSliceMapper->ImmediateModeRenderingOn( );
3759 vtkActor *_3DSliceActor = vtkActor::New( );
3760 _3DSliceActor->SetMapper( _3DSliceMapper );
3762 // The usual rendering stuff.
3763 vtkCamera *camera = vtkCamera::New();
3764 camera->SetPosition(1,1,1);
3765 camera->SetFocalPoint(0,0,0);
3767 vtkRenderer *renderer = vtkRenderer::New();
3768 vtkRenderWindow *renWin = vtkRenderWindow::New();
3769 renWin->AddRenderer(renderer);
3771 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3772 iren->SetRenderWindow(renWin);
3774 renderer->AddActor( _3DSliceActor );
3775 renderer->SetActiveCamera(camera);
3776 renderer->ResetCamera();
3777 renderer->SetBackground(1,1,1);
3779 renWin->SetSize(300,300);
3781 // interact with data
3791 //-------------------------------------------------------------------
3792 // EED 25 Janvier 2007 testLoic
3793 void wxVtkMPR3DView::TestLoic2()
3796 vtkVectorNorm *vecMagnitude = vtkVectorNorm::New();
3797 vecMagnitude->SetInput(VtkMainGrid);
3798 vecMagnitude->NormalizeOff();
3799 vecMagnitude->Update();
3802 vtkPlane *slicePlane = vtkPlane::New();
3803 this->_planeWidget->GetPlane( slicePlane );
3806 vtkCutter* sliceCutter = vtkCutter::New();
3807 vtkImageData *vtkimagedata = this->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
3808 sliceCutter->SetInput( vtkimagedata );
3809 sliceCutter->SetCutFunction( slicePlane );
3812 // vtkLookupTable *lut = BuildHueWeightBaseMap();
3815 vtkPolyDataMapper *slice = vtkPolyDataMapper::New();
3816 slice->SetInput( sliceCutter->GetOutput() );
3820 vtkimagedata->GetScalarRange(range);
3821 // vecMagnitude->GetOutput()->GetScalarRange( range );
3822 // range[1] *= 0.7; // reduce the upper range by 30%
3823 // slice->SetScalarRange( range );
3824 // slice->SetLookupTable( lut );
3826 // vtkActor *sliceActor = vtkActor::New();
3827 // sliceActor->SetMapper( slice );
3829 vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
3830 contourMapper->SetInput( sliceCutter->GetOutput() );
3831 contourMapper->SetScalarRange( range );
3832 // contourMapper->SetLookupTable( lut );
3835 vtkActor *contourActor = vtkActor::New();
3836 contourActor->SetMapper( contourMapper );
3840 // The usual rendering stuff.
3841 vtkCamera *camera = vtkCamera::New();
3842 camera->SetPosition(1,1,1);
3843 camera->SetFocalPoint(0,0,0);
3845 vtkRenderer *renderer = vtkRenderer::New();
3846 vtkRenderWindow *renWin = vtkRenderWindow::New();
3847 renWin->AddRenderer(renderer);
3849 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
3850 iren->SetRenderWindow(renWin);
3852 renderer->AddActor( contourActor );
3853 // renderer->AddActor(cubeActor);
3854 renderer->SetActiveCamera(camera);
3855 renderer->ResetCamera();
3856 renderer->SetBackground(1,1,1);
3858 renWin->SetSize(300,300);
3860 // interact with data
3867 //-------------------------------------------------------------------
3868 //-------------------------------------------------------------------
3869 //-------------------------------------------------------------------
3871 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
3873 _wxvtk3Dbaseview = wxvtk3Dbaseview;
3874 _vtkclipping3Ddataviewer = NULL;
3875 _wxvtkclipping3DviewCntrlPanel = NULL;
3877 _boxWidgetVolume = NULL;
3878 _boxWidgetS1 = NULL;
3881 //-------------------------------------------------------------------
3882 wxVtkClipping3DView::~wxVtkClipping3DView(){
3883 if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
3884 if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
3885 if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
3886 if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
3888 //-------------------------------------------------------------------
3889 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
3894 _boxWidgetS1->Off();
3897 //-------------------------------------------------------------------
3898 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
3900 if (_boxWidgetVolume!=NULL){
3902 _boxWidgetVolume->On();
3904 _boxWidgetVolume->Off();
3908 //-------------------------------------------------------------------
3909 void wxVtkClipping3DView::Refresh()
3911 _vtkclipping3Ddataviewer->Refresh();
3912 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
3914 _wxvtkclipping3DviewCntrlPanel->Refresh();
3917 //-------------------------------------------------------------------
3918 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
3920 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
3921 return _wxvtkclipping3DviewCntrlPanel;
3923 //-------------------------------------------------------------------
3924 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
3926 return _vtkclipping3Ddataviewer;
3928 //-------------------------------------------------------------------
3929 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
3930 if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
3931 if (visTissue==false){
3932 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
3934 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
3935 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
3936 // _actor->VisibilityOn();
3938 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
3941 //-------------------------------------------------------------------
3942 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
3945 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
3947 if (representationType==false){
3948 tmpActor->GetProperty()->SetRepresentationToWireframe();
3950 tmpActor->GetProperty()->SetRepresentationToSurface();
3953 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
3956 //-------------------------------------------------------------------
3957 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
3958 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
3959 if (visVolume==false){
3961 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
3962 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
3965 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
3966 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
3968 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
3971 //-------------------------------------------------------------------
3972 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()
3974 return _wxvtk3Dbaseview;
3976 //-------------------------------------------------------------------
3977 void wxVtkClipping3DView::Configure(){
3978 _wxvtk3Dbaseview->Configure();
3980 // Actors are added to the renderer.
3981 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
3983 _boxWidgetS1 = vtkBoxWidget::New();
3984 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
3985 _boxWidgetS1->SetPlaceFactor(1.25);
3989 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
3990 vtkPolyData *polydata= stripper->GetOutput();
3993 _boxWidgetS1->SetInput( polydata );
3994 _boxWidgetS1->PlaceWidget();
3997 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
3999 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
4005 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
4006 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
4008 VisibleActor(0, false );
4009 VisibleActor(1, false );
4010 VisibleActor(2, false );
4011 VisibleActor(3, false );
4013 _boxWidgetS1->HandlesOn ();
4015 _boxWidgetS1->Off();
4017 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
4018 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
4019 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
4020 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
4024 _boxWidgetVolume = vtkBoxWidget::New();
4025 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
4026 _boxWidgetVolume->SetPlaceFactor(1.25);
4028 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
4029 _boxWidgetVolume->PlaceWidget();
4031 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
4033 _boxWidgetVolume->HandlesOn ();
4034 _boxWidgetVolume->On();
4035 _boxWidgetVolume->Off();
4038 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
4039 // _boxWidgetVolume->GetPlanes( vtkplanes );
4042 // An initial camera view is created. The Dolly() method moves
4043 // the camera towards the FocalPoint, thereby enlarging the image.
4044 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
4045 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
4046 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
4048 // Set a background color for the renderer and set the size of the
4049 // render window (expressed in pixels).
4050 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
4051 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
4053 // Note that when camera movement occurs (as it does in the Dolly()
4054 // method), the clipping planes often need adjusting. Clipping planes
4055 // consist of two planes: near and far along the view direction. The
4056 // near plane clips out objects in front of the plane; the far plane
4057 // clips out objects behind the plane. This way only what is drawn
4058 // between the planes is actually rendered.
4059 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
4061 //-------------------------------------------------------------------
4062 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
4064 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4068 //---------------------------------------------------------------------------
4069 //---------------------------------------------------------------------------
4070 //---------------------------------------------------------------------------
4071 vtkInteractorStyle3DView::vtkInteractorStyle3DView()
4074 //---------------------------------------------------------------------------
4075 vtkInteractorStyle3DView::~vtkInteractorStyle3DView()
4078 //---------------------------------------------------------------------------
4079 bool vtkInteractorStyle3DView::OnLeftDClick()
4081 SelectMarchibCubePoint();
4084 //---------------------------------------------------------------------------
4085 bool vtkInteractorStyle3DView::SelectMarchibCubePoint()
4088 gtm::TVector< double > pO( 3 ), pF( 3 ), pp( 3 ), cp( 3 );
4089 gtm::TVector< double > xc( 3 );
4090 gtm::TVector< double > x1( 3 ), n1( 3 );
4091 gtm::TVector< double > x2( 3 ), n2( 3 );
4093 double pickPoint[ 3 ], cameraPos[ 3 ];
4095 vtkPointPicker* picker = vtkPointPicker::New( );
4096 eventrwi[0]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
4097 eventrwi[1]= _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
4098 vtkRenderer *pRenderer = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetRenderer();
4099 picker->Pick( eventrwi[0], eventrwi[1], 0.0, pRenderer );
4100 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
4101 picker->GetPickPosition( pickPoint );
4104 pp( 0 ) = pickPoint[ 0 ]; pp( 1 ) = pickPoint[ 1 ]; pp( 2 ) = pickPoint[ 2 ];
4105 cp( 0 ) = cameraPos[ 0 ]; cp( 1 ) = cameraPos[ 1 ]; cp( 2 ) = cameraPos[ 2 ];
4108 //EED 27 sep 2006 (1/2)
4109 // wxVtkMPR3DView *wxvtkmpr3Dview = (wxVtkMPR3DView *)_vtkInteractorStyleBaseView->GetWxVtk3DBaseView();
4111 // wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetSpacing(spc);
4114 vtkImageData *imageData = GetWxVtkMPR3DView()->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
4117 imageData->GetDimensions(dim);
4118 imageData->GetSpacing(spc);
4121 vtkMarchingCubes *mcubes = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetMCubes(0);
4124 UtilVtk3DGeometriSelection utilVtk3DGeometriSelection;
4125 utilVtk3DGeometriSelection.SetDimentions(dim[0],dim[1],dim[2]);
4127 utilVtk3DGeometriSelection.SetMarchingCube(mcubes);
4130 fac = GTM_MAX( dim[0], dim[2] );
4133 if( utilVtk3DGeometriSelection.FindCubePointsFromPoints(
4134 pO.GetAnsiRef( ), pF.GetAnsiRef( ),
4135 pp.GetAnsiRef( ), cp.GetAnsiRef( ) ) )
4138 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4139 x1.GetAnsiRef( ), n1.GetAnsiRef( ),
4140 pO.GetAnsiRef( ), pF.GetAnsiRef( ) ) )
4142 if( utilVtk3DGeometriSelection.GetPointAndNormalIntersection(
4143 x2.GetAnsiRef( ), n2.GetAnsiRef( ),
4144 ( x1 - n1 ).GetAnsiRef( ), ( x1 - ( n1 * fac ) ).GetAnsiRef( ) ) )
4146 xc = ( x2 + x1 ) * 0.5;
4147 //EED 27 sep 2006 (2/2)
4148 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX(xc(0)/spc[0]);
4149 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY(xc(1)/spc[1]);
4150 this->_wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ(xc(2)/spc[2]);
4151 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4152 this->_wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4161 //-------------------------------------------------------------------
4162 void vtkInteractorStyle3DView::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4164 _wxvtkmpr3Dview = wxvtkmpr3Dview;
4166 //-------------------------------------------------------------------
4167 wxVtkMPR3DView *vtkInteractorStyle3DView::GetWxVtkMPR3DView()
4169 return _wxvtkmpr3Dview;
4171 //-------------------------------------------------------------------
4172 wxVtkClipping3DView *vtkInteractorStyle3DView::GetWxVtkClipping3DView()
4174 return _wxvtkclipping3Dview;
4176 //-------------------------------------------------------------------
4177 void vtkInteractorStyle3DView::SetWxVtkClipping3DView( wxVtkClipping3DView *wxvtkclipping3Dview)
4179 _wxvtkclipping3Dview = wxvtkclipping3Dview;
4184 //-------------------------------------------------------------------
4185 //-------------------------------------------------------------------
4186 //-------------------------------------------------------------------
4187 void vtkmyPWCallback_3DPointWidget::Execute(vtkObject *caller, unsigned long, void*)
4191 double delta = 0.000000001;
4193 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4195 if (caller==_pointWidget)
4197 _pointWidget->GetPosition(p);
4199 if (caller==_planeWidget)
4201 _planeWidget->GetCenter(p);
4202 _planeWidget->GetNormal(n);
4203 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetNormal(n[0],n[1],n[2]);
4207 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData()->GetSpacing(spc);
4212 // Orientation change
4213 if ( (fabs(n[0]-_backNormal[0])>delta) || (fabs(n[1]-_backNormal[1])>delta) || (fabs(n[2]-_backNormal[2])>delta) )
4215 _backNormal[0] = n[0];
4216 _backNormal[1] = n[1];
4217 _backNormal[2] = n[2];
4218 isbv->SetParent_refresh_waiting();
4223 double tx = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetX();
4224 double ty = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetY();
4225 double tz = _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetZ();
4228 if ( (fabs(tx-p[0])>delta) || (fabs(ty-p[1])>delta) || (fabs(tz-p[2])>delta) )
4230 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetX( p[0] );
4231 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetY( p[1] );
4232 _wxvtkmpr3Dview->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->SetZ( p[2] );
4233 vtkInteractorStyleBaseView *isbv = _wxvtkmpr3Dview->GetWxvtk3Dbaseview()->GetInteractorStyleBaseView();
4234 isbv->BlockRefresh();
4235 isbv->vtkInteractorStyleBaseView::OnLeftButtonDown();
4236 isbv->SetParent_refresh_waiting();
4237 isbv->vtkInteractorStyleBaseView::OnMouseMove();
4238 isbv->UnBlockRefresh();
4240 isbv->EvaluateToRefresh();
4242 //-------------------------------------------------------------------
4243 void vtkmyPWCallback_3DPointWidget::SetWxVtkMPR3DView( wxVtkMPR3DView *wxvtkmpr3Dview )
4245 _wxvtkmpr3Dview=wxvtkmpr3Dview;
4247 //-------------------------------------------------------------------
4248 void vtkmyPWCallback_3DPointWidget::SetVtkPointWidget( vtkPointWidget *pointWidget )
4250 _pointWidget=pointWidget;
4252 //-------------------------------------------------------------------
4253 void vtkmyPWCallback_3DPointWidget::SetVtkPlaneWidget( vtkPlaneWidget *planeWidget )
4255 _planeWidget=planeWidget;
4257 //-------------------------------------------------------------------
4258 //-------------------------------------------------------------------
4259 //-------------------------------------------------------------------
4261 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
4262 : wxPanel( parent, -1)
4265 _histogrammeVector=NULL;
4268 Create3DViewObjects();
4271 //-------------------------------------------------------------------
4272 wxPanelCuttingImageData::~wxPanelCuttingImageData()
4276 delete _modelSphere;
4277 delete _modelCylinder;
4279 _vtkcube -> Delete();
4280 _vtksphere -> Delete();
4281 _vtkcylinder -> Delete();
4282 _cubeMapper -> Delete();
4283 _sphereMapper -> Delete();
4284 _cylinderMapper -> Delete();
4285 _cubeActor -> Delete();
4286 _sphereActor -> Delete();
4287 _cylinderActor -> Delete();
4288 // _xyplot->RemoveAllInputs();
4289 _xyplot -> Delete();
4290 _histogrammeVector->Delete();
4292 delete _wxvtkbaseView;
4296 //-------------------------------------------------------------------
4297 void wxPanelCuttingImageData::RemoveActors()
4299 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4303 //-------------------------------------------------------------------
4304 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
4306 _wxvtk3Dbaseview=wxvtk3Dbaseview;
4309 //-------------------------------------------------------------------
4311 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
4313 this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
4316 //-------------------------------------------------------------------
4317 void wxPanelCuttingImageData::Create3DViewObjects()
4320 _vtksphere = vtkSphereSource::New();
4321 _vtksphere->SetThetaResolution (20);
4322 _vtksphere->SetPhiResolution (20);
4323 _sphereMapper = vtkPolyDataMapper::New();
4324 _sphereMapper->SetInput( _vtksphere->GetOutput() );
4325 _sphereActor = vtkActor::New();
4326 _sphereActor->SetMapper(_sphereMapper);
4327 _sphereActor->SetOrigin(0, 0, 0);
4328 _sphereActor->SetPosition(0, 0, 0);
4329 _sphereActor->GetProperty()->SetColor(1, 0, 0);
4330 _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );
4333 _vtkcube = vtkCubeSource::New();
4334 _vtkcube->SetXLength (1);
4335 _vtkcube->SetYLength (1);
4336 _vtkcube->SetZLength (1);
4337 _cubeMapper = vtkPolyDataMapper::New();
4338 _cubeMapper->SetInput( _vtkcube->GetOutput() );
4339 _cubeActor = vtkActor::New();
4340 _cubeActor->SetMapper(_cubeMapper);
4341 _cubeActor->SetOrigin(0, 0, 0);
4342 _cubeActor->SetPosition(0, 0, 0);
4343 _cubeActor->GetProperty()->SetColor(1, 0, 0);
4344 _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );
4347 _vtkcylinder = vtkCylinderSource::New();
4348 _vtkcylinder->SetResolution(20);
4349 _cylinderMapper = vtkPolyDataMapper::New();
4350 _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
4351 _cylinderActor = vtkActor::New();
4352 _cylinderActor->SetMapper(_cylinderMapper);
4353 _cylinderActor->SetOrigin(0, 0, 0);
4354 _cylinderActor->SetPosition(0, 0, 0);
4355 _cylinderActor->GetProperty()->SetColor(1, 0, 0);
4356 _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );
4361 //-------------------------------------------------------------------
4362 void wxPanelCuttingImageData::CreateModel()
4364 _modelCube = new figureCuttingCubeModel();
4365 _modelSphere = new figureCuttingSphereModel();
4366 _modelCylinder = new figureCuttingCylinderModel();
4368 // _modelCube->SetVtkTransform( _modelCube->GetVtkTransform() );
4369 // _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform() );
4370 // _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform() );
4373 //-------------------------------------------------------------------
4375 void wxPanelCuttingImageData::InitHistogramme()
4378 if (_imageData==NULL)
4382 _imageData->GetScalarRange(rangeA);
4384 _xyplot->RemoveAllInputs();
4386 if ( _histogrammeVector!=NULL )
4388 _histogrammeVector -> Delete();
4391 _histogrammeVector = vtkImageData::New();
4392 _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
4393 _histogrammeVector -> SetScalarTypeToUnsignedShort();
4394 _histogrammeVector -> AllocateScalars();
4395 _histogrammeVector -> Update();
4397 unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4398 int i,size = (int) (rangeA[1]);
4399 for (i=0; i < size; i++)
4404 _xyplot->SetXRange(0, rangeA[1]);
4405 _xyplot->SetYRange(0, 10);
4406 _xyplot->AddInput( _histogrammeVector );
4409 //-------------------------------------------------------------------
4410 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
4412 _xyplot = vtkXYPlotActor::New();
4414 _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
4415 _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
4416 _xyplot->SetXValuesToArcLength();
4417 _xyplot->SetNumberOfXLabels(6);
4419 _xyplot->SetTitle("Histogramme");
4420 _xyplot->SetXTitle("Gray level");
4421 _xyplot->SetYTitle("Occurrences ");
4422 _xyplot->GetProperty()->SetColor(1, 0, 0);
4423 _xyplot->GetProperty()->SetPointSize(2);
4424 vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
4425 tprop->SetColor( 1,0,1 );
4427 _xyplot->SetAxisTitleTextProperty(tprop);
4428 _xyplot->SetAxisLabelTextProperty(tprop);
4429 _xyplot->PlotPointsOn();
4430 _xyplot->GetProperty()->SetPointSize(3);
4432 _wxvtkbaseView = new wxVtkBaseView(this);
4433 _wxvtkbaseView->Configure();
4435 vtkRenderer *ren = vtkRenderer::New();
4436 vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
4437 renWin->AddRenderer( ren );
4438 ren->AddActor2D( _xyplot );
4440 return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
4443 //-------------------------------------------------------------------
4445 void wxPanelCuttingImageData::CreateInterface()
4448 wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); // Principal sizer
4450 wxBoxSizer *sizerH0 = new wxBoxSizer(wxHORIZONTAL ); // type of segmentation figure
4451 wxBoxSizer *sizerH2 = new wxBoxSizer(wxHORIZONTAL ); // scale
4452 wxBoxSizer *sizerH3 = new wxBoxSizer(wxHORIZONTAL ); // rotation
4453 wxBoxSizer *sizerH4 = new wxBoxSizer(wxHORIZONTAL ); // intern extern
4454 wxBoxSizer *sizerH5 = new wxBoxSizer(wxHORIZONTAL ); // Isovalue
4455 wxBoxSizer *sizerH6 = new wxBoxSizer(wxHORIZONTAL ); // Buttons
4456 wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(2 ); // Volumic information
4459 _typeFig = new wxChoice(this,-1);
4460 _opacityFig = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4462 _scaleX = new wxSlider(this,-1,6,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4463 _scaleY = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4464 _scaleZ = new wxSlider(this,-1,7,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4466 _rotationX = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4467 _rotationY = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4468 _rotationZ = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4470 _volIntern = new wxRadioButton(this,-1, _T("Volume intern " ));
4471 _volExtern = new wxRadioButton(this,-1, _T("Volume extern " ));
4473 _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
4475 _isoValue = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4476 _valueBeforeIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4477 _valueAfterIsoValue = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
4479 wxButton *btnExtract = new wxButton(this, -1,_T("Extract"));
4481 _infoToVo = new wxStaticText(this,-1,_T("########################"));
4482 _infoSuVoA = new wxStaticText(this,-1,_T("############"));
4483 _infoSuVo = new wxStaticText(this,-1,_T("############"));
4484 _infoPixLe = new wxStaticText(this,-1,_T("############"));
4485 _infoPixHi = new wxStaticText(this,-1,_T("############"));
4488 wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
4490 _typeFig->Append(_T("Cylindre"));
4491 _typeFig->Append(_T("Cube"));
4492 _typeFig->Append(_T("Sphere"));
4493 _typeFig->SetSelection(0);
4494 _volIntern->SetValue(true);
4496 Connect(_typeFig->GetId() , wxEVT_COMMAND_CHOICE_SELECTED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig );
4498 Connect(_opacityFig->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig );
4499 Connect(_rotationX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4500 Connect(_rotationY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4501 Connect(_rotationZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4502 Connect(_scaleX->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4503 Connect(_scaleY->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4504 Connect(_scaleZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform );
4505 Connect(btnExtract->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract );
4508 // wxStaticText *text=new wxStaticText(this,-1, " ");
4510 sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type: "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL ,0);
4511 sizerH0 -> Add( _typeFig ,1,wxALL ,0);
4512 sizerH0 -> Add( _opacityFig ,1,wxALL|wxEXPAND ,0);
4514 sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale : ")) ,1,wxALL ,0);
4515 sizerH2 -> Add( _scaleX ,1,wxALL | wxEXPAND ,0 );
4516 sizerH2 -> Add( _scaleY ,1,wxALL | wxEXPAND ,0 );
4517 sizerH2 -> Add( _scaleZ ,1,wxALL | wxEXPAND ,0 );
4519 sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation : ")) ,1,wxALL ,0);
4520 sizerH3 -> Add( _rotationX ,1,wxALL | wxEXPAND ,0 );
4521 sizerH3 -> Add( _rotationY ,1,wxALL | wxEXPAND ,0 );
4522 sizerH3 -> Add( _rotationZ ,1,wxALL | wxEXPAND ,0 );
4525 sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern : ")) ,1,wxALL ,0);
4526 sizerH4 -> Add( _volIntern ,1,wxALL ,0);
4527 sizerH4 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4528 sizerH4 -> Add( _volExtern ,1,wxALL ,0);
4530 sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue ")) ,1,wxALL ,0);
4531 sizerH5 -> Add( _isoValue ,1,wxALL | wxEXPAND ,0 );
4532 sizerH5 -> Add( _valueBeforeIsoValue ,1,wxALL | wxEXPAND ,0 );
4533 sizerH5 -> Add( _valueAfterIsoValue ,1,wxALL | wxEXPAND ,0 );
4535 sizerH6 -> Add( new wxStaticText(this,-1, _T(" ")) ,1,wxALL ,0);
4536 sizerH6 -> Add( btnExtract ,1,wxALL ,0);
4538 sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4539 sizerH7 -> Add( _infoToVo , 1 , wxALL ,0);
4540 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume: "), wxDefaultPosition, wxSize(200,12) ) , 1 , wxALL ,0);
4541 sizerH7 -> Add( _infoSuVo , 1 , wxALL ,0);
4542 sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4543 sizerH7 -> Add( _infoSuVoA , 1 , wxALL ,0);
4544 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue: ") , wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4545 sizerH7 -> Add( _infoPixLe , 1 , wxALL ,0);
4546 sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12)) , 1 , wxALL ,0);
4547 sizerH7 -> Add( _infoPixHi , 1 , wxALL ,0);
4548 // sizerH7 -> SetMinSize(300, 120);
4551 topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND ,0);
4554 topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND ,0);
4557 topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND ,0);
4560 topsizer -> Add( sizerH4 ,1,wxALL ,0);
4564 topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
4567 topsizer -> Add( sizerH6 , 1 , wxALL ,0);
4570 topsizer -> Add( _histogrammeAccumulated ,1, wxALL ,0);
4572 // Volumic information
4573 topsizer -> Add( sizerH7 , 1 , wxALL|wxEXPAND ,0);
4577 // wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
4578 wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
4579 sizerHor -> Add( topsizer , 1 , wxALL | wxEXPAND ,0);
4580 sizerHor -> Add( panelPlotHistogramme , 1 , wxGROW ,0);
4583 this->SetAutoLayout(true);
4584 this->SetSizer( sizerHor );
4587 // this->FitInside();
4590 //-------------------------------------------------------------------
4592 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
4597 bool volInt, volExt;
4599 unsigned short *pOrg;
4600 unsigned short *p_histogramme;
4603 long int contAfter = 0;
4604 long int contBefor = 0;
4606 double min=999999999;
4607 double max=-999999999;
4609 volExt=_volExtern->GetValue();
4610 volInt=_volIntern->GetValue();
4611 int isoValue = _isoValue->GetValue();
4612 int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue();
4613 int valueAfterIsoValue = _valueAfterIsoValue ->GetValue();
4616 p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
4618 _imageData->GetDimensions(dim);
4619 _imageData->GetSpacing(spc);
4620 _actualCuttingModel->CalculeInversMatrix();
4622 for (xx=0;xx<dim[0]; xx++)
4624 for (yy=0;yy<dim[1]; yy++)
4626 for (zz=0;zz<dim[2];zz++)
4628 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
4629 if ( ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
4631 pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz);
4633 if ((*pOrg)<isoValue)
4636 if (valueBeforeIsoValue!=-1)
4638 *pOrg=valueBeforeIsoValue;
4642 if (valueAfterIsoValue!=-1)
4644 *pOrg=valueAfterIsoValue;
4648 p_histogramme[*pOrg]++;
4649 if (*pOrg<min) min=*pOrg;
4650 if (*pOrg>max) max=*pOrg;
4664 double volumeUnit = spc[0]*spc[1]*spc[2];
4665 long int totalSubVolume = contBefor + contAfter;
4666 double contBeforPorc = 100*(double)contBefor/(double)totalSubVolume;
4667 double contAfterPorc = 100*(double)contAfter/(double)totalSubVolume;
4668 infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
4669 infoSuVo.Printf(_T("%d") , totalSubVolume);
4670 infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
4671 infoPixLe.Printf(_T("%d pix. (%.2f %s) - %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
4672 infoPixHi.Printf(_T("%d pix. (%.2f %s) - %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
4674 _infoToVo->SetLabel(infoToVo);
4675 _infoSuVo->SetLabel(infoSuVo);
4676 _infoSuVoA->SetLabel(infoSuVoA);
4677 _infoPixLe->SetLabel(infoPixLe);
4678 _infoPixHi->SetLabel(infoPixHi);
4681 if ( _histogrammeAccumulated->GetValue()==true )
4684 _histogrammeVector -> GetDimensions ( dimHist );
4686 int i,size=dimHist[0];
4687 for (i=1; i<=size; i++)
4689 p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
4693 _histogrammeVector->Update();
4694 _histogrammeVector->GetScalarRange(range);
4695 _xyplot->SetYRange( 0 , range[1] );
4696 _xyplot->SetXRange( min , max );
4698 _vtkclipping3Ddataviewer->RefreshSurface();
4699 _wxvtkbaseView->Refresh();
4701 // _wxvtkbaseView->RefreshView();
4702 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
4703 _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
4707 //-------------------------------------------------------------------
4708 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
4710 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
4712 if (_typeFig->GetSelection()==0){
4713 _actualCuttingModel=_modelCylinder;
4714 _actualActor=_cylinderActor;
4716 if (_typeFig->GetSelection()==1){
4717 _actualCuttingModel=_modelCube;
4718 _actualActor=_cubeActor;
4720 if (_typeFig->GetSelection()==2){
4721 _actualCuttingModel=_modelSphere;
4722 _actualActor=_sphereActor;
4724 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4729 //-------------------------------------------------------------------
4730 void wxPanelCuttingImageData::RefreshOpacity()
4732 double op= _opacityFig->GetValue()/100.0;
4733 _actualActor->GetProperty()->SetOpacity( op );
4736 //-------------------------------------------------------------------
4737 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
4742 //-------------------------------------------------------------------
4743 void wxPanelCuttingImageData::RefreshView()
4745 SetParamsOfTransformation( );
4748 //-------------------------------------------------------------------
4749 void wxPanelCuttingImageData::Refresh()
4751 _wxvtk3Dbaseview->Refresh();
4754 //-------------------------------------------------------------------
4755 void wxPanelCuttingImageData::SetParamsOfTransformation( )
4758 vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
4759 vtkimagedata->GetSpacing(spc);
4760 int px = (int) (_vtkmprbasedata->GetX() );
4761 int py = (int) (_vtkmprbasedata->GetY() );
4762 int pz = (int) (_vtkmprbasedata->GetZ() );
4763 int sx = (int) (_scaleX->GetValue() * spc[0] );
4764 int sy = (int) (_scaleY->GetValue() * spc[1] );
4765 int sz = (int) (_scaleZ->GetValue() * spc[2] );
4766 _actualCuttingModel -> SetScale ( sx , sy , sz );
4767 _actualCuttingModel -> SetPosition ( px , py , pz );
4768 _actualCuttingModel -> SetRotation ( _rotationX->GetValue() , _rotationY->GetValue() , _rotationZ->GetValue() );
4769 _actualCuttingModel -> SetSpacing ( spc[0] , spc[1] , spc[2] );
4770 _actualCuttingModel -> CalculeMatrix();
4773 //-------------------------------------------------------------------
4775 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
4780 //-------------------------------------------------------------------
4781 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
4783 _vtkmprbasedata = vtkmprbasedata;
4784 _imageData = _vtkmprbasedata->GetImageData();
4787 //-------------------------------------------------------------------
4789 void wxPanelCuttingImageData::Configure()
4791 _actualCuttingModel=_modelCylinder;
4792 _actualActor=_cylinderActor;
4793 _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
4794 SetParamsOfTransformation();
4800 //-------------------------------------------------------------------
4801 //-------------------------------------------------------------------
4802 //-------------------------------------------------------------------
4805 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
4806 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
4809 //-------------------------------------------------------------------
4811 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
4812 : wxSplitterWindow( parent , -1)
4815 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
4816 this->SetMinimumPaneSize(50);
4818 //-------------------------------------------------------------------
4819 wxWidgetMesure2D::~wxWidgetMesure2D()
4822 //-------------------------------------------------------------------
4823 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
4825 wxPanel *panel = new wxPanel(parent,-1);
4827 _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
4828 _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
4829 _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
4830 _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
4832 _cb_mt_visible->SetValue(true);
4833 _cb_closeContour->SetValue(true);
4834 _cb_visibleText->SetValue(true);
4836 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
4838 sizer->Add(_cb_messuretool);
4839 sizer->Add(_cb_mt_visible);
4840 sizer->Add(_cb_closeContour);
4841 sizer->Add(_cb_visibleText);
4843 panel->SetAutoLayout(true);
4844 panel->SetSizer(sizer);
4845 panel->SetSize(400,30);
4848 // panel->FitInside();
4850 Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
4851 Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
4852 Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
4853 Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
4858 //-------------------------------------------------------------------
4859 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
4861 _wxvtk2Dbaseview = wxvtk2Dbaseview;
4864 _manContourControl_1 = new manualContourControler();
4865 _mContourModel_1 = new manualContourModel();
4866 _mViewContour_1 = new manualViewContour();
4867 _mViewContour_1->SetModel( _mContourModel_1 );
4868 _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
4869 _mViewContour_1->SetRange( 1 );
4873 // _wxvtk2Dbaseview->GetSpacing( spc );
4874 // _mViewContour_1->SetSpacing( spc );
4878 _manContourControl_1->SetZ( 1000 );
4879 _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
4880 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_1 );
4881 _manContourControl_1->CreateNewManualContour();
4882 _manContourControl_1->SetActive( false );
4883 _mViewContour_1->RefreshContour();
4887 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
4888 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
4889 // CreateWin1a(this->GetWindow1() );
4891 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
4892 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
4893 this->GetWindow1()->SetSizer(sizerA);
4894 this->SetAutoLayout(true);
4897 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
4898 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
4899 this->GetWindow2()->SetSizer(sizerB);
4900 this->SetAutoLayout(true);
4904 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
4908 // this->FitInside();
4912 //-------------------------------------------------------------------
4913 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
4915 _wxvtk2Dbaseview->GetInteractorStyleBaseView()->SetActiveAllInteractors(!ok);
4916 _manContourControl_1->SetActive( ok );
4919 //-------------------------------------------------------------------
4920 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
4922 ActiveMessureTool( _cb_messuretool->GetValue() );
4923 if ( _cb_messuretool->GetValue() == true )
4925 _cb_mt_visible->SetValue(true);
4926 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
4927 _cb_closeContour->Enable(true);
4928 _cb_visibleText->Enable(true);
4930 _cb_closeContour->Enable(false);
4931 _cb_visibleText->Enable(false);
4933 _wxvtk2Dbaseview->Refresh();
4934 _wxvtk2Dbaseview->RefreshView();
4937 //-------------------------------------------------------------------
4938 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
4940 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
4941 if (_cb_messuretool->GetValue()==true)
4943 _cb_closeContour->Enable(true);
4944 _cb_visibleText->Enable(true);
4946 ActiveMessureTool( _cb_messuretool->GetValue() );
4947 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
4948 _mViewContour_1->Refresh();
4949 _wxvtk2Dbaseview->Refresh();
4950 _wxvtk2Dbaseview->RefreshView();
4953 //-------------------------------------------------------------------
4954 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
4956 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
4957 _mViewContour_1->Refresh();
4958 _wxvtk2Dbaseview->Refresh();
4959 _wxvtk2Dbaseview->RefreshView();
4962 //-------------------------------------------------------------------
4963 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
4965 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
4966 _mViewContour_1->Refresh();
4967 _wxvtk2Dbaseview->Refresh();
4968 _wxvtk2Dbaseview->RefreshView();
4970 //-------------------------------------------------------------------
4971 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
4973 _mViewContour_1->SetMesureScale(mesureScale);
4975 //-------------------------------------------------------------------
4976 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
4978 return _mContourModel_1;
4981 //-------------------------------------------------------------------
4982 //-------------------------------------------------------------------
4983 //-------------------------------------------------------------------
4985 wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
4986 : wxWidgetMesure2D(parent)
4990 _circle1Actor = NULL;
4991 _circle1Mapper = NULL;
4995 _circle2Actor = NULL;
4996 _circle2Mapper = NULL;
4999 _ptsLineRef1 = NULL;
5000 _lineRef1Actor = NULL;
5001 _lineRef1Mapper = NULL;
5004 _ptsLineRef2 = NULL;
5005 _lineRef2Actor = NULL;
5006 _lineRef2Mapper = NULL;
5011 //-------------------------------------------------------------------
5013 wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
5016 if ( _ptsCircle1 != NULL){ _ptsCircle1 -> Delete(); }
5017 if ( _circle1Actor != NULL){ _circle1Actor -> Delete(); }
5018 if ( _circle1Mapper != NULL){ _circle1Mapper -> Delete(); }
5019 if ( _pdCircle1 != NULL){ _pdCircle1 -> Delete(); }
5021 if ( _ptsCircle2 != NULL){ _ptsCircle2 -> Delete(); }
5022 if ( _circle2Actor != NULL){ _circle2Actor -> Delete(); }
5023 if ( _circle2Mapper != NULL){ _circle2Mapper -> Delete(); }
5024 if ( _pdCircle2 != NULL){ _pdCircle2 -> Delete(); }
5026 if ( _ptsLineRef1 != NULL){ _ptsLineRef1 -> Delete(); }
5027 if ( _lineRef1Actor != NULL){ _lineRef1Actor -> Delete(); }
5028 if ( _lineRef1Mapper != NULL){ _lineRef1Mapper -> Delete(); }
5029 if ( _pdLineRef1 != NULL){ _pdLineRef1 -> Delete(); }
5031 if ( _ptsLineRef2 != NULL){ _ptsLineRef2 -> Delete(); }
5032 if ( _lineRef2Actor != NULL){ _lineRef2Actor -> Delete(); }
5033 if ( _lineRef2Mapper != NULL){ _lineRef2Mapper -> Delete(); }
5034 if ( _pdLineRef2 != NULL){ _pdLineRef2 -> Delete(); }
5037 //-------------------------------------------------------------------
5039 wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
5041 wxPanel *panel = new wxPanel(parent,-1);
5043 _cb_circle = new wxCheckBox(panel,-1,_T("Circle "));
5044 _cb_line = new wxCheckBox(panel,-1,_T("Rotation Axe "));
5047 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
5048 sizerA->Add(_cb_circle);
5049 sizerA->Add(_cb_line);
5052 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5053 sizer->Add( sizerA );
5054 sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
5056 panel->SetAutoLayout(true);
5057 panel->SetSizer(sizer);
5058 panel->SetSize(400,30);
5061 // panel->FitInside();
5063 Connect(_cb_line->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine );
5064 Connect(_cb_circle->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle );
5070 //-------------------------------------------------------------------
5071 void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
5073 SetVisibleCircle( _cb_circle->GetValue() );
5074 _wxvtk2Dbaseview->RefreshView();
5077 //-------------------------------------------------------------------
5078 void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
5087 _lineRef1Actor->GetProperty()->SetOpacity( opacity );
5088 _lineRef2Actor->GetProperty()->SetOpacity( opacity );
5089 _circle1Actor->GetProperty()->SetOpacity( opacity );
5090 _circle2Actor->GetProperty()->SetOpacity( opacity );
5092 //-------------------------------------------------------------------
5093 void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
5095 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5096 vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
5097 _wxvtk2Dbaseview->RefreshView();
5101 //-------------------------------------------------------------------
5102 void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
5104 wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
5106 ConfigureCircleLine();
5107 SetVisibleCircle(false);
5111 //-------------------------------------------------------------------
5112 void wxWidgetMesure2D_Plane::ConfigureCircleLine()
5116 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
5117 int sizeIma = vtkplane2Dview->GetImgSize();
5120 double k=(360/(maxPts-1)) * (3.1416/180);
5121 double x,y,r1=5,r2=10,r3=15;
5122 for (i=0;i<maxPts;i++)
5126 _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1 , (sizeIma/2) + y*r1 , 1 );
5127 _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2 , (sizeIma/2) + y*r2 , 1 );
5131 ang=(45) * (3.1416/180);
5134 _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5136 ang=(45+180) * (3.1416/180);
5139 _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5142 ang=(135) * (3.1416/180);
5145 _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5147 ang=(135+180) * (3.1416/180);
5150 _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3 , (sizeIma/2) + y*r3 , 1 );
5155 //-------------------------------------------------------------------
5156 void wxWidgetMesure2D_Plane::CircleLine()
5159 vtkCellArray *lines;
5161 vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
5164 // Circle 1 Horizontal
5165 _ptsCircle1 = vtkPoints::New();
5166 _ptsCircle1->SetNumberOfPoints(maxPts);
5167 lines = vtkCellArray::New();
5168 lines->InsertNextCell(maxPts);
5169 for (i=0;i<maxPts;i++)
5171 lines->InsertCellPoint(i);
5172 _ptsCircle1->SetPoint(i, 0 , 0 , 0 );
5174 lines->InsertCellPoint(0);
5175 _ptsCircle1->SetPoint(0, -1000 , -1000 , -1000 );
5176 _ptsCircle1->SetPoint(1, 1000 , 1000 , 1000 );
5178 _pdCircle1 = vtkPolyData::New();
5179 _pdCircle1->SetPoints( _ptsCircle1 );
5180 _pdCircle1->SetLines( lines );
5181 lines->Delete(); //do not delete lines ??
5182 _circle1Actor = vtkActor::New();
5183 _circle1Mapper = vtkPolyDataMapper::New();
5184 _circle1Mapper->SetInput(_pdCircle1);
5185 _circle1Mapper->ImmediateModeRenderingOn();
5186 _circle1Actor->SetMapper(_circle1Mapper);
5187 _circle1Actor->GetProperty()->BackfaceCullingOn();
5188 _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5189 _circle1Actor->GetProperty()->SetLineWidth(2);
5190 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
5192 // Circle 2 Horizontal
5193 _ptsCircle2 = vtkPoints::New();
5194 _ptsCircle2->SetNumberOfPoints(maxPts);
5195 lines = vtkCellArray::New();
5196 lines->InsertNextCell(maxPts);
5197 for (i=0;i<maxPts;i++)
5199 lines->InsertCellPoint(i);
5200 _ptsCircle2->SetPoint(i, 0 , 0 , 0 );
5202 _ptsCircle2->SetPoint(0, -1000 , -1000 , -1000 );
5203 _ptsCircle2->SetPoint(1, 1000 , 1000 , 1000 );
5205 _pdCircle2 = vtkPolyData::New();
5206 _pdCircle2->SetPoints( _ptsCircle2 );
5207 _pdCircle2->SetLines( lines );
5208 lines->Delete(); //do not delete lines ??
5209 _circle2Actor = vtkActor::New();
5210 _circle2Mapper = vtkPolyDataMapper::New();
5211 _circle2Mapper->SetInput(_pdCircle2);
5212 _circle2Mapper->ImmediateModeRenderingOn();
5213 _circle2Actor->SetMapper(_circle2Mapper);
5214 _circle2Actor->GetProperty()->BackfaceCullingOn();
5215 _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5216 _circle2Actor->GetProperty()->SetLineWidth(2);
5217 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
5220 _ptsLineRef1 = vtkPoints::New();
5221 _ptsLineRef1->SetNumberOfPoints(2);
5222 _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
5223 _ptsLineRef1->SetPoint(1, 1000 , 1000 , 1000 );
5224 lines = vtkCellArray::New();
5225 lines->InsertNextCell(2);
5226 lines->InsertCellPoint(0);
5227 lines->InsertCellPoint(1);
5229 _pdLineRef1 = vtkPolyData::New();
5230 _pdLineRef1->SetPoints( _ptsLineRef1 );
5231 _pdLineRef1->SetLines( lines );
5232 lines->Delete(); //do not delete lines ??
5233 _lineRef1Actor = vtkActor::New();
5234 _lineRef1Mapper = vtkPolyDataMapper::New();
5235 _lineRef1Mapper->SetInput(_pdLineRef1);
5236 _lineRef1Mapper->ImmediateModeRenderingOn();
5237 _lineRef1Actor->SetMapper(_lineRef1Mapper);
5238 _lineRef1Actor->GetProperty()->BackfaceCullingOn();
5239 _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
5240 _lineRef1Actor->GetProperty()->SetLineWidth(2);
5241 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
5244 _ptsLineRef2 = vtkPoints::New();
5245 _ptsLineRef2->SetNumberOfPoints(2);
5246 _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
5247 _ptsLineRef2->SetPoint(1, 1000 , 1000 , 1000 );
5248 lines = vtkCellArray::New();
5249 lines->InsertNextCell(2);
5250 lines->InsertCellPoint(0);
5251 lines->InsertCellPoint(1);
5253 _pdLineRef2 = vtkPolyData::New();
5254 _pdLineRef2->SetPoints( _ptsLineRef2 );
5255 _pdLineRef2->SetLines( lines );
5256 lines->Delete(); //do not delete lines ??
5257 _lineRef2Actor = vtkActor::New();
5258 _lineRef2Mapper = vtkPolyDataMapper::New();
5259 _lineRef2Mapper->SetInput(_pdLineRef2);
5260 _lineRef2Mapper->ImmediateModeRenderingOn();
5261 _lineRef2Actor->SetMapper(_lineRef2Mapper);
5262 _lineRef2Actor->GetProperty()->BackfaceCullingOn();
5263 _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
5264 _lineRef2Actor->GetProperty()->SetLineWidth(2);
5265 imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
5271 //-------------------------------------------------------------------
5272 //-------------------------------------------------------------------
5273 //-------------------------------------------------------------------
5275 wxWidgetMesure2D_Plane_in_MPR::wxWidgetMesure2D_Plane_in_MPR(wxWindow *parent)
5276 :wxWidgetMesure2D_Plane(parent)
5278 _vtkplane2Dview=NULL;
5281 //-------------------------------------------------------------------
5283 wxWidgetMesure2D_Plane_in_MPR::~wxWidgetMesure2D_Plane_in_MPR()
5286 //-------------------------------------------------------------------
5287 void wxWidgetMesure2D_Plane_in_MPR::OnActiveLink(wxCommandEvent& event)
5289 if (_vtkplane2Dview!=NULL)
5291 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5292 _vtkplane2Dview->Refresh();
5293 _vtkplane2Dview->RefreshView();
5298 //-------------------------------------------------------------------
5299 void wxWidgetMesure2D_Plane_in_MPR::SetActiveLink(bool ok)
5301 _cb_link->SetValue(ok);
5302 if (_vtkplane2Dview!=NULL)
5304 _vtkplane2Dview->SetActive( _cb_link->GetValue() );
5307 //-------------------------------------------------------------------
5309 void wxWidgetMesure2D_Plane_in_MPR::SetVtkPlane2DView(vtkPlane2DView *vtkplane2Dview)
5311 _vtkplane2Dview = vtkplane2Dview;
5314 //-------------------------------------------------------------------
5316 wxWindow *wxWidgetMesure2D_Plane_in_MPR::CreateWin1a(wxWindow *parent) // virtual
5318 wxPanel *panel = new wxPanel(parent,-1);
5320 _cb_link = new wxCheckBox(panel,-1,_T("LINK "));
5321 _cb_link->SetValue(true);
5323 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5325 sizer->Add(_cb_link);
5327 sizer->Add( wxWidgetMesure2D_Plane::CreateWin1a(panel) );
5329 panel->SetAutoLayout(true);
5330 panel->SetSizer(sizer);
5331 panel->SetSize(400,30);
5335 // panel->FitInside();
5337 Connect(_cb_link->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &wxWidgetMesure2D_Plane_in_MPR::OnActiveLink );
5345 //-------------------------------------------------------------------
5346 //-------------------------------------------------------------------
5347 //-------------------------------------------------------------------
5349 BEGIN_EVENT_TABLE( wxMPRWidget, wxPanel )
5350 EVT_MENU( 12121, wxMPRWidget::OnRefreshView )
5351 EVT_MENU( 12122, wxMPRWidget::OnDClickLeft )
5356 wxMPRWidget::wxMPRWidget( wxWindow* parent,
5357 marImageData *marimageData , double voxelSize)
5358 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
5361 _vtkmpr2Dview[0] = NULL;
5362 _vtkmpr2Dview[1] = NULL;
5363 _vtkmpr2Dview[2] = NULL;
5364 _vtkplane2Dview = NULL;
5365 _widgetMesure = NULL;
5366 _wxsphereview = NULL;
5367 _wxvtk3Dbaseview_MPRClipping3D = NULL;
5368 _wxvtkmpr3Dview = NULL;
5369 _wxvtkclipping3Dview = NULL;
5370 _vtkplane2Dview_B = NULL;
5371 _widgetMesure_B = NULL;
5373 _vtkmpr2Dview_B[0] = NULL;
5374 _vtkmpr2Dview_B[1] = NULL;
5375 _vtkmpr2Dview_B[2] = NULL;
5376 _vtkplane2Dview_B = NULL;
5377 _widgetMesure_B = NULL;
5378 _wxsphereview_B = NULL;
5379 _wxvtk3Dbaseview_MPR3D_B = NULL;
5380 _wxvtkmpr3Dview_B = NULL;
5381 _wxvtk3Dbaseview_Clipping3D_BB = NULL;
5382 _wxvtkmpr3Dview_BB = NULL;
5383 _wxvtkclipping3Dview_BB = NULL;
5385 _vtkmprbasedata = NULL;
5388 _voxelSize = voxelSize;
5389 _framePanelCutting = NULL;
5390 _panelCutting = NULL;
5391 _marImageData = marimageData;
5393 _vtkmprbasedata = new vtkMPRBaseData();
5394 _vtkmprbasedata->SetMarImageData(_marImageData);
5396 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
5398 wxPanel *MPRPanel = CreateMPRPanel(pnlSplitter,_vtkmprbasedata);
5399 wxPanel *controlPanel = CreateControlPanel(pnlSplitter);
5400 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
5401 sizer -> Add( pnlSplitter ,1,wxGROW ,0);
5405 while (pp->GetParent()!=NULL) pp=pp->GetParent();
5406 pp->GetSize(&ww,&hh);
5408 pnlSplitter -> SetMinimumPaneSize( 2 );
5410 pnlSplitter -> SplitVertically( MPRPanel, controlPanel, 550 );
5411 this -> SetAutoLayout( true );
5412 this -> SetSizer(sizer);
5413 // sizer -> Fit( this );
5420 //----------------------------------------------------------------------------
5422 wxMPRWidget::~wxMPRWidget( )
5425 if (_framePanelCutting!=NULL)
5427 _framePanelCutting->Close();
5430 if (_vtkmpr2Dview[0]!=NULL) { delete _vtkmpr2Dview[0]; }
5431 if (_vtkmpr2Dview[1]!=NULL) { delete _vtkmpr2Dview[1]; }
5432 if (_vtkmpr2Dview[2]!=NULL) { delete _vtkmpr2Dview[2]; }
5434 if (_vtkmpr2Dview_B[0]!=NULL) { delete _vtkmpr2Dview_B[0]; }
5436 if (_vtkmpr2Dview_B[1]!=NULL) { delete _vtkmpr2Dview_B[1]; }
5437 if (_vtkmpr2Dview_B[2]!=NULL) { delete _vtkmpr2Dview_B[2]; }
5439 if (_vtkmprbasedata!=NULL) { delete _vtkmprbasedata; }
5440 if (_vtkplane2Dview!=NULL) { delete _vtkplane2Dview; }
5441 if (_wxsphereview!=NULL) { delete _wxsphereview; }
5442 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL) { delete _wxvtk3Dbaseview_MPRClipping3D; }
5443 if (_wxvtkmpr3Dview!=NULL) { delete _wxvtkmpr3Dview; }
5444 if (_wxvtkclipping3Dview!=NULL) { delete _wxvtkclipping3Dview; }
5446 if (_vtkplane2Dview_B!=NULL) { delete _vtkplane2Dview_B; }
5447 if (_wxsphereview_B!=NULL) { delete _wxsphereview_B; }
5449 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) { delete _wxvtk3Dbaseview_MPR3D_B; }
5450 if (_wxvtkmpr3Dview_B!=NULL) { delete _wxvtkmpr3Dview_B; }
5452 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL) { delete _wxvtk3Dbaseview_Clipping3D_BB; }
5453 if (_wxvtkmpr3Dview_BB!=NULL) { delete _wxvtkmpr3Dview_BB; }
5454 if (_wxvtkclipping3Dview_BB!=NULL) { delete _wxvtkclipping3Dview_BB; }
5457 //----------------------------------------------------------------------------
5459 wxPanel* wxMPRWidget::CreateControlPanel(wxWindow *parent)
5462 wxPanel *panel=new wxPanel(parent,-1);
5465 // wxStaticText *tmpText = new wxStaticText(panel,-1,"");
5467 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"));
5469 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"));
5471 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)"));
5473 wxStaticText *help3Text = new wxStaticText(panel,-1,
5474 _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"));
5476 wxStaticText *help4Text = new wxStaticText(panel,-1,_T("MPR3D:\n see split control"));
5478 wxString text=_T("");
5479 text=text+_T("Clipping: \n");
5480 text=text+_T(" see split control \n");
5481 text=text+_T(" 4 MarchingCubes: \n");
5482 text=text+_T(" color, isovalue, opacity \n");
5483 text=text+_T(" Box:\n");
5484 text=text+_T(" mouse left drag (box): rotation\n");
5485 text=text+_T(" mouse left drag (sphere): size,position\n");
5486 text=text+_T(" mouse right drag (box): box size");
5487 text=text+_T(" Axis: 3D\n");
5488 text=text+_T(" mouse drag: translate\n");
5489 text=text+_T(" shift + mouse drag: translate 2 axis\n");
5490 text=text+_T(" mouse right: scale\n");
5491 text=text+_T(" Plane 3D:\n");
5492 text=text+_T(" mouse drag perpendicular axis: rotate plane\n");
5493 text=text+_T(" mouse drag spheres: size plane\n");
5494 text=text+_T(" ctrl +mouse right over the plane: size plane\n");
5495 text=text+_T(" mouse drag plane: translate\n");
5496 text=text+_T(" middle click perpendicular axis: translate\n");
5497 wxStaticText *help5Text = new wxStaticText(panel,-1, text );
5500 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
5501 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5502 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5503 sizer->Add( help0Text );
5505 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5506 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5507 sizer->Add( help1Text );
5509 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5510 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5511 sizer->Add( help2Text );
5513 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5514 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5515 sizer->Add( help3Text );
5517 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5518 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5519 sizer->Add( help4Text );
5521 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5522 sizer->Add( new wxStaticText(panel,-1,_T("")) );
5523 sizer->Add( help5Text );
5525 panel->SetSizer(sizer);
5526 panel->SetAutoLayout(true);
5527 panel->SetSize(350,500);
5532 //----------------------------------------------------------------------------
5534 void wxMPRWidget::OnPageAChanged(wxNotebookEvent & event)
5536 _refreshAPage=event.GetSelection();
5541 //----------------------------------------------------------------------------
5543 void wxMPRWidget::OnPageBChanged(wxNotebookEvent & event)
5545 _refreshBPage=event.GetSelection();
5551 //----------------------------------------------------------------------------
5553 wxPanel* wxMPRWidget::CreateView(int type,wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5556 wxPanel *panel=new wxPanel(parent,-1);
5560 _vtkmpr2Dview_B[0] = new wxVtkMPR2DView(panel,0);
5561 _vtkmpr2Dview_B[0]->SetVtkBaseData(vtkmprbasedata);
5562 wxwindow=_vtkmpr2Dview_B[0]->GetWxVTKRenderWindowInteractor();
5566 _vtkmpr2Dview_B[1] = new wxVtkMPR2DView(panel,1);
5567 _vtkmpr2Dview_B[1]->SetVtkBaseData(vtkmprbasedata);
5568 wxwindow=_vtkmpr2Dview_B[1]->GetWxVTKRenderWindowInteractor();
5572 _vtkmpr2Dview_B[2] = new wxVtkMPR2DView(panel,2);
5573 _vtkmpr2Dview_B[2]->SetVtkBaseData(vtkmprbasedata);
5574 wxwindow=_vtkmpr2Dview_B[2]->GetWxVTKRenderWindowInteractor();
5578 _widgetMesure_B = new wxWidgetMesure2D_Plane_in_MPR(panel);
5579 _vtkplane2Dview_B = new vtkPlane2DView( _widgetMesure_B->GetWindow2());
5580 _widgetMesure_B->SetVtkPlane2DView( _vtkplane2Dview_B );
5581 _vtkplane2Dview_B->SetImgSize( 200 );
5582 _vtkplane2Dview_B->SetVtkBaseData(vtkmprbasedata);
5583 wxwindow = _widgetMesure_B;
5587 _wxsphereview_B = new wxSphereView( panel , vtkmprbasedata, vtkmprbasedata->GetImageData() );
5588 wxwindow=_wxsphereview_B->GetWxVTKRenderWindowInteractor();
5593 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( panel , -1);
5594 _wxvtk3Dbaseview_MPR3D_B = new wxVtk3DBaseView( panelMPR3D );
5596 _wxvtkmpr3Dview_B = new wxVtkMPR3DView(_wxvtk3Dbaseview_MPR3D_B);
5597 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5598 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5599 vtkmpr3Ddataviewer->Configure();
5600 _wxvtkmpr3Dview_B->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5602 wxWindow *window3D = _wxvtk3Dbaseview_MPR3D_B->GetWxVTKRenderWindowInteractor();
5603 wxPanel *controlPanel3D = _wxvtkmpr3Dview_B->CreateControlPanel(panelMPR3D);
5606 panelMPR3D -> SetMinimumPaneSize( 5 );
5607 panelMPR3D -> SplitHorizontally( controlPanel3D,window3D,600 );
5609 wxwindow=panelMPR3D;
5614 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
5615 _wxvtk3Dbaseview_Clipping3D_BB = new wxVtk3DBaseView( panelClipping3D );
5617 _wxvtkclipping3Dview_BB = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_BB);
5618 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5619 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5620 vtkclipping3Ddataviewer->Configure();
5621 _wxvtkclipping3Dview_BB->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5623 _wxvtkmpr3Dview_BB = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_BB );
5624 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5625 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5626 vtkmpr3Ddataviewer->Configure();
5627 _wxvtkmpr3Dview_BB->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5629 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_BB->GetWxVTKRenderWindowInteractor();
5631 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
5632 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_BB->CreateControlPanel(panelControl);
5633 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_BB->CreateControlPanel(panelControl);
5634 _btnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
5635 Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
5637 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5638 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5639 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5640 sizerCtrol->Add( _btnCutImageData , 1, wxALL, 2);
5642 panelControl->SetAutoLayout(true);
5643 panelControl->SetSizer(sizerCtrol);
5644 panelControl->SetSize(400,350);
5645 panelControl->Layout();
5647 // panelControl->FitInside();
5650 panelClipping3D -> SetMinimumPaneSize( 5 );
5651 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
5652 wxwindow=panelClipping3D;
5655 wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
5656 sizerH1->Add(wxwindow , 1, wxALL|wxGROW, 0);
5657 panel->SetAutoLayout(true);
5658 panel->SetSizer(sizerH1);
5659 panel->SetSize(400,400);
5665 //----------------------------------------------------------------------------
5667 wxPanel* wxMPRWidget::CreateMPRPanel(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5669 wxPanel *panel=new wxPanel(parent,-1);
5671 wxNotebook *notebook = new wxNotebook( panel, -1 );
5673 notebook->AddPage( CreateMPRPanel4View( notebook ,vtkmprbasedata), _T("4-View") );
5674 notebook->AddPage( CreateView(0,notebook,vtkmprbasedata) , _T("Axial") );
5675 notebook->AddPage( CreateView(1,notebook,vtkmprbasedata) , _T("Sagital") );
5676 notebook->AddPage( CreateView(2,notebook,vtkmprbasedata) , _T("Coronal") );
5677 notebook->AddPage( CreateView(3,notebook,vtkmprbasedata) , _T("Plane") );
5678 notebook->AddPage( CreateView(4,notebook,vtkmprbasedata) , _T("Sphere") );
5679 notebook->AddPage( CreateView(5,notebook,vtkmprbasedata) , _T("MPR 3D") );
5680 notebook->AddPage( CreateView(6,notebook,vtkmprbasedata) , _T("Clipping") );
5681 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageAChanged );
5683 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
5684 sizer->Add(notebook , 1, wxALL|wxGROW, 2);
5685 panel->SetAutoLayout(true);
5686 panel->SetSizer(sizer);
5687 panel->SetSize(400,400);
5691 // panel->FitInside();
5697 //----------------------------------------------------------------------------
5699 wxPanel* wxMPRWidget::CreateMPRPanel4View(wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
5701 wxPanel *panel=new wxPanel(parent,-1);
5704 _vtkmpr2Dview[0] = new wxVtkMPR2DView(panel,0);
5705 _vtkmpr2Dview[0]->SetVtkBaseData(vtkmprbasedata);
5706 wxVTKRenderWindowInteractor *iren0 = _vtkmpr2Dview[0]->GetWxVTKRenderWindowInteractor();
5709 _vtkmpr2Dview[1] = new wxVtkMPR2DView(panel,1);
5710 _vtkmpr2Dview[1]->SetVtkBaseData(vtkmprbasedata);
5711 wxVTKRenderWindowInteractor *iren1 = _vtkmpr2Dview[1]->GetWxVTKRenderWindowInteractor();
5714 _vtkmpr2Dview[2] = new wxVtkMPR2DView(panel,2);
5715 _vtkmpr2Dview[2]->SetVtkBaseData(vtkmprbasedata);
5716 wxVTKRenderWindowInteractor *iren2 = _vtkmpr2Dview[2]->GetWxVTKRenderWindowInteractor();
5719 wxNotebook *notebook = new wxNotebook( panel, -1 );
5720 notebook->SetSize(400,400);
5724 _widgetMesure = new wxWidgetMesure2D_Plane_in_MPR(notebook);
5725 _vtkplane2Dview = new vtkPlane2DView( _widgetMesure->GetWindow2() );
5726 _widgetMesure->SetVtkPlane2DView( _vtkplane2Dview );
5727 _vtkplane2Dview->SetImgSize( 200 );
5728 _vtkplane2Dview->SetVtkBaseData(vtkmprbasedata);
5729 notebook->AddPage( _widgetMesure, _T("Plane") );
5732 _wxsphereview = new wxSphereView( notebook , vtkmprbasedata, vtkmprbasedata->GetImageData());
5733 wxVTKRenderWindowInteractor *iren3B = _wxsphereview->GetWxVTKRenderWindowInteractor();
5734 notebook->AddPage( iren3B, _T("Sphere") );
5738 wxSplitterWindow *panelMPR3D = new wxSplitterWindow( notebook , -1);
5739 _wxvtk3Dbaseview_MPRClipping3D = new wxVtk3DBaseView( panelMPR3D );
5741 _wxvtkmpr3Dview = new wxVtkMPR3DView( _wxvtk3Dbaseview_MPRClipping3D );
5742 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
5743 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5744 vtkmpr3Ddataviewer->Configure();
5745 _wxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
5748 _wxvtkclipping3Dview = new wxVtkClipping3DView( _wxvtk3Dbaseview_MPRClipping3D );
5749 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
5750 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
5751 vtkclipping3Ddataviewer->Configure();
5752 _wxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
5755 wxWindow *window3D = _wxvtk3Dbaseview_MPRClipping3D->GetWxVTKRenderWindowInteractor();
5757 wxPanel *panelControl = new wxPanel(panelMPR3D,-1);
5758 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview->CreateControlPanel(panelControl);
5759 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview->CreateControlPanel(panelControl);
5764 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
5765 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
5766 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
5767 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
5770 panelControl->SetAutoLayout(true);
5771 panelControl->SetSizer(sizerCtrol);
5772 panelControl->SetSize(400,150);
5773 panelControl->Layout();
5776 panelMPR3D -> SetMinimumPaneSize( 5 );
5778 panelMPR3D -> SplitHorizontally( panelControl,window3D,200 );
5780 notebook->AddPage( panelMPR3D, _T("MPR 3D - Clipping") );
5783 Connect(notebook->GetId() , wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED , (wxObjectEventFunction) &wxMPRWidget::OnPageBChanged );
5785 wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
5786 wxBoxSizer *sizerH1= new wxBoxSizer(wxHORIZONTAL);
5787 wxBoxSizer *sizerH2= new wxBoxSizer(wxHORIZONTAL);
5788 sizerH1->Add(iren2 , 1, wxALL|wxEXPAND, 2);
5789 sizerH1->Add(iren0 , 1, wxALL|wxEXPAND, 2);
5790 sizerH2->Add(iren1 , 1, wxALL|wxEXPAND, 2);
5791 // sizerH2->Add(iren3 , 1, wxALL|wxEXPAND, 2);
5792 sizerH2->Add(notebook , 1, wxALL|wxEXPAND, 2);
5794 sizerV->Add(sizerH1, 1, wxALL|wxEXPAND, 0);
5795 sizerV->Add(sizerH2, 1, wxALL|wxEXPAND, 0);
5797 panel->SetAutoLayout(true);
5798 panel->SetSizer(sizerV);
5799 panel->SetSize(400,400);
5804 //----------------------------------------------------------------------------
5805 void wxMPRWidget::OnCutImagaData(wxCommandEvent &event)
5807 if (_btnCutImageData->GetValue()==true){
5808 _framePanelCutting = new wxFrame(this,-1,_T("Cutting Module"),wxDefaultPosition,wxDefaultSize,wxCAPTION|wxSTAY_ON_TOP| wxRESIZE_BORDER );
5809 _framePanelCutting->SetSize(550,400);
5810 _panelCutting = new wxPanelCuttingImageData(_framePanelCutting);
5811 _panelCutting->SetWxVtk3DBaseView( _wxvtk3Dbaseview_Clipping3D_BB );
5812 _panelCutting->SetVtkMPRBaseData( GetVtkMPRBaseData() );
5813 _panelCutting->SetVtkClipping3DDataViewer( this->_wxvtkclipping3Dview_BB->GetVtkClipping3DDataViewer() );
5814 _panelCutting->Configure( );
5816 wxBoxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL );
5817 topsizer -> Add( _panelCutting ,1,wxALL ,0);
5818 _framePanelCutting->SetAutoLayout(true);
5819 _framePanelCutting->SetSizer( topsizer ); // use the sizer for layout
5820 _framePanelCutting->Layout();
5822 // _framePanelCutting->FitInside();
5824 _framePanelCutting->Show();
5826 if (_framePanelCutting!=NULL){
5827 _panelCutting->RemoveActors();
5828 _framePanelCutting->Close();
5829 _framePanelCutting = NULL;
5830 _panelCutting = NULL;
5835 //----------------------------------------------------------------------------
5836 void wxMPRWidget::ConfigureVTK(){
5839 if (_vtkmprbasedata!=NULL)
5841 x=_vtkmprbasedata -> GetMaxPositionX()/2;
5842 y=_vtkmprbasedata -> GetMaxPositionY()/2;
5843 z=_vtkmprbasedata -> GetMaxPositionZ()/2;
5846 if(_vtkmpr2Dview[0]!=NULL) {_vtkmpr2Dview[0] -> Configure();}
5847 if(_vtkmpr2Dview[1]!=NULL) {_vtkmpr2Dview[1] -> Configure();}
5848 if(_vtkmpr2Dview[2]!=NULL) {_vtkmpr2Dview[2] -> Configure();}
5851 if (_vtkmpr2Dview_B[0]!=NULL) { _vtkmpr2Dview_B[0] -> Configure(); }
5852 if (_vtkmpr2Dview_B[1]!=NULL) { _vtkmpr2Dview_B[1] -> Configure(); }
5853 if (_vtkmpr2Dview_B[2]!=NULL) { _vtkmpr2Dview_B[2] -> Configure(); }
5856 if (_vtkmprbasedata!=NULL)
5858 _vtkmprbasedata->SetX( x );
5859 _vtkmprbasedata->SetY( y );
5860 _vtkmprbasedata->SetZ( z );
5863 if (_vtkplane2Dview!=NULL){_vtkplane2Dview -> Configure();}
5864 if (_widgetMesure!=NULL){_widgetMesure -> ConfigureA(_vtkplane2Dview);}
5865 if (_widgetMesure!=NULL){_widgetMesure -> SetActiveLink(true);}
5866 if (_widgetMesure!=NULL){_widgetMesure -> SetMesureScale( _voxelSize );}
5867 if (_wxsphereview!=NULL){_wxsphereview -> Configure();}
5869 if (_wxvtk3Dbaseview_MPRClipping3D!=NULL){_wxvtk3Dbaseview_MPRClipping3D -> Configure();}
5870 if (_wxvtkmpr3Dview!=NULL){
5871 _wxvtkmpr3Dview -> Configure();
5873 if (_wxvtkclipping3Dview!=NULL){_wxvtkclipping3Dview -> Configure();}
5875 if (_vtkplane2Dview_B!=NULL){ _vtkplane2Dview_B -> Configure(); }
5876 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> ConfigureA( _vtkplane2Dview_B ); }
5877 if (_widgetMesure_B!=NULL){ _widgetMesure_B -> SetActiveLink(true); }
5881 // vtkImageData *imageData = _vtkmprbasedata->GetImageData();
5882 // imageData->Update();
5883 // imageData->GetSpacing(spc);
5884 // _widgetMesure_B->SetMesureScale(spc[0]);
5886 if (_widgetMesure_B!=NULL) {_widgetMesure_B->SetMesureScale( _voxelSize );}
5889 if (_wxsphereview_B!=NULL) {_wxsphereview_B -> Configure();}
5891 if (_wxvtk3Dbaseview_MPR3D_B!=NULL) {_wxvtk3Dbaseview_MPR3D_B -> Configure();}
5892 if (_wxvtkmpr3Dview_B!=NULL) {_wxvtkmpr3Dview_B -> Configure();}
5894 if ( _wxvtk3Dbaseview_Clipping3D_BB!=NULL) {_wxvtk3Dbaseview_Clipping3D_BB -> Configure(); }
5895 if ( _wxvtkmpr3Dview_BB!=NULL) {_wxvtkmpr3Dview_BB -> Configure(); }
5896 if ( _wxvtkclipping3Dview_BB!=NULL) {_wxvtkclipping3Dview_BB -> Configure(); }
5899 vtkInteractorStyle3DView *vtkinteractorstyle3Dview;
5900 if (_wxvtkmpr3Dview_BB!=NULL)
5902 vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
5903 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_BB);
5904 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_BB);
5907 if (_wxvtk3Dbaseview_Clipping3D_BB!=NULL)
5909 _wxvtk3Dbaseview_Clipping3D_BB->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
5915 //----------------------------------------------------------------------------
5917 void wxMPRWidget::OnRefreshView(wxCommandEvent & event)
5921 //----------------------------------------------------------------------------
5922 void wxMPRWidget::OnDClickLeft(wxCommandEvent & event)
5924 if (_wxsphereview!=NULL) {
5925 _wxsphereview -> RefreshPoint();
5927 if (_wxsphereview_B!=NULL) {
5928 _wxsphereview_B -> RefreshPoint();
5931 //----------------------------------------------------------------------------
5932 void wxMPRWidget::RefreshView(bool firsttime){
5934 if (_refreshAPage == 0 )
5937 if ((_vtkmpr2Dview[0]!=NULL) && (_vtkmpr2Dview[1]!=NULL) && (_vtkmpr2Dview[2]!=NULL) )
5939 _vtkmpr2Dview[2] -> Refresh();
5940 _vtkmpr2Dview[1] -> Refresh();
5941 _vtkmpr2Dview[0] -> Refresh();
5943 if (firsttime==false)
5945 _vtkmpr2Dview[2] -> RefreshView();
5946 _vtkmpr2Dview[1] -> RefreshView();
5947 _vtkmpr2Dview[0] -> RefreshView();
5950 if (_refreshBPage == 0 )
5952 if (_vtkplane2Dview!=NULL)
5954 _vtkplane2Dview -> Refresh();
5955 if (firsttime==false)
5957 _vtkplane2Dview -> RefreshView();
5959 // _wxvtk3Dbaseview_MPR3D_B -> Refresh();
5962 if (_refreshBPage == 1 )
5966 if (_refreshBPage == 2 )
5968 if ((_wxvtkmpr3Dview!=NULL) && (_wxvtk3Dbaseview_MPRClipping3D!=NULL) && (_wxvtkclipping3Dview!=NULL) )
5970 _wxvtkmpr3Dview -> RefreshView();
5971 _wxvtk3Dbaseview_MPRClipping3D -> Refresh();
5972 _wxvtkclipping3Dview -> Refresh();
5978 if (_refreshAPage == 1 )
5980 if (_vtkmpr2Dview_B[0] !=NULL){
5981 _vtkmpr2Dview_B[0] -> Refresh();
5984 if (_refreshAPage == 2 )
5986 if (_vtkmpr2Dview_B[1] !=NULL){
5987 _vtkmpr2Dview_B[1] -> Refresh();
5990 if (_refreshAPage == 3 )
5992 if (_vtkmpr2Dview_B[2] !=NULL){
5993 _vtkmpr2Dview_B[2] -> Refresh();
5996 if (_refreshAPage == 4 )
5998 if (_vtkplane2Dview_B!=NULL){
5999 _vtkplane2Dview_B -> Refresh();
6000 if (firsttime==false)
6002 _vtkplane2Dview_B -> RefreshView();
6007 if (_refreshAPage == 5 )
6011 if (_refreshAPage == 6 )
6013 if (_wxvtkmpr3Dview_B!=NULL){
6014 _wxvtkmpr3Dview_B -> Refresh();
6015 _wxvtk3Dbaseview_MPR3D_B -> Refresh();
6018 if (_refreshAPage == 7 )
6020 if (_wxvtkmpr3Dview_BB!=NULL){
6021 _wxvtkmpr3Dview_BB -> RefreshView();
6022 _wxvtkclipping3Dview_BB -> Refresh();
6023 _wxvtk3Dbaseview_Clipping3D_BB -> Refresh();
6024 if (_panelCutting!=NULL)
6026 _panelCutting->RefreshView();
6032 //----------------------------------------------------------------------------
6033 vtkMPRBaseData *wxMPRWidget::GetVtkMPRBaseData(){
6034 return _vtkmprbasedata;
6036 //----------------------------------------------------------------------------
6037 vtkPlane2DView *wxMPRWidget::GetVtkPlane2DView()
6039 return _vtkplane2Dview;
6041 //----------------------------------------------------------------------------
6042 wxVtkMPR3DView *wxMPRWidget::GetWxvtkmpr3Dview_BB()
6044 return _wxvtkmpr3Dview_BB;
6046 //----------------------------------------------------------------------------
6047 wxVtkBaseView *wxMPRWidget::GetWxVtkBaseView(int page, int id)
6049 wxVtkBaseView *result=NULL;
6052 if ((id>=0) &&(id<=3)){
6053 result=_vtkmpr2Dview[id];
6057 result=_vtkplane2Dview;
6062 //----------------------------------------------------------------------------
6063 wxVtkMPR2DView *wxMPRWidget::GetWxvtkMPR2Dview(int direction)
6065 return _vtkmpr2Dview[direction];
6068 //----------------------------------------------------------------------------
6069 //----------------------------------------------------------------------------
6070 //----------------------------------------------------------------------------
6071 wxMPRWidget2::wxMPRWidget2(wxWindow* parent,marImageData *marimagedata,double voxelSize)
6072 : wxMPRWidget(parent,marimagedata,voxelSize)
6075 //----------------------------------------------------------------------------
6076 wxMPRWidget2::~wxMPRWidget2()
6079 //----------------------------------------------------------------------------
6080 void wxMPRWidget2::OnRefreshView(wxCommandEvent & event) // Virtual
6082 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
6083 this->GetParent()->ProcessEvent(newevent1);
6087 //----------------------------------------------------------------------------
6088 //----------------------------------------------------------------------------
6089 //----------------------------------------------------------------------------
6090 figureCuttingModel::figureCuttingModel()
6092 _inversModel = vtkTransform::New();
6093 _matrixModel = vtkTransform::New();
6094 _matrixVisual = vtkTransform::New();
6100 //----------------------------------------------------------------------------
6101 figureCuttingModel::~figureCuttingModel() // virtual
6103 _inversModel->Delete();
6105 //----------------------------------------------------------------------------
6106 void figureCuttingModel::SetPosition(double x,double y, double z)
6112 //----------------------------------------------------------------------------
6113 void figureCuttingModel::SetScale(double sx,double sy, double sz)
6119 //----------------------------------------------------------------------------
6120 void figureCuttingModel::SetRotation(double alfa,double beta, double teta)
6127 //----------------------------------------------------------------------------
6128 void figureCuttingModel::CalculeMatrix()
6130 _matrixModel->Identity();
6131 _matrixModel->Translate(_px,_py,_pz);
6132 _matrixModel->RotateY(_beta);
6133 _matrixModel->RotateX(_alfa);
6134 _matrixModel->RotateY(_teta);
6135 _matrixModel->Scale(_sx,_sy,_sz);
6137 _matrixVisual->Identity();
6138 _matrixVisual->Translate( _px*_spcX , _py*_spcY , _pz*_spcZ );
6139 _matrixVisual->RotateY(_beta);
6140 _matrixVisual->RotateX(_alfa);
6141 _matrixVisual->RotateY(_teta);
6142 _matrixVisual->Scale( _sx*_spcX , _sy*_spcY , _sz*_spcZ );
6147 //----------------------------------------------------------------------------
6148 void figureCuttingModel::CalculeInversMatrix()
6150 _inversModel->Identity ();
6151 _inversModel->Concatenate ( _matrixModel );
6152 _inversModel->Inverse();
6154 //----------------------------------------------------------------------------
6155 bool figureCuttingModel::IfPointInside(double x, double y, double z) // virtual
6160 //----------------------------------------------------------------------------
6161 vtkTransform *figureCuttingModel::GetVtkTransform()
6163 return _matrixVisual;
6166 //----------------------------------------------------------------------------
6167 //void figureCuttingModel::SetVtkTransform(vtkTransform *matrix)
6169 // _matrixModel = matrix;
6172 //----------------------------------------------------------------------------
6173 double figureCuttingModel::GetTheoricVolume() // virtual
6178 //----------------------------------------------------------------------------
6179 double figureCuttingModel::GetPositionX()
6183 //----------------------------------------------------------------------------
6184 double figureCuttingModel::GetPositionY()
6188 //----------------------------------------------------------------------------
6189 double figureCuttingModel::GetPositionZ()
6193 //----------------------------------------------------------------------------
6194 double figureCuttingModel::GetScaleX()
6198 //----------------------------------------------------------------------------
6199 double figureCuttingModel::GetScaleY()
6203 //----------------------------------------------------------------------------
6204 double figureCuttingModel::GetScaleZ()
6208 //----------------------------------------------------------------------------
6209 double figureCuttingModel::GetAngleAlfa()
6213 //----------------------------------------------------------------------------
6214 double figureCuttingModel::GetAngleBeta()
6218 //----------------------------------------------------------------------------
6219 double figureCuttingModel::GetAngleTeta()
6223 //----------------------------------------------------------------------------
6224 char *figureCuttingModel::GetName() // virtual
6229 //----------------------------------------------------------------------------
6230 void figureCuttingModel::SetSpacing(double spcX,double spcY, double spcZ)
6237 //----------------------------------------------------------------------------
6240 //----------------------------------------------------------------------------
6241 //----------------------------------------------------------------------------
6242 //----------------------------------------------------------------------------
6243 figureCuttingSphereModel::figureCuttingSphereModel()
6246 //----------------------------------------------------------------------------
6247 figureCuttingSphereModel::~figureCuttingSphereModel() // virtual
6250 //----------------------------------------------------------------------------
6251 bool figureCuttingSphereModel::IfPointInside(double x, double y, double z) // virtual
6253 double in[4],out[4];
6258 _inversModel->MultiplyPoint (in, out);
6261 if (sqrt( out[0]*out[0] + out[1]*out[1] + out[2]*out[2] )<0.5 )
6267 //----------------------------------------------------------------------------
6268 double figureCuttingSphereModel::GetTheoricVolume() // virtual
6270 double piTMP=3.14159265;
6271 return (4.0/3.0) * piTMP * (_sx/2)*(_sy/2)*(_sz/2);
6273 //----------------------------------------------------------------------------
6274 char *figureCuttingSphereModel::GetName() // virtual
6280 //----------------------------------------------------------------------------
6281 //----------------------------------------------------------------------------
6282 //----------------------------------------------------------------------------
6283 figureCuttingCubeModel::figureCuttingCubeModel()
6286 //----------------------------------------------------------------------------
6287 figureCuttingCubeModel::~figureCuttingCubeModel() // virtual
6290 //----------------------------------------------------------------------------
6291 bool figureCuttingCubeModel::IfPointInside(double x, double y, double z) // virtual
6293 double in[4],out[4];
6298 _inversModel->MultiplyPoint (in, out);
6301 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) )
6307 //----------------------------------------------------------------------------
6308 double figureCuttingCubeModel::GetTheoricVolume() // virtual
6310 return _sx * _sy * _sz;
6313 //----------------------------------------------------------------------------
6314 char *figureCuttingCubeModel::GetName() // virtual
6319 //----------------------------------------------------------------------------
6320 //----------------------------------------------------------------------------
6321 //----------------------------------------------------------------------------
6323 figureCuttingCylinderModel::figureCuttingCylinderModel()
6326 //----------------------------------------------------------------------------
6327 figureCuttingCylinderModel::~figureCuttingCylinderModel() // virtual
6330 //----------------------------------------------------------------------------
6331 bool figureCuttingCylinderModel::IfPointInside(double x, double y, double z) // virtual
6333 double in[4],out[4];
6338 _inversModel->MultiplyPoint (in, out);
6341 if ((sqrt( out[0]*out[0] + out[2]*out[2] )<0.5 ) && (out[1]>-0.5) && (out[1]<0.5) )
6347 //----------------------------------------------------------------------------
6348 double figureCuttingCylinderModel::GetTheoricVolume() // virtual
6350 double piTMP=3.14159265;
6351 return piTMP*(_sx/2)*(_sz/2)*_sy;
6353 //----------------------------------------------------------------------------
6354 char *figureCuttingCylinderModel::GetName() // virtual
6358 //----------------------------------------------------------------------------
6362 // EOF - wxMPRWidget.cxx