1 /*=========================================================================
4 Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
6 Date: $Date: 2009/09/15 11:25:07 $
7 Version: $Revision: 1.12 $
9 Copyright: (c) 2002, 2003
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notice for more information.
16 =========================================================================*/
18 //------------------------------------------------------------------------------------------------------------
19 // Definition includes
20 //------------------------------------------------------------------------------------------------------------
21 #include "wxMaracas_N_ViewersWidget.h"
23 //------------------------------------------------------------------------------------------------------------
25 //------------------------------------------------------------------------------------------------------------
28 //------------------------------------------------------------------------------------------------------------
29 // Constructors & Destructors
30 //------------------------------------------------------------------------------------------------------------
33 BEGIN_EVENT_TABLE( wxMaracas_N_ViewersWidget, wxPanel )
34 EVT_MENU( 12121, wxMaracas_N_ViewersWidget::OnRefreshView )
35 EVT_MENU( 12122, wxMaracas_N_ViewersWidget::OnDClickLeft )
39 //------------------------------------------------------------------------------------------------------------
40 // Constructors & Destructors
41 //------------------------------------------------------------------------------------------------------------
45 wxMaracas_N_ViewersWidget::wxMaracas_N_ViewersWidget(wxWindow *parent, vtkImageData* imagedata, std::vector<int> *nTypeView)
46 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
53 mvtkmprbasedata = NULL;
55 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
56 this->SetSizer(sizer);
57 this->SetAutoLayout(true);
60 if(imagedata!=NULL && nTypeView!=NULL ){
61 this->SetType(nTypeView);
62 this->UpdateLayout(imagedata);
67 //-------------------------------------------------------------------------
69 wxMaracas_N_ViewersWidget::~wxMaracas_N_ViewersWidget()
71 if (mvtkmprbasedata!=NULL)
73 delete mvtkmprbasedata;
77 //------------------------------------------------------------------------------------------------------------
79 //------------------------------------------------------------------------------------------------------------
82 //-------------------------------------------------------------------------
84 void wxMaracas_N_ViewersWidget::Update()
86 //wxvtkrenderwindowinteractor->Render();
87 // wxvtkrenderwindowinteractor->Refresh();
91 //-------------------------------------------------------------------------
93 void wxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
97 //----------------------------------------------------------------------------
98 void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
103 //-------------------------------------------------------------------------
105 vtkRenderer *wxMaracas_N_ViewersWidget::GetRenderer()
107 return NULL; //renderer;
110 void wxMaracas_N_ViewersWidget::RefreshView()
112 if (wxwindow1!=NULL) {wxwindow1->RefreshView(); }
113 if (wxwindow2!=NULL) {wxwindow2->RefreshView(); }
114 if (wxwindow3!=NULL) {wxwindow3->RefreshView(); }
115 if (wxwindow4!=NULL) {wxwindow4->RefreshView(); }
118 //-------------------------------------------------------------------------
119 wxMaracas_ViewerWidget *wxMaracas_N_ViewersWidget::GetWindow(int iWin)
121 wxMaracas_ViewerWidget *tmpWin=NULL;
141 //-------------------------------------------------------------------------
142 wxVtkBaseView *wxMaracas_N_ViewersWidget::GetwxVtkBaseView(int iWin)
144 wxVtkBaseView *wxvtkbaseview=NULL;
145 wxMaracas_ViewerWidget *tmpWin=GetWindow(iWin);
146 if (tmpWin!=NULL){ wxvtkbaseview = tmpWin->GetwxVtkBaseView(); }
147 return wxvtkbaseview;
150 //-------------------------------------------------------------------------
151 void wxMaracas_N_ViewersWidget::Refresh(bool eraseBackground, const wxRect* rect )
153 wxPanel::Refresh(false);
156 //-------------------------------------------------------------------------
157 void wxMaracas_N_ViewersWidget::UpdateLayout(vtkImageData* imagedata)
160 wxWindow *wxwindow = NULL;
161 wxSizer *sizer = this->GetSizer();
163 if (mvtkmprbasedata!=NULL)
165 delete mvtkmprbasedata;
168 marImageData *marimagedata = new marImageData( imagedata );
169 mvtkmprbasedata = new vtkMPRBaseData();
170 mvtkmprbasedata->SetMarImageData(marimagedata);
172 if(_currentwxw != NULL){
173 _currentwxw->Show(false);
175 //sizer->Remove(currentwxwindow);
176 //delete currentwxwindow;
179 //std::cout<<"size "<<nTypeView->size()<<std::endl;
180 if (nTypeView->size()==1)
182 wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0],mvtkmprbasedata);
184 wxwindow1->ConfigureVTK();
185 wxwindow = wxwindow1;
186 }else if (nTypeView->size()==2) {
187 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
188 spliter->SetMinimumPaneSize(1);
189 wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0],mvtkmprbasedata);
190 wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1],mvtkmprbasedata);
191 wxwindow1->ConfigureVTK();
192 wxwindow2->ConfigureVTK();
193 spliter -> SplitVertically( wxwindow1 , wxwindow2 );
195 }else if (nTypeView->size()==3)
197 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
198 wxSplitterWindow *spliterA = new wxSplitterWindow( spliter , -1);
199 spliter->SetMinimumPaneSize(1);
200 spliterA->SetMinimumPaneSize(1);
201 wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0],mvtkmprbasedata);
202 wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
203 wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2],mvtkmprbasedata);
204 wxwindow1->ConfigureVTK();
205 wxwindow2->ConfigureVTK();
206 wxwindow3->ConfigureVTK();
207 spliter -> SplitVertically( wxwindow1 , spliterA );
208 spliterA-> SplitHorizontally( wxwindow2 , wxwindow3 );
210 }else if (nTypeView->size()>=4){
211 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
212 wxSplitterWindow *spliterA = new wxSplitterWindow( spliter , -1);
213 wxSplitterWindow *spliterB = new wxSplitterWindow( spliter , -1);
214 spliter->SetMinimumPaneSize(1);
215 spliterA->SetMinimumPaneSize(1);
216 spliterB->SetMinimumPaneSize(1);
217 wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0],mvtkmprbasedata);
218 wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1],mvtkmprbasedata);
219 wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2],mvtkmprbasedata);
220 wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3],mvtkmprbasedata);
221 wxwindow1->ConfigureVTK();
222 wxwindow2->ConfigureVTK();
223 wxwindow3->ConfigureVTK();
224 wxwindow4->ConfigureVTK();
225 spliter -> SplitVertically( spliterA , spliterB );
226 spliterA-> SplitHorizontally( wxwindow1 , wxwindow2 );
227 spliterB-> SplitHorizontally( wxwindow3 , wxwindow4 );
231 //panel->SetDimension()
232 sizer->Add( wxwindow , 1, wxEXPAND);
234 _currentwxw = wxwindow;
235 _currentwxw->Show(true);
242 //-----------------------------------------------------------------------------------
243 void wxMaracas_N_ViewersWidget::SetType(std::vector<int>* type){
249 //-----------------------------------------------------------------------------------
250 void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image )
252 if (wxwindow1!=NULL) {
254 wxwindow1->SetImage(image);
256 if (wxwindow2!=NULL) { wxwindow2->SetImage(image); }
257 if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
258 if (wxwindow4!=NULL) { wxwindow4->SetImage(image); }
263 //-----------------------------------------------------------------------------------
264 double wxMaracas_N_ViewersWidget :: GetX()
266 return mvtkmprbasedata->GetX();
267 // return wxwindow1->GetX();
270 //-----------------------------------------------------------------------------------
271 double wxMaracas_N_ViewersWidget :: GetY()
273 return mvtkmprbasedata->GetY();
274 // return wxwindow1->GetY();
278 //-----------------------------------------------------------------------------------
279 double wxMaracas_N_ViewersWidget :: GetZ()
281 return mvtkmprbasedata->GetZ();
282 // return wxwindow1->GetZ();
285 void wxMaracas_N_ViewersWidget::setColorTransferFunction(vtkColorTransferFunction* colortable){
286 if (wxwindow1!=NULL) {
287 wxwindow1->setColorTransferFunction(colortable);
289 if (wxwindow2!=NULL) {
290 wxwindow2->setColorTransferFunction(colortable);
292 if (wxwindow3!=NULL) {
293 wxwindow3->setColorTransferFunction(colortable);
295 if (wxwindow4!=NULL) {
296 wxwindow4->setColorTransferFunction(colortable);
300 void wxMaracas_N_ViewersWidget::setWindowLevel(double level){
301 if (wxwindow1!=NULL) {
302 wxwindow1->setWindowLevel(level);
304 if (wxwindow2!=NULL) {
305 wxwindow2->setWindowLevel(level);
307 if (wxwindow3!=NULL) {
308 wxwindow3->setWindowLevel(level);
310 if (wxwindow4!=NULL) {
311 wxwindow4->setWindowLevel(level);
314 void wxMaracas_N_ViewersWidget::setColorLevel(double level){
315 if (wxwindow1!=NULL) {
316 wxwindow1->setColorLevel(level);
318 if (wxwindow2!=NULL) {
319 wxwindow2->setColorLevel(level);
321 if (wxwindow3!=NULL) {
322 wxwindow3->setColorLevel(level);
324 if (wxwindow4!=NULL) {
325 wxwindow4->setColorLevel(level);