1 #include "wxVtkClipping3DView.h"
3 #include "wxVtkClipping3DViewCntrlPanel.h"
5 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
7 _wxvtk3Dbaseview = wxvtk3Dbaseview;
8 _vtkclipping3Ddataviewer = NULL;
9 _wxvtkclipping3DviewCntrlPanel = NULL;
11 _boxWidgetVolume = NULL;
15 //-------------------------------------------------------------------
16 wxVtkClipping3DView::~wxVtkClipping3DView(){
17 if (_boxWidgetVolume!=NULL) { _boxWidgetVolume -> Delete(); }
18 if (_boxWidgetS1!=NULL) { _boxWidgetS1 -> Delete(); }
19 if (_vtkclipping3Ddataviewer!=NULL) { delete _vtkclipping3Ddataviewer; }
20 if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel; }
22 //-------------------------------------------------------------------
23 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
31 //-------------------------------------------------------------------
32 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
34 if (_boxWidgetVolume!=NULL){
36 _boxWidgetVolume->On();
38 _boxWidgetVolume->Off();
42 //-------------------------------------------------------------------
43 void wxVtkClipping3DView::Refresh()
45 _vtkclipping3Ddataviewer->Refresh();
46 if (_wxvtkclipping3DviewCntrlPanel!=NULL)
48 _wxvtkclipping3DviewCntrlPanel->Refresh();
51 //-------------------------------------------------------------------
52 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
54 _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
55 return _wxvtkclipping3DviewCntrlPanel;
57 //-------------------------------------------------------------------
58 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
60 return _vtkclipping3Ddataviewer;
62 //-------------------------------------------------------------------
63 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
64 if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
65 if (visTissue==false){
66 _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
68 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) );
69 // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
70 // _actor->VisibilityOn();
72 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
75 //-------------------------------------------------------------------
76 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
79 tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
81 if (representationType==false){
82 tmpActor->GetProperty()->SetRepresentationToWireframe();
84 tmpActor->GetProperty()->SetRepresentationToSurface();
87 _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
90 //-------------------------------------------------------------------
91 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
92 if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
93 if (visVolume==false){
95 // _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
96 _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
99 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );
100 _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );
102 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
105 //-------------------------------------------------------------------
106 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
108 if(_wxvtk3Dbaseview==NULL){
109 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
111 return _wxvtk3Dbaseview;
113 //-------------------------------------------------------------------
114 void wxVtkClipping3DView::Configure(){
115 _wxvtk3Dbaseview->Configure();
117 // Actors are added to the renderer.
118 _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );
120 _boxWidgetS1 = vtkBoxWidget::New();
121 _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
122 _boxWidgetS1->SetPlaceFactor(1.25);
126 vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
127 vtkPolyData *polydata= stripper->GetOutput();
130 _boxWidgetS1->SetInput( polydata );
131 _boxWidgetS1->PlaceWidget();
134 for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
136 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverS(i) );
142 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );
143 // _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));
145 VisibleActor(0, false );
146 VisibleActor(1, false );
147 VisibleActor(2, false );
148 VisibleActor(3, false );
150 _boxWidgetS1->HandlesOn ();
153 // _boxWidgetS1->On();
157 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
158 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
159 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
160 _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
164 _boxWidgetVolume = vtkBoxWidget::New();
165 _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
166 _boxWidgetVolume->SetPlaceFactor(1.25);
168 _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
169 _boxWidgetVolume->PlaceWidget();
171 _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() );
173 _boxWidgetVolume->HandlesOn ();
176 // _boxWidgetVolume->On();
178 _boxWidgetVolume->Off();
181 // vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
182 // _boxWidgetVolume->GetPlanes( vtkplanes );
185 // An initial camera view is created. The Dolly() method moves
186 // the camera towards the FocalPoint, thereby enlarging the image.
187 _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
188 _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
189 _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
191 // Set a background color for the renderer and set the size of the
192 // render window (expressed in pixels).
193 _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
194 _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
196 // Note that when camera movement occurs (as it does in the Dolly()
197 // method), the clipping planes often need adjusting. Clipping planes
198 // consist of two planes: near and far along the view direction. The
199 // near plane clips out objects in front of the plane; the far plane
200 // clips out objects behind the plane. This way only what is drawn
201 // between the planes is actually rendered.
202 _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
204 //-------------------------------------------------------------------
205 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
207 _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;