From 9d859a4bbe2433d2489e7c91f64ef32bef816462 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Mon, 11 Jul 2011 17:32:52 +0000 Subject: [PATCH] no message --- bbtk/src/bbmaracasvisuShowNPoints.cxx | 157 ++++++++++++++++---------- bbtk/src/bbmaracasvisuShowNPoints.h | 8 +- 2 files changed, 101 insertions(+), 64 deletions(-) diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 8f434b0..fd778dc 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -19,63 +19,92 @@ namespace bbcreaMaracasVisu wxPanel *panel = this; wxSizer *sizer = NULL; - // Widget interface - askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR - textCtrl = new wxTextCtrl(panel, -1); - wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point")); - wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point")); - wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point")); - wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point")); - wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point")); - wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points")); - wxButton *btnSavePoints = new wxButton( panel, -1, _T("Save points")); - 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(" "))); - - Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint); - Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint); - Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint); - Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint); - Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); - Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); - 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(askPointLabel); // JPR - sizer1->Add(textCtrl); - sizer1->Add(btnAddPoint); - sizer1->Add(btnSetPositionPoint); - sizer1->Add(btnRenamePoint); - sizer1->Add(btnErasePoint); - sizer1->Add(btnEraseLastPoint); - sizer1->Add(btnDeleteAllPoints); - sizer1->Add(txtNrPoints); - sizer1->Add(txOpacity); - sizer1->Add(sdrOpacity,1,wxGROW ); - sizer1->Add(txRadio); - sizer1->Add(sdrRadio,1,wxGROW ); - sizer1->Add(btnSavePoints); - sizer1->Add(btnLoadPoints); - - sizer = sizer1; - panel ->SetSizer(sizer); - panel ->SetAutoLayout(true); - panel ->Layout(); + if (mbbShowNPoints->bbGetInputType()==0) + { + // Widget interface + askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR + textCtrl = new wxTextCtrl(panel, -1); + wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point")); + wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point")); + wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point")); + wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point")); + wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point")); + wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points")); + wxButton *btnSavePoints = new wxButton( panel, -1, _T("Save points")); + 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(" "))); + + Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint); + Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint); + Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint); + Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint); + Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); + Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); + 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(askPointLabel); // JPR + sizer1->Add(textCtrl); + sizer1->Add(btnAddPoint); + sizer1->Add(btnSetPositionPoint); + sizer1->Add(btnRenamePoint); + sizer1->Add(btnErasePoint); + sizer1->Add(btnEraseLastPoint); + sizer1->Add(btnDeleteAllPoints); + sizer1->Add(txtNrPoints); + sizer1->Add(txOpacity); + sizer1->Add(sdrOpacity,1,wxGROW ); + sizer1->Add(txRadio); + sizer1->Add(sdrRadio,1,wxGROW ); + sizer1->Add(btnSavePoints); + sizer1->Add(btnLoadPoints); + sizer = sizer1; + } + + if (mbbShowNPoints->bbGetInputType()==1) + { + // Widget interface + wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point")); + 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); + Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint); + Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); + Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); + + sizer1->Add(btnSetPositionPoint); + sizer1->Add(txtNrPoints); + sizer1->Add(txOpacity); + sizer1->Add(sdrOpacity,1,wxGROW ); + sizer1->Add(txRadio); + sizer1->Add(sdrRadio,1,wxGROW ); + sizer = sizer1; + } + + if (sizer!=NULL) + { + panel->SetSizer(sizer); + panel->SetAutoLayout(true); + panel->Layout(); + } } //------------------------------------------------------------------------ @@ -237,8 +266,6 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label) lstActorsText.push_back(textActor); RefreshPoint(lstPointsX.size()-1); - - SetOutputBox(); } @@ -404,6 +431,13 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event) { int id=GetNearestPoint(); + if((id==-1) && (mbbShowNPoints->bbGetInputType()==1)) + { + id=0; + AddPoint(0,0,0,""); + } + + if (id>=0) { printf("WidgetShowNPoints::OnSetPoint \n"); @@ -564,12 +598,12 @@ void ShowNPoints::Process() void ShowNPoints::CreateWidget(wxWindow* parent) { mwxwidget = new WidgetShowNPoints( parent, this); - bbSetOutputWidget( mwxwidget ); + bbSetOutputWidget( mwxwidget ); } void ShowNPoints::bbUserSetDefaultValues() { - mwxwidget = NULL; + mwxwidget = NULL; bbSetInputRadio(1); bbSetInputOpacity(1); @@ -581,6 +615,7 @@ void ShowNPoints::bbUserSetDefaultValues() bbSetInputColour(colour); bbSetInputImage(NULL); + bbSetInputType(0); bbSetInputRenderer(NULL); } diff --git a/bbtk/src/bbmaracasvisuShowNPoints.h b/bbtk/src/bbmaracasvisuShowNPoints.h index fd2d848..17dc629 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.h +++ b/bbtk/src/bbmaracasvisuShowNPoints.h @@ -44,9 +44,10 @@ namespace bbcreaMaracasVisu std::vector GetLstPointsZ(); std::vector GetLstLabels(); + void AddPoint(int x, int y, int z, std::string label); + private: - void AddPoint(int x, int y, int z, std::string label); std::string CleanSpaces(std::string ss); int GetNearestPoint(); int IdInsidePoint(); @@ -89,6 +90,7 @@ class /*BBTK_EXPORT*/ ShowNPoints BBTK_DECLARE_INPUT(Colour, std::vector ); BBTK_DECLARE_INPUT(Opacity, double ); BBTK_DECLARE_INPUT(Radio, double ); + BBTK_DECLARE_INPUT(Type, int ); BBTK_DECLARE_OUTPUT( lstPointsX, std::vector ); BBTK_DECLARE_OUTPUT( lstPointsY, std::vector ); BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector ); @@ -99,8 +101,7 @@ class /*BBTK_EXPORT*/ ShowNPoints void CreateWidget(wxWindow*); private: - WidgetShowNPoints *mwxwidget; - + WidgetShowNPoints *mwxwidget; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox); @@ -114,6 +115,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox); BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector,"colour"); BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor",double,""); BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres",double,""); + BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point",int,""); BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector ,""); BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector ,""); -- 2.47.1