]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
#3485 ShowNPionts for Multiple Groups
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / WidgetShowNPoints.cxx
1
2
3 #include "vtkSphereSource.h"
4 #include "vtkRenderer.h"
5 #include "vtkTextActor3D.h"
6
7
8
9 #include <wx/button.h>
10 #include <wx/checkbox.h>
11 #include <wx/sizer.h>
12 #include <wx/filedlg.h>
13 #include <wx/msgdlg.h>
14 #include <wx/notebook.h>
15
16 #include "WidgetShowNPoints.h"
17
18
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 //----------------------------------------------------------------------
24   WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
25     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
26   {
27     printf("EED WidgetShowNPoints::WidgetShowNPoints Start \n");
28         // EED 2022-05-19
29     //  mmodelShowNPoints                                = new ModelShowNPoints();
30                         mActualCollection= 0;
31     ModelShowNPoints*   modelShowNPoints = new ModelShowNPoints();
32     lstModelShowNPoints.push_back( modelShowNPoints );
33     lstViewShowNPoints.push_back( new  ViewShowNPoints( modelShowNPoints ) );
34       
35     mtype                                                       = type;
36     SetType(mtype);
37     wxPanel*    panelParent         = this;
38     wxSizer*    sizer                           = NULL;
39     wxSizer*    MNPsizer            = NULL;
40
41     wxNotebook* bookSetPoints       = NULL;
42     wxNotebook* bookGroupManager    = NULL;
43     wxPanel*    panel               = NULL;
44     wxPanel*    panel2              = NULL;
45
46       bookSetPoints     = new wxNotebook(panelParent,
47                           -1,
48                           wxDefaultPosition,
49                           wxDefaultSize,
50                           wxNB_TOP );
51       panel  = new wxPanel(bookSetPoints);
52
53
54     // Group Manager
55     if (mtype==4)
56     {
57           bookGroupManager   = new wxNotebook(panelParent, //bbGetWxParent(),
58                               -1,
59                               wxDefaultPosition,
60                               wxDefaultSize,
61                               wxNB_TOP );
62           panel2  = new wxPanel(bookGroupManager);
63           txtNrCollections                      = new wxStaticText(panel2,-1, _T("1   /  1 "));
64           wxButton *btnBackCollection           = new wxButton( panel2, -1, _T("<"));
65           wxButton *btnNextCollection           = new wxButton( panel2, -1, _T(">"));
66           wxButton *btnInsertCollectionBefore   = new wxButton( panel2, -1, _T("Insert Group Before"));
67           wxButton *btnInsertCollectionAfter    = new wxButton( panel2, -1, _T("Insert Group After"));
68           wxButton *btnDeleteCollection         = new wxButton( panel2, -1, _T("Delete Group "));
69           wxButton *btnSaveCollection           = new wxButton( panel2, -1, _T("Save Groups"));
70           wxButton *btnLoadCollection           = new wxButton( panel2, -1, _T("Load Groups"));
71
72           wxFlexGridSizer *sizer1               = new wxFlexGridSizer(1);
73           wxFlexGridSizer *sizer2               = new wxFlexGridSizer(2);
74           wxStaticText* txOpacity               = new wxStaticText(panel2, -1, wxString(_T("  Points Opacity  ")));
75           sdrOpacity                            = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
76           wxStaticText* txRadio                 = new wxStaticText(panel2, -1, wxString(_T("  Points Radius  ")));
77           sdrRadio                              = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
78
79           Connect(btnBackCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection           );
80           Connect(btnNextCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection           );
81           Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore   );
82           Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter    );
83           Connect(btnDeleteCollection->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection         );
84           Connect(sdrOpacity->GetId()               , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints                );
85           Connect(sdrRadio->GetId()                 , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints                );
86           Connect(btnSaveCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections          );
87           Connect(btnLoadCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections          );
88
89         
90           sizer2->Add( btnBackCollection );
91           sizer2->Add( btnNextCollection );
92
93           sizer1->Add( txtNrCollections );
94           sizer1->Add( sizer2 );
95           sizer1->Add( btnInsertCollectionBefore );
96           sizer1->Add( btnInsertCollectionAfter );
97           sizer1->Add( btnDeleteCollection );
98         
99           sizer1->Add( txOpacity );
100           sizer1->Add( sdrOpacity );
101           sizer1->Add( txRadio );
102           sizer1->Add( sdrRadio );
103
104           sizer1->Add( btnSaveCollection );
105           sizer1->Add( btnLoadCollection );
106           MNPsizer                        = sizer1;
107           panel2->SetSizer( MNPsizer );
108           panel2->SetAutoLayout(true);
109           panel2->Layout();
110           bookGroupManager->AddPage(panel2 , _T("Groupts") );
111     } // if mtype 4
112
113         if ( (mtype==0) || (mtype==3) || (mtype==4) )
114         {
115                 // Widget interface
116                 askPointLabel                                   = new wxStaticText(panel, -1, _T("Point label :")); // JPR
117                 textCtrl                                                = new wxTextCtrl(panel, -1);
118                 wxButton    *btnAddPoint                = new wxButton( panel, -1, _T("Add Point"));
119                 wxButton    *btnInsertPoint             = new wxButton( panel, -1, _T("Insert Point"));//CFT
120                 wxButton    *btnSetPositionPoint= new wxButton( panel, -1, _T("Set nearest point"));
121         wxCheckBox  *chkBox             = new wxCheckBox(panel, -1, _T("Track Point") );
122         wxButton    *btnRenamePoint             = new wxButton( panel, -1, _T("Rename point"));
123                 wxButton    *btnEraseLastPoint  = new wxButton( panel, -1, _T("Erase Last point"));
124                 wxButton    *btnErasePoint              = new wxButton( panel, -1, _T("Erase point"));
125                 wxButton    *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
126                 wxButton    *btnSavePoints              = NULL;
127                 wxButton    *btnLoadPoints              = NULL;
128                 if ( mtype==0 )
129                 {
130                         btnSavePoints                           = new wxButton( panel, -1, _T("Save points"));
131                         btnLoadPoints                           = new wxButton( panel, -1, _T("Load points"));
132             Connect(btnSavePoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
133             Connect(btnLoadPoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
134                 } // if mtype
135                 txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
136
137         wxStaticText* txOpacity;
138         wxStaticText* txRadio;
139         if ( (mtype==0) || (mtype==3) )
140         {
141             //NTU: Sliders for opacity and radio change
142             txOpacity         = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
143             sdrOpacity        = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
144             txRadio           = new wxStaticText(panel, -1, wxString(_T("  Points Radius  ")));
145             sdrRadio          = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
146             //NTU: Slider events
147             Connect(sdrOpacity->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
148             Connect(sdrRadio->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
149         } // if mtype 0 3
150
151                 Connect(btnAddPoint->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
152                 Connect(btnInsertPoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
153                 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
154                 Connect(btnRenamePoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
155                 Connect(btnEraseLastPoint->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
156                 Connect(btnErasePoint->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
157                 Connect(btnDeleteAllPoints->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
158
159
160         wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
161                 sizer1->Add(askPointLabel); // JPR
162                 sizer1->Add(textCtrl);
163                 sizer1->Add(btnAddPoint);
164                 sizer1->Add(btnInsertPoint);//CFT
165         sizer1->Add(chkBox);
166                 sizer1->Add(btnSetPositionPoint);
167                 sizer1->Add(btnRenamePoint);
168                 sizer1->Add(btnErasePoint);
169                 sizer1->Add(btnEraseLastPoint);
170                 sizer1->Add(btnDeleteAllPoints);
171                 sizer1->Add(txtNrPoints);
172         
173         if ( (mtype==0) || (mtype==3) )
174         {
175             sizer1->Add(txOpacity);
176             sizer1->Add(sdrOpacity,1,wxGROW );
177             sizer1->Add(txRadio);
178             sizer1->Add(sdrRadio,1,wxGROW );
179         }  // if mtype 0 3
180         if ( mtype==0 )
181                 {
182                         sizer1->Add(btnSavePoints);
183                         sizer1->Add(btnLoadPoints);
184                 } // if mtype 0
185                 sizer = sizer1;
186         }
187
188           if (mtype==1)
189           {
190                   // Widget interface
191                   wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set nearest point"));
192                   txtNrPoints                                           = new wxStaticText(panel,-1, _T(" "));
193
194                   //NTU: Sliders for opacity and radio change
195                   wxStaticText* txOpacity                       = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
196                   sdrOpacity                                            = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
197                   wxStaticText* txRadio                         = new wxStaticText(panel, -1, wxString(_T("  Points Radio  ")));
198                   sdrRadio                                                      = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
199                   Connect(btnSetPositionPoint->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
200                   Connect(sdrOpacity->GetId()   , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
201                   Connect(sdrRadio->GetId()     , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
202
203           wxFlexGridSizer *sizer1            = new wxFlexGridSizer(1);
204                   sizer1->Add(btnSetPositionPoint);
205                   sizer1->Add(txtNrPoints);
206                   sizer1->Add(txOpacity);
207                   sizer1->Add(sdrOpacity,1,wxGROW );
208                   sizer1->Add(txRadio);
209                   sizer1->Add(sdrRadio,1,wxGROW );
210                   sizer = sizer1;
211           }
212     
213     if (mtype == 2) 
214         {
215                 askPointLabel                                           = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
216         wxButton                *btnAddPoint            = new wxButton(panel, -1,        _T("      Add  Point      "));
217         wxButton                *btnDeleteAllPoints = new wxButton(panel, -1, _T("      Delete All      "));
218         wxStaticText    *spacer                         = new wxStaticText(panel, -1, _T("\n")); // JPR
219                                          textCtrl                       = new wxTextCtrl(panel, -1);
220         Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
221         Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);    
222         wxFlexGridSizer *sizer1             = new wxFlexGridSizer(1);
223         sizer1->Add(askPointLabel);
224         sizer1->Add(btnAddPoint);
225         sizer1->Add(btnDeleteAllPoints);
226         sizer1->Add(spacer);
227         sizer1->Add(textCtrl);
228       //  sdrOpacity                          = new wxSlider();
229       //  sdrRadio                            = new wxSlider();
230         txtNrPoints                         = new wxStaticText(panel, -1, _T("\n\n\n"));
231         sizer                               = sizer1;
232         } // bbGetInputType 2
233
234             
235       panel->SetSizer(sizer);
236       panel->SetAutoLayout(true);
237       panel->Layout();
238       bookSetPoints->AddPage(panel , _T("Points") );
239
240     if ((mtype >= 0) && (mtype <= 3) )
241     {
242         if (sizer!=NULL)
243         {
244             wxFlexGridSizer *sizerParent             = new wxFlexGridSizer(1);
245             sizerParent->Add( bookSetPoints );
246             panelParent->SetSizer( sizerParent );
247             panelParent->SetAutoLayout(true);
248             panelParent->Layout();
249         } // if sizer
250     } // if  mtype 0 1 2 3
251       
252     if (mtype == 4)
253     {
254         if ((sizer!=NULL) && (MNPsizer!=NULL))
255         {
256             wxFlexGridSizer *sizerG             = new wxFlexGridSizer(2);
257             sizerG->Add(bookGroupManager);
258             sizerG->Add(bookSetPoints);
259             panelParent->SetSizer(sizerG);
260             panelParent->SetAutoLayout(true);
261             panelParent->Layout();
262         } // if sizer
263     } // if mtype 4
264 }
265
266 //------------------------------------------------------------------------
267 WidgetShowNPoints::~WidgetShowNPoints()
268 {
269 }
270
271 //------------------------------------------------------------------------
272 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
273 {
274     // EED 2022-05-19
275     // return mmodelShowNPoints;
276     return lstModelShowNPoints[ mActualCollection ];
277 }
278
279 // EED 2022-05-19
280 //------------------------------------------------------------------------
281 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
282 {
283     return lstViewShowNPoints[ mActualCollection ];
284 }
285
286
287 //------------------------------------------------------------------------
288 void WidgetShowNPoints::SetRadio(double radio)
289 {
290     // EED 2022-05-19
291     // GetModelShowNPoints()->SetRadio(radio);
292     int i,size = lstModelShowNPoints.size();
293     for (i=0;i<size;i++)
294     {
295         lstModelShowNPoints[i]->SetRadio( radio );
296     } // for i
297         //NTU: For Slider
298         sdrRadio->SetValue(radio);
299 }
300
301 //------------------------------------------------------------------------
302 void WidgetShowNPoints::SetColour(std::vector<double> colour)
303 {
304     // EED 2022-05-19
305     //this->mcolour = colour;
306     int i,size = lstViewShowNPoints.size();
307     for (i=0 ; i<size ; i++)
308     {
309         lstViewShowNPoints[i]->mcolour = colour;
310     } // for i
311 }
312
313 //------------------------------------------------------------------------
314 void WidgetShowNPoints::SetImage(vtkImageData* image)
315 {
316     // EED 2022-05-19
317         //GetModelShowNPoints()->SetImage(image);
318     int i,size = lstModelShowNPoints.size();
319     for (i=0 ; i<size ; i++)
320     {
321         lstModelShowNPoints[i]->SetImage(image);
322     } // for i
323 }
324
325 //------------------------------------------------------------------------
326 void WidgetShowNPoints::SetOpacity(double opacity)
327 {
328     // EED 2022-05-19
329         //this->mopacity=opacity;
330     int i,size = lstViewShowNPoints.size();
331     for (i=0 ; i<size ; i++)
332     {
333         lstViewShowNPoints[i]->mopacity = opacity;
334     } // for i
335         //NTU: For Slider
336         sdrOpacity->SetValue( opacity*100.0 );
337 }
338
339
340 //------------------------------------------------------------------------
341 void  WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
342 {
343     // EED 2022-05-19
344         //this->renderer        = renderer;
345     int i,size = lstViewShowNPoints.size();
346     for (i=0 ; i<size ; i++)
347     {
348         lstViewShowNPoints[i]->renderer = renderer;
349     } // for i
350 }
351
352 /* EED 2022-05-19
353 //------------------------------------------------------------------------
354         
355 void WidgetShowNPoints::RefreshPoint(int id)
356 {
357         double spc[3];
358         int x,y,z;
359         GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
360         GetModelShowNPoints()->GetImage()->GetSpacing(spc);
361         std::string label       = GetModelShowNPoints()->GetIdLabel(id);
362         double radio            = GetModelShowNPoints()->GetRadio();
363     lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
364     lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
365     lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
366     lstSourceSphere[id]->SetRadius( radio );
367 //EED 2017-01-01 Migration VTK7
368 #if VTK_MAJOR_VERSION <= 5
369         // ..
370 #else
371     lstSourceSphere[id]->Update();
372 #endif
373     lstActorsText[id]->SetInput( label.c_str()  );
374     lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
375 }
376
377 //------------------------------------------------------------------------
378 void WidgetShowNPoints::RefreshPoints()
379 {
380         int id,size=lstActorsSphere.size();
381         for (id=0;id<size;id++)
382         {
383                 RefreshPoint(id);
384         } // for
385         renderer->GetRenderWindow()->Render();
386 }
387
388 //------------------------------------------------------------------------
389 void WidgetShowNPoints::AddVtkPoint()
390 {
391         // Sphere
392         vtkSphereSource *vtksphere = vtkSphereSource::New();
393         vtksphere->SetThetaResolution (20);
394         vtksphere->SetPhiResolution (20);
395         vtksphere->SetRadius( 1 );
396         //NTU: For updating points
397         lstSourceSphere.push_back(vtksphere);
398         vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
399
400 //EED 2017-01-01 Migration VTK7
401 #if VTK_MAJOR_VERSION <= 5
402         sphereMapper->SetInput( vtksphere->GetOutput() );
403 #else
404         vtksphere->Update();
405         sphereMapper->SetInputData( vtksphere->GetOutput() );
406 #endif
407
408         vtkActor *sphereActor   = vtkActor::New();
409         sphereActor->SetMapper(sphereMapper);
410         sphereActor->SetOrigin(0, 0, 0);
411
412         lstActorsSphere.push_back(sphereActor);
413         if(renderer==NULL){
414                 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
415                 dialog.ShowModal();             
416                 return;
417         }
418         renderer->AddActor( sphereActor );
419         // Actor
420         vtkTextActor3D *textActor = vtkTextActor3D::New();
421 //      textActor->SetInput( strLabel.c_str()  );
422         renderer->AddActor( textActor );
423         lstActorsText.push_back(textActor);
424 }
425  */
426
427
428 //------------------------------------------------------------------------
429 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
430 {
431         GetModelShowNPoints()->AddPoint(x,y,z, label );
432     // EED 2022-05-19
433     //AddVtkPoint();
434     //RefreshPoint(lstActorsSphere.size()-1);
435     GetViewShowNPoints()->AddPoint();
436 }
437
438 //------------------------------------------------------------------------
439 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
440 {
441     // EED 2022-05-19
442         //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
443         //{
444     //    AddVtkPoint();
445         //} else {
446         //      AddPoint(x,y,z,label);
447         //}
448         //RefreshPoints();
449     if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
450     {
451         GetViewShowNPoints()->AddVtkPoint();
452     } else {
453         AddPoint(x,y,z,label);
454     }
455     GetViewShowNPoints()->RefreshPoints();
456
457 }
458
459 //------------------------------------------------------------------------
460 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
461 {       
462     // EED 2022-05-19
463         //if (this->renderer==NULL)
464     if (GetViewShowNPoints()->renderer==NULL)
465         {
466                 return;
467         }
468
469         std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
470         if (point.size()==3)
471         {
472                 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
473                 SetOutputBox();
474         // EED 2022-05-19
475         //renderer->GetRenderWindow()->Render();
476         GetViewShowNPoints()->Render();
477         } else {//mpoint.size
478                 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
479         }
480 }
481
482 //------------------------------------------------------------------------
483 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
484 {       
485     // EED 2022-05-19
486     //if (this->renderer==NULL)
487     if (GetViewShowNPoints()->renderer==NULL)
488         {
489                 return;
490         }
491
492         std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
493         if (point.size()==3)
494         {
495                 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
496                 SetOutputBox();
497         } else {//mpoint.size
498                 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
499         }
500 }
501
502
503 //------------------------------------------------------------------------
504         void WidgetShowNPoints::SetOutputBox()
505         {
506 //EED           renderer->GetRenderWindow()->Render();
507                 wxString strTmp;
508                 strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
509                 txtNrPoints->SetLabel( strTmp );
510                 //--BBTK
511
512 //EED 2017-06-03
513 //              mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
514 //              mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
515 //              mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
516 //              mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
517 //              mbbShowNPoints->bbSignalOutputModification();
518         }
519
520
521 //------------------------------------------------------------------------
522         void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
523         {
524
525 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
526 #if wxMAJOR_VERSION <= 2
527                 wxFileDialog* FD = new wxFileDialog( 0,
528                                             _T("Save points .."),
529                                             _T(""),
530                                             _T(""),
531                                             _T("(*.xls)|*.xls"),
532                                             wxSAVE | wxOVERWRITE_PROMPT,
533                                             wxDefaultPosition);
534 #else
535                 wxFileDialog* FD = new wxFileDialog( 0,
536                                             _T("Save points .."),
537                                             _T(""),
538                                             _T(""),
539                                             _T("(*.xls)|*.xls"),
540                                             wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
541                                             wxDefaultPosition);
542 #endif
543
544                 int result_FD = FD->ShowModal();
545                 // This line is need it by windows //EED
546                 FD->SetReturnCode( result_FD );
547                 if (FD->GetReturnCode()==wxID_OK)
548                 {
549                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
550                         GetModelShowNPoints()->SavePoints( filename );
551                 }       // dialog box
552         }
553
554
555 //------------------------------------------------------------------------
556         void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
557         {
558
559 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
560 #if wxMAJOR_VERSION <= 2
561                 wxFileDialog* FD = new wxFileDialog( 0,
562                                              _T("Load points .."),
563                                              _T(""),
564                                              _T(""),
565                                              _T("(*.xls)|*.xls"),
566                                              wxOPEN | wxFILE_MUST_EXIST,
567                                              wxDefaultPosition);
568 #else
569                 wxFileDialog* FD = new wxFileDialog( 0,
570                                              _T("Load points .."),
571                                              _T(""),
572                                              _T(""),
573                                              _T("(*.xls)|*.xls"),
574                                              wxFD_OPEN | wxFD_FILE_MUST_EXIST,
575                                              wxDefaultPosition);
576 #endif
577                 int i;
578                 //EED
579                 int result_FD = FD->ShowModal();
580                 // This line is need it by windows //EED
581                 FD->SetReturnCode( result_FD );
582                 if (FD->GetReturnCode()==wxID_OK)
583                 {
584
585                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
586                         int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
587                         for (i=0;i<numberPointsRead;i++)
588                         {
589                 // EED 2022-05-19
590                 //AddVtkPoint();
591                 GetViewShowNPoints()->AddVtkPoint();
592                         }// for
593                         SetOutputBox();
594             // EED 2022-05-19
595                         //RefreshPoints();
596             GetViewShowNPoints()->RefreshPoints();
597                 }       // dialog box
598         }
599
600         //------------------------------------------------------------------------
601         void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
602         {
603                 int id=GetModelShowNPoints()->GetNearestPoint();
604                 if((id==-1) && (mtype==1))
605                 {
606                         id=0;
607                         AddPoint(0,0,0,"");
608                         SetOutputBox();
609                 }
610         
611                 if (id>=0)
612                 {
613                         GetModelShowNPoints()->SetPointId_mReferencePoint(id);
614             // EED 2022-05-19
615                         //RefreshPoint(id);
616                         //renderer->GetRenderWindow()->Render();
617             GetViewShowNPoints()->RefreshPoint(id);
618             GetViewShowNPoints()->Render();
619                 } // if id
620                 SetOutputBox();
621         }
622         
623 //------------------------------------------------------------------------
624         void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
625         {
626                 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
627                 if (id>=0)
628                 {
629             // EED 2022-05-19
630                         //lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
631                         //renderer->GetRenderWindow()->Render();
632             GetViewShowNPoints()->lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
633             GetViewShowNPoints()->Render();
634             SetOutputBox();
635                 }
636         }
637
638 //------------------------------------------------------------------------
639         void WidgetShowNPoints::ErasePoint(int id)
640         {
641         // EED 2022-05-19
642                 //if (this->renderer!=NULL)
643         if (GetViewShowNPoints()->renderer!=NULL)
644                 {
645                         if (id>=0)
646                         {
647                 // EED 2022-05-19
648                                 //renderer->RemoveActor( lstActorsSphere[id] );
649                                 //renderer->RemoveActor( lstActorsText[id] );
650                                 //lstActorsSphere[id]->Delete();
651                                 //lstActorsText[id]->Delete();
652                                 //lstSourceSphere[id]->Delete();
653                                 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
654                                 //lstActorsText.erase( lstActorsText.begin()+id );
655                                 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
656                 GetViewShowNPoints()->ErasePoint(id);
657                                 GetModelShowNPoints()->ErasePoint(id);
658                         } // if id
659                 } // if renderer
660         }
661
662 //------------------------------------------------------------------------
663         void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
664         {
665                 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
666                 SetOutputBox();
667         // EED 2022-05-19
668                 //renderer->GetRenderWindow()->Render();
669         GetViewShowNPoints()->Render();
670         }
671
672 //------------------------------------------------------------------------
673         void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
674         {
675         // EED 2022-05-19
676         //ErasePoint( lstActorsSphere.size()-1 );
677         //renderer->GetRenderWindow()->Render();
678         int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
679         ErasePoint( id );
680         GetViewShowNPoints()->Render();
681         SetOutputBox();
682         }
683
684 //------------------------------------------------------------------------
685 void WidgetShowNPoints::DeleteAllPoints()
686 {
687     // EED 2022-05-19
688         //int id,size=lstActorsSphere.size();
689     int id,size=GetViewShowNPoints()->lstActorsSphere.size();
690         for (id=size-1;id>=0;id--)
691         {
692                 ErasePoint(id);
693         }
694         SetOutputBox();
695     // EED 2022-05-19
696         //renderer->GetRenderWindow()->Render();
697     GetViewShowNPoints()->Render();
698 }
699
700 //------------------------------------------------------------------------
701 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
702 {
703         DeleteAllPoints();
704 }
705
706 //NTU: Method for updating points opacity and Radio
707
708 //------------------------------------------------------------------------
709 void WidgetShowNPoints::UpdatePoints_()
710 {
711     // EED 2022-05-19
712     //this->mopacity = sdrOpacity->GetValue()/100.0;
713     //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
714     //RefreshPoints();
715
716     double opacity  = sdrOpacity->GetValue()/100.0;
717     double radio    = sdrRadio->GetValue();
718     int i,size      = lstViewShowNPoints.size();
719     for (i=0 ; i<size ; i++)
720     {
721         lstViewShowNPoints[i]->mopacity = opacity;
722         lstModelShowNPoints[i]->SetRadio( radio ) ;
723     } // for i
724 //    GetViewShowNPoints()->RefreshPoints();
725 }
726
727 //------------------------------------------------------------------------
728 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
729 {
730     RefreshColourCollection();
731 }
732
733 //------------------------------------------------------------------------
734 void  WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
735 {
736         GetModelShowNPoints()->SetReferencePoint(point);
737     int i,size=lstModelShowNPoints.size();
738     for (i=0;i<size;i++)
739     {
740         lstModelShowNPoints[i]->SetReferencePoint(point);    // All collection
741     } // for i
742 }
743
744 //------------------------------------------------------------------------
745 void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
746 {
747     // EED 2022-05-19
748         //if (this->renderer==NULL)
749     if (GetViewShowNPoints()->renderer==NULL)
750         {
751                 return;
752         }
753         int i,sizeX,sizeY,sizeZ,sizeLabels;
754         sizeX = (int)initLstPointsX.size();
755         sizeY = (int)initLstPointsY.size();
756         sizeZ = (int)initLstPointsZ.size();
757         sizeLabels = (int)initLstLabels.size();
758         int x,y,z;
759         std::string label;
760         if ( (sizeX==sizeY) && (sizeX==sizeZ) )
761         {
762                 for (i=0;i<sizeX;i++)
763                 {
764                         x               = initLstPointsX[i];
765                         y               = initLstPointsY[i];
766                         z               = initLstPointsZ[i];
767                         if (i<sizeLabels) 
768                         {
769                                 label   = initLstLabels[i];
770                         } else {
771                                 label="";
772                         }
773                         AddPoint( x,y,z,label );
774                 } // for i
775                 //      SetOutputBox(); 
776                 //      renderer->GetRenderWindow()->Render();
777         } // if size
778 }
779
780 //------------------------------------------------------------------------
781 void WidgetShowNPoints::SetType(int type)
782 {
783         mtype=type;
784 }
785
786 //------------------------------------------------------------------------
787 int WidgetShowNPoints::GetType()
788 {
789         return mtype;
790 }
791
792
793 //------------------------------------------------------------------------
794 double WidgetShowNPoints::GetRadio()
795 {
796         return sdrRadio->GetValue();
797 }
798 //------------------------------------------------------------------------
799 double WidgetShowNPoints::GetOpacity()
800 {
801         return sdrOpacity->GetValue()/100;
802 }
803
804 //------------------------------------------------------------------------
805 void WidgetShowNPoints::InsertCollection()
806 {
807     ModelShowNPoints*   model   = new ModelShowNPoints();
808     ViewShowNPoints*    view    = new ViewShowNPoints( model );
809     model->SetImage( lstModelShowNPoints[0]->GetImage() );
810     view->mopacity = lstViewShowNPoints[0]->mopacity;
811     view->renderer = lstViewShowNPoints[0]->renderer;
812     lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
813     lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
814     RefreshCollectionText();
815 }
816
817 //------------------------------------------------------------------------
818 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
819 {
820     InsertCollection();
821     RefreshColourCollection();
822 }
823
824 //------------------------------------------------------------------------
825 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
826 {
827     mActualCollection++;
828     InsertCollection();
829     RefreshColourCollection();
830 }
831
832 //------------------------------------------------------------------------
833 void WidgetShowNPoints::DeleteCollection_()
834 {
835     if ( lstModelShowNPoints.size()>1 )
836     {
837         DeleteAllPoints();  // Actual Collection
838         lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
839         lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
840         if ( mActualCollection>=lstModelShowNPoints.size() )
841         {
842             mActualCollection--;
843         } // if
844     } else {
845         DeleteAllPoints();  // Actual Collection
846     } // if
847 }
848
849 //------------------------------------------------------------------------
850 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
851 {
852     DeleteCollection_();
853     RefreshCollectionText();
854     RefreshColourCollection();
855 }
856
857 //------------------------------------------------------------------------
858 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
859 {
860     mActualCollection--;
861     if ( mActualCollection <0  )
862     {
863         mActualCollection=0;
864     } //if <=0
865     RefreshCollectionText();
866     RefreshColourCollection();
867 }
868
869 //------------------------------------------------------------------------
870 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
871 {
872     mActualCollection++;
873     if ( mActualCollection >=lstModelShowNPoints.size() )
874     {
875         mActualCollection = lstModelShowNPoints.size()-1;
876     } //if <=0
877     RefreshCollectionText();
878     RefreshColourCollection();
879 }
880
881 //------------------------------------------------------------------------
882 void WidgetShowNPoints::RefreshColourCollection()
883 {
884     UpdatePoints_();
885     std::vector<double> colourAll;
886     colourAll.push_back(1);
887     colourAll.push_back(0);
888     colourAll.push_back(0);
889     std::vector<double> colourActual;
890     colourActual.push_back(1);
891     colourActual.push_back(1);
892     colourActual.push_back(0);
893     SetColour( colourAll );                                             // For all collections
894     int i,size=lstViewShowNPoints.size();
895     for (i=0;i<size;i++)
896     {
897         lstViewShowNPoints[i] -> mcolour = colourAll;    // All collection
898         lstViewShowNPoints[i]->RefreshEachPoint();
899     } // for i
900     lstViewShowNPoints[mActualCollection] -> mcolour = colourActual;    // Actual collection
901     lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
902     lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
903 }
904
905 //------------------------------------------------------------------------
906 void WidgetShowNPoints::RefreshCollectionText()
907 {
908     wxString strTmp;
909     strTmp.Printf(_T("%d   /  %d "),  (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
910     txtNrCollections->SetLabel( strTmp );
911     SetOutputBox();
912 }
913
914 //------------------------------------------------------------------------
915 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
916 {
917     //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
918     #if wxMAJOR_VERSION <= 2
919             wxFileDialog* FD = new wxFileDialog( 0,
920                                                 _T("Save groups of points .."),
921                                                 _T(""),
922                                                 _T(""),
923                                                 _T("(*.xls)|*.xls"),
924                                                 wxSAVE | wxOVERWRITE_PROMPT,
925                                                 wxDefaultPosition);
926     #else
927             wxFileDialog* FD = new wxFileDialog( 0,
928                                                 _T("Save groups of points .."),
929                                                 _T(""),
930                                                 _T(""),
931                                                 _T("(*.xls)|*.xls"),
932                                                 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
933                                                 wxDefaultPosition);
934     #endif
935
936             int result_FD = FD->ShowModal();
937             // This line is need it by windows //EED
938             FD->SetReturnCode( result_FD );
939             if (FD->GetReturnCode()==wxID_OK)
940             {
941                 std::string filename= (const char*) ( FD->GetPath().mb_str() );
942
943                 FILE *ff;
944                 ff = fopen( filename.c_str() , "w+" );
945                 if (ff!=NULL)
946                 {
947                     int i,size=lstModelShowNPoints.size();
948                     fprintf(ff,"NumberOfGroups %d \n",size);
949
950                     for (i=0;i<size;i++)
951                     {
952                         lstModelShowNPoints[i]->SavePoints_(ff);
953                     } // for i
954
955                     fclose(ff);
956                 } else {   // else ff
957                     printf("WidgetShowNPoints::Save Groups Points  ...Error... creating file \n");
958                 } //ff
959
960                 
961             }     // dialog box
962
963 }
964
965 //------------------------------------------------------------------------
966 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
967 {
968     //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
969     #if wxMAJOR_VERSION <= 2
970             wxFileDialog* FD = new wxFileDialog( 0,
971                                                  _T("Load groups of points .."),
972                                                  _T(""),
973                                                  _T(""),
974                                                  _T("(*.xls)|*.xls"),
975                                                  wxOPEN | wxFILE_MUST_EXIST,
976                                                  wxDefaultPosition);
977     #else
978             wxFileDialog* FD = new wxFileDialog( 0,
979                                                  _T("Load groups of points .."),
980                                                  _T(""),
981                                                  _T(""),
982                                                  _T("(*.xls)|*.xls"),
983                                                  wxFD_OPEN | wxFD_FILE_MUST_EXIST,
984                                                  wxDefaultPosition);
985     #endif
986             bool okEraseFirstGrout=false;
987
988             int result_FD = FD->ShowModal();
989             // This line is need it by windows //EED
990             FD->SetReturnCode( result_FD );
991             if (FD->GetReturnCode()==wxID_OK)
992             {
993                 if (lstModelShowNPoints.size()==1)
994                 {
995                     if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGrout=true; }
996                 }
997                 std::string filename= (const char*) ( FD->GetPath().mb_str() );
998                 FILE *ff = fopen( filename.c_str() , "r+" );
999                 if (ff!=NULL)
1000                 {
1001                     int i;
1002                     int iGroup,sizeGroups;
1003                     int iPoint,numberPointsRead;
1004                     char chartmp[256];
1005                     fscanf(ff," %s %d",chartmp,&sizeGroups);
1006                     for (iGroup=0;iGroup<sizeGroups;iGroup++)
1007                     {
1008                         mActualCollection = lstModelShowNPoints.size();
1009                         InsertCollection();
1010
1011                         int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1012                         for (i=0;i<numberPointsRead;i++)
1013                         {
1014                             // EED 2022-05-19
1015                             //AddVtkPoint();
1016                             GetViewShowNPoints()->AddVtkPoint();
1017                         }// for
1018                     } // for i
1019
1020                     fclose(ff);
1021                 } else {   // else ff
1022                     printf("WidgetShowNPoints::Load Group of Points  ...Error... reading file");
1023                 } //ff
1024                 if (okEraseFirstGrout==true)
1025                 {
1026                     mActualCollection=0;
1027                     DeleteCollection_();
1028                     mActualCollection = lstModelShowNPoints.size()-1;
1029                 }
1030                 RefreshCollectionText();
1031                 RefreshColourCollection();
1032             }     // dialog box
1033 }
1034
1035
1036 //------------------------------------------------------------------------
1037 std::vector<int> WidgetShowNPoints::GetLstPointsX()
1038 {
1039     if (mtype!=4)
1040     {
1041         return GetModelShowNPoints()->GetLstPointsX();
1042     } else {
1043         std::vector<int> lst;
1044         int iP,s;
1045         int iG,sG=lstModelShowNPoints.size();
1046         for (iG=0 ; iG<sG ; iG++)
1047         {
1048             std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1049             s = lstTmp.size();
1050             for (iP=0 ; iP<s ; iP++)
1051             {
1052                 lst.push_back( lstTmp[iP] );
1053             } // for iP
1054         } // for iG
1055         return lst;
1056     } // if 4
1057 }
1058
1059 //------------------------------------------------------------------------
1060 std::vector<int> WidgetShowNPoints::GetLstPointsY()
1061 {
1062     if (mtype!=4)
1063     {
1064         return GetModelShowNPoints()->GetLstPointsY();
1065     } else {
1066         std::vector<int> lst;
1067         int iP,s;
1068         int iG,sG=lstModelShowNPoints.size();
1069         for (iG=0 ; iG<sG ; iG++)
1070         {
1071             std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1072             s = lstTmp.size();
1073             for (iP=0 ; iP<s ; iP++)
1074             {
1075                 lst.push_back( lstTmp[iP] );
1076             } // for iP
1077         } // for iG
1078         return lst;
1079     }
1080 }
1081
1082 //------------------------------------------------------------------------
1083 std::vector<int> WidgetShowNPoints::GetLstPointsZ()
1084 {
1085     if (mtype!=4)
1086     {
1087         return GetModelShowNPoints()->GetLstPointsZ();
1088     } else {
1089         std::vector<int> lst;
1090         int iP,s;
1091         int iG,sG=lstModelShowNPoints.size();
1092         for (iG=0 ; iG<sG ; iG++)
1093         {
1094             std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1095             s = lstTmp.size();
1096             for (iP=0 ; iP<s ; iP++)
1097             {
1098                 lst.push_back( lstTmp[iP] );
1099             } // for iP
1100         } // for iG
1101         return lst;
1102
1103     }
1104 }
1105
1106 //------------------------------------------------------------------------
1107 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1108 {
1109     if (mtype!=4)
1110     {
1111         return GetModelShowNPoints()->GetLstLabels();
1112     } else {
1113         std::vector< std::string > lst;
1114         int iP,s;
1115         int iG,sG=lstModelShowNPoints.size();
1116         for (iG=0 ; iG<sG ; iG++)
1117         {
1118             std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1119             s = lstTmp.size();
1120             for (iP=0 ; iP<s ; iP++)
1121             {
1122                 lst.push_back( lstTmp[iP] );
1123             } // for iP
1124         } // for iG
1125         return lst;
1126     }
1127 }
1128
1129 //------------------------------------------------------------------------
1130 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1131 {
1132     std::vector<int> lstIndexs;
1133     if (mtype!=4)
1134     {
1135         lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1136     } else {
1137         int iG,sG=lstModelShowNPoints.size();
1138         for (iG=0 ; iG<sG ; iG++)
1139         {
1140             lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1141         } // for iG
1142     }
1143     return lstIndexs;
1144 }
1145