X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbmaracasvisuShowNPoints.cxx;h=bd4ec4272aff02d3718599324a21cd8f685c3dd3;hb=f010d4e7f1754243c513cc659372169c42560d5f;hp=83d7fe2a6c03597899453dfa2c0edf9104549248;hpb=1747b4600c1578c814c8cffcc17f548d14b4a6fa;p=creaMaracasVisu.git diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 83d7fe2..bd4ec42 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -32,6 +32,14 @@ namespace bbcreaMaracasVisu wxButton *btnLoadPoints = new wxButton( panel, -1, _T("Load points")); txtNrPoints = new wxStaticText(panel,-1, _T(" ")); + //NTU: Sliders for opacity and radio change + + wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T(" Points Opacity "))); + sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS); + + wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T(" Points Radio "))); + sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS); + wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1); // sizer1->Add(new wxStaticText(panel,-1,_T(" "))); @@ -43,6 +51,10 @@ namespace bbcreaMaracasVisu Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints); Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints); + //NTU: Slider events + Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); + Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); + sizer1->Add(textCtrl); sizer1->Add(btnAddPoint); sizer1->Add(btnRenamePoint); @@ -50,6 +62,10 @@ namespace bbcreaMaracasVisu sizer1->Add(btnEraseLastPoint); sizer1->Add(btnDeleteAllPoints); sizer1->Add(txtNrPoints); + sizer1->Add(txOpacity); + sizer1->Add(sdrOpacity); + sizer1->Add(txRadio); + sizer1->Add(sdrRadio); sizer1->Add(btnSavePoints); sizer1->Add(btnLoadPoints); @@ -68,7 +84,9 @@ WidgetShowNPoints::~WidgetShowNPoints() void WidgetShowNPoints::SetRadio(double radio) { - mradio=radio; + this->mradio=radio; + //NTU: For Slider + sdrRadio->SetValue(this->mradio); } //------------------------------------------------------------------------ @@ -114,6 +132,8 @@ void WidgetShowNPoints::SetColour(std::vector colour) void WidgetShowNPoints::SetOpacity(double opacity) { this->mopacity=opacity; + //NTU: For Slider + sdrOpacity->SetValue(this->mopacity*100.0); } //------------------------------------------------------------------------ @@ -155,18 +175,33 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label) vtksphere->SetThetaResolution (20); vtksphere->SetPhiResolution (20); vtksphere->SetRadius( mradio ); + + //NTU: For updating points + + lstSourceSphere.push_back(vtksphere); + vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); sphereMapper->SetInput( vtksphere->GetOutput() ); vtkActor *sphereActor = vtkActor::New(); sphereActor->SetMapper(sphereMapper); sphereActor->SetOrigin(0, 0, 0); double spc[3]; + if(mimage==NULL){ + wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR); + dialog.ShowModal(); + return; + } mimage->GetSpacing(spc); sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z ); sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] ); sphereActor->GetProperty()->SetOpacity( mopacity ); lstActorsSphere.push_back(sphereActor); + if(renderer==NULL){ + wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR); + dialog.ShowModal(); + return; + } renderer->AddActor( sphereActor ); // Actor @@ -308,20 +343,28 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) int id=-1; int i, size=(int)(lstActorsSphere.size()); double spc[3]; - mimage->GetSpacing(spc); - for ( i=0 ; iShowModal(); + return -1; + }else{ + + mimage->GetSpacing(spc); + + for ( i=0 ; iRemoveActor( lstActorsText[id] ); lstActorsSphere[id]->Delete(); lstActorsText[id]->Delete(); + lstSourceSphere[id]->Delete(); lstActorsSphere.erase( lstActorsSphere.begin()+id ); lstActorsText.erase( lstActorsText.begin()+id ); + lstSourceSphere.erase( lstSourceSphere.begin()+id ); lstPointsX.erase( lstPointsX.begin()+id ); lstPointsY.erase( lstPointsY.begin()+id ); @@ -384,6 +429,34 @@ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event) } +//NTU: Method for updating points opacity and Radio + +//------------------------------------------------------------------------ +void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event) +{ + //Difference in Radio for text placement + int difradio = sdrRadio->GetValue() - this->mradio; + + this->mopacity = sdrOpacity->GetValue()/100.0; + this->mradio = sdrRadio->GetValue(); + + //NTU refresh the inputs + mbbShowNPoints->bbSetInputOpacity(this->mopacity); + mbbShowNPoints->bbSetInputRadio(this->mradio); + + int size = (int) this->lstActorsSphere.size(); + int i; + for(i = 0; i < size; i ++) + { + this->lstSourceSphere[i]->SetRadius(mradio); + this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity); + this->lstActorsText[i]->SetPosition(this->lstActorsText[i]->GetPosition()[0]+difradio,this->lstActorsText[i]->GetPosition()[1], this->lstActorsText[i]->GetPosition()[2]); + } + + //NTU: For updating + SetOutputBox(); +} + BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints) @@ -424,7 +497,7 @@ void ShowNPoints::bbUserSetDefaultValues() { mwxwidget = NULL; - bbSetInputRadio(0.5); + bbSetInputRadio(1); bbSetInputOpacity(1); std::vector colour;