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 wxButton *btnBackPoint = new wxButton( panel, -1, _T("<") , wxDefaultPosition, sizeButton );
173 wxButton *btnNextPoint = new wxButton( panel, -1, _T(">") , wxDefaultPosition, sizeButton );
174 wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton );
175 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );
176 cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton );
177 wxButton *btnMovePointUp = new wxButton( panel, -1, _T("<-") , wxDefaultPosition, sizeButton );
178 wxButton *btnMovePointDown = new wxButton( panel, -1, _T("->") , wxDefaultPosition, sizeButton );
180 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton );
181 cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton );
182 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton );
183 wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
184 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
185 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
186 wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
187 wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
188 wxButton *btnSavePoints = NULL;
189 wxButton *btnLoadPoints = NULL;
192 btnBackPoint -> SetToolTip( _T("Select befor point") );
193 btnNextPoint -> SetToolTip( _T("Select next point") );
194 cbAutoAddPoints -> SetToolTip( _T("Auto Add point") );
195 btnAddPoint -> SetToolTip( _T("+ Add point") );
196 btnInsertPoint -> SetToolTip( _T("(-) Insert point") );
197 btnMovePointUp -> SetToolTip( _T("Move point Up in the normal direction") );
198 btnMovePointDown -> SetToolTip( _T("Move point Down in the normal direction") );
200 btnErasePoint -> SetToolTip( _T("- Erase point") );
201 btnEraseLastPoint -> SetToolTip( _T("- lst Erase last point") );
202 btnDeleteAllPoints -> SetToolTip( _T("-- Erase all points") );
206 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
207 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
208 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
209 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
211 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
213 wxStaticText* txOpacity;
214 wxStaticText* txRadio;
215 if ( (mtype==0) || (mtype==3) )
217 //NTU: Sliders for opacity and radio change
218 txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
219 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
220 txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
221 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
223 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
224 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
226 Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints);
227 Connect(btnBackPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnBackPoint);
228 Connect(btnNextPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnNextPoint);
229 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
230 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
231 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
232 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
233 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
234 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
235 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
236 Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
237 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
238 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
239 wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
240 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
241 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(3);
242 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
243 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
244 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
245 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
246 wxFlexGridSizer *sizer7 = new wxFlexGridSizer(2);
247 sizer1->Add( textCtrl );
248 sizer1->Add( btnRenamePoint );
249 // sizer2->Add( cbAutoAddPoints );
250 // sizer2->Add( new wxStaticText(panel, -1, _T(" ")) );
251 sizer2->Add( btnAddPoint );
252 sizer2->Add( btnInsertPoint );//CFT
253 sizer2->Add( cbAutoAddPoints );
254 sizer3->Add( btnSetPositionPoint );
255 sizer3->Add( cbTrackPoint );
256 sizer4->Add( btnErasePoint );
257 sizer4->Add( btnEraseLastPoint );
258 sizer4->Add( btnDeleteAllPoints );
259 sizer5->Add( btnUndo );
260 sizer5->Add( btnRedo );
261 sizer6->Add( btnBackPoint );
262 sizer6->Add( btnNextPoint );
263 sizer7->Add( btnMovePointUp );
264 sizer7->Add( btnMovePointDown );
266 // sizer0->Add(askPointLabel); // JPR
267 sizer0->Add(txtNrPoints);
275 if ( (mtype==0) || (mtype==3) )
277 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
278 sizer5->Add(txRadio);
279 sizer5->Add(sdrRadio,1,wxGROW );
280 sizer5->Add(txOpacity);
281 sizer5->Add(sdrOpacity,1,wxGROW );
286 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
287 sizer6->Add(btnSavePoints);
288 sizer6->Add(btnLoadPoints);
297 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
298 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
300 //NTU: Sliders for opacity and radio change
301 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
302 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
303 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
304 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
305 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
306 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
307 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
309 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
310 sizer1->Add(btnSetPositionPoint);
311 sizer1->Add(txtNrPoints);
312 sizer1->Add(txRadio);
313 sizer1->Add(sdrRadio,1,wxGROW );
314 sizer1->Add(txOpacity);
315 sizer1->Add(sdrOpacity,1,wxGROW );
321 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
322 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
323 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
324 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
325 textCtrl = new wxTextCtrl(panel, -1);
326 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
327 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
328 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
329 sizer1->Add(askPointLabel);
330 sizer1->Add(btnAddPoint);
331 sizer1->Add(btnDeleteAllPoints);
333 sizer1->Add(textCtrl);
334 // sdrOpacity = new wxSlider();
335 // sdrRadio = new wxSlider();
336 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
338 } // bbGetInputType 2
340 panel->SetSizer(sizer);
341 panel->SetAutoLayout(true);
343 bookSetPoints->AddPage(panel , _T("Points") );
345 if ((mtype >= 0) && (mtype <= 3) )
349 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
350 sizerParent->Add( bookSetPoints );
351 panelParent->SetSizer( sizerParent );
352 panelParent->SetAutoLayout(true);
353 panelParent->Layout();
355 } // if mtype 0 1 2 3
359 if ((sizer!=NULL) && (MNPsizer!=NULL))
361 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
362 sizerG->Add(bookGroupManager);
363 sizerG->Add(bookSetPoints);
364 panelParent->SetSizer(sizerG);
365 panelParent->SetAutoLayout(true);
366 panelParent->Layout();
371 //------------------------------------------------------------------------
372 WidgetShowNPoints::~WidgetShowNPoints()
376 //------------------------------------------------------------------------
377 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
380 // return mmodelShowNPoints;
381 return lstModelShowNPoints[ mActualCollection ];
384 //------------------------------------------------------------------------
385 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id)
387 if(id >= 0 && id < lstModelShowNPoints.size())
389 return lstModelShowNPoints[ id ];
394 //------------------------------------------------------------------------
395 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
397 return lstViewShowNPoints[ mActualCollection ];
401 //------------------------------------------------------------------------
402 void WidgetShowNPoints::SetRadio(double radio)
405 // GetModelShowNPoints()->SetRadio(radio);
406 int i,size = lstModelShowNPoints.size();
409 lstModelShowNPoints[i]->SetRadio( radio );
412 sdrRadio->SetValue(radio);
415 //------------------------------------------------------------------------
416 void WidgetShowNPoints::SetColour(std::vector<double> colour)
419 //this->mcolour = colour;
420 int i,size = lstViewShowNPoints.size();
421 for (i=0 ; i<size ; i++)
423 lstViewShowNPoints[i]->mcolour = colour;
427 //------------------------------------------------------------------------
428 void WidgetShowNPoints::SetImage(vtkImageData* image)
431 //GetModelShowNPoints()->SetImage(image);
432 int i,size = lstModelShowNPoints.size();
433 for (i=0 ; i<size ; i++)
435 lstModelShowNPoints[i]->SetImage(image);
439 //------------------------------------------------------------------------
440 void WidgetShowNPoints::SetOpacity(double opacity)
443 //this->mopacity=opacity;
444 int i,size = lstViewShowNPoints.size();
445 for (i=0 ; i<size ; i++)
447 lstViewShowNPoints[i]->mopacity = opacity;
450 sdrOpacity->SetValue( opacity*100.0 );
454 //------------------------------------------------------------------------
455 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
458 //this->renderer = renderer;
459 int i,size = lstViewShowNPoints.size();
460 for (i=0 ; i<size ; i++)
462 lstViewShowNPoints[i]->renderer = renderer;
467 //------------------------------------------------------------------------
469 void WidgetShowNPoints::RefreshPoint(int id)
473 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
474 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
475 std::string label = GetModelShowNPoints()->GetIdLabel(id);
476 double radio = GetModelShowNPoints()->GetRadio();
477 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
478 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
479 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
480 lstSourceSphere[id]->SetRadius( radio );
481 //EED 2017-01-01 Migration VTK7
482 #if VTK_MAJOR_VERSION <= 5
485 lstSourceSphere[id]->Update();
487 lstActorsText[id]->SetInput( label.c_str() );
488 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
491 //------------------------------------------------------------------------
492 void WidgetShowNPoints::RefreshPoints()
494 int id,size=lstActorsSphere.size();
495 for (id=0;id<size;id++)
499 renderer->GetRenderWindow()->Render();
502 //------------------------------------------------------------------------
503 void WidgetShowNPoints::AddVtkPoint()
506 vtkSphereSource *vtksphere = vtkSphereSource::New();
507 vtksphere->SetThetaResolution (20);
508 vtksphere->SetPhiResolution (20);
509 vtksphere->SetRadius( 1 );
510 //NTU: For updating points
511 lstSourceSphere.push_back(vtksphere);
512 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
514 //EED 2017-01-01 Migration VTK7
515 #if VTK_MAJOR_VERSION <= 5
516 sphereMapper->SetInput( vtksphere->GetOutput() );
519 sphereMapper->SetInputData( vtksphere->GetOutput() );
522 vtkActor *sphereActor = vtkActor::New();
523 sphereActor->SetMapper(sphereMapper);
524 sphereActor->SetOrigin(0, 0, 0);
526 lstActorsSphere.push_back(sphereActor);
528 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
532 renderer->AddActor( sphereActor );
534 vtkTextActor3D *textActor = vtkTextActor3D::New();
535 // textActor->SetInput( strLabel.c_str() );
536 renderer->AddActor( textActor );
537 lstActorsText.push_back(textActor);
542 void WidgetShowNPoints::SetCurrentPoint(int idCurrentPoint )
544 int size = GetModelShowNPoints()->GetLstPointsSize();
545 if (idCurrentPoint<0) { idCurrentPoint = size-1; }
546 if (idCurrentPoint>=size ) { idCurrentPoint = 0; }
547 GetModelShowNPoints()->SetIdCurrentPoint( idCurrentPoint );
548 RefreshCollectionText();
549 RefreshColourCollection();
552 void WidgetShowNPoints::OnBackPoint(wxCommandEvent &event)
554 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() + 1 );
557 void WidgetShowNPoints::OnNextPoint(wxCommandEvent &event)
559 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() - 1 );
563 //------------------------------------------------------------------------
564 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
566 printf("WidgetShowNPoints::AddPoint 0 model=%p\n", GetModelShowNPoints() );
567 GetModelShowNPoints()->AddPoint(x,y,z, label );
570 //RefreshPoint(lstActorsSphere.size()-1);
571 printf("WidgetShowNPoints::AddPoint 1 view=%p\n", GetViewShowNPoints() );
572 GetViewShowNPoints()->AddPoint();
573 printf("WidgetShowNPoints::AddPoint 2\n");
576 //------------------------------------------------------------------------
577 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
580 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
584 // AddPoint(x,y,z,label);
587 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
589 GetViewShowNPoints()->AddVtkPoint();
591 AddPoint(x,y,z,label);
593 GetViewShowNPoints()->RefreshPoints();
596 //------------------------------------------------------------------------
597 void WidgetShowNPoints::OnInsertPoint_()
600 //if (this->renderer==NULL)
604 if (GetViewShowNPoints()->renderer==NULL)
608 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
611 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
613 } else {//mpoint.size
614 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
616 UndoRedo_SaveCollection();
619 //------------------------------------------------------------------------
620 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
625 //------------------------------------------------------------------------
626 void WidgetShowNPoints::OnAddPoint__()
629 //if (this->renderer==NULL)
630 if (GetViewShowNPoints()->renderer==NULL)
634 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
637 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
640 //renderer->GetRenderWindow()->Render();
641 GetViewShowNPoints()->Render();
642 } else {//mpoint.size
643 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
645 UndoRedo_SaveCollection();
648 void WidgetShowNPoints::OnAddPoint_()
655 //------------------------------------------------------------------------
656 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
661 //------------------------------------------------------------------------
662 void WidgetShowNPoints::AutoAddPoints()
664 if ( cbAutoAddPoints->GetValue() == true )
667 } // if cbAutoAddPoints
670 //------------------------------------------------------------------------
671 void WidgetShowNPoints::OnAutoAddPoints_tool()
674 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
677 //------------------------------------------------------------------------
678 void WidgetShowNPoints::OnAutoAddPoints_()
681 printf("EED WidgetShowNPoints::OnAutoAddPoints_ \n");
684 //------------------------------------------------------------------------
685 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
688 printf("EED WidgetShowNPoints::OnAutoAddPoints \n");
691 //------------------------------------------------------------------------
692 void WidgetShowNPoints::StopAutoAddPoints( )
694 cbAutoAddPoints->SetValue(false);
697 //------------------------------------------------------------------------
698 void WidgetShowNPoints::SetOutputBox()
700 //EED renderer->GetRenderWindow()->Render();
702 strTmp.Printf(_T("Nbr pnts: %d"), GetModelShowNPoints()->GetLstPointsSize() );
703 txtNrPoints->SetLabel( strTmp );
707 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
708 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
709 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
710 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
711 // mbbShowNPoints->bbSignalOutputModification();
715 //------------------------------------------------------------------------
716 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
719 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
720 #if wxMAJOR_VERSION <= 2
721 wxFileDialog* FD = new wxFileDialog( 0,
722 _T("Save points .."),
726 wxSAVE | wxOVERWRITE_PROMPT,
729 wxFileDialog* FD = new wxFileDialog( 0,
730 _T("Save points .."),
734 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
738 int result_FD = FD->ShowModal();
739 // This line is need it by windows //EED
740 FD->SetReturnCode( result_FD );
741 if (FD->GetReturnCode()==wxID_OK)
743 std::string filename= (const char*) ( FD->GetPath().mb_str() );
744 GetModelShowNPoints()->SavePoints( filename );
749 //------------------------------------------------------------------------
750 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
753 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
754 #if wxMAJOR_VERSION <= 2
755 wxFileDialog* FD = new wxFileDialog( 0,
756 _T("Load points .."),
760 wxOPEN | wxFILE_MUST_EXIST,
763 wxFileDialog* FD = new wxFileDialog( 0,
764 _T("Load points .."),
768 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
773 int result_FD = FD->ShowModal();
774 // This line is need it by windows //EED
775 FD->SetReturnCode( result_FD );
776 if (FD->GetReturnCode()==wxID_OK)
779 std::string filename= (const char*) ( FD->GetPath().mb_str() );
780 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
781 for (i=0;i<numberPointsRead;i++)
785 GetViewShowNPoints()->AddVtkPoint();
790 GetViewShowNPoints()->RefreshPoints();
794 //------------------------------------------------------------------------
795 void WidgetShowNPoints::OnSetPoint_()
800 int id=GetModelShowNPoints()->GetNearestPoint();
801 if((id==-1) && (mtype==1))
809 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
812 //renderer->GetRenderWindow()->Render();
813 GetViewShowNPoints()->RefreshPoint(id);
814 GetViewShowNPoints()->Render();
817 UndoRedo_SaveCollection();
820 //------------------------------------------------------------------------
821 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
826 //------------------------------------------------------------------------
827 void WidgetShowNPoints::TrackingPoint( )
829 if ( cbTrackPoint->GetValue() == true )
831 int id = GetModelShowNPoints()->IdInsidePoint();
839 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
840 GetViewShowNPoints()->RefreshPoint(idTrack);
841 GetViewShowNPoints()->Render();
842 UndoRedo_SaveCollection();
844 } // if trackPointFlag
847 //------------------------------------------------------------------------
848 void WidgetShowNPoints::OnTrackPoint_tool()
850 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
854 //------------------------------------------------------------------------
855 void WidgetShowNPoints::OnTrackPoint_()
860 if ( cbTrackPoint->GetValue() == true )
862 idTrack = GetModelShowNPoints()->IdInsidePoint();
863 } // if trackPointFlag
866 //------------------------------------------------------------------------
867 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
869 printf("WidgetShowNPoints::OnTrackPoint \n");
873 //------------------------------------------------------------------------
874 void WidgetShowNPoints::StopTrackPoint( )
876 cbTrackPoint->SetValue(false);
880 //------------------------------------------------------------------------
881 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
883 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
887 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
888 //renderer->GetRenderWindow()->Render();
889 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
890 GetViewShowNPoints()->Render();
892 UndoRedo_SaveCollection();
896 //------------------------------------------------------------------------
897 void WidgetShowNPoints::ErasePoint(int id)
900 //if (this->renderer!=NULL)
901 if (GetViewShowNPoints()->renderer!=NULL)
906 //renderer->RemoveActor( lstActorsSphere[id] );
907 //renderer->RemoveActor( lstActorsText[id] );
908 //lstActorsSphere[id]->Delete();
909 //lstActorsText[id]->Delete();
910 //lstSourceSphere[id]->Delete();
911 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
912 //lstActorsText.erase( lstActorsText.begin()+id );
913 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
914 GetViewShowNPoints()->ErasePoint(id);
915 GetModelShowNPoints()->ErasePoint(id);
920 //------------------------------------------------------------------------
921 void WidgetShowNPoints::OnErasePoint_()
926 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
929 //renderer->GetRenderWindow()->Render();
930 GetViewShowNPoints()->Render();
932 UndoRedo_SaveCollection();
935 //------------------------------------------------------------------------
936 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
941 //------------------------------------------------------------------------
942 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
945 //ErasePoint( lstActorsSphere.size()-1 );
946 //renderer->GetRenderWindow()->Render();
950 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
952 UndoRedo_SaveCollection();
953 GetViewShowNPoints()->Render();
958 //------------------------------------------------------------------------
959 void WidgetShowNPoints::DeleteAllPoints_()
962 //int id,size=lstActorsSphere.size();
963 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
964 for (id=size-1;id>=0;id--)
970 void WidgetShowNPoints::OnDeleteAllPoints_()
976 UndoRedo_SaveCollection();
979 //------------------------------------------------------------------------
980 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
982 OnDeleteAllPoints_();
984 GetViewShowNPoints()->Render();
987 //NTU: Method for updating points opacity and Radio
989 //------------------------------------------------------------------------
990 void WidgetShowNPoints::UpdatePoints_()
993 //this->mopacity = sdrOpacity->GetValue()/100.0;
994 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
997 double opacity = sdrOpacity->GetValue()/100.0;
998 double radio = sdrRadio->GetValue();
999 int i,size = lstViewShowNPoints.size();
1000 for (i=0 ; i<size ; i++)
1002 lstViewShowNPoints[i]->mopacity = opacity;
1003 lstModelShowNPoints[i]->SetRadio( radio ) ;
1005 // GetViewShowNPoints()->RefreshPoints();
1008 //------------------------------------------------------------------------
1009 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
1011 RefreshColourCollection();
1014 //------------------------------------------------------------------------
1015 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
1017 GetModelShowNPoints()->SetReferencePoint(point);
1018 int i,size=lstModelShowNPoints.size();
1019 for (i=0;i<size;i++)
1021 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
1025 //------------------------------------------------------------------------
1026 void WidgetShowNPoints::SetActualCollection( int actual )
1033 if (actual>lstModelShowNPoints.size()-1 )
1035 actual=lstModelShowNPoints.size()-1;
1038 mActualCollection=actual;
1042 //------------------------------------------------------------------------
1043 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
1045 if (GetViewShowNPoints()->renderer==NULL)
1051 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1052 int ii,iIndexs,sizeIndexs;
1054 sizeX = (int)initLstPointsX.size();
1055 sizeY = (int)initLstPointsY.size();
1056 sizeZ = (int)initLstPointsZ.size();
1057 sizeLabels = (int)initLstLabels.size();
1058 sizeIndexs = (int)initLstIndexs.size();
1062 initLstIndexs.push_back(sizeX);
1063 sizeIndexs = (int)initLstIndexs.size();
1066 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1069 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1073 InsertCollectionAfter_();
1075 sizeTmp = initLstIndexs[iIndexs];
1076 for (ii=0;ii<sizeTmp;ii++)
1078 x = initLstPointsX[i];
1079 y = initLstPointsY[i];
1080 z = initLstPointsZ[i];
1083 label = initLstLabels[i];
1087 AddPoint( x,y,z,label );
1094 // renderer->GetRenderWindow()->Render();
1103 //if (this->renderer==NULL)
1104 if (GetViewShowNPoints()->renderer==NULL)
1108 int i,sizeX,sizeY,sizeZ,sizeLabels;
1109 sizeX = (int)initLstPointsX.size();
1110 sizeY = (int)initLstPointsY.size();
1111 sizeZ = (int)initLstPointsZ.size();
1112 sizeLabels = (int)initLstLabels.size();
1115 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1117 for (i=0;i<sizeX;i++)
1119 x = initLstPointsX[i];
1120 y = initLstPointsY[i];
1121 z = initLstPointsZ[i];
1124 label = initLstLabels[i];
1128 AddPoint( x,y,z,label );
1131 // renderer->GetRenderWindow()->Render();
1137 //------------------------------------------------------------------------
1138 void WidgetShowNPoints::SetType(int type)
1143 //------------------------------------------------------------------------
1144 int WidgetShowNPoints::GetType()
1150 //------------------------------------------------------------------------
1151 double WidgetShowNPoints::GetRadio()
1153 return sdrRadio->GetValue();
1155 //------------------------------------------------------------------------
1156 double WidgetShowNPoints::GetOpacity()
1158 return sdrOpacity->GetValue()/100;
1161 //------------------------------------------------------------------------
1162 void WidgetShowNPoints::InsertCollection()
1164 ModelShowNPoints* model = new ModelShowNPoints();
1165 ViewShowNPoints* view = new ViewShowNPoints( model );
1166 view->mopacity = lstViewShowNPoints[0]->mopacity;
1167 view->renderer = lstViewShowNPoints[0]->renderer;
1168 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1169 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1170 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1173 //------------------------------------------------------------------------
1174 void WidgetShowNPoints::InsertCollectionBefore_()
1177 RefreshCollectionText();
1178 RefreshColourCollection();
1182 //------------------------------------------------------------------------
1183 void WidgetShowNPoints::OnInsertCollectionBefore_()
1185 InsertCollectionBefore_();
1186 CreatePointsIntoNewCollection();
1187 UndoRedo_SaveCollection();
1191 //------------------------------------------------------------------------
1192 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1194 OnInsertCollectionBefore_();
1198 //------------------------------------------------------------------------
1199 void WidgetShowNPoints::InsertCollectionAfter_()
1201 mActualCollection++;
1203 RefreshCollectionText();
1204 RefreshColourCollection();
1209 //------------------------------------------------------------------------
1210 void WidgetShowNPoints::OnInsertCollectionAfter_()
1212 InsertCollectionAfter_();
1213 CreatePointsIntoNewCollection();
1214 UndoRedo_SaveCollection();
1217 //------------------------------------------------------------------------
1218 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1220 OnInsertCollectionAfter_();
1223 //------------------------------------------------------------------------
1224 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1226 // ---------------------------------------------
1227 printf("\nWidgetShowNPoints::InsertCollection mActualCollection=%d\n",mActualCollection);
1228 int c1 = mActualCollection-1;
1229 int c2 = mActualCollection+1;
1230 if (c2==lstModelShowNPoints.size()) { c2=0; }
1231 if ((c1>=0) && (c1!=c2) )
1233 std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1234 std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1235 std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1236 std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1237 std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1238 std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1239 std::vector<double> c1LstXX;
1240 std::vector<double> c1LstYY;
1241 std::vector<double> c1LstZZ;
1242 std::vector<double> c2LstXX;
1243 std::vector<double> c2LstYY;
1244 std::vector<double> c2LstZZ;
1245 creaContoursFactory f;
1246 manualContourModel *m;
1249 int sc; // sizeContour
1251 if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1253 // ----------------- Spline 1 --------------------
1255 size = c1LstX.size();
1256 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1257 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1258 m->SetNumberOfPointsSpline( sc );
1259 m->SetCloseContour( false );
1260 for (i=0;i<size;i++)
1262 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1267 m->GetSpline_i_Point(i,&x,&y,&z);
1268 c1LstXX.push_back(x);
1269 c1LstYY.push_back(y);
1270 c1LstZZ.push_back(z);
1273 // ----------------- Spline 2 --------------------
1274 size = c2LstX.size();
1275 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1276 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1277 m->SetNumberOfPointsSpline( sc );
1278 m->SetCloseContour( false );
1279 for (i=0;i<size;i++)
1281 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1286 m->GetSpline_i_Point(i,&x,&y,&z);
1287 c2LstXX.push_back(x);
1288 c2LstYY.push_back(y);
1289 c2LstZZ.push_back(z);
1292 // ----------------- Add new Points --------------------
1293 i=0; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1294 // i=33; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1295 // i=66; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1296 i=25; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1297 i=50; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1298 i=75; x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1299 i=sc-1;x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
1301 RefreshCollectionText();
1302 RefreshColourCollection();
1305 } // if size of c1LstX c2LstX
1312 //------------------------------------------------------------------------
1313 void WidgetShowNPoints::DeleteCollection_()
1315 if ( lstModelShowNPoints.size()>1 )
1317 DeleteAllPoints_(); // Actual Collection
1318 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1319 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1320 if ( mActualCollection>=lstModelShowNPoints.size() )
1322 mActualCollection--;
1325 DeleteAllPoints_(); // Actual Collection
1329 //------------------------------------------------------------------------
1330 void WidgetShowNPoints::OnDeleteCollection_()
1332 DeleteCollection_();
1334 GetViewShowNPoints()->Render();
1335 RefreshCollectionText();
1336 RefreshColourCollection();
1338 UndoRedo_SaveCollection();
1341 //------------------------------------------------------------------------
1342 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1344 OnDeleteCollection_();
1347 //------------------------------------------------------------------------
1348 void WidgetShowNPoints::ResetCollections_()
1350 int i,size=lstModelShowNPoints.size();
1351 for (i=0;i<size;i++)
1353 DeleteCollection_();
1355 GetViewShowNPoints()->Render();
1356 RefreshCollectionText();
1357 RefreshColourCollection();
1362 //------------------------------------------------------------------------
1363 void WidgetShowNPoints::OnResetCollections_()
1365 ResetCollections_();
1366 UndoRedo_SaveCollection();
1370 //------------------------------------------------------------------------
1371 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1373 OnResetCollections_();
1376 //------------------------------------------------------------------------
1377 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1379 mActualCollection--;
1380 if ( mActualCollection <0 )
1382 // mActualCollection=0;
1383 mActualCollection = lstModelShowNPoints.size()-1;
1385 RefreshCollectionText();
1386 RefreshColourCollection();
1388 UndoRedo_SaveCollection();
1391 //------------------------------------------------------------------------
1392 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1394 mActualCollection++;
1395 if ( mActualCollection >=lstModelShowNPoints.size() )
1397 // mActualCollection = lstModelShowNPoints.size()-1;
1398 mActualCollection = 0;
1399 } //if mActualCollection >= size
1400 RefreshCollectionText();
1401 RefreshColourCollection();
1403 UndoRedo_SaveCollection();
1406 //------------------------------------------------------------------------
1407 void WidgetShowNPoints::DetectCollectionActive()
1410 int i,size=lstModelShowNPoints.size();
1411 for (i=0;i<size;i++)
1413 id = lstModelShowNPoints[i]->IdInsidePoint();
1416 mActualCollection=i;
1419 RefreshCollectionText();
1420 RefreshColourCollection();
1423 //------------------------------------------------------------------------
1424 void WidgetShowNPoints::RefreshColourCollection()
1427 std::vector<double> colourAll;
1428 colourAll.push_back(1);
1429 colourAll.push_back(0);
1430 colourAll.push_back(0);
1431 std::vector<double> colourActualGroup;
1432 colourActualGroup.push_back(1);
1433 colourActualGroup.push_back(1);
1434 colourActualGroup.push_back(0);
1436 // For all collections
1437 SetColour( colourAll );
1438 int i,size=lstViewShowNPoints.size();
1439 for (i=0;i<size;i++)
1441 lstViewShowNPoints[i] -> mcolour = colourAll;
1442 lstViewShowNPoints[i] -> ratioRadio = 1;
1443 lstViewShowNPoints[i]->RefreshEachPoint();
1446 // Actual collection
1447 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1448 lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.1;
1449 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1452 int curPnt = lstModelShowNPoints[mActualCollection] -> GetIdCurrentPoint();
1453 size=lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1454 if ((curPnt>=0) && (curPnt<size ) )
1456 std::vector<double> colourActualPoint;
1457 colourActualPoint.push_back(0);
1458 colourActualPoint.push_back(0);
1459 colourActualPoint.push_back(1);
1460 double radio = GetModelShowNPoints()->GetRadio();
1461 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1462 lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt );
1463 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1465 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1468 //------------------------------------------------------------------------
1469 void WidgetShowNPoints::RefreshCollectionText()
1471 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1474 strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1475 txtNrCollections->SetLabel( strTmp );
1481 //------------------------------------------------------------------------
1482 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1485 ff = fopen( filename.c_str() , "w+" );
1488 int i,size = lstModelShowNPoints.size();
1489 fprintf(ff,"NumberOfGroups %d \n",size);
1490 for (i=0 ; i<size ; i++)
1492 lstModelShowNPoints[i]->SavePoints_(ff);
1496 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1502 //------------------------------------------------------------------------
1503 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1505 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1506 #if wxMAJOR_VERSION <= 2
1507 wxFileDialog* FD = new wxFileDialog( 0,
1508 _T("Save groups of points .."),
1511 _T("(*.xls)|*.xls"),
1512 wxSAVE | wxOVERWRITE_PROMPT,
1515 wxFileDialog* FD = new wxFileDialog( 0,
1516 _T("Save groups of points .."),
1519 _T("(*.xls)|*.xls"),
1520 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1524 int result_FD = FD->ShowModal();
1525 // This line is need it by windows //EED
1526 FD->SetReturnCode( result_FD );
1527 if (FD->GetReturnCode()==wxID_OK)
1529 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1530 OnSaveCollections_( filename );
1535 //------------------------------------------------------------------------
1536 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1538 bool okEraseFirstGroup=false;
1539 if (lstModelShowNPoints.size()==1)
1541 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1543 FILE *ff = fopen( filename.c_str() , "r+" );
1547 int iGroup,sizeGroups;
1548 int iPoint,numberPointsRead;
1550 fscanf(ff," %s %d",chartmp,&sizeGroups);
1551 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1553 mActualCollection = lstModelShowNPoints.size();
1555 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1556 for (i=0;i<numberPointsRead;i++)
1560 GetViewShowNPoints()->AddVtkPoint();
1566 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1568 if (okEraseFirstGroup==true)
1570 mActualCollection=0;
1571 DeleteCollection_();
1572 mActualCollection = lstModelShowNPoints.size()-1;
1574 GetViewShowNPoints()->Render();
1575 RefreshCollectionText();
1576 RefreshColourCollection();
1580 //------------------------------------------------------------------------
1581 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1583 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1584 #if wxMAJOR_VERSION <= 2
1585 wxFileDialog* FD = new wxFileDialog( 0,
1586 _T("Load groups of points .."),
1589 _T("(*.xls)|*.xls"),
1590 wxOPEN | wxFILE_MUST_EXIST,
1593 wxFileDialog* FD = new wxFileDialog( 0,
1594 _T("Load groups of points .."),
1597 _T("(*.xls)|*.xls"),
1598 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1601 int result_FD = FD->ShowModal();
1602 // This line is need it by windows //EED
1603 FD->SetReturnCode( result_FD );
1604 if (FD->GetReturnCode()==wxID_OK)
1606 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1607 OnLoadCollections_( filename );
1608 UndoRedo_SaveCollection();
1612 //------------------------------------------------------------------------
1613 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1616 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1621 //------------------------------------------------------------------------
1622 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1624 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1626 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1627 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1630 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1633 //------------------------------------------------------------------------
1634 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1638 return GetModelShowNPoints()->GetLstPointsX();
1640 std::vector<double> lst;
1642 int iG,sG=lstModelShowNPoints.size();
1643 for (iG=0 ; iG<sG ; iG++)
1645 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1647 for (iP=0 ; iP<s ; iP++)
1649 lst.push_back( lstTmp[iP] );
1656 //------------------------------------------------------------------------
1657 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1661 return GetModelShowNPoints()->GetLstPointsY();
1663 std::vector<double> lst;
1665 int iG,sG=lstModelShowNPoints.size();
1666 for (iG=0 ; iG<sG ; iG++)
1668 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1670 for (iP=0 ; iP<s ; iP++)
1672 lst.push_back( lstTmp[iP] );
1679 //------------------------------------------------------------------------
1680 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1684 return GetModelShowNPoints()->GetLstPointsZ();
1686 std::vector<double> lst;
1688 int iG,sG=lstModelShowNPoints.size();
1689 for (iG=0 ; iG<sG ; iG++)
1691 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1693 for (iP=0 ; iP<s ; iP++)
1695 lst.push_back( lstTmp[iP] );
1703 //------------------------------------------------------------------------
1704 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1708 return GetModelShowNPoints()->GetLstLabels();
1710 std::vector< std::string > lst;
1712 int iG,sG=lstModelShowNPoints.size();
1713 for (iG=0 ; iG<sG ; iG++)
1715 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1717 for (iP=0 ; iP<s ; iP++)
1719 lst.push_back( lstTmp[iP] );
1726 //------------------------------------------------------------------------
1727 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1729 std::vector<int> lstIndexs;
1732 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1734 int iG,sG=lstModelShowNPoints.size();
1735 for (iG=0 ; iG<sG ; iG++)
1737 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1742 //------------------------------------------------------------------------
1743 int WidgetShowNPoints::GetLstModelShowNPointsSize()
1745 return lstModelShowNPoints.size();
1748 //------------------------------------------------------------------------
1749 void WidgetShowNPoints::InvertLstPoints_()
1751 int i,size=lstModelShowNPoints.size();
1753 for (i=0 ; i < size ; i++)
1755 lstModelShowNPoints[i]->InversLstPoints();
1759 ModelShowNPoints* tmpModel;
1761 for (i=0 ; i < size2 ; i++)
1763 tmpModel = lstModelShowNPoints[i];
1764 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
1765 lstModelShowNPoints[size-1-i] = tmpModel;
1770 //------------------------------------------------------------------------
1771 void WidgetShowNPoints::OnInvertLstPoints_()
1773 StopAutoAddPoints();
1778 UndoRedo_SaveCollection();
1782 //------------------------------------------------------------------------
1783 std::string WidgetShowNPoints::GetUndoRedoFileName()
1786 sprintf(buff,"%p_%d",this, idUndoRedo);
1787 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
1791 //------------------------------------------------------------------------
1792 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
1794 ResetCollections_();
1795 // if (idUndoRedo==maxUndoRedo+1)
1798 // } // if idUndoRedo+1
1805 OnLoadCollections_( GetUndoRedoFileName() );
1811 //------------------------------------------------------------------------
1812 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
1814 if (idUndoRedo>maxUndoRedo)
1816 idUndoRedo=maxUndoRedo+1;
1818 ResetCollections_();
1819 OnLoadCollections_( GetUndoRedoFileName() );
1824 //------------------------------------------------------------------------
1825 void WidgetShowNPoints::UndoRedo_SaveCollection()
1827 OnSaveCollections_( GetUndoRedoFileName() );
1828 maxUndoRedo = idUndoRedo;