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