]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/QT/MPRInteractionCommand.cxx
b65266fbf5280f794c398ce53c5d3bb738ab4273
[cpPlugins.git] / lib / cpExtensions / QT / MPRInteractionCommand.cxx
1 #include <cpExtensions/QT/MPRInteractionCommand.h>
2
3 #ifdef cpExtensions_QT4
4
5 #include <cpExtensions/Interaction/ImageSliceStyle.h>
6 #include <cpExtensions/Visualization/ImageViewerActors.h>
7 #include <cpExtensions/QT/ImageWidget.h>
8 #include <cpExtensions/QT/MPR3DWidget.h>
9 #include <vtkImageData.h>
10
11 // -------------------------------------------------------------------------
12 cpExtensions::QT::MPRInteractionCommand::
13 Self* cpExtensions::QT::MPRInteractionCommand::
14 New( )
15 {
16   return( new Self( ) );
17 }
18
19 // -------------------------------------------------------------------------
20 void cpExtensions::QT::MPRInteractionCommand::
21 AddWidget( QWidget* w )
22 {
23   /*
24     typedef cpExtensions::QT::ImageWidget _TImageWidget;
25     typedef cpExtensions::QT::MPR3DWidget _TMPR3DWidget;
26
27     auto img = dynamic_cast< _TImageWidget* >( w );
28     auto ren = dynamic_cast< _TMPR3DWidget* >( w );
29     if( img != NULL )
30     this->m_ImageWidgets.insert( img );
31     else if( ren != NULL )
32     this->m_MPR3DWidgets.insert( ren );
33   */
34 }
35
36 // -------------------------------------------------------------------------
37 void cpExtensions::QT::MPRInteractionCommand::
38 Execute( vtkObject* caller, unsigned long evId, void* data )
39 {
40   /*
41   typedef cpExtensions::Interaction::ImageSliceStyle _TStyle;
42
43   static const unsigned long _SuperCursor = vtkCommand::UserEvent + 1;
44   static const unsigned long _Slice = vtkCommand::UserEvent + 2;
45
46   // Prepare interaction data
47   auto* src = dynamic_cast< _TStyle* >( caller );
48   if( src == NULL || ( evId != _SuperCursor && evId != _Slice ) )
49     return;
50   if( evId == _SuperCursor )
51   {
52     auto ori = src->GetActors( )->GetOrientation( );
53     auto img = src->GetActors( )->GetImage( );
54     auto pos = reinterpret_cast< double* >( data );
55     int ijk[ 3 ];
56     double pcoords[ 3 ];
57     img->ComputeStructuredCoordinates( pos, ijk, pcoords );
58
59     for(
60       auto i = this->m_ImageWidgets.begin( );
61       i != this->m_ImageWidgets.end( );
62       ++i
63       )
64       if( ( *i )->GetInteractorStyle( ) != src )
65         ( *i )->SetSliceNumber( ijk[ ( *i )->GetOrientation( ) ] );
66     
67     for(
68       auto r = this->m_MPR3DWidgets.begin( );
69       r != this->m_MPR3DWidgets.end( );
70       ++r
71       )
72       ( *r )->SetSlicesNumbers( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ] );
73   }
74   else if( evId == _Slice )
75   {
76     auto slice = *( reinterpret_cast< int* >( data ) );
77     auto ori = src->GetActors( )->GetOrientation( );
78     for(
79       auto r = this->m_MPR3DWidgets.begin( );
80       r != this->m_MPR3DWidgets.end( );
81       ++r
82       )
83       ( *r )->SetSliceNumber( ori, slice );
84     
85   } // fi
86   */
87 }
88       
89 // -------------------------------------------------------------------------
90 cpExtensions::QT::MPRInteractionCommand::
91 MPRInteractionCommand( )
92   : Superclass( )
93 {
94 }
95
96 // -------------------------------------------------------------------------
97 cpExtensions::QT::MPRInteractionCommand::
98 ~MPRInteractionCommand( )
99 {
100 }
101
102 #endif // cpExtensions_QT4
103
104 // eof - $RCSfile$