wxMaracas_N_ViewersWidget.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   wxMaracas
00004   Module:    $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
00005   Language:  C++
00006   Date:      $Date: 2010/02/04 10:54:49 $
00007   Version:   $Revision: 1.14 $
00008 
00009   Copyright: (c) 2002, 2003
00010   License:
00011   
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notice for more information.
00015 
00016 =========================================================================*/
00017 
00018 //------------------------------------------------------------------------------------------------------------
00019 // Definition includes
00020 //------------------------------------------------------------------------------------------------------------
00021 #include "wxMaracas_N_ViewersWidget.h"
00022 
00023 //------------------------------------------------------------------------------------------------------------
00024 // Other includes
00025 //------------------------------------------------------------------------------------------------------------
00026 
00027 
00028         //------------------------------------------------------------------------------------------------------------
00029         // Constructors & Destructors
00030         //------------------------------------------------------------------------------------------------------------
00031 
00032 
00033         BEGIN_EVENT_TABLE( wxMaracas_N_ViewersWidget, wxPanel )
00034                 EVT_MENU( 12121, wxMaracas_N_ViewersWidget::OnRefreshView )
00035                 EVT_MENU( 12122, wxMaracas_N_ViewersWidget::OnDClickLeft  )
00036         END_EVENT_TABLE( );
00037 
00038         
00039         //------------------------------------------------------------------------------------------------------------
00040         // Constructors & Destructors
00041         //------------------------------------------------------------------------------------------------------------
00042 
00043 
00044 
00045         wxMaracas_N_ViewersWidget::wxMaracas_N_ViewersWidget(wxWindow *parent, vtkImageData* imagedata, std::vector<int> *nTypeView)
00046                 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
00047         {
00048                 wxwindow1               = NULL;
00049                 wxwindow2               = NULL;
00050                 wxwindow3               = NULL;
00051                 wxwindow4               = NULL;
00052                 _currentwxw             = NULL;
00053                 mvtkmprbasedata = NULL;
00054                 
00055                 wxSizer *sizer  = new wxBoxSizer(wxVERTICAL);
00056                 this->SetSizer(sizer);
00057                 this->SetAutoLayout(true);
00058                 
00059                 
00060                 if(imagedata!=NULL && nTypeView!=NULL ){
00061                         this->SetType(nTypeView);
00062                         this->UpdateLayout(imagedata);
00063                 }
00064 
00065                 
00066         }
00067         //-------------------------------------------------------------------------
00068           
00069         wxMaracas_N_ViewersWidget::~wxMaracas_N_ViewersWidget()
00070         {
00071                 if (mvtkmprbasedata!=NULL)
00072                 {
00073                         delete mvtkmprbasedata;
00074                 }
00075 
00076         }
00077         //------------------------------------------------------------------------------------------------------------
00078         // Methods
00079         //------------------------------------------------------------------------------------------------------------
00080 
00081 
00082         //-------------------------------------------------------------------------
00083 
00084         void wxMaracas_N_ViewersWidget::Update()
00085         {
00086                 //wxvtkrenderwindowinteractor->Render();
00087         //    wxvtkrenderwindowinteractor->Refresh();
00088         //    Refresh();
00089         }
00090 
00091         //-------------------------------------------------------------------------
00092 
00093         void wxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) 
00094         {
00095                 RefreshView();
00096         }
00097         //----------------------------------------------------------------------------
00098         void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event) 
00099         {
00100                 RefreshView();
00101         }
00102 
00103                 //-------------------------------------------------------------------------
00104 
00105         vtkRenderer *wxMaracas_N_ViewersWidget::GetRenderer()
00106         {
00107                 return NULL; //renderer;
00108         }
00109 
00110         void wxMaracas_N_ViewersWidget::RefreshView()
00111         {               
00112                 if (wxwindow1!=NULL) {wxwindow1->RefreshView(); }
00113                 if (wxwindow2!=NULL) {wxwindow2->RefreshView(); }
00114                 if (wxwindow3!=NULL) {wxwindow3->RefreshView(); }
00115                 if (wxwindow4!=NULL) {wxwindow4->RefreshView(); }
00116         }
00117 
00118         //-------------------------------------------------------------------------
00119         wxMaracas_ViewerWidget *wxMaracas_N_ViewersWidget::GetWindow(int iWin)  
00120         {
00121                 wxMaracas_ViewerWidget *tmpWin=NULL;
00122                 if  (iWin==1)
00123                 {
00124                         tmpWin=wxwindow1;
00125                 }
00126                 if  (iWin==2)
00127                 {
00128                         tmpWin=wxwindow2;
00129                 }
00130                 if  (iWin==3)
00131                 {
00132                         tmpWin=wxwindow3;
00133                 }
00134                 if  (iWin==4)
00135                 {
00136                         tmpWin=wxwindow4;
00137                 }
00138                 return tmpWin;
00139         }
00140 
00141         //-------------------------------------------------------------------------
00142         wxVtkBaseView *wxMaracas_N_ViewersWidget::GetwxVtkBaseView(int iWin)
00143         { 
00144                 wxVtkBaseView *wxvtkbaseview=NULL;
00145                 wxMaracas_ViewerWidget *tmpWin=GetWindow(iWin);
00146                 if (tmpWin!=NULL){  wxvtkbaseview = tmpWin->GetwxVtkBaseView();  }
00147                 return wxvtkbaseview;
00148         }
00149    
00150         //-------------------------------------------------------------------------
00151         void wxMaracas_N_ViewersWidget::Refresh(bool eraseBackground, const wxRect* rect )
00152         {
00153                 wxPanel::Refresh(false);
00154         }
00155 
00156         //-------------------------------------------------------------------------
00157         void wxMaracas_N_ViewersWidget::UpdateLayout(vtkImageData* imagedata)
00158         {
00159 
00160                 wxWindow                                *wxwindow       = NULL;
00161                 wxSizer *sizer                                          = this->GetSizer();     
00162                 
00163                 if (mvtkmprbasedata!=NULL)
00164                 {
00165                         delete mvtkmprbasedata;
00166                 }
00167                 
00168                 marImageData    *marimagedata   = new marImageData( imagedata );                        
00169                 mvtkmprbasedata                                 = new vtkMPRBaseData(); 
00170                 mvtkmprbasedata->SetMarImageData(marimagedata);
00171                 
00172                 if(_currentwxw != NULL){
00173                         _currentwxw->Show(false);
00174                         delete _currentwxw;
00175                         //sizer->Remove(currentwxwindow);                       
00176                         //delete currentwxwindow;
00177                 }
00178 
00179                 //std::cout<<"size "<<nTypeView->size()<<std::endl;
00180                 if (nTypeView->size()==1)
00181                 {
00182                         wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0],mvtkmprbasedata);
00183 
00184                         wxwindow1->ConfigureVTK();
00185                         wxwindow = wxwindow1;
00186                 }else   if (nTypeView->size()==2)       {
00187                         wxSplitterWindow        *spliter        = new wxSplitterWindow( this , -1);
00188                         spliter->SetMinimumPaneSize(1);
00189                         wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0],mvtkmprbasedata);
00190                         wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1],mvtkmprbasedata);
00191                         wxwindow1->ConfigureVTK();
00192                         wxwindow2->ConfigureVTK();
00193                         spliter -> SplitVertically( wxwindow1 , wxwindow2  );
00194                         wxwindow = spliter;                     
00195                 }else if (nTypeView->size()==3)
00196                 {
00197                         wxSplitterWindow        *spliter        = new wxSplitterWindow( this , -1);
00198                         wxSplitterWindow        *spliterA       = new wxSplitterWindow( spliter , -1);
00199                         spliter->SetMinimumPaneSize(1);
00200                         spliterA->SetMinimumPaneSize(1);
00201                         wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0],mvtkmprbasedata);
00202                         wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
00203                         wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2],mvtkmprbasedata);
00204                         wxwindow1->ConfigureVTK();
00205                         wxwindow2->ConfigureVTK();
00206                         wxwindow3->ConfigureVTK();
00207                         spliter -> SplitVertically( wxwindow1 , spliterA   );
00208                         spliterA-> SplitHorizontally( wxwindow2 , wxwindow3  );
00209                         wxwindow = spliter;
00210                 }else if (nTypeView->size()>=4){
00211                         wxSplitterWindow        *spliter        = new wxSplitterWindow( this , -1);
00212                         wxSplitterWindow        *spliterA       = new wxSplitterWindow( spliter , -1);
00213                         wxSplitterWindow        *spliterB       = new wxSplitterWindow( spliter , -1);
00214                         spliter->SetMinimumPaneSize(1);
00215                         spliterA->SetMinimumPaneSize(1);
00216                         spliterB->SetMinimumPaneSize(1);
00217                         wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0],mvtkmprbasedata);
00218                         wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
00219                         wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2],mvtkmprbasedata);
00220                         wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3],mvtkmprbasedata);
00221                         wxwindow1->ConfigureVTK();
00222                         wxwindow2->ConfigureVTK();
00223                         wxwindow3->ConfigureVTK();
00224                         wxwindow4->ConfigureVTK();
00225                         spliter -> SplitVertically( spliterA , spliterB   );
00226                         spliterA-> SplitHorizontally( wxwindow1 , wxwindow2  );
00227                         spliterB-> SplitHorizontally( wxwindow3 , wxwindow4  );
00228                         wxwindow = spliter;
00229                 }
00230                 
00231                 //panel->SetDimension()
00232                 sizer->Add( wxwindow , 1, wxEXPAND);
00233                 sizer->Layout();
00234                 _currentwxw = wxwindow;         
00235                 _currentwxw->Show(true);
00236                 
00237                 this->Layout();
00238                 this->Refresh();
00239  }
00240 
00241 
00242 //-----------------------------------------------------------------------------------
00243  void wxMaracas_N_ViewersWidget::SetType(std::vector<int>* type){
00244          nTypeView = type;
00245  }
00246 
00247 
00248 
00249 //-----------------------------------------------------------------------------------
00250  void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image  )
00251  {
00252          if (wxwindow1!=NULL) { wxwindow1->SetImage(image); }
00253          if (wxwindow2!=NULL) { wxwindow2->SetImage(image); } 
00254          if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
00255          if (wxwindow4!=NULL) { wxwindow4->SetImage(image); }
00256  }
00257 
00258 //-----------------------------------------------------------------------------------
00259  void wxMaracas_N_ViewersWidget::ConfigureVTK()
00260  {
00261          if (wxwindow1!=NULL) { wxwindow1->ConfigureVTK(); }
00262          if (wxwindow2!=NULL) { wxwindow2->ConfigureVTK(); }
00263          if (wxwindow3!=NULL) { wxwindow3->ConfigureVTK(); }
00264          if (wxwindow4!=NULL) { wxwindow4->ConfigureVTK(); }
00265  }
00266 
00267 //-----------------------------------------------------------------------------------
00268 double wxMaracas_N_ViewersWidget :: GetX()
00269 {
00270         return mvtkmprbasedata->GetX();
00271 //      return wxwindow1->GetX();
00272 }
00273 
00274 //-----------------------------------------------------------------------------------
00275 double wxMaracas_N_ViewersWidget :: GetY()
00276 {
00277         return mvtkmprbasedata->GetY();
00278 //      return wxwindow1->GetY();
00279 }
00280 
00281 
00282 //-----------------------------------------------------------------------------------
00283 double wxMaracas_N_ViewersWidget :: GetZ()
00284 {
00285         return mvtkmprbasedata->GetZ();
00286 //      return wxwindow1->GetZ();
00287 }
00288 
00289 void wxMaracas_N_ViewersWidget::setColorTransferFunction(vtkColorTransferFunction* colortable){
00290     if (wxwindow1!=NULL) {
00291                 wxwindow1->setColorTransferFunction(colortable);
00292         }
00293         if (wxwindow2!=NULL) {
00294                 wxwindow2->setColorTransferFunction(colortable);
00295         }
00296         if (wxwindow3!=NULL) {
00297                 wxwindow3->setColorTransferFunction(colortable);
00298         }
00299         if (wxwindow4!=NULL) {
00300                 wxwindow4->setColorTransferFunction(colortable);
00301         }
00302 }
00303 
00304 void wxMaracas_N_ViewersWidget::setWindowLevel(double level){
00305         if (wxwindow1!=NULL) {
00306                 wxwindow1->setWindowLevel(level);
00307         }
00308         if (wxwindow2!=NULL) {
00309                 wxwindow2->setWindowLevel(level);
00310         }
00311         if (wxwindow3!=NULL) {
00312                 wxwindow3->setWindowLevel(level);
00313         }
00314         if (wxwindow4!=NULL) {
00315                 wxwindow4->setWindowLevel(level);
00316         }
00317 }
00318 void wxMaracas_N_ViewersWidget::setColorLevel(double level){
00319         if (wxwindow1!=NULL) {
00320                 wxwindow1->setColorLevel(level);
00321         }
00322         if (wxwindow2!=NULL) {
00323                 wxwindow2->setColorLevel(level);
00324         }
00325         if (wxwindow3!=NULL) {
00326                 wxwindow3->setColorLevel(level);
00327         }
00328         if (wxwindow4!=NULL) {
00329                 wxwindow4->setColorLevel(level);
00330         }
00331 }
00332 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1