X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FwxMaracas_N_ViewersWidget.cxx;h=38da613ae54c9cb8be9253c2d28e9f24e6f01507;hb=ae196719490130990cdde501c982c3370b46b21c;hp=b89ff63d3a371c9d568458d20d978b66c79a6479;hpb=199d5048b6c5ac6663b8671f55289e4a0820f9cc;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx index b89ff63..38da613 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_N_ViewersWidget.cxx @@ -3,14 +3,14 @@ Program: wxMaracas Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $ Language: C++ - Date: $Date: 2010/08/25 17:51:12 $ - Version: $Revision: 1.19 $ + Date: $Date: 2010/10/23 12:01:32 $ + Version: $Revision: 1.20 $ Copyright: (c) 2002, 2003 License: - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ @@ -35,7 +35,7 @@ EVT_MENU( 12122, wxMaracas_N_ViewersWidget::OnDClickLeft ) END_EVENT_TABLE( ); - + //------------------------------------------------------------------------------------------------------------ // Constructors & Destructors //------------------------------------------------------------------------------------------------------------ @@ -51,25 +51,25 @@ wxwindow4 = NULL; _currentwxw = NULL; mvtkmprbasedata = NULL; - + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); this->SetSizer(sizer); this->SetAutoLayout(true); - - + + if(imagedata!=NULL && nTypeView!=NULL ){ this->SetType(nTypeView); this->UpdateLayout(imagedata); } - + } /** * @pre A wxWindow* object must be provided as a parent for the viewer and the type of layout for the viewer - * @post The layout of the viewer is initialized, if no image is provided at first, a default image is + * @post The layout of the viewer is initialized, if no image is provided at first, a default image is * used * @param wxWindow* parent of the window - * @param std::vector* vector of the type for the viewer + * @param std::vector* vector of the type for the viewer * @param vtkImageData* imagedata of the viewer */ wxMaracas_N_ViewersWidget::wxMaracas_N_ViewersWidget(wxWindow *parent, std::vector *nTypeView, vtkImageData* imagedata) @@ -80,13 +80,13 @@ wxwindow4 = NULL; _currentwxw = NULL; mvtkmprbasedata = NULL; - + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); this->SetSizer(sizer); this->SetAutoLayout(true); - + this->SetType(nTypeView); - + /*if(imagedata==NULL){ double spc[3]; spc[0] = 1; @@ -99,18 +99,18 @@ extent[3] = 1; extent[4] = 0; extent[5] = 0; - + imagedata = vtkImageData::New(); imagedata->SetSpacing(spc); imagedata->SetExtent(extent); imagedata->SetScalarTypeToUnsignedChar(); imagedata->AllocateScalars(); }*/ - + this->UpdateLayout(imagedata); } //------------------------------------------------------------------------- - + wxMaracas_N_ViewersWidget::~wxMaracas_N_ViewersWidget() { if (mvtkmprbasedata!=NULL) @@ -135,12 +135,12 @@ //------------------------------------------------------------------------- - void wxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) + void wxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) { RefreshView(); } //---------------------------------------------------------------------------- - void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event) + void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event) { RefreshView(); } @@ -153,7 +153,8 @@ } void wxMaracas_N_ViewersWidget::RefreshView() - { + { + if (wxwindow1!=NULL) {wxwindow1->RefreshView(); } if (wxwindow2!=NULL) {wxwindow2->RefreshView(); } if (wxwindow3!=NULL) {wxwindow3->RefreshView(); } @@ -161,7 +162,7 @@ } //------------------------------------------------------------------------- - wxMaracas_ViewerWidget *wxMaracas_N_ViewersWidget::GetWindow(int iWin) + wxMaracas_ViewerWidget *wxMaracas_N_ViewersWidget::GetWindow(int iWin) { wxMaracas_ViewerWidget *tmpWin=NULL; if (iWin==1) @@ -185,13 +186,13 @@ //------------------------------------------------------------------------- wxVtkBaseView *wxMaracas_N_ViewersWidget::GetwxVtkBaseView(int iWin) - { + { wxVtkBaseView *wxvtkbaseview=NULL; wxMaracas_ViewerWidget *tmpWin=GetWindow(iWin); if (tmpWin!=NULL){ wxvtkbaseview = tmpWin->GetwxVtkBaseView(); } return wxvtkbaseview; } - + //------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::Refresh(bool eraseBackground, const wxRect* rect ) { @@ -201,23 +202,22 @@ //------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::UpdateLayout(vtkImageData* imagedata) { - wxWindow *wxwindow = NULL; - wxSizer *sizer = this->GetSizer(); - + wxSizer *sizer = this->GetSizer(); + if (mvtkmprbasedata!=NULL) { delete mvtkmprbasedata; } - - marImageData *marimagedata = new marImageData( imagedata ); - mvtkmprbasedata = new vtkMPRBaseData(); + + marImageData *marimagedata = new marImageData( imagedata ); + mvtkmprbasedata = new vtkMPRBaseData(); mvtkmprbasedata->SetMarImageData(marimagedata); - + if(_currentwxw != NULL){ _currentwxw->Show(false); delete _currentwxw; - //sizer->Remove(currentwxwindow); + //sizer->Remove(currentwxwindow); //delete currentwxwindow; } @@ -225,18 +225,14 @@ if (nTypeView->size()==1) { wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0], mvtkmprbasedata); - - wxwindow1->ConfigureVTK(); wxwindow = wxwindow1; }else if (nTypeView->size()==2) { wxSplitterWindow *spliter = new wxSplitterWindow( this , -1); spliter->SetMinimumPaneSize(1); wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0], mvtkmprbasedata); wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1], mvtkmprbasedata); - wxwindow1->ConfigureVTK(); - wxwindow2->ConfigureVTK(); spliter -> SplitVertically( wxwindow1 , wxwindow2 ); - wxwindow = spliter; + wxwindow = spliter; }else if (nTypeView->size()==3) { wxSplitterWindow *spliter = new wxSplitterWindow( this , -1); @@ -246,9 +242,6 @@ wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0], mvtkmprbasedata); wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1], mvtkmprbasedata); wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2], mvtkmprbasedata); - wxwindow1->ConfigureVTK(); - wxwindow2->ConfigureVTK(); - wxwindow3->ConfigureVTK(); spliter -> SplitVertically( wxwindow1 , spliterA ); spliterA-> SplitHorizontally( wxwindow2 , wxwindow3 ); wxwindow = spliter; @@ -259,28 +252,33 @@ spliter->SetMinimumPaneSize(1); spliterA->SetMinimumPaneSize(1); spliterB->SetMinimumPaneSize(1); + + spliter -> SplitVertically( spliterA , spliterB ); wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0], mvtkmprbasedata); wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1], mvtkmprbasedata); + spliterA-> SplitHorizontally( wxwindow1 , wxwindow2 ); wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2], mvtkmprbasedata); wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3], mvtkmprbasedata); - wxwindow1->ConfigureVTK(); - wxwindow2->ConfigureVTK(); - wxwindow3->ConfigureVTK(); - wxwindow4->ConfigureVTK(); - spliter -> SplitVertically( spliterA , spliterB ); - spliterA-> SplitHorizontally( wxwindow1 , wxwindow2 ); spliterB-> SplitHorizontally( wxwindow3 , wxwindow4 ); wxwindow = spliter; } - + + //panel->SetDimension() sizer->Add( wxwindow , 1, wxGROW); sizer->Layout(); - //_currentwxw = wxwindow; + //_currentwxw = wxwindow; //_currentwxw->Show(true); - + //this->Layout(); //this->Refresh(); + + +// I don't undestand how this works and not the opposite ... + if (wxwindow4!=NULL) {wxwindow4->ConfigureVTK(); } + if (wxwindow3!=NULL) {wxwindow3->ConfigureVTK(); } + if (wxwindow2!=NULL) {wxwindow2->ConfigureVTK(); } + if (wxwindow1!=NULL) {wxwindow1->ConfigureVTK(); } } @@ -293,13 +291,13 @@ //----------------------------------------------------------------------------------- void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image ) - { + { if (wxwindow1!=NULL) { wxwindow1->SetImage(image); } - if (wxwindow2!=NULL) { wxwindow2->SetImage(image); } + if (wxwindow2!=NULL) { wxwindow2->SetImage(image); } if (wxwindow3!=NULL) { wxwindow3->SetImage(image); } if (wxwindow4!=NULL) { wxwindow4->SetImage(image); } ConfigureVTK(); - + } //----------------------------------------------------------------------------------- @@ -313,7 +311,7 @@ //----------------------------------------------------------------------------------- double wxMaracas_N_ViewersWidget :: GetX() -{ +{ invariant(); return mvtkmprbasedata->GetX(); // return wxwindow1->GetX();