]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkPlane2DView.cxx
#3404 creaMaracasVisu Feature New Normal - vtk8itk5wx3-macos
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkPlane2DView.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 "vtkPlane2DView.h"
27
28 #include "vtkCellArray.h"
29
30 #include "vtkInteractorStyleBaseView2D.h"
31 #include "vtkPointData.h"
32
33
34 vtkPlane2DView::vtkPlane2DView( wxWindow *parent)
35 : wxVtk2DBaseView(parent)
36 {
37
38         _backX                                  =       -99999;
39         _backY                                  =       -99999;
40         _backZ                                  =       -99999;
41
42         _backOrient[0]                  =       -99999;
43         _backOrient[1]                  =       -99999;
44         _backOrient[2]                  =       -99999;
45         _backOrient[3]                  =       -99999;
46
47         _active                                 =   true;
48         _mip_visualization              =       true;
49         _mip_width                              =       2;
50
51     _transform1                         =       vtkTransform::New();
52     _transform2                         =       vtkTransform::New();
53         _transform1->Identity();
54         _transform2->Identity();
55
56         _sizeIma                                =       200;
57
58         _pSource                                =       NULL;
59         _3Dslices                               =       NULL;
60         _stPoints                               =       NULL;
61         _change                                 =       NULL;
62         _imageResult                    =       NULL;
63
64         // line horizontal
65     _pts                                        =       NULL;
66     _lineActor                          =       NULL;
67         _lineMapper                             =       NULL;
68         _pd                                             =       NULL;
69
70         _interactorstyleplane2D =       NULL;
71 }
72 //-------------------------------------------------------------------
73 vtkPlane2DView::~vtkPlane2DView()
74 {
75         ResetPlane();
76         // Horizontal Line
77     if (_pts            != NULL)        {       _pts                    -> Delete(); }
78     if (_lineActor      != NULL)        {       _lineActor              -> Delete(); }
79     if (_lineMapper     != NULL)        {       _lineMapper             -> Delete(); }
80     if (_pd                     != NULL)        {       _pd                             -> Delete(); }
81         _transform1             -> Delete();
82         _transform2             -> Delete();
83 }
84
85 //-------------------------------------------------------------------
86 void vtkPlane2DView::ResetBack()
87 {
88                 _backX=-1;
89                 _backY=-1;
90                 _backZ=-1;
91                 _backOrient[0]=-1;
92                 _backOrient[1]=-1;
93                 _backOrient[2]=-1;
94                 _backOrient[3]=-1;
95 }
96
97 //-------------------------------------------------------------------
98 void vtkPlane2DView::ResetPlane()
99 {
100         if (_pSource    !=NULL) { _pSource      -> Delete();    }
101         if (_3Dslices   !=NULL) { _3Dslices     -> Delete();    }
102         if (_stPoints   !=NULL) { _stPoints     -> Delete();    }
103         if (_change             !=NULL) { _change       -> Delete();    }
104 }
105
106 //-------------------------------------------------------------------
107 vtkMPRBaseData *vtkPlane2DView::GetVtkmprbasedata()
108 {
109         return (vtkMPRBaseData*)GetVtkBaseData();
110 }
111
112 //-------------------------------------------------------------------
113 void vtkPlane2DView::SetPSource(int sizeIma){
114         int dimIma      = sizeIma; 
115
116         double x = GetVtkmprbasedata()->GetX();
117         double y = GetVtkmprbasedata()->GetY();
118         double z = GetVtkmprbasedata()->GetZ();
119
120         double spc[3];
121         vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
122         imagedata->GetSpacing(spc);
123         x=x*spc[0];
124         y=y*spc[1];
125         z=z*spc[2];
126
127
128         vtkMPRBaseData  *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
129         vtkTransform    *transform       = mprbasedata->GetTransformOrientation();
130
131         double in[3];  // temp
132         double pA[3];
133         double pB[3];
134         in[0]=1;                in[1]=0;                        in[2]=0;
135         transform->TransformPoint(in,_n);
136
137         in[0]=0;        in[1]=dimIma-1;         in[2] = 0;
138         transform->TransformPoint(in,pA);
139
140         in[0]=0;        in[1]=0;                in[2]=dimIma-1;
141         transform->TransformPoint(in,pB);
142
143     _pSource -> SetPoint1( pA   );
144     _pSource -> SetPoint2( pB   );
145
146         _pSource -> SetOrigin( 0        , 0             , 0             );
147     _pSource -> SetResolution( sizeIma-1 , sizeIma -1 );
148         _pSource -> Update();
149         _pSource -> SetCenter( x, y, z );
150     _pSource -> SetNormal( _n );
151     _pSource -> Update( );
152
153 // EED Borrame
154 //      transform->Delete();
155
156 }
157
158 //-------------------------------------------------------------------
159 void vtkPlane2DView::ExtractPlane() 
160 {
161         double x = GetVtkmprbasedata()->GetX();
162         double y = GetVtkmprbasedata()->GetY();
163         double z = GetVtkmprbasedata()->GetZ();
164
165         double spc[3];
166         vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
167         imagedata->GetSpacing(spc);
168         x=x*spc[0];
169         y=y*spc[1];
170         z=z*spc[2];
171
172         vtkTransform *transform = GetVtkmprbasedata()->GetTransformOrientation();
173         double orientation[4];
174         transform->GetOrientationWXYZ(orientation);
175
176         bool okOrientation=true;
177         if ((orientation[0]!=_backOrient[0]) || (orientation[1]!=_backOrient[1]) ||
178                 (orientation[2]!=_backOrient[2]) || (orientation[3]!=_backOrient[3]))
179         {
180                 okOrientation=false;
181         }
182
183         bool okPosicion=true;
184         if ( (x!=_backX) || (y!=_backY) || (z!=_backZ) )
185         {
186                 okPosicion=false;
187         }
188
189         if ((okPosicion==false) || (okOrientation==false) ) {
190                 if (_active==true){
191
192                         bool ok = false;
193
194                         if ( _mip_visualization==true )
195                         {
196                                 if (_interactorstyleplane2D!=NULL)
197                                 {
198                                         if (_interactorstyleplane2D->GetStateRotate()==false )
199                                         {
200                                                 ok=true;
201                                         }
202                                 }
203                         }
204 //                      ok=true;
205
206                         if (ok==true)
207                         {
208                                 Extract_MIP_PlaneVTK();
209                         } else {
210                                 Extract_One_PlaneVTK();
211                         } // ok
212
213                 } // active
214                 _backX=x;
215                 _backY=y;
216                 _backZ=z;
217                 _backOrient[0]=orientation[0];
218                 _backOrient[1]=orientation[1];
219                 _backOrient[2]=orientation[2];
220                 _backOrient[3]=orientation[3];
221         } //okPosition okOrientation
222 }
223
224 //-------------------------------------------------------------------
225 void vtkPlane2DView::Extract_One_PlaneVTK()
226 {
227         vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
228         SetPSource(_sizeIma);
229
230 //EED 2017-01-01 Migration VTK7
231 #if VTK_MAJOR_VERSION <= 5
232         _3Dslices -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
233         _3Dslices -> SetSource( imagedata );
234 #else
235         _3Dslices -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
236         _3Dslices -> SetSourceData( imagedata );
237 #endif
238
239         _3Dslices -> Update( );
240         _stPoints -> GetPointData( )->SetScalars(  _3Dslices->GetOutput()->GetPointData()->GetScalars()  );
241         _stPoints -> SetDimensions( _sizeIma, _sizeIma, 1 );
242
243 //EED 2017-01-01 Migration VTK7
244 #if VTK_MAJOR_VERSION <= 5
245         _stPoints -> SetScalarType( imagedata->GetScalarType() );
246         _stPoints -> SetScalarTypeToShort();
247         _stPoints -> Update();
248 //      _change   -> SetInput( _stPoints );  
249 //      _change   -> Update();    //important
250         _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _stPoints );
251 #else
252 printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
253 printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
254 printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
255 printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
256 printf("EED Warning!  vtkPlane2DView::Extract_One_PlaneVTK     VTK 5->7   ???? SetScalarTypeToShort  \n");
257         vtkInformation* info=_stPoints->GetInformation();
258         vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_SHORT, 1);
259         _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _stPoints );
260
261 #endif
262
263
264 //      _imageViewer2XYZ->GetVtkImageViewer2()->SetInput ( _change->GetOutput() );
265         //      vtkImageActor *imageActor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor();
266 }
267
268 //-------------------------------------------------------------------
269 void vtkPlane2DView::Extract_MIP_PlaneVTK( /*double heightDefinition*/ )
270 {
271         int mipWidth;
272         double sp;
273         int sizeWidth = (_mip_width*2)+1 ;
274         int deltaPixel;
275         int iWidth,itmp,tmpSizeWith;
276         double spc[3];
277         vtkImageData *imagedata = GetVtkmprbasedata()->GetImageData();
278         SetPSource(_sizeIma);
279         imagedata->GetSpacing(spc);
280         bool heightDefinition=false;
281         if (_mip_width<3)
282         {
283                 heightDefinition=true;
284         }
285         if (heightDefinition==true)
286         {
287                 mipWidth        =       _mip_width;
288                 sp                      =       spc[0];
289                 deltaPixel      =       1;
290         } else {
291                 mipWidth        =       2;
292                 tmpSizeWith =   (mipWidth*2) + 1;
293                 sp                      =       (spc[0]*sizeWidth)/tmpSizeWith;
294                 sizeWidth       =       tmpSizeWith;
295                 deltaPixel      =       4;
296         }
297         std::vector< vtkProbeFilter* > slicesLST;
298         _pSource->Push( -mipWidth * sp );
299         _pSource->Update();
300         for ( iWidth=0 ; iWidth<sizeWidth ; iWidth++ )
301         {       
302                 vtkProbeFilter *slice = vtkProbeFilter::New();
303 //EED 2017-01-01 Migration VTK7
304 #if VTK_MAJOR_VERSION <= 5
305                 slice -> SetInput( ( vtkDataSet* )_pSource->GetOutput( ) );
306                 slice -> SetSource( imagedata );
307 #else
308                 slice -> SetInputData( ( vtkDataSet* )_pSource->GetOutput( ) );
309                 slice -> SetSourceData( imagedata );
310 #endif
311                 slice -> Update( );
312                 slicesLST.push_back( slice );
313                 _pSource->Push( sp );
314         }
315         if (_imageResult ==NULL)
316         {
317                 _imageResult = vtkImageData::New();
318                 _imageResult -> SetDimensions(_sizeIma,_sizeIma,1);
319                 _imageResult -> SetSpacing(1,1,1);
320                 _imageResult -> SetExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
321 //EED 2017-01-01 Migration VTK7
322 #if VTK_MAJOR_VERSION <= 5
323                 _imageResult -> SetScalarType( imagedata->GetScalarType() );
324                 _imageResult -> SetWholeExtent(0,_sizeIma-1,0,_sizeIma-1,0,0);
325                 _imageResult -> AllocateScalars();
326                 _imageResult -> Update();
327 #else
328                 _imageResult -> AllocateScalars(imagedata->GetScalarType(),1);
329 #endif
330
331         }
332         unsigned short *pTemp;
333         unsigned short *pResult;
334         pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); 
335         int iPixels , sizePixels = _sizeIma*_sizeIma;
336         for(iPixels=0 ; iPixels<sizePixels ; iPixels=iPixels+deltaPixel)
337         {
338                 pTemp = (unsigned short*)slicesLST[0]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
339                 pResult = (unsigned short*)_imageResult->GetScalarPointer( 0 , 0 , 0 ); 
340                 pResult[iPixels] = pTemp[iPixels];
341                 for (iWidth=1;iWidth<sizeWidth;iWidth++)
342                 {
343                         pTemp = (unsigned short*)slicesLST[iWidth]->GetOutput()->GetPointData()->GetScalars()->GetVoidPointer(0);
344
345                         if (pResult[iPixels]< pTemp[iPixels])
346                         {
347                                 pResult[iPixels] = pTemp[iPixels];
348                         }
349                 }
350                 if (deltaPixel!=1)
351                 {
352                         for (itmp=1;itmp<deltaPixel;itmp++)
353                         {
354                                 pResult[iPixels+itmp] = pResult[iPixels];
355                         }
356                 }
357         }
358         for (iWidth=0;iWidth<sizeWidth;iWidth++)
359         {       
360                 slicesLST[iWidth]->Delete();
361         }
362         _imageResult->Modified();
363 //EED 2017-01-01 Migration VTK7
364 #if VTK_MAJOR_VERSION <= 5
365         _imageViewer2XYZ->GetVtkImageViewer2()->SetInput( _imageResult );
366 #else
367         _imageViewer2XYZ->GetVtkImageViewer2()->SetInputData( _imageResult );
368 #endif
369 }
370
371 //-------------------------------------------------------------------
372 void vtkPlane2DView::Configure( )
373 {
374         wxVtk2DBaseView::Configure(false);
375
376         HorizontalLine();
377 // Borrame
378 //      CircleLine();
379
380         _pSource         = vtkPlaneSource::New( );
381     _3Dslices    = vtkProbeFilter::New( ) ;
382         _stPoints        = vtkStructuredPoints::New( );
383         _change          = vtkImageChangeInformation::New();
384
385         crea::wxVTKRenderWindowInteractor *iren         = GetWxVTKRenderWindowInteractor();
386         ExtractPlane();
387 //      SetActive(false);
388         _imageViewer2XYZ -> GetVtkImageViewer2()        -> SetupInteractor ( iren );
389
390         //////////////
391         //RaC 04-2010 Look for the description of new changes in vtkInteractorStyleBaseView2D constructor.
392         //
393         // Previous version
394         // SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
395         //
396         // Actual version
397         vtkInteractorStyleBaseView2D *style2D = vtkInteractorStyleBaseView2D::New();
398         manualInteractorWindowLevel *_manualinteractorwindowlevel= new manualInteractorWindowLevel();
399         style2D->SetInteractorWindowLevel( _manualinteractorwindowlevel );
400         vtkInteractorScrollZ *_vtkInteractorScrollZ = new vtkInteractorScrollZ();
401         style2D->SetInteractorScrollZ(_vtkInteractorScrollZ);
402         SetInteractorStyleImage( style2D );
403
404         // RaC
405         //////////////
406
407         _interactorstyleplane2D = new vtkInteractorStylePlane2D();
408         ((vtkInteractorStyleBaseView*)GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _interactorstyleplane2D );
409
410         vtkCamera *camera =_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->GetActiveCamera();
411         
412         camera->SetViewUp               (       0                       ,       1                               ,       0       );
413         camera->SetPosition             ((0+_sizeIma)/2 , (0+_sizeIma)/2        , 10000 ); 
414         
415         camera->SetFocalPoint   ((0+_sizeIma)/2 , (0+_sizeIma)/2        ,       0       ); 
416         camera->SetClippingRange(0.01, 100000);
417         camera->ComputeViewPlaneNormal();
418         camera->SetParallelScale( _sizeIma/3.0 );
419
420         // text information over the graphic window
421         _vtkInfoTextImage                                               = new vtkInfoTextImage();
422         _vtkInfoTextImageInteractorPlane2D              = new vtkInfoTextImageInteractorPlane2D();
423         _vtkInfoTextImage->SetWxVtk2DBaseView(this);
424         _vtkInfoTextImage->SetMarImageData(  GetVtkmprbasedata()->GetMarImageData() );
425         _vtkInfoTextImageInteractorPlane2D->SetModelVtkInfoTextImage(_vtkInfoTextImage);        
426         _vtkInfoTextImage->Configure();
427         ((vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView())->AddInteractorStyleMaracas(_vtkInfoTextImageInteractorPlane2D);
428 }
429
430 //-------------------------------------------------------------------
431 void vtkPlane2DView::HorizontalLine()
432 {
433 // Axe Horizontal
434         _pts = vtkPoints::New();
435         _pts->SetNumberOfPoints(2);
436         _pts->SetPoint(0, -1000 , -1000 , -1000 );
437         _pts->SetPoint(1,  1000 ,  1000 ,  1000 );
438         vtkCellArray *lines = vtkCellArray::New();
439         lines->InsertNextCell(2);
440         lines->InsertCellPoint(0);
441         lines->InsertCellPoint(1);
442         _pd = vtkPolyData::New();
443     _pd->SetPoints( _pts );
444     _pd->SetLines( lines );
445         lines->Delete();  //do not delete lines ??
446         _lineActor                                      =       vtkActor::New();
447     _lineMapper                                 =       vtkPolyDataMapper::New();
448 //EED 2017-01-01 Migration VTK7
449 #if VTK_MAJOR_VERSION <= 5
450         _lineMapper->SetInput(_pd);
451         _lineMapper->ImmediateModeRenderingOn();
452 #else
453         _lineMapper->SetInputData(_pd);
454 #endif
455         _lineActor->SetMapper(_lineMapper);
456         _lineActor->GetProperty()->BackfaceCullingOn();
457         _lineActor->GetProperty()->SetDiffuseColor(0,0,1);
458         _lineActor->GetProperty()->SetLineWidth(2);
459         _lineActor->GetProperty()->SetOpacity(0);
460     _imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineActor );
461 }
462
463 //-------------------------------------------------------------------
464 void vtkPlane2DView::RotationStart()
465 {
466         vtkMPRBaseData  *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
467         vtkTransform    *transform       = mprbasedata->GetTransformOrientation();
468         _transform1->SetMatrix( transform->GetMatrix() );
469 }
470
471 //-------------------------------------------------------------------
472 void vtkPlane2DView::RotationDrag(double vx, double vy, bool ok_v, bool ok_ang)
473
474         if (ok_ang==false)
475         {
476                 _ang =sqrt( vx*vx + vy*vy ) / 1.5;
477         }
478
479         if (ok_v==false){
480                 _vxb=-vy;
481                 _vyb=vx;
482         }
483         _transform2->Identity();
484         _transform2->RotateWXYZ(_ang,0,_vxb,_vyb);
485
486         vtkMPRBaseData  *mprbasedata = (vtkMPRBaseData*)this->GetVtkBaseData();
487         vtkTransform *transform          =      vtkTransform::New();
488         transform->Identity();
489         transform->Concatenate(_transform1);
490         transform->Concatenate(_transform2);
491         mprbasedata->InitTransformOrientation(transform);
492         transform->Delete();
493
494         // Refresh Horizontal Line
495         _pts->SetPoint( 0 , (_sizeIma/2) - _vxb*2       , (_sizeIma/2) - _vyb*2 , 1 );
496         _pts->SetPoint( 1 , (_sizeIma/2) + _vxb*2       , (_sizeIma/2) + _vyb*2 , 1 );
497 //      RefreshCircleLine();
498 }
499
500 //-------------------------------------------------------------------
501 void vtkPlane2DView::Refresh(  )
502 {
503         ExtractPlane();
504         UpdateColorWindowLevel();
505         wxVtkBaseView::Refresh();
506 }
507 //-------------------------------------------------------------------
508 void vtkPlane2DView::SetImgSize( int imgSize )
509 {
510         _sizeIma = imgSize;
511 }
512 //-------------------------------------------------------------------
513 int vtkPlane2DView::GetImgSize()
514 {
515         return _sizeIma;
516 }
517 //-------------------------------------------------------------------
518 int     vtkPlane2DView::GetActualSlice()  // virtual 
519 {
520         _cx = GetVtkmprbasedata()->GetX();
521         _cy = GetVtkmprbasedata()->GetY();
522         _cz = GetVtkmprbasedata()->GetZ();
523         return 0;
524 }
525
526 //-------------------------------------------------------------------
527
528 bool vtkPlane2DView::GetMipVisualization()
529 {
530         return _mip_visualization;
531 }
532
533 //-------------------------------------------------------------------
534 int vtkPlane2DView::GetMipWidth()
535 {
536         return _mip_width;
537 }
538
539 //-------------------------------------------------------------------
540 void vtkPlane2DView::SetActualSlice(int slice)  // Virtual
541 {
542         double dir=(double)slice/3.0;
543         GetVtkmprbasedata()->SetX( _cx + (_n[0]*dir) );
544         GetVtkmprbasedata()->SetY( _cy + (_n[1]*dir) );
545         GetVtkmprbasedata()->SetZ( _cz + (_n[2]*dir) );
546 }
547 //---------------------------------------------------------------------------
548 vtkInteractorStylePlane2D       *vtkPlane2DView::GetInteractorstyleplane2D()
549 {
550         return this->_interactorstyleplane2D;
551 }
552 //---------------------------------------------------------------------------
553 void vtkPlane2DView::SetActive(bool active)
554 {
555         _active = active;
556 }
557
558 //---------------------------------------------------------------------------
559
560 void vtkPlane2DView::SetMipVisualization(bool ok)
561 {
562         _mip_visualization=ok;
563 }
564
565 //---------------------------------------------------------------------------
566
567 void vtkPlane2DView::SetMipWidth(int value)
568 {
569         _mip_width=value;
570 }
571
572 //---------------------------------------------------------------------------
573 void vtkPlane2DView::SetVisibleLine(bool ok)
574 {
575         double opacity;
576         if (ok==true)
577         {
578                 opacity=1;
579         } else {
580                 opacity=0;
581         }
582         _lineActor->GetProperty()->SetOpacity(opacity);
583 }
584
585 // ----------------------------------------------------------------------------
586 void vtkPlane2DView::TransfromCoordViewWorld2(double &X, double &Y, double &Z)
587 {
588         double spc[3];
589         GetVtkmprbasedata()->GetImageData()->GetSpacing(spc);
590         double xx = X;
591         double yy = Y;
592         double zz = 0;
593         TransFromCoordScreenToWorld(xx,yy,zz);
594         vtkTransform *transf1 = vtkTransform::New();
595         transf1->Identity();
596         vtkTransform *transf2 = GetVtkmprbasedata()->GetTransformOrientation();
597         transf1->Concatenate(transf2->GetMatrix());
598         double in[4], out[4];
599         double center = GetImgSize() / 2;
600         in[0] = 0;
601         in[1] = xx - center;
602         in[2] = yy - center;
603         in[3] = 0;
604         transf1->MultiplyPoint(in,out);
605         transf1->Delete();
606         X = out[0] + GetVtkmprbasedata()->GetX() ;
607         Y = out[1] + GetVtkmprbasedata()->GetY() ;
608         Z = out[2] + GetVtkmprbasedata()->GetZ() ;
609 }
610