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 //----------------------------------------------------------------------
15 //----------------------------------------------------------------------
16 //----------------------------------------------------------------------
17 //----------------------------------------------------------------------
18 //----------------------------------------------------------------------
19 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
20 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
23 // mmodelShowNPoints = new ModelShowNPoints();
27 char * val = getenv( "TEMP" );
30 UndoRedoDir = std::string("");
32 UndoRedoDir = std::string(val)+"\\creatools";
33 printf("WidgetShowNPoints::WidgetShowNPoints UndoRedoDir = %s %p \n", UndoRedoDir.c_str() , this );
34 std::string cmd1 = "mkdir "+ UndoRedoDir;
35 system( cmd1.c_str() );
36 // Erasing files of more than 1 day old ( -1 )
37 std::string cmd2 = "ForFiles /p \"" + UndoRedoDir + "\" /s /d -1 /c \"cmd /c del @file \"";
38 system( cmd2.c_str() );
40 #elif defined(__GNUC__)
44 UndoRedoDir = "/tmp/creatools";
46 UndoRedoDir = "/tmp/creatools";
49 printf("WidgetShowNPoints::WidgetShowNPoints UndoRedoDir = %s %p \n", UndoRedoDir.c_str() , this );
50 std::string cmd1 = "mkdir "+ UndoRedoDir;
51 system( cmd1.c_str() );
52 // Erasing files of more than 1 day old ( +1 )
53 std::string cmd= "find "+UndoRedoDir+" -name \"UndoRedo_collection_*.undoredo\" -type f -mtime +1 -delete";
54 system( cmd.c_str() );
61 mActualCollection = 0;
62 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
63 lstModelShowNPoints.push_back( modelShowNPoints );
64 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
68 wxPanel* panelParent = this;
69 wxSizer* sizer = NULL;
70 wxSizer* MNPsizer = NULL;
71 wxNotebook* bookSetPoints = NULL;
72 wxNotebook* bookGroupManager = NULL;
73 wxPanel* panel = NULL;
74 wxPanel* panel2 = NULL;
75 txtNrCollections = NULL;
76 bookSetPoints = new wxNotebook(panelParent,
81 panel = new wxPanel(bookSetPoints);
82 txtNrCollections = NULL;
85 sizeButton.Set( 45 , -1 );
87 sizeSlider.Set( 90 , -1 );
92 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
97 panel2 = new wxPanel(bookGroupManager);
98 txtNrCollections = new wxStaticText(panel2,-1, _T("1 / 1 "));
99 wxButton *btnBackCollection = new wxButton( panel2, -1, _T("<") , wxDefaultPosition, sizeButton );
100 wxButton *btnNextCollection = new wxButton( panel2, -1, _T(">") , wxDefaultPosition, sizeButton );
101 wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("+<") , wxDefaultPosition, sizeButton );
102 wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("+>") , wxDefaultPosition, sizeButton );
103 wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("-") , wxDefaultPosition, sizeButton );
104 wxButton *btnResetCollection = new wxButton( panel2, -1, _T("--") , wxDefaultPosition, sizeButton );
105 wxButton *btnSaveCollection = new wxButton( panel2, -1, _T("Save") , wxDefaultPosition, sizeButton );
106 wxButton *btnLoadCollection = new wxButton( panel2, -1, _T("Load") , wxDefaultPosition, sizeButton );
107 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
108 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
109 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(3);
110 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
111 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
112 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
113 // wxStaticText* txOpacity = new wxStaticText(panel2, -1, wxString(_T("Op:")));
115 btnInsertCollectionBefore -> SetToolTip( _T("+ Add group before") );
116 btnInsertCollectionAfter -> SetToolTip( _T("+> Add group after") );
117 btnDeleteCollection -> SetToolTip( _T("- Erase group") );
118 btnResetCollection -> SetToolTip( _T("-- Reset : Erase all groups") );
120 sdrOpacity = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, sizeSlider, wxSL_LABELS);
121 // wxStaticText* txRadio = new wxStaticText(panel2, -1, wxString(_T("R:")));
122 sdrRadio = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, sizeSlider, wxSL_LABELS);
124 sdrRadio -> SetToolTip( _T("Radio") );
125 sdrOpacity -> SetToolTip( _T("Opacity") );
127 Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection );
128 Connect(btnNextCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection );
129 Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore );
130 Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter );
131 Connect(btnDeleteCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection );
132 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints );
133 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints );
134 Connect(btnSaveCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections );
135 Connect(btnLoadCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections );
136 Connect(btnResetCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnResetCollections );
138 sizer2->Add( btnBackCollection );
139 sizer2->Add( btnNextCollection );
140 sizer3->Add( btnInsertCollectionBefore );
141 sizer3->Add( btnInsertCollectionAfter );
142 sizer4->Add( btnLoadCollection );
143 sizer4->Add( btnSaveCollection );
144 // sizer5->Add( txRadio ,wxGROW );
145 sizer5->Add( sdrRadio ,wxGROW );
146 // sizer5->Add( txOpacity ,wxGROW );
147 sizer5->Add( sdrOpacity ,wxGROW );
148 sizer6->Add( btnDeleteCollection );
149 sizer6->Add( btnResetCollection );
151 sizer1->Add( txtNrCollections );
152 sizer1->Add( sizer2 );
153 sizer1->Add( sizer3 );
154 sizer1->Add( sizer6 );
155 sizer1->Add( sizer4 );
156 sizer1->Add( sizer5 ,wxGROW );
159 panel2->SetSizer( MNPsizer );
160 panel2->SetAutoLayout(true);
162 bookGroupManager->AddPage(panel2 , _T("Groups") );
165 if ( (mtype==0) || (mtype==3) || (mtype==4) )
168 // askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR
169 textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton);
170 cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton );
171 wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton );
172 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );//CFT
173 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton );
174 cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton );
175 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton );
176 wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
177 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
178 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
179 wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
180 wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
181 wxButton *btnSavePoints = NULL;
182 wxButton *btnLoadPoints = NULL;
184 cbAutoAddPoints -> SetToolTip( _T("Auto Add point") );
185 btnAddPoint -> SetToolTip( _T("+ Add point") );
186 btnInsertPoint -> SetToolTip( _T("(-) Insert point") );
187 btnErasePoint -> SetToolTip( _T("- Erase point") );
188 btnEraseLastPoint -> SetToolTip( _T("- lst Erase last point") );
189 btnDeleteAllPoints -> SetToolTip( _T("-- Erase all points") );
193 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
194 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
195 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
196 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
198 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
200 wxStaticText* txOpacity;
201 wxStaticText* txRadio;
202 if ( (mtype==0) || (mtype==3) )
204 //NTU: Sliders for opacity and radio change
205 txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
206 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
207 txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
208 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
210 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
211 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
213 Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints);
214 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
215 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
216 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
217 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
218 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
219 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
220 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
221 Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
222 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
223 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
224 wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
225 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
226 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
227 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
228 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(2);
229 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
230 sizer1->Add( textCtrl );
231 sizer1->Add( btnRenamePoint );
232 sizer2->Add( cbAutoAddPoints );
233 sizer2->Add( new wxStaticText(panel, -1, _T(" ")) );
234 sizer2->Add( btnAddPoint );
235 sizer2->Add( btnInsertPoint );//CFT
236 sizer3->Add( btnSetPositionPoint );
237 sizer3->Add( cbTrackPoint );
238 sizer4->Add( btnErasePoint );
239 sizer4->Add( btnEraseLastPoint );
240 sizer4->Add( btnDeleteAllPoints );
241 sizer5->Add( btnUndo );
242 sizer5->Add( btnRedo );
243 // sizer0->Add(askPointLabel); // JPR
244 sizer0->Add(txtNrPoints);
250 if ( (mtype==0) || (mtype==3) )
252 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
253 sizer5->Add(txRadio);
254 sizer5->Add(sdrRadio,1,wxGROW );
255 sizer5->Add(txOpacity);
256 sizer5->Add(sdrOpacity,1,wxGROW );
261 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
262 sizer6->Add(btnSavePoints);
263 sizer6->Add(btnLoadPoints);
272 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
273 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
275 //NTU: Sliders for opacity and radio change
276 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
277 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
278 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
279 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
280 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
281 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
282 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
284 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
285 sizer1->Add(btnSetPositionPoint);
286 sizer1->Add(txtNrPoints);
287 sizer1->Add(txRadio);
288 sizer1->Add(sdrRadio,1,wxGROW );
289 sizer1->Add(txOpacity);
290 sizer1->Add(sdrOpacity,1,wxGROW );
296 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
297 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
298 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
299 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
300 textCtrl = new wxTextCtrl(panel, -1);
301 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
302 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
303 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
304 sizer1->Add(askPointLabel);
305 sizer1->Add(btnAddPoint);
306 sizer1->Add(btnDeleteAllPoints);
308 sizer1->Add(textCtrl);
309 // sdrOpacity = new wxSlider();
310 // sdrRadio = new wxSlider();
311 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
313 } // bbGetInputType 2
315 panel->SetSizer(sizer);
316 panel->SetAutoLayout(true);
318 bookSetPoints->AddPage(panel , _T("Points") );
320 if ((mtype >= 0) && (mtype <= 3) )
324 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
325 sizerParent->Add( bookSetPoints );
326 panelParent->SetSizer( sizerParent );
327 panelParent->SetAutoLayout(true);
328 panelParent->Layout();
330 } // if mtype 0 1 2 3
334 if ((sizer!=NULL) && (MNPsizer!=NULL))
336 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
337 sizerG->Add(bookGroupManager);
338 sizerG->Add(bookSetPoints);
339 panelParent->SetSizer(sizerG);
340 panelParent->SetAutoLayout(true);
341 panelParent->Layout();
346 //------------------------------------------------------------------------
347 WidgetShowNPoints::~WidgetShowNPoints()
351 //------------------------------------------------------------------------
352 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
355 // return mmodelShowNPoints;
356 return lstModelShowNPoints[ mActualCollection ];
360 //------------------------------------------------------------------------
361 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
363 return lstViewShowNPoints[ mActualCollection ];
367 //------------------------------------------------------------------------
368 void WidgetShowNPoints::SetRadio(double radio)
371 // GetModelShowNPoints()->SetRadio(radio);
372 int i,size = lstModelShowNPoints.size();
375 lstModelShowNPoints[i]->SetRadio( radio );
378 sdrRadio->SetValue(radio);
381 //------------------------------------------------------------------------
382 void WidgetShowNPoints::SetColour(std::vector<double> colour)
385 //this->mcolour = colour;
386 int i,size = lstViewShowNPoints.size();
387 for (i=0 ; i<size ; i++)
389 lstViewShowNPoints[i]->mcolour = colour;
393 //------------------------------------------------------------------------
394 void WidgetShowNPoints::SetImage(vtkImageData* image)
397 //GetModelShowNPoints()->SetImage(image);
398 int i,size = lstModelShowNPoints.size();
399 for (i=0 ; i<size ; i++)
401 lstModelShowNPoints[i]->SetImage(image);
405 //------------------------------------------------------------------------
406 void WidgetShowNPoints::SetOpacity(double opacity)
409 //this->mopacity=opacity;
410 int i,size = lstViewShowNPoints.size();
411 for (i=0 ; i<size ; i++)
413 lstViewShowNPoints[i]->mopacity = opacity;
416 sdrOpacity->SetValue( opacity*100.0 );
420 //------------------------------------------------------------------------
421 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
424 //this->renderer = renderer;
425 int i,size = lstViewShowNPoints.size();
426 for (i=0 ; i<size ; i++)
428 lstViewShowNPoints[i]->renderer = renderer;
433 //------------------------------------------------------------------------
435 void WidgetShowNPoints::RefreshPoint(int id)
439 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
440 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
441 std::string label = GetModelShowNPoints()->GetIdLabel(id);
442 double radio = GetModelShowNPoints()->GetRadio();
443 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
444 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
445 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
446 lstSourceSphere[id]->SetRadius( radio );
447 //EED 2017-01-01 Migration VTK7
448 #if VTK_MAJOR_VERSION <= 5
451 lstSourceSphere[id]->Update();
453 lstActorsText[id]->SetInput( label.c_str() );
454 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
457 //------------------------------------------------------------------------
458 void WidgetShowNPoints::RefreshPoints()
460 int id,size=lstActorsSphere.size();
461 for (id=0;id<size;id++)
465 renderer->GetRenderWindow()->Render();
468 //------------------------------------------------------------------------
469 void WidgetShowNPoints::AddVtkPoint()
472 vtkSphereSource *vtksphere = vtkSphereSource::New();
473 vtksphere->SetThetaResolution (20);
474 vtksphere->SetPhiResolution (20);
475 vtksphere->SetRadius( 1 );
476 //NTU: For updating points
477 lstSourceSphere.push_back(vtksphere);
478 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
480 //EED 2017-01-01 Migration VTK7
481 #if VTK_MAJOR_VERSION <= 5
482 sphereMapper->SetInput( vtksphere->GetOutput() );
485 sphereMapper->SetInputData( vtksphere->GetOutput() );
488 vtkActor *sphereActor = vtkActor::New();
489 sphereActor->SetMapper(sphereMapper);
490 sphereActor->SetOrigin(0, 0, 0);
492 lstActorsSphere.push_back(sphereActor);
494 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
498 renderer->AddActor( sphereActor );
500 vtkTextActor3D *textActor = vtkTextActor3D::New();
501 // textActor->SetInput( strLabel.c_str() );
502 renderer->AddActor( textActor );
503 lstActorsText.push_back(textActor);
508 //------------------------------------------------------------------------
509 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
511 GetModelShowNPoints()->AddPoint(x,y,z, label );
514 //RefreshPoint(lstActorsSphere.size()-1);
515 GetViewShowNPoints()->AddPoint();
518 //------------------------------------------------------------------------
519 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
522 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
526 // AddPoint(x,y,z,label);
529 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
531 GetViewShowNPoints()->AddVtkPoint();
533 AddPoint(x,y,z,label);
535 GetViewShowNPoints()->RefreshPoints();
538 //------------------------------------------------------------------------
539 void WidgetShowNPoints::OnInsertPoint_()
542 //if (this->renderer==NULL)
546 if (GetViewShowNPoints()->renderer==NULL)
550 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
553 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
555 } else {//mpoint.size
556 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
558 UndoRedo_SaveCollection();
561 //------------------------------------------------------------------------
562 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
567 //------------------------------------------------------------------------
568 void WidgetShowNPoints::OnAddPoint__()
571 //if (this->renderer==NULL)
572 if (GetViewShowNPoints()->renderer==NULL)
576 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
579 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
582 //renderer->GetRenderWindow()->Render();
583 GetViewShowNPoints()->Render();
584 } else {//mpoint.size
585 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
587 UndoRedo_SaveCollection();
590 void WidgetShowNPoints::OnAddPoint_()
597 //------------------------------------------------------------------------
598 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
603 //------------------------------------------------------------------------
604 void WidgetShowNPoints::AutoAddPoints()
606 if ( cbAutoAddPoints->GetValue() == true )
609 } // if cbAutoAddPoints
612 //------------------------------------------------------------------------
613 void WidgetShowNPoints::OnAutoAddPoints_tool()
616 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
619 //------------------------------------------------------------------------
620 void WidgetShowNPoints::OnAutoAddPoints_()
623 printf("EED WidgetShowNPoints::OnAutoAddPoints_ \n");
626 //------------------------------------------------------------------------
627 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
630 printf("EED WidgetShowNPoints::OnAutoAddPoints \n");
633 //------------------------------------------------------------------------
634 void WidgetShowNPoints::StopAutoAddPoints( )
636 cbAutoAddPoints->SetValue(false);
639 //------------------------------------------------------------------------
640 void WidgetShowNPoints::SetOutputBox()
642 //EED renderer->GetRenderWindow()->Render();
644 strTmp.Printf(_T("Nbr pnts: %d"), GetModelShowNPoints()->GetLstPointsSize() );
645 txtNrPoints->SetLabel( strTmp );
649 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
650 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
651 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
652 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
653 // mbbShowNPoints->bbSignalOutputModification();
657 //------------------------------------------------------------------------
658 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
661 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
662 #if wxMAJOR_VERSION <= 2
663 wxFileDialog* FD = new wxFileDialog( 0,
664 _T("Save points .."),
668 wxSAVE | wxOVERWRITE_PROMPT,
671 wxFileDialog* FD = new wxFileDialog( 0,
672 _T("Save points .."),
676 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
680 int result_FD = FD->ShowModal();
681 // This line is need it by windows //EED
682 FD->SetReturnCode( result_FD );
683 if (FD->GetReturnCode()==wxID_OK)
685 std::string filename= (const char*) ( FD->GetPath().mb_str() );
686 GetModelShowNPoints()->SavePoints( filename );
691 //------------------------------------------------------------------------
692 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
695 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
696 #if wxMAJOR_VERSION <= 2
697 wxFileDialog* FD = new wxFileDialog( 0,
698 _T("Load points .."),
702 wxOPEN | wxFILE_MUST_EXIST,
705 wxFileDialog* FD = new wxFileDialog( 0,
706 _T("Load points .."),
710 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
715 int result_FD = FD->ShowModal();
716 // This line is need it by windows //EED
717 FD->SetReturnCode( result_FD );
718 if (FD->GetReturnCode()==wxID_OK)
721 std::string filename= (const char*) ( FD->GetPath().mb_str() );
722 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
723 for (i=0;i<numberPointsRead;i++)
727 GetViewShowNPoints()->AddVtkPoint();
732 GetViewShowNPoints()->RefreshPoints();
736 //------------------------------------------------------------------------
737 void WidgetShowNPoints::OnSetPoint_()
742 int id=GetModelShowNPoints()->GetNearestPoint();
743 if((id==-1) && (mtype==1))
751 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
754 //renderer->GetRenderWindow()->Render();
755 GetViewShowNPoints()->RefreshPoint(id);
756 GetViewShowNPoints()->Render();
759 UndoRedo_SaveCollection();
762 //------------------------------------------------------------------------
763 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
768 //------------------------------------------------------------------------
769 void WidgetShowNPoints::TrackingPoint( )
771 if ( cbTrackPoint->GetValue() == true )
773 int id = GetModelShowNPoints()->IdInsidePoint();
781 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
782 GetViewShowNPoints()->RefreshPoint(idTrack);
783 GetViewShowNPoints()->Render();
784 UndoRedo_SaveCollection();
786 } // if trackPointFlag
789 //------------------------------------------------------------------------
790 void WidgetShowNPoints::OnTrackPoint_tool()
792 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
796 //------------------------------------------------------------------------
797 void WidgetShowNPoints::OnTrackPoint_()
802 if ( cbTrackPoint->GetValue() == true )
804 idTrack = GetModelShowNPoints()->IdInsidePoint();
805 } // if trackPointFlag
808 //------------------------------------------------------------------------
809 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
811 printf("WidgetShowNPoints::OnTrackPoint \n");
815 //------------------------------------------------------------------------
816 void WidgetShowNPoints::StopTrackPoint( )
818 cbTrackPoint->SetValue(false);
822 //------------------------------------------------------------------------
823 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
825 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
829 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
830 //renderer->GetRenderWindow()->Render();
831 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
832 GetViewShowNPoints()->Render();
834 UndoRedo_SaveCollection();
838 //------------------------------------------------------------------------
839 void WidgetShowNPoints::ErasePoint(int id)
842 //if (this->renderer!=NULL)
843 if (GetViewShowNPoints()->renderer!=NULL)
848 //renderer->RemoveActor( lstActorsSphere[id] );
849 //renderer->RemoveActor( lstActorsText[id] );
850 //lstActorsSphere[id]->Delete();
851 //lstActorsText[id]->Delete();
852 //lstSourceSphere[id]->Delete();
853 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
854 //lstActorsText.erase( lstActorsText.begin()+id );
855 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
856 GetViewShowNPoints()->ErasePoint(id);
857 GetModelShowNPoints()->ErasePoint(id);
862 //------------------------------------------------------------------------
863 void WidgetShowNPoints::OnErasePoint_()
868 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
871 //renderer->GetRenderWindow()->Render();
872 GetViewShowNPoints()->Render();
874 UndoRedo_SaveCollection();
877 //------------------------------------------------------------------------
878 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
883 //------------------------------------------------------------------------
884 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
887 //ErasePoint( lstActorsSphere.size()-1 );
888 //renderer->GetRenderWindow()->Render();
892 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
894 UndoRedo_SaveCollection();
895 GetViewShowNPoints()->Render();
900 //------------------------------------------------------------------------
901 void WidgetShowNPoints::DeleteAllPoints_()
904 //int id,size=lstActorsSphere.size();
905 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
906 for (id=size-1;id>=0;id--)
912 void WidgetShowNPoints::OnDeleteAllPoints_()
918 UndoRedo_SaveCollection();
921 //------------------------------------------------------------------------
922 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
924 OnDeleteAllPoints_();
926 GetViewShowNPoints()->Render();
929 //NTU: Method for updating points opacity and Radio
931 //------------------------------------------------------------------------
932 void WidgetShowNPoints::UpdatePoints_()
935 //this->mopacity = sdrOpacity->GetValue()/100.0;
936 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
939 double opacity = sdrOpacity->GetValue()/100.0;
940 double radio = sdrRadio->GetValue();
941 int i,size = lstViewShowNPoints.size();
942 for (i=0 ; i<size ; i++)
944 lstViewShowNPoints[i]->mopacity = opacity;
945 lstModelShowNPoints[i]->SetRadio( radio ) ;
947 // GetViewShowNPoints()->RefreshPoints();
950 //------------------------------------------------------------------------
951 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
953 RefreshColourCollection();
956 //------------------------------------------------------------------------
957 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
959 GetModelShowNPoints()->SetReferencePoint(point);
960 int i,size=lstModelShowNPoints.size();
963 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
967 //------------------------------------------------------------------------
968 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
970 if (GetViewShowNPoints()->renderer==NULL)
976 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
977 int ii,iIndexs,sizeIndexs;
979 sizeX = (int)initLstPointsX.size();
980 sizeY = (int)initLstPointsY.size();
981 sizeZ = (int)initLstPointsZ.size();
982 sizeLabels = (int)initLstLabels.size();
983 sizeIndexs = (int)initLstIndexs.size();
987 initLstIndexs.push_back(sizeX);
988 sizeIndexs = (int)initLstIndexs.size();
991 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
994 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
998 InsertCollectionAfter_();
1000 sizeTmp = initLstIndexs[iIndexs];
1001 for (ii=0;ii<sizeTmp;ii++)
1003 x = initLstPointsX[i];
1004 y = initLstPointsY[i];
1005 z = initLstPointsZ[i];
1008 label = initLstLabels[i];
1012 AddPoint( x,y,z,label );
1019 // renderer->GetRenderWindow()->Render();
1028 //if (this->renderer==NULL)
1029 if (GetViewShowNPoints()->renderer==NULL)
1033 int i,sizeX,sizeY,sizeZ,sizeLabels;
1034 sizeX = (int)initLstPointsX.size();
1035 sizeY = (int)initLstPointsY.size();
1036 sizeZ = (int)initLstPointsZ.size();
1037 sizeLabels = (int)initLstLabels.size();
1040 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1042 for (i=0;i<sizeX;i++)
1044 x = initLstPointsX[i];
1045 y = initLstPointsY[i];
1046 z = initLstPointsZ[i];
1049 label = initLstLabels[i];
1053 AddPoint( x,y,z,label );
1056 // renderer->GetRenderWindow()->Render();
1062 //------------------------------------------------------------------------
1063 void WidgetShowNPoints::SetType(int type)
1068 //------------------------------------------------------------------------
1069 int WidgetShowNPoints::GetType()
1075 //------------------------------------------------------------------------
1076 double WidgetShowNPoints::GetRadio()
1078 return sdrRadio->GetValue();
1080 //------------------------------------------------------------------------
1081 double WidgetShowNPoints::GetOpacity()
1083 return sdrOpacity->GetValue()/100;
1086 //------------------------------------------------------------------------
1087 void WidgetShowNPoints::InsertCollection()
1089 ModelShowNPoints* model = new ModelShowNPoints();
1090 ViewShowNPoints* view = new ViewShowNPoints( model );
1091 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1092 view->mopacity = lstViewShowNPoints[0]->mopacity;
1093 view->renderer = lstViewShowNPoints[0]->renderer;
1094 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1095 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1098 //------------------------------------------------------------------------
1099 void WidgetShowNPoints::InsertCollectionBefore_()
1102 RefreshCollectionText();
1103 RefreshColourCollection();
1107 //------------------------------------------------------------------------
1108 void WidgetShowNPoints::OnInsertCollectionBefore_()
1110 InsertCollectionBefore_();
1111 UndoRedo_SaveCollection();
1115 //------------------------------------------------------------------------
1116 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1118 OnInsertCollectionBefore_();
1122 //------------------------------------------------------------------------
1123 void WidgetShowNPoints::InsertCollectionAfter_()
1125 mActualCollection++;
1127 RefreshCollectionText();
1128 RefreshColourCollection();
1132 //------------------------------------------------------------------------
1133 void WidgetShowNPoints::OnInsertCollectionAfter_()
1135 InsertCollectionAfter_();
1136 UndoRedo_SaveCollection();
1139 //------------------------------------------------------------------------
1140 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1142 OnInsertCollectionAfter_();
1145 //------------------------------------------------------------------------
1146 void WidgetShowNPoints::DeleteCollection_()
1148 if ( lstModelShowNPoints.size()>1 )
1150 DeleteAllPoints_(); // Actual Collection
1151 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1152 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1153 if ( mActualCollection>=lstModelShowNPoints.size() )
1155 mActualCollection--;
1158 DeleteAllPoints_(); // Actual Collection
1162 //------------------------------------------------------------------------
1163 void WidgetShowNPoints::OnDeleteCollection_()
1165 DeleteCollection_();
1167 GetViewShowNPoints()->Render();
1168 RefreshCollectionText();
1169 RefreshColourCollection();
1171 UndoRedo_SaveCollection();
1174 //------------------------------------------------------------------------
1175 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1177 OnDeleteCollection_();
1180 //------------------------------------------------------------------------
1181 void WidgetShowNPoints::ResetCollections_()
1183 int i,size=lstModelShowNPoints.size();
1184 for (i=0;i<size;i++)
1186 DeleteCollection_();
1188 GetViewShowNPoints()->Render();
1189 RefreshCollectionText();
1190 RefreshColourCollection();
1195 //------------------------------------------------------------------------
1196 void WidgetShowNPoints::OnResetCollections_()
1198 ResetCollections_();
1199 UndoRedo_SaveCollection();
1203 //------------------------------------------------------------------------
1204 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1206 OnResetCollections_();
1209 //------------------------------------------------------------------------
1210 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1212 mActualCollection--;
1213 if ( mActualCollection <0 )
1215 mActualCollection=0;
1217 RefreshCollectionText();
1218 RefreshColourCollection();
1220 UndoRedo_SaveCollection();
1223 //------------------------------------------------------------------------
1224 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1226 mActualCollection++;
1227 if ( mActualCollection >=lstModelShowNPoints.size() )
1229 mActualCollection = lstModelShowNPoints.size()-1;
1231 RefreshCollectionText();
1232 RefreshColourCollection();
1234 UndoRedo_SaveCollection();
1237 //------------------------------------------------------------------------
1238 void WidgetShowNPoints::DetectCollectionActive()
1241 int i,size=lstModelShowNPoints.size();
1242 for (i=0;i<size;i++)
1244 id = lstModelShowNPoints[i]->IdInsidePoint();
1247 mActualCollection=i;
1250 RefreshCollectionText();
1251 RefreshColourCollection();
1254 //------------------------------------------------------------------------
1255 void WidgetShowNPoints::RefreshColourCollection()
1258 std::vector<double> colourAll;
1259 colourAll.push_back(1);
1260 colourAll.push_back(0);
1261 colourAll.push_back(0);
1262 std::vector<double> colourActual;
1263 colourActual.push_back(1);
1264 colourActual.push_back(1);
1265 colourActual.push_back(0);
1266 SetColour( colourAll ); // For all collections
1267 int i,size=lstViewShowNPoints.size();
1268 for (i=0;i<size;i++)
1270 lstViewShowNPoints[i] -> mcolour = colourAll; // All collection
1271 lstViewShowNPoints[i]->RefreshEachPoint();
1273 lstViewShowNPoints[mActualCollection] -> mcolour = colourActual; // Actual collection
1274 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1275 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1278 //------------------------------------------------------------------------
1279 void WidgetShowNPoints::RefreshCollectionText()
1281 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1284 strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1285 txtNrCollections->SetLabel( strTmp );
1291 //------------------------------------------------------------------------
1292 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1295 ff = fopen( filename.c_str() , "w+" );
1298 int i,size = lstModelShowNPoints.size();
1299 fprintf(ff,"NumberOfGroups %d \n",size);
1300 for (i=0 ; i<size ; i++)
1302 lstModelShowNPoints[i]->SavePoints_(ff);
1306 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1312 //------------------------------------------------------------------------
1313 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1315 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1316 #if wxMAJOR_VERSION <= 2
1317 wxFileDialog* FD = new wxFileDialog( 0,
1318 _T("Save groups of points .."),
1321 _T("(*.xls)|*.xls"),
1322 wxSAVE | wxOVERWRITE_PROMPT,
1325 wxFileDialog* FD = new wxFileDialog( 0,
1326 _T("Save groups of points .."),
1329 _T("(*.xls)|*.xls"),
1330 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1334 int result_FD = FD->ShowModal();
1335 // This line is need it by windows //EED
1336 FD->SetReturnCode( result_FD );
1337 if (FD->GetReturnCode()==wxID_OK)
1339 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1340 OnSaveCollections_( filename );
1345 //------------------------------------------------------------------------
1346 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1348 bool okEraseFirstGroup=false;
1349 if (lstModelShowNPoints.size()==1)
1351 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1353 FILE *ff = fopen( filename.c_str() , "r+" );
1357 int iGroup,sizeGroups;
1358 int iPoint,numberPointsRead;
1360 fscanf(ff," %s %d",chartmp,&sizeGroups);
1361 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1363 mActualCollection = lstModelShowNPoints.size();
1365 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1366 for (i=0;i<numberPointsRead;i++)
1370 GetViewShowNPoints()->AddVtkPoint();
1376 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1378 if (okEraseFirstGroup==true)
1380 mActualCollection=0;
1381 DeleteCollection_();
1382 mActualCollection = lstModelShowNPoints.size()-1;
1384 GetViewShowNPoints()->Render();
1385 RefreshCollectionText();
1386 RefreshColourCollection();
1390 //------------------------------------------------------------------------
1391 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1393 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1394 #if wxMAJOR_VERSION <= 2
1395 wxFileDialog* FD = new wxFileDialog( 0,
1396 _T("Load groups of points .."),
1399 _T("(*.xls)|*.xls"),
1400 wxOPEN | wxFILE_MUST_EXIST,
1403 wxFileDialog* FD = new wxFileDialog( 0,
1404 _T("Load groups of points .."),
1407 _T("(*.xls)|*.xls"),
1408 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1411 int result_FD = FD->ShowModal();
1412 // This line is need it by windows //EED
1413 FD->SetReturnCode( result_FD );
1414 if (FD->GetReturnCode()==wxID_OK)
1416 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1417 OnLoadCollections_( filename );
1418 UndoRedo_SaveCollection();
1422 //------------------------------------------------------------------------
1423 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1426 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1431 //------------------------------------------------------------------------
1432 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1434 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1436 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1437 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1440 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1443 //------------------------------------------------------------------------
1444 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1448 return GetModelShowNPoints()->GetLstPointsX();
1450 std::vector<double> lst;
1452 int iG,sG=lstModelShowNPoints.size();
1453 for (iG=0 ; iG<sG ; iG++)
1455 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1457 for (iP=0 ; iP<s ; iP++)
1459 lst.push_back( lstTmp[iP] );
1466 //------------------------------------------------------------------------
1467 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1471 return GetModelShowNPoints()->GetLstPointsY();
1473 std::vector<double> lst;
1475 int iG,sG=lstModelShowNPoints.size();
1476 for (iG=0 ; iG<sG ; iG++)
1478 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1480 for (iP=0 ; iP<s ; iP++)
1482 lst.push_back( lstTmp[iP] );
1489 //------------------------------------------------------------------------
1490 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1494 return GetModelShowNPoints()->GetLstPointsZ();
1496 std::vector<double> lst;
1498 int iG,sG=lstModelShowNPoints.size();
1499 for (iG=0 ; iG<sG ; iG++)
1501 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1503 for (iP=0 ; iP<s ; iP++)
1505 lst.push_back( lstTmp[iP] );
1513 //------------------------------------------------------------------------
1514 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1518 return GetModelShowNPoints()->GetLstLabels();
1520 std::vector< std::string > lst;
1522 int iG,sG=lstModelShowNPoints.size();
1523 for (iG=0 ; iG<sG ; iG++)
1525 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1527 for (iP=0 ; iP<s ; iP++)
1529 lst.push_back( lstTmp[iP] );
1536 //------------------------------------------------------------------------
1537 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1539 std::vector<int> lstIndexs;
1542 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1544 int iG,sG=lstModelShowNPoints.size();
1545 for (iG=0 ; iG<sG ; iG++)
1547 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1552 //------------------------------------------------------------------------
1553 int WidgetShowNPoints::GetLstModelShowNPointsSize()
1555 return lstModelShowNPoints.size();
1558 //------------------------------------------------------------------------
1559 void WidgetShowNPoints::InvertLstPoints_()
1561 int i,size=lstModelShowNPoints.size();
1563 for (i=0 ; i < size ; i++)
1565 lstModelShowNPoints[i]->InversLstPoints();
1569 ModelShowNPoints* tmpModel;
1571 for (i=0 ; i < size2 ; i++)
1573 tmpModel = lstModelShowNPoints[i];
1574 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
1575 lstModelShowNPoints[size-1-i] = tmpModel;
1580 //------------------------------------------------------------------------
1581 void WidgetShowNPoints::OnInvertLstPoints_()
1583 StopAutoAddPoints();
1588 UndoRedo_SaveCollection();
1592 //------------------------------------------------------------------------
1593 std::string WidgetShowNPoints::GetUndoRedoFileName()
1596 sprintf(buff,"%p_%d",this, idUndoRedo);
1597 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
1601 //------------------------------------------------------------------------
1602 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
1604 ResetCollections_();
1605 // if (idUndoRedo==maxUndoRedo+1)
1608 // } // if idUndoRedo+1
1615 OnLoadCollections_( GetUndoRedoFileName() );
1621 //------------------------------------------------------------------------
1622 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
1624 if (idUndoRedo>maxUndoRedo)
1626 idUndoRedo=maxUndoRedo+1;
1628 ResetCollections_();
1629 OnLoadCollections_( GetUndoRedoFileName() );
1634 //------------------------------------------------------------------------
1635 void WidgetShowNPoints::UndoRedo_SaveCollection()
1637 OnSaveCollections_( GetUndoRedoFileName() );
1638 maxUndoRedo = idUndoRedo;