wxVtkClipping3DViewCntrlPanel.cxx

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

Generated on Wed Jul 29 16:35:31 2009 for creaMaracasVisu_lib by  doxygen 1.5.3