00001
00002 #include "wxVtkClipping3DViewCntrlPanel.h"
00003 #include "wx/colordlg.h"
00004 #include "vtkTriangleFilter.h"
00005 #include "vtkPolyDataConnectivityFilter.h"
00006 #include "vtkClosePolyData.h"
00007 #include "vtkSTLWriter.h"
00008 #include "HistogramDialog.h"
00009 #include "marDicomBase.h"
00010
00011 wxVtkClipping3DViewCntrlPanel::wxVtkClipping3DViewCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
00012 : wxPanel(parent, -1)
00013 {
00014 wxPanel *panel = this;
00015 _wxvtkclipping3Dview = wxvtkclipping3Dview;
00016
00017
00018
00019
00020
00021 _surfA = new wxRadioButton(panel,-1,_T("A"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00022 _surfB = new wxRadioButton(panel,-1,_T("B"));
00023 _surfC = new wxRadioButton(panel,-1,_T("C"));
00024 _surfD = new wxRadioButton(panel,-1,_T("D"));
00025
00026
00027
00028
00029 wxCheckBox *ckBoxSurface = new wxCheckBox(panel,-1,_T("Surface Box"));
00030
00031
00032
00033
00034 _color = new wxButton(panel,-1,_T(""));
00035 _visible = new wxCheckBox(panel,-1,_T("Vis"));
00036 _opacity = new wxSlider(panel,-1,50,0,100, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_LABELS);
00037
00038 wxStaticText *isoValueTitle = new wxStaticText(panel,-1,_T("isoValue"));
00039 _isoValue = new wxSlider(panel,-1,2000,110,2000, wxDefaultPosition, wxSize(800,40), wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
00040
00041
00042 _wireFrameRep = new wxRadioButton(panel,-1,_T("WireFrame"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00043 _surfaceRep = new wxRadioButton(panel,-1,_T("Surface"));
00044
00045
00046 double range[2];
00047 vtkImageData *vtkimagedata = wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
00048 vtkimagedata->GetScalarRange( range );
00049 _isoValue->SetRange( (int)(range[1]*0.1) , (int)(range[1]) );
00050 _isoValue->SetValue( (int)(wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(0)) );
00051
00052
00053 _isoValue->SetTickFreq(25,0);
00054
00055 _isoValueSpin = new wxSlider(panel , -1,5,1,10,wxDefaultPosition , wxSize(25,45), wxSL_VERTICAL | wxSL_AUTOTICKS |wxSL_LEFT );
00056 _isoValueSpin->SetRange(1,8);
00057 _isoValueSpin->SetValue(5);
00058 Connect(_isoValueSpin->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin );
00059
00060 wxButton *btnSTL = new wxButton(panel,-1,_T("Create STL File"));
00061 wxButton *btnSaveRaw = new wxButton(panel,-1,_T("Save Raw Volume"));
00062
00063
00064
00065
00066
00067 Connect(btnSTL->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL );
00068 Connect(btnSaveRaw->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume );
00069
00070
00071
00072
00073
00074 wxButton *btnMeshVTKLoad = new wxButton(panel,-1,_T("Load Mesh"));
00075 Connect(btnMeshVTKLoad->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad );
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 ckBoxSurface->SetValue(false);
00092
00093
00094
00095
00096
00097 _color->SetSize(40,20);
00098 _opacity->SetSize(370,20);
00099
00100
00101
00102 _surfA->SetValue(true);
00103 _wireFrameRep->SetValue(false);
00104 _surfaceRep->SetValue(true);
00105 _visible->SetValue(false);
00106
00107
00108
00109
00110
00111
00112
00113
00114 Connect(_surfA->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
00115 Connect(_surfB->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
00116 Connect(_surfC->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
00117 Connect(_surfD->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnSurface );
00118 Connect(ckBoxSurface->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface );
00119
00120 Connect(_wireFrameRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
00121 Connect(_surfaceRep->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame );
00122
00123 Connect(_color->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnColor );
00124 Connect(_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnVisibleSurface );
00125 Connect(_opacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnOpacity );
00126
00127
00128
00129 Connect(_isoValue->GetId() , wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction) &wxVtkClipping3DViewCntrlPanel::OnIsoValue );
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
00141 wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
00142 wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20);
00143 wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(10);
00144 wxFlexGridSizer *sizerH3 = new wxFlexGridSizer(10);
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 sizerH0->Add( btnMeshVTKLoad , 1, wxALL|wxEXPAND, 0);
00157
00158
00159 sizerH1->Add( _surfA , 1, wxALL|wxEXPAND, 0);
00160 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00161 sizerH1->Add( _surfB , 1, wxALL|wxEXPAND, 0);
00162 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00163 sizerH1->Add( _surfC , 1, wxALL|wxEXPAND, 0);
00164 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00165 sizerH1->Add( _surfD , 1, wxALL|wxEXPAND, 0);
00166 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00167 sizerH1->Add( ckBoxSurface , 1, wxALL|wxEXPAND, 0);
00168 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00169 sizerH1->Add( btnSTL , 1, wxALL|wxEXPAND, 0);
00170 sizerH1->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00171 sizerH1->Add( btnSaveRaw , 1, wxALL|wxEXPAND, 0);
00172
00173
00174
00175 sizerH2->Add( _color , 1, wxALL|wxEXPAND, 0);
00176 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00177 sizerH2->Add( _visible , 1, wxALL|wxEXPAND, 0);
00178 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00179
00180
00181 sizerH2->Add( _wireFrameRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
00182 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00183 sizerH2->Add( _surfaceRep , 1,wxSHAPED | wxALIGN_CENTER_VERTICAL , 0);
00184 sizerH2->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
00185
00186 sizerH2->Add( _opacity , 1, wxALL|wxEXPAND, 0);
00187
00188
00189 sizerH3->Add( isoValueTitle , 1, wxALL|wxEXPAND, 0);
00190 sizerH3->Add( _isoValueSpin , 1, wxALL|wxEXPAND, 0);
00191 sizerH3->Add( _isoValue , 1, wxALL|wxEXPAND, 0);
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
00207 sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2);
00208 sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2);
00209 sizer->Add( sizerH3 , 1, wxALL|wxEXPAND, 2);
00210
00211
00212
00213
00214 panel->SetSize(300,60);
00215 panel->SetAutoLayout(true);
00216 panel->SetSizer(sizer);
00217 panel->Layout();
00218
00219 panel->SetEventHandler((wxEvtHandler*)this);
00220
00221 }
00222
00223 wxVtkClipping3DViewCntrlPanel::~wxVtkClipping3DViewCntrlPanel()
00224 {
00225 }
00226
00227 void wxVtkClipping3DViewCntrlPanel::Refresh()
00228 {
00229
00230
00231
00232
00233
00234
00235 }
00236
00237 int wxVtkClipping3DViewCntrlPanel::GetIdTissue()
00238 {
00239 int idTissue=-1;
00240 if (_surfA->GetValue()==true)
00241 {
00242 idTissue=0;
00243 }
00244 if (_surfB->GetValue()==true)
00245 {
00246 idTissue=1;
00247 }
00248 if (_surfC->GetValue()==true)
00249 {
00250 idTissue=2;
00251 }
00252 if (_surfD->GetValue()==true)
00253 {
00254 idTissue=3;
00255 }
00256
00257 return idTissue;
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 void wxVtkClipping3DViewCntrlPanel::OnSurface(wxCommandEvent& event)
00282 {
00283 int idTissue=GetIdTissue();
00284 if (idTissue!=-1)
00285 {
00286
00287 vtkActor *tmpActor;
00288 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
00289 double rgb[3];
00290 tmpActor->GetProperty()->GetColor( rgb );
00291 wxColour colour( (int)(rgb[0]*255) , (int)(rgb[1]*255) , (int)(rgb[2]*255) );
00292 _color->SetBackgroundColour(colour);
00293
00294
00295 _visible->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVisibleTissue(idTissue));
00296
00297
00298 _opacity->SetValue( (int)(tmpActor->GetProperty()->GetOpacity()*100) );
00299
00300
00301 _surfaceRep->SetValue(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
00302 _wireFrameRep->SetValue(!_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRepresentationType(idTissue));
00303
00304
00305 int isoValue= (int)(_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIsovalue(idTissue));
00306 _isoValue->SetValue(isoValue);
00307 }
00308 }
00309
00310
00311
00312 void wxVtkClipping3DViewCntrlPanel::OnRepresentationSurfaceWireFrame(wxCommandEvent& event)
00313 {
00314 int idTissue=GetIdTissue();
00315 if (idTissue!=-1)
00316 {
00317 _wxvtkclipping3Dview->SetRepSurfaceWireFrame(idTissue , _surfaceRep->GetValue() );
00318
00319 _wxvtkclipping3Dview->Refresh();
00320
00321 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00322 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00323
00324 }
00325 }
00326
00327
00328 void wxVtkClipping3DViewCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
00329 {
00330 _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked() );
00331 _wxvtkclipping3Dview->Refresh();
00332
00333 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00334 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00335 }
00336
00337 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxSurface(wxCommandEvent& event)
00338 {
00339 _wxvtkclipping3Dview->SetVisibleBoxSurface(event.IsChecked() );
00340 _wxvtkclipping3Dview->Refresh();
00341 }
00342
00343 void wxVtkClipping3DViewCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
00344 {
00345 _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
00346 _wxvtkclipping3Dview->Refresh();
00347 }
00348
00349 void wxVtkClipping3DViewCntrlPanel::OnColor(wxCommandEvent& event)
00350 {
00351 int idTissue=GetIdTissue();
00352 if (idTissue!=-1)
00353 {
00354
00355 wxColourDialog dlgColour(this);
00356
00357 if( dlgColour.ShowModal( ) == wxID_OK )
00358 {
00359 vtkActor *tmpActor;
00360 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
00361 float r=dlgColour.GetColourData().GetColour().Red()/255;
00362 float g=dlgColour.GetColourData().GetColour().Green()/255;
00363 float b=dlgColour.GetColourData().GetColour().Blue()/255;
00364 tmpActor->GetProperty()->SetColor( r , g , b );
00365 _color->SetBackgroundColour(dlgColour.GetColourData().GetColour());
00366
00367 _wxvtkclipping3Dview->Refresh();
00368
00369 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00370 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00371 }
00372 }
00373 }
00374
00375 void wxVtkClipping3DViewCntrlPanel::OnVisibleSurface(wxCommandEvent& event)
00376 {
00377 int idTissue=GetIdTissue();
00378 if (idTissue!=-1)
00379 {
00380 _wxvtkclipping3Dview->VisibleActor(idTissue, _visible->GetValue());
00381
00382 _wxvtkclipping3Dview->Refresh();
00383
00384 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00385 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00386 }
00387 }
00388
00389 void wxVtkClipping3DViewCntrlPanel::OnOpacity(wxScrollEvent& event)
00390 {
00391 int idTissue=GetIdTissue();
00392 if (idTissue!=-1)
00393 {
00394 vtkActor *tmpActor;
00395 tmpActor = _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueActor(idTissue);
00396 float opacity=_opacity->GetValue();
00397 tmpActor->GetProperty()->SetOpacity( opacity/100 );
00398
00399 _wxvtkclipping3Dview->Refresh();
00400
00401 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00402 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00403 }
00404 }
00405
00406
00407 void wxVtkClipping3DViewCntrlPanel::OnIsoValueSpin(wxScrollEvent& event)
00408 {
00409 int value = _isoValue->GetValue();
00410 int delta= (int)pow( (double)4 ,(double) _isoValueSpin->GetValue() );
00411 int min=value - delta/2;
00412 int max=value + delta/2;
00413 if (min<0)
00414 {
00415 min=0;
00416 max=delta;
00417 }
00418 _isoValue->SetRange(min,max);
00419 }
00420
00421
00422
00423 void wxVtkClipping3DViewCntrlPanel::OnIsoValue(wxScrollEvent& event)
00424 {
00425 wxBusyCursor wait;
00426
00427 int idTissue=GetIdTissue();
00428 if (idTissue!=-1)
00429 {
00430 int isoValue=_isoValue->GetValue();
00431 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->SetIsovalue(idTissue,isoValue);
00432
00433
00434
00435 _wxvtkclipping3Dview->Refresh();
00436
00437 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00438 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00439 }
00440
00441 }
00442
00443 void wxVtkClipping3DViewCntrlPanel::OnBtnCreateFileSTL(wxCommandEvent& event)
00444 {
00445
00446 int idTissue=GetIdTissue();
00447 if (idTissue==-1)
00448 {
00449 idTissue=0;
00450 }
00451
00452
00453 wxString dirSTL = wxGetHomeDir( ) ;
00454 wxFileDialog dialog( this, _T("Choose a directory..."), dirSTL , _T(""), _T("*.*"), wxSAVE );
00455
00456 if( dialog.ShowModal( ) == wxID_OK )
00457 {
00458
00459
00460
00461
00462
00463
00464 std::string prefix = (const char*) (dialog.GetPath().mb_str() );
00465 std::string filename;
00466
00467
00468
00469 vtkTriangleFilter *filtro = vtkTriangleFilter::New();
00470
00471
00472 filtro->SetInput( this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTissueClipper(idTissue)->GetOutput() );
00473 vtkPolyDataConnectivityFilter *pdcf = vtkPolyDataConnectivityFilter::New();
00474 pdcf->SetInput( filtro->GetOutput() );
00475 vtkClosePolyData *cpd = vtkClosePolyData::New();
00476 cpd->SetInput( pdcf->GetOutput() );
00477
00478
00479 cpd->Update();
00480 vtkSTLWriter *writer = vtkSTLWriter::New();
00481 writer->SetInput( cpd->GetOutput() );
00482 filename =prefix;
00483 writer->SetFileName(filename.c_str());
00484 writer->SetFileTypeToASCII();
00485 writer->Write();
00486 writer->Delete();
00487
00488
00489 filtro->Delete();
00490 cpd->Delete();
00491 pdcf->Delete();
00492 }
00493
00494 }
00495
00496
00497
00498 void wxVtkClipping3DViewCntrlPanel::OnBtnSaveRawVolume(wxCommandEvent& event)
00499 {
00500 wxFileDialog dialog(this, _T("Choose a file"), _T(""), _T(""), _T("*.maracas"), wxSAVE );
00501 if (dialog.ShowModal() == wxID_OK)
00502 {
00503 std::string directory = (const char*) (dialog.GetDirectory().mb_str() );
00504 std::string filename = (const char*) (dialog.GetFilename().mb_str() );
00505 float rescalaSlope = 1;
00506 float rescalaIntercept = 0;
00507 vtkMPRBaseData *vtkmprbasedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData();
00508 vtkImageData *vtkimagedata = vtkmprbasedata->GetImageData();
00509 int dim[3];
00510 vtkimagedata->GetDimensions(dim);
00511 int voi[6];
00512 voi[0]=0;
00513 voi[1]=dim[0];
00514 voi[2]=0;
00515 voi[3]=dim[1];
00516 voi[4]=0;
00517 voi[5]=dim[2];
00518
00519 marRAW2Files marraw2;
00520 marraw2.saveVolume(directory,filename,vtkimagedata,voi,rescalaSlope,rescalaIntercept);
00521 }
00522 }
00523
00524
00525
00526 void wxVtkClipping3DViewCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
00527 {
00528
00529 int xi,yi,r,g,b;
00530 vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
00531 vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
00532 std::vector<double>* gtf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
00533 std::vector<double>* itf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
00534 std::vector<double>* greyctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
00535 std::vector<double>* rctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
00536 std::vector<double>* gctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
00537 std::vector<double>* bctf = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
00538 vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557 HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
00558
00559
00560
00561 int tfSize=gtf->size();
00562 if(tfSize>0)
00563 {
00564 int i=0;
00565 hDlg->erasePointsTransferenceFunction();
00566 while(i<tfSize)
00567 {
00568 double g=(*gtf)[i];
00569 double in=(*itf)[i];
00570 hDlg->addPointToTransferenceFunction(g,in*100);
00571 i++;
00572 }
00573
00574 }
00575
00576 int ctfSize=rctf->size();
00577 if(ctfSize>0)
00578 {
00579 int i=0;
00580 while(i<ctfSize)
00581 {
00582 double gr=(*greyctf)[i];
00583 double r=(*rctf)[i];
00584 double g=(*gctf)[i];
00585 double b=(*bctf)[i];
00586 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
00587 i++;
00588 }
00589 }
00590
00591 hDlg->setCTF(ctfun);
00592 hDlg->setTF(tfun);
00593
00594
00595
00596
00597
00598
00599
00600
00601 if(hDlg->ShowModal()== wxID_OK )
00602 {
00603
00604 tfun->RemoveAllPoints();
00605 gtf->clear();
00606 itf->clear();
00607
00608 int nTFPoints=hDlg->getSizeTransferenceFunction();
00609 int i=0;
00610 while(i<nTFPoints)
00611 {
00612 hDlg->getTransferenceFunctionPoint(i,xi,yi);
00613 tfun->AddPoint( xi , yi/100.0 );
00614 gtf->push_back(xi);
00615 itf->push_back(yi/100.0);
00616 i++;
00617 }
00618
00619 ctfun->RemoveAllPoints ();
00620
00621 rctf->clear();
00622 gctf->clear();
00623 bctf->clear();
00624 greyctf->clear();
00625
00626 int nCTFpoints=hDlg->getSizeBarColor();
00627 i=0;
00628 while(i<nCTFpoints)
00629 {
00630 hDlg->getDataBarColorPoint(i,xi,r,g,b);
00631 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
00632 rctf->push_back(r/255.0);
00633 gctf->push_back(g/255.0);
00634 bctf->push_back(b/255.0);
00635 greyctf->push_back(xi);
00636 i++;
00637 }
00638
00639
00640
00641
00642 _wxvtkclipping3Dview->Refresh();
00643 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00644 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00645
00646
00647
00648
00649
00650 } else {
00651 if(hDlg->getRefreshed())
00652 {
00653 int i=0,size;
00654
00655 tfun->RemoveAllPoints();
00656 i=0;
00657 size=gtf->size();
00658 for(i=0;i<size;i++)
00659 {
00660 double grey1=(*gtf)[i];
00661 double in2=(*itf)[i];
00662 tfun->AddPoint( grey1 , in2 );
00663 }
00664
00665
00666 ctfun->RemoveAllPoints ();
00667
00668 i=0;
00669 size=greyctf->size();
00670 for(i=0;i<size;i++)
00671 {
00672 double grey2=(*greyctf)[i];
00673 double red =(*rctf)[i];
00674 double green =(*gctf)[i];
00675 double blue = (*bctf)[i];
00676 ctfun->AddRGBPoint(grey2,red,green,blue);
00677 }
00678
00679
00680
00681
00682
00683 _wxvtkclipping3Dview->Refresh();
00684 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00685 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00686
00687
00688
00689
00690
00691 }
00692
00693 }
00694
00695 hDlg->Destroy();
00696 }
00697
00698
00699
00700 void wxVtkClipping3DViewCntrlPanel::OnBtnMeshVTKLoad(wxCommandEvent& event)
00701 {
00702 wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.vtk"), wxOPEN);
00703 if (dialog.ShowModal() == wxID_OK)
00704 {
00705 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadMeshVTK( (char *)dialog.GetPath().c_str() );
00706 _wxvtkclipping3Dview->Refresh();
00707 wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);
00708 _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00709 }
00710 }
00711