]> Creatis software - creaMaracasVisu.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 11 Jul 2011 17:32:52 +0000 (17:32 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Mon, 11 Jul 2011 17:32:52 +0000 (17:32 +0000)
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuShowNPoints.h

index 8f434b06db9d059a434f4e1b5dca63f9cd0b225f..fd778dca7de22406fda0fdc829ff5681e93ea336 100644 (file)
@@ -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);
 }
 
index fd2d8487b73a7ee68a42e40256d52e57d3099aa4..17dc629581714af5eb3544202a5b0e80ee6d6c3a 100644 (file)
@@ -44,9 +44,10 @@ namespace bbcreaMaracasVisu
          std::vector<int> GetLstPointsZ();
          std::vector<std::string> 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<double> );
   BBTK_DECLARE_INPUT(Opacity, double );
   BBTK_DECLARE_INPUT(Radio, double );
+  BBTK_DECLARE_INPUT(Type, int );
   BBTK_DECLARE_OUTPUT( lstPointsX, std::vector<int> );
   BBTK_DECLARE_OUTPUT( lstPointsY, std::vector<int> );
   BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector<int> );
@@ -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<double>,"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<int> ,"");
   BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
   BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");