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