wxVtkClipping3DView.cxx

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

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1