]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx
#3219 creaMaracasVisu Feature New Normal - vtk8itk4wx3-mingw64
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkMPR2DView.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "wxVtkMPR2DView.h"
27
28 #include "vtkInteractorStyleBaseView.h"
29
30 #include "vtkCellArray.h"
31 #include "vtkImageActor.h"
32
33 #ifdef WIN32
34 #include <mathdefs.h>
35 using namespace gtm;
36 #endif
37
38 wxVtkMPR2DView::wxVtkMPR2DView( wxWindow *parent, int direction)
39  :wxVtk2DBaseView(parent)
40 {
41         _backX                  = -99999;
42         _backY                  = -99999;
43         _backZ                  = -99999;
44         _direction              = direction;
45         _ptsA                   = NULL;
46         _lineAActor             = NULL;
47         _lineAMapper    = NULL;
48         _pdA                    = NULL;
49         _ptsB                   = NULL;
50         _lineBActor             = NULL;
51         _lineBMapper    = NULL;
52         _pdB                    = NULL;
53         _interactorstylemprview = NULL;
54 }
55
56 //-------------------------------------------------------------------
57 wxVtkMPR2DView::~wxVtkMPR2DView()
58 {
59         if (_ptsA!=NULL)            { _ptsA->Delete();                  }
60         if (_lineAActor!=NULL)  { _lineAActor->Delete();        }
61         if (_lineAMapper!=NULL) { _lineAMapper->Delete();       }
62         if (_pdA!=NULL)             { _pdA->Delete();                   }
63         if (_ptsB!=NULL)            { _ptsB->Delete();                  }
64         if (_lineBActor!=NULL)  { _lineBActor->Delete();        }
65         if (_lineBMapper!=NULL) { _lineBMapper->Delete();       }
66         if (_pdB!=NULL)             { _pdB->Delete();                   }
67 }
68 //-------------------------------------------------------------------
69 vtkMPRBaseData *wxVtkMPR2DView::GetVtkmprbasedata()
70 {
71         return (vtkMPRBaseData*)GetVtkBaseData();
72 }
73 //-------------------------------------------------------------------
74 void wxVtkMPR2DView::Configure()
75 {
76         wxVtk2DBaseView::Configure();
77         int x1,x2,y1,y2,z1,z2;
78         GetVtkmprbasedata()     -> GetDimensionExtention(&x1,&x2,&y1,&y2,&z1,&z2);
79         double spc[3];
80         vtkImageData* img =  GetVtkmprbasedata()->GetImageData();
81         if(_interactorstylemprview==NULL)
82         {
83                 _interactorstylemprview = new vtkInteractorStyleMPRView();
84                 ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstylemprview );
85         }
86
87         if(img!=NULL)
88         {
89                 double* origin = img->GetOrigin();
90                 img->GetExtent(x1,x2,y1,y2,z1,z2);
91                 img->GetSpacing(spc);
92                 x1 += origin[0];
93                 x2 += origin[0];
94                 y1 += origin[1];
95                 y2 += origin[1];
96                 z1 += origin[2];
97                 z2 += origin[2];
98                 x1 = (int)(x1*spc[0]);
99                 y1 = (int)(y1*spc[1]);
100                 z1 = (int)(z1*spc[2]);
101                 x2 = (int)(x2*spc[0]);
102                 y2 = (int)(y2*spc[1]);
103                 z2 = (int)(z2*spc[2]);
104                 _visibleAxis = true;
105         }
106
107         // Axe A
108         if(_lineAActor==NULL){
109                 _lineAActor = vtkActor::New();
110                 _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
111                 _lineAActor->GetProperty()->SetLineWidth(0.5);
112
113                 _ptsA = vtkPoints::New();
114                 _ptsA->SetNumberOfPoints(2);
115                 _ptsA->SetPoint(0, -1000        , -1000 , -1000 );
116                 _ptsA->SetPoint(1,  1000        ,  1000 ,  1000 );
117                 _pdA = vtkPolyData::New();
118                 _lineAMapper = vtkPolyDataMapper::New();
119
120 //EED 2017-01-01 Migration VTK7
121 #if VTK_MAJOR_VERSION <= 5
122                 _lineAMapper->SetInput(_pdA);
123 #else
124                 _lineAMapper->SetInputData(_pdA);
125 #endif
126
127                 _lineAMapper->ImmediateModeRenderingOn();
128                 _lineAActor->SetMapper(_lineAMapper);
129         }
130
131         vtkCellArray *linesA = vtkCellArray::New();
132         linesA->InsertNextCell(2);
133         linesA->InsertCellPoint(0);
134         linesA->InsertCellPoint(1);
135         _pdA->SetPoints( _ptsA );
136         _pdA->SetLines( linesA );
137         linesA->Delete();  //do not delete lines ??
138 //              _lineAActor->GetProperty()->BackfaceCullingOn();
139
140
141 // Axe B
142         if(_lineBActor==NULL)
143         {
144                 _lineBActor                                             =       vtkActor::New();
145                 _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
146                 _lineBActor->GetProperty()->SetLineWidth(0.5);
147                 _lineBMapper                                    =       vtkPolyDataMapper::New();
148                 _lineBActor->SetMapper(_lineBMapper);
149                 _ptsB = vtkPoints::New();
150                 _ptsB->SetNumberOfPoints(2);
151                 _ptsB->SetPoint(0, -1000        , -1000 , -1000 );
152                 _ptsB->SetPoint(1,  1000        ,  1000 ,  1000 );
153 //              _lineBActor->GetProperty()->BackfaceCullingOn();
154         }
155
156         vtkCellArray *linesB;
157         linesB = vtkCellArray::New();
158         linesB->InsertNextCell(2);
159         linesB->InsertCellPoint(0);
160         linesB->InsertCellPoint(1);
161         _pdB = vtkPolyData::New();
162         _pdB->SetPoints( _ptsB );
163         _pdB->SetLines( linesB );
164         linesB->Delete();  //do not delete lines ??
165
166 //EED 2017-01-01 Migration VTK7
167 #if VTK_MAJOR_VERSION <= 5
168         _lineBMapper->SetInput(_pdB);
169 #else
170         _lineBMapper->SetInputData(_pdB);
171 #endif
172
173         _lineBMapper->ImmediateModeRenderingOn();
174         if(_imageViewer2XYZ)
175         {
176                 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
177                 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
178                 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
179
180         //EED 17Avril2009
181     //EED 21 mars 2012  FLIP problem  ..PLOP..
182
183                 if (_direction==0) 
184                 {  // YZ
185                         camera->SetViewUp               (   0   ,    0          ,     1         );
186                         camera->SetPosition             ( 10000,(y1+y2)/2       , (z1+z2)/2     );
187                         camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
188                         camera->SetParallelScale( (z2-z1)/3.0 );
189                 }
190                 if (_direction==1) 
191                 { // XZ
192                         camera->SetViewUp               (       0               ,       0       ,       1               );
193                         camera->SetPosition             ((x1+x2)/2      , -10000        , (z1+z2)/2     );
194                         camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
195                         camera->SetParallelScale( (x2-x1)/3.0 );
196                 }
197                 if (_direction==2) 
198                 {  // XY
199                         camera->SetViewUp               (       0               ,       -1              ,       0       );
200                         camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     , -10000);
201                         camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       );
202                         camera->SetParallelScale( (x2-x1)/3.0 );
203                 }
204
205 /*
206                 if (_direction==0) {    // YZ
207                         camera->SetViewUp               (   0   ,     1         ,     0         );
208                         camera->SetPosition             (  10000,(y1+y2)/2      , (z1+z2)/2     );
209                         camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
210                         camera->SetParallelScale( (z2-z1)/3.0 );
211                 }
212
213                 if (_direction==1) {    // XZ
214                         camera->SetViewUp               (       0               ,       0       ,       -1              );
215                         camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     );
216                         camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
217                         camera->SetParallelScale( (x2-x1)/3.0 );
218                 }
219
220                 if (_direction==2) {    // XY
221                         camera->SetViewUp               (       0               ,       1               ,       0       );
222                         camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     ,  10000);
223                         camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       );
224                         camera->SetParallelScale( (x2-x1)/3.0 );
225                 }
226 */
227
228         //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
229         //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
230         }
231 }
232
233 void wxVtkMPR2DView::SetVisibleAxis(bool ok)
234 {
235         if (ok!=_visibleAxis)
236         {
237                 _visibleAxis=ok;
238                 if (_visibleAxis==true)
239                 {
240                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
241                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
242                 }
243                 if (_visibleAxis==false)
244                 {
245                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
246                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
247                 } // if visible
248         } // ok
249 }
250
251 //-------------------------------------------------------------------
252 void wxVtkMPR2DView::Refresh()
253 {
254         //wxVtk2DBaseView::Refresh();
255         int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0;
256 //EED 02/08/2013
257 //      int x = 0, y = 0, z = 0;
258         double  x  = 0, y  = 0, z  = 0;
259         int     xx = 0, yy = 0, zz = 0;
260         double *spc     = 0;
261         double *origin  = 0;
262         double xx1,yy1,zz1,xx2,yy2,zz2;
263         bool   fixAxis2D;
264         double opacityAxis;
265         vtkImageData* img = GetVtkmprbasedata()->GetImageData();
266         if(img!=NULL)
267         {
268                 origin = img->GetOrigin();
269                 img->GetExtent(x1,x2,y1,y2,z1,z2);
270                 spc = img->GetSpacing();
271                 x1 += origin[0];
272                 x2 += origin[0];
273                 y1 += origin[1];
274                 y2 += origin[1];
275                 z1 += origin[2];
276                 z2 += origin[2];
277                 xx1 =           x1*spc[0];
278                 yy1 =           y1*spc[1];
279                 zz1 =           z1*spc[2];
280                 xx2 =           x2*spc[0];
281                 yy2 =           y2*spc[1];
282                 zz2 =           z2*spc[2];
283                 x1      = (int)(x1*spc[0]);
284                 y1      = (int)(y1*spc[1]);
285                 z1      = (int)(z1*spc[2]);
286                 x2      = (int)(x2*spc[0]);
287                 y2      = (int)(y2*spc[1]);
288                 z2      = (int)(z2*spc[2]);
289                 xx      = (int)(GetVtkmprbasedata()->GetX());
290                 yy      = (int)(GetVtkmprbasedata()->GetY());
291                 zz      = (int)(GetVtkmprbasedata()->GetZ());
292 //EED 02/08/2013
293 //              x =  round(xx*spc[0]);
294 //              y =  round(yy*spc[1]);
295 //              z =  round(zz*spc[2]);
296                 x       =  xx*spc[0];
297                 y       =  yy*spc[1];
298                 z       =  zz*spc[2];
299                 fixAxis2D               = GetVtkmprbasedata()->GetFixAxis2D();
300                 opacityAxis             = GetVtkmprbasedata()->GetOpacityAxis();
301                 if ((xx!=_backX) || (yy!=_backY) || (zz!=_backZ)  || (fixAxis2D!=_backFixAxis2D) || (opacityAxis!=_backOpacityAxis)) 
302                 {
303                         double position[3];
304                         double focalpoint[3];
305                         GetRenderer()->GetActiveCamera()->GetPosition(position);
306                         GetRenderer()->GetActiveCamera()->GetFocalPoint(focalpoint);
307                         if (_direction==0) {    // YZ
308                                 if(_imageViewer2XYZ)
309                                 {
310                                         _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
311                                 }
312 //EED 21 mars 2012  FLIP probleme  ..PLOP..
313                                 //_ptsA->SetPoint(0, x2, y1  , z );
314                                 //_ptsA->SetPoint(1, x2, y2  , z );
315                                 //_ptsB->SetPoint(0, x2, y   , z1);
316                                 //_ptsB->SetPoint(1, x2, y   , z2);
317                                 _ptsA->SetPoint(0, xx2, yy1  , z  );
318                                 _ptsA->SetPoint(1, xx2, yy2  , z  );
319                                 _ptsB->SetPoint(0, xx2, y    , zz1);
320                                 _ptsB->SetPoint(1, xx2, y    , zz2);
321                                 position[1]             = y;    
322                                 position[2]             = z;    
323                                 focalpoint[1]   = y;    
324                                 focalpoint[2]   = z;    
325                         }
326                         if (_direction==1) {    // XZ
327                                 if(_imageViewer2XYZ)
328                                 {
329                                         _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
330                                 }
331 //EED 21 mars 2012  FLIP probleme  ..PLOP..
332                             //_ptsA->SetPoint(0, x1 , y2 , z );
333                                 //_ptsA->SetPoint(1, x2 , y2 , z );
334                                 //_ptsB->SetPoint(0, x  , y2 , z1);
335                                 //_ptsB->SetPoint(1, x  , y2 , z2);
336                             _ptsA->SetPoint(0, xx1 , y1 , z  );
337                                 _ptsA->SetPoint(1, xx2 , y1 , z  );
338                                 _ptsB->SetPoint(0, x   , y1 , zz1);
339                                 _ptsB->SetPoint(1, x   , y1 , zz2);
340                                 position[0]             = x;    
341                                 position[2]             = z;    
342                                 focalpoint[0]   = x;    
343                                 focalpoint[2]   = z;    
344                         }
345                         if (_direction==2) {    // XY
346                                 if(_imageViewer2XYZ)
347                                 {
348                                         _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
349                                 }
350                         //      _ptsA->SetPoint(0, x1 , y , -z2 );
351                         //      _ptsA->SetPoint(1, x2 , y , -z2 );
352                         //      _ptsB->SetPoint(0, x  , y1, -z2 );
353                         //      _ptsB->SetPoint(1, x  , y2, -z2 );
354
355                                 
356 //EED 21 mars 2012  FLIP probleme  ..PLOP..
357                                 //_ptsA->SetPoint(0, x1 , y , z2 );
358                                 //_ptsA->SetPoint(1, x2 , y , z2 );
359                                 //_ptsB->SetPoint(0, x  , y1, z2 );
360                                 //_ptsB->SetPoint(1, x  , y2, z2 );
361                                 _ptsA->SetPoint(0, xx1 , y  , z1 );
362                                 _ptsA->SetPoint(1, xx2 , y  , z1 );
363                                 _ptsB->SetPoint(0, x   , yy1, z1 );
364                                 _ptsB->SetPoint(1, x   , yy2, z1 );
365                                 position[0]             = x;    
366                                 position[1]             = y;    
367                                 focalpoint[0]   = x;    
368                                 focalpoint[1]   = y;                                    
369                         } // if back
370                         
371 //EED 2017-01-01 Migration VTK7
372 #if VTK_MAJOR_VERSION <= 5
373                                 // ..
374 #else
375                                 _ptsA->Modified();
376                                 _ptsB->Modified();
377 #endif
378
379                         if (fixAxis2D == true)
380                         {
381                                 GetRenderer()->GetActiveCamera()->SetPosition(position);
382                                 GetRenderer()->GetActiveCamera()->SetFocalPoint(focalpoint);
383                         } // if GetFixAxis2D
384                         _lineAActor->GetProperty()->SetOpacity( opacityAxis );
385                         _lineBActor->GetProperty()->SetOpacity( opacityAxis );
386                         _backX                  = xx;
387                         _backY                  = yy;
388                         _backZ                  = zz;
389                         _backFixAxis2D  = fixAxis2D;
390                         _backOpacityAxis= opacityAxis;
391                 } // if image
392
393 //EED 2016/02/19
394         vtkImageActor *imageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
395         imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() );
396 //EED 01nov2012
397                 UpdateColorWindowLevel();
398                 wxVtkBaseView::Refresh();
399         }
400 }
401
402 //-------------------------------------------------------------------
403 int wxVtkMPR2DView::GetActualSlice()   // virtual
404 {
405         int result;
406         if (_direction==0)
407         {
408                 result = (int)(GetVtkmprbasedata()->GetX());
409         }
410         if (_direction==1)
411         {
412                 result = (int)(GetVtkmprbasedata()->GetY());
413         }
414         if (_direction==2)
415         {
416                 result = (int)(GetVtkmprbasedata()->GetZ());
417         }
418         return result;
419 }
420 //-------------------------------------------------------------------
421 void wxVtkMPR2DView::SetActualSlice(int slice)   // virtual
422 {
423         if (_direction==0)
424         {
425                 GetVtkmprbasedata()->SetX(slice);
426         }
427         if (_direction==1)
428         {
429                 GetVtkmprbasedata()->SetY(slice);
430         }
431         if (_direction==2)
432         {
433                 GetVtkmprbasedata()->SetZ(slice);
434         }
435 }
436 //-------------------------------------------------------------------
437 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
438 {
439         double delta=5;
440         bool result=false;
441         if (_direction==0)
442         {
443         }
444         if (_direction==1)
445         {
446                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
447                 {
448                         result = true;
449                 }
450         }
451         if (_direction==2)
452         {
453                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
454                 {
455                         result = true;
456                 }
457         }
458         return result;
459 }
460 //-------------------------------------------------------------------
461 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
462 {
463         double delta=5;
464         bool result=false;
465         if (_direction==0)
466         {
467                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
468                 {
469                         result = true;
470                 }
471         }
472         if (_direction==1)
473         {
474         }
475         if (_direction==2)
476         {
477                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
478                 {
479                         result = true;
480                 }
481         }
482         return result;
483 }
484 //-------------------------------------------------------------------
485 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
486 {
487         double delta=5;
488         bool result=false;
489         if (_direction==0)
490         {
491                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
492                 {
493                         result = true;
494                 }
495         }
496         if (_direction==1)
497         {
498                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
499                 {
500                         result = true;
501                 }
502         }
503         if (_direction==2)
504         {
505         }
506         return result;
507 }
508 //-------------------------------------------------------------------
509 void wxVtkMPR2DView::MoveX(double x, double y, double z)
510 {
511         if (_direction==0)
512         {
513         }
514         if (_direction==1)
515         {
516                 GetVtkmprbasedata()->SetX(x);
517         }
518         if (_direction==2)
519         {
520                 GetVtkmprbasedata()->SetX(x);
521         }
522 }
523 //-------------------------------------------------------------------
524 void wxVtkMPR2DView::MoveY(double x, double y, double z)
525 {
526         if (_direction==0)
527         {
528                 GetVtkmprbasedata()->SetY(y);
529         }
530         if (_direction==1)
531         {
532         }
533         if (_direction==2)
534         {
535                 GetVtkmprbasedata()->SetY(y);
536         }
537 }
538 //-------------------------------------------------------------------
539 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
540 {
541         if (_direction==0)
542         {
543                 GetVtkmprbasedata()->SetZ(z);
544         }
545         if (_direction==1)
546         {
547                 GetVtkmprbasedata()->SetZ(z);
548         }
549         if (_direction==2)
550         {
551         }
552 }
553 //-------------------------------------------------------------------
554 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
555 {
556         double c1r=1,c1g=1,c1b=0;
557         double c2r=1,c2g=0,c2b=0;
558
559         if (_direction==0)
560         {
561                 if (IfMouseTouchY(x,y,z)==true)
562                 {
563                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
564                 } else {
565                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
566                 }
567                 if (IfMouseTouchZ(x,y,z)==true)
568                 {
569                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
570                 } else {
571                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
572                 }
573         }
574
575         if (_direction==1)
576         {
577                 if (IfMouseTouchX(x,y,z)==true)
578                 {
579                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
580                 } else {
581                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
582                 }
583                 if (IfMouseTouchZ(x,y,z)==true)
584                 {
585                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
586                 } else {
587                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
588                 }
589         }
590
591         if (_direction==2)
592         {
593                 if (IfMouseTouchX(x,y,z)==true)
594                 {
595                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
596                 } else {
597                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
598                 }
599                 if (IfMouseTouchY(x,y,z)==true)
600                 {
601                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
602                 } else {
603                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
604                 }
605         }
606         Refresh();
607 }
608
609
610 //EED 5 juin 2009
611 //void wxVtkMPR2DView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
612 void wxVtkMPR2DView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
613 {
614
615         wxVtkBaseView::TransFromCoordScreenToWorld(X,Y,Z,keepNormalDirection,_direction);
616
617         if ((_direction==0) && (keepNormalDirection==true) )
618         {
619                 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
620         }
621
622         if ((_direction==1) && (keepNormalDirection==true) )
623         {
624                 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
625         }
626
627         if ((_direction==2) && (keepNormalDirection==true) )
628         {
629                 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
630         }
631
632 }
633
634 //-------------------------------------------------------------------
635 int wxVtkMPR2DView::GetDirection() // virtual
636 {
637     return _direction;
638 }
639
640
641 //-------------------------------------------------------------------
642 //-------------------------------------------------------------------
643 //-------------------------------------------------------------------
644 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
645 //      if (eventId==vtkCommand::StartInteractionEvent){
646 //              _renWin->SetDesiredUpdateRate(10);
647 //      }
648 //      if (eventId==vtkCommand::InteractionEvent){
649 //              _renWin->SetDesiredUpdateRate(0.001);
650 //      }
651 //      if (eventId==vtkCommand::EndInteractionEvent){
652 //              vtkPlanes *planes = vtkPlanes::New();
653 //              vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
654 //              boxwidget->GetPlanes(planes);
655 //              _volumeMapper->SetClippingPlanes(planes);
656 //              planes -> Delete();
657 //      }
658 //}
659
660 //-------------------------------------------------------------------
661 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
662 //      _renWin = renWin;
663 //}
664 //-------------------------------------------------------------------
665 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
666 //      _volumeMapper = volumeMapper;
667 //}