]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuShowNPoints.cxx
#2647 creaMaracasVisu Feature New Normal - Merge creaButtonContainer BRANCH
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.cxx
index 8f434b06db9d059a434f4e1b5dca63f9cd0b225f..c0edbf2b31ea9774d7f2db40028d46eec4f0ae51 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 #include "bbmaracasvisuShowNPoints.h"
 #include "bbcreaMaracasVisuPackage.h"
 
@@ -6,6 +31,7 @@
 #include "vtkPolyDataMapper.h"
 #include "vtkRenderWindow.h"
 #include "vtkTextActor3D.h"
+#include <vtkTextProperty.h>
 
 namespace bbcreaMaracasVisu
 {
@@ -19,63 +45,121 @@ 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 *btnInsertPoint                        = new wxButton( panel, -1, _T("Insert Point"));//CFT
+               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(btnInsertPoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
+               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(btnInsertPoint);//CFT
+               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 (mbbShowNPoints->bbGetInputType() == 2) {
+            askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
+            
+            wxButton *btnAddPoint = new wxButton(panel, -1,        _T("      Add  Point      "));
+            wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T("      Delete All      "));
+            wxStaticText* spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
+            textCtrl = new wxTextCtrl(panel, -1);
+            
+            wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+
+            Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
+            Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
+            
+            sizer1->Add(askPointLabel); 
+            sizer1->Add(btnAddPoint);
+            sizer1->Add(btnDeleteAllPoints);
+            sizer1->Add(spacer);
+            sizer1->Add(textCtrl);
+            
+            sdrOpacity = new wxSlider();
+            sdrRadio = new wxSlider();
+            
+            txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));  
+            
+            sizer = sizer1;
+        } 
+         if (sizer!=NULL)
+         {
+                 panel->SetSizer(sizer);
+                 panel->SetAutoLayout(true);
+                 panel->Layout();
+         }
 }
 
 //------------------------------------------------------------------------
@@ -83,6 +167,7 @@ WidgetShowNPoints::~WidgetShowNPoints()
 {
 }
 
