]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx
#3470 merge vtk8itk5wx3-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                 _lineAMapper->ImmediateModeRenderingOn();
124 #else
125                 _lineAMapper->SetInputData(_pdA);
126 #endif
127
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         _lineBMapper->ImmediateModeRenderingOn();
170 #else
171         _lineBMapper->SetInputData(_pdB);
172 #endif
173
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 //-------------------------------------------------------------------
253 void wxVtkMPR2DView::ResetBackXYZ()
254 {
255         _backX = -9999;
256         _backY = -9999;
257         _backZ = -9999;
258 }
259
260
261 //-------------------------------------------------------------------
262 void wxVtkMPR2DView::Refresh()
263 {
264         //wxVtk2DBaseView::Refresh();
265         int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0;
266 //EED 02/08/2013
267 //      int x = 0, y = 0, z = 0;
268         double  x  = 0, y  = 0, z  = 0;
269         int     xx = 0, yy = 0, zz = 0;
270         double *spc     = 0;
271         double *origin  = 0;
272         double xx1,yy1,zz1,xx2,yy2,zz2;
273         bool   fixAxis2D;
274         double opacityAxis;
275         vtkImageData* img = GetVtkmprbasedata()->GetImageData();
276         if(img!=NULL)
277         {
278                 origin = img->GetOrigin();
279                 img->GetExtent(x1,x2,y1,y2,z1,z2);
280                 spc = img->GetSpacing();
281                 x1 += origin[0];
282                 x2 += origin[0];
283                 y1 += origin[1];
284                 y2 += origin[1];
285                 z1 += origin[2];
286                 z2 += origin[2];
287                 xx1 = x1*spc[0];
288                 yy1 = y1*spc[1];
289                 zz1 = z1*spc[2];
290                 xx2 = x2*spc[0];
291                 yy2 = y2*spc[1];
292                 zz2 = z2*spc[2];
293                 x1      = (int)(x1*spc[0]);
294                 y1      = (int)(y1*spc[1]);
295                 z1      = (int)(z1*spc[2]);
296                 x2      = (int)(x2*spc[0]);
297                 y2      = (int)(y2*spc[1]);
298                 z2      = (int)(z2*spc[2]);
299                 xx      = (int)(GetVtkmprbasedata()->GetX());
300                 yy      = (int)(GetVtkmprbasedata()->GetY());
301                 zz      = (int)(GetVtkmprbasedata()->GetZ());
302                 x       =  xx*spc[0];
303                 y       =  yy*spc[1];
304                 z       =  zz*spc[2];
305                 fixAxis2D               = GetVtkmprbasedata()->GetFixAxis2D();
306                 opacityAxis             = GetVtkmprbasedata()->GetOpacityAxis();
307                 if ((xx!=_backX) || (yy!=_backY) || (zz!=_backZ)  || (fixAxis2D!=_backFixAxis2D) || (opacityAxis!=_backOpacityAxis)) 
308                 {
309                         double position[3];
310                         double focalpoint[3];
311                         GetRenderer()->GetActiveCamera()->GetPosition(position);
312                         GetRenderer()->GetActiveCamera()->GetFocalPoint(focalpoint);
313                         if (_direction==0) {    // YZ
314                                 if(_imageViewer2XYZ)
315                                 {
316                                         _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
317                                 }
318 //EED 21 mars 2012  FLIP probleme  ..PLOP..
319                                 //_ptsA->SetPoint(0, x2, y1  , z );
320                                 //_ptsA->SetPoint(1, x2, y2  , z );
321                                 //_ptsB->SetPoint(0, x2, y   , z1);
322                                 //_ptsB->SetPoint(1, x2, y   , z2);
323                                 _ptsA->SetPoint(0, xx2+1, yy1  , z  );
324                                 _ptsA->SetPoint(1, xx2+1, yy2  , z  );
325                                 _ptsB->SetPoint(0, xx2+1, y    , zz1);
326                                 _ptsB->SetPoint(1, xx2+1, y    , zz2);
327                                 position[1]             = y;    
328                                 position[2]             = z;    
329                                 focalpoint[1]   = y;    
330                                 focalpoint[2]   = z;    
331                         }
332                         if (_direction==1) {    // XZ
333                                 if(_imageViewer2XYZ)
334                                 {
335                                         _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
336                                 }
337 //EED 21 mars 2012  FLIP probleme  ..PLOP..
338                             //_ptsA->SetPoint(0, x1 , y2 , z );
339                                 //_ptsA->SetPoint(1, x2 , y2 , z );
340                                 //_ptsB->SetPoint(0, x  , y2 , z1);
341                                 //_ptsB->SetPoint(1, x  , y2 , z2);
342                             _ptsA->SetPoint(0, xx1 , y1-1 , z  );
343                                 _ptsA->SetPoint(1, xx2 , y1-1 , z  );
344                                 _ptsB->SetPoint(0, x   , y1-1 , zz1);
345                                 _ptsB->SetPoint(1, x   , y1-1 , zz2);
346                                 position[0]             = x;    
347                                 position[2]             = z;    
348                                 focalpoint[0]   = x;    
349                                 focalpoint[2]   = z;    
350                         }
351                         if (_direction==2) {    // XY
352                                 if(_imageViewer2XYZ)
353                                 {
354                                         _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
355                                 }
356                         //      _ptsA->SetPoint(0, x1 , y , -z2 );
357                         //      _ptsA->SetPoint(1, x2 , y , -z2 );
358                         //      _ptsB->SetPoint(0, x  , y1, -z2 );
359                         //      _ptsB->SetPoint(1, x  , y2, -z2 );
360
361                                 
362 //EED 21 mars 2012  FLIP probleme  ..PLOP..
363                                 //_ptsA->SetPoint(0, x1 , y , z2 );
364                                 //_ptsA->SetPoint(1, x2 , y , z2 );
365                                 //_ptsB->SetPoint(0, x  , y1, z2 );
366                                 //_ptsB->SetPoint(1, x  , y2, z2 );
367
368                                 _ptsA->SetPoint(0, xx1 , y  , z1-1 );
369                                 _ptsA->SetPoint(1, xx2 , y  , z1-1 );
370                                 _ptsB->SetPoint(0, x   , yy1, z1-1 );
371                                 _ptsB->SetPoint(1, x   , yy2, z1-1 );
372                                 
373                                 position[0]             = x;    
374                                 position[1]             = y;    
375                                 focalpoint[0]   = x;    
376                                 focalpoint[1]   = y;                                    
377                         } // if back
378                         
379 //EED 2017-01-01 Migration VTK7
380 #if VTK_MAJOR_VERSION <= 5
381                                 // ..
382 #else
383                                 _ptsA->Modified();
384                                 _ptsB->Modified();
385 #endif
386
387                         if (fixAxis2D == true)
388                         {
389                                 GetRenderer()->GetActiveCamera()->SetPosition(position);
390                                 GetRenderer()->GetActiveCamera()->SetFocalPoint(focalpoint);
391                         } // if GetFixAxis2D
392                         _lineAActor->GetProperty()->SetOpacity( opacityAxis );
393                         _lineBActor->GetProperty()->SetOpacity( opacityAxis );
394                         SetOpacityText( opacityAxis );
395                         _backX                  = xx;
396                         _backY                  = yy;
397                         _backZ                  = zz;
398                         _backFixAxis2D  = fixAxis2D;
399                         _backOpacityAxis= opacityAxis;
400                 } // if image
401
402 //EED 2016/02/19
403         vtkImageActor *imageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
404         imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() );
405 //EED 01nov2012
406                 UpdateColorWindowLevel();
407 //EED 05juin2019
408                 UpdateCameraParallelScale();
409                 wxVtkBaseView::Refresh();
410         }
411 }
412
413 //-------------------------------------------------------------------
414 int wxVtkMPR2DView::GetActualSlice()   // virtual
415 {
416         int result;
417         if (_direction==0)
418         {
419                 result = (int)(GetVtkmprbasedata()->GetX());
420         }
421         if (_direction==1)
422         {
423                 result = (int)(GetVtkmprbasedata()->GetY());
424         }
425         if (_direction==2)
426         {
427                 result = (int)(GetVtkmprbasedata()->GetZ());
428         }
429         return result;
430 }
431 //-------------------------------------------------------------------
432 void wxVtkMPR2DView::SetActualSlice(int slice)   // virtual
433 {
434         if (_direction==0)
435         {
436                 GetVtkmprbasedata()->SetX(slice);
437         }
438         if (_direction==1)
439         {
440                 GetVtkmprbasedata()->SetY(slice);
441         }
442         if (_direction==2)
443         {
444                 GetVtkmprbasedata()->SetZ(slice);
445         }
446 }
447 //-------------------------------------------------------------------
448 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
449 {
450         double delta=5;
451         bool result=false;
452         if (_direction==0)
453         {
454         }
455         if (_direction==1)
456         {
457                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
458                 {
459                         result = true;
460                 }
461         }
462         if (_direction==2)
463         {
464                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
465                 {
466                         result = true;
467                 }
468         }
469         return result;
470 }
471 //-------------------------------------------------------------------
472 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
473 {
474         double delta=5;
475         bool result=false;
476         if (_direction==0)
477         {
478                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
479                 {
480                         result = true;
481                 }
482         }
483         if (_direction==1)
484         {
485         }
486         if (_direction==2)
487         {
488                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
489                 {
490                         result = true;
491                 }
492         }
493         return result;
494 }
495 //-------------------------------------------------------------------
496 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
497 {
498         double delta=5;
499         bool result=false;
500         if (_direction==0)
501         {
502                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
503                 {
504                         result = true;
505                 }
506         }
507         if (_direction==1)
508         {
509                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
510                 {
511                         result = true;
512                 }
513         }
514         if (_direction==2)
515         {
516         }
517         return result;
518 }
519 //-------------------------------------------------------------------
520 void wxVtkMPR2DView::MoveX(double x, double y, double z)
521 {
522         if (_direction==0)
523         {
524         }
525         if (_direction==1)
526         {
527                 GetVtkmprbasedata()->SetX(x);
528         }
529         if (_direction==2)
530         {
531                 GetVtkmprbasedata()->SetX(x);
532         }
533 }
534 //-------------------------------------------------------------------
535 void wxVtkMPR2DView::MoveY(double x, double y, double z)
536 {
537         if (_direction==0)
538         {
539                 GetVtkmprbasedata()->SetY(y);
540         }
541         if (_direction==1)
542         {
543         }
544         if (_direction==2)
545         {
546                 GetVtkmprbasedata()->SetY(y);
547         }
548 }
549 //-------------------------------------------------------------------
550 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
551 {
552         if (_direction==0)
553         {
554                 GetVtkmprbasedata()->SetZ(z);
555         }
556         if (_direction==1)
557         {
558                 GetVtkmprbasedata()->SetZ(z);
559         }
560         if (_direction==2)
561         {
562         }
563 }
564 //-------------------------------------------------------------------
565 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
566 {
567         double c1r=1,c1g=1,c1b=0;
568         double c2r=1,c2g=0,c2b=0;
569
570         if (_direction==0)
571         {
572                 if (IfMouseTouchY(x,y,z)==true)
573                 {
574                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
575                 } else {
576                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
577                 }
578                 if (IfMouseTouchZ(x,y,z)==true)
579                 {
580                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
581                 } else {
582                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
583                 }
584         }
585
586         if (_direction==1)
587         {
588                 if (IfMouseTouchX(x,y,z)==true)
589                 {
590                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
591                 } else {
592                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
593                 }
594                 if (IfMouseTouchZ(x,y,z)==true)
595                 {
596                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
597                 } else {
598                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
599                 }
600         }
601
602         if (_direction==2)
603         {
604                 if (IfMouseTouchX(x,y,z)==true)
605                 {
606                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
607                 } else {
608                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
609                 }
610                 if (IfMouseTouchY(x,y,z)==true)
611                 {
612                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
613                 } else {
614                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
615                 }
616         }
617         Refresh();
618 }
619
620
621 //EED 5 juin 2009
622 //void wxVtkMPR2DView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
623 void wxVtkMPR2DView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
624 {
625
626         wxVtkBaseView::TransFromCoordScreenToWorld(X,Y,Z,keepNormalDirection,_direction);
627
628         if ((_direction==0) && (keepNormalDirection==true) )
629         {
630                 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
631         }
632
633         if ((_direction==1) && (keepNormalDirection==true) )
634         {
635                 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
636         }
637
638         if ((_direction==2) && (keepNormalDirection==true) )
639         {
640                 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
641         }
642
643 }
644
645 //-------------------------------------------------------------------
646 int wxVtkMPR2DView::GetDirection() // virtual
647 {
648     return _direction;
649 }
650
651
652 //-------------------------------------------------------------------
653 //-------------------------------------------------------------------
654 //-------------------------------------------------------------------
655 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
656 //      if (eventId==vtkCommand::StartInteractionEvent){
657 //              _renWin->SetDesiredUpdateRate(10);
658 //      }
659 //      if (eventId==vtkCommand::InteractionEvent){
660 //              _renWin->SetDesiredUpdateRate(0.001);
661 //      }
662 //      if (eventId==vtkCommand::EndInteractionEvent){
663 //              vtkPlanes *planes = vtkPlanes::New();
664 //              vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
665 //              boxwidget->GetPlanes(planes);
666 //              _volumeMapper->SetClippingPlanes(planes);
667 //              planes -> Delete();
668 //      }
669 //}
670
671 //-------------------------------------------------------------------
672 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
673 //      _renWin = renWin;
674 //}
675 //-------------------------------------------------------------------
676 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
677 //      _volumeMapper = volumeMapper;
678 //}