wxPanelCuttingImageData.cxx

Go to the documentation of this file.
00001 
00002 #include "wxPanelCuttingImageData.h"
00003 
00004 //-------------------------------------------------------------------
00005 
00006 #include <vtkProperty.h>
00007 #include <vtkTextProperty.h>
00008 #include <vtkProperty2D.h>
00009 //-------------------------------------------------------------------
00010 //-------------------------------------------------------------------
00011 
00012 wxPanelCuttingImageData::wxPanelCuttingImageData (wxWindow *parent)
00013 : wxPanel( parent, -1)
00014 {
00015         _imageData=NULL;
00016         _histogrammeVector=NULL;
00017         _wxvtk3Dbaseview=NULL;
00018         _wxvtkbaseView=NULL;
00019         CreateInterface();
00020         CreateModel();
00021         Create3DViewObjects();
00022 }
00023 
00024 //-------------------------------------------------------------------
00025 wxPanelCuttingImageData::~wxPanelCuttingImageData()
00026 {
00027 
00028 
00029         delete _modelCube;      
00030         delete _modelSphere;    
00031         delete _modelCylinder;  
00032         _vtkcube                -> Delete();    
00033         _vtksphere              -> Delete();    
00034         _vtkcylinder    -> Delete();    
00035         _cubeMapper             -> Delete();    
00036         _sphereMapper   -> Delete();    
00037         _cylinderMapper -> Delete();    
00038         _cubeActor              -> Delete();    
00039         _sphereActor    -> Delete();    
00040         _cylinderActor  -> Delete();    
00041 //      _xyplot->RemoveAllInputs();     
00042         _xyplot                 -> Delete();    
00043         _histogrammeVector->Delete();   
00044         _renplotter->Delete();
00045         
00046         if(_wxvtkbaseView!=NULL){
00047                 delete _wxvtkbaseView;
00048         }
00049         //delete _vtkclipping3Ddataviewer;
00050         
00051 
00052         //fclose(file);
00053 
00054 }
00055 
00056 //-------------------------------------------------------------------
00057 void wxPanelCuttingImageData::RemoveActors()
00058 {
00059         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
00060 }
00061 
00062 
00063 //-------------------------------------------------------------------
00064 void wxPanelCuttingImageData::SetWxVtk3DBaseView( wxVtk3DBaseView * wxvtk3Dbaseview )
00065 {
00066         _wxvtk3Dbaseview=wxvtk3Dbaseview;
00067 }
00068 
00069 //-------------------------------------------------------------------
00070 
00071 void wxPanelCuttingImageData::SetVtkClipping3DDataViewer( vtkClipping3DDataViewer *vtkclipping3Ddataviewer )
00072 {
00073         this->_vtkclipping3Ddataviewer = vtkclipping3Ddataviewer;
00074 }
00075 
00076 //-------------------------------------------------------------------
00077 void wxPanelCuttingImageData::Create3DViewObjects()
00078 {
00079         // Sphere
00080         _vtksphere              = vtkSphereSource::New();
00081         _vtksphere->SetThetaResolution (20);
00082         _vtksphere->SetPhiResolution (20);
00083         _sphereMapper   = vtkPolyDataMapper::New();
00084         _sphereMapper->SetInput( _vtksphere->GetOutput() );
00085         _sphereActor    = vtkActor::New();
00086         _sphereActor->SetMapper(_sphereMapper);
00087         _sphereActor->SetOrigin(0, 0, 0);
00088         _sphereActor->SetPosition(0, 0, 0);
00089         _sphereActor->GetProperty()->SetColor(1, 0, 0);
00090         _sphereActor->SetUserTransform( _modelSphere->GetVtkTransform() );      
00091 
00092         // cube
00093         _vtkcube                = vtkCubeSource::New();
00094         _vtkcube->SetXLength (1);
00095         _vtkcube->SetYLength (1);
00096         _vtkcube->SetZLength (1);
00097         _cubeMapper             = vtkPolyDataMapper::New();
00098         _cubeMapper->SetInput( _vtkcube->GetOutput() );
00099         _cubeActor              = vtkActor::New();
00100         _cubeActor->SetMapper(_cubeMapper);
00101         _cubeActor->SetOrigin(0, 0, 0);
00102         _cubeActor->SetPosition(0, 0, 0);
00103         _cubeActor->GetProperty()->SetColor(1, 0, 0);
00104         _cubeActor->SetUserTransform( _modelCube->GetVtkTransform() );          
00105 
00106         // cylinder
00107         _vtkcylinder    = vtkCylinderSource::New();
00108         _vtkcylinder->SetResolution(20);
00109         _cylinderMapper = vtkPolyDataMapper::New();
00110         _cylinderMapper->SetInput( _vtkcylinder->GetOutput() );
00111         _cylinderActor  = vtkActor::New();
00112         _cylinderActor->SetMapper(_cylinderMapper);
00113         _cylinderActor->SetOrigin(0, 0, 0);
00114         _cylinderActor->SetPosition(0, 0, 0);
00115         _cylinderActor->GetProperty()->SetColor(1, 0, 0);
00116         _cylinderActor->SetUserTransform( _modelCylinder->GetVtkTransform() );          
00117 
00118 
00119 }
00120 
00121 //-------------------------------------------------------------------
00122 void wxPanelCuttingImageData::CreateModel()
00123 {
00124         _modelCube              = new figureCuttingCubeModel();
00125         _modelSphere    = new figureCuttingSphereModel();
00126         _modelCylinder  = new figureCuttingCylinderModel();
00127 
00128 //      _modelCube->SetVtkTransform( _modelCube->GetVtkTransform()                      );
00129 //      _modelSphere->SetVtkTransform( _modelSphere->GetVtkTransform()          );
00130 //      _modelCylinder->SetVtkTransform( _modelCylinder->GetVtkTransform()      );
00131 }
00132 
00133 //-------------------------------------------------------------------
00134 
00135 void wxPanelCuttingImageData::InitHistogramme()
00136 {
00137         double rangeA[2];
00138         if (_imageData==NULL)
00139         {
00140                 rangeA[1]=1;
00141         } else {
00142                 _imageData->GetScalarRange(rangeA);
00143         }
00144         _xyplot->RemoveAllInputs();
00145 /*
00146         if ( _histogrammeVector!=NULL )
00147         {
00148                 _histogrammeVector -> Delete();
00149         }
00150 */
00151         _histogrammeVector =  vtkImageData::New();
00152     _histogrammeVector -> SetDimensions ( (int)(rangeA[1]),1,1 );
00153     _histogrammeVector -> SetScalarTypeToUnsignedShort();
00154     _histogrammeVector -> AllocateScalars();    
00155     _histogrammeVector -> Update(); 
00156         
00157         unsigned short *p_vol = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
00158         int i,size = (int) (rangeA[1]);
00159         for (i=0; i < size; i++)
00160         {
00161                 *p_vol=0;
00162                 p_vol++;
00163         }
00164         _xyplot->SetXRange(0, rangeA[1]);
00165         _xyplot->SetYRange(0, 10);
00166         _xyplot->AddInput( _histogrammeVector );
00167 }
00168 
00169 //-------------------------------------------------------------------
00170 wxWindow *wxPanelCuttingImageData::CreatePlotHistogrammeInterface()
00171 {
00172         _xyplot = vtkXYPlotActor::New();
00173         InitHistogramme();
00174         _xyplot->GetPositionCoordinate()->SetValue(0.00, 0.00, 0);
00175         _xyplot->GetPosition2Coordinate()->SetValue(1.0, 1.00, 0); //relative to Position
00176         _xyplot->SetXValuesToArcLength();
00177         _xyplot->SetNumberOfXLabels(6);
00178 
00179         _xyplot->SetTitle("Histogramme");
00180         _xyplot->SetXTitle("Gray level");
00181         _xyplot->SetYTitle("Occurrences ");
00182         _xyplot->GetProperty()->SetColor(1, 0, 0);
00183         _xyplot->GetProperty()->SetPointSize(2);
00184         vtkTextProperty *tprop = _xyplot->GetTitleTextProperty();
00185         tprop->SetColor( 1,0,1 );
00186         tprop->BoldOff ();
00187         _xyplot->SetAxisTitleTextProperty(tprop);
00188         _xyplot->SetAxisLabelTextProperty(tprop);
00189         _xyplot->PlotPointsOn();
00190         _xyplot->GetProperty()->SetPointSize(3);
00191 
00192         _wxvtkbaseView = new wxVtkBaseView(this);
00193         _wxvtkbaseView->Configure();
00194 
00195         _renplotter = vtkRenderer::New();
00196         vtkRenderWindow *renWin = _wxvtkbaseView->GetRenWin();
00197         renWin->AddRenderer( _renplotter );
00198         _renplotter->AddActor2D( _xyplot );
00199 
00200         return _wxvtkbaseView->GetWxVTKRenderWindowInteractor();
00201 }
00202 
00203 //-------------------------------------------------------------------
00204 
00205 void wxPanelCuttingImageData::CreateInterface()
00206 {
00207         SetSize(300,500);
00208         wxBoxSizer      *topsizer               = new wxBoxSizer(wxVERTICAL);   // Principal sizer
00209 
00210         wxBoxSizer              *sizerH0        = new wxBoxSizer(wxHORIZONTAL   );  // type of segmentation figure
00211         wxBoxSizer          *sizerH2    = new wxBoxSizer(wxHORIZONTAL   );      // scale
00212         wxBoxSizer              *sizerH3        = new wxBoxSizer(wxHORIZONTAL   );      // rotation
00213         wxBoxSizer              *sizerH4        = new wxBoxSizer(wxHORIZONTAL   );  // intern extern
00214         wxBoxSizer              *sizerH5        = new wxBoxSizer(wxHORIZONTAL   );  // Isovalue
00215         wxBoxSizer              *sizerH6        = new wxBoxSizer(wxHORIZONTAL   );  // Buttons
00216         wxFlexGridSizer *sizerH7        = new wxFlexGridSizer(2                 );  // Volumic information 
00217 
00218         
00219         _typeFig        = new wxChoice(this,-1);
00220         _opacityFig     = new wxSlider(this,-1,100,0,100, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00221 
00222         _scaleX         = new wxSlider(this,-1,6,0,500  , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00223         _scaleY         = new wxSlider(this,-1,20,0,500 , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00224         _scaleZ         = new wxSlider(this,-1,7,0,500  , wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00225 
00226         _rotationX      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00227         _rotationY      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00228         _rotationZ      = new wxSlider(this,-1,0,-360,360, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00229 
00230         _volIntern              = new wxRadioButton(this,-1, _T("Volume intern " ));
00231         _volExtern              = new wxRadioButton(this,-1, _T("Volume extern " ));
00232 
00233         _histogrammeAccumulated = new wxCheckBox(this,-1,_T("Histogramme accumulated"));
00234 
00235         _isoValue                               = new wxSlider(this,-1, 200, 0,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00236         _valueBeforeIsoValue    = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00237         _valueAfterIsoValue             = new wxSlider(this,-1,-1,-1,2000, wxDefaultPosition, wxSize(200,45), wxSL_HORIZONTAL | wxSL_LABELS);
00238 
00239         wxButton *btnExtract    = new wxButton(this, -1,_T("Extract"));
00240 
00241         _infoToVo       = new wxStaticText(this,-1,_T("########################"));
00242         _infoSuVoA      = new wxStaticText(this,-1,_T("############"));
00243         _infoSuVo       = new wxStaticText(this,-1,_T("############"));
00244         _infoPixLe      = new wxStaticText(this,-1,_T("############"));
00245         _infoPixHi      = new wxStaticText(this,-1,_T("############"));
00246 
00247 
00248         
00249 
00250         _typeFig->Append(_T("Cylindre"));
00251         _typeFig->Append(_T("Cube"));
00252         _typeFig->Append(_T("Sphere"));
00253         _typeFig->SetSelection(0);
00254         _volIntern->SetValue(true);
00255 
00256         Connect(_typeFig->GetId()                               , wxEVT_COMMAND_CHOICE_SELECTED         , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTypeFig ); 
00257 
00258         Connect(_opacityFig->GetId()                    , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnOpacityFig ); 
00259         Connect(_rotationX->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00260         Connect(_rotationY->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00261         Connect(_rotationZ->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00262         Connect(_scaleX->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00263         Connect(_scaleY->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00264         Connect(_scaleZ->GetId()                                , wxEVT_COMMAND_SLIDER_UPDATED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnTransform ); 
00265         Connect(btnExtract->GetId()                             , wxEVT_COMMAND_BUTTON_CLICKED          , (wxObjectEventFunction) &wxPanelCuttingImageData::OnExtract   ); 
00266          
00267 
00268 //      wxStaticText *text=new wxStaticText(this,-1, " ");
00269 
00270         sizerH0 -> Add( new wxStaticText(this,-1, _T("Fig. Type:   "),wxDefaultPosition, wxSize(50,20)) ,1,wxALL  ,0);
00271         sizerH0 -> Add( _typeFig                ,1,wxALL  ,0);
00272         sizerH0 -> Add( _opacityFig             ,1,wxALL|wxEXPAND  ,0);
00273 
00274         sizerH2 -> Add( new wxStaticText(this,-1,_T("Scale :   "))              ,1,wxALL  ,0);
00275         sizerH2 -> Add( _scaleX         ,1,wxALL | wxEXPAND ,0 );
00276         sizerH2 -> Add( _scaleY         ,1,wxALL | wxEXPAND ,0 );
00277         sizerH2 -> Add( _scaleZ         ,1,wxALL | wxEXPAND ,0 );
00278 
00279         sizerH3 -> Add( new wxStaticText(this,-1,_T("Rotation :   "))   ,1,wxALL  ,0);
00280         sizerH3 -> Add( _rotationX      ,1,wxALL | wxEXPAND ,0 );
00281         sizerH3 -> Add( _rotationY      ,1,wxALL | wxEXPAND ,0 );
00282         sizerH3 -> Add( _rotationZ      ,1,wxALL | wxEXPAND ,0 );
00283 
00284 
00285         sizerH4 -> Add( new wxStaticText(this,-1,_T("Intern / Extern :   "))    ,1,wxALL  ,0);
00286         sizerH4 -> Add( _volIntern                                              ,1,wxALL  ,0);
00287         sizerH4 -> Add( new wxStaticText(this,-1, _T(" "))      ,1,wxALL  ,0);
00288         sizerH4 -> Add( _volExtern                                              ,1,wxALL  ,0);
00289 
00290         sizerH5 -> Add( new wxStaticText(this,-1,_T("Isovalue   "))     ,1,wxALL  ,0);
00291         sizerH5 -> Add( _isoValue                                               ,1,wxALL | wxEXPAND ,0 );
00292         sizerH5 -> Add( _valueBeforeIsoValue                    ,1,wxALL | wxEXPAND ,0 );
00293         sizerH5 -> Add( _valueAfterIsoValue                             ,1,wxALL | wxEXPAND ,0 );
00294 
00295         sizerH6 -> Add( new wxStaticText(this,-1, _T(" "))              ,1,wxALL  ,0);
00296         sizerH6 -> Add( btnExtract      ,1,wxALL  ,0);
00297 
00298         sizerH7 -> Add( new wxStaticText(this,-1,_T("Total Volume: "), wxDefaultPosition, wxSize(200,12))                       , 1 , wxALL  ,0);
00299         sizerH7 -> Add( _infoToVo                                                                               , 1 , wxALL  ,0);
00300         sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume:   "), wxDefaultPosition, wxSize(200,12) )               , 1 , wxALL  ,0);
00301         sizerH7 -> Add( _infoSuVo                                                                               , 1 , wxALL  ,0);
00302         sizerH7 -> Add( new wxStaticText(this,-1,_T("SubVolume (ana.): "), wxDefaultPosition, wxSize(200,12))   , 1 , wxALL  ,0);
00303         sizerH7 -> Add( _infoSuVoA                                                                              , 1 , wxALL  ,0);
00304         sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix < isovalue:   ") , wxDefaultPosition, wxSize(200,12))  , 1 , wxALL  ,0);
00305         sizerH7 -> Add( _infoPixLe                                                                              , 1 , wxALL  ,0);
00306         sizerH7 -> Add( new wxStaticText(this,-1,_T("Pix > isovalue: "), wxDefaultPosition, wxSize(200,12))     , 1 , wxALL  ,0);
00307         sizerH7 -> Add( _infoPixHi                                                                              , 1 , wxALL  ,0);
00308 //      sizerH7 -> SetMinSize(300, 120);
00309 
00310         // Figure type
00311         topsizer -> Add( sizerH0 ,1,wxALL|wxEXPAND  ,0);
00312 
00313         // Scale
00314         topsizer -> Add( sizerH2 ,1,wxALL|wxEXPAND  ,0);
00315 
00316         // Rotation
00317         topsizer -> Add( sizerH3 ,1,wxALL|wxEXPAND  ,0);
00318 
00319         // Intern / Extern
00320         topsizer -> Add( sizerH4 ,1,wxALL  ,0);
00321 
00322 
00323         // Isovalue limite
00324         topsizer -> Add( sizerH5 ,1,wxALL |wxEXPAND ,0);
00325 
00326         // btn Extraction
00327         topsizer -> Add( sizerH6        , 1 , wxALL  ,0);
00328 
00329         // Histograme
00330         topsizer -> Add( _histogrammeAccumulated ,1,  wxALL  ,0);
00331 
00332         // Volumic information
00333         topsizer -> Add( sizerH7                                , 1 , wxALL|wxEXPAND   ,0);
00334 
00335 
00336 
00337 //    wxBoxSizer *sizerHor = new wxBoxSizer(wxHORIZONTAL);
00338     wxBoxSizer *sizerHor = new wxBoxSizer(wxVERTICAL);
00339         sizerHor -> Add( topsizer                               , 1 , wxALL | wxEXPAND  ,0);
00340 
00341 
00342         wxWindow *panelPlotHistogramme = CreatePlotHistogrammeInterface();
00343         sizerHor -> Add( panelPlotHistogramme   , 1 , wxGROW  ,0);
00344 
00345 
00346         this->SetAutoLayout(true);
00347         this->SetSizer( sizerHor );      
00348         this->Layout(); 
00349 //EEDxx2.4
00350 //      this->FitInside();
00351 }
00352 
00353 //-------------------------------------------------------------------
00354 
00355 void wxPanelCuttingImageData::OnExtract(wxCommandEvent& event)
00356 {
00357         wxBusyCursor wait;
00358 
00359         bool                    inside;
00360         bool                    volInt, volExt;
00361         int                             xx,yy,zz;
00362         unsigned short  *pOrg;
00363         unsigned short  *p_histogramme;
00364         int                             dim[3];
00365         double                  spc[3];
00366         long int                contAfter = 0;
00367         long int                contBefor = 0;
00368 
00369         double min=999999999;
00370         double max=-999999999;
00371 
00372         volExt=_volExtern->GetValue();
00373         volInt=_volIntern->GetValue();
00374         int isoValue                = _isoValue->GetValue();
00375         int valueBeforeIsoValue = _valueBeforeIsoValue->GetValue(); 
00376         int valueAfterIsoValue  = _valueAfterIsoValue ->GetValue(); 
00377 
00378         InitHistogramme();
00379         p_histogramme = (unsigned short*)_histogrammeVector->GetScalarPointer(0,0,0);
00380 
00381         _imageData->GetDimensions(dim);    
00382         _imageData->GetSpacing(spc);    
00383         _actualCuttingModel->CalculeInversMatrix();
00384 
00385         for (xx=0;xx<dim[0]; xx++)
00386         {
00387                 for (yy=0;yy<dim[1]; yy++)
00388                 {
00389                         for (zz=0;zz<dim[2];zz++)
00390                         {
00391                                 inside=_actualCuttingModel->IfPointInside(xx,yy,zz);
00392                                 if (  ((inside==true)&&(volInt==true)) || ((!inside==true)&&(volExt==true)) )
00393                                 {
00394                                         pOrg=(unsigned short*)_imageData->GetScalarPointer (xx,yy,zz); 
00395 
00396                                         if ((*pOrg)<isoValue)
00397                                         {
00398                                                 contBefor++;
00399                                                 if (valueBeforeIsoValue!=-1)
00400                                                 {
00401                                                         *pOrg=valueBeforeIsoValue;
00402                                                 }
00403                                         } else {
00404                                                 contAfter++;
00405                                                 if (valueAfterIsoValue!=-1)
00406                                                 {
00407                                                         *pOrg=valueAfterIsoValue;
00408                                                 } // if
00409                                         } // if isovalue
00410 
00411                                         p_histogramme[*pOrg]++;
00412                                         if (*pOrg<min) min=*pOrg; 
00413                                         if (*pOrg>max) max=*pOrg; 
00414                                 } // if inside
00415                         } // for zz
00416                 } // for yy
00417         } // for xx
00418 
00419 
00420         // Information
00421         wxString infoToVo;
00422         wxString infoSuVo;
00423         wxString infoSuVoA;
00424         wxString infoPixLe;
00425         wxString infoPixHi;
00426 
00427         double volumeUnit = spc[0]*spc[1]*spc[2];
00428         long int totalSubVolume = contBefor + contAfter;
00429         double contBeforPorc    = 100*(double)contBefor/(double)totalSubVolume;
00430         double contAfterPorc    = 100*(double)contAfter/(double)totalSubVolume;
00431         infoToVo.Printf(_T("%dx%dx%d = %d"),dim[0],dim[1],dim[2], dim[0]*dim[1]*dim[2] );
00432         infoSuVo.Printf(_T("%ld") , totalSubVolume);
00433         infoSuVoA.Printf(_T("%.2f"), _actualCuttingModel->GetTheoricVolume() );
00434         infoPixLe.Printf(_T("%ld pix.   (%.2f %s)  -  %.2f mm^3"),contBefor, contBeforPorc ,_T("%"),contBefor*volumeUnit);
00435         infoPixHi.Printf(_T("%ld pix.   (%.2f %s)  -  %.2f mm^3"),contAfter, contAfterPorc ,_T("%"),contAfter*volumeUnit);
00436 
00437         _infoToVo->SetLabel(infoToVo);
00438         _infoSuVo->SetLabel(infoSuVo);
00439         _infoSuVoA->SetLabel(infoSuVoA);
00440         _infoPixLe->SetLabel(infoPixLe);
00441         _infoPixHi->SetLabel(infoPixHi);
00442 
00443         // Histogram
00444         if ( _histogrammeAccumulated->GetValue()==true )
00445         {
00446                 int dimHist[3];
00447                 _histogrammeVector -> GetDimensions ( dimHist );
00448 
00449                 int i,size=dimHist[0];
00450                 for (i=1; i<=size; i++)
00451                 {
00452                         p_histogramme[i] = p_histogramme[i] + p_histogramme[i-1];
00453                 }
00454         }
00455         double range[2];
00456         _histogrammeVector->Update();
00457         _histogrammeVector->GetScalarRange(range);
00458         _xyplot->SetYRange( 0   , range[1]      );
00459         _xyplot->SetXRange( min , max           );
00460 
00461         _vtkclipping3Ddataviewer->RefreshSurface();
00462         _wxvtkbaseView->Refresh();
00463 
00464 //      _wxvtkbaseView->RefreshView();
00465         wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121);  // Refresh
00466         _wxvtkbaseView->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1);
00467 }
00468 
00469 
00470 //-------------------------------------------------------------------
00471 void wxPanelCuttingImageData::OnTypeFig(wxCommandEvent& event)
00472 {
00473         _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _actualActor );
00474 
00475         if (_typeFig->GetSelection()==0){
00476                 _actualCuttingModel=_modelCylinder;
00477                 _actualActor=_cylinderActor;
00478         }
00479         if (_typeFig->GetSelection()==1){
00480                 _actualCuttingModel=_modelCube;
00481                 _actualActor=_cubeActor;
00482         }
00483         if (_typeFig->GetSelection()==2){
00484                 _actualCuttingModel=_modelSphere;
00485                 _actualActor=_sphereActor;
00486         }
00487         _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
00488         RefreshOpacity();
00489         RefreshView();
00490 }
00491 
00492 //-------------------------------------------------------------------
00493 void wxPanelCuttingImageData::RefreshOpacity()
00494 {
00495         double op= _opacityFig->GetValue()/100.0;
00496         _actualActor->GetProperty()->SetOpacity( op );
00497 }
00498 
00499 //-------------------------------------------------------------------
00500 void wxPanelCuttingImageData::OnOpacityFig(wxScrollEvent& event)
00501 {
00502         RefreshOpacity();
00503         Refresh();
00504 }
00505 //-------------------------------------------------------------------
00506 void wxPanelCuttingImageData::RefreshView()
00507 {
00508         SetParamsOfTransformation( );
00509         Refresh();
00510 }
00511 //-------------------------------------------------------------------
00512 void wxPanelCuttingImageData::Refresh()
00513 {
00514         _wxvtk3Dbaseview->Refresh();
00515 }
00516 
00517 //-------------------------------------------------------------------
00518 void wxPanelCuttingImageData::SetParamsOfTransformation( )
00519 {
00520         double spc[3];
00521         vtkImageData *vtkimagedata = _vtkmprbasedata->GetImageData();
00522         vtkimagedata->GetSpacing(spc);
00523         int px = (int) (_vtkmprbasedata->GetX() );
00524         int py = (int) (_vtkmprbasedata->GetY() );
00525         int pz = (int) (_vtkmprbasedata->GetZ() );
00526         int sx = (int) (_scaleX->GetValue() * spc[0] );
00527         int sy = (int) (_scaleY->GetValue() * spc[1] );
00528         int sz = (int) (_scaleZ->GetValue() * spc[2] );
00529         _actualCuttingModel     -> SetScale             ( sx    , sy    , sz );
00530         _actualCuttingModel     -> SetPosition  ( px    , py , pz       );
00531         _actualCuttingModel     -> SetRotation  ( _rotationX->GetValue()        , _rotationY->GetValue() , _rotationZ->GetValue()       );
00532         _actualCuttingModel     -> SetSpacing   ( spc[0]        , spc[1]    , spc[2] );
00533         _actualCuttingModel     -> CalculeMatrix();
00534 }
00535 
00536 //-------------------------------------------------------------------
00537 
00538 void wxPanelCuttingImageData::OnTransform(wxScrollEvent& event)
00539 {
00540         RefreshView();
00541 }
00542 
00543 //-------------------------------------------------------------------
00544 void wxPanelCuttingImageData::SetVtkMPRBaseData( vtkMPRBaseData *vtkmprbasedata )
00545 {
00546         _vtkmprbasedata = vtkmprbasedata;
00547         _imageData              = _vtkmprbasedata->GetImageData();
00548 }
00549 
00550 //-------------------------------------------------------------------
00551 
00552 void wxPanelCuttingImageData::Configure()
00553 {
00554         _actualCuttingModel=_modelCylinder;
00555         _actualActor=_cylinderActor;
00556         _wxvtk3Dbaseview->GetRenderer()->AddActor( _actualActor );
00557         SetParamsOfTransformation();
00558         RefreshView();
00559 }
00560 

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