3 #include "vtkSphereSource.h"
4 #include "vtkRenderer.h"
5 #include "vtkTextActor3D.h"
11 #include <wx/filedlg.h>
12 #include <wx/msgdlg.h>
13 #include <wx/notebook.h>
15 #include "WidgetShowNPoints.h"
18 //----------------------------------------------------------------------
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
24 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
26 printf("EED WidgetShowNPoints::WidgetShowNPoints Start \n");
28 // mmodelShowNPoints = new ModelShowNPoints();
30 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
31 lstModelShowNPoints.push_back( modelShowNPoints );
32 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
36 wxPanel* panelParent = this;
37 wxSizer* sizer = NULL;
38 wxSizer* MNPsizer = NULL;
40 wxNotebook* bookSetPoints = NULL;
41 wxNotebook* bookGroupManager = NULL;
42 wxPanel* panel = NULL;
43 wxPanel* panel2 = NULL;
45 bookSetPoints = new wxNotebook(panelParent,
50 panel = new wxPanel(bookSetPoints);
56 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
61 panel2 = new wxPanel(bookGroupManager);
62 txtNrCollections = new wxStaticText(panel2,-1, _T("1 / 1 "));
63 wxButton *btnBackCollection = new wxButton( panel2, -1, _T("<"));
64 wxButton *btnNextCollection = new wxButton( panel2, -1, _T(">"));
65 wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("Insert Group Before"));
66 wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("Insert Group After"));
67 wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("Delete Group "));
68 wxButton *btnSaveCollection = new wxButton( panel2, -1, _T("Save Groups"));
69 wxButton *btnLoadCollection = new wxButton( panel2, -1, _T("Load Groups"));
71 //NTU: Sliders for opacity and radio change
72 wxStaticText* txOpacity = new wxStaticText(panel2, -1, wxString(_T(" Points Opacity ")));
73 sdrOpacity = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
74 wxStaticText* txRadio = new wxStaticText(panel2, -1, wxString(_T(" Points Radius ")));
75 sdrRadio = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
77 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
78 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
80 Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore );
81 Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter );
82 Connect(btnDeleteCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection );
83 Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection );
84 Connect(btnSaveCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections );
85 Connect(btnLoadCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections );
87 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
88 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
90 sizer2->Add( btnBackCollection );
91 sizer2->Add( btnNextCollection );
93 sizer1->Add( txtNrCollections );
94 sizer1->Add( sizer2 );
95 sizer1->Add( btnInsertCollectionBefore );
96 sizer1->Add( btnInsertCollectionAfter );
97 sizer1->Add( btnDeleteCollection );
99 sizer1->Add( txOpacity );
100 sizer1->Add( sdrOpacity );
101 sizer1->Add( txRadio );
102 sizer1->Add( sdrRadio );
104 sizer1->Add( btnSaveCollection );
105 sizer1->Add( btnLoadCollection );
107 panel2->SetSizer( MNPsizer );
108 panel2->SetAutoLayout(true);
110 bookGroupManager->AddPage(panel2 , _T("Groupts") );
113 if ( (mtype==0) || (mtype==3) || (mtype==4) )
116 askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR
117 textCtrl = new wxTextCtrl(panel, -1);
118 wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point"));
119 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("Insert Point"));//CFT
120 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
121 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point"));
122 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point"));
123 wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point"));
124 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
125 wxButton *btnSavePoints = NULL;
126 wxButton *btnLoadPoints = NULL;
129 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
130 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
131 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
132 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
134 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
136 wxStaticText* txOpacity;
137 wxStaticText* txRadio;
138 if ( (mtype==0) || (mtype==3) )
140 //NTU: Sliders for opacity and radio change
141 txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
142 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
143 txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
144 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
146 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
147 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
150 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
151 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
152 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
153 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
154 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
155 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
156 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
159 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
160 sizer1->Add(askPointLabel); // JPR
161 sizer1->Add(textCtrl);
162 sizer1->Add(btnAddPoint);
163 sizer1->Add(btnInsertPoint);//CFT
164 sizer1->Add(btnSetPositionPoint);
165 sizer1->Add(btnRenamePoint);
166 sizer1->Add(btnErasePoint);
167 sizer1->Add(btnEraseLastPoint);
168 sizer1->Add(btnDeleteAllPoints);
169 sizer1->Add(txtNrPoints);
171 if ( (mtype==0) || (mtype==3) )
173 sizer1->Add(txOpacity);
174 sizer1->Add(sdrOpacity,1,wxGROW );
175 sizer1->Add(txRadio);
176 sizer1->Add(sdrRadio,1,wxGROW );
180 sizer1->Add(btnSavePoints);
181 sizer1->Add(btnLoadPoints);
189 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
190 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
192 //NTU: Sliders for opacity and radio change
193 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
194 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
195 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
196 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
197 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
198 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
199 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
201 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
202 sizer1->Add(btnSetPositionPoint);
203 sizer1->Add(txtNrPoints);
204 sizer1->Add(txOpacity);
205 sizer1->Add(sdrOpacity,1,wxGROW );
206 sizer1->Add(txRadio);
207 sizer1->Add(sdrRadio,1,wxGROW );
213 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
214 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
215 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
216 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
217 textCtrl = new wxTextCtrl(panel, -1);
218 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
219 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
220 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
221 sizer1->Add(askPointLabel);
222 sizer1->Add(btnAddPoint);
223 sizer1->Add(btnDeleteAllPoints);
225 sizer1->Add(textCtrl);
226 // sdrOpacity = new wxSlider();
227 // sdrRadio = new wxSlider();
228 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
230 } // bbGetInputType 2
233 panel->SetSizer(sizer);
234 panel->SetAutoLayout(true);
236 bookSetPoints->AddPage(panel , _T("Points") );
238 if ((mtype >= 0) && (mtype <= 3) )
242 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
243 sizerParent->Add( bookSetPoints );
244 panelParent->SetSizer( sizerParent );
245 panelParent->SetAutoLayout(true);
246 panelParent->Layout();
248 } // if mtype 0 1 2 3
252 if ((sizer!=NULL) && (MNPsizer!=NULL))
254 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
255 sizerG->Add(bookGroupManager);
256 sizerG->Add(bookSetPoints);
257 panelParent->SetSizer(sizerG);
258 panelParent->SetAutoLayout(true);
259 panelParent->Layout();
264 //------------------------------------------------------------------------
265 WidgetShowNPoints::~WidgetShowNPoints()
269 //------------------------------------------------------------------------
270 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
273 // return mmodelShowNPoints;
274 return lstModelShowNPoints[ mActualCollection ];
278 //------------------------------------------------------------------------
279 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
281 return lstViewShowNPoints[ mActualCollection ];
285 //------------------------------------------------------------------------
286 void WidgetShowNPoints::SetRadio(double radio)
289 // GetModelShowNPoints()->SetRadio(radio);
290 int i,size = lstModelShowNPoints.size();
293 lstModelShowNPoints[i]->SetRadio( radio );
296 sdrRadio->SetValue(radio);
299 //------------------------------------------------------------------------
300 void WidgetShowNPoints::SetColour(std::vector<double> colour)
303 //this->mcolour = colour;
304 int i,size = lstViewShowNPoints.size();
305 for (i=0 ; i<size ; i++)
307 lstViewShowNPoints[i]->mcolour = colour;
311 //------------------------------------------------------------------------
312 void WidgetShowNPoints::SetImage(vtkImageData* image)
315 //GetModelShowNPoints()->SetImage(image);
316 int i,size = lstModelShowNPoints.size();
317 for (i=0 ; i<size ; i++)
319 lstModelShowNPoints[i]->SetImage(image);
323 //------------------------------------------------------------------------
324 void WidgetShowNPoints::SetOpacity(double opacity)
327 //this->mopacity=opacity;
328 int i,size = lstViewShowNPoints.size();
329 for (i=0 ; i<size ; i++)
331 lstViewShowNPoints[i]->mopacity = opacity;
334 sdrOpacity->SetValue( opacity*100.0 );
338 //------------------------------------------------------------------------
339 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
342 //this->renderer = renderer;
343 int i,size = lstViewShowNPoints.size();
344 for (i=0 ; i<size ; i++)
346 lstViewShowNPoints[i]->renderer = renderer;
351 //------------------------------------------------------------------------
353 void WidgetShowNPoints::RefreshPoint(int id)
357 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
358 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
359 std::string label = GetModelShowNPoints()->GetIdLabel(id);
360 double radio = GetModelShowNPoints()->GetRadio();
361 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
362 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
363 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
364 lstSourceSphere[id]->SetRadius( radio );
365 //EED 2017-01-01 Migration VTK7
366 #if VTK_MAJOR_VERSION <= 5
369 lstSourceSphere[id]->Update();
371 lstActorsText[id]->SetInput( label.c_str() );
372 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
375 //------------------------------------------------------------------------
376 void WidgetShowNPoints::RefreshPoints()
378 int id,size=lstActorsSphere.size();
379 for (id=0;id<size;id++)
383 renderer->GetRenderWindow()->Render();
386 //------------------------------------------------------------------------
387 void WidgetShowNPoints::AddVtkPoint()
390 vtkSphereSource *vtksphere = vtkSphereSource::New();
391 vtksphere->SetThetaResolution (20);
392 vtksphere->SetPhiResolution (20);
393 vtksphere->SetRadius( 1 );
394 //NTU: For updating points
395 lstSourceSphere.push_back(vtksphere);
396 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
398 //EED 2017-01-01 Migration VTK7
399 #if VTK_MAJOR_VERSION <= 5
400 sphereMapper->SetInput( vtksphere->GetOutput() );
403 sphereMapper->SetInputData( vtksphere->GetOutput() );
406 vtkActor *sphereActor = vtkActor::New();
407 sphereActor->SetMapper(sphereMapper);
408 sphereActor->SetOrigin(0, 0, 0);
410 lstActorsSphere.push_back(sphereActor);
412 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
416 renderer->AddActor( sphereActor );
418 vtkTextActor3D *textActor = vtkTextActor3D::New();
419 // textActor->SetInput( strLabel.c_str() );
420 renderer->AddActor( textActor );
421 lstActorsText.push_back(textActor);
426 //------------------------------------------------------------------------
427 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
429 GetModelShowNPoints()->AddPoint(x,y,z, label );
432 //RefreshPoint(lstActorsSphere.size()-1);
433 GetViewShowNPoints()->AddPoint();
436 //------------------------------------------------------------------------
437 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
440 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
444 // AddPoint(x,y,z,label);
447 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
449 GetViewShowNPoints()->AddVtkPoint();
451 AddPoint(x,y,z,label);
453 GetViewShowNPoints()->RefreshPoints();
457 //------------------------------------------------------------------------
458 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
461 //if (this->renderer==NULL)
462 if (GetViewShowNPoints()->renderer==NULL)
467 std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
470 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
473 //renderer->GetRenderWindow()->Render();
474 GetViewShowNPoints()->Render();
475 } else {//mpoint.size
476 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
480 //------------------------------------------------------------------------
481 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
484 //if (this->renderer==NULL)
485 if (GetViewShowNPoints()->renderer==NULL)
490 std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
493 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
495 } else {//mpoint.size
496 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
501 //------------------------------------------------------------------------
502 void WidgetShowNPoints::SetOutputBox()
504 //EED renderer->GetRenderWindow()->Render();
506 strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
507 txtNrPoints->SetLabel( strTmp );
511 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
512 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
513 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
514 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
515 // mbbShowNPoints->bbSignalOutputModification();
519 //------------------------------------------------------------------------
520 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
523 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
524 #if wxMAJOR_VERSION <= 2
525 wxFileDialog* FD = new wxFileDialog( 0,
526 _T("Save points .."),
530 wxSAVE | wxOVERWRITE_PROMPT,
533 wxFileDialog* FD = new wxFileDialog( 0,
534 _T("Save points .."),
538 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
542 int result_FD = FD->ShowModal();
543 // This line is need it by windows //EED
544 FD->SetReturnCode( result_FD );
545 if (FD->GetReturnCode()==wxID_OK)
547 std::string filename= (const char*) ( FD->GetPath().mb_str() );
548 GetModelShowNPoints()->SavePoints( filename );
553 //------------------------------------------------------------------------
554 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
557 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
558 #if wxMAJOR_VERSION <= 2
559 wxFileDialog* FD = new wxFileDialog( 0,
560 _T("Load points .."),
564 wxOPEN | wxFILE_MUST_EXIST,
567 wxFileDialog* FD = new wxFileDialog( 0,
568 _T("Load points .."),
572 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
577 int result_FD = FD->ShowModal();
578 // This line is need it by windows //EED
579 FD->SetReturnCode( result_FD );
580 if (FD->GetReturnCode()==wxID_OK)
583 std::string filename= (const char*) ( FD->GetPath().mb_str() );
584 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
585 for (i=0;i<numberPointsRead;i++)
589 GetViewShowNPoints()->AddVtkPoint();
594 GetViewShowNPoints()->RefreshPoints();
598 //------------------------------------------------------------------------
599 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
601 int id=GetModelShowNPoints()->GetNearestPoint();
602 if((id==-1) && (mtype==1))
611 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
614 //renderer->GetRenderWindow()->Render();
615 GetViewShowNPoints()->RefreshPoint(id);
616 GetViewShowNPoints()->Render();
621 //------------------------------------------------------------------------
622 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
624 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
628 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
629 //renderer->GetRenderWindow()->Render();
630 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
631 GetViewShowNPoints()->Render();
636 //------------------------------------------------------------------------
637 void WidgetShowNPoints::ErasePoint(int id)
640 //if (this->renderer!=NULL)
641 if (GetViewShowNPoints()->renderer!=NULL)
646 //renderer->RemoveActor( lstActorsSphere[id] );
647 //renderer->RemoveActor( lstActorsText[id] );
648 //lstActorsSphere[id]->Delete();
649 //lstActorsText[id]->Delete();
650 //lstSourceSphere[id]->Delete();
651 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
652 //lstActorsText.erase( lstActorsText.begin()+id );
653 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
654 GetViewShowNPoints()->ErasePoint(id);
655 GetModelShowNPoints()->ErasePoint(id);
660 //------------------------------------------------------------------------
661 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
663 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
666 //renderer->GetRenderWindow()->Render();
667 GetViewShowNPoints()->Render();
670 //------------------------------------------------------------------------
671 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
674 //ErasePoint( lstActorsSphere.size()-1 );
675 //renderer->GetRenderWindow()->Render();
676 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
678 GetViewShowNPoints()->Render();
682 //------------------------------------------------------------------------
683 void WidgetShowNPoints::DeleteAllPoints()
686 //int id,size=lstActorsSphere.size();
687 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
688 for (id=size-1;id>=0;id--)
694 //renderer->GetRenderWindow()->Render();
695 GetViewShowNPoints()->Render();
698 //------------------------------------------------------------------------
699 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
704 //NTU: Method for updating points opacity and Radio
706 //------------------------------------------------------------------------
707 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
710 //this->mopacity = sdrOpacity->GetValue()/100.0;
711 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
714 double opacity = sdrOpacity->GetValue()/100.0;
715 double radio = sdrRadio->GetValue();
716 int i,size = lstViewShowNPoints.size();
717 for (i=0 ; i<size ; i++)
719 lstViewShowNPoints[i]->mopacity = opacity;
720 lstModelShowNPoints[i]->SetRadio( radio ) ;
722 // GetViewShowNPoints()->RefreshPoints();
723 RefreshColourCollection();
726 //------------------------------------------------------------------------
727 void WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
729 GetModelShowNPoints()->SetReferencePoint(point);
732 //------------------------------------------------------------------------
733 void WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
736 //if (this->renderer==NULL)
737 if (GetViewShowNPoints()->renderer==NULL)
741 int i,sizeX,sizeY,sizeZ,sizeLabels;
742 sizeX = (int)initLstPointsX.size();
743 sizeY = (int)initLstPointsY.size();
744 sizeZ = (int)initLstPointsZ.size();
745 sizeLabels = (int)initLstLabels.size();
748 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
750 for (i=0;i<sizeX;i++)
752 x = initLstPointsX[i];
753 y = initLstPointsY[i];
754 z = initLstPointsZ[i];
757 label = initLstLabels[i];
761 AddPoint( x,y,z,label );
764 // renderer->GetRenderWindow()->Render();
768 //------------------------------------------------------------------------
769 void WidgetShowNPoints::SetType(int type)
774 //------------------------------------------------------------------------
775 int WidgetShowNPoints::GetType()
781 //------------------------------------------------------------------------
782 double WidgetShowNPoints::GetRadio()
784 return sdrRadio->GetValue();
786 //------------------------------------------------------------------------
787 double WidgetShowNPoints::GetOpacity()
789 return sdrOpacity->GetValue()/100;
792 //------------------------------------------------------------------------
793 void WidgetShowNPoints::InsertCollection()
795 ModelShowNPoints* model = new ModelShowNPoints();
796 ViewShowNPoints* view = new ViewShowNPoints( model );
797 model->SetImage( lstModelShowNPoints[0]->GetImage() );
798 view->mopacity = lstViewShowNPoints[0]->mopacity;
799 view->renderer = lstViewShowNPoints[0]->renderer;
800 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
801 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
802 RefreshCollectionText();
805 //------------------------------------------------------------------------
806 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
809 RefreshColourCollection();
812 //------------------------------------------------------------------------
813 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
817 RefreshColourCollection();
820 //------------------------------------------------------------------------
821 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
823 if ( lstModelShowNPoints.size()>1 )
825 DeleteAllPoints(); // Actual Collection
826 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
827 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
828 if ( mActualCollection>=lstModelShowNPoints.size() )
833 DeleteAllPoints(); // Actual Collection
836 RefreshCollectionText();
837 RefreshColourCollection();
840 //------------------------------------------------------------------------
841 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
844 if ( mActualCollection <0 )
848 RefreshCollectionText();
849 RefreshColourCollection();
852 //------------------------------------------------------------------------
853 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
856 if ( mActualCollection >=lstModelShowNPoints.size() )
858 mActualCollection = lstModelShowNPoints.size()-1;
860 RefreshCollectionText();
861 RefreshColourCollection();
864 //------------------------------------------------------------------------
865 void WidgetShowNPoints::RefreshColourCollection()
867 std::vector<double> colourAll;
868 colourAll.push_back(1);
869 colourAll.push_back(0);
870 colourAll.push_back(0);
871 std::vector<double> colourActual;
872 colourActual.push_back(1);
873 colourActual.push_back(1);
874 colourActual.push_back(0);
875 SetColour( colourAll ); // For all collections
877 int i,size=lstViewShowNPoints.size();
880 lstViewShowNPoints[i] -> mcolour = colourAll; // All collection
881 lstViewShowNPoints[i]->RefreshEachPoint();
883 lstViewShowNPoints[mActualCollection] -> mcolour = colourActual; // Actual collection
884 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
885 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
888 //------------------------------------------------------------------------
889 void WidgetShowNPoints::RefreshCollectionText()
892 strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
893 txtNrCollections->SetLabel( strTmp );
897 //------------------------------------------------------------------------
898 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
900 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
901 #if wxMAJOR_VERSION <= 2
902 wxFileDialog* FD = new wxFileDialog( 0,
903 _T("Save groups of points .."),
907 wxSAVE | wxOVERWRITE_PROMPT,
910 wxFileDialog* FD = new wxFileDialog( 0,
911 _T("Save groups of points .."),
915 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
919 int result_FD = FD->ShowModal();
920 // This line is need it by windows //EED
921 FD->SetReturnCode( result_FD );
922 if (FD->GetReturnCode()==wxID_OK)
924 std::string filename= (const char*) ( FD->GetPath().mb_str() );
927 ff = fopen( filename.c_str() , "w+" );
930 int i,size=lstModelShowNPoints.size();
931 fprintf(ff,"NumberOfGroups %d \n",size);
935 lstModelShowNPoints[i]->SavePoints_(ff);
940 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
948 //------------------------------------------------------------------------
949 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
951 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
952 #if wxMAJOR_VERSION <= 2
953 wxFileDialog* FD = new wxFileDialog( 0,
954 _T("Load groups of points .."),
958 wxOPEN | wxFILE_MUST_EXIST,
961 wxFileDialog* FD = new wxFileDialog( 0,
962 _T("Load groups of points .."),
966 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
971 int result_FD = FD->ShowModal();
972 // This line is need it by windows //EED
973 FD->SetReturnCode( result_FD );
974 if (FD->GetReturnCode()==wxID_OK)
977 FILE *ff = fopen( filename.c_str() , "r+" );
980 int iGroup,sizeGroups;
981 int iPoint,numberPointsRead
983 fscanf(ff," %s %d",chartmp,&sizeGroups);
985 /// InsertCollection();
987 for (iGroup=0;i<sizeGroups;i++)
989 int numberPointsRead= lstModelShowNPoints?????????[i]->ReadPoints_(ff);
990 for (i=0;i<numberPointsRead;i++)
994 GetViewShowNPoints?????()->AddVtkPoint();
1000 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1003 RefreshCollectionText();
1004 RefreshColourCollection();