]> Creatis software - creaMaracasVisu.git/commitdiff
#3485 ShowNPionts for Multiple Groups
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 15 Jun 2022 14:53:26 +0000 (16:53 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 15 Jun 2022 14:53:26 +0000 (16:53 +0200)
bbtk/src/bbmaracasvisuShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index 661b6778b5d3400ea478b4b26ee98d051ada4059..561f35f7d6801f64ebf740d8613f83e81f9c4f51 100644 (file)
@@ -133,7 +133,7 @@ void ShowNPoints::bbUserSetDefaultValues()
        bbSetInputOpacity(1);
        std::vector<double> colour;
        colour.push_back(1.0);
-       colour.push_back(0.0);
+       colour.push_back(1.0);
        colour.push_back(0.0);
        bbSetInputColour(colour);
        bbSetInputImage(NULL);
index 7468bfdc2bef2de9d43921ef2da7e89ff5ad17b8..422c299f380b78646d9e3a3d552ac6abff799b09 100644 (file)
@@ -181,59 +181,71 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
 }
 
 
+//------------------------------------------------------------------------
+void ModelShowNPoints::SavePoints_(FILE* ff)
+{
+        std::string tmpLabel;
+        int i , size = (int) (lstPointsX.size());
+        fprintf(ff,"NumberOfPoints %d \n",size);
+        fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
+        int x, y, z;
+        double value;
+        for (i=0; i<size; i++)
+        {
+            x       = lstPointsX[i];
+            y       = lstPointsY[i];
+            z       = lstPointsZ[i];
+            value   = mimage->GetScalarComponentAsDouble(x,y,z,0);
+            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
+}
+
 //------------------------------------------------------------------------
 void ModelShowNPoints::SavePoints(std::string filename)
 {
-       std::string tmpLabel;
-       FILE *ff;
-       ff = fopen( filename.c_str() , "w+" );
-       if (ff!=NULL)
-       {
-               int i , size = (int) (lstPointsX.size());
-               fprintf(ff,"NumberOfPoints %d \n",size);
-               fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
-               int x, y, z;
-               double value;
-               for (i=0; i<size; i++)
-               {
-                       x=lstPointsX[i];
-                       y=lstPointsY[i];
-                       z=lstPointsZ[i];
-                       value= mimage->GetScalarComponentAsDouble(x,y,z,0);
-                       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
+       FILE* ff = fopen( filename.c_str() , "w+" );
+    if (ff!=NULL)
+    {
+        SavePoints_(ff);
                fclose(ff);
        } else {   // else ff
-               printf("ModelShowNPoints::SavePoints  ...Error... creating file");
+               printf("ModelShowNPoints::SavePoints  ...Error... creating file\n");
        } //ff
 }
 
+//------------------------------------------------------------------------
+int ModelShowNPoints::ReadPoints_(FILE* ff)
+{
+    int i,size;
+    char chartmp[256];
+    fscanf(ff," %s %d",chartmp,&size);
+    fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
+
+    float value;
+    int x,y,z;
+    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 );
+    }
+    return size;
+}
+
 //------------------------------------------------------------------------
 int ModelShowNPoints::ReadPoints(std::string filename)
 {
-       int i,size;
-       char chartmp[256];
-       FILE *ff;
-       ff = fopen( filename.c_str() , "r+" );
+    int size=0;
+       FILE *ff = fopen( filename.c_str() , "r+" );
        if (ff!=NULL)
        {
-               fscanf(ff," %s %d",chartmp,&size);
-               fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
-
-               float value;
-               int x,y,z;
-               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 );
-               }
+        size = ReadPoints_(ff);
                fclose(ff);
        } else {   // else ff
                printf("ModelShowNPoints::LoadPoints  ...Error... reading file");
index cee74951d95a3f4518afe43dcb3a1ded96fd03ab..b56348c59eb9f8e0eeecba831d75deb770c77377 100644 (file)
@@ -23,7 +23,9 @@ class ModelShowNPoints
          double                                        Distance(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
          int                                           InsertPoint(int x, int y, int z, std::string label);
          void                                          SavePoints(std::string filename);
-         int                                           ReadPoints(std::string filename);
+      void                      SavePoints_(FILE* ff);
+
+      int                                              ReadPoints(std::string filename);
          int                                           GetNearestPoint();
 
          int                                           GetLstPointsSize();
index ac81dd792d76a0eb84dc06b48c871eb00bd64666..0af0e4532675941e3d3489f350d35164bbe0557a 100644 (file)
@@ -7,7 +7,7 @@
 ViewShowNPoints::ViewShowNPoints(ModelShowNPoints* modelShowNPoints)
 {
     renderer                    = NULL;
-    mmodelShowNPoints=modelShowNPoints;
+    mmodelShowNPoints           = modelShowNPoints;
 }
 //----------------------------------------------------------------------
 
@@ -41,13 +41,19 @@ void ViewShowNPoints::RefreshPoint(int id)
 }
 
 //------------------------------------------------------------------------
-void ViewShowNPoints::RefreshPoints()
+void ViewShowNPoints::RefreshEachPoint()
 {
     int id,size=lstActorsSphere.size();
     for (id=0;id<size;id++)
     {
         RefreshPoint(id);
     } // for
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::RefreshPoints()
+{
+    RefreshEachPoint();
     renderer->GetRenderWindow()->Render();
 }
 
@@ -56,8 +62,8 @@ void ViewShowNPoints::AddVtkPoint()
 {
     // Sphere
     vtkSphereSource *vtksphere = vtkSphereSource::New();
-    vtksphere->SetThetaResolution (20);
-    vtksphere->SetPhiResolution (20);
+    vtksphere->SetThetaResolution (10);
+    vtksphere->SetPhiResolution (10);
     vtksphere->SetRadius( 1 );
     //NTU: For updating points
     lstSourceSphere.push_back(vtksphere);
@@ -134,5 +140,5 @@ ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
 //------------------------------------------------------------------------
 void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints*  modelShowNPoints)
 {
-    mmodelShowNPoints=modelShowNPoints;
+    mmodelShowNPoints = modelShowNPoints;
 }
index 168d86a15ef24c7016befbb100abb0e9bd599194..d70292c2bafb53bf2c361a056d6d2e067048b067 100644 (file)
@@ -22,6 +22,7 @@ class ViewShowNPoints
       ModelShowNPoints* GetModelShowNPoints();
       void SetModelShowNPoints(ModelShowNPoints* modelShowNPoints);
       void RefreshPoint(int id);
+      void RefreshEachPoint();
       void RefreshPoints();
       void AddVtkPoint();
       void AddPoint();
index f97d8cd6fb1221642cd2ef60cb2824fd8b634066..eb35406713a43fc164c1c8b40f117bb907a0aff4 100644 (file)
@@ -42,9 +42,6 @@
     wxPanel*    panel               = NULL;
     wxPanel*    panel2              = NULL;
 
-
-      
-
       bookSetPoints     = new wxNotebook(panelParent,
                           -1,
                           wxDefaultPosition,
           txtNrCollections                      = new wxStaticText(panel2,-1, _T("1   /  1 "));
           wxButton *btnBackCollection           = new wxButton( panel2, -1, _T("<"));
           wxButton *btnNextCollection           = new wxButton( panel2, -1, _T(">"));
-          wxButton *btnInsertCollectionBefore   = new wxButton( panel2, -1, _T("Insert Before"));
-          wxButton *btnInsertCollectionAfter    = new wxButton( panel2, -1, _T("Insert After"));
-          wxButton *btnDeleteCollection         = new wxButton( panel2, -1, _T("Delete"));
-
-          Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore);
-          Connect(btnInsertCollectionAfter->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter);
-          Connect(btnDeleteCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection);
-          Connect(btnBackCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection);
-          Connect(btnNextCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection);
+          wxButton *btnInsertCollectionBefore   = new wxButton( panel2, -1, _T("Insert Group Before"));
+          wxButton *btnInsertCollectionAfter    = new wxButton( panel2, -1, _T("Insert Group After"));
+          wxButton *btnDeleteCollection         = new wxButton( panel2, -1, _T("Delete Group "));
+          wxButton *btnSaveCollection           = new wxButton( panel2, -1, _T("Save Groups"));
+          wxButton *btnLoadCollection           = new wxButton( panel2, -1, _T("Load Groups"));
+
+          //NTU: Sliders for opacity and radio change
+          wxStaticText* txOpacity         = new wxStaticText(panel2, -1, wxString(_T("  Points Opacity  ")));
+          sdrOpacity                      = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+          wxStaticText* txRadio           = new wxStaticText(panel2, -1, wxString(_T("  Points Radius  ")));
+          sdrRadio                        = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+          //NTU: Slider events
+          Connect(sdrOpacity->GetId()    , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+          Connect(sdrRadio->GetId()      , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+        
+          Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore   );
+          Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter    );
+          Connect(btnDeleteCollection->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection         );
+          Connect(btnBackCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection           );
+          Connect(btnSaveCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections          );
+          Connect(btnLoadCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections          );
 
           wxFlexGridSizer *sizer1               = new wxFlexGridSizer(1);
           wxFlexGridSizer *sizer2               = new wxFlexGridSizer(2);
           sizer1->Add( btnInsertCollectionBefore );
           sizer1->Add( btnInsertCollectionAfter );
           sizer1->Add( btnDeleteCollection );
+        
+          sizer1->Add( txOpacity );
+          sizer1->Add( sdrOpacity );
+          sizer1->Add( txRadio );
+          sizer1->Add( sdrRadio );
+
+          sizer1->Add( btnSaveCollection );
+          sizer1->Add( btnLoadCollection );
           MNPsizer                        = sizer1;
           panel2->SetSizer( MNPsizer );
           panel2->SetAutoLayout(true);
           panel2->Layout();
-          bookGroupManager->AddPage(panel2 , _T("Collection") );
+          bookGroupManager->AddPage(panel2 , _T("Groupts") );
     } // if mtype 4
 
        if ( (mtype==0) || (mtype==3) || (mtype==4) )
                wxButton *btnDeleteAllPoints    = new wxButton( panel, -1, _T("Delete all points"));
                wxButton *btnSavePoints                 = NULL;
                wxButton *btnLoadPoints                 = NULL;
-               if ( (mtype==0) || (mtype==4) )
+               if ( mtype==0 )
                {
                        btnSavePoints                           = new wxButton( panel, -1, _T("Save points"));
                        btnLoadPoints                           = new wxButton( panel, -1, _T("Load points"));
+            Connect(btnSavePoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
+            Connect(btnLoadPoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
                } // if mtype
                txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
 
-               //NTU: Sliders for opacity and radio change
-               wxStaticText* txOpacity         = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
-               sdrOpacity                      = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
-               wxStaticText* txRadio           = new wxStaticText(panel, -1, wxString(_T("  Points Radius  ")));
-               sdrRadio                        = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+        wxStaticText* txOpacity;
+        wxStaticText* txRadio;
+        if ( (mtype==0) || (mtype==3) )
+        {
+            //NTU: Sliders for opacity and radio change
+            txOpacity         = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
+            sdrOpacity        = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+            txRadio           = new wxStaticText(panel, -1, wxString(_T("  Points Radius  ")));
+            sdrRadio          = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+            //NTU: Slider events
+            Connect(sdrOpacity->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+            Connect(sdrRadio->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+        } // if mtype 0 3
 
                Connect(btnAddPoint->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
                Connect(btnInsertPoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
                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);
-               if ((mtype==0) || (mtype==4) )
-               {
-                       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);
+
 
         wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
                sizer1->Add(askPointLabel); // JPR
                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 );
-        if ((mtype==0) || (mtype==4) )
+        
+        if ( (mtype==0) || (mtype==3) )
+        {
+            sizer1->Add(txOpacity);
+            sizer1->Add(sdrOpacity,1,wxGROW );
+            sizer1->Add(txRadio);
+            sizer1->Add(sdrRadio,1,wxGROW );
+        }  // if mtype 0 3
+        if ( mtype==0 )
                {
                        sizer1->Add(btnSavePoints);
                        sizer1->Add(btnLoadPoints);
-               }
+               } // if mtype 0
                sizer = sizer1;
        }
 
       panel->SetSizer(sizer);
       panel->SetAutoLayout(true);
       panel->Layout();
-      bookSetPoints->AddPage(panel , _T("Set Points") );
+      bookSetPoints->AddPage(panel , _T("Points") );
 
     if ((mtype >= 0) && (mtype <= 3) )
     {
@@ -695,7 +719,8 @@ void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
         lstViewShowNPoints[i]->mopacity = opacity;
         lstModelShowNPoints[i]->SetRadio( radio ) ;
     } // for i
-    GetViewShowNPoints()->RefreshPoints();
+//    GetViewShowNPoints()->RefreshPoints();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -781,6 +806,7 @@ void WidgetShowNPoints::InsertCollection()
 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
 {
     InsertCollection();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -788,6 +814,7 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
 {
     mActualCollection++;
     InsertCollection();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -802,8 +829,12 @@ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
         {
             mActualCollection--;
         } // if
-    }
+    } else {
+        DeleteAllPoints();  // Actual Collection
+    } // if
+
     RefreshCollectionText();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -815,6 +846,7 @@ void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
         mActualCollection=0;
     } //if <=0
     RefreshCollectionText();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -826,6 +858,31 @@ void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
         mActualCollection = lstModelShowNPoints.size()-1;
     } //if <=0
     RefreshCollectionText();
+    RefreshColourCollection();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::RefreshColourCollection()
+{
+    std::vector<double> colourAll;
+    colourAll.push_back(1);
+    colourAll.push_back(0);
+    colourAll.push_back(0);
+    std::vector<double> colourActual;
+    colourActual.push_back(1);
+    colourActual.push_back(1);
+    colourActual.push_back(0);
+    SetColour( colourAll );                                             // For all collections
+    
+    int i,size=lstViewShowNPoints.size();
+    for (i=0;i<size;i++)
+    {
+        lstViewShowNPoints[i] -> mcolour = colourAll;    // All collection
+        lstViewShowNPoints[i]->RefreshEachPoint();
+    } // for i
+    lstViewShowNPoints[mActualCollection] -> mcolour = colourActual;    // Actual collection
+    lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
+    lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
 }
 
 //------------------------------------------------------------------------
@@ -836,3 +893,118 @@ void WidgetShowNPoints::RefreshCollectionText()
     txtNrCollections->SetLabel( strTmp );
     SetOutputBox();
 }
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
+{
+    //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+    #if wxMAJOR_VERSION <= 2
+            wxFileDialog* FD = new wxFileDialog( 0,
+                                                _T("Save groups of points .."),
+                                                _T(""),
+                                                _T(""),
+                                                _T("(*.xls)|*.xls"),
+                                                wxSAVE | wxOVERWRITE_PROMPT,
+                                                wxDefaultPosition);
+    #else
+            wxFileDialog* FD = new wxFileDialog( 0,
+                                                _T("Save groups of points .."),
+                                                _T(""),
+                                                _T(""),
+                                                _T("(*.xls)|*.xls"),
+                                                wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+                                                wxDefaultPosition);
+    #endif
+
+            int result_FD = FD->ShowModal();
+            // This line is need it by windows //EED
+            FD->SetReturnCode( result_FD );
+            if (FD->GetReturnCode()==wxID_OK)
+            {
+                std::string filename= (const char*) ( FD->GetPath().mb_str() );
+
+                FILE *ff;
+                ff = fopen( filename.c_str() , "w+" );
+                if (ff!=NULL)
+                {
+                    int i,size=lstModelShowNPoints.size();
+                    fprintf(ff,"NumberOfGroups %d \n",size);
+
+                    for (i=0;i<size;i++)
+                    {
+                        lstModelShowNPoints[i]->SavePoints_(ff);
+                    } // for i
+
+                    fclose(ff);
+                } else {   // else ff
+                    printf("WidgetShowNPoints::Save Groups Points  ...Error... creating file \n");
+                } //ff
+
+                
+            }     // dialog box
+
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
+{
+    //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
+    #if wxMAJOR_VERSION <= 2
+            wxFileDialog* FD = new wxFileDialog( 0,
+                                                 _T("Load groups of points .."),
+                                                 _T(""),
+                                                 _T(""),
+                                                 _T("(*.xls)|*.xls"),
+                                                 wxOPEN | wxFILE_MUST_EXIST,
+                                                 wxDefaultPosition);
+    #else
+            wxFileDialog* FD = new wxFileDialog( 0,
+                                                 _T("Load groups of points .."),
+                                                 _T(""),
+                                                 _T(""),
+                                                 _T("(*.xls)|*.xls"),
+                                                 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
+                                                 wxDefaultPosition);
+    #endif
+            int i;
+            //EED
+            int result_FD = FD->ShowModal();
+            // This line is need it by windows //EED
+            FD->SetReturnCode( result_FD );
+            if (FD->GetReturnCode()==wxID_OK)
+            {
+
+                FILE *ff = fopen( filename.c_str() , "r+" );
+                if (ff!=NULL)
+                {
+                    int iGroup,sizeGroups;
+                    int iPoint,numberPointsRead
+                    char chartmp[256];
+                    fscanf(ff," %s %d",chartmp,&sizeGroups);
+                    
+                    /// InsertCollection(); 
+                    
+                    for (iGroup=0;i<sizeGroups;i++)
+                    {
+                        int numberPointsRead= lstModelShowNPoints?????????[i]->ReadPoints_(ff);
+                        for (i=0;i<numberPointsRead;i++)
+                        {
+                            // EED 2022-05-19
+                            //AddVtkPoint();
+                            GetViewShowNPoints?????()->AddVtkPoint();
+                        }// for
+                    } // for i
+
+                    fclose(ff);
+                } else {   // else ff
+                    printf("WidgetShowNPoints::Load Group of Points  ...Error... reading file");
+                } //ff
+                
+                RefreshCollectionText();
+                RefreshColourCollection();
+
+            }     // dialog box
+
+///
+    
+}
index a0b664a48ea85ebc5a1b94e80c5c08fced16afcf..b701facde79d0d9e83175ef20128a161b41dd5e9 100644 (file)
@@ -16,7 +16,7 @@ class WidgetShowNPoints : public wxPanel
          WidgetShowNPoints( wxWindow *parent , int type );
          ~WidgetShowNPoints(); 
          void OnAddPoint(wxCommandEvent &event);   
-         void OnInsertPoint (wxCommandEvent& event);//CFT
+         void OnInsertPoint(wxCommandEvent& event);//CFT
          void OnSetPoint(wxCommandEvent& event);
          void OnRenamePoint(wxCommandEvent& event);
          void OnErasePoint(wxCommandEvent& event);
@@ -33,11 +33,14 @@ class WidgetShowNPoints : public wxPanel
       void OnDeleteCollection(wxCommandEvent &event);
       void OnBackCollection(wxCommandEvent &event);
       void OnNextCollection(wxCommandEvent &event);
+      void OnSaveCollections(wxCommandEvent &event);
+      void OnLoadCollections(wxCommandEvent &event);
 
       void RefreshCollectionText();
+      void RefreshColourCollection();
 
     
-    // EED 2022-05-19
+      // EED 2022-05-19
          //void RefreshPoint(int id);
       //void RefreshPoints();
       //void AddVtkPoint();