+//------------------------------------------------------------------------
 void WidgetShowNPoints::SetRadio(double radio)
 {
        this->mradio=radio;
@@ -131,7 +216,7 @@ void WidgetShowNPoints::SetOpacity(double opacity)
 {
        this->mopacity=opacity;
        //NTU: For Slider
-       sdrOpacity->SetValue(this->mopacity/100.0);
+       sdrOpacity->SetValue(this->mopacity*100.0);
 }
 
 //------------------------------------------------------------------------
@@ -204,8 +289,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        vtkActor *sphereActor   = vtkActor::New();
        sphereActor->SetMapper(sphereMapper);
        sphereActor->SetOrigin(0, 0, 0);
-       
-       
+
 /*EED Borrame
        double spc[3];
        if(mimage==NULL){
@@ -218,7 +302,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        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);
@@ -237,9 +321,99 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        lstActorsText.push_back(textActor);
 
        RefreshPoint(lstPointsX.size()-1);
+}
+
+//------------------------------------------------------------------------
+double WidgetShowNPoints::Distance(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1)//CFT
+{
+    return sqrt((dX1 - dX0)*(dX1 - dX0) + (dY1 - dY0)*(dY1 - dY0) + (dZ1 - dZ0)*(dZ1 - dZ0));
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
+{
+       std::cout<<"WidgetShowNPoints::InsertPoint begin "<<std::endl;
+
+       if(lstPointsX.size()>1)
+       {
+               std::vector<int> dTotal;
+               int pos = 1;
+               int a,b,res;
+               
+               //Calcule distance for each pair of points
+               for(int i = 0; i<lstPointsX.size()-1 ; i++)
+               {
+                               a = Distance(x, y, z, lstPointsX[i], lstPointsY[i], lstPointsZ[i]);
+                               b = Distance(x, y, z, lstPointsX[i+1], lstPointsY[i+1], lstPointsZ[i+1]);
+                               res = a + b;            
+                               dTotal.push_back (res);         
+               }
+               //Gets the smallest distance 
+               int smallTMP = dTotal[0];
+               for (int j = 0; j < dTotal.size(); j++)
+               {
+                         if(dTotal[j]<smallTMP)
+                         {
+                                         smallTMP=dTotal[j];
+                                               pos = j+1;
+                         }
+               }
+               
+               std::vector<int>::iterator it;
+               //Insert the point in the list of points
+               it = lstPointsX.begin();
+               lstPointsX.insert( it+pos, x );
+               it = lstPointsY.begin();
+               lstPointsY.insert( it+pos, y );
+               it = lstPointsZ.begin();
+               lstPointsZ.insert( it+pos, z );
+
+               std::string strLabel = CleanSpaces(  label );
        
-       
-       SetOutputBox();
+               std::vector<std::string>::iterator itS;
+               itS = lstLabels.begin();
+               //Insert Label in list of labels
+               lstLabels.insert( itS+pos, strLabel );
+
+               // Sphere
+               vtkSphereSource *vtksphere              = vtkSphereSource::New();
+               vtksphere->SetThetaResolution (20);
+               vtksphere->SetPhiResolution (20);
+               vtksphere->SetRadius( mradio  );
+
+               //NTU: For updating points
+               std::vector<vtkSphereSource*>::iterator itSS;
+               itSS = lstSourceSphere.begin();
+               lstSourceSphere.insert( itSS+pos, vtksphere);
+
+               vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
+               sphereMapper->SetInput( vtksphere->GetOutput() );
+               vtkActor *sphereActor   = vtkActor::New();
+               sphereActor->SetMapper(sphereMapper);
+               sphereActor->SetOrigin(0, 0, 0);
+
+               std::vector<vtkActor*>::iterator itAS;
+               itAS = lstActorsSphere.begin();
+               lstActorsSphere.insert( itAS+pos, sphereActor);
+               if(renderer==NULL){
+                       wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
+                       dialog.ShowModal();             
+                       return;
+               }
+               renderer->AddActor( sphereActor );
+
+               // Actor
+               vtkTextActor3D *textActor = vtkTextActor3D::New();
+
+               textActor->SetInput( strLabel.c_str()  );
+               renderer->AddActor( textActor );
+               std::vector<vtkTextActor3D*>::iterator itTA;
+               itTA = lstActorsText.begin();
+               lstActorsText.insert( itTA+pos , textActor);
+
+               RefreshPoint(pos);
+       }//end if
+       std::cout<<"WidgetShowNPoints::InsertPoint end"<<std::endl;
 }
 
 //------------------------------------------------------------------------
@@ -254,12 +428,35 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
        if (this->renderer!=NULL){
                if (mpoint.size()==3){
                        AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+                       SetOutputBox();
+               } else {//mpoint.size
+                       printf("creaMaracasVisu::ShowNPoints (not match point) \n");
+               }
+       } // renderer
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
+{
+       std::cout<<"WidgetShowNPoints::OnInsertPoint begin"<<std::endl;
+       if(mimage==NULL){
+               wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
+               dialog.ShowModal();
+               return;
+       }
+       
+       if (this->renderer!=NULL){
+               if (mpoint.size()==3){
+                       InsertPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+                       SetOutputBox();
                } else {//mpoint.size
                        printf("creaMaracasVisu::ShowNPoints (not match point) \n");
                }
        } // renderer
+       std::cout<<"WidgetShowNPoints::OnInsertPoint end"<<std::endl;
 }
 
+
 //------------------------------------------------------------------------
        void WidgetShowNPoints::SetOutputBox()
        {
@@ -273,10 +470,14 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                mbbShowNPoints->bbSetOutputlstPointsY( lstPointsY );
                mbbShowNPoints->bbSetOutputlstPointsZ( lstPointsZ );
                mbbShowNPoints->bbSetOutputlstLabels( lstLabels );
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
-               mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
+
+               mbbShowNPoints->bbSignalOutputModification();
+
+//EED 07/07/2014
+//             mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+//             mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+//             mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
+//             mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
        }
 
 //------------------------------------------------------------------------
@@ -292,7 +493,8 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                //EED
 
                int result_FD = FD->ShowModal();
-
+               std::string tmpLabel;
+               
                // This line is need it by windows //EED
                FD->SetReturnCode( result_FD );
 
@@ -314,7 +516,13 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                        y=lstPointsY[i];
                                        z=lstPointsZ[i];
                                        value= mimage->GetScalarComponentAsDouble(x,y,z,0);
-                                       fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , lstLabels[i].c_str());
+                                       if (lstLabels[i]!="") 
+                                       {
+                                               tmpLabel=lstLabels[i];
+                                       } else{
+                                           tmpLabel="<_VOID_>";
+                                       }
+                                       fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
                                } // for
                                fclose(ff);
                        } else {   // else ff
@@ -357,8 +565,10 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                for (i=0; i<size; i++)
                                {
                                        fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
+                                       if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
                                        AddPoint(x,y,z, chartmp );
                                }
+                               SetOutputBox();
                                fclose(ff);
                        } else {   // else ff
                                printf("WidgetShowNPoints::OnLoadPoints  ...Error... reading file");
@@ -404,6 +614,14 @@ 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,"");
+                       SetOutputBox();
+               }
+               
+               
                if (id>=0)
                {
                        printf("WidgetShowNPoints::OnSetPoint \n");
@@ -451,7 +669,6 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                }
        }
 
-       
 //------------------------------------------------------------------------
        void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
        {
@@ -533,16 +750,20 @@ void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
        {
                this->lstSourceSphere[i]->SetRadius(mradio);
                this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity);
+               this->lstActorsText[i]->GetTextProperty()->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();
+//EED  SetOutputBox();
+        renderer->GetRenderWindow()->Render();
+
 }
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
 
+//-----------------------------------------------------------------
 void ShowNPoints::Process()
 {
        if (mwxwidget!=NULL)
@@ -558,20 +779,23 @@ void ShowNPoints::Process()
                bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
                bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
                bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
+
        } // mwxwidget
 }
 
+//-----------------------------------------------------------------
 void ShowNPoints::CreateWidget(wxWindow* parent)
 {
        mwxwidget = new WidgetShowNPoints( parent, this);
-        bbSetOutputWidget( mwxwidget );
+    bbSetOutputWidget( mwxwidget );
 }
 
+//-----------------------------------------------------------------
 void ShowNPoints::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
 
-       bbSetInputRadio(1);
+       bbSetInputRadio(10);
        bbSetInputOpacity(1);
 
        std::vector<double> colour;
@@ -581,6 +805,7 @@ void ShowNPoints::bbUserSetDefaultValues()
        bbSetInputColour(colour);
 
        bbSetInputImage(NULL);
+       bbSetInputType(0);
        bbSetInputRenderer(NULL);
 }