]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
a7a08401f8967e042f0ffb4eeb3d18ba36f29b5c
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / WidgetShowNPoints.cxx
1
2 #include "vtkSphereSource.h"
3 #include "vtkRenderer.h"
4 #include "vtkTextActor3D.h"
5
6 #include <wx/button.h>
7 #include <wx/sizer.h>
8 #include <wx/filedlg.h>
9 #include <wx/msgdlg.h>
10 #include <wx/notebook.h>
11
12 #include "WidgetShowNPoints.h"
13
14 #include <creaContoursFactory.h>
15
16 //----------------------------------------------------------------------
17 //----------------------------------------------------------------------
18 //----------------------------------------------------------------------
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21   WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
22     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
23   {
24         // EED 2022-05-19
25     //  mmodelShowNPoints                                   = new ModelShowNPoints();
26                         idUndoRedo          = 0;
27                         maxUndoRedo         = 0;        
28 #if defined(_WIN32)
29                                                 char * val = getenv( "TEMP" );
30                                                 if (val == NULL) 
31                                                 { 
32                                                         UndoRedoDir = std::string("");  
33                                                 } else { 
34                                                         UndoRedoDir = std::string(val)+"\\creatools"; 
35                                                         printf("WidgetShowNPoints::WidgetShowNPoints  UndoRedoDir = %s   %p \n", UndoRedoDir.c_str() , this );
36                                                         std::string cmd1 = "mkdir "+ UndoRedoDir;
37                                                         system( cmd1.c_str() );
38                                                         // Erasing files of more than 1 day old  ( -1 )
39                                                         std::string cmd2 = "ForFiles /p \"" + UndoRedoDir + "\" /s /d -1 /c \"cmd /c del @file \"";
40                                                         system( cmd2.c_str() );
41                                                 }
42 #elif defined(__GNUC__)
43
44
45     #if defined(MACOSX)
46                                                 UndoRedoDir         = "/tmp/creatools";
47     #else  // Linux
48                                                 UndoRedoDir         = "/tmp/creatools";
49     #endif
50         
51         printf("WidgetShowNPoints::WidgetShowNPoints  UndoRedoDir = %s   %p \n", UndoRedoDir.c_str() , this );
52     std::string cmd1 = "mkdir "+ UndoRedoDir;
53     system( cmd1.c_str() );
54         // Erasing files of more than 1 day old  ( +1 )
55         std::string cmd= "find "+UndoRedoDir+" -name \"UndoRedo_collection_*.undoredo\" -type f -mtime +1 -delete";
56         system( cmd.c_str() );
57
58 #else
59                                                 UndoRedoDir         = "./";
60 #endif
61    
62    
63                         mActualCollection   = 0;
64     ModelShowNPoints*   modelShowNPoints    = new ModelShowNPoints();
65     lstModelShowNPoints.push_back( modelShowNPoints );
66     lstViewShowNPoints.push_back( new  ViewShowNPoints( modelShowNPoints ) );
67       
68     mtype                                                       = type;
69     SetType(mtype);
70     wxPanel*    panelParent         = this;
71     wxSizer*    sizer                           = NULL;
72     wxSizer*    MNPsizer            = NULL;
73     wxNotebook* bookSetPoints       = NULL;
74     wxNotebook* bookGroupManager    = NULL;
75     wxPanel*    panel               = NULL;
76     wxPanel*    panel2              = NULL;
77                 txtNrCollections    = NULL;
78       bookSetPoints     = new wxNotebook(panelParent,
79                           -1,
80                           wxDefaultPosition,
81                           wxDefaultSize,
82                           wxNB_TOP );
83       panel  = new wxPanel(bookSetPoints);
84       txtNrCollections = NULL;
85
86       wxSize sizeButton;
87       sizeButton.Set( 45  ,  -1 );
88       wxSize sizeSlider;
89       sizeSlider.Set( 90  ,  -1 );
90
91     // Group Manager
92     if (mtype==4)
93     {
94           bookGroupManager   = new wxNotebook(panelParent, //bbGetWxParent(),
95                               -1,
96                               wxDefaultPosition,
97                               wxDefaultSize,
98                               wxNB_TOP );
99           panel2  = new wxPanel(bookGroupManager);
100           txtNrCollections                      = new wxStaticText(panel2,-1, _T("1   /  1 "));
101           wxButton *btnBackCollection           = new wxButton( panel2, -1, _T("<")     ,   wxDefaultPosition, sizeButton );
102           wxButton *btnNextCollection           = new wxButton( panel2, -1, _T(">")     ,   wxDefaultPosition, sizeButton );
103           wxButton *btnInsertCollectionBefore   = new wxButton( panel2, -1, _T("+<")    ,   wxDefaultPosition, sizeButton );
104           wxButton *btnInsertCollectionAfter    = new wxButton( panel2, -1, _T("+>")    ,   wxDefaultPosition, sizeButton );
105           wxButton *btnDeleteCollection         = new wxButton( panel2, -1, _T("-")     ,   wxDefaultPosition, sizeButton );
106           wxButton *btnResetCollection          = new wxButton( panel2, -1, _T("--")    ,   wxDefaultPosition, sizeButton );
107           wxButton *btnSaveCollection           = new wxButton( panel2, -1, _T("Save")  ,   wxDefaultPosition, sizeButton );
108           wxButton *btnLoadCollection           = new wxButton( panel2, -1, _T("Load")  ,   wxDefaultPosition, sizeButton );
109           wxFlexGridSizer *sizer1               = new wxFlexGridSizer(1);
110           wxFlexGridSizer *sizer2               = new wxFlexGridSizer(2);
111           wxFlexGridSizer *sizer3               = new wxFlexGridSizer(3);
112           wxFlexGridSizer *sizer4               = new wxFlexGridSizer(3);
113           wxFlexGridSizer *sizer5               = new wxFlexGridSizer(1);
114           wxFlexGridSizer *sizer6               = new wxFlexGridSizer(2);
115  //         wxStaticText* txOpacity               = new wxStaticText(panel2, -1, wxString(_T("Op:")));
116         
117           btnInsertCollectionBefore   -> SetToolTip( _T("+  Add group before") );
118           btnInsertCollectionAfter    -> SetToolTip( _T("+>  Add group after") );
119           btnDeleteCollection         -> SetToolTip( _T("-  Erase group") );
120           btnResetCollection          -> SetToolTip( _T("-- Reset : Erase all groups") );
121
122           sdrOpacity                            = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, sizeSlider, wxSL_LABELS);
123 //          wxStaticText* txRadio                 = new wxStaticText(panel2, -1, wxString(_T("R:")));
124           sdrRadio                              = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, sizeSlider, wxSL_LABELS);
125
126           sdrRadio                    -> SetToolTip( _T("Radio") );
127           sdrOpacity                  -> SetToolTip( _T("Opacity") );
128         
129           Connect(btnBackCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection           );
130           Connect(btnNextCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection           );
131           Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore   );
132           Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter    );
133           Connect(btnDeleteCollection->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection         );
134           Connect(sdrOpacity->GetId()               , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints                );
135           Connect(sdrRadio->GetId()                 , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints                );
136           Connect(btnSaveCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections          );
137           Connect(btnLoadCollection->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections          );
138           Connect(btnResetCollection->GetId()       , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnResetCollections         );
139         
140           sizer2->Add( btnBackCollection );
141           sizer2->Add( btnNextCollection );
142           sizer3->Add( btnInsertCollectionBefore );
143           sizer3->Add( btnInsertCollectionAfter );
144           sizer4->Add( btnLoadCollection );
145           sizer4->Add( btnSaveCollection );
146 //          sizer5->Add( txRadio ,wxGROW );
147           sizer5->Add( sdrRadio ,wxGROW );
148 //          sizer5->Add( txOpacity ,wxGROW );
149           sizer5->Add( sdrOpacity ,wxGROW );
150           sizer6->Add( btnDeleteCollection );
151           sizer6->Add( btnResetCollection );
152
153           sizer1->Add( txtNrCollections );
154           sizer1->Add( sizer2 );
155           sizer1->Add( sizer3 );
156           sizer1->Add( sizer6 );
157           sizer1->Add( sizer4 );
158           sizer1->Add( sizer5 ,wxGROW );
159
160           MNPsizer                        = sizer1;
161           panel2->SetSizer( MNPsizer );
162           panel2->SetAutoLayout(true);
163           panel2->Layout();
164           bookGroupManager->AddPage(panel2 , _T("Groups") );
165     } // if mtype 4
166
167         if ( (mtype==0) || (mtype==3) || (mtype==4) )
168         {
169                 // Widget interface
170 //              askPointLabel                                       = new wxStaticText(panel, -1, _T("Label:")); // JPR
171                 textCtrl                                                    = new wxTextCtrl(panel, -1, wxEmptyString   ,    wxDefaultPosition, sizeButton);
172                     cbAutoAddPoints         = new wxCheckBox(panel,-1, _T("Auto")       ,   wxDefaultPosition, sizeButton );
173                 wxButton    *btnAddPoint                    = new wxButton( panel, -1, _T("+")          ,   wxDefaultPosition, sizeButton );
174                 wxButton    *btnInsertPoint                 = new wxButton( panel, -1, _T("(+)")        ,   wxDefaultPosition, sizeButton );//CFT
175                 wxButton    *btnSetPositionPoint    = new wxButton( panel, -1, _T("Set")        ,   wxDefaultPosition, sizeButton );
176                      cbTrackPoint           = new wxCheckBox(panel,-1, _T("Tra.")       ,   wxDefaultPosition, sizeButton );
177         wxButton    *btnRenamePoint                 = new wxButton( panel, -1, _T("Ren.")       ,   wxDefaultPosition, sizeButton );
178         wxButton    *btnErasePoint          = new wxButton( panel, -1, _T("-")          ,   wxDefaultPosition, sizeButton );
179                 wxButton    *btnEraseLastPoint      = new wxButton( panel, -1, _T("- lst")      ,   wxDefaultPosition, sizeButton );
180                 wxButton    *btnDeleteAllPoints     = new wxButton( panel, -1, _T("--")         ,   wxDefaultPosition, sizeButton );
181         wxButton    *btnUndo                = new wxButton( panel, -1, _T("Undo")       ,   wxDefaultPosition, sizeButton );
182         wxButton    *btnRedo                = new wxButton( panel, -1, _T("Redo")       ,   wxDefaultPosition, sizeButton );
183                 wxButton    *btnSavePoints                  = NULL;
184                 wxButton    *btnLoadPoints                  = NULL;
185                 
186         cbAutoAddPoints     -> SetToolTip( _T("Auto Add point")          );
187         btnAddPoint         -> SetToolTip( _T("+  Add point")          );
188         btnInsertPoint      -> SetToolTip( _T("(-)  Insert point")       );
189         btnErasePoint       -> SetToolTip( _T("-  Erase point")        );
190         btnEraseLastPoint   -> SetToolTip( _T("- lst  Erase last point")   );
191         btnDeleteAllPoints  -> SetToolTip( _T("-- Erase all points")   );
192         
193                 if ( mtype==0 )
194                 {
195                         btnSavePoints                           = new wxButton( panel, -1, _T("Save points"));
196                         btnLoadPoints                           = new wxButton( panel, -1, _T("Load points"));
197             Connect(btnSavePoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
198             Connect(btnLoadPoints->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
199                 } // if mtype
200                 txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
201
202         wxStaticText* txOpacity;
203         wxStaticText* txRadio;
204         if ( (mtype==0) || (mtype==3) )
205         {
206             //NTU: Sliders for opacity and radio change
207             txOpacity         = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
208             sdrOpacity        = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
209             txRadio           = new wxStaticText(panel, -1, wxString(_T("  Points Radius  ")));
210             sdrRadio          = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
211             //NTU: Slider events
212             Connect(sdrOpacity->GetId()          , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
213             Connect(sdrRadio->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
214         } // if mtype 0 3
215         Connect(cbAutoAddPoints->GetId()    , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints);
216                 Connect(btnAddPoint->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
217                 Connect(btnInsertPoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
218                 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
219                 Connect(btnRenamePoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
220                 Connect(btnEraseLastPoint->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
221                 Connect(btnErasePoint->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
222                 Connect(btnDeleteAllPoints->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
223         Connect(cbTrackPoint->GetId()       , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
224         Connect(btnUndo->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
225         Connect(btnRedo->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
226         wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
227         wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
228         wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
229         wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
230         wxFlexGridSizer *sizer4 = new wxFlexGridSizer(2);
231         wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
232         sizer1->Add( textCtrl               );
233         sizer1->Add( btnRenamePoint         );
234         sizer2->Add( cbAutoAddPoints        );
235         sizer2->Add( new wxStaticText(panel, -1, _T(" "))            );
236         sizer2->Add( btnAddPoint            );
237         sizer2->Add( btnInsertPoint         );//CFT
238         sizer3->Add( btnSetPositionPoint    );
239         sizer3->Add( cbTrackPoint           );
240         sizer4->Add( btnErasePoint          );
241         sizer4->Add( btnEraseLastPoint      );
242         sizer4->Add( btnDeleteAllPoints     );
243         sizer5->Add( btnUndo                );
244         sizer5->Add( btnRedo                );
245 //              sizer0->Add(askPointLabel); // JPR
246         sizer0->Add(txtNrPoints);
247         sizer0->Add(sizer2);
248         sizer0->Add(sizer1);
249                 sizer0->Add(sizer3);
250         sizer0->Add(sizer4);
251         sizer0->Add(sizer5);
252         if ( (mtype==0) || (mtype==3) )
253         {
254             wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
255             sizer5->Add(txRadio);
256             sizer5->Add(sdrRadio,1,wxGROW );
257             sizer5->Add(txOpacity);
258             sizer5->Add(sdrOpacity,1,wxGROW );
259             sizer0->Add(sizer5);
260         }  // if mtype 0 3
261         if ( mtype==0 )
262                 {
263             wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
264                         sizer6->Add(btnSavePoints);
265                         sizer6->Add(btnLoadPoints);
266             sizer0->Add(sizer6);
267                 } // if mtype 0
268                 sizer = sizer0;
269         }
270
271           if (mtype==1)
272           {
273                   // Widget interface
274                   wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set nearest point"));
275                   txtNrPoints                                           = new wxStaticText(panel,-1, _T(" "));
276
277                   //NTU: Sliders for opacity and radio change
278                   wxStaticText* txOpacity                       = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
279                   sdrOpacity                                            = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
280                   wxStaticText* txRadio                         = new wxStaticText(panel, -1, wxString(_T("  Points Radio  ")));
281                   sdrRadio                                                      = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
282                   Connect(btnSetPositionPoint->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
283                   Connect(sdrOpacity->GetId()   , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
284                   Connect(sdrRadio->GetId()     , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
285
286           wxFlexGridSizer *sizer1            = new wxFlexGridSizer(1);
287                   sizer1->Add(btnSetPositionPoint);
288                   sizer1->Add(txtNrPoints);
289                   sizer1->Add(txRadio);
290                   sizer1->Add(sdrRadio,1,wxGROW );
291           sizer1->Add(txOpacity);
292           sizer1->Add(sdrOpacity,1,wxGROW );
293                   sizer = sizer1;
294           }
295     
296     if (mtype == 2) 
297         {
298                 askPointLabel                                           = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
299         wxButton                *btnAddPoint            = new wxButton(panel, -1,        _T("      Add  Point      "));
300         wxButton                *btnDeleteAllPoints = new wxButton(panel, -1, _T("      Delete All      "));
301         wxStaticText    *spacer                         = new wxStaticText(panel, -1, _T("\n")); // JPR
302                                          textCtrl                       = new wxTextCtrl(panel, -1);
303         Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
304         Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);    
305         wxFlexGridSizer *sizer1             = new wxFlexGridSizer(1);
306         sizer1->Add(askPointLabel);
307         sizer1->Add(btnAddPoint);
308         sizer1->Add(btnDeleteAllPoints);
309         sizer1->Add(spacer);
310         sizer1->Add(textCtrl);
311       //  sdrOpacity                          = new wxSlider();
312       //  sdrRadio                            = new wxSlider();
313         txtNrPoints                         = new wxStaticText(panel, -1, _T("\n\n\n"));
314         sizer                               = sizer1;
315         } // bbGetInputType 2
316
317     panel->SetSizer(sizer);
318     panel->SetAutoLayout(true);
319     panel->Layout();
320     bookSetPoints->AddPage(panel , _T("Points") );
321
322     if ((mtype >= 0) && (mtype <= 3) )
323     {
324         if (sizer!=NULL)
325         {
326             wxFlexGridSizer *sizerParent             = new wxFlexGridSizer(1);
327             sizerParent->Add( bookSetPoints );
328             panelParent->SetSizer( sizerParent );
329             panelParent->SetAutoLayout(true);
330             panelParent->Layout();
331         } // if sizer
332     } // if  mtype 0 1 2 3
333       
334     if (mtype == 4)
335     {
336         if ((sizer!=NULL) && (MNPsizer!=NULL))
337         {
338             wxFlexGridSizer *sizerG             = new wxFlexGridSizer(2);
339             sizerG->Add(bookGroupManager);
340             sizerG->Add(bookSetPoints);
341             panelParent->SetSizer(sizerG);
342             panelParent->SetAutoLayout(true);
343             panelParent->Layout();
344         } // if sizer
345     } // if mtype 4
346 }
347
348 //------------------------------------------------------------------------
349 WidgetShowNPoints::~WidgetShowNPoints()
350 {
351 }
352
353 //------------------------------------------------------------------------
354 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
355 {
356     // EED 2022-05-19
357     // return mmodelShowNPoints;
358     return lstModelShowNPoints[ mActualCollection ];
359 }
360
361 //------------------------------------------------------------------------
362 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id)
363 {
364         if(id >= 0 && id < lstModelShowNPoints.size())
365         {
366                 return lstModelShowNPoints[ id ];       
367         }
368 }
369
370 // EED 2022-05-19
371 //------------------------------------------------------------------------
372 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
373 {
374     return lstViewShowNPoints[ mActualCollection ];
375 }
376
377
378 //------------------------------------------------------------------------
379 void WidgetShowNPoints::SetRadio(double radio)
380 {
381     // EED 2022-05-19
382     // GetModelShowNPoints()->SetRadio(radio);
383     int i,size = lstModelShowNPoints.size();
384     for (i=0;i<size;i++)
385     {
386         lstModelShowNPoints[i]->SetRadio( radio );
387     } // for i
388         //NTU: For Slider
389         sdrRadio->SetValue(radio);
390 }
391
392 //------------------------------------------------------------------------
393 void WidgetShowNPoints::SetColour(std::vector<double> colour)
394 {
395     // EED 2022-05-19
396     //this->mcolour = colour;
397     int i,size = lstViewShowNPoints.size();
398     for (i=0 ; i<size ; i++)
399     {
400         lstViewShowNPoints[i]->mcolour = colour;
401     } // for i
402 }
403
404 //------------------------------------------------------------------------
405 void WidgetShowNPoints::SetImage(vtkImageData* image)
406 {
407     // EED 2022-05-19
408         //GetModelShowNPoints()->SetImage(image);
409     int i,size = lstModelShowNPoints.size();
410     for (i=0 ; i<size ; i++)
411     {
412         lstModelShowNPoints[i]->SetImage(image);
413     } // for i
414 }
415
416 //------------------------------------------------------------------------
417 void WidgetShowNPoints::SetOpacity(double opacity)
418 {
419     // EED 2022-05-19
420         //this->mopacity=opacity;
421     int i,size = lstViewShowNPoints.size();
422     for (i=0 ; i<size ; i++)
423     {
424         lstViewShowNPoints[i]->mopacity = opacity;
425     } // for i
426         //NTU: For Slider
427         sdrOpacity->SetValue( opacity*100.0 );
428 }
429
430
431 //------------------------------------------------------------------------
432 void  WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
433 {
434     // EED 2022-05-19
435         //this->renderer        = renderer;
436     int i,size = lstViewShowNPoints.size();
437     for (i=0 ; i<size ; i++)
438     {
439         lstViewShowNPoints[i]->renderer = renderer;
440     } // for i
441 }
442
443 /* EED 2022-05-19
444 //------------------------------------------------------------------------
445         
446 void WidgetShowNPoints::RefreshPoint(int id)
447 {
448         double spc[3];
449         int x,y,z;
450         GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
451         GetModelShowNPoints()->GetImage()->GetSpacing(spc);
452         std::string label       = GetModelShowNPoints()->GetIdLabel(id);
453         double radio            = GetModelShowNPoints()->GetRadio();
454     lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
455     lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
456     lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
457     lstSourceSphere[id]->SetRadius( radio );
458 //EED 2017-01-01 Migration VTK7
459 #if VTK_MAJOR_VERSION <= 5
460         // ..
461 #else
462     lstSourceSphere[id]->Update();
463 #endif
464     lstActorsText[id]->SetInput( label.c_str()  );
465     lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
466 }
467
468 //------------------------------------------------------------------------
469 void WidgetShowNPoints::RefreshPoints()
470 {
471         int id,size=lstActorsSphere.size();
472         for (id=0;id<size;id++)
473         {
474                 RefreshPoint(id);
475         } // for
476         renderer->GetRenderWindow()->Render();
477 }
478
479 //------------------------------------------------------------------------
480 void WidgetShowNPoints::AddVtkPoint()
481 {
482         // Sphere
483         vtkSphereSource *vtksphere = vtkSphereSource::New();
484         vtksphere->SetThetaResolution (20);
485         vtksphere->SetPhiResolution (20);
486         vtksphere->SetRadius( 1 );
487         //NTU: For updating points
488         lstSourceSphere.push_back(vtksphere);
489         vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
490
491 //EED 2017-01-01 Migration VTK7
492 #if VTK_MAJOR_VERSION <= 5
493         sphereMapper->SetInput( vtksphere->GetOutput() );
494 #else
495         vtksphere->Update();
496         sphereMapper->SetInputData( vtksphere->GetOutput() );
497 #endif
498
499         vtkActor *sphereActor   = vtkActor::New();
500         sphereActor->SetMapper(sphereMapper);
501         sphereActor->SetOrigin(0, 0, 0);
502
503         lstActorsSphere.push_back(sphereActor);
504         if(renderer==NULL){
505                 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
506                 dialog.ShowModal();             
507                 return;
508         }
509         renderer->AddActor( sphereActor );
510         // Actor
511         vtkTextActor3D *textActor = vtkTextActor3D::New();
512 //      textActor->SetInput( strLabel.c_str()  );
513         renderer->AddActor( textActor );
514         lstActorsText.push_back(textActor);
515 }
516  */
517
518
519 //------------------------------------------------------------------------
520 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
521 {
522     printf("WidgetShowNPoints::AddPoint 0  model=%p\n", GetModelShowNPoints() );
523         GetModelShowNPoints()->AddPoint(x,y,z, label );
524     // EED 2022-05-19
525     //AddVtkPoint();
526     //RefreshPoint(lstActorsSphere.size()-1);
527     printf("WidgetShowNPoints::AddPoint 1   view=%p\n", GetViewShowNPoints() );
528     GetViewShowNPoints()->AddPoint();
529     printf("WidgetShowNPoints::AddPoint 2\n");
530 }
531
532 //------------------------------------------------------------------------
533 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
534 {
535     // EED 2022-05-19
536         //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
537         //{
538     //    AddVtkPoint();
539         //} else {
540         //      AddPoint(x,y,z,label);
541         //}
542         //RefreshPoints();
543     if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
544     {
545         GetViewShowNPoints()->AddVtkPoint();
546     } else {
547         AddPoint(x,y,z,label);
548     }
549     GetViewShowNPoints()->RefreshPoints();
550 }
551
552 //------------------------------------------------------------------------
553 void WidgetShowNPoints::OnInsertPoint_()
554 {
555     // EED 2022-05-19
556     //if (this->renderer==NULL)
557     
558     StopAutoAddPoints();
559     StopTrackPoint();
560     if (GetViewShowNPoints()->renderer==NULL)
561     {
562         return;
563     }
564     std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
565     if (point.size()==3)
566     {
567         InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
568         SetOutputBox();
569     } else {//mpoint.size
570         printf("creaMaracasVisu::ShowNPoints (not match point) \n");
571     }
572     UndoRedo_SaveCollection();
573 }
574
575 //------------------------------------------------------------------------
576 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
577 {
578     OnInsertPoint_();
579 }
580
581 //------------------------------------------------------------------------
582 void WidgetShowNPoints::OnAddPoint__()
583 {       
584     // EED 2022-05-19
585         //if (this->renderer==NULL)
586     if (GetViewShowNPoints()->renderer==NULL)
587         {
588                 return;
589         }
590         std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
591         if (point.size()==3)
592         {
593                 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
594         SetOutputBox();
595         // EED 2022-05-19
596         //renderer->GetRenderWindow()->Render();
597         GetViewShowNPoints()->Render();
598         } else {//mpoint.size
599                 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
600         }
601     UndoRedo_SaveCollection();
602 }
603
604 void WidgetShowNPoints::OnAddPoint_()
605 {
606     StopAutoAddPoints();
607     StopTrackPoint();
608     OnAddPoint__();
609 }
610
611 //------------------------------------------------------------------------
612 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
613 {
614     OnAddPoint_();
615 }
616
617 //------------------------------------------------------------------------
618 void WidgetShowNPoints::AutoAddPoints()
619 {
620     if ( cbAutoAddPoints->GetValue() == true )
621     {
622         OnAddPoint__();
623     } // if cbAutoAddPoints
624 }
625
626 //------------------------------------------------------------------------
627 void WidgetShowNPoints::OnAutoAddPoints_tool()
628 {
629     StopTrackPoint();
630     cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
631 }
632
633 //------------------------------------------------------------------------
634 void WidgetShowNPoints::OnAutoAddPoints_()
635 {
636     StopTrackPoint();
637     printf("EED WidgetShowNPoints::OnAutoAddPoints_ \n");
638 }
639
640 //------------------------------------------------------------------------
641 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
642 {
643     StopTrackPoint();
644     printf("EED WidgetShowNPoints::OnAutoAddPoints \n");
645 }
646
647 //------------------------------------------------------------------------
648 void WidgetShowNPoints::StopAutoAddPoints( )
649 {
650     cbAutoAddPoints->SetValue(false);
651 }
652
653 //------------------------------------------------------------------------
654         void WidgetShowNPoints::SetOutputBox()
655         {
656 //EED           renderer->GetRenderWindow()->Render();
657                 wxString strTmp;
658                 strTmp.Printf(_T("Nbr pnts: %d"), GetModelShowNPoints()->GetLstPointsSize() );
659                 txtNrPoints->SetLabel( strTmp );
660                 //--BBTK
661
662 //EED 2017-06-03
663 //              mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
664 //              mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
665 //              mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
666 //              mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
667 //              mbbShowNPoints->bbSignalOutputModification();
668         }
669
670
671 //------------------------------------------------------------------------
672         void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
673         {
674
675 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
676 #if wxMAJOR_VERSION <= 2
677                 wxFileDialog* FD = new wxFileDialog( 0,
678                                             _T("Save points .."),
679                                             _T(""),
680                                             _T(""),
681                                             _T("(*.xls)|*.xls"),
682                                             wxSAVE | wxOVERWRITE_PROMPT,
683                                             wxDefaultPosition);
684 #else
685                 wxFileDialog* FD = new wxFileDialog( 0,
686                                             _T("Save points .."),
687                                             _T(""),
688                                             _T(""),
689                                             _T("(*.xls)|*.xls"),
690                                             wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
691                                             wxDefaultPosition);
692 #endif
693
694                 int result_FD = FD->ShowModal();
695                 // This line is need it by windows //EED
696                 FD->SetReturnCode( result_FD );
697                 if (FD->GetReturnCode()==wxID_OK)
698                 {
699                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
700                         GetModelShowNPoints()->SavePoints( filename );
701                 }       // dialog box
702         }
703
704
705 //------------------------------------------------------------------------
706         void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
707         {
708
709 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
710 #if wxMAJOR_VERSION <= 2
711                 wxFileDialog* FD = new wxFileDialog( 0,
712                                              _T("Load points .."),
713                                              _T(""),
714                                              _T(""),
715                                              _T("(*.xls)|*.xls"),
716                                              wxOPEN | wxFILE_MUST_EXIST,
717                                              wxDefaultPosition);
718 #else
719                 wxFileDialog* FD = new wxFileDialog( 0,
720                                              _T("Load points .."),
721                                              _T(""),
722                                              _T(""),
723                                              _T("(*.xls)|*.xls"),
724                                              wxFD_OPEN | wxFD_FILE_MUST_EXIST,
725                                              wxDefaultPosition);
726 #endif
727                 int i;
728                 //EED
729                 int result_FD = FD->ShowModal();
730                 // This line is need it by windows //EED
731                 FD->SetReturnCode( result_FD );
732                 if (FD->GetReturnCode()==wxID_OK)
733                 {
734
735                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
736                         int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
737                         for (i=0;i<numberPointsRead;i++)
738                         {
739                 // EED 2022-05-19
740                 //AddVtkPoint();
741                 GetViewShowNPoints()->AddVtkPoint();
742                         }// for
743                         SetOutputBox();
744             // EED 2022-05-19
745                         //RefreshPoints();
746             GetViewShowNPoints()->RefreshPoints();
747                 }       // dialog box
748         }
749
750 //------------------------------------------------------------------------
751 void WidgetShowNPoints::OnSetPoint_()
752 {
753     StopAutoAddPoints();
754     StopTrackPoint();
755
756     int id=GetModelShowNPoints()->GetNearestPoint();
757     if((id==-1) && (mtype==1))
758     {
759         id=0;
760         AddPoint(0,0,0,"");
761         SetOutputBox();
762     }
763     if (id>=0)
764     {
765         GetModelShowNPoints()->SetPointId_mReferencePoint(id);
766         // EED 2022-05-19
767         //RefreshPoint(id);
768         //renderer->GetRenderWindow()->Render();
769         GetViewShowNPoints()->RefreshPoint(id);
770         GetViewShowNPoints()->Render();
771     } // if id
772     SetOutputBox();
773     UndoRedo_SaveCollection();
774 }
775
776 //------------------------------------------------------------------------
777 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
778 {
779     OnSetPoint_();
780 }
781
782 //------------------------------------------------------------------------
783 void WidgetShowNPoints::TrackingPoint( )
784 {
785     if ( cbTrackPoint->GetValue() == true )
786     {
787         int id = GetModelShowNPoints()->IdInsidePoint();
788         if (id>=0)
789         {
790             idTrack=id;
791         }
792         
793         if (idTrack>=0)
794         {
795             GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
796             GetViewShowNPoints()->RefreshPoint(idTrack);
797             GetViewShowNPoints()->Render();
798             UndoRedo_SaveCollection();
799         } // if id
800     } // if trackPointFlag
801 }
802
803 //------------------------------------------------------------------------
804 void WidgetShowNPoints::OnTrackPoint_tool()
805 {
806     cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
807     OnTrackPoint_();
808 }
809
810 //------------------------------------------------------------------------
811 void WidgetShowNPoints::OnTrackPoint_()
812 {
813     StopAutoAddPoints();
814
815     idTrack         =   -1;
816     if ( cbTrackPoint->GetValue() == true )
817     {
818         idTrack = GetModelShowNPoints()->IdInsidePoint();
819     } // if trackPointFlag
820 }
821
822 //------------------------------------------------------------------------
823 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
824 {
825     printf("WidgetShowNPoints::OnTrackPoint  \n");
826     OnTrackPoint_();
827 }
828
829 //------------------------------------------------------------------------
830 void WidgetShowNPoints::StopTrackPoint( )
831 {
832     cbTrackPoint->SetValue(false);
833     idTrack=-1;
834 }
835
836 //------------------------------------------------------------------------
837         void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
838         {
839                 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
840                 if (id>=0)
841                 {
842             // EED 2022-05-19
843                         //lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
844                         //renderer->GetRenderWindow()->Render();
845             GetViewShowNPoints()->lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
846             GetViewShowNPoints()->Render();
847             SetOutputBox();
848             UndoRedo_SaveCollection();
849                 } // if id
850         }
851
852 //------------------------------------------------------------------------
853         void WidgetShowNPoints::ErasePoint(int id)
854         {
855         // EED 2022-05-19
856                 //if (this->renderer!=NULL)
857         if (GetViewShowNPoints()->renderer!=NULL)
858                 {
859                         if (id>=0)
860                         {
861                 // EED 2022-05-19
862                                 //renderer->RemoveActor( lstActorsSphere[id] );
863                                 //renderer->RemoveActor( lstActorsText[id] );
864                                 //lstActorsSphere[id]->Delete();
865                                 //lstActorsText[id]->Delete();
866                                 //lstSourceSphere[id]->Delete();
867                                 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
868                                 //lstActorsText.erase( lstActorsText.begin()+id );
869                                 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
870                 GetViewShowNPoints()->ErasePoint(id);
871                                 GetModelShowNPoints()->ErasePoint(id);
872                         } // if id
873                 } // if renderer
874         }
875
876 //------------------------------------------------------------------------
877     void WidgetShowNPoints::OnErasePoint_()
878     {
879         StopAutoAddPoints();
880         StopTrackPoint();
881
882         ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
883         SetOutputBox();
884         // EED 2022-05-19
885         //renderer->GetRenderWindow()->Render();
886         GetViewShowNPoints()->Render();
887         StopTrackPoint();
888         UndoRedo_SaveCollection();
889     }
890
891 //------------------------------------------------------------------------
892         void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
893         {
894                 OnErasePoint_();
895         }
896
897 //------------------------------------------------------------------------
898         void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
899         {
900         // EED 2022-05-19
901         //ErasePoint( lstActorsSphere.size()-1 );
902         //renderer->GetRenderWindow()->Render();
903         StopAutoAddPoints();
904         StopTrackPoint();
905
906         int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
907         ErasePoint( id );
908         UndoRedo_SaveCollection();
909         GetViewShowNPoints()->Render();
910         SetOutputBox();
911         StopTrackPoint();
912         }
913
914 //------------------------------------------------------------------------
915 void WidgetShowNPoints::DeleteAllPoints_()
916 {
917     // EED 2022-05-19
918     //int id,size=lstActorsSphere.size();
919     int id,size=GetViewShowNPoints()->lstActorsSphere.size();
920     for (id=size-1;id>=0;id--)
921     {
922         ErasePoint(id);
923     }// for id
924 }
925
926 void WidgetShowNPoints::OnDeleteAllPoints_()
927 {
928     StopAutoAddPoints();
929     StopTrackPoint();
930
931     DeleteAllPoints_();
932     UndoRedo_SaveCollection();
933 }
934
935 //------------------------------------------------------------------------
936 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
937 {
938         OnDeleteAllPoints_();
939     SetOutputBox();
940     GetViewShowNPoints()->Render();
941 }
942
943 //NTU: Method for updating points opacity and Radio
944
945 //------------------------------------------------------------------------
946 void WidgetShowNPoints::UpdatePoints_()
947 {
948     // EED 2022-05-19
949     //this->mopacity = sdrOpacity->GetValue()/100.0;
950     //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
951     //RefreshPoints();
952
953     double opacity  = sdrOpacity->GetValue()/100.0;
954     double radio    = sdrRadio->GetValue();
955     int i,size      = lstViewShowNPoints.size();
956     for (i=0 ; i<size ; i++)
957     {
958         lstViewShowNPoints[i]->mopacity = opacity;
959         lstModelShowNPoints[i]->SetRadio( radio ) ;
960     } // for i
961 //    GetViewShowNPoints()->RefreshPoints();
962 }
963
964 //------------------------------------------------------------------------
965 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
966 {
967     RefreshColourCollection();
968 }
969
970 //------------------------------------------------------------------------
971 void  WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
972 {
973         GetModelShowNPoints()->SetReferencePoint(point);
974     int i,size=lstModelShowNPoints.size();
975     for (i=0;i<size;i++)
976     {
977         lstModelShowNPoints[i]->SetReferencePoint(point);    // All collection
978     } // for i
979 }
980
981 //------------------------------------------------------------------------
982 void WidgetShowNPoints::SetActualCollection( int actual )
983 {
984     if (actual<0)
985     {
986         actual=0;
987     } // if actual<0
988     
989     if (actual>lstModelShowNPoints.size()-1 )
990     {
991         actual=lstModelShowNPoints.size()-1;
992     } // if actual<0
993
994     mActualCollection=actual;
995 }
996
997
998 //------------------------------------------------------------------------
999 void  WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX,  std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels,   std::vector<int> initLstIndexs )
1000 {
1001     if (GetViewShowNPoints()->renderer==NULL)
1002     {
1003         return;
1004     }
1005     double x,y,z;
1006     std::string label;
1007     int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1008     int ii,iIndexs,sizeIndexs;
1009     
1010     sizeX       = (int)initLstPointsX.size();
1011     sizeY       = (int)initLstPointsY.size();
1012     sizeZ       = (int)initLstPointsZ.size();
1013     sizeLabels  = (int)initLstLabels.size();
1014     sizeIndexs  = (int)initLstIndexs.size();
1015     
1016     if (sizeIndexs==0)
1017     {
1018         initLstIndexs.push_back(sizeX);
1019         sizeIndexs  = (int)initLstIndexs.size();
1020     }
1021     
1022     if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1023     {
1024         i=0;
1025         for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1026         {
1027             if (iIndexs!=0)
1028             {
1029                 InsertCollectionAfter_();
1030             }// if last iIndexs
1031             sizeTmp = initLstIndexs[iIndexs];
1032             for (ii=0;ii<sizeTmp;ii++)
1033             {
1034                 x        = initLstPointsX[i];
1035                 y        = initLstPointsY[i];
1036                 z        = initLstPointsZ[i];
1037                 if (i<sizeLabels)
1038                 {
1039                     label    = initLstLabels[i];
1040                 } else {
1041                     label="";
1042                 }
1043                 AddPoint( x,y,z,label );
1044                 i++;
1045             } // for i
1046
1047             
1048         }// for ii
1049         //    SetOutputBox();
1050         //    renderer->GetRenderWindow()->Render();
1051     } // if size
1052
1053     
1054
1055     
1056     /*
1057     
1058     // EED 2022-05-19
1059         //if (this->renderer==NULL)
1060     if (GetViewShowNPoints()->renderer==NULL)
1061         {
1062                 return;
1063         }
1064         int i,sizeX,sizeY,sizeZ,sizeLabels;
1065         sizeX = (int)initLstPointsX.size();
1066         sizeY = (int)initLstPointsY.size();
1067         sizeZ = (int)initLstPointsZ.size();
1068         sizeLabels = (int)initLstLabels.size();
1069         double x,y,z;
1070         std::string label;
1071         if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1072         {
1073                 for (i=0;i<sizeX;i++)
1074                 {
1075                         x               = initLstPointsX[i];
1076                         y               = initLstPointsY[i];
1077                         z               = initLstPointsZ[i];
1078                         if (i<sizeLabels) 
1079                         {
1080                                 label   = initLstLabels[i];
1081                         } else {
1082                                 label="";
1083                         }
1084                         AddPoint( x,y,z,label );
1085                 } // for i
1086                 //      SetOutputBox(); 
1087                 //      renderer->GetRenderWindow()->Render();
1088         } // if size
1089      
1090    */
1091 }
1092
1093 //------------------------------------------------------------------------
1094 void WidgetShowNPoints::SetType(int type)
1095 {
1096         mtype=type;
1097 }
1098
1099 //------------------------------------------------------------------------
1100 int WidgetShowNPoints::GetType()
1101 {
1102         return mtype;
1103 }
1104
1105
1106 //------------------------------------------------------------------------
1107 double WidgetShowNPoints::GetRadio()
1108 {
1109         return sdrRadio->GetValue();
1110 }
1111 //------------------------------------------------------------------------
1112 double WidgetShowNPoints::GetOpacity()
1113 {
1114         return sdrOpacity->GetValue()/100;
1115 }
1116
1117 //------------------------------------------------------------------------
1118 void WidgetShowNPoints::InsertCollection()
1119 {
1120     ModelShowNPoints*   model   = new ModelShowNPoints();
1121     ViewShowNPoints*    view    = new ViewShowNPoints( model );
1122     view->mopacity              = lstViewShowNPoints[0]->mopacity;
1123     view->renderer              = lstViewShowNPoints[0]->renderer;
1124     model->SetImage( lstModelShowNPoints[0]->GetImage() );
1125     lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1126     lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1127 }
1128
1129 //------------------------------------------------------------------------
1130 void WidgetShowNPoints::InsertCollectionBefore_()  
1131 {
1132     InsertCollection();
1133     RefreshCollectionText();
1134     RefreshColourCollection();
1135     StopTrackPoint();
1136 }
1137
1138 //------------------------------------------------------------------------
1139 void WidgetShowNPoints::OnInsertCollectionBefore_()
1140 {
1141     InsertCollectionBefore_();
1142     CreatePointsIntoNewCollection();
1143     UndoRedo_SaveCollection();
1144 }
1145
1146
1147 //------------------------------------------------------------------------
1148 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1149 {
1150     OnInsertCollectionBefore_();
1151 }
1152
1153
1154 //------------------------------------------------------------------------
1155 void WidgetShowNPoints::InsertCollectionAfter_()
1156 {
1157     mActualCollection++;
1158     InsertCollection();
1159     RefreshCollectionText();
1160     RefreshColourCollection();
1161     StopTrackPoint();
1162 }
1163
1164
1165 //------------------------------------------------------------------------
1166 void WidgetShowNPoints::OnInsertCollectionAfter_()
1167 {
1168     InsertCollectionAfter_();
1169     CreatePointsIntoNewCollection();
1170     UndoRedo_SaveCollection();
1171 }
1172
1173 //------------------------------------------------------------------------
1174 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1175 {
1176     OnInsertCollectionAfter_();
1177 }
1178
1179 //------------------------------------------------------------------------
1180 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1181 {
1182     //   ---------------------------------------------
1183     printf("\nWidgetShowNPoints::InsertCollection mActualCollection=%d\n",mActualCollection);
1184     int c1 = mActualCollection-1;
1185     int c2 = mActualCollection+1;
1186     if (c2==lstModelShowNPoints.size()) { c2=0; }
1187     if ((c1>=0) && (c1!=c2) )
1188     {
1189         std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1190         std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1191         std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1192         std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1193         std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1194         std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1195         std::vector<double> c1LstXX;
1196         std::vector<double> c1LstYY;
1197         std::vector<double> c1LstZZ;
1198         std::vector<double> c2LstXX;
1199         std::vector<double> c2LstYY;
1200         std::vector<double> c2LstZZ;
1201         creaContoursFactory     f;
1202         manualContourModel      *m;
1203         double                  x,y,z;
1204         int                     i,size;
1205         int                     sc; // sizeContour
1206         
1207         if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1208         {
1209             // ----------------- Spline 1 --------------------
1210             sc          = 100;
1211             size        = c1LstX.size();
1212             m           = (manualContourModel*)f.getContourModel( 1 );  // Spline
1213             //        m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1214             m->SetNumberOfPointsSpline( sc );
1215             m->SetCloseContour( false );
1216             for (i=0;i<size;i++)
1217             {
1218                 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1219             } // for
1220             m->UpdateSpline();
1221             for (i=0;i<sc;i++)
1222             {
1223                 m->GetSpline_i_Point(i,&x,&y,&z);
1224                 c1LstXX.push_back(x);
1225                 c1LstYY.push_back(y);
1226                 c1LstZZ.push_back(z);
1227             } // for
1228             delete m;
1229             // ----------------- Spline 2 --------------------
1230             size        = c2LstX.size();
1231             m           = (manualContourModel*)f.getContourModel( 1 );  // Spline
1232             //        m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1233             m->SetNumberOfPointsSpline( sc );
1234             m->SetCloseContour( false );
1235             for (i=0;i<size;i++)
1236             {
1237                 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1238             } // for
1239             m->UpdateSpline();
1240             for (i=0;i<sc;i++)
1241             {
1242                 m->GetSpline_i_Point(i,&x,&y,&z);
1243                 c2LstXX.push_back(x);
1244                 c2LstYY.push_back(y);
1245                 c2LstZZ.push_back(z);
1246             } // for
1247             delete m;
1248             // ----------------- Add new Points --------------------
1249             i=0;   x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1250 //            i=33;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1251 //            i=66;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1252             i=25;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1253             i=50;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1254             i=75;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1255             i=sc-1;x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1256         } // if size of c1LstX c2LstX
1257     }  // if c1 && c2
1258
1259 }
1260
1261
1262
1263 //------------------------------------------------------------------------
1264 void WidgetShowNPoints::DeleteCollection_()
1265 {
1266     if ( lstModelShowNPoints.size()>1 )
1267     {
1268         DeleteAllPoints_();  // Actual Collection
1269         lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1270         lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1271         if ( mActualCollection>=lstModelShowNPoints.size() )
1272         {
1273             mActualCollection--;
1274         } // if
1275     } else {
1276         DeleteAllPoints_();  // Actual Collection
1277     } // if
1278 }
1279
1280 //------------------------------------------------------------------------
1281 void WidgetShowNPoints::OnDeleteCollection_()
1282 {
1283     DeleteCollection_();
1284     SetOutputBox();
1285     GetViewShowNPoints()->Render();
1286     RefreshCollectionText();
1287     RefreshColourCollection();
1288     StopTrackPoint();
1289     UndoRedo_SaveCollection();
1290 }
1291
1292 //------------------------------------------------------------------------
1293 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1294 {
1295     OnDeleteCollection_();
1296 }
1297
1298 //------------------------------------------------------------------------
1299 void WidgetShowNPoints::ResetCollections_()
1300 {
1301     int i,size=lstModelShowNPoints.size();
1302     for (i=0;i<size;i++)
1303     {
1304         DeleteCollection_();
1305     }
1306     GetViewShowNPoints()->Render();
1307     RefreshCollectionText();
1308     RefreshColourCollection();
1309     StopTrackPoint();
1310 }
1311
1312
1313 //------------------------------------------------------------------------
1314 void WidgetShowNPoints::OnResetCollections_()
1315 {
1316     ResetCollections_();
1317     UndoRedo_SaveCollection();
1318 }
1319
1320
1321 //------------------------------------------------------------------------
1322 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1323 {
1324     OnResetCollections_();
1325 }
1326
1327 //------------------------------------------------------------------------
1328 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1329 {
1330     mActualCollection--;
1331     if ( mActualCollection <0  )
1332     {
1333         mActualCollection=0;
1334     } //if <=0
1335     RefreshCollectionText();
1336     RefreshColourCollection();
1337     StopTrackPoint();
1338     UndoRedo_SaveCollection();
1339 }
1340
1341 //------------------------------------------------------------------------
1342 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1343 {
1344     mActualCollection++;
1345     if ( mActualCollection >=lstModelShowNPoints.size() )
1346     {
1347         mActualCollection = lstModelShowNPoints.size()-1;
1348     } //if <=0
1349     RefreshCollectionText();
1350     RefreshColourCollection();
1351     StopTrackPoint();
1352     UndoRedo_SaveCollection();
1353 }
1354
1355 //------------------------------------------------------------------------
1356 void WidgetShowNPoints::DetectCollectionActive()
1357 {
1358     int id;
1359     int i,size=lstModelShowNPoints.size();
1360     for (i=0;i<size;i++)
1361     {
1362         id = lstModelShowNPoints[i]->IdInsidePoint();
1363         if (id>=0)
1364         {
1365             mActualCollection=i;
1366         } // if id>=0
1367     } // for i
1368     RefreshCollectionText();
1369     RefreshColourCollection();
1370 }
1371
1372 //------------------------------------------------------------------------
1373 void WidgetShowNPoints::RefreshColourCollection()
1374 {
1375     UpdatePoints_();
1376     std::vector<double> colourAll;
1377     colourAll.push_back(1);
1378     colourAll.push_back(0);
1379     colourAll.push_back(0);
1380     std::vector<double> colourActualGroup;
1381     colourActualGroup.push_back(1);
1382     colourActualGroup.push_back(1);
1383     colourActualGroup.push_back(0);
1384
1385     // For all collections
1386     SetColour( colourAll );
1387     int i,size=lstViewShowNPoints.size();
1388     for (i=0;i<size;i++)
1389     {
1390         lstViewShowNPoints[i] -> mcolour    = colourAll;
1391         lstViewShowNPoints[i] -> ratioRadio = 1;
1392         lstViewShowNPoints[i]->RefreshEachPoint();
1393     } // for i
1394     
1395     // Actual collection
1396     lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1397     lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.1;
1398     lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1399     
1400     //Actual Point
1401     int curPnt = lstModelShowNPoints[mActualCollection] -> GetIdCurrentPoint();
1402     size=lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1403     if ((curPnt>=0)  && (curPnt<size  ) )
1404     {
1405         std::vector<double> colourActualPoint;
1406         colourActualPoint.push_back(0);
1407         colourActualPoint.push_back(0);
1408         colourActualPoint.push_back(1);
1409         double radio          = GetModelShowNPoints()->GetRadio();
1410         lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1411         lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt   );
1412         lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1413     }
1414     lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1415 }
1416
1417 //------------------------------------------------------------------------
1418 void WidgetShowNPoints::RefreshCollectionText()
1419 {
1420     if ((mtype==4) && (txtNrCollections!=NULL))  // Just for Collection interface
1421     {
1422         wxString strTmp;
1423         strTmp.Printf(_T("%d   /  %d "),  (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1424         txtNrCollections->SetLabel( strTmp );
1425     } // if mtype 4
1426     SetOutputBox();
1427 }
1428
1429
1430 //------------------------------------------------------------------------
1431 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1432 {
1433     FILE *ff;
1434     ff = fopen( filename.c_str() , "w+" );
1435     if (ff!=NULL)
1436     {
1437         int i,size = lstModelShowNPoints.size();
1438         fprintf(ff,"NumberOfGroups %d \n",size);
1439         for (i=0 ; i<size ; i++)
1440         {
1441             lstModelShowNPoints[i]->SavePoints_(ff);
1442         } // for i
1443         fclose(ff);
1444     } else {   // else ff
1445         printf("WidgetShowNPoints::Save Groups Points  ...Error... creating file \n");
1446     } //ff
1447
1448 }
1449
1450
1451 //------------------------------------------------------------------------
1452 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1453 {
1454     //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1455     #if wxMAJOR_VERSION <= 2
1456             wxFileDialog* FD = new wxFileDialog( 0,
1457                                                 _T("Save groups of points .."),
1458                                                 _T(""),
1459                                                 _T(""),
1460                                                 _T("(*.xls)|*.xls"),
1461                                                 wxSAVE | wxOVERWRITE_PROMPT,
1462                                                 wxDefaultPosition);
1463     #else
1464             wxFileDialog* FD = new wxFileDialog( 0,
1465                                                 _T("Save groups of points .."),
1466                                                 _T(""),
1467                                                 _T(""),
1468                                                 _T("(*.xls)|*.xls"),
1469                                                 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1470                                                 wxDefaultPosition);
1471     #endif
1472
1473             int result_FD = FD->ShowModal();
1474             // This line is need it by windows //EED
1475             FD->SetReturnCode( result_FD );
1476             if (FD->GetReturnCode()==wxID_OK)
1477             {
1478                 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1479                 OnSaveCollections_( filename );
1480             }     // dialog box
1481     StopTrackPoint();
1482 }
1483
1484 //------------------------------------------------------------------------
1485 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1486 {
1487     bool okEraseFirstGroup=false;
1488     if (lstModelShowNPoints.size()==1)
1489     {
1490         if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1491     }
1492     FILE *ff = fopen( filename.c_str() , "r+" );
1493     if (ff!=NULL)
1494     {
1495         int i;
1496         int iGroup,sizeGroups;
1497         int iPoint,numberPointsRead;
1498         char chartmp[256];
1499         fscanf(ff," %s %d",chartmp,&sizeGroups);
1500         for (iGroup=0;iGroup<sizeGroups;iGroup++)
1501         {
1502             mActualCollection = lstModelShowNPoints.size();
1503             InsertCollection();
1504             int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1505             for (i=0;i<numberPointsRead;i++)
1506             {
1507                 // EED 2022-05-19
1508                 //AddVtkPoint();
1509                 GetViewShowNPoints()->AddVtkPoint();
1510             }// for
1511         } // for i
1512
1513         fclose(ff);
1514     } else {   // else ff
1515         printf("WidgetShowNPoints::Load Group of Points  ...Error... reading file");
1516     } //ff
1517     if (okEraseFirstGroup==true)
1518     {
1519         mActualCollection=0;
1520         DeleteCollection_();
1521         mActualCollection = lstModelShowNPoints.size()-1;
1522     }
1523     GetViewShowNPoints()->Render();
1524     RefreshCollectionText();
1525     RefreshColourCollection();
1526     StopTrackPoint();
1527 }
1528
1529 //------------------------------------------------------------------------
1530 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1531 {
1532     //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1533     #if wxMAJOR_VERSION <= 2
1534             wxFileDialog* FD = new wxFileDialog( 0,
1535                                                  _T("Load groups of points .."),
1536                                                  _T(""),
1537                                                  _T(""),
1538                                                  _T("(*.xls)|*.xls"),
1539                                                  wxOPEN | wxFILE_MUST_EXIST,
1540                                                  wxDefaultPosition);
1541     #else
1542             wxFileDialog* FD = new wxFileDialog( 0,
1543                                                  _T("Load groups of points .."),
1544                                                  _T(""),
1545                                                  _T(""),
1546                                                  _T("(*.xls)|*.xls"),
1547                                                  wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1548                                                  wxDefaultPosition);
1549     #endif
1550             int result_FD = FD->ShowModal();
1551             // This line is need it by windows //EED
1552             FD->SetReturnCode( result_FD );
1553             if (FD->GetReturnCode()==wxID_OK)
1554             {
1555                 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1556                 OnLoadCollections_( filename );
1557                 UndoRedo_SaveCollection();
1558             }     // dialog box
1559 }
1560
1561 //------------------------------------------------------------------------
1562 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1563 {
1564     double x,y,z;
1565     lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1566     pPoint[0] = x;
1567     pPoint[1] = y;
1568     pPoint[2] = z;
1569 }
1570 //------------------------------------------------------------------------
1571 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1572 {
1573         if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1574         {
1575                 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1576                 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1577         }
1578         else{
1579                 printf("WidgetShowNPoints::SetCollectionPoint  ...Error... Invalid collection, out of range");
1580         }
1581 }
1582 //------------------------------------------------------------------------
1583 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1584 {
1585     if (mtype!=4)
1586     {
1587         return GetModelShowNPoints()->GetLstPointsX();
1588     } else {
1589         std::vector<double> lst;
1590         int iP,s;
1591         int iG,sG=lstModelShowNPoints.size();
1592         for (iG=0 ; iG<sG ; iG++)
1593         {
1594             std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1595             s = lstTmp.size();
1596             for (iP=0 ; iP<s ; iP++)
1597             {
1598                 lst.push_back( lstTmp[iP] );
1599             } // for iP
1600         } // for iG
1601         return lst;
1602     } // if 4
1603 }
1604
1605 //------------------------------------------------------------------------
1606 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1607 {
1608     if (mtype!=4)
1609     {
1610         return GetModelShowNPoints()->GetLstPointsY();
1611     } else {
1612         std::vector<double> lst;
1613         int iP,s;
1614         int iG,sG=lstModelShowNPoints.size();
1615         for (iG=0 ; iG<sG ; iG++)
1616         {
1617             std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1618             s = lstTmp.size();
1619             for (iP=0 ; iP<s ; iP++)
1620             {
1621                 lst.push_back( lstTmp[iP] );
1622             } // for iP
1623         } // for iG
1624         return lst;
1625     }
1626 }
1627
1628 //------------------------------------------------------------------------
1629 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1630 {
1631     if (mtype!=4)
1632     {
1633         return GetModelShowNPoints()->GetLstPointsZ();
1634     } else {
1635         std::vector<double> lst;
1636         int iP,s;
1637         int iG,sG=lstModelShowNPoints.size();
1638         for (iG=0 ; iG<sG ; iG++)
1639         {
1640             std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1641             s = lstTmp.size();
1642             for (iP=0 ; iP<s ; iP++)
1643             {
1644                 lst.push_back( lstTmp[iP] );
1645             } // for iP
1646         } // for iG
1647         return lst;
1648
1649     }
1650 }
1651
1652 //------------------------------------------------------------------------
1653 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1654 {
1655     if (mtype!=4)
1656     {
1657         return GetModelShowNPoints()->GetLstLabels();
1658     } else {
1659         std::vector< std::string > lst;
1660         int iP,s;
1661         int iG,sG=lstModelShowNPoints.size();
1662         for (iG=0 ; iG<sG ; iG++)
1663         {
1664             std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1665             s = lstTmp.size();
1666             for (iP=0 ; iP<s ; iP++)
1667             {
1668                 lst.push_back( lstTmp[iP] );
1669             } // for iP
1670         } // for iG
1671         return lst;
1672     }
1673 }
1674
1675 //------------------------------------------------------------------------
1676 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1677 {
1678     std::vector<int> lstIndexs;
1679     if (mtype!=4)
1680     {
1681         lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1682     } else {
1683         int iG,sG=lstModelShowNPoints.size();
1684         for (iG=0 ; iG<sG ; iG++)
1685         {
1686             lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1687         } // for iG
1688     }
1689     return lstIndexs;
1690 }
1691 //------------------------------------------------------------------------
1692 int WidgetShowNPoints::GetLstModelShowNPointsSize()
1693 {
1694     return lstModelShowNPoints.size();
1695 }
1696
1697 //------------------------------------------------------------------------
1698 void WidgetShowNPoints::InvertLstPoints_()
1699 {
1700     int i,size=lstModelShowNPoints.size();
1701     
1702     for (i=0 ;  i < size ; i++)
1703     {
1704         lstModelShowNPoints[i]->InversLstPoints();
1705     } // for iM
1706      
1707     /*
1708     ModelShowNPoints* tmpModel;
1709     int size2=size/2;
1710     for (i=0 ;  i < size2 ; i++)
1711     {
1712         tmpModel                        = lstModelShowNPoints[i];
1713         lstModelShowNPoints[i]          = lstModelShowNPoints[size-1-i];
1714         lstModelShowNPoints[size-1-i]   = tmpModel;
1715     } // for iM
1716      */
1717 }
1718
1719 //------------------------------------------------------------------------
1720 void WidgetShowNPoints::OnInvertLstPoints_()
1721 {
1722     StopAutoAddPoints();
1723     StopTrackPoint();
1724
1725     InvertLstPoints_();
1726     SetOutputBox();
1727     UndoRedo_SaveCollection();
1728 }
1729
1730
1731 //------------------------------------------------------------------------
1732 std::string WidgetShowNPoints::GetUndoRedoFileName()
1733 {
1734     char buff[20];
1735     sprintf(buff,"%p_%d",this, idUndoRedo);
1736     return  UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
1737 }
1738
1739
1740 //------------------------------------------------------------------------
1741 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
1742 {
1743     ResetCollections_();
1744 //    if (idUndoRedo==maxUndoRedo+1)
1745 //    {
1746 //       idUndoRedo--;
1747 //    } // if idUndoRedo+1
1748     idUndoRedo--;
1749     idUndoRedo--;
1750     if (idUndoRedo<0)
1751     {
1752         idUndoRedo=-1;
1753     } else {
1754         OnLoadCollections_( GetUndoRedoFileName() );
1755     }// if idUndoRedo
1756     idUndoRedo++;
1757
1758 }
1759
1760 //------------------------------------------------------------------------
1761 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
1762 {
1763     if (idUndoRedo>maxUndoRedo)
1764     {
1765         idUndoRedo=maxUndoRedo+1;
1766     } else {
1767         ResetCollections_();
1768         OnLoadCollections_( GetUndoRedoFileName() );
1769         idUndoRedo++;
1770     }// if idUndoRedo
1771 }
1772
1773 //------------------------------------------------------------------------
1774 void WidgetShowNPoints::UndoRedo_SaveCollection()
1775 {
1776     OnSaveCollections_( GetUndoRedoFileName() );
1777     maxUndoRedo = idUndoRedo;
1778     idUndoRedo++;
1779 }
1780
1781