2 #include "vtkSphereSource.h"
3 #include "vtkRenderer.h"
4 #include "vtkTextActor3D.h"
8 #include <wx/filedlg.h>
10 #include <wx/notebook.h>
12 #include "WidgetShowNPoints.h"
14 #include <creaContoursFactory.h>
16 //----------------------------------------------------------------------
17 //----------------------------------------------------------------------
18 //----------------------------------------------------------------------
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
22 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
25 // mmodelShowNPoints = new ModelShowNPoints();
29 char * val = getenv( "TEMP" );
32 UndoRedoDir = std::string("");
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() );
42 #elif defined(__GNUC__)
46 UndoRedoDir = "/tmp/creatools";
48 UndoRedoDir = "/tmp/creatools";
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() );
63 mActualCollection = 0;
64 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
65 lstModelShowNPoints.push_back( modelShowNPoints );
66 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
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,
83 panel = new wxPanel(bookSetPoints);
84 txtNrCollections = NULL;
87 sizeButton.Set( 45 , -1 );
89 sizeSlider.Set( 90 , -1 );
94 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
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:")));
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") );
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);
126 sdrRadio -> SetToolTip( _T("Radio") );
127 sdrOpacity -> SetToolTip( _T("Opacity") );
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 );
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 );
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 );
161 panel2->SetSizer( MNPsizer );
162 panel2->SetAutoLayout(true);
164 bookGroupManager->AddPage(panel2 , _T("Groups") );
167 if ( (mtype==0) || (mtype==3) || (mtype==4) )
170 // askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR
171 textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton);
172 cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton );
173 wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton );
174 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );//CFT
175 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton );
176 cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton );
177 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton );
178 wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
179 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
180 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
181 wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
182 wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
183 wxButton *btnSavePoints = NULL;
184 wxButton *btnLoadPoints = NULL;
186 cbAutoAddPoints -> SetToolTip( _T("Auto Add point") );
187 btnAddPoint -> SetToolTip( _T("+ Add point") );
188 btnInsertPoint -> SetToolTip( _T("(-) Insert point") );
189 btnErasePoint -> SetToolTip( _T("- Erase point") );
190 btnEraseLastPoint -> SetToolTip( _T("- lst Erase last point") );
191 btnDeleteAllPoints -> SetToolTip( _T("-- Erase all points") );
195 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
196 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
197 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
198 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
200 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
202 wxStaticText* txOpacity;
203 wxStaticText* txRadio;
204 if ( (mtype==0) || (mtype==3) )
206 //NTU: Sliders for opacity and radio change
207 txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
208 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
209 txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
210 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
212 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
213 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
215 Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints);
216 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
217 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
218 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
219 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
220 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
221 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
222 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
223 Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
224 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
225 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
226 wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
227 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
228 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
229 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
230 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(2);
231 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
232 sizer1->Add( textCtrl );
233 sizer1->Add( btnRenamePoint );
234 sizer2->Add( cbAutoAddPoints );
235 sizer2->Add( new wxStaticText(panel, -1, _T(" ")) );
236 sizer2->Add( btnAddPoint );
237 sizer2->Add( btnInsertPoint );//CFT
238 sizer3->Add( btnSetPositionPoint );
239 sizer3->Add( cbTrackPoint );
240 sizer4->Add( btnErasePoint );
241 sizer4->Add( btnEraseLastPoint );
242 sizer4->Add( btnDeleteAllPoints );
243 sizer5->Add( btnUndo );
244 sizer5->Add( btnRedo );
245 // sizer0->Add(askPointLabel); // JPR
246 sizer0->Add(txtNrPoints);
252 if ( (mtype==0) || (mtype==3) )
254 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
255 sizer5->Add(txRadio);
256 sizer5->Add(sdrRadio,1,wxGROW );
257 sizer5->Add(txOpacity);
258 sizer5->Add(sdrOpacity,1,wxGROW );
263 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
264 sizer6->Add(btnSavePoints);
265 sizer6->Add(btnLoadPoints);
274 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
275 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
277 //NTU: Sliders for opacity and radio change
278 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
279 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
280 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
281 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
282 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
283 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
284 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
286 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
287 sizer1->Add(btnSetPositionPoint);
288 sizer1->Add(txtNrPoints);
289 sizer1->Add(txRadio);
290 sizer1->Add(sdrRadio,1,wxGROW );
291 sizer1->Add(txOpacity);
292 sizer1->Add(sdrOpacity,1,wxGROW );
298 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
299 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
300 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
301 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
302 textCtrl = new wxTextCtrl(panel, -1);
303 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
304 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
305 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
306 sizer1->Add(askPointLabel);
307 sizer1->Add(btnAddPoint);
308 sizer1->Add(btnDeleteAllPoints);
310 sizer1->Add(textCtrl);
311 // sdrOpacity = new wxSlider();
312 // sdrRadio = new wxSlider();
313 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
315 } // bbGetInputType 2
317 panel->SetSizer(sizer);
318 panel->SetAutoLayout(true);
320 bookSetPoints->AddPage(panel , _T("Points") );
322 if ((mtype >= 0) && (mtype <= 3) )
326 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
327 sizerParent->Add( bookSetPoints );
328 panelParent->SetSizer( sizerParent );
329 panelParent->SetAutoLayout(true);
330 panelParent->Layout();
332 } // if mtype 0 1 2 3
336 if ((sizer!=NULL) && (MNPsizer!=NULL))
338 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
339 sizerG->Add(bookGroupManager);
340 sizerG->Add(bookSetPoints);
341 panelParent->SetSizer(sizerG);
342 panelParent->SetAutoLayout(true);
343 panelParent->Layout();
348 //------------------------------------------------------------------------
349 WidgetShowNPoints::~WidgetShowNPoints()
353 //------------------------------------------------------------------------
354 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
357 // return mmodelShowNPoints;
358 return lstModelShowNPoints[ mActualCollection ];
361 //------------------------------------------------------------------------
362 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id)
364 if(id >= 0 && id < lstModelShowNPoints.size())
366 return lstModelShowNPoints[ id ];
371 //------------------------------------------------------------------------
372 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
374 return lstViewShowNPoints[ mActualCollection ];
378 //------------------------------------------------------------------------
379 void WidgetShowNPoints::SetRadio(double radio)
382 // GetModelShowNPoints()->SetRadio(radio);
383 int i,size = lstModelShowNPoints.size();
386 lstModelShowNPoints[i]->SetRadio( radio );
389 sdrRadio->SetValue(radio);
392 //------------------------------------------------------------------------
393 void WidgetShowNPoints::SetColour(std::vector<double> colour)
396 //this->mcolour = colour;
397 int i,size = lstViewShowNPoints.size();
398 for (i=0 ; i<size ; i++)
400 lstViewShowNPoints[i]->mcolour = colour;
404 //------------------------------------------------------------------------
405 void WidgetShowNPoints::SetImage(vtkImageData* image)
408 //GetModelShowNPoints()->SetImage(image);
409 int i,size = lstModelShowNPoints.size();
410 for (i=0 ; i<size ; i++)
412 lstModelShowNPoints[i]->SetImage(image);
416 //------------------------------------------------------------------------
417 void WidgetShowNPoints::SetOpacity(double opacity)
420 //this->mopacity=opacity;
421 int i,size = lstViewShowNPoints.size();
422 for (i=0 ; i<size ; i++)
424 lstViewShowNPoints[i]->mopacity = opacity;
427 sdrOpacity->SetValue( opacity*100.0 );
431 //------------------------------------------------------------------------
432 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
435 //this->renderer = renderer;
436 int i,size = lstViewShowNPoints.size();
437 for (i=0 ; i<size ; i++)
439 lstViewShowNPoints[i]->renderer = renderer;
444 //------------------------------------------------------------------------
446 void WidgetShowNPoints::RefreshPoint(int id)
450 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
451 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
452 std::string label = GetModelShowNPoints()->GetIdLabel(id);
453 double radio = GetModelShowNPoints()->GetRadio();
454 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
455 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
456 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
457 lstSourceSphere[id]->SetRadius( radio );
458 //EED 2017-01-01 Migration VTK7
459 #if VTK_MAJOR_VERSION <= 5
462 lstSourceSphere[id]->Update();
464 lstActorsText[id]->SetInput( label.c_str() );
465 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
468 //------------------------------------------------------------------------
469 void WidgetShowNPoints::RefreshPoints()
471 int id,size=lstActorsSphere.size();
472 for (id=0;id<size;id++)
476 renderer->GetRenderWindow()->Render();
479 //------------------------------------------------------------------------
480 void WidgetShowNPoints::AddVtkPoint()
483 vtkSphereSource *vtksphere = vtkSphereSource::New();
484 vtksphere->SetThetaResolution (20);
485 vtksphere->SetPhiResolution (20);
486 vtksphere->SetRadius( 1 );
487 //NTU: For updating points
488 lstSourceSphere.push_back(vtksphere);
489 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
491 //EED 2017-01-01 Migration VTK7
492 #if VTK_MAJOR_VERSION <= 5
493 sphereMapper->SetInput( vtksphere->GetOutput() );
496 sphereMapper->SetInputData( vtksphere->GetOutput() );
499 vtkActor *sphereActor = vtkActor::New();
500 sphereActor->SetMapper(sphereMapper);
501 sphereActor->SetOrigin(0, 0, 0);
503 lstActorsSphere.push_back(sphereActor);
505 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
509 renderer->AddActor( sphereActor );
511 vtkTextActor3D *textActor = vtkTextActor3D::New();
512 // textActor->SetInput( strLabel.c_str() );
513 renderer->AddActor( textActor );
514 lstActorsText.push_back(textActor);
519 //------------------------------------------------------------------------
520 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
522 printf("WidgetShowNPoints::AddPoint 0 model=%p\n", GetModelShowNPoints() );
523 GetModelShowNPoints()->AddPoint(x,y,z, label );
526 //RefreshPoint(lstActorsSphere.size()-1);
527 printf("WidgetShowNPoints::AddPoint 1 view=%p\n", GetViewShowNPoints() );
528 GetViewShowNPoints()->AddPoint();
529 printf("WidgetShowNPoints::AddPoint 2\n");
532 //------------------------------------------------------------------------
533 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
536 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
540 // AddPoint(x,y,z,label);
543 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
545 GetViewShowNPoints()->AddVtkPoint();
547 AddPoint(x,y,z,label);
549 GetViewShowNPoints()->RefreshPoints();
552 //------------------------------------------------------------------------
553 void WidgetShowNPoints::OnInsertPoint_()
556 //if (this->renderer==NULL)
560 if (GetViewShowNPoints()->renderer==NULL)
564 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
567 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
569 } else {//mpoint.size
570 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
572 UndoRedo_SaveCollection();
575 //------------------------------------------------------------------------
576 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
581 //------------------------------------------------------------------------
582 void WidgetShowNPoints::OnAddPoint__()
585 //if (this->renderer==NULL)
586 if (GetViewShowNPoints()->renderer==NULL)
590 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
593 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
596 //renderer->GetRenderWindow()->Render();
597 GetViewShowNPoints()->Render();
598 } else {//mpoint.size
599 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
601 UndoRedo_SaveCollection();
604 void WidgetShowNPoints::OnAddPoint_()
611 //------------------------------------------------------------------------
612 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
617 //------------------------------------------------------------------------
618 void WidgetShowNPoints::AutoAddPoints()
620 if ( cbAutoAddPoints->GetValue() == true )
623 } // if cbAutoAddPoints
626 //------------------------------------------------------------------------
627 void WidgetShowNPoints::OnAutoAddPoints_tool()
630 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
633 //------------------------------------------------------------------------
634 void WidgetShowNPoints::OnAutoAddPoints_()
637 printf("EED WidgetShowNPoints::OnAutoAddPoints_ \n");
640 //------------------------------------------------------------------------
641 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
644 printf("EED WidgetShowNPoints::OnAutoAddPoints \n");
647 //------------------------------------------------------------------------
648 void WidgetShowNPoints::StopAutoAddPoints( )
650 cbAutoAddPoints->SetValue(false);
653 //------------------------------------------------------------------------
654 void WidgetShowNPoints::SetOutputBox()
656 //EED renderer->GetRenderWindow()->Render();
658 strTmp.Printf(_T("Nbr pnts: %d"), GetModelShowNPoints()->GetLstPointsSize() );
659 txtNrPoints->SetLabel( strTmp );
663 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
664 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
665 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
666 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
667 // mbbShowNPoints->bbSignalOutputModification();
671 //------------------------------------------------------------------------
672 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
675 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
676 #if wxMAJOR_VERSION <= 2
677 wxFileDialog* FD = new wxFileDialog( 0,
678 _T("Save points .."),
682 wxSAVE | wxOVERWRITE_PROMPT,
685 wxFileDialog* FD = new wxFileDialog( 0,
686 _T("Save points .."),
690 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
694 int result_FD = FD->ShowModal();
695 // This line is need it by windows //EED
696 FD->SetReturnCode( result_FD );
697 if (FD->GetReturnCode()==wxID_OK)
699 std::string filename= (const char*) ( FD->GetPath().mb_str() );
700 GetModelShowNPoints()->SavePoints( filename );
705 //------------------------------------------------------------------------
706 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
709 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
710 #if wxMAJOR_VERSION <= 2
711 wxFileDialog* FD = new wxFileDialog( 0,
712 _T("Load points .."),
716 wxOPEN | wxFILE_MUST_EXIST,
719 wxFileDialog* FD = new wxFileDialog( 0,
720 _T("Load points .."),
724 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
729 int result_FD = FD->ShowModal();
730 // This line is need it by windows //EED
731 FD->SetReturnCode( result_FD );
732 if (FD->GetReturnCode()==wxID_OK)
735 std::string filename= (const char*) ( FD->GetPath().mb_str() );
736 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
737 for (i=0;i<numberPointsRead;i++)
741 GetViewShowNPoints()->AddVtkPoint();
746 GetViewShowNPoints()->RefreshPoints();
750 //------------------------------------------------------------------------
751 void WidgetShowNPoints::OnSetPoint_()
756 int id=GetModelShowNPoints()->GetNearestPoint();
757 if((id==-1) && (mtype==1))
765 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
768 //renderer->GetRenderWindow()->Render();
769 GetViewShowNPoints()->RefreshPoint(id);
770 GetViewShowNPoints()->Render();
773 UndoRedo_SaveCollection();
776 //------------------------------------------------------------------------
777 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
782 //------------------------------------------------------------------------
783 void WidgetShowNPoints::TrackingPoint( )
785 if ( cbTrackPoint->GetValue() == true )
787 int id = GetModelShowNPoints()->IdInsidePoint();
795 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
796 GetViewShowNPoints()->RefreshPoint(idTrack);
797 GetViewShowNPoints()->Render();
798 UndoRedo_SaveCollection();
800 } // if trackPointFlag
803 //------------------------------------------------------------------------
804 void WidgetShowNPoints::OnTrackPoint_tool()
806 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
810 //------------------------------------------------------------------------
811 void WidgetShowNPoints::OnTrackPoint_()
816 if ( cbTrackPoint->GetValue() == true )
818 idTrack = GetModelShowNPoints()->IdInsidePoint();
819 } // if trackPointFlag
822 //------------------------------------------------------------------------
823 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
825 printf("WidgetShowNPoints::OnTrackPoint \n");
829 //------------------------------------------------------------------------
830 void WidgetShowNPoints::StopTrackPoint( )
832 cbTrackPoint->SetValue(false);
836 //------------------------------------------------------------------------
837 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
839 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
843 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
844 //renderer->GetRenderWindow()->Render();
845 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
846 GetViewShowNPoints()->Render();
848 UndoRedo_SaveCollection();
852 //------------------------------------------------------------------------
853 void WidgetShowNPoints::ErasePoint(int id)
856 //if (this->renderer!=NULL)
857 if (GetViewShowNPoints()->renderer!=NULL)
862 //renderer->RemoveActor( lstActorsSphere[id] );
863 //renderer->RemoveActor( lstActorsText[id] );
864 //lstActorsSphere[id]->Delete();
865 //lstActorsText[id]->Delete();
866 //lstSourceSphere[id]->Delete();
867 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
868 //lstActorsText.erase( lstActorsText.begin()+id );
869 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
870 GetViewShowNPoints()->ErasePoint(id);
871 GetModelShowNPoints()->ErasePoint(id);
876 //------------------------------------------------------------------------
877 void WidgetShowNPoints::OnErasePoint_()
882 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
885 //renderer->GetRenderWindow()->Render();
886 GetViewShowNPoints()->Render();
888 UndoRedo_SaveCollection();
891 //------------------------------------------------------------------------
892 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
897 //------------------------------------------------------------------------
898 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
901 //ErasePoint( lstActorsSphere.size()-1 );
902 //renderer->GetRenderWindow()->Render();
906 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
908 UndoRedo_SaveCollection();
909 GetViewShowNPoints()->Render();
914 //------------------------------------------------------------------------
915 void WidgetShowNPoints::DeleteAllPoints_()
918 //int id,size=lstActorsSphere.size();
919 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
920 for (id=size-1;id>=0;id--)
926 void WidgetShowNPoints::OnDeleteAllPoints_()
932 UndoRedo_SaveCollection();
935 //------------------------------------------------------------------------
936 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
938 OnDeleteAllPoints_();
940 GetViewShowNPoints()->Render();
943 //NTU: Method for updating points opacity and Radio
945 //------------------------------------------------------------------------
946 void WidgetShowNPoints::UpdatePoints_()
949 //this->mopacity = sdrOpacity->GetValue()/100.0;
950 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
953 double opacity = sdrOpacity->GetValue()/100.0;
954 double radio = sdrRadio->GetValue();
955 int i,size = lstViewShowNPoints.size();
956 for (i=0 ; i<size ; i++)
958 lstViewShowNPoints[i]->mopacity = opacity;
959 lstModelShowNPoints[i]->SetRadio( radio ) ;
961 // GetViewShowNPoints()->RefreshPoints();
964 //------------------------------------------------------------------------
965 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
967 RefreshColourCollection();
970 //------------------------------------------------------------------------
971 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
973 GetModelShowNPoints()->SetReferencePoint(point);
974 int i,size=lstModelShowNPoints.size();
977 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
981 //------------------------------------------------------------------------
982 void WidgetShowNPoints::SetActualCollection( int actual )
989 if (actual>lstModelShowNPoints.size()-1 )
991 actual=lstModelShowNPoints.size()-1;
994 mActualCollection=actual;
998 //------------------------------------------------------------------------
999 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
1001 if (GetViewShowNPoints()->renderer==NULL)
1007 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1008 int ii,iIndexs,sizeIndexs;
1010 sizeX = (int)initLstPointsX.size();
1011 sizeY = (int)initLstPointsY.size();
1012 sizeZ = (int)initLstPointsZ.size();
1013 sizeLabels = (int)initLstLabels.size();
1014 sizeIndexs = (int)initLstIndexs.size();
1018 initLstIndexs.push_back(sizeX);
1019 sizeIndexs = (int)initLstIndexs.size();
1022 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1025 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1029 InsertCollectionAfter_();
1031 sizeTmp = initLstIndexs[iIndexs];
1032 for (ii=0;ii<sizeTmp;ii++)
1034 x = initLstPointsX[i];
1035 y = initLstPointsY[i];
1036 z = initLstPointsZ[i];
1039 label = initLstLabels[i];
1043 AddPoint( x,y,z,label );
1050 // renderer->GetRenderWindow()->Render();
1059 //if (this->renderer==NULL)
1060 if (GetViewShowNPoints()->renderer==NULL)
1064 int i,sizeX,sizeY,sizeZ,sizeLabels;
1065 sizeX = (int)initLstPointsX.size();
1066 sizeY = (int)initLstPointsY.size();
1067 sizeZ = (int)initLstPointsZ.size();
1068 sizeLabels = (int)initLstLabels.size();
1071 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1073 for (i=0;i<sizeX;i++)
1075 x = initLstPointsX[i];
1076 y = initLstPointsY[i];
1077 z = initLstPointsZ[i];
1080 label = initLstLabels[i];
1084 AddPoint( x,y,z,label );
1087 // renderer->GetRenderWindow()->Render();
1093 //------------------------------------------------------------------------
1094 void WidgetShowNPoints::SetType(int type)
1099 //------------------------------------------------------------------------
1100 int WidgetShowNPoints::GetType()
1106 //------------------------------------------------------------------------
1107 double WidgetShowNPoints::GetRadio()
1109 return sdrRadio->GetValue();
1111 //------------------------------------------------------------------------
1112 double WidgetShowNPoints::GetOpacity()
1114 return sdrOpacity->GetValue()/100;
1117 //------------------------------------------------------------------------
1118 void WidgetShowNPoints::InsertCollection()
1120 ModelShowNPoints* model = new ModelShowNPoints();
1121 ViewShowNPoints* view = new ViewShowNPoints( model );
1122 view->mopacity = lstViewShowNPoints[0]->mopacity;
1123 view->renderer = lstViewShowNPoints[0]->renderer;
1124 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1125 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1126 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1129 //------------------------------------------------------------------------
1130 void WidgetShowNPoints::InsertCollectionBefore_()
1133 RefreshCollectionText();
1134 RefreshColourCollection();
1138 //------------------------------------------------------------------------
1139 void WidgetShowNPoints::OnInsertCollectionBefore_()
1141 InsertCollectionBefore_();
1142 CreatePointsIntoNewCollection();
1143 UndoRedo_SaveCollection();
1147 //------------------------------------------------------------------------
1148 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1150 OnInsertCollectionBefore_();
1154 //------------------------------------------------------------------------
1155 void WidgetShowNPoints::InsertCollectionAfter_()
1157 mActualCollection++;
1159 RefreshCollectionText();
1160 RefreshColourCollection();
1165 //------------------------------------------------------------------------
1166 void WidgetShowNPoints::OnInsertCollectionAfter_()
1168 InsertCollectionAfter_();
1169 CreatePointsIntoNewCollection();
1170 UndoRedo_SaveCollection();
1173 //------------------------------------------------------------------------
1174 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1176 OnInsertCollectionAfter_();
1179 //------------------------------------------------------------------------
1180 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1182 // ---------------------------------------------
1183 printf("\nWidgetShowNPoints::InsertCollection mActualCollection=%d\n",mActualCollection);
1184 int c1 = mActualCollection-1;
1185 int c2 = mActualCollection+1;
1186 if (c2==lstModelShowNPoints.size()) { c2=0; }
1187 if ((c1>=0) && (c1!=c2) )
1189 std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1190 std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1191 std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1192 std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1193 std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1194 std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1195 std::vector<double> c1LstXX;
1196 std::vector<double> c1LstYY;
1197 std::vector<double> c1LstZZ;
1198 std::vector<double> c2LstXX;
1199 std::vector<double> c2LstYY;
1200 std::vector<double> c2LstZZ;
1201 creaContoursFactory f;
1202 manualContourModel *m;
1205 int sc; // sizeContour
1207 if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1209 // ----------------- Spline 1 --------------------
1211 size = c1LstX.size();
1212 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1213 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1214 m->SetNumberOfPointsSpline( sc );
1215 m->SetCloseContour( false );
1216 for (i=0;i<size;i++)
1218 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1223 m->GetSpline_i_Point(i,&x,&y,&z);
1224 c1LstXX.push_back(x);
1225 c1LstYY.push_back(y);
1226 c1LstZZ.push_back(z);
1229 // ----------------- Spline 2 --------------------
1230 size = c2LstX.size();
1231 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1232 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1233 m->SetNumberOfPointsSpline( sc );
1234 m->SetCloseContour( false );
1235 for (i=0;i<size;i++)
1237 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1242 m->GetSpline_i_Point(i,&x,&y,&z);
1243 c2LstXX.push_back(x);
1244 c2LstYY.push_back(y);
1245 c2LstZZ.push_back(z);
1248 // ----------------- Add new Points --------------------
1249 i=0; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1250 // i=33; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1251 // i=66; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1252 i=25; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1253 i=50; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1254 i=75; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1255 i=sc-1;x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1256 } // if size of c1LstX c2LstX
1263 //------------------------------------------------------------------------
1264 void WidgetShowNPoints::DeleteCollection_()
1266 if ( lstModelShowNPoints.size()>1 )
1268 DeleteAllPoints_(); // Actual Collection
1269 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1270 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1271 if ( mActualCollection>=lstModelShowNPoints.size() )
1273 mActualCollection--;
1276 DeleteAllPoints_(); // Actual Collection
1280 //------------------------------------------------------------------------
1281 void WidgetShowNPoints::OnDeleteCollection_()
1283 DeleteCollection_();
1285 GetViewShowNPoints()->Render();
1286 RefreshCollectionText();
1287 RefreshColourCollection();
1289 UndoRedo_SaveCollection();
1292 //------------------------------------------------------------------------
1293 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1295 OnDeleteCollection_();
1298 //------------------------------------------------------------------------
1299 void WidgetShowNPoints::ResetCollections_()
1301 int i,size=lstModelShowNPoints.size();
1302 for (i=0;i<size;i++)
1304 DeleteCollection_();
1306 GetViewShowNPoints()->Render();
1307 RefreshCollectionText();
1308 RefreshColourCollection();
1313 //------------------------------------------------------------------------
1314 void WidgetShowNPoints::OnResetCollections_()
1316 ResetCollections_();
1317 UndoRedo_SaveCollection();
1321 //------------------------------------------------------------------------
1322 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1324 OnResetCollections_();
1327 //------------------------------------------------------------------------
1328 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1330 mActualCollection--;
1331 if ( mActualCollection <0 )
1333 mActualCollection=0;
1335 RefreshCollectionText();
1336 RefreshColourCollection();
1338 UndoRedo_SaveCollection();
1341 //------------------------------------------------------------------------
1342 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1344 mActualCollection++;
1345 if ( mActualCollection >=lstModelShowNPoints.size() )
1347 mActualCollection = lstModelShowNPoints.size()-1;
1349 RefreshCollectionText();
1350 RefreshColourCollection();
1352 UndoRedo_SaveCollection();
1355 //------------------------------------------------------------------------
1356 void WidgetShowNPoints::DetectCollectionActive()
1359 int i,size=lstModelShowNPoints.size();
1360 for (i=0;i<size;i++)
1362 id = lstModelShowNPoints[i]->IdInsidePoint();
1365 mActualCollection=i;
1368 RefreshCollectionText();
1369 RefreshColourCollection();
1372 //------------------------------------------------------------------------
1373 void WidgetShowNPoints::RefreshColourCollection()
1376 std::vector<double> colourAll;
1377 colourAll.push_back(1);
1378 colourAll.push_back(0);
1379 colourAll.push_back(0);
1380 std::vector<double> colourActualGroup;
1381 colourActualGroup.push_back(1);
1382 colourActualGroup.push_back(1);
1383 colourActualGroup.push_back(0);
1385 // For all collections
1386 SetColour( colourAll );
1387 int i,size=lstViewShowNPoints.size();
1388 for (i=0;i<size;i++)
1390 lstViewShowNPoints[i] -> mcolour = colourAll;
1391 lstViewShowNPoints[i] -> ratioRadio = 1;
1392 lstViewShowNPoints[i]->RefreshEachPoint();
1395 // Actual collection
1396 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1397 lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.1;
1398 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1401 int curPnt = lstModelShowNPoints[mActualCollection] -> GetIdCurrentPoint();
1402 size=lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1403 if ((curPnt>=0) && (curPnt<size ) )
1405 std::vector<double> colourActualPoint;
1406 colourActualPoint.push_back(0);
1407 colourActualPoint.push_back(0);
1408 colourActualPoint.push_back(1);
1409 double radio = GetModelShowNPoints()->GetRadio();
1410 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1411 lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt );
1412 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1414 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1417 //------------------------------------------------------------------------
1418 void WidgetShowNPoints::RefreshCollectionText()
1420 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1423 strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1424 txtNrCollections->SetLabel( strTmp );
1430 //------------------------------------------------------------------------
1431 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1434 ff = fopen( filename.c_str() , "w+" );
1437 int i,size = lstModelShowNPoints.size();
1438 fprintf(ff,"NumberOfGroups %d \n",size);
1439 for (i=0 ; i<size ; i++)
1441 lstModelShowNPoints[i]->SavePoints_(ff);
1445 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1451 //------------------------------------------------------------------------
1452 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1454 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1455 #if wxMAJOR_VERSION <= 2
1456 wxFileDialog* FD = new wxFileDialog( 0,
1457 _T("Save groups of points .."),
1460 _T("(*.xls)|*.xls"),
1461 wxSAVE | wxOVERWRITE_PROMPT,
1464 wxFileDialog* FD = new wxFileDialog( 0,
1465 _T("Save groups of points .."),
1468 _T("(*.xls)|*.xls"),
1469 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1473 int result_FD = FD->ShowModal();
1474 // This line is need it by windows //EED
1475 FD->SetReturnCode( result_FD );
1476 if (FD->GetReturnCode()==wxID_OK)
1478 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1479 OnSaveCollections_( filename );
1484 //------------------------------------------------------------------------
1485 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1487 bool okEraseFirstGroup=false;
1488 if (lstModelShowNPoints.size()==1)
1490 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1492 FILE *ff = fopen( filename.c_str() , "r+" );
1496 int iGroup,sizeGroups;
1497 int iPoint,numberPointsRead;
1499 fscanf(ff," %s %d",chartmp,&sizeGroups);
1500 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1502 mActualCollection = lstModelShowNPoints.size();
1504 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1505 for (i=0;i<numberPointsRead;i++)
1509 GetViewShowNPoints()->AddVtkPoint();
1515 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1517 if (okEraseFirstGroup==true)
1519 mActualCollection=0;
1520 DeleteCollection_();
1521 mActualCollection = lstModelShowNPoints.size()-1;
1523 GetViewShowNPoints()->Render();
1524 RefreshCollectionText();
1525 RefreshColourCollection();
1529 //------------------------------------------------------------------------
1530 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1532 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1533 #if wxMAJOR_VERSION <= 2
1534 wxFileDialog* FD = new wxFileDialog( 0,
1535 _T("Load groups of points .."),
1538 _T("(*.xls)|*.xls"),
1539 wxOPEN | wxFILE_MUST_EXIST,
1542 wxFileDialog* FD = new wxFileDialog( 0,
1543 _T("Load groups of points .."),
1546 _T("(*.xls)|*.xls"),
1547 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1550 int result_FD = FD->ShowModal();
1551 // This line is need it by windows //EED
1552 FD->SetReturnCode( result_FD );
1553 if (FD->GetReturnCode()==wxID_OK)
1555 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1556 OnLoadCollections_( filename );
1557 UndoRedo_SaveCollection();
1561 //------------------------------------------------------------------------
1562 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1565 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1570 //------------------------------------------------------------------------
1571 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1573 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1575 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1576 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1579 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1582 //------------------------------------------------------------------------
1583 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1587 return GetModelShowNPoints()->GetLstPointsX();
1589 std::vector<double> lst;
1591 int iG,sG=lstModelShowNPoints.size();
1592 for (iG=0 ; iG<sG ; iG++)
1594 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1596 for (iP=0 ; iP<s ; iP++)
1598 lst.push_back( lstTmp[iP] );
1605 //------------------------------------------------------------------------
1606 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1610 return GetModelShowNPoints()->GetLstPointsY();
1612 std::vector<double> lst;
1614 int iG,sG=lstModelShowNPoints.size();
1615 for (iG=0 ; iG<sG ; iG++)
1617 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1619 for (iP=0 ; iP<s ; iP++)
1621 lst.push_back( lstTmp[iP] );
1628 //------------------------------------------------------------------------
1629 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1633 return GetModelShowNPoints()->GetLstPointsZ();
1635 std::vector<double> lst;
1637 int iG,sG=lstModelShowNPoints.size();
1638 for (iG=0 ; iG<sG ; iG++)
1640 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1642 for (iP=0 ; iP<s ; iP++)
1644 lst.push_back( lstTmp[iP] );
1652 //------------------------------------------------------------------------
1653 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1657 return GetModelShowNPoints()->GetLstLabels();
1659 std::vector< std::string > lst;
1661 int iG,sG=lstModelShowNPoints.size();
1662 for (iG=0 ; iG<sG ; iG++)
1664 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1666 for (iP=0 ; iP<s ; iP++)
1668 lst.push_back( lstTmp[iP] );
1675 //------------------------------------------------------------------------
1676 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1678 std::vector<int> lstIndexs;
1681 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1683 int iG,sG=lstModelShowNPoints.size();
1684 for (iG=0 ; iG<sG ; iG++)
1686 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1691 //------------------------------------------------------------------------
1692 int WidgetShowNPoints::GetLstModelShowNPointsSize()
1694 return lstModelShowNPoints.size();
1697 //------------------------------------------------------------------------
1698 void WidgetShowNPoints::InvertLstPoints_()
1700 int i,size=lstModelShowNPoints.size();
1702 for (i=0 ; i < size ; i++)
1704 lstModelShowNPoints[i]->InversLstPoints();
1708 ModelShowNPoints* tmpModel;
1710 for (i=0 ; i < size2 ; i++)
1712 tmpModel = lstModelShowNPoints[i];
1713 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
1714 lstModelShowNPoints[size-1-i] = tmpModel;
1719 //------------------------------------------------------------------------
1720 void WidgetShowNPoints::OnInvertLstPoints_()
1722 StopAutoAddPoints();
1727 UndoRedo_SaveCollection();
1731 //------------------------------------------------------------------------
1732 std::string WidgetShowNPoints::GetUndoRedoFileName()
1735 sprintf(buff,"%p_%d",this, idUndoRedo);
1736 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
1740 //------------------------------------------------------------------------
1741 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
1743 ResetCollections_();
1744 // if (idUndoRedo==maxUndoRedo+1)
1747 // } // if idUndoRedo+1
1754 OnLoadCollections_( GetUndoRedoFileName() );
1760 //------------------------------------------------------------------------
1761 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
1763 if (idUndoRedo>maxUndoRedo)
1765 idUndoRedo=maxUndoRedo+1;
1767 ResetCollections_();
1768 OnLoadCollections_( GetUndoRedoFileName() );
1773 //------------------------------------------------------------------------
1774 void WidgetShowNPoints::UndoRedo_SaveCollection()
1776 OnSaveCollections_( GetUndoRedoFileName() );
1777 maxUndoRedo = idUndoRedo;