X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbmaracasvisuShowNPoints.cxx;h=bd4ec4272aff02d3718599324a21cd8f685c3dd3;hb=f010d4e7f1754243c513cc659372169c42560d5f;hp=6b35fe33e6a5265d2bb30aa64c334adeb5255b1b;hpb=6e940f8b87d85a90438f01d56c3c6c92da2bc14a;p=creaMaracasVisu.git diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 6b35fe3..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,6 +175,11 @@ 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(); @@ -364,8 +389,10 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) renderer->RemoveActor( 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 ); @@ -402,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)