00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "wxMaracas_N_ViewersWidget.h"
00022
00023
00024
00025
00026
00027
00028
00029
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
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 }
00075 wxMaracas_N_ViewersWidget::wxMaracas_N_ViewersWidget(wxWindow *parent, std::vector<int> *nTypeView, vtkImageData* imagedata)
00076 : wxPanel( parent, -1){
00077 wxwindow1 = NULL;
00078 wxwindow2 = NULL;
00079 wxwindow3 = NULL;
00080 wxwindow4 = NULL;
00081 _currentwxw = NULL;
00082 mvtkmprbasedata = NULL;
00083
00084 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00085 this->SetSizer(sizer);
00086 this->SetAutoLayout(true);
00087
00088 this->SetType(nTypeView);
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 this->UpdateLayout(imagedata);
00111 }
00112
00113
00114 wxMaracas_N_ViewersWidget::~wxMaracas_N_ViewersWidget()
00115 {
00116 if (mvtkmprbasedata!=NULL)
00117 {
00118 delete mvtkmprbasedata;
00119 }
00120
00121 }
00122
00123
00124
00125
00126
00127
00128
00129 void wxMaracas_N_ViewersWidget::Update()
00130 {
00131
00132
00133
00134 }
00135
00136
00137
00138 void wxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
00139 {
00140 RefreshView();
00141 }
00142
00143 void wxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
00144 {
00145 RefreshView();
00146 }
00147
00148
00149
00150 vtkRenderer *wxMaracas_N_ViewersWidget::GetRenderer()
00151 {
00152 return NULL;
00153 }
00154
00155 void wxMaracas_N_ViewersWidget::RefreshView()
00156 {
00157 if (wxwindow1!=NULL) {wxwindow1->RefreshView(); }
00158 if (wxwindow2!=NULL) {wxwindow2->RefreshView(); }
00159 if (wxwindow3!=NULL) {wxwindow3->RefreshView(); }
00160 if (wxwindow4!=NULL) {wxwindow4->RefreshView(); }
00161 }
00162
00163
00164 wxMaracas_ViewerWidget *wxMaracas_N_ViewersWidget::GetWindow(int iWin)
00165 {
00166 wxMaracas_ViewerWidget *tmpWin=NULL;
00167 if (iWin==1)
00168 {
00169 tmpWin=wxwindow1;
00170 }
00171 if (iWin==2)
00172 {
00173 tmpWin=wxwindow2;
00174 }
00175 if (iWin==3)
00176 {
00177 tmpWin=wxwindow3;
00178 }
00179 if (iWin==4)
00180 {
00181 tmpWin=wxwindow4;
00182 }
00183 return tmpWin;
00184 }
00185
00186
00187 wxVtkBaseView *wxMaracas_N_ViewersWidget::GetwxVtkBaseView(int iWin)
00188 {
00189 wxVtkBaseView *wxvtkbaseview=NULL;
00190 wxMaracas_ViewerWidget *tmpWin=GetWindow(iWin);
00191 if (tmpWin!=NULL){ wxvtkbaseview = tmpWin->GetwxVtkBaseView(); }
00192 return wxvtkbaseview;
00193 }
00194
00195
00196 void wxMaracas_N_ViewersWidget::Refresh(bool eraseBackground, const wxRect* rect )
00197 {
00198 wxPanel::Refresh(false);
00199 }
00200
00201
00202 void wxMaracas_N_ViewersWidget::UpdateLayout(vtkImageData* imagedata)
00203 {
00204
00205 wxWindow *wxwindow = NULL;
00206 wxSizer *sizer = this->GetSizer();
00207
00208 if (mvtkmprbasedata!=NULL)
00209 {
00210 delete mvtkmprbasedata;
00211 }
00212
00213 marImageData *marimagedata = new marImageData( imagedata );
00214 mvtkmprbasedata = new vtkMPRBaseData();
00215 mvtkmprbasedata->SetMarImageData(marimagedata);
00216
00217 if(_currentwxw != NULL){
00218 _currentwxw->Show(false);
00219 delete _currentwxw;
00220
00221
00222 }
00223
00224
00225 if (nTypeView->size()==1)
00226 {
00227 wxwindow1 = new wxMaracas_ViewerWidget(this, imagedata, (*nTypeView)[0], mvtkmprbasedata);
00228
00229 wxwindow1->ConfigureVTK();
00230 wxwindow = wxwindow1;
00231 }else if (nTypeView->size()==2) {
00232 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
00233 spliter->SetMinimumPaneSize(1);
00234 wxwindow1 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[0], mvtkmprbasedata);
00235 wxwindow2 = new wxMaracas_ViewerWidget(spliter, imagedata, (*nTypeView)[1], mvtkmprbasedata);
00236 wxwindow1->ConfigureVTK();
00237 wxwindow2->ConfigureVTK();
00238 spliter -> SplitVertically( wxwindow1 , wxwindow2 );
00239 wxwindow = spliter;
00240 }else if (nTypeView->size()==3)
00241 {
00242 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
00243 wxSplitterWindow *spliterA = new wxSplitterWindow( spliter , -1);
00244 spliter->SetMinimumPaneSize(1);
00245 spliterA->SetMinimumPaneSize(1);
00246 wxwindow1 = new wxMaracas_ViewerWidget(spliter , imagedata, (*nTypeView)[0], mvtkmprbasedata);
00247 wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1], mvtkmprbasedata);
00248 wxwindow3 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[2], mvtkmprbasedata);
00249 wxwindow1->ConfigureVTK();
00250 wxwindow2->ConfigureVTK();
00251 wxwindow3->ConfigureVTK();
00252 spliter -> SplitVertically( wxwindow1 , spliterA );
00253 spliterA-> SplitHorizontally( wxwindow2 , wxwindow3 );
00254 wxwindow = spliter;
00255 }else if (nTypeView->size()>=4){
00256 wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
00257 wxSplitterWindow *spliterA = new wxSplitterWindow( spliter , -1);
00258 wxSplitterWindow *spliterB = new wxSplitterWindow( spliter , -1);
00259 spliter->SetMinimumPaneSize(1);
00260 spliterA->SetMinimumPaneSize(1);
00261 spliterB->SetMinimumPaneSize(1);
00262 wxwindow1 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[0], mvtkmprbasedata);
00263 wxwindow2 = new wxMaracas_ViewerWidget(spliterA, imagedata, (*nTypeView)[1], mvtkmprbasedata);
00264 wxwindow3 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[2], mvtkmprbasedata);
00265 wxwindow4 = new wxMaracas_ViewerWidget(spliterB, imagedata, (*nTypeView)[3], mvtkmprbasedata);
00266 wxwindow1->ConfigureVTK();
00267 wxwindow2->ConfigureVTK();
00268 wxwindow3->ConfigureVTK();
00269 wxwindow4->ConfigureVTK();
00270 spliter -> SplitVertically( spliterA , spliterB );
00271 spliterA-> SplitHorizontally( wxwindow1 , wxwindow2 );
00272 spliterB-> SplitHorizontally( wxwindow3 , wxwindow4 );
00273 wxwindow = spliter;
00274 }
00275
00276
00277 sizer->Add( wxwindow , 1, wxGROW);
00278 sizer->Layout();
00279
00280
00281
00282
00283
00284 }
00285
00286
00287
00288 void wxMaracas_N_ViewersWidget::SetType(std::vector<int>* type){
00289 nTypeView = type;
00290 }
00291
00292
00293
00294
00295 void wxMaracas_N_ViewersWidget::SetImage( vtkImageData *image )
00296 {
00297 if (wxwindow1!=NULL) { wxwindow1->SetImage(image); }
00298 if (wxwindow2!=NULL) { wxwindow2->SetImage(image); }
00299 if (wxwindow3!=NULL) { wxwindow3->SetImage(image); }
00300 if (wxwindow4!=NULL) { wxwindow4->SetImage(image); }
00301 ConfigureVTK();
00302
00303 }
00304
00305
00306 void wxMaracas_N_ViewersWidget::ConfigureVTK()
00307 {
00308 if (wxwindow1!=NULL) { wxwindow1->ConfigureVTK(); }
00309 if (wxwindow2!=NULL) { wxwindow2->ConfigureVTK(); }
00310 if (wxwindow3!=NULL) { wxwindow3->ConfigureVTK(); }
00311 if (wxwindow4!=NULL) { wxwindow4->ConfigureVTK(); }
00312 }
00313
00314
00315 double wxMaracas_N_ViewersWidget :: GetX()
00316 {
00317 invariant();
00318 return mvtkmprbasedata->GetX();
00319
00320 }
00321
00322
00323 double wxMaracas_N_ViewersWidget :: GetY()
00324 {
00325 invariant();
00326 return mvtkmprbasedata->GetY();
00327
00328 }
00329
00330
00331
00332 double wxMaracas_N_ViewersWidget :: GetZ()
00333 {
00334 invariant();
00335 return mvtkmprbasedata->GetZ();
00336
00337 }
00338
00339 void wxMaracas_N_ViewersWidget :: invariant(){
00340 if(mvtkmprbasedata == 0){
00341 throw "The image has not been set in the viewer";
00342 }
00343 }
00344
00345 void wxMaracas_N_ViewersWidget::setColorTransferFunction(vtkColorTransferFunction* colortable){
00346 if (wxwindow1!=NULL) {
00347 wxwindow1->setColorTransferFunction(colortable);
00348 }
00349 if (wxwindow2!=NULL) {
00350 wxwindow2->setColorTransferFunction(colortable);
00351 }
00352 if (wxwindow3!=NULL) {
00353 wxwindow3->setColorTransferFunction(colortable);
00354 }
00355 if (wxwindow4!=NULL) {
00356 wxwindow4->setColorTransferFunction(colortable);
00357 }
00358 }
00359
00360 void wxMaracas_N_ViewersWidget::setWindowLevel(double level){
00361 if (wxwindow1!=NULL) {
00362 wxwindow1->setWindowLevel(level);
00363 }
00364 if (wxwindow2!=NULL) {
00365 wxwindow2->setWindowLevel(level);
00366 }
00367 if (wxwindow3!=NULL) {
00368 wxwindow3->setWindowLevel(level);
00369 }
00370 if (wxwindow4!=NULL) {
00371 wxwindow4->setWindowLevel(level);
00372 }
00373 }
00374 void wxMaracas_N_ViewersWidget::setColorLevel(double level){
00375 if (wxwindow1!=NULL) {
00376 wxwindow1->setColorLevel(level);
00377 }
00378 if (wxwindow2!=NULL) {
00379 wxwindow2->setColorLevel(level);
00380 }
00381 if (wxwindow3!=NULL) {
00382 wxwindow3->setColorLevel(level);
00383 }
00384 if (wxwindow4!=NULL) {
00385 wxwindow4->setColorLevel(level);
00386 }
00387 }
00388