]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.cxx
functionalities of RC and MIP working in paralell
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxVtkClipping3DView.cxx
1 #include "wxVtkClipping3DView.h"
2
3 #include "wxVtkClipping3DViewCntrlPanel.h"
4 #include "wxVtkClipping3DViewVolCntrlPanel.h"
5
6 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
7 {
8         _wxvtk3Dbaseview                                =       wxvtk3Dbaseview;
9         _vtkclipping3Ddataviewer                =       NULL;
10         _wxvtkclipping3DviewCntrlPanel  =       NULL;
11
12         _boxWidgetVolume                                =       NULL;
13         _boxWidgetS1                                    =       NULL;
14 }
15
16 //-------------------------------------------------------------------
17 wxVtkClipping3DView::~wxVtkClipping3DView(){
18         if (_boxWidgetVolume!=NULL)                              { _boxWidgetVolume     -> Delete();                                    }
19         if (_boxWidgetS1!=NULL)                                  { _boxWidgetS1         -> Delete();                                    }
20         if (_vtkclipping3Ddataviewer!=NULL)              { delete _vtkclipping3Ddataviewer;                     }
21         if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel;       }
22 }
23 //-------------------------------------------------------------------
24 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
25 {
26         if (visible==true){
27                 _boxWidgetS1->On();
28         } else {
29                 _boxWidgetS1->Off();
30         }
31 }
32 //-------------------------------------------------------------------
33 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
34 {
35         if (_boxWidgetVolume!=NULL){
36                 if (visible==true){
37                         _boxWidgetVolume->On();
38                 } else {
39                         _boxWidgetVolume->Off();
40                 }
41         }
42 }
43 //-------------------------------------------------------------------
44 void wxVtkClipping3DView::Refresh()
45 {
46         _vtkclipping3Ddataviewer->Refresh();
47         if (_wxvtkclipping3DviewCntrlPanel!=NULL)
48         {
49                 _wxvtkclipping3DviewCntrlPanel->Refresh();
50         }
51 }
52 //-------------------------------------------------------------------
53 wxPanel* wxVtkClipping3DView::CreateSurfControlPanel(wxWindow *parent)
54 {
55         _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
56         return _wxvtkclipping3DviewCntrlPanel;
57 }
58
59 //RaC 03-2010 Divide in two panels
60 //-------------------------------------------------------------------
61 wxPanel* wxVtkClipping3DView::CreateVolControlPanel(wxWindow *parent)
62 {
63         _wxvtkclipping3DviewVolCntrlPanel = new wxVtkClipping3DViewVolCntrlPanel(parent,this);
64         return _wxvtkclipping3DviewVolCntrlPanel;
65 }
66
67
68 //-------------------------------------------------------------------
69 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
70 {
71         return _vtkclipping3Ddataviewer;
72 }
73 //-------------------------------------------------------------------
74 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
75         if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
76                 if (visTissue==false){
77                         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue)  );
78                 } else {
79                         _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue)  );
80 //                      _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
81 //                      _actor->VisibilityOn();
82                 }
83                 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
84         }
85 }
86 //-------------------------------------------------------------------
87 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
88 {
89         vtkActor *tmpActor;
90         tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
91
92         if (representationType==false){
93                 tmpActor->GetProperty()->SetRepresentationToWireframe();
94         } else {
95                 tmpActor->GetProperty()->SetRepresentationToSurface();
96         }
97
98         _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
99 }
100
101 //-------------------------------------------------------------------
102 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
103         if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
104                 if (visVolume==false){
105 //EED 31/03/2008
106 //                      _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor()  );
107                         _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor()  );
108                 } else {
109 //EED 31/03/2008
110 //                      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
111                         _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
112                 }
113                 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
114         }
115 }
116 //-------------------------------------------------------------------
117 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
118 {
119         if(_wxvtk3Dbaseview==NULL){
120                 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
121         }
122         return _wxvtk3Dbaseview;
123 }
124 //-------------------------------------------------------------------
125 void wxVtkClipping3DView::Configure(){
126         _wxvtk3Dbaseview->Configure();
127
128         // Actors are added to the renderer.
129         _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
130
131         _boxWidgetS1 = vtkBoxWidget::New();
132         _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
133         _boxWidgetS1->SetPlaceFactor(1.25);
134
135
136
137         vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
138         vtkPolyData *polydata= stripper->GetOutput();
139
140
141         _boxWidgetS1->SetInput( polydata );
142         _boxWidgetS1->PlaceWidget();
143
144         int i;
145         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
146         {
147                 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent          , _vtkclipping3Ddataviewer->GetObserverS(i) );
148         }
149
150
151
152
153 //      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
154 //      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
155
156         VisibleActor(0, false );
157         VisibleActor(1, false );
158         VisibleActor(2, false );
159         VisibleActor(3, false );
160
161         _boxWidgetS1->HandlesOn ();
162
163 //EED 29Mars2009
164 //      _boxWidgetS1->On();
165
166         _boxWidgetS1->Off();
167
168         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
169         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
170         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
171         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
172
173 // EED 9 fev 2007
174 // box Volume
175         _boxWidgetVolume = vtkBoxWidget::New();
176         _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
177         _boxWidgetVolume->SetPlaceFactor(1.25);
178
179         _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
180         _boxWidgetVolume->PlaceWidget();
181
182         _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent              , _vtkclipping3Ddataviewer->GetObserverV() );
183
184         _boxWidgetVolume->HandlesOn ();
185
186 //EED 29Mars2009
187 //      _boxWidgetVolume->On();
188
189         _boxWidgetVolume->Off();
190
191
192 //      vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
193 //      _boxWidgetVolume->GetPlanes( vtkplanes );
194
195
196   // An initial camera view is created.  The Dolly() method moves
197   // the camera towards the FocalPoint, thereby enlarging the image.
198   _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
199   _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
200   _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
201
202   // Set a background color for the renderer and set the size of the
203   // render window (expressed in pixels).
204   _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
205   _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
206
207   // Note that when camera movement occurs (as it does in the Dolly()
208   // method), the clipping planes often need adjusting. Clipping planes
209   // consist of two planes: near and far along the view direction. The
210   // near plane clips out objects in front of the plane; the far plane
211   // clips out objects behind the plane. This way only what is drawn
212   // between the planes is actually rendered.
213   _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
214 }
215 //-------------------------------------------------------------------
216 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
217 {
218         _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
219 }
220
221 void wxVtkClipping3DView::SetRayCasting(bool active)
222 {
223     _vtkclipping3Ddataviewer->SetRayCasting(active);
224     _vtkclipping3Ddataviewer->Configure();
225 }
226
227 void wxVtkClipping3DView::SetMIPActive(bool active)
228 {
229     _vtkclipping3Ddataviewer->SetMIPActive(active);
230     _vtkclipping3Ddataviewer->Configure();
231 }
232
233 void wxVtkClipping3DView::SetInterpolation(bool active)
234 {
235     _vtkclipping3Ddataviewer->SetInterpolation(active);
236     _vtkclipping3Ddataviewer->Configure();
237 }
238
239 void wxVtkClipping3DView::SetShade(bool active)
240 {
241     _vtkclipping3Ddataviewer->SetShade(active);
242     _vtkclipping3Ddataviewer->Configure();
243 }
244
245