]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
f7fa68f29570aefedf98041f7cb6a7350fc772f6
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / WidgetShowNPoints.cxx
1
2
3 #include "vtkSphereSource.h"
4 #include "vtkRenderer.h"
5 #include "vtkTextActor3D.h"
6
7
8
9 #include <wx/button.h>
10 #include <wx/sizer.h>
11 #include <wx/filedlg.h>
12 #include <wx/msgdlg.h>
13
14 #include "WidgetShowNPoints.h"
15
16
17 //----------------------------------------------------------------------
18 //----------------------------------------------------------------------
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 //----------------------------------------------------------------------
22   WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
23     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
24   {
25         // EED 2022-05-19
26     //  mmodelShowNPoints                                = new ModelShowNPoints();
27       mActualLstPoints=0;
28       ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
29       lstModelShowNPoints.push_back( modelShowNPoints );
30       lstViewShowNPoints.push_back( new  ViewShowNPoints( modelShowNPoints ) );
31       
32       
33     mtype                                                       = type;
34     SetType(mtype);
35     wxPanel     *panel                                  = this;
36     wxSizer *sizer                                      = NULL;
37
38         if ((mtype==0) || (mtype==3))
39         {
40                 // Widget interface
41                 askPointLabel                                   = new wxStaticText(panel, -1, _T("Point label :")); // JPR
42                 textCtrl                                                = new wxTextCtrl(panel, -1);
43                 wxButton *btnAddPoint                   = new wxButton( panel, -1, _T("Add Point"));
44                 wxButton *btnInsertPoint                = new wxButton( panel, -1, _T("Insert Point"));//CFT
45                 wxButton *btnSetPositionPoint   = new wxButton( panel, -1, _T("Set nearest point"));
46                 wxButton *btnRenamePoint                = new wxButton( panel, -1, _T("Rename point"));
47                 wxButton *btnEraseLastPoint             = new wxButton( panel, -1, _T("Erase Last point"));
48                 wxButton *btnErasePoint                 = new wxButton( panel, -1, _T("Erase point"));
49                 wxButton *btnDeleteAllPoints    = new wxButton( panel, -1, _T("Delete all points"));
50                 wxButton *btnSavePoints                 = NULL;
51                 wxButton *btnLoadPoints                 = NULL;
52                 if (mtype==0)
53                 {
54                         btnSavePoints                           = new wxButton( panel, -1, _T("Save points"));
55                         btnLoadPoints                           = new wxButton( panel, -1, _T("Load points"));
56                 }
57                 txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
58
59                 //NTU: Sliders for opacity and radio change
60                 wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T("  Points Opacity  ")));
61                 sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
62                 wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T("  Points Radius  ")));
63                 sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
64
65                 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
66                 //    sizer1->Add(new wxStaticText(panel,-1,_T("  ")));
67
68                 Connect(btnAddPoint->GetId()            , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
69                 Connect(btnInsertPoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
70                 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
71                 Connect(btnRenamePoint->GetId()         , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
72                 Connect(btnEraseLastPoint->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
73                 Connect(btnErasePoint->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
74                 Connect(btnDeleteAllPoints->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
75                 if (mtype==0)
76                 {
77                         Connect(btnSavePoints->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
78                         Connect(btnLoadPoints->GetId()          , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
79                 }
80                 //NTU: Slider events
81                 Connect(sdrOpacity->GetId()                     , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
82                 Connect(sdrRadio->GetId()                       , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
83
84                 sizer1->Add(askPointLabel); // JPR
85                 sizer1->Add(textCtrl);
86                 sizer1->Add(btnAddPoint);
87                 sizer1->Add(btnInsertPoint);//CFT
88                 sizer1->Add(btnSetPositionPoint);
89                 sizer1->Add(btnRenamePoint);
90                 sizer1->Add(btnErasePoint);
91                 sizer1->Add(btnEraseLastPoint);
92                 sizer1->Add(btnDeleteAllPoints);
93                 sizer1->Add(txtNrPoints);
94                 sizer1->Add(txOpacity);
95                 sizer1->Add(sdrOpacity,1,wxGROW );
96                 sizer1->Add(txRadio);
97                 sizer1->Add(sdrRadio,1,wxGROW );
98                 if (mtype==0)
99                 {
100                         sizer1->Add(btnSavePoints);
101                         sizer1->Add(btnLoadPoints);
102                 }
103                 sizer = sizer1;
104         }
105
106           if (mtype==1)
107           {
108                   // Widget interface
109                   wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set nearest point"));
110                   txtNrPoints                                           = new wxStaticText(panel,-1, _T(" "));
111
112                   //NTU: Sliders for opacity and radio change
113                   wxStaticText* txOpacity                       = new wxStaticText(this, -1, wxString(_T("  Points Opacity  ")));
114                   sdrOpacity                                            = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
115                   wxStaticText* txRadio                         = new wxStaticText(this, -1, wxString(_T("  Points Radio  ")));
116                   sdrRadio                                                      = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
117                   wxFlexGridSizer *sizer1                       = new wxFlexGridSizer(1);
118                   Connect(btnSetPositionPoint->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
119                   Connect(sdrOpacity->GetId()   , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
120                   Connect(sdrRadio->GetId()     , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
121
122                   sizer1->Add(btnSetPositionPoint);
123                   sizer1->Add(txtNrPoints);
124                   sizer1->Add(txOpacity);
125                   sizer1->Add(sdrOpacity,1,wxGROW );
126                   sizer1->Add(txRadio);
127                   sizer1->Add(sdrRadio,1,wxGROW );
128                   sizer = sizer1;
129           }
130     
131     if (mtype == 2) 
132         {
133                 askPointLabel                                           = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
134         wxButton                *btnAddPoint            = new wxButton(panel, -1,        _T("      Add  Point      "));
135         wxButton                *btnDeleteAllPoints = new wxButton(panel, -1, _T("      Delete All      "));
136         wxStaticText    *spacer                         = new wxStaticText(panel, -1, _T("\n")); // JPR
137                                          textCtrl                       = new wxTextCtrl(panel, -1);
138         wxFlexGridSizer *sizer1                         = new wxFlexGridSizer(1);
139         Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
140         Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);    
141         sizer1->Add(askPointLabel); 
142         sizer1->Add(btnAddPoint);
143         sizer1->Add(btnDeleteAllPoints);
144         sizer1->Add(spacer);
145         sizer1->Add(textCtrl);
146         sdrOpacity  = new wxSlider();
147         sdrRadio    = new wxSlider();
148         txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
149         sizer = sizer1;
150         } // bbGetInputType 2
151
152         if (sizer!=NULL)
153         {
154                 panel->SetSizer(sizer);
155                 panel->SetAutoLayout(true);
156                 panel->Layout();
157         } // if sizer
158 }
159
160 //------------------------------------------------------------------------
161 WidgetShowNPoints::~WidgetShowNPoints()
162 {
163 }
164
165 //------------------------------------------------------------------------
166 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
167 {
168     // EED 2022-05-19
169     // return mmodelShowNPoints;
170     return lstModelShowNPoints[ mActualLstPoints ];
171 }
172
173 // EED 2022-05-19
174 //------------------------------------------------------------------------
175 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
176 {
177     return lstViewShowNPoints[ mActualLstPoints ];
178 }
179
180
181 //------------------------------------------------------------------------
182 void WidgetShowNPoints::SetRadio(double radio)
183 {
184     // EED 2022-05-19
185     // GetModelShowNPoints()->SetRadio(radio);
186     int i,size = lstModelShowNPoints.size();
187     for (i=0;i<size;i++)
188     {
189         lstModelShowNPoints[i]->SetRadio( radio );
190     } // for i
191         //NTU: For Slider
192         sdrRadio->SetValue(radio);
193 }
194
195 //------------------------------------------------------------------------
196 void WidgetShowNPoints::SetColour(std::vector<double> colour)
197 {
198     // EED 2022-05-19
199     //this->mcolour = colour;
200     int i,size = lstViewShowNPoints.size();
201     for (i=0 ; i<size ; i++)
202     {
203         lstViewShowNPoints[i]->mcolour = colour;
204     } // for i
205 }
206
207 //------------------------------------------------------------------------
208 void WidgetShowNPoints::SetImage(vtkImageData* image)
209 {
210     // EED 2022-05-19
211         //GetModelShowNPoints()->SetImage(image);
212     int i,size = lstModelShowNPoints.size();
213     for (i=0 ; i<size ; i++)
214     {
215         lstModelShowNPoints[i]->SetImage(image);
216     } // for i
217 }
218
219 //------------------------------------------------------------------------
220 void WidgetShowNPoints::SetOpacity(double opacity)
221 {
222     // EED 2022-05-19
223         //this->mopacity=opacity;
224     int i,size = lstViewShowNPoints.size();
225     for (i=0 ; i<size ; i++)
226     {
227         lstViewShowNPoints[i]->mopacity = opacity;
228     } // for i
229         //NTU: For Slider
230         sdrOpacity->SetValue( opacity*100.0 );
231 }
232
233
234 //------------------------------------------------------------------------
235 void  WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
236 {
237     // EED 2022-05-19
238         //this->renderer        = renderer;
239     int i,size = lstViewShowNPoints.size();
240     for (i=0 ; i<size ; i++)
241     {
242         lstViewShowNPoints[i]->renderer = renderer;
243     } // for i
244 }
245
246 /* EED 2022-05-19
247 //------------------------------------------------------------------------
248         
249 void WidgetShowNPoints::RefreshPoint(int id)
250 {
251         double spc[3];
252         int x,y,z;
253         GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
254         GetModelShowNPoints()->GetImage()->GetSpacing(spc);
255         std::string label       = GetModelShowNPoints()->GetIdLabel(id);
256         double radio            = GetModelShowNPoints()->GetRadio();
257     lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
258     lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
259     lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
260     lstSourceSphere[id]->SetRadius( radio );
261 //EED 2017-01-01 Migration VTK7
262 #if VTK_MAJOR_VERSION <= 5
263         // ..
264 #else
265     lstSourceSphere[id]->Update();
266 #endif
267     lstActorsText[id]->SetInput( label.c_str()  );
268     lstActorsText[id]->SetPosition(  radio+spc[0]*x , spc[1]*y , spc[2]*z );
269 }
270
271 //------------------------------------------------------------------------
272 void WidgetShowNPoints::RefreshPoints()
273 {
274         int id,size=lstActorsSphere.size();
275         for (id=0;id<size;id++)
276         {
277                 RefreshPoint(id);
278         } // for
279         renderer->GetRenderWindow()->Render();
280 }
281
282 //------------------------------------------------------------------------
283 void WidgetShowNPoints::AddVtkPoint()
284 {
285         // Sphere
286         vtkSphereSource *vtksphere = vtkSphereSource::New();
287         vtksphere->SetThetaResolution (20);
288         vtksphere->SetPhiResolution (20);
289         vtksphere->SetRadius( 1 );
290         //NTU: For updating points
291         lstSourceSphere.push_back(vtksphere);
292         vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
293
294 //EED 2017-01-01 Migration VTK7
295 #if VTK_MAJOR_VERSION <= 5
296         sphereMapper->SetInput( vtksphere->GetOutput() );
297 #else
298         vtksphere->Update();
299         sphereMapper->SetInputData( vtksphere->GetOutput() );
300 #endif
301
302         vtkActor *sphereActor   = vtkActor::New();
303         sphereActor->SetMapper(sphereMapper);
304         sphereActor->SetOrigin(0, 0, 0);
305
306         lstActorsSphere.push_back(sphereActor);
307         if(renderer==NULL){
308                 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
309                 dialog.ShowModal();             
310                 return;
311         }
312         renderer->AddActor( sphereActor );
313         // Actor
314         vtkTextActor3D *textActor = vtkTextActor3D::New();
315 //      textActor->SetInput( strLabel.c_str()  );
316         renderer->AddActor( textActor );
317         lstActorsText.push_back(textActor);
318 }
319  */
320
321
322 //------------------------------------------------------------------------
323 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
324 {
325         GetModelShowNPoints()->AddPoint(x,y,z, label );
326     // EED 2022-05-19
327     //AddVtkPoint();
328     //RefreshPoint(lstActorsSphere.size()-1);
329     GetViewShowNPoints()->AddPoint();
330 }
331
332 //------------------------------------------------------------------------
333 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
334 {
335     // EED 2022-05-19
336         //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
337         //{
338     //    AddVtkPoint();
339         //} else {
340         //      AddPoint(x,y,z,label);
341         //}
342         //RefreshPoints();
343     if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
344     {
345         GetViewShowNPoints()->AddVtkPoint();
346     } else {
347         AddPoint(x,y,z,label);
348     }
349     GetViewShowNPoints()->RefreshPoints();
350
351 }
352
353 //------------------------------------------------------------------------
354 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
355 {       
356     // EED 2022-05-19
357         //if (this->renderer==NULL)
358     if (GetViewShowNPoints()->renderer==NULL)
359         {
360                 return;
361         }
362
363         std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
364         if (point.size()==3)
365         {
366                 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
367                 SetOutputBox();
368         // EED 2022-05-19
369         //renderer->GetRenderWindow()->Render();
370         GetViewShowNPoints()->Render();
371         } else {//mpoint.size
372                 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
373         }
374 }
375
376 //------------------------------------------------------------------------
377 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
378 {       
379     // EED 2022-05-19
380     //if (this->renderer==NULL)
381     if (GetViewShowNPoints()->renderer==NULL)
382         {
383                 return;
384         }
385
386         std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
387         if (point.size()==3)
388         {
389                 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
390                 SetOutputBox();
391         } else {//mpoint.size
392                 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
393         }
394 }
395
396
397 //------------------------------------------------------------------------
398         void WidgetShowNPoints::SetOutputBox()
399         {
400 //EED           renderer->GetRenderWindow()->Render();
401                 wxString strTmp;
402                 strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
403                 txtNrPoints->SetLabel( strTmp );
404                 //--BBTK
405
406 //EED 2017-06-03
407 //              mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
408 //              mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
409 //              mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
410 //              mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
411 //              mbbShowNPoints->bbSignalOutputModification();
412         }
413
414
415 //------------------------------------------------------------------------
416         void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
417         {
418
419 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
420 #if wxMAJOR_VERSION <= 2
421                 wxFileDialog* FD = new wxFileDialog( 0,
422                                             _T("Save points .."),
423                                             _T(""),
424                                             _T(""),
425                                             _T("(*.xls)|*.xls"),
426                                             wxSAVE | wxOVERWRITE_PROMPT,
427                                             wxDefaultPosition);
428 #else
429                 wxFileDialog* FD = new wxFileDialog( 0,
430                                             _T("Save points .."),
431                                             _T(""),
432                                             _T(""),
433                                             _T("(*.xls)|*.xls"),
434                                             wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
435                                             wxDefaultPosition);
436 #endif
437
438                 int result_FD = FD->ShowModal();
439                 // This line is need it by windows //EED
440                 FD->SetReturnCode( result_FD );
441                 if (FD->GetReturnCode()==wxID_OK)
442                 {
443                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
444                         GetModelShowNPoints()->SavePoints( filename );
445                 }       // dialog box
446         }
447
448
449 //------------------------------------------------------------------------
450         void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
451         {
452
453 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
454 #if wxMAJOR_VERSION <= 2
455                 wxFileDialog* FD = new wxFileDialog( 0,
456                                              _T("Load points .."),
457                                              _T(""),
458                                              _T(""),
459                                              _T("(*.xls)|*.xls"),
460                                              wxOPEN | wxFILE_MUST_EXIST,
461                                              wxDefaultPosition);
462 #else
463                 wxFileDialog* FD = new wxFileDialog( 0,
464                                              _T("Load points .."),
465                                              _T(""),
466                                              _T(""),
467                                              _T("(*.xls)|*.xls"),
468                                              wxFD_OPEN | wxFD_FILE_MUST_EXIST,
469                                              wxDefaultPosition);
470 #endif
471                 int i;
472                 //EED
473                 int result_FD = FD->ShowModal();
474                 // This line is need it by windows //EED
475                 FD->SetReturnCode( result_FD );
476                 if (FD->GetReturnCode()==wxID_OK)
477                 {
478
479                         std::string filename= (const char*) ( FD->GetPath().mb_str() ); 
480                         int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
481                         for (i=0;i<numberPointsRead;i++)
482                         {
483                 // EED 2022-05-19
484                 //AddVtkPoint();
485                 GetViewShowNPoints()->AddVtkPoint();
486                         }// for
487                         SetOutputBox();
488             // EED 2022-05-19
489                         //RefreshPoints();
490             GetViewShowNPoints()->RefreshPoints();
491                 }       // dialog box
492         }
493
494         //------------------------------------------------------------------------
495         void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
496         {
497                 int id=GetModelShowNPoints()->GetNearestPoint();
498                 if((id==-1) && (mtype==1))
499                 {
500                         id=0;
501                         AddPoint(0,0,0,"");
502                         SetOutputBox();
503                 }
504         
505                 if (id>=0)
506                 {
507                         GetModelShowNPoints()->SetPointId_mReferencePoint(id);
508             // EED 2022-05-19
509                         //RefreshPoint(id);
510                         //renderer->GetRenderWindow()->Render();
511             GetViewShowNPoints()->RefreshPoint(id);
512             GetViewShowNPoints()->Render();
513                 } // if id
514                 SetOutputBox();
515         }
516         
517 //------------------------------------------------------------------------
518         void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
519         {
520                 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
521                 if (id>=0)
522                 {
523             // EED 2022-05-19
524                         //lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
525                         //renderer->GetRenderWindow()->Render();
526             GetViewShowNPoints()->lstActorsText[id]->SetInput(  (const char*) ( textCtrl->GetValue().mb_str() ) );
527             GetViewShowNPoints()->Render();
528             SetOutputBox();
529                 }
530         }
531
532 //------------------------------------------------------------------------
533         void WidgetShowNPoints::ErasePoint(int id)
534         {
535         // EED 2022-05-19
536                 //if (this->renderer!=NULL)
537         if (GetViewShowNPoints()->renderer!=NULL)
538                 {
539                         if (id>=0)
540                         {
541                 // EED 2022-05-19
542                                 //renderer->RemoveActor( lstActorsSphere[id] );
543                                 //renderer->RemoveActor( lstActorsText[id] );
544                                 //lstActorsSphere[id]->Delete();
545                                 //lstActorsText[id]->Delete();
546                                 //lstSourceSphere[id]->Delete();
547                                 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
548                                 //lstActorsText.erase( lstActorsText.begin()+id );
549                                 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
550                 GetViewShowNPoints()->ErasePoint(id);
551                                 GetModelShowNPoints()->ErasePoint(id);
552                         } // if id
553                 } // if renderer
554         }
555
556 //------------------------------------------------------------------------
557         void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
558         {
559                 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
560                 SetOutputBox();
561         // EED 2022-05-19
562                 //renderer->GetRenderWindow()->Render();
563         GetViewShowNPoints()->Render();
564         }
565
566 //------------------------------------------------------------------------
567         void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
568         {
569         // EED 2022-05-19
570         //ErasePoint( lstActorsSphere.size()-1 );
571         //renderer->GetRenderWindow()->Render();
572         int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
573         ErasePoint( id );
574         GetViewShowNPoints()->Render();
575         SetOutputBox();
576         }
577
578 //------------------------------------------------------------------------
579 void WidgetShowNPoints::DeleteAllPoints()
580 {
581     // EED 2022-05-19
582         //int id,size=lstActorsSphere.size();
583     int id,size=GetViewShowNPoints()->lstActorsSphere.size();
584         for (id=size-1;id>=0;id--)
585         {
586                 ErasePoint(id);
587         }
588         SetOutputBox();
589     // EED 2022-05-19
590         //renderer->GetRenderWindow()->Render();
591     GetViewShowNPoints()->Render();
592 }
593
594 //------------------------------------------------------------------------
595 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
596 {
597         DeleteAllPoints();
598 }
599
600 //NTU: Method for updating points opacity and Radio
601
602 //------------------------------------------------------------------------
603 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
604 {
605     // EED 2022-05-19
606         //this->mopacity = sdrOpacity->GetValue()/100.0;
607     //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
608     //RefreshPoints();
609
610     double opacity  = sdrOpacity->GetValue()/100.0;
611     double radio    = sdrRadio->GetValue();
612     int i,size      = lstViewShowNPoints.size();
613     for (i=0 ; i<size ; i++)
614     {
615         lstViewShowNPoints[i]->mopacity = opacity;
616         lstModelShowNPoints[i]->SetRadio( radio ) ;
617     } // for i
618     GetViewShowNPoints()->RefreshPoints();
619 }
620
621 //------------------------------------------------------------------------
622 void  WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
623 {
624         GetModelShowNPoints()->SetReferencePoint(point);
625 }
626
627 //------------------------------------------------------------------------
628 void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
629 {
630     // EED 2022-05-19
631         //if (this->renderer==NULL)
632     if (GetViewShowNPoints()->renderer==NULL)
633         {
634                 return;
635         }
636         int i,sizeX,sizeY,sizeZ,sizeLabels;
637         sizeX=(int)initLstPointsX.size();
638         sizeY=(int)initLstPointsY.size();
639         sizeZ=(int)initLstPointsZ.size();
640         sizeLabels=(int)initLstLabels.size();
641         int x,y,z;
642         std::string label;
643         if ( (sizeX==sizeY) && (sizeX==sizeZ) )
644         {
645                 for (i=0;i<sizeX;i++)
646                 {
647                         x               = initLstPointsX[i];
648                         y               = initLstPointsY[i];
649                         z               = initLstPointsZ[i];
650                         if (i<sizeLabels) 
651                         {
652                                 label   = initLstLabels[i];
653                         } else {
654                                 label="";
655                         }
656                         AddPoint( x,y,z,label );
657                 } // for i
658                 //      SetOutputBox(); 
659                 //      renderer->GetRenderWindow()->Render();
660         } // if size
661 }
662
663 //------------------------------------------------------------------------
664 void WidgetShowNPoints::SetType(int type)
665 {
666         mtype=type;
667 }
668
669 //------------------------------------------------------------------------
670 int WidgetShowNPoints::GetType()
671 {
672         return mtype;
673 }
674
675
676 //------------------------------------------------------------------------
677 double WidgetShowNPoints::GetRadio()
678 {
679         return sdrRadio->GetValue();
680 }
681 //------------------------------------------------------------------------
682 double WidgetShowNPoints::GetOpacity()
683 {
684         return sdrOpacity->GetValue()/100;
685 }