wxVtkClipping3DViewVolCntrlPanel.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------------
00002 //RaC 03-2010 Divides in two panels thje last tab Surface/Volume
00003 //-------------------------------------------------------------------
00004 
00005 #include "wxVtkClipping3DViewVolCntrlPanel.h"
00006 #include "wx/colordlg.h"
00007 #include "vtkTriangleFilter.h"
00008 #include "vtkPolyDataConnectivityFilter.h"
00009 #include "vtkClosePolyData.h"
00010 #include "vtkSTLWriter.h"
00011 #include "HistogramDialog.h"
00012 #include "marDicomBase.h"
00013 
00014 wxVtkClipping3DViewVolCntrlPanel::wxVtkClipping3DViewVolCntrlPanel(wxWindow *parent, wxVtkClipping3DView *wxvtkclipping3Dview )
00015 : wxPanel(parent, -1)
00016 {
00017         wxPanel *panel  = this;
00018         _wxvtkclipping3Dview    = wxvtkclipping3Dview;
00019 
00020 
00021         wxCheckBox              *ckVolum                = new wxCheckBox(panel,-1,_T("Vol"));
00022         wxCheckBox              *ckBoxVolume    = new wxCheckBox(panel,-1,_T("Volume Box"));
00023 
00024         wxButton *btnVolumeFunctions    = new wxButton(panel,-1,_T("Read Volume Functions"));
00025 
00026         Connect(btnVolumeFunctions->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions       ); 
00027 
00028         ckBoxVolume->SetValue(false);
00029 
00030         Connect(ckVolum->GetId()                , wxEVT_COMMAND_CHECKBOX_CLICKED          , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnVisibleVolume                          );
00031         Connect(ckBoxVolume->GetId()    , wxEVT_COMMAND_CHECKBOX_CLICKED          , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnVisibleBoxVolume                       );
00032 
00033         wxFlexGridSizer *sizer   = new wxFlexGridSizer(1);
00034         wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20);
00035 
00036         sizerH0->Add( ckVolum                                                                   , 1, wxALL|wxEXPAND, 0);
00037         sizerH0->Add( new wxStaticText(panel, -1,_T("          "))      , 1, wxALL|wxEXPAND, 0);
00038         sizerH0->Add( ckBoxVolume                                                               , 1, wxALL|wxEXPAND, 0);
00039         sizerH0->Add( new wxStaticText(panel, -1,_T("          "))      , 1, wxALL|wxEXPAND, 0);
00040         sizerH0->Add( btnVolumeFunctions                                                , 1, wxALL|wxEXPAND, 0);
00041 
00042 
00043         sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2);
00044 
00045         panel->SetSize(300,60);
00046         panel->SetAutoLayout(true);
00047         panel->SetSizer(sizer);
00048         panel->Layout();
00049 
00050         panel->SetEventHandler((wxEvtHandler*)this);
00051 
00052 }
00053 //-------------------------------------------------------------------
00054 wxVtkClipping3DViewVolCntrlPanel::~wxVtkClipping3DViewVolCntrlPanel()
00055 {
00056 }
00057 //-------------------------------------------------------------------
00058 void wxVtkClipping3DViewVolCntrlPanel::Refresh()
00059 {
00060 }
00061 
00062 //-------------------------------------------------------------------
00063 void wxVtkClipping3DViewVolCntrlPanel::OnVisibleVolume(wxCommandEvent& event)
00064 {
00065         _wxvtkclipping3Dview->VisibleVolumeActor( event.IsChecked()  );
00066         _wxvtkclipping3Dview->Refresh();
00067 
00068         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
00069         _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00070 }
00071 
00072 //-------------------------------------------------------------------
00073 void wxVtkClipping3DViewVolCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event)
00074 {
00075         _wxvtkclipping3Dview->SetVisibleBoxVolume(event.IsChecked() );
00076         _wxvtkclipping3Dview->Refresh();
00077 }
00078 
00079 //EED 22 Fevrier 2007
00080 //-------------------------------------------------------------------
00081 void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event)
00082 {
00083         
00084         int /*i=0,*/ xi,yi,r,g,b;  // JPRx
00085         vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction();
00086         vtkPiecewiseFunction* tfun      = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction();
00087         std::vector<double>* gtf                = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValuesTransferenceFVector();
00088         std::vector<double>* itf                = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetIntensityValuesTransferenceFVector();
00089         std::vector<double>* greyctf    = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreyValueColorsOfColorTransferenceFVector();
00090         std::vector<double>* rctf               = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetRedColorsOfColorTransferenceFVector();
00091         std::vector<double>* gctf               = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetGreenColorsOfColorTransferenceFVector();
00092         std::vector<double>* bctf               = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetBlueColorsOfColorTransferenceFVector();
00093         vtkImageData *imagedata = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
00094 
00095         //use for update in the refresh
00096         /*
00097         vtkVolumeRayCastMapper* volumeMapper = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeMapper();
00098         vtkVolume* newvol       =this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetVolumeActor();
00099         */
00100 
00101         /*
00102         MMLR BORRAME 
00103         wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN);
00104         if (dialog.ShowModal() == wxID_OK)
00105         {
00106                 _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() );
00107                 
00108         
00109         }
00110         */
00111 
00112         HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1);
00113         // 
00114         // put in a method
00115         //
00116         int tfSize=gtf->size();
00117                 if(tfSize>0)
00118                 {
00119                         int i=0;
00120                         hDlg->erasePointsTransferenceFunction();
00121                         while(i<tfSize)
00122                         {
00123                                 double g=(*gtf)[i];
00124                                 double in=(*itf)[i];
00125                                 hDlg->addPointToTransferenceFunction(g,in*100);
00126                                 i++;
00127                         }
00128                         
00129                 }
00130 
00131         int ctfSize=rctf->size();
00132         if(ctfSize>0)
00133         {
00134                 int i=0;
00135                         while(i<ctfSize)
00136                         {
00137                                 double gr=(*greyctf)[i];
00138                                 double r=(*rctf)[i];
00139                                 double g=(*gctf)[i];
00140                                 double b=(*bctf)[i];
00141                                 hDlg->addColorPoint(gr,(int)(r*255),(int)(g*255),(int)(b*255));
00142                                 i++;
00143                         }
00144         }
00145         //setting variables if the user wants to do refresh
00146         hDlg->setCTF(ctfun);
00147         hDlg->setTF(tfun);
00148         //hDlg->setClipping3DView(_wxvtkclipping3Dview);
00149         /*
00150         hDlg->setVolume(newvol);
00151         hDlg->setVolumeMapper(volumeMapper);
00152         */
00153         //
00154         // when the user had changed the transference Function
00155         //
00156         if(hDlg->ShowModal()== wxID_OK )
00157         {       
00158                         // -- vtkPiecewiseFunction --
00159                         tfun->RemoveAllPoints();
00160                         gtf->clear();
00161                         itf->clear();
00162                 
00163                         int nTFPoints=hDlg->getSizeTransferenceFunction();
00164                         int i=0;
00165                         while(i<nTFPoints)
00166                         {
00167                                 hDlg->getTransferenceFunctionPoint(i,xi,yi);
00168                                 tfun->AddPoint( xi , yi/100.0 );
00169                                 gtf->push_back(xi);
00170                                 itf->push_back(yi/100.0);
00171                                 i++;
00172                         }       
00173                         // -- vtkColorTransferFunction  --
00174                         ctfun->RemoveAllPoints ();
00175                         //clean colors
00176                         rctf->clear();
00177                         gctf->clear();
00178                         bctf->clear();
00179                         greyctf->clear();
00180 
00181                         int nCTFpoints=hDlg->getSizeBarColor();
00182                         i=0;    
00183                         while(i<nCTFpoints)
00184                         {
00185                                 hDlg->getDataBarColorPoint(i,xi,r,g,b);
00186                                 ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
00187                                 rctf->push_back(r/255.0);
00188                                 gctf->push_back(g/255.0);
00189                                 bctf->push_back(b/255.0);
00190                                 greyctf->push_back(xi);
00191                                 i++;
00192                         }
00193                         //---------------------------------
00194                         // Refreshing and sending the event
00195                         //---------------------------------
00196                         //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
00197                         _wxvtkclipping3Dview->Refresh();
00198                         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
00199                         _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00200                         
00201                         /*
00202                         volumeMapper->Update();
00203                         newvol->Update();
00204                         */
00205         } else  {
00206                 if(hDlg->getRefreshed())
00207                 {
00208                         int i=0,size;
00209                         //--Transference Function----
00210                         tfun->RemoveAllPoints();
00211                         i=0;
00212                         size=gtf->size();
00213                         for(i=0;i<size;i++)
00214                         {
00215                                 double grey1=(*gtf)[i];
00216                                 double  in2=(*itf)[i];
00217                                 tfun->AddPoint( grey1 , in2 );
00218                         }
00219                         
00220                         // -- vtkColorTransferFunction  --
00221                         ctfun->RemoveAllPoints ();
00222                         
00223                         i=0;
00224                         size=greyctf->size();           
00225                         for(i=0;i<size;i++)
00226                         {
00227                                 double grey2=(*greyctf)[i];
00228                                 double red =(*rctf)[i];
00229                                 double green =(*gctf)[i];
00230                                 double blue = (*bctf)[i];
00231                                 ctfun->AddRGBPoint(grey2,red,green,blue);
00232                         }
00233                 
00234                         //---------------------------------
00235                         // Refreshing and sending the event
00236                         //---------------------------------
00237                         //_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions();
00238                         _wxvtkclipping3Dview->Refresh();
00239                         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
00240                         _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00241                         
00242                         /*
00243                         volumeMapper->Update();
00244                         newvol->Update();
00245                         */
00246                  }
00247                  
00248         }
00249         //destroy the dialog
00250         hDlg->Destroy();
00251 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1