wxVtkClipping3DView.cxx

Go to the documentation of this file.
00001 #include "wxVtkClipping3DView.h"
00002 
00003 #include "wxVtkClipping3DViewCntrlPanel.h"
00004 
00005 wxVtkClipping3DView::wxVtkClipping3DView(wxVtk3DBaseView* wxvtk3Dbaseview)
00006 {
00007         _wxvtk3Dbaseview                                =       wxvtk3Dbaseview;
00008         _vtkclipping3Ddataviewer                =       NULL;
00009         _wxvtkclipping3DviewCntrlPanel  =       NULL;
00010 
00011         _boxWidgetVolume                                =       NULL;
00012         _boxWidgetS1                                    =       NULL;
00013 }
00014 
00015 //-------------------------------------------------------------------
00016 wxVtkClipping3DView::~wxVtkClipping3DView(){
00017         if (_boxWidgetVolume!=NULL)                              { _boxWidgetVolume     -> Delete();                                    }
00018         if (_boxWidgetS1!=NULL)                                  { _boxWidgetS1         -> Delete();                                    }
00019         if (_vtkclipping3Ddataviewer!=NULL)              { delete _vtkclipping3Ddataviewer;                     }
00020         if (_wxvtkclipping3DviewCntrlPanel!=NULL){ delete _wxvtkclipping3DviewCntrlPanel;       }
00021 }
00022 //-------------------------------------------------------------------
00023 void wxVtkClipping3DView::SetVisibleBoxSurface(bool visible)
00024 {
00025         if (visible==true){
00026                 _boxWidgetS1->On();
00027         } else {
00028                 _boxWidgetS1->Off();
00029         }
00030 }
00031 //-------------------------------------------------------------------
00032 void wxVtkClipping3DView::SetVisibleBoxVolume(bool visible)
00033 {
00034         if (_boxWidgetVolume!=NULL){
00035                 if (visible==true){
00036                         _boxWidgetVolume->On();
00037                 } else {
00038                         _boxWidgetVolume->Off();
00039                 }
00040         }
00041 }
00042 //-------------------------------------------------------------------
00043 void wxVtkClipping3DView::Refresh()
00044 {
00045         _vtkclipping3Ddataviewer->Refresh();
00046         if (_wxvtkclipping3DviewCntrlPanel!=NULL)
00047         {
00048                 _wxvtkclipping3DviewCntrlPanel->Refresh();
00049         }
00050 }
00051 //-------------------------------------------------------------------
00052 wxPanel* wxVtkClipping3DView::CreateControlPanel(wxWindow *parent)
00053 {
00054         _wxvtkclipping3DviewCntrlPanel = new wxVtkClipping3DViewCntrlPanel(parent,this);
00055         return _wxvtkclipping3DviewCntrlPanel;
00056 }
00057 //-------------------------------------------------------------------
00058 vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer()
00059 {
00060         return _vtkclipping3Ddataviewer; 
00061 }
00062 //-------------------------------------------------------------------
00063 void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){
00064         if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){
00065                 if (visTissue==false){
00066                         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue)  );    
00067                 } else {
00068                         _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue)  );       
00069 //                      _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) );
00070 //                      _actor->VisibilityOn();
00071                 }
00072                 _vtkclipping3Ddataviewer->SetVisibleTissue(idTissue,visTissue);
00073         }
00074 }
00075 //-------------------------------------------------------------------
00076 void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representationType )
00077 {
00078         vtkActor *tmpActor;
00079         tmpActor = GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
00080 
00081         if (representationType==false){
00082                 tmpActor->GetProperty()->SetRepresentationToWireframe();
00083         } else {
00084                 tmpActor->GetProperty()->SetRepresentationToSurface();
00085         }
00086 
00087         _vtkclipping3Ddataviewer->SetRepresentationType(idTissue,representationType);
00088 }
00089 
00090 //-------------------------------------------------------------------
00091 void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){
00092         if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){
00093                 if (visVolume==false){
00094 //EED 31/03/2008                        
00095 //                      _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor()  );    
00096                         _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor()  );   
00097                 } else {
00098 //EED 31/03/2008                        
00099 //                      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() );        
00100                         _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() );       
00101                 }
00102                 _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume);
00103         }
00104 }
00105 //-------------------------------------------------------------------
00106 wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*)
00107 {
00108         if(_wxvtk3Dbaseview==NULL){
00109                 throw "wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview() _wxvtk3Dbaseview=NULL";
00110         }
00111         return _wxvtk3Dbaseview;
00112 }
00113 //-------------------------------------------------------------------
00114 void wxVtkClipping3DView::Configure(){
00115         _wxvtk3Dbaseview->Configure();
00116 
00117         // Actors are added to the renderer. 
00118         _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() );                       
00119 
00120         _boxWidgetS1 = vtkBoxWidget::New();
00121         _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
00122         _boxWidgetS1->SetPlaceFactor(1.25);
00123 
00124 
00125 
00126         vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0);
00127         vtkPolyData *polydata= stripper->GetOutput();
00128  
00129 
00130         _boxWidgetS1->SetInput( polydata );
00131         _boxWidgetS1->PlaceWidget();
00132 
00133         int i;
00134         for (i=0; i< VTKMPRDATA_MAXTISSUE ; i++)
00135         {
00136                 _boxWidgetS1->AddObserver( vtkCommand::InteractionEvent          , _vtkclipping3Ddataviewer->GetObserverS(i) );
00137         }
00138 
00139 
00140 
00141 
00142 //      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) );                       
00143 //      _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3));                        
00144 
00145         VisibleActor(0, false );
00146         VisibleActor(1, false );
00147         VisibleActor(2, false );
00148         VisibleActor(3, false );
00149 
00150         _boxWidgetS1->HandlesOn ();
00151         
00152 //EED 29Mars2009        
00153 //      _boxWidgetS1->On();
00154         
00155         _boxWidgetS1->Off();
00156 
00157         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) );
00158         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) );
00159         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) );
00160         _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) );
00161         
00162 // EED 9 fev 2007
00163 // box Volume
00164         _boxWidgetVolume = vtkBoxWidget::New();
00165         _boxWidgetVolume->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() );
00166         _boxWidgetVolume->SetPlaceFactor(1.25);
00167 
00168         _boxWidgetVolume->SetInput( this->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData() );
00169         _boxWidgetVolume->PlaceWidget();
00170 
00171         _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent              , _vtkclipping3Ddataviewer->GetObserverV() );
00172 
00173         _boxWidgetVolume->HandlesOn ();
00174         
00175 //EED 29Mars2009        
00176 //      _boxWidgetVolume->On();
00177         
00178         _boxWidgetVolume->Off();
00179 
00180 
00181 //      vtkPlanes *vtkplanes=this->GetVtkClipping3DDataViewer()->GetVolumePlanes();
00182 //      _boxWidgetVolume->GetPlanes( vtkplanes );
00183 
00184 
00185   // An initial camera view is created.  The Dolly() method moves 
00186   // the camera towards the FocalPoint, thereby enlarging the image.
00187   _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera());
00188   _wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
00189   _wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
00190 
00191   // Set a background color for the renderer and set the size of the
00192   // render window (expressed in pixels).
00193   _wxvtk3Dbaseview->GetRenderer()->SetBackground( 0.36 , 0.36 , 0.36 );
00194   _wxvtk3Dbaseview->GetRenWin()->SetSize(400, 400);
00195 
00196   // Note that when camera movement occurs (as it does in the Dolly()
00197   // method), the clipping planes often need adjusting. Clipping planes
00198   // consist of two planes: near and far along the view direction. The 
00199   // near plane clips out objects in front of the plane; the far plane
00200   // clips out objects behind the plane. This way only what is drawn
00201   // between the planes is actually rendered.
00202   _wxvtk3Dbaseview->GetRenderer()->ResetCameraClippingRange();
00203 }
00204 //-------------------------------------------------------------------
00205 void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vtkclipping3Ddataviewer)
00206 {
00207         _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
00208 }

Generated on Wed Jul 29 16:35:31 2009 for creaMaracasVisu_lib by  doxygen 1.5.3