1 #include "wxVtkClipping3DView.h"
3 #include "wxVtkClipping3DViewCntrlPanel.h"
4 #include "wxVtkClipping3DViewVolCntrlPanel.h"
6 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
8 _wxvtk3Dbaseview = wxvtk3Dbaseview;
9 _vtkclipping3Ddataviewer = NULL;
10 _wxvtkclipping3DviewCntrlPanel = NULL;
12 _boxWidgetVolume = NULL;
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; }
23 //-------------------------------------------------------------------
24 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
32 //-------------------------------------------------------------------
33 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
35 if (_boxWidgetVolume!=NULL){
37 _boxWidgetVolume->On();
39 _boxWidgetVolume->Off();
43 //-------------------------------------------------------------------
44 void wxVtkClipping3DView::Refresh()
46 _vtkclipping3Ddataviewer->Refresh();
47 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
49 _wxvtkclipping3DviewCntrlPanel->Refresh();
52 //-------------------------------------------------------------------
53 wxPanel* wxVtkClipping3DView::CreateSurfControlPanel(wxWindow *parent)
55 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
56 return _wxvtkclipping3DviewCntrlPanel;
59 //RaC 03-2010 Divide in two panels
60 //-------------------------------------------------------------------
61 wxPanel* wxVtkClipping3DView::CreateVolControlPanel(wxWindow *parent)
63 _wxvtkclipping3DviewVolCntrlPanel = new wxVtkClipping3DViewVolCntrlPanel(parent,this);
64 return _wxvtkclipping3DviewVolCntrlPanel;
68 //-------------------------------------------------------------------
69 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
71 return _vtkclipping3Ddataviewer;
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) );
79 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
80 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
81 // _actor->VisibilityOn();
83 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
86 //-------------------------------------------------------------------
87 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
90 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
92 if (representationType==false){
93 tmpActor->GetProperty()->SetRepresentationToWireframe();
95 tmpActor->GetProperty()->SetRepresentationToSurface();
98 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
101 //-------------------------------------------------------------------
102 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
103 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
104 if (visVolume==false){
106 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
107 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
110 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
111 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
113 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
116 //-------------------------------------------------------------------
117 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
119 if(_wxvtk3Dbaseview==NULL){
120 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
122 return _wxvtk3Dbaseview;
124 //-------------------------------------------------------------------
125 void wxVtkClipping3DView::Configure(){
126 _wxvtk3Dbaseview->Configure();
128 // Actors are added to the renderer.
129 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
131 _boxWidgetS1 = vtkBoxWidget::New();
132 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
133 _boxWidgetS1->SetPlaceFactor(1.25);
137 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
138 vtkPolyData *polydata= stripper->GetOutput();
141 _boxWidgetS1->SetInput( polydata );
142 _boxWidgetS1->PlaceWidget();
145 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
147 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
153 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
154 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
156 VisibleActor(0, false );
157 VisibleActor(1, false );
158 VisibleActor(2, false );
159 VisibleActor(3, false );
161 _boxWidgetS1->HandlesOn ();
164 // _boxWidgetS1->On();
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) );
175 _boxWidgetVolume = vtkBoxWidget::New();
176 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
177 _boxWidgetVolume->SetPlaceFactor(1.25);
179 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
180 _boxWidgetVolume->PlaceWidget();
182 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
184 _boxWidgetVolume->HandlesOn ();
187 // _boxWidgetVolume->On();
189 _boxWidgetVolume->Off();
192 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
193 // _boxWidgetVolume->GetPlanes( vtkplanes );
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);
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);
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();
215 //-------------------------------------------------------------------
216 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
218 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;