From e9163fc688996aa392f7211cf6e49d3962149246 Mon Sep 17 00:00:00 2001 From: reyes Date: Fri, 18 Mar 2011 15:45:43 +0000 Subject: [PATCH] functionalities of RC and MIP working in paralell --- .../widgets/vtkClipping3DDataViewer.cxx | 170 ++++++++++++------ .../widgets/vtkClipping3DDataViewer.h | 18 +- .../wxWindows/widgets/wxVtkClipping3DView.cxx | 72 +++++--- .../wxWindows/widgets/wxVtkClipping3DView.h | 8 +- .../wxVtkClipping3DViewVolCntrlPanel.cxx | 113 ++++++++++-- .../wxVtkClipping3DViewVolCntrlPanel.h | 10 +- 6 files changed, 293 insertions(+), 98 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx index a0b370e..800f8be 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.cxx @@ -11,6 +11,14 @@ vtkClipping3DDataViewer::vtkClipping3DDataViewer() _representationType[i] = true; } _visibleVolume=false; + _isRayCasting=true; + _isMIP=false; + _interpolation=false; + _shade=false; + + _volumeMapper = vtkVolumeRayCastMapper::New(); + _newvol = vtkVolume::New(); + _volumeProperty = vtkVolumeProperty::New(); } //------------------------------------------------------------------- vtkClipping3DDataViewer::~vtkClipping3DDataViewer() @@ -76,7 +84,7 @@ void vtkClipping3DDataViewer::Refresh() // _newvol->VisibilityOn(); - + // _volumeMapper = vtkVolumeRayCastMapper::New(); // _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() ); // _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); @@ -177,11 +185,11 @@ void vtkClipping3DDataViewer::Configure_Tissue() _tissuePlanes[i] = vtkPlanes::New(); - + int x1,x2,y1,y2,z1,z2; imagedata->GetExtent(x1,x2,y1,y2,z1,z2); _tissuePlanes[i]->SetBounds (x1,x2,y1,y2,z1,z2); - + _tissueClipper[i] = vtkClipPolyData::New(); _tissueClipper[i]->SetInput( _tissueStripper[i]->GetOutput() ); _tissueClipper[i]->SetClipFunction( _tissuePlanes[i] ); @@ -193,7 +201,7 @@ void vtkClipping3DDataViewer::Configure_Tissue() // _tissueMapper[i]->Update(); } - + // vtkActor tissue @@ -227,6 +235,17 @@ void vtkClipping3DDataViewer::Configure_Volume() { // Volume + + + /** if(_newvol != NULL) + { + _newvol->Delete(); + _volumeMapper->Delete(); + _volumeProperty->Delete(); + }*/ + + + _tfun = vtkPiecewiseFunction::New(); _ctfun = vtkColorTransferFunction::New(); @@ -251,7 +270,7 @@ void vtkClipping3DDataViewer::Configure_Volume() _tfun->AddPoint(max * 2/2 , 1.0); /* - Adding the colors to the vectors + Adding the colors to the vectors */ //RED redColorsOfColorTransferenceFVector.push_back(0.0); @@ -266,14 +285,14 @@ void vtkClipping3DDataViewer::Configure_Volume() greenColorsOfColorTransferenceFVector.push_back(0.0); greenColorsOfColorTransferenceFVector.push_back(1.0); greenColorsOfColorTransferenceFVector.push_back(0.2); - + //BLUE blueColorsOfColorTransferenceFVector.push_back(0.0); blueColorsOfColorTransferenceFVector.push_back(0.0); blueColorsOfColorTransferenceFVector.push_back(1.0); blueColorsOfColorTransferenceFVector.push_back(0.0); blueColorsOfColorTransferenceFVector.push_back(0.0); - //GREY VALUE + //GREY VALUE greyValueColorsOfColorTransferenceFVector.push_back(max*0/4); greyValueColorsOfColorTransferenceFVector.push_back(max*1/4); greyValueColorsOfColorTransferenceFVector.push_back(max*2/4); @@ -293,35 +312,63 @@ void vtkClipping3DDataViewer::Configure_Volume() // _volumePlanes->SetBounds(x1,x2,y1,y2,z1,z2); // EED 13/03/2011 - + _compositeFunction = vtkVolumeRayCastCompositeFunction::New(); vtkVolumeRayCastMIPFunction* _compositeFunctionMIP = vtkVolumeRayCastMIPFunction::New(); - _volumeMapper = vtkVolumeRayCastMapper::New(); + // _volumeMapper = vtkVolumeRayCastMapper::New(); _volumeMapper->SetInput( this->GetVtkMPRBaseData()->GetImageData() ); - - _volumeMapper->SetVolumeRayCastFunction(_compositeFunction); -// _volumeMapper->SetVolumeRayCastFunction(_compositeFunctionMIP); - + +if(_isRayCasting) +{ + cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isRayCasting"<SetVolumeRayCastFunction(_compositeFunction); + +} +else if(_isMIP) +{ + cout<<"JPRG::vtkClipping3DDataViewer::Configure_Volume::isMIP"<SetVolumeRayCastFunction(_compositeFunctionMIP); +} + +// + _volumeMapper->SetClippingPlanes( _volumePlanes ); _volumeMapper->AutoAdjustSampleDistancesOn(); - _volumeProperty = vtkVolumeProperty::New(); + //_volumeProperty = vtkVolumeProperty::New(); _volumeProperty->SetColor(_ctfun); _volumeProperty->SetScalarOpacity( _tfun ); // EED 31/03/2008 - + _volumeProperty->DisableGradientOpacityOn(); - - _volumeProperty->SetInterpolationTypeToLinear(); -// _volumeProperty->SetInterpolationTypeToNearest(); - - _volumeProperty->ShadeOn(); -// _volumeProperty->ShadeOff(); - - + +if(_interpolation) +{ + _volumeProperty->SetInterpolationTypeToLinear(); +} +else +{ + _volumeProperty->SetInterpolationTypeToNearest(); +} + +if(_shade) +{ + _volumeProperty->ShadeOn(); +} +else +{ + _volumeProperty->ShadeOff(); +} + +// _ + + +// _ + + // _volumeProperty->SetInterpolationTypeToNearest(); // _volumeProperty->ShadeOff(); // _volumeProperty->SetAmbient(0.3); @@ -329,7 +376,7 @@ void vtkClipping3DDataViewer::Configure_Volume() // _volumeProperty->SetSpecular(0.8); // _volumeProperty->DisableGradientOpacityOn(); - _newvol = vtkVolume::New(); + // _newvol = vtkVolume::New(); _newvol->SetMapper(_volumeMapper ); _newvol->SetProperty(_volumeProperty ); @@ -414,7 +461,7 @@ std::vector* vtkClipping3DDataViewer::GetGreenColorsOfColorTransferenceF } //-------------------------------------------------------------------- std::vector* vtkClipping3DDataViewer::GetBlueColorsOfColorTransferenceFVector() -{ +{ return &blueColorsOfColorTransferenceFVector; } //-------------------------------------------------------------------- @@ -444,9 +491,9 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() /* int i=0,xi,yi,r,g,b,gValue; vtkImageData *imagedata = this->_vtkmprbasedata->GetImageData(); - + HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata); - // + // // put in a method // int tfSize=this->greyValuesTransferenceFVector.size(); @@ -461,7 +508,7 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() hDlg->addPointToTransferenceFunction(g,in*100); i++; } - + } int ctfSize=this->redColorsOfColorTransferenceFVector.size(); @@ -483,17 +530,17 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() //setting variables if the user wants to do refresh hDlg->setCTF(_ctfun); hDlg->setTF(_tfun); - + // // when the user had changed the transference Function // if(hDlg->ShowModal()== wxID_OK ) - { + { // -- vtkPiecewiseFunction -- this->_tfun->RemoveAllPoints(); greyValuesTransferenceFVector.clear(); intensityValuesTransferenceFVector.clear(); - + int nTFPoints=hDlg->getSizeTransferenceFunction(); i=0; while(i_ctfun->RemoveAllPoints (); //clean colors @@ -513,7 +560,7 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() greyValueColorsOfColorTransferenceFVector.clear(); int nCTFpoints=hDlg->getSizeBarColor(); - i=0; + i=0; while(igetDataBarColorPoint(i,xi,r,g,b); @@ -524,14 +571,14 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() greyValueColorsOfColorTransferenceFVector.push_back(xi); i++; } - + this->_volumeMapper->Update(); this->_newvol->Update(); } - + else { - + if(hDlg->getRefreshed()) { int i=0,size; @@ -545,12 +592,12 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions() double in2=intensityValuesTransferenceFVector[i]; this->_tfun->AddPoint( grey1 , in2 ); } - + // -- vtkColorTransferFunction -- _ctfun->RemoveAllPoints (); - + i=0; - size=greyValueColorsOfColorTransferenceFVector.size(); + size=greyValueColorsOfColorTransferenceFVector.size(); for(i=0;i_volumeMapper->Update(); this->_newvol->Update(); } - + } hDlg->Destroy(); */ @@ -592,29 +639,29 @@ void vtkClipping3DDataViewer::ReadVolumeFunctions(char *namefile) // -- vtkPiecewiseFunction -- this->_tfun->RemoveAllPoints(); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); while ( strcmp(tmp,"--")!=0 ) { x=atof(tmp); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); val=atof(tmp); this->_tfun->AddPoint( x*max , val ); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); } this->_ctfun->RemoveAllPoints (); // -- vtkColorTransferFunction -- while ( !feof(ff)) { - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); x=atof(tmp); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); r=atof(tmp); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); g=atof(tmp); - fscanf(ff,"%s",tmp); + fscanf(ff,"%s",tmp); b=atof(tmp); - this->_ctfun->AddRGBPoint( x*max , r,g,b ); + this->_ctfun->AddRGBPoint( x*max , r,g,b ); } @@ -637,7 +684,30 @@ void vtkClipping3DDataViewer::ReadMeshVTK(char *namefile) } void vtkClipping3DDataViewer::setColorTransferFunction(vtkColorTransferFunction* colortable){ - + _volumeProperty->SetColor(colortable); - + +} + + +void vtkClipping3DDataViewer::SetRayCasting(bool active) +{ + _isRayCasting = active; + +} + +void vtkClipping3DDataViewer::SetMIPActive(bool active) +{ + _isMIP = active; +} + +void vtkClipping3DDataViewer::SetInterpolation(bool active) +{ + _interpolation = active; } + +void vtkClipping3DDataViewer::SetShade(bool active) +{ + _shade = active; +} + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h index e520ddf..444b972 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClipping3DDataViewer.h @@ -68,9 +68,9 @@ public: boxSurfaceObserver *GetObserverS(int idObserverS); boxSurfaceObserver *GetObserverV(); - //void ReadVolumeFunctions(char *namefile); - void ReadVolumeFunctions(); - void ReadMeshVTK(char *namefile); + //void ReadVolumeFunctions(char *namefile); + void ReadVolumeFunctions(); + void ReadMeshVTK(char *namefile); //------------------- @@ -93,10 +93,15 @@ public: vtkPiecewiseFunction *GetTransferencefunction(); vtkColorTransferFunction *GetColorTransferenceFunction(); + void SetRayCasting(bool active); + void SetMIPActive(bool active); + void SetInterpolation(bool active); + void SetShade(bool active); + private: - + vtkMarchingCubes *_mCubes[ VTKMPRDATA_MAXTISSUE ]; vtkStripper *_tissueStripper[ VTKMPRDATA_MAXTISSUE ]; vtkPolyDataMapper *_tissueMapper[ VTKMPRDATA_MAXTISSUE ]; @@ -132,6 +137,11 @@ private: std::vector greenColorsOfColorTransferenceFVector; std::vector blueColorsOfColorTransferenceFVector; std::vector greyValueColorsOfColorTransferenceFVector; + + bool _isRayCasting; + bool _isMIP; + bool _interpolation; + bool _shade; }; #endif /*VTKCLIPPING3DDATAVIEWER_H_*/ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.cxx index 5408597..9a984c5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.cxx @@ -68,15 +68,15 @@ wxPanel* wxVtkClipping3DView::CreateVolControlPanel(wxWindow *parent) //------------------------------------------------------------------- vtkClipping3DDataViewer* wxVtkClipping3DView::GetVtkClipping3DDataViewer() { - return _vtkclipping3Ddataviewer; + return _vtkclipping3Ddataviewer; } //------------------------------------------------------------------- void wxVtkClipping3DView::VisibleActor(int idTissue, bool visTissue){ if (visTissue!=_vtkclipping3Ddataviewer->GetVisibleTissue(idTissue)){ if (visTissue==false){ - _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) ); + _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) ); } else { - _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) ); + _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(idTissue) ); // _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(idTissue) ); // _actor->VisibilityOn(); } @@ -102,13 +102,13 @@ void wxVtkClipping3DView::SetRepSurfaceWireFrame(int idTissue , bool representat void wxVtkClipping3DView::VisibleVolumeActor( bool visVolume){ if (visVolume!=_vtkclipping3Ddataviewer->GetVisibleVolume() ){ if (visVolume==false){ -//EED 31/03/2008 -// _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() ); - _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() ); +//EED 31/03/2008 +// _wxvtk3Dbaseview->GetRenderer()->RemoveActor( _vtkclipping3Ddataviewer->GetVolumeActor() ); + _wxvtk3Dbaseview->GetRenderer()->RemoveVolume( _vtkclipping3Ddataviewer->GetVolumeActor() ); } else { -//EED 31/03/2008 -// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() ); - _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() ); +//EED 31/03/2008 +// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetVolumeActor() ); + _wxvtk3Dbaseview->GetRenderer()->AddVolume( _vtkclipping3Ddataviewer->GetVolumeActor() ); } _vtkclipping3Ddataviewer->SetVisibleVolume(visVolume); } @@ -125,8 +125,8 @@ wxVtk3DBaseView* wxVtkClipping3DView::GetWxvtk3Dbaseview()throw(char*) void wxVtkClipping3DView::Configure(){ _wxvtk3Dbaseview->Configure(); - // Actors are added to the renderer. - _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() ); + // Actors are added to the renderer. + _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetOutlineActor() ); _boxWidgetS1 = vtkBoxWidget::New(); _boxWidgetS1->SetInteractor( _wxvtk3Dbaseview->GetWxVTKRenderWindowInteractor() ); @@ -136,7 +136,7 @@ void wxVtkClipping3DView::Configure(){ vtkStripper *stripper=_vtkclipping3Ddataviewer->GetTissueStripper(0); vtkPolyData *polydata= stripper->GetOutput(); - + _boxWidgetS1->SetInput( polydata ); _boxWidgetS1->PlaceWidget(); @@ -150,8 +150,8 @@ void wxVtkClipping3DView::Configure(){ -// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) ); -// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3)); +// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(0) ); +// _wxvtk3Dbaseview->GetRenderer()->AddActor( _vtkclipping3Ddataviewer->GetTissueActor(3)); VisibleActor(0, false ); VisibleActor(1, false ); @@ -159,17 +159,17 @@ void wxVtkClipping3DView::Configure(){ VisibleActor(3, false ); _boxWidgetS1->HandlesOn (); - -//EED 29Mars2009 + +//EED 29Mars2009 // _boxWidgetS1->On(); - + _boxWidgetS1->Off(); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(0) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(1) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(2) ); _boxWidgetS1->GetPlanes( this->GetVtkClipping3DDataViewer()->GetTissuePlanes(3) ); - + // EED 9 fev 2007 // box Volume _boxWidgetVolume = vtkBoxWidget::New(); @@ -182,10 +182,10 @@ void wxVtkClipping3DView::Configure(){ _boxWidgetVolume->AddObserver( vtkCommand::InteractionEvent , _vtkclipping3Ddataviewer->GetObserverV() ); _boxWidgetVolume->HandlesOn (); - -//EED 29Mars2009 + +//EED 29Mars2009 // _boxWidgetVolume->On(); - + _boxWidgetVolume->Off(); @@ -193,7 +193,7 @@ void wxVtkClipping3DView::Configure(){ // _boxWidgetVolume->GetPlanes( vtkplanes ); - // An initial camera view is created. The Dolly() method moves + // An initial camera view is created. The Dolly() method moves // the camera towards the FocalPoint, thereby enlarging the image. _wxvtk3Dbaseview->GetRenderer()->SetActiveCamera(_wxvtk3Dbaseview->GetCamera()); _wxvtk3Dbaseview->GetRenderer()->ResetCamera (); @@ -206,7 +206,7 @@ void wxVtkClipping3DView::Configure(){ // Note that when camera movement occurs (as it does in the Dolly() // method), the clipping planes often need adjusting. Clipping planes - // consist of two planes: near and far along the view direction. The + // consist of two planes: near and far along the view direction. The // near plane clips out objects in front of the plane; the far plane // clips out objects behind the plane. This way only what is drawn // between the planes is actually rendered. @@ -217,3 +217,29 @@ void wxVtkClipping3DView::SetVtkClipping3DDataViewer(vtkClipping3DDataViewer *vt { _vtkclipping3Ddataviewer = vtkclipping3Ddataviewer; } + +void wxVtkClipping3DView::SetRayCasting(bool active) +{ + _vtkclipping3Ddataviewer->SetRayCasting(active); + _vtkclipping3Ddataviewer->Configure(); +} + +void wxVtkClipping3DView::SetMIPActive(bool active) +{ + _vtkclipping3Ddataviewer->SetMIPActive(active); + _vtkclipping3Ddataviewer->Configure(); +} + +void wxVtkClipping3DView::SetInterpolation(bool active) +{ + _vtkclipping3Ddataviewer->SetInterpolation(active); + _vtkclipping3Ddataviewer->Configure(); +} + +void wxVtkClipping3DView::SetShade(bool active) +{ + _vtkclipping3Ddataviewer->SetShade(active); + _vtkclipping3Ddataviewer->Configure(); +} + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h index ac6185f..cdff5f4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DView.h @@ -19,7 +19,7 @@ public: wxPanel* CreateSurfControlPanel(wxWindow *parent); wxPanel* CreateVolControlPanel(wxWindow *parent); - + vtkClipping3DDataViewer* GetVtkClipping3DDataViewer(); void VisibleActor(int idTissue, bool visTissue); @@ -30,6 +30,12 @@ public: wxVtk3DBaseView* GetWxvtk3Dbaseview()throw(char*); + void SetRayCasting(bool active); + void SetMIPActive(bool active); + void SetInterpolation(bool active); + void SetShade(bool active); + + private: wxVtk3DBaseView *_wxvtk3Dbaseview; vtkClipping3DDataViewer *_vtkclipping3Ddataviewer; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.cxx index 6a4fd6b..f140661 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.cxx @@ -18,20 +18,44 @@ wxVtkClipping3DViewVolCntrlPanel::wxVtkClipping3DViewVolCntrlPanel(wxWindow *par _wxvtkclipping3Dview = wxvtkclipping3Dview; - wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Vol")); + wxCheckBox *ckVolum = new wxCheckBox(panel,-1,_T("Volume")); wxCheckBox *ckBoxVolume = new wxCheckBox(panel,-1,_T("Volume Box")); + ckBoxVolume->Disable(); + + rbRayCasting = new wxRadioButton(panel, -1, _T("Ray Casting"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + rbMIP = new wxRadioButton(panel, -1, _T("MIP")); + + ckInterpolation = new wxCheckBox(panel, -1, _T("Interpolation")); + ckShade = new wxCheckBox(panel, -1, _T("Shade")); + + rbRayCasting->Disable(); + rbMIP->Disable(); + ckInterpolation->Disable(); + ckShade->Disable(); + + wxButton *btnVolumeFunctions = new wxButton(panel,-1,_T("Read Volume Functions")); - Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions ); + Connect(btnVolumeFunctions->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions ); ckBoxVolume->SetValue(false); Connect(ckVolum->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnVisibleVolume ); Connect(ckBoxVolume->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnVisibleBoxVolume ); + Connect(rbRayCasting->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnRayCastingActive ); + Connect(rbMIP->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnMIPActive ); + + Connect(ckInterpolation->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnInterpolationActive ); + Connect(ckShade->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkClipping3DViewVolCntrlPanel::OnShadeActive ); + + + wxFlexGridSizer *sizer = new wxFlexGridSizer(1); wxFlexGridSizer *sizerH0 = new wxFlexGridSizer(20); + wxFlexGridSizer *sizerH1 = new wxFlexGridSizer(20); + wxFlexGridSizer *sizerH2 = new wxFlexGridSizer(20); sizerH0->Add( ckVolum , 1, wxALL|wxEXPAND, 0); sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0); @@ -39,8 +63,16 @@ wxVtkClipping3DViewVolCntrlPanel::wxVtkClipping3DViewVolCntrlPanel(wxWindow *par sizerH0->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0); sizerH0->Add( btnVolumeFunctions , 1, wxALL|wxEXPAND, 0); + sizerH1->Add(rbRayCasting, 1, wxALL|wxEXPAND, 0 ); + sizerH1->Add(rbMIP, 1, wxALL|wxEXPAND, 0 ); + + sizerH2->Add(ckInterpolation, 1, wxALL|wxEXPAND, 0 ); + sizerH2->Add(ckShade, 1, wxALL|wxEXPAND, 0 ); + sizer->Add( sizerH0 , 1, wxALL|wxEXPAND, 2); + sizer->Add( sizerH1 , 1, wxALL|wxEXPAND, 2); + sizer->Add( sizerH2 , 1, wxALL|wxEXPAND, 2); panel->SetSize(300,60); panel->SetAutoLayout(true); @@ -62,7 +94,22 @@ void wxVtkClipping3DViewVolCntrlPanel::Refresh() //------------------------------------------------------------------- void wxVtkClipping3DViewVolCntrlPanel::OnVisibleVolume(wxCommandEvent& event) { + cout<<"JPRG::wxVtkClipping3DViewVolCntrlPanel::OnVisibleVolume::event_value::"<VisibleVolumeActor( event.IsChecked() ); + if(event.IsChecked()) + { + rbRayCasting->Enable(); + rbMIP->Enable(); + ckInterpolation->Enable(); + ckShade->Enable(); + } + else + { + rbRayCasting->Disable(); + rbMIP->Disable(); + ckInterpolation->Disable(); + ckShade->Disable(); + } _wxvtkclipping3Dview->Refresh(); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh @@ -80,7 +127,7 @@ void wxVtkClipping3DViewVolCntrlPanel::OnVisibleBoxVolume(wxCommandEvent& event) //------------------------------------------------------------------- void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& event) { - + int /*i=0,*/ xi,yi,r,g,b; // JPRx vtkColorTransferFunction* ctfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetColorTransferenceFunction(); vtkPiecewiseFunction* tfun = this->_wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->GetTransferencefunction(); @@ -99,18 +146,18 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even */ /* - MMLR BORRAME + MMLR BORRAME wxFileDialog dialog(this, _T("Choose a file"), _T("c:/Maracas_configuration"),_T(""), _T("*.MarVolConf"), wxOPEN); if (dialog.ShowModal() == wxID_OK) { _wxvtkclipping3Dview->GetVtkClipping3DDataViewer()->ReadVolumeFunctions( (char *)dialog.GetPath().c_str() ); - - + + } */ HistogramDialog* hDlg=new HistogramDialog(NULL,_T("Histogram Dialog"),imagedata,1); - // + // // put in a method // int tfSize=gtf->size(); @@ -125,7 +172,7 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even hDlg->addPointToTransferenceFunction(g,in*100); i++; } - + } int ctfSize=rctf->size(); @@ -154,12 +201,12 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even // when the user had changed the transference Function // if(hDlg->ShowModal()== wxID_OK ) - { + { // -- vtkPiecewiseFunction -- tfun->RemoveAllPoints(); gtf->clear(); itf->clear(); - + int nTFPoints=hDlg->getSizeTransferenceFunction(); int i=0; while(ipush_back(xi); itf->push_back(yi/100.0); i++; - } + } // -- vtkColorTransferFunction -- ctfun->RemoveAllPoints (); //clean colors @@ -179,7 +226,7 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even greyctf->clear(); int nCTFpoints=hDlg->getSizeBarColor(); - i=0; + i=0; while(igetDataBarColorPoint(i,xi,r,g,b); @@ -197,7 +244,7 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even _wxvtkclipping3Dview->Refresh(); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1); - + /* volumeMapper->Update(); newvol->Update(); @@ -216,12 +263,12 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even double in2=(*itf)[i]; tfun->AddPoint( grey1 , in2 ); } - + // -- vtkColorTransferFunction -- ctfun->RemoveAllPoints (); - + i=0; - size=greyctf->size(); + size=greyctf->size(); for(i=0;iAddRGBPoint(grey2,red,green,blue); } - + //--------------------------------- // Refreshing and sending the event //--------------------------------- @@ -238,14 +285,42 @@ void wxVtkClipping3DViewVolCntrlPanel::OnBtnVolumeFunctions(wxCommandEvent& even _wxvtkclipping3Dview->Refresh(); wxCommandEvent newevent1(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh _wxvtkclipping3Dview->GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor()->GetParent()->ProcessEvent(newevent1); - + /* volumeMapper->Update(); newvol->Update(); */ } - + } //destroy the dialog hDlg->Destroy(); } + +void wxVtkClipping3DViewVolCntrlPanel::OnRayCastingActive(wxCommandEvent& event){ + //If Ray Casting is active, others options are disabled. Only RayCasting is true + _wxvtkclipping3Dview->SetRayCasting(true); + _wxvtkclipping3Dview->SetMIPActive(false); + _wxvtkclipping3Dview->Refresh(); +} + +void wxVtkClipping3DViewVolCntrlPanel::OnMIPActive(wxCommandEvent& event){ + //If MIP is active, others options are disabled. Only MIP is true + _wxvtkclipping3Dview->SetMIPActive(true); + _wxvtkclipping3Dview->SetRayCasting(false); + + _wxvtkclipping3Dview->Refresh(); +} + + + +void wxVtkClipping3DViewVolCntrlPanel::OnInterpolationActive(wxCommandEvent& event){ + _wxvtkclipping3Dview->SetInterpolation(event.IsChecked()); + _wxvtkclipping3Dview->Refresh(); +} + +void wxVtkClipping3DViewVolCntrlPanel::OnShadeActive(wxCommandEvent& event){ + _wxvtkclipping3Dview->SetShade(event.IsChecked()); + _wxvtkclipping3Dview->Refresh(); +} + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.h index 4a7c134..a0185b6 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtkClipping3DViewVolCntrlPanel.h @@ -9,15 +9,23 @@ class wxVtkClipping3DViewVolCntrlPanel: public wxPanel public: wxVtkClipping3DViewVolCntrlPanel(wxWindow *parent, wxVtkClipping3DView *_wxvtkclipping3Dview); ~wxVtkClipping3DViewVolCntrlPanel(); - + void OnVisibleVolume(wxCommandEvent& event); void OnVisibleBoxVolume(wxCommandEvent& event); virtual void Refresh(); void OnBtnVolumeFunctions(wxCommandEvent& event); + void OnRayCastingActive(wxCommandEvent& event); + void OnMIPActive(wxCommandEvent& event); + void OnInterpolationActive(wxCommandEvent& event); + void OnShadeActive(wxCommandEvent& event); private: wxVtkClipping3DView *_wxvtkclipping3Dview; + wxRadioButton *rbRayCasting; + wxRadioButton *rbMIP; + wxCheckBox *ckInterpolation; + wxCheckBox *ckShade; protected: -- 2.47.1