]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkMPR2DView.cxx
#3155 creaMaracasVisu Feature New Normal - ViewerPlane ComplexBox
[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                 double* origin = img->GetOrigin();
89                 img->GetExtent(x1,x2,y1,y2,z1,z2);
90                 img->GetSpacing(spc);
91                 x1 += origin[0];
92                 x2 += origin[0];
93                 y1 += origin[1];
94                 y2 += origin[1];
95                 z1 += origin[2];
96                 z2 += origin[2];
97                 x1 = (int)(x1*spc[0]);
98                 y1 = (int)(y1*spc[1]);
99                 z1 = (int)(z1*spc[2]);
100                 x2 = (int)(x2*spc[0]);
101                 y2 = (int)(y2*spc[1]);
102                 z2 = (int)(z2*spc[2]);
103                 _visibleAxis = true;
104         }
105
106         // Axe A
107         if(_lineAActor==NULL){
108                 _lineAActor = vtkActor::New();
109                 _lineAActor->GetProperty()->SetDiffuseColor(1,0,0);
110                 _lineAActor->GetProperty()->SetLineWidth(0.5);
111
112                 _ptsA = vtkPoints::New();
113                 _ptsA->SetNumberOfPoints(2);
114                 _ptsA->SetPoint(0, -1000        , -1000 , -1000 );
115                 _ptsA->SetPoint(1,  1000        ,  1000 ,  1000 );
116                 _pdA = vtkPolyData::New();
117                 _lineAMapper = vtkPolyDataMapper::New();
118                 _lineAMapper->SetInput(_pdA);
119                 _lineAMapper->ImmediateModeRenderingOn();
120                 _lineAActor->SetMapper(_lineAMapper);
121         }
122
123         vtkCellArray *linesA = vtkCellArray::New();
124         linesA->InsertNextCell(2);
125         linesA->InsertCellPoint(0);
126         linesA->InsertCellPoint(1);
127         _pdA->SetPoints( _ptsA );
128         _pdA->SetLines( linesA );
129         linesA->Delete();  //do not delete lines ??
130 //              _lineAActor->GetProperty()->BackfaceCullingOn();
131
132
133 // Axe B
134         if(_lineBActor==NULL)
135         {
136                 _lineBActor                                             =       vtkActor::New();
137                 _lineBActor->GetProperty()->SetDiffuseColor(1,0,0);
138                 _lineBActor->GetProperty()->SetLineWidth(0.5);
139                 _lineBMapper                                    =       vtkPolyDataMapper::New();
140                 _lineBActor->SetMapper(_lineBMapper);
141                 _ptsB = vtkPoints::New();
142                 _ptsB->SetNumberOfPoints(2);
143                 _ptsB->SetPoint(0, -1000        , -1000 , -1000 );
144                 _ptsB->SetPoint(1,  1000        ,  1000 ,  1000 );
145 //              _lineBActor->GetProperty()->BackfaceCullingOn();
146         }
147
148         vtkCellArray *linesB;
149         linesB = vtkCellArray::New();
150         linesB->InsertNextCell(2);
151         linesB->InsertCellPoint(0);
152         linesB->InsertCellPoint(1);
153         _pdB = vtkPolyData::New();
154         _pdB->SetPoints( _ptsB );
155         _pdB->SetLines( linesB );
156         linesB->Delete();  //do not delete lines ??
157         _lineBMapper->SetInput(_pdB);
158         _lineBMapper->ImmediateModeRenderingOn();
159         if(_imageViewer2XYZ)
160         {
161                 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
162                 _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
163                 vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
164
165         //EED 17Avril2009
166     //EED 21 mars 2012  FLIP problem  ..PLOP..
167
168                 if (_direction==0) 
169                 {  // YZ
170                         camera->SetViewUp               (   0   ,    0          ,     1         );
171                         camera->SetPosition             ( 10000,(y1+y2)/2       , (z1+z2)/2     );
172                         camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
173                         camera->SetParallelScale( (z2-z1)/3.0 );
174                 }
175                 if (_direction==1) 
176                 { // XZ
177                         camera->SetViewUp               (       0               ,       0       ,       1               );
178                         camera->SetPosition             ((x1+x2)/2      , -10000        , (z1+z2)/2     );
179                         camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
180                         camera->SetParallelScale( (x2-x1)/3.0 );
181                 }
182                 if (_direction==2) 
183                 {  // XY
184                         camera->SetViewUp               (       0               ,       -1              ,       0       );
185                         camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     , -10000);
186                         camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       );
187                         camera->SetParallelScale( (x2-x1)/3.0 );
188                 }
189
190 /*
191                 if (_direction==0) {    // YZ
192                         camera->SetViewUp               (   0   ,     1         ,     0         );
193                         camera->SetPosition             (  10000,(y1+y2)/2      , (z1+z2)/2     );
194                         camera->SetFocalPoint   (   0   , (y1+y2)/2     , (z1+z2)/2     );
195                         camera->SetParallelScale( (z2-z1)/3.0 );
196                 }
197
198                 if (_direction==1) {    // XZ
199                         camera->SetViewUp               (       0               ,       0       ,       -1              );
200                         camera->SetPosition             ((x1+x2)/2      , 10000 , (z1+z2)/2     );
201                         camera->SetFocalPoint   ((x1+x2)/2      ,   0   , (z1+z2)/2     );
202                         camera->SetParallelScale( (x2-x1)/3.0 );
203                 }
204
205                 if (_direction==2) {    // XY
206                         camera->SetViewUp               (       0               ,       1               ,       0       );
207                         camera->SetPosition             ((x1+x2)/2      , (y1+y2)/2     ,  10000);
208                         camera->SetFocalPoint   ((x1+x2)/2      , (y1+y2)/2     ,       0       );
209                         camera->SetParallelScale( (x2-x1)/3.0 );
210                 }
211 */
212
213         //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow (160);
214         //      _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel (800);
215         }
216 }
217
218 void wxVtkMPR2DView::SetVisibleAxis(bool ok)
219 {
220         if (ok!=_visibleAxis)
221         {
222                 _visibleAxis=ok;
223                 if (_visibleAxis==true)
224                 {
225                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineAActor );
226                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineBActor );
227                 }
228                 if (_visibleAxis==false)
229                 {
230                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineAActor );
231                         _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->RemoveActor( _lineBActor );
232                 } // if visible
233         } // ok
234 }
235
236 //-------------------------------------------------------------------
237 void wxVtkMPR2DView::Refresh()
238 {
239         //wxVtk2DBaseView::Refresh();
240         int x1 = 0,x2 = 0,y1 = 0,y2 = 0,z1 = 0,z2 = 0;
241 //EED 02/08/2013
242 //      int x = 0, y = 0, z = 0;
243         double  x  = 0, y  = 0, z  = 0;
244         int     xx = 0, yy = 0, zz = 0;
245         double *spc     = 0;
246         double *origin  = 0;
247         double xx1,yy1,zz1,xx2,yy2,zz2;
248         bool   fixAxis2D;
249         double opacityAxis;
250         vtkImageData* img = GetVtkmprbasedata()->GetImageData();
251         if(img!=NULL)
252         {
253                 origin = img->GetOrigin();
254                 img->GetExtent(x1,x2,y1,y2,z1,z2);
255                 spc = img->GetSpacing();
256                 x1 += origin[0];
257                 x2 += origin[0];
258                 y1 += origin[1];
259                 y2 += origin[1];
260                 z1 += origin[2];
261                 z2 += origin[2];
262                 xx1 =           x1*spc[0];
263                 yy1 =           y1*spc[1];
264                 zz1 =           z1*spc[2];
265                 xx2 =           x2*spc[0];
266                 yy2 =           y2*spc[1];
267                 zz2 =           z2*spc[2];
268                 x1      = (int)(x1*spc[0]);
269                 y1      = (int)(y1*spc[1]);
270                 z1      = (int)(z1*spc[2]);
271                 x2      = (int)(x2*spc[0]);
272                 y2      = (int)(y2*spc[1]);
273                 z2      = (int)(z2*spc[2]);
274                 xx      = (int)(GetVtkmprbasedata()->GetX());
275                 yy      = (int)(GetVtkmprbasedata()->GetY());
276                 zz      = (int)(GetVtkmprbasedata()->GetZ());
277 //EED 02/08/2013
278 //              x =  round(xx*spc[0]);
279 //              y =  round(yy*spc[1]);
280 //              z =  round(zz*spc[2]);
281                 x       =  xx*spc[0];
282                 y       =  yy*spc[1];
283                 z       =  zz*spc[2];
284                 fixAxis2D               = GetVtkmprbasedata()->GetFixAxis2D();
285                 opacityAxis             = GetVtkmprbasedata()->GetOpacityAxis();
286                 if ((xx!=_backX) || (yy!=_backY) || (zz!=_backZ)  || (fixAxis2D!=_backFixAxis2D) || (opacityAxis!=_backOpacityAxis)) 
287                 {
288                         double position[3];
289                         double focalpoint[3];
290                         GetRenderer()->GetActiveCamera()->GetPosition(position);
291                         GetRenderer()->GetActiveCamera()->GetFocalPoint(focalpoint);
292                         if (_direction==0) {    // YZ
293                                 if(_imageViewer2XYZ)
294                                 {
295                                         _imageViewer2XYZ->SetXSlice( (int)(GetVtkmprbasedata()->GetX()) );
296                                 }
297 //EED 21 mars 2012  FLIP probleme  ..PLOP..
298                                 //_ptsA->SetPoint(0, x2, y1  , z );
299                                 //_ptsA->SetPoint(1, x2, y2  , z );
300                                 //_ptsB->SetPoint(0, x2, y   , z1);
301                                 //_ptsB->SetPoint(1, x2, y   , z2);
302                                 _ptsA->SetPoint(0, xx2, yy1  , z  );
303                                 _ptsA->SetPoint(1, xx2, yy2  , z  );
304                                 _ptsB->SetPoint(0, xx2, y    , zz1);
305                                 _ptsB->SetPoint(1, xx2, y    , zz2);
306                                 position[1]             = y;    
307                                 position[2]             = z;    
308                                 focalpoint[1]   = y;    
309                                 focalpoint[2]   = z;    
310                         }
311                         if (_direction==1) {    // XZ
312                                 if(_imageViewer2XYZ)
313                                 {
314                                         _imageViewer2XYZ->SetYSlice( (int)(GetVtkmprbasedata()->GetY()) );
315                                 }
316 //EED 21 mars 2012  FLIP probleme  ..PLOP..
317                             //_ptsA->SetPoint(0, x1 , y2 , z );
318                                 //_ptsA->SetPoint(1, x2 , y2 , z );
319                                 //_ptsB->SetPoint(0, x  , y2 , z1);
320                                 //_ptsB->SetPoint(1, x  , y2 , z2);
321                             _ptsA->SetPoint(0, xx1 , y1 , z  );
322                                 _ptsA->SetPoint(1, xx2 , y1 , z  );
323                                 _ptsB->SetPoint(0, x   , y1 , zz1);
324                                 _ptsB->SetPoint(1, x   , y1 , zz2);
325                                 position[0]             = x;    
326                                 position[2]             = z;    
327                                 focalpoint[0]   = x;    
328                                 focalpoint[2]   = z;    
329                         }
330                         if (_direction==2) {    // XY
331                                 if(_imageViewer2XYZ)
332                                 {
333                                         _imageViewer2XYZ->SetZSlice( (int)(GetVtkmprbasedata()->GetZ()) );
334                                 }
335                         //      _ptsA->SetPoint(0, x1 , y , -z2 );
336                         //      _ptsA->SetPoint(1, x2 , y , -z2 );
337                         //      _ptsB->SetPoint(0, x  , y1, -z2 );
338                         //      _ptsB->SetPoint(1, x  , y2, -z2 );
339
340                                 
341 //EED 21 mars 2012  FLIP probleme  ..PLOP..
342                                 //_ptsA->SetPoint(0, x1 , y , z2 );
343                                 //_ptsA->SetPoint(1, x2 , y , z2 );
344                                 //_ptsB->SetPoint(0, x  , y1, z2 );
345                                 //_ptsB->SetPoint(1, x  , y2, z2 );
346                                 _ptsA->SetPoint(0, xx1 , y  , z1 );
347                                 _ptsA->SetPoint(1, xx2 , y  , z1 );
348                                 _ptsB->SetPoint(0, x   , yy1, z1 );
349                                 _ptsB->SetPoint(1, x   , yy2, z1 );
350                                 position[0]             = x;    
351                                 position[1]             = y;    
352                                 focalpoint[0]   = x;    
353                                 focalpoint[1]   = y;                                    
354                         } // if back
355                         if (fixAxis2D == true)
356                         {
357                                 GetRenderer()->GetActiveCamera()->SetPosition(position);
358                                 GetRenderer()->GetActiveCamera()->SetFocalPoint(focalpoint);
359                         } // if GetFixAxis2D
360                         _lineAActor->GetProperty()->SetOpacity( opacityAxis );
361                         _lineBActor->GetProperty()->SetOpacity( opacityAxis );
362                         _backX                  = xx;
363                         _backY                  = yy;
364                         _backZ                  = zz;
365                         _backFixAxis2D  = fixAxis2D;
366                         _backOpacityAxis= opacityAxis;
367                 } // if image
368
369 //EED 2016/02/19
370         vtkImageActor *imageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
371         imageactor->SetInterpolate( GetVtkBaseData()->GetInterpolate() );
372 //EED 01nov2012
373                 UpdateColorWindowLevel();
374                 wxVtkBaseView::Refresh();
375         }
376 }
377
378 //-------------------------------------------------------------------
379 int wxVtkMPR2DView::GetActualSlice()   // virtual
380 {
381         int result;
382         if (_direction==0)
383         {
384                 result = (int)(GetVtkmprbasedata()->GetX());
385         }
386         if (_direction==1)
387         {
388                 result = (int)(GetVtkmprbasedata()->GetY());
389         }
390         if (_direction==2)
391         {
392                 result = (int)(GetVtkmprbasedata()->GetZ());
393         }
394         return result;
395 }
396 //-------------------------------------------------------------------
397 void wxVtkMPR2DView::SetActualSlice(int slice)   // virtual
398 {
399         if (_direction==0)
400         {
401                 GetVtkmprbasedata()->SetX(slice);
402         }
403         if (_direction==1)
404         {
405                 GetVtkmprbasedata()->SetY(slice);
406         }
407         if (_direction==2)
408         {
409                 GetVtkmprbasedata()->SetZ(slice);
410         }
411 }
412 //-------------------------------------------------------------------
413 bool wxVtkMPR2DView::IfMouseTouchX(double x, double y, double z)
414 {
415         double delta=5;
416         bool result=false;
417         if (_direction==0)
418         {
419         }
420         if (_direction==1)
421         {
422                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
423                 {
424                         result = true;
425                 }
426         }
427         if (_direction==2)
428         {
429                 if (( x<GetVtkmprbasedata()->GetX()+delta ) && ( x>GetVtkmprbasedata()->GetX()-delta ))
430                 {
431                         result = true;
432                 }
433         }
434         return result;
435 }
436 //-------------------------------------------------------------------
437 bool wxVtkMPR2DView::IfMouseTouchY(double x, double y, double z)
438 {
439         double delta=5;
440         bool result=false;
441         if (_direction==0)
442         {
443                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
444                 {
445                         result = true;
446                 }
447         }
448         if (_direction==1)
449         {
450         }
451         if (_direction==2)
452         {
453                 if (( y<GetVtkmprbasedata()->GetY()+delta ) && ( y>GetVtkmprbasedata()->GetY()-delta ))
454                 {
455                         result = true;
456                 }
457         }
458         return result;
459 }
460 //-------------------------------------------------------------------
461 bool wxVtkMPR2DView::IfMouseTouchZ(double x, double y, double z)
462 {
463         double delta=5;
464         bool result=false;
465         if (_direction==0)
466         {
467                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
468                 {
469                         result = true;
470                 }
471         }
472         if (_direction==1)
473         {
474                 if (( z<GetVtkmprbasedata()->GetZ()+delta ) && ( z>GetVtkmprbasedata()->GetZ()-delta ))
475                 {
476                         result = true;
477                 }
478         }
479         if (_direction==2)
480         {
481         }
482         return result;
483 }
484 //-------------------------------------------------------------------
485 void wxVtkMPR2DView::MoveX(double x, double y, double z)
486 {
487         if (_direction==0)
488         {
489         }
490         if (_direction==1)
491         {
492                 GetVtkmprbasedata()->SetX(x);
493         }
494         if (_direction==2)
495         {
496                 GetVtkmprbasedata()->SetX(x);
497         }
498 }
499 //-------------------------------------------------------------------
500 void wxVtkMPR2DView::MoveY(double x, double y, double z)
501 {
502         if (_direction==0)
503         {
504                 GetVtkmprbasedata()->SetY(y);
505         }
506         if (_direction==1)
507         {
508         }
509         if (_direction==2)
510         {
511                 GetVtkmprbasedata()->SetY(y);
512         }
513 }
514 //-------------------------------------------------------------------
515 void wxVtkMPR2DView::MoveZ(double x, double y, double z)
516 {
517         if (_direction==0)
518         {
519                 GetVtkmprbasedata()->SetZ(z);
520         }
521         if (_direction==1)
522         {
523                 GetVtkmprbasedata()->SetZ(z);
524         }
525         if (_direction==2)
526         {
527         }
528 }
529 //-------------------------------------------------------------------
530 void wxVtkMPR2DView::ChangeAxisColor(double x, double y, double z)
531 {
532         double c1r=1,c1g=1,c1b=0;
533         double c2r=1,c2g=0,c2b=0;
534
535         if (_direction==0)
536         {
537                 if (IfMouseTouchY(x,y,z)==true)
538                 {
539                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
540                 } else {
541                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
542                 }
543                 if (IfMouseTouchZ(x,y,z)==true)
544                 {
545                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
546                 } else {
547                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
548                 }
549         }
550
551         if (_direction==1)
552         {
553                 if (IfMouseTouchX(x,y,z)==true)
554                 {
555                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
556                 } else {
557                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
558                 }
559                 if (IfMouseTouchZ(x,y,z)==true)
560                 {
561                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
562                 } else {
563                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
564                 }
565         }
566
567         if (_direction==2)
568         {
569                 if (IfMouseTouchX(x,y,z)==true)
570                 {
571                         _lineBActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
572                 } else {
573                         _lineBActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
574                 }
575                 if (IfMouseTouchY(x,y,z)==true)
576                 {
577                         _lineAActor->GetProperty()->SetDiffuseColor(c1r,c1g,c1b);
578                 } else {
579                         _lineAActor->GetProperty()->SetDiffuseColor(c2r,c2g,c2b);
580                 }
581         }
582         Refresh();
583 }
584
585
586 //EED 5 juin 2009
587 //void wxVtkMPR2DView::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type) // virtual
588 void wxVtkMPR2DView::TransFromCoordScreenToWorld(double &X, double &Y, double &Z, bool keepNormalDirection, int type) //virtual //keepNormalDirection=false, type=2
589 {
590
591         wxVtkBaseView::TransFromCoordScreenToWorld(X,Y,Z,keepNormalDirection,_direction);
592
593         if ((_direction==0) && (keepNormalDirection==true) )
594         {
595                 X = ((vtkMPRBaseData*)GetVtkBaseData())->GetX();
596         }
597
598         if ((_direction==1) && (keepNormalDirection==true) )
599         {
600                 Y = ((vtkMPRBaseData*)GetVtkBaseData())->GetY();
601         }
602
603         if ((_direction==2) && (keepNormalDirection==true) )
604         {
605                 Z = ((vtkMPRBaseData*)GetVtkBaseData())->GetZ();
606         }
607
608 }
609
610 //-------------------------------------------------------------------
611 int wxVtkMPR2DView::GetDirection() // virtual
612 {
613     return _direction;
614 }
615
616
617 //-------------------------------------------------------------------
618 //-------------------------------------------------------------------
619 //-------------------------------------------------------------------
620 //void boxVolumeObserver::Execute(vtkObject *wdg, unsigned long eventId, void* calldata) {  // virtual
621 //      if (eventId==vtkCommand::StartInteractionEvent){
622 //              _renWin->SetDesiredUpdateRate(10);
623 //      }
624 //      if (eventId==vtkCommand::InteractionEvent){
625 //              _renWin->SetDesiredUpdateRate(0.001);
626 //      }
627 //      if (eventId==vtkCommand::EndInteractionEvent){
628 //              vtkPlanes *planes = vtkPlanes::New();
629 //              vtkBoxWidget *boxwidget = reinterpret_cast<vtkBoxWidget*>(wdg);
630 //              boxwidget->GetPlanes(planes);
631 //              _volumeMapper->SetClippingPlanes(planes);
632 //              planes -> Delete();
633 //      }
634 //}
635
636 //-------------------------------------------------------------------
637 //void boxVolumeObserver::SetRenWin( vtkRenderWindow *renWin ){
638 //      _renWin = renWin;
639 //}
640 //-------------------------------------------------------------------
641 //void boxVolumeObserver::SetVolumeMapper(vtkVolumeRayCastMapper *volumeMapper){
642 //      _volumeMapper = volumeMapper;
643 //}