4 #include <wx/filedlg.h>
6 #include <wx/notebook.h>
9 #include <vtkStaticPointLocator.h>
10 #include <vtkPointData.h>
11 #include <vtkDataArray.h>
13 #include <vtkStaticPointLocator.h>
14 #include <vtkPoints.h>
16 #include "vtkSphereSource.h"
17 #include "vtkRenderer.h"
18 #include "vtkTextActor3D.h"
20 #include "WidgetShowNPoints.h"
21 #include <creaContoursFactory.h>
24 //----------------------------------------------------------------------
25 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
29 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
30 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
33 aux_mesh_spc.push_back(1);
34 aux_mesh_spc.push_back(1);
35 aux_mesh_spc.push_back(1);
36 aux_mesh_type = 0; // 0:Patch 1:CloseSpline1 2:CloseSpline2
39 // mmodelShowNPoints = new ModelShowNPoints();
43 char * val = getenv( "TEMP" );
46 UndoRedoDir = std::string("");
48 UndoRedoDir = std::string(val)+"\\creatools";
49 std::string cmd1 = "mkdir "+ UndoRedoDir;
50 system( cmd1.c_str() );
51 // Erasing files of more than 1 day old ( -1 )
52 std::string cmd2 = "ForFiles /p \"" + UndoRedoDir + "\" /s /d -1 /c \"cmd /c del @file \"";
53 system( cmd2.c_str() );
55 #elif defined(__GNUC__)
59 UndoRedoDir = "/tmp/creatools";
61 UndoRedoDir = "/tmp/creatools";
64 std::string cmd1 = "mkdir "+ UndoRedoDir;
65 system( cmd1.c_str() );
66 // Erasing files of more than 1 day old ( +1 )
67 std::string cmd= "find "+UndoRedoDir+" -name \"UndoRedo_collection_*.undoredo\" -type f -mtime +1 -delete";
68 system( cmd.c_str() );
75 mActualCollection = 0;
76 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
77 lstModelShowNPoints.push_back( modelShowNPoints );
78 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
82 wxPanel* panelParent = this;
83 wxSizer* sizer = NULL;
84 wxSizer* MNPsizer = NULL;
85 wxNotebook* bookSetPoints = NULL;
86 wxNotebook* bookGroupManager = NULL;
87 wxPanel* panel = NULL;
88 wxPanel* panel2 = NULL;
89 txtNrCollections = NULL;
91 cbVisuActualCollection = NULL;
92 bookSetPoints = new wxNotebook(panelParent, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
93 panel = new wxPanel(bookSetPoints);
95 wxSize sizeButton( 50 , -1 );
96 wxSize sizeSlider( 90 , -1 );
101 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
106 panel2 = new wxPanel(bookGroupManager);
107 cbVisuActualCollection = new wxCheckBox ( panel2,-1, _T("A.V.") , wxDefaultPosition, sizeButton );
108 txtNrCollections = new wxStaticText ( panel2,-1, _T(" 1/1 "));
109 wxButton *btnBackCollection = new wxButton ( panel2, -1, _T("<") , wxDefaultPosition, sizeButton );
110 wxButton *btnNextCollection = new wxButton ( panel2, -1, _T(">") , wxDefaultPosition, sizeButton );
111 wxButton *btnInsertCollectionBefore = new wxButton ( panel2, -1, _T("+<") , wxDefaultPosition, sizeButton );
112 wxButton *btnInsertCollectionAfter = new wxButton ( panel2, -1, _T("+>") , wxDefaultPosition, sizeButton );
113 wxButton *btnDeleteCollection = new wxButton ( panel2, -1, _T("-") , wxDefaultPosition, sizeButton );
114 wxButton *btnResetCollection = new wxButton ( panel2, -1, _T("--") , wxDefaultPosition, sizeButton );
115 wxButton *btnSaveCollection = new wxButton ( panel2, -1, _T("Save") , wxDefaultPosition, sizeButton );
116 wxButton *btnLoadCollection = new wxButton ( panel2, -1, _T("Load") , wxDefaultPosition, sizeButton );
117 wxButton *btnUndo = new wxButton ( panel2, -1, _T("Undo") , wxDefaultPosition, sizeButton );
118 wxButton *btnRedo = new wxButton ( panel2, -1, _T("Redo") , wxDefaultPosition, sizeButton );
120 sCtrlRadio = new wxSpinCtrl( panel2, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
121 sCtrlRadio->SetRange(1,10);
122 sCtrlRadio->SetValue( 2 );
123 sCtrlOpacity= new wxSpinCtrl( panel2, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
124 sCtrlOpacity->SetRange(0,10);
125 sCtrlOpacity->SetValue( 10 );
127 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
128 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
129 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(3);
130 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
131 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
132 wxFlexGridSizer *sizer5a = new wxFlexGridSizer(2);
133 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
134 wxFlexGridSizer *sizer7 = new wxFlexGridSizer(2);
135 wxFlexGridSizer *sizer8 = new wxFlexGridSizer(2);
137 cbVisuActualCollection -> SetToolTip( _T("Visu actual collection") );
138 btnInsertCollectionBefore -> SetToolTip( _T("+ Add group before") );
139 btnInsertCollectionAfter -> SetToolTip( _T("+> Add group after") );
140 btnDeleteCollection -> SetToolTip( _T("- Erase group") );
141 btnResetCollection -> SetToolTip( _T("-- Reset : Erase all groups") );
142 sCtrlRadio -> SetToolTip( _T("Radio") );
143 sCtrlOpacity -> SetToolTip( _T("Opacity") );
145 // sdrOpacity = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, sizeSlider, wxSL_LABELS);
146 // sdrRadio = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, sizeSlider, wxSL_LABELS);
147 // sdrRadio -> SetToolTip( _T("Radio") );
148 // sdrOpacity -> SetToolTip( _T("Opacity") );
150 Connect(cbVisuActualCollection->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnVisuActualCollection );
151 Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection );
152 Connect(btnNextCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection );
153 Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore );
154 Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter );
155 Connect(btnDeleteCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection );
157 // Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) & WidgetShowNPoints::UpdatePoints );
158 // Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) & WidgetShowNPoints::UpdatePoints );
159 Connect( sCtrlRadio->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
160 Connect( sCtrlOpacity->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
162 Connect(btnSaveCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections );
163 Connect(btnLoadCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections );
164 Connect(btnResetCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) & WidgetShowNPoints::OnResetCollections );
165 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo );
166 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo );
168 sizer2->Add( btnBackCollection );
169 sizer2->Add( btnNextCollection );
170 sizer3->Add( btnInsertCollectionBefore );
171 sizer3->Add( btnInsertCollectionAfter );
172 sizer4->Add( btnLoadCollection );
173 sizer4->Add( btnSaveCollection );
174 // sizer5->Add( txRadio ,wxGROW );
175 // sizer5->Add( sdrRadio ,wxGROW );
176 // sizer5->Add( txOpacity ,wxGROW );
177 // sizer5->Add( sdrOpacity ,wxGROW );
179 sizer5->Add( sCtrlRadio );
180 sizer5->Add( sCtrlOpacity );
182 sizer6->Add( btnDeleteCollection );
183 sizer6->Add( btnResetCollection );
185 sizer7->Add( cbVisuActualCollection );
186 sizer7->Add( txtNrCollections );
188 sizer8->Add( btnUndo );
189 sizer8->Add( btnRedo );
191 sizer1->Add( sizer7 );
192 sizer1->Add( sizer2 );
193 sizer1->Add( sizer3 );
194 sizer1->Add( sizer6 );
195 sizer1->Add( sizer4 );
196 sizer1->Add( sizer5 );
197 sizer1->Add( sizer8 );
199 // sizer1->Add( sizer5 ,wxGROW );
202 panel2->SetSizer( MNPsizer );
203 panel2->SetAutoLayout(true);
205 bookGroupManager->AddPage(panel2 , _T("Groups") );
208 if ( (mtype==0) || (mtype==3) || (mtype==4) )
211 // askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR
212 textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton);
213 wxButton *btnBackPoint = new wxButton( panel, -1, _T("<") , wxDefaultPosition, sizeButton );
214 wxButton *btnNextPoint = new wxButton( panel, -1, _T(">") , wxDefaultPosition, sizeButton );
215 wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton );
216 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );
217 cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton );
218 wxButton *btnMovePointUp = new wxButton( panel, -1, _T("<-") , wxDefaultPosition, sizeButton );
219 wxButton *btnMovePointDown = new wxButton( panel, -1, _T("->") , wxDefaultPosition, sizeButton );
220 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton );
221 cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton );
222 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton );
223 wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
224 // wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
225 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
226 wxButton *btnUndo = NULL;
227 wxButton *btnRedo = NULL;
228 wxButton *btnSavePoints = NULL;
229 wxButton *btnLoadPoints = NULL;
230 btnBackPoint -> SetToolTip( _T("Select befor point") );
231 btnNextPoint -> SetToolTip( _T("Select next point") );
232 cbAutoAddPoints -> SetToolTip( _T("Auto Add point") );
233 btnAddPoint -> SetToolTip( _T("+ Add point") );
234 btnInsertPoint -> SetToolTip( _T("(+) Insert point") );
235 btnMovePointUp -> SetToolTip( _T("Move point Up in the normal direction") );
236 btnMovePointDown -> SetToolTip( _T("Move point Down in the normal direction") );
237 btnRenamePoint -> SetToolTip( _T("Rename label for each point") );
238 textCtrl -> SetToolTip( _T("Point label") );
239 btnErasePoint -> SetToolTip( _T("- Erase point") );
240 // btnEraseLastPoint -> SetToolTip( _T("- lst Erase last point") );
241 btnDeleteAllPoints -> SetToolTip( _T("-- Erase all points") );
244 btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
245 btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
246 btnSavePoints = new wxButton( panel, -1, _T("Save") , wxDefaultPosition, sizeButton );
247 btnLoadPoints = new wxButton( panel, -1, _T("Load") , wxDefaultPosition, sizeButton );
248 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints );
249 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints );
250 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo );
251 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo );
253 txtNrPoints = new wxStaticText(panel,-1, _T(" -/-"));
254 wxStaticText* txOpacity;
255 wxStaticText* txRadio;
256 if ( (mtype==0) || (mtype==3) )
258 //NTU: Sliders for opacity and radio change
259 // txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
260 // sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
261 // txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
262 // sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
263 // //NTU: Slider events
264 // Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
265 // Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
267 sCtrlRadio = new wxSpinCtrl( panel, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
268 sCtrlRadio->SetRange(1,10);
269 sCtrlRadio->SetValue( 2 );
270 sCtrlOpacity= new wxSpinCtrl( panel, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
271 sCtrlOpacity->SetRange(0,10);
272 sCtrlOpacity->SetValue( 10 );
273 Connect( sCtrlRadio->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
274 Connect( sCtrlOpacity->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
278 Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints );
279 Connect(btnBackPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnBackPoint );
280 Connect(btnNextPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnNextPoint );
281 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint );
282 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint );
283 Connect(btnMovePointUp->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnMovePointUp );
284 Connect(btnMovePointDown->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnMovePointDown );
285 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint );
286 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint );
287 // Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint );
288 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint );
289 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints );
290 Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint );
291 wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
292 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
293 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(3);
294 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
295 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
296 // wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
297 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
298 wxFlexGridSizer *sizer7 = new wxFlexGridSizer(2);
299 wxFlexGridSizer *sizer8 = new wxFlexGridSizer(2);
300 sizer1->Add( textCtrl );
301 sizer1->Add( btnRenamePoint );
302 sizer2->Add( btnAddPoint );
303 sizer2->Add( btnInsertPoint );
304 // sizer2->Add( cbAutoAddPoints );
305 sizer3->Add( btnSetPositionPoint );
306 sizer3->Add( cbTrackPoint );
307 sizer4->Add( btnErasePoint );
308 // sizer4->Add( btnEraseLastPoint );
309 sizer4->Add( btnDeleteAllPoints );
310 // sizer5->Add( btnUndo );
311 // sizer5->Add( btnRedo );
312 sizer6->Add( btnBackPoint );
313 sizer6->Add( btnNextPoint );
314 sizer7->Add( btnMovePointUp );
315 sizer7->Add( btnMovePointDown );
316 sizer8->Add( cbAutoAddPoints );
317 sizer8->Add( txtNrPoints );
318 // sizer0->Add(askPointLabel); // JPR
326 // sizer0->Add(sizer5);
327 if ( (mtype==0) || (mtype==3) )
329 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
330 // sizer5->Add(txRadio);
331 // sizer5->Add(sdrRadio,1,wxGROW );
332 // sizer5->Add(txOpacity);
333 // sizer5->Add(sdrOpacity,1,wxGROW );
334 sizer5->Add( sCtrlRadio );
335 sizer5->Add( sCtrlOpacity );
340 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
341 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
342 sizer6->Add( btnSavePoints );
343 sizer6->Add( btnLoadPoints );
344 sizer5->Add( btnUndo );
345 sizer5->Add( btnRedo );
346 sizer0->Add( sizer6 );
347 sizer0->Add( sizer5 );
355 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
356 txtNrPoints = new wxStaticText(panel,-1, _T("-/-"));
358 //NTU: Sliders for opacity and radio change
359 // sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
360 // sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
361 // Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
362 // Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
363 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
364 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
366 sCtrlRadio = new wxSpinCtrl( panel, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
367 sCtrlRadio->SetRange(1,10);
368 sCtrlRadio->SetValue( 2 );
369 sCtrlOpacity= new wxSpinCtrl( panel, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
370 sCtrlOpacity->SetRange(0,10);
371 sCtrlOpacity->SetValue( 10 );
372 Connect( sCtrlRadio->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
373 Connect( sCtrlOpacity->GetId() ,wxEVT_COMMAND_SPINCTRL_UPDATED,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
374 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
375 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
376 sizer1->Add(btnSetPositionPoint);
377 sizer1->Add(txtNrPoints);
378 sizer1->Add(txRadio);
379 //sizer1->Add(sdrRadio,1,wxGROW );
380 //sizer1->Add(sdrOpacity,1,wxGROW );
381 sizer1->Add(sCtrlRadio );
382 sizer1->Add(sCtrlOpacity);
388 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
389 wxButton *btnAddPoint = new wxButton(panel , -1, _T(" Add Point "));
390 wxButton *btnDeleteAllPoints = new wxButton(panel , -1, _T(" Delete All "));
391 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
392 textCtrl = new wxTextCtrl(panel, -1);
393 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
394 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
395 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
396 sizer1->Add(askPointLabel);
397 sizer1->Add(btnAddPoint);
398 sizer1->Add(btnDeleteAllPoints);
400 sizer1->Add(textCtrl);
401 // sdrOpacity = new wxSlider();
402 // sdrRadio = new wxSlider();
403 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
405 } // bbGetInputType 2
407 panel->SetSizer(sizer);
408 panel->SetAutoLayout(true);
410 bookSetPoints->AddPage(panel , _T("Points") );
412 if ((mtype >= 0) && (mtype <= 3) )
416 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
417 sizerParent->Add( bookSetPoints );
418 panelParent->SetSizer( sizerParent );
419 panelParent->SetAutoLayout(true);
420 panelParent->Layout();
422 } // if mtype 0 1 2 3
426 if ((sizer!=NULL) && (MNPsizer!=NULL))
428 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
429 sizerG->Add(bookGroupManager);
430 sizerG->Add(bookSetPoints);
431 panelParent->SetSizer(sizerG);
432 panelParent->SetAutoLayout(true);
433 panelParent->Layout();
438 //------------------------------------------------------------------------
439 WidgetShowNPoints::~WidgetShowNPoints()
443 //------------------------------------------------------------------------
444 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
447 // return mmodelShowNPoints;
448 return lstModelShowNPoints[ mActualCollection ];
451 //------------------------------------------------------------------------
452 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id)
454 if(id >= 0 && id < lstModelShowNPoints.size())
456 return lstModelShowNPoints[ id ];
461 //------------------------------------------------------------------------
462 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
464 return lstViewShowNPoints[ mActualCollection ];
468 //------------------------------------------------------------------------
469 void WidgetShowNPoints::SetRadio(double radio)
472 // GetModelShowNPoints()->SetRadio(radio);
473 int i,size = lstModelShowNPoints.size();
476 lstModelShowNPoints[i]->SetRadio( radio );
479 // sdrRadio->SetValue(radio);
480 sCtrlRadio->SetValue(radio);
483 //------------------------------------------------------------------------
484 void WidgetShowNPoints::SetColour(std::vector<double> colour)
487 //this->mcolour = colour;
488 int i,size = lstViewShowNPoints.size();
489 for (i=0 ; i<size ; i++)
491 lstViewShowNPoints[i]->mcolour = colour;
495 //------------------------------------------------------------------------
496 void WidgetShowNPoints::SetImage(vtkImageData* image)
499 //GetModelShowNPoints()->SetImage(image);
500 int i,size = lstModelShowNPoints.size();
501 for (i=0 ; i<size ; i++)
503 lstModelShowNPoints[i]->SetImage(image);
507 //------------------------------------------------------------------------
508 void WidgetShowNPoints::SetOpacity(double opacity)
511 //this->mopacity=opacity;
512 int i,size = lstViewShowNPoints.size();
513 for (i=0 ; i<size ; i++)
515 lstViewShowNPoints[i]->mopacity = opacity;
518 // sdrOpacity->SetValue( opacity*100.0 );
519 sCtrlOpacity->SetValue( opacity*10.0 );
524 //------------------------------------------------------------------------
525 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
528 //this->renderer = renderer;
529 int i,size = lstViewShowNPoints.size();
530 for (i=0 ; i<size ; i++)
532 lstViewShowNPoints[i]->renderer = renderer;
537 //------------------------------------------------------------------------
539 void WidgetShowNPoints::RefreshPoint(int id)
543 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
544 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
545 std::string label = GetModelShowNPoints()->GetIdLabel(id);
546 double radio = GetModelShowNPoints()->GetRadio();
547 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
548 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
549 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
550 lstSourceSphere[id]->SetRadius( radio );
551 //EED 2017-01-01 Migration VTK7
552 #if VTK_MAJOR_VERSION <= 5
555 lstSourceSphere[id]->Update();
557 lstActorsText[id]->SetInput( label.c_str() );
558 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
561 //------------------------------------------------------------------------
562 void WidgetShowNPoints::RefreshPoints()
564 int id,size=lstActorsSphere.size();
565 for (id=0;id<size;id++)
569 renderer->GetRenderWindow()->Render();
572 //------------------------------------------------------------------------
573 void WidgetShowNPoints::AddVtkPoint()
576 vtkSphereSource *vtksphere = vtkSphereSource::New();
577 vtksphere->SetThetaResolution (20);
578 vtksphere->SetPhiResolution (20);
579 vtksphere->SetRadius( 1 );
580 //NTU: For updating points
581 lstSourceSphere.push_back(vtksphere);
582 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
584 //EED 2017-01-01 Migration VTK7
585 #if VTK_MAJOR_VERSION <= 5
586 sphereMapper->SetInput( vtksphere->GetOutput() );
589 sphereMapper->SetInputData( vtksphere->GetOutput() );
592 vtkActor *sphereActor = vtkActor::New();
593 sphereActor->SetMapper(sphereMapper);
594 sphereActor->SetOrigin(0, 0, 0);
596 lstActorsSphere.push_back(sphereActor);
598 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
602 renderer->AddActor( sphereActor );
604 vtkTextActor3D *textActor = vtkTextActor3D::New();
605 // textActor->SetInput( strLabel.c_str() );
606 renderer->AddActor( textActor );
607 lstActorsText.push_back(textActor);
612 void WidgetShowNPoints::SetCurrentPoint(int idCurrentPoint )
614 int size = GetModelShowNPoints()->GetLstPointsSize();
615 if (idCurrentPoint<0) { idCurrentPoint = size-1; }
616 if (idCurrentPoint>=size ) { idCurrentPoint = 0; }
617 GetModelShowNPoints()->SetIdCurrentPoint( idCurrentPoint );
618 RefreshCollectionText();
619 RefreshColourCollection();
622 void WidgetShowNPoints::OnBackPoint(wxCommandEvent &event)
624 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() - 1 );
627 void WidgetShowNPoints::OnNextPoint(wxCommandEvent &event)
629 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() + 1 );
633 //------------------------------------------------------------------------
634 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
636 GetModelShowNPoints()->AddPoint(x,y,z, label );
639 //RefreshPoint(lstActorsSphere.size()-1);
640 GetViewShowNPoints()->AddPoint();
643 //------------------------------------------------------------------------
644 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
647 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
651 // AddPoint(x,y,z,label);
654 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
656 GetViewShowNPoints()->AddVtkPoint();
658 AddPoint(x,y,z,label);
660 GetViewShowNPoints()->RefreshPoints();
663 //------------------------------------------------------------------------
664 void WidgetShowNPoints::OnInsertPoint_()
667 //if (this->renderer==NULL)
671 if (GetViewShowNPoints()->renderer==NULL)
675 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
678 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
680 } else {//mpoint.size
681 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
683 RefreshCollectionText();
684 RefreshColourCollection();
685 UndoRedo_SaveCollection();
688 //------------------------------------------------------------------------
689 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
694 //------------------------------------------------------------------------
695 void WidgetShowNPoints::OnAddPoint__()
698 //if (this->renderer==NULL)
699 if (GetViewShowNPoints()->renderer==NULL)
703 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
706 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
709 //renderer->GetRenderWindow()->Render();
710 GetViewShowNPoints()->Render();
711 UndoRedo_SaveCollection();
712 } else {//mpoint.size
713 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
717 void WidgetShowNPoints::OnAddPoint_()
724 //------------------------------------------------------------------------
725 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
730 //------------------------------------------------------------------------
731 void WidgetShowNPoints::AutoAddPoints()
733 if ( cbAutoAddPoints->GetValue() == true )
736 RefreshCollectionText();
737 RefreshColourCollection();
738 } // if cbAutoAddPoints
741 //------------------------------------------------------------------------
742 void WidgetShowNPoints::OnAutoAddPoints_tool()
745 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
748 //------------------------------------------------------------------------
749 void WidgetShowNPoints::OnAutoAddPoints_()
754 //------------------------------------------------------------------------
755 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
760 //------------------------------------------------------------------------
761 void WidgetShowNPoints::StopAutoAddPoints( )
763 cbAutoAddPoints->SetValue(false);
766 //------------------------------------------------------------------------
767 void WidgetShowNPoints::SetOutputBox()
770 if (GetModelShowNPoints()->GetIdCurrentPoint()<0)
772 strTmp.Printf(_T(" -/%d") , GetModelShowNPoints()->GetLstPointsSize() );
774 strTmp.Printf(_T(" %d/%d"), GetModelShowNPoints()->GetIdCurrentPoint()+1 , GetModelShowNPoints()->GetLstPointsSize() );
776 txtNrPoints->SetLabel( strTmp );
780 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
781 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
782 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
783 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
784 // mbbShowNPoints->bbSignalOutputModification();
788 //------------------------------------------------------------------------
789 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
792 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
793 #if wxMAJOR_VERSION <= 2
794 wxFileDialog* FD = new wxFileDialog( 0,
795 _T("Save points .."),
799 wxSAVE | wxOVERWRITE_PROMPT,
802 wxFileDialog* FD = new wxFileDialog( 0,
803 _T("Save points .."),
807 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
811 int result_FD = FD->ShowModal();
812 // This line is need it by windows //EED
813 FD->SetReturnCode( result_FD );
814 if (FD->GetReturnCode()==wxID_OK)
816 std::string filename= (const char*) ( FD->GetPath().mb_str() );
817 GetModelShowNPoints()->SavePoints( filename );
822 //------------------------------------------------------------------------
823 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
826 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
827 #if wxMAJOR_VERSION <= 2
828 wxFileDialog* FD = new wxFileDialog( 0,
829 _T("Load points .."),
833 wxOPEN | wxFILE_MUST_EXIST,
836 wxFileDialog* FD = new wxFileDialog( 0,
837 _T("Load points .."),
841 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
846 int result_FD = FD->ShowModal();
847 // This line is need it by windows //EED
848 FD->SetReturnCode( result_FD );
849 if (FD->GetReturnCode()==wxID_OK)
852 std::string filename= (const char*) ( FD->GetPath().mb_str() );
853 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
854 for (i=0;i<numberPointsRead;i++)
858 GetViewShowNPoints()->AddVtkPoint();
863 GetViewShowNPoints()->RefreshPoints();
867 //------------------------------------------------------------------------
868 void WidgetShowNPoints::OnSetPoint_()
873 //int id=GetModelShowNPoints()->GetNearestPoint();
874 int id=GetModelShowNPoints()->GetIdCurrentPoint();
876 if((id==-1) && (mtype==1))
884 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
887 //renderer->GetRenderWindow()->Render();
888 GetViewShowNPoints()->RefreshPoint(id);
889 GetViewShowNPoints()->Render();
891 RefreshCollectionText();
892 RefreshColourCollection();
894 UndoRedo_SaveCollection();
897 //------------------------------------------------------------------------
898 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
903 //------------------------------------------------------------------------
904 void WidgetShowNPoints::MovePoint_(double step)
909 int id=GetModelShowNPoints()->GetIdCurrentPoint();
912 if((GetLstModelShowNPointsSize()>=2) //Check condition
913 && (GetModelShowNPoints()->GetLstPointsSize()>0)
914 && (aux_mesh != NULL)
915 && (aux_mesh_spc.size() == 3))
919 double normal[3]; // point to modify and normal
920 std::vector<double> pN(3); // new point
921 vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New();
922 pointLocator->SetDataSet( aux_mesh );
923 pointLocator->BuildLocator();
925 // int idControlPoint = wsp->GetModelShowNPoints()->GetNearestPoint();
926 int idControlPoint = GetModelShowNPoints()->GetIdCurrentPoint();
927 if(idControlPoint >= 0)
929 GetModelShowNPoints()->GetIdPoint(idControlPoint, &x, &y, &z);
930 p[0] = x * aux_mesh_spc[0];
931 p[1] = y * aux_mesh_spc[1];
932 p[2] = z * aux_mesh_spc[2];
933 long int idMeshPoint = pointLocator->FindClosestPoint(p);
934 vtkDataArray *dataArrayNormals = aux_mesh->GetPointData()->GetNormals();
935 if (dataArrayNormals!=NULL)
937 dataArrayNormals->GetTuple(idMeshPoint, normal);
939 int direction = step;
940 // pN[0] = p[0] / spc[0] + direction*normal[0];
941 // pN[1] = p[1] / spc[1] + direction*normal[1];
942 // pN[2] = p[2] / spc[2] + direction*normal[2];
943 pN[0] = x + (direction * normal[0]);
944 pN[1] = y + (direction * normal[1]);
945 pN[2] = z + (direction * normal[2]);
946 GetModelShowNPoints()->SetPointById(idControlPoint, pN);
947 // GetViewShowNPoints()->RefreshPoint(idControlPoint);
948 // RefreshCollectionText();
949 // RefreshColourCollection();
951 UndoRedo_SaveCollection();
953 printf("Error! WidgetShowNPoints::MovePoint_ Missing normals in aux_mesh \n");
955 } // if idControlPoint
956 } // if wsp->GetLstModelShowNPointsSiz->size()>=2
961 double minX=max,minY=max,minZ=max;
962 double maxX=-max,maxY=-max,maxZ=-max;
963 sizeG = lstModelShowNPoints.size();
964 for (i=0; i<sizeG; i++)
966 std::vector<double> lstX = lstModelShowNPoints[i]->GetLstPointsX();
967 std::vector<double> lstY = lstModelShowNPoints[i]->GetLstPointsY();
968 std::vector<double> lstZ = lstModelShowNPoints[i]->GetLstPointsZ();
970 for (j=0; j<sizeP; j++)
972 if ( lstX[j]<minX ) { minX=lstX[j]; }
973 if ( lstY[j]<minY ) { minY=lstY[j]; }
974 if ( lstZ[j]<minZ ) { minZ=lstZ[j]; }
975 if ( lstX[j]>maxX ) { maxX=lstX[j]; }
976 if ( lstY[j]>maxY ) { maxY=lstY[j]; }
977 if ( lstZ[j]>maxZ ) { maxZ=lstZ[j]; }
981 pc[0]=(minX+maxX) /2 ; pc[1]=(minY+maxY) /2 ; pc[2]=(minZ+maxZ) /2 ;
983 p[0]=GetModelShowNPoints()->GetLstPointsX()[id];
984 p[1]=GetModelShowNPoints()->GetLstPointsY()[id];
985 p[2]=GetModelShowNPoints()->GetLstPointsZ()[id];
990 double mag=sqrt ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
991 std::vector<double> point;
1002 point.push_back( p[0] + step*v[0] );
1003 point.push_back( p[1] + step*v[1] );
1004 point.push_back( p[2] + step*v[2] );
1005 GetModelShowNPoints()->SetPointById(id,point);
1006 UndoRedo_SaveCollection();
1009 RefreshCollectionText();
1010 RefreshColourCollection();
1013 //------------------------------------------------------------------------
1014 void WidgetShowNPoints::OnMovePointUp(wxCommandEvent& event)
1019 //------------------------------------------------------------------------
1020 void WidgetShowNPoints::OnMovePointDown(wxCommandEvent& event)
1025 //------------------------------------------------------------------------
1026 void WidgetShowNPoints::TrackingPoint( )
1028 if ( cbTrackPoint->GetValue() == true )
1030 // int id = GetModelShowNPoints()->IdInsidePoint();
1036 // int idTrack = GetModelShowNPoints()->GetIdCurrentPoint();
1037 int idTrack = GetModelShowNPoints()->GetNearestPoint();
1042 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
1044 RefreshCollectionText();
1045 RefreshColourCollection();
1047 // GetViewShowNPoints()->RefreshPoint(idTrack);
1048 // GetViewShowNPoints()->Render();
1049 UndoRedo_SaveCollection();
1051 } // if trackPointFlag
1054 //------------------------------------------------------------------------
1055 void WidgetShowNPoints::OnTrackPoint_tool()
1057 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
1061 //------------------------------------------------------------------------
1062 void WidgetShowNPoints::OnTrackPoint_()
1064 StopAutoAddPoints();
1067 if ( cbTrackPoint->GetValue() == true )
1070 // idTrack = GetModelShowNPoints()->IdInsidePoint();
1071 // idTrack = GetModelShowNPoints()->GetIdCurrentPoint();
1072 } // if trackPointFlag
1075 //------------------------------------------------------------------------
1076 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
1081 //------------------------------------------------------------------------
1082 void WidgetShowNPoints::StopTrackPoint( )
1084 cbTrackPoint->SetValue(false);
1088 //------------------------------------------------------------------------
1089 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
1091 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
1095 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1096 //renderer->GetRenderWindow()->Render();
1097 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1098 GetViewShowNPoints()->Render();
1100 UndoRedo_SaveCollection();
1104 //------------------------------------------------------------------------
1105 bool WidgetShowNPoints::ErasePoint(int id)
1108 //if (this->renderer!=NULL)
1110 if (GetViewShowNPoints()->renderer!=NULL)
1115 //renderer->RemoveActor( lstActorsSphere[id] );
1116 //renderer->RemoveActor( lstActorsText[id] );
1117 //lstActorsSphere[id]->Delete();
1118 //lstActorsText[id]->Delete();
1119 //lstSourceSphere[id]->Delete();
1120 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
1121 //lstActorsText.erase( lstActorsText.begin()+id );
1122 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
1123 GetViewShowNPoints()->ErasePoint(id);
1124 GetModelShowNPoints()->ErasePoint(id);
1131 //------------------------------------------------------------------------
1132 void WidgetShowNPoints::OnErasePoint_()
1134 StopAutoAddPoints();
1137 //ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
1138 if (ErasePoint( GetModelShowNPoints()->GetIdCurrentPoint() ) == true)
1142 //renderer->GetRenderWindow()->Render();
1143 // GetViewShowNPoints()->Render();
1144 RefreshCollectionText();
1145 RefreshColourCollection();
1147 UndoRedo_SaveCollection();
1151 //------------------------------------------------------------------------
1152 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
1157 //------------------------------------------------------------------------
1158 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
1161 //ErasePoint( lstActorsSphere.size()-1 );
1162 //renderer->GetRenderWindow()->Render();
1163 StopAutoAddPoints();
1166 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
1169 RefreshCollectionText();
1170 RefreshColourCollection();
1172 UndoRedo_SaveCollection();
1173 GetViewShowNPoints()->Render();
1178 //------------------------------------------------------------------------
1179 void WidgetShowNPoints::DeleteAllPoints_()
1182 //int id,size=lstActorsSphere.size();
1183 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
1184 for (id=size-1;id>=0;id--)
1190 void WidgetShowNPoints::OnDeleteAllPoints_()
1192 StopAutoAddPoints();
1196 UndoRedo_SaveCollection();
1199 //------------------------------------------------------------------------
1200 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
1202 OnDeleteAllPoints_();
1204 GetViewShowNPoints()->Render();
1207 //NTU: Method for updating points opacity and Radio
1209 //------------------------------------------------------------------------
1210 void WidgetShowNPoints::UpdatePoints_()
1213 //this->mopacity = sdrOpacity->GetValue()/100.0;
1214 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
1217 // double opacity = sdrOpacity->GetValue()/100.0;
1218 // double radio = sdrRadio->GetValue();
1219 double opacity = (sCtrlOpacity->GetValue()*10)/100.0;
1220 double radio = sCtrlRadio->GetValue();
1222 int i,size = lstViewShowNPoints.size();
1223 for (i=0 ; i<size ; i++)
1225 lstViewShowNPoints[i]->mopacity = opacity;
1226 lstModelShowNPoints[i]->SetRadio( radio ) ;
1228 // GetViewShowNPoints()->RefreshPoints();
1231 //------------------------------------------------------------------------
1232 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
1234 RefreshColourCollection();
1237 //------------------------------------------------------------------------
1238 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
1240 GetModelShowNPoints()->SetReferencePoint(point);
1241 int i,size=lstModelShowNPoints.size();
1242 for (i=0;i<size;i++)
1244 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
1248 //------------------------------------------------------------------------
1249 void WidgetShowNPoints::SetActualCollection( int actual )
1256 if (actual>lstModelShowNPoints.size()-1 )
1258 actual=lstModelShowNPoints.size()-1;
1261 mActualCollection=actual;
1265 //------------------------------------------------------------------------
1266 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
1268 if (GetViewShowNPoints()->renderer==NULL)
1274 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1275 int ii,iIndexs,sizeIndexs;
1277 sizeX = (int)initLstPointsX.size();
1278 sizeY = (int)initLstPointsY.size();
1279 sizeZ = (int)initLstPointsZ.size();
1280 sizeLabels = (int)initLstLabels.size();
1281 sizeIndexs = (int)initLstIndexs.size();
1285 initLstIndexs.push_back(sizeX);
1286 sizeIndexs = (int)initLstIndexs.size();
1289 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1292 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1296 InsertCollectionAfter_();
1298 sizeTmp = initLstIndexs[iIndexs];
1299 for (ii=0;ii<sizeTmp;ii++)
1301 x = initLstPointsX[i];
1302 y = initLstPointsY[i];
1303 z = initLstPointsZ[i];
1306 label = initLstLabels[i];
1310 AddPoint( x,y,z,label );
1317 // renderer->GetRenderWindow()->Render();
1326 //if (this->renderer==NULL)
1327 if (GetViewShowNPoints()->renderer==NULL)
1331 int i,sizeX,sizeY,sizeZ,sizeLabels;
1332 sizeX = (int)initLstPointsX.size();
1333 sizeY = (int)initLstPointsY.size();
1334 sizeZ = (int)initLstPointsZ.size();
1335 sizeLabels = (int)initLstLabels.size();
1338 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1340 for (i=0;i<sizeX;i++)
1342 x = initLstPointsX[i];
1343 y = initLstPointsY[i];
1344 z = initLstPointsZ[i];
1347 label = initLstLabels[i];
1351 AddPoint( x,y,z,label );
1354 // renderer->GetRenderWindow()->Render();
1360 //------------------------------------------------------------------------
1361 void WidgetShowNPoints::SetType(int type)
1366 //------------------------------------------------------------------------
1367 int WidgetShowNPoints::GetType()
1373 //------------------------------------------------------------------------
1374 double WidgetShowNPoints::GetRadio()
1376 // return sdrRadio->GetValue();
1377 return sCtrlRadio->GetValue();
1379 //------------------------------------------------------------------------
1380 double WidgetShowNPoints::GetOpacity()
1382 // return sdrOpacity->GetValue()/100;
1383 return (sCtrlOpacity->GetValue()*10)/100.0;
1386 //------------------------------------------------------------------------
1387 void WidgetShowNPoints::InsertCollection()
1389 ModelShowNPoints* model = new ModelShowNPoints();
1390 ViewShowNPoints* view = new ViewShowNPoints( model );
1391 view->mopacity = lstViewShowNPoints[0]->mopacity;
1392 view->renderer = lstViewShowNPoints[0]->renderer;
1393 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1394 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1395 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1398 //------------------------------------------------------------------------
1399 void WidgetShowNPoints::InsertCollectionBefore_()
1402 RefreshCollectionText();
1403 RefreshColourCollection();
1407 //------------------------------------------------------------------------
1408 void WidgetShowNPoints::OnInsertCollectionBefore_()
1410 InsertCollectionBefore_();
1411 CreatePointsIntoNewCollection();
1412 UndoRedo_SaveCollection();
1416 //------------------------------------------------------------------------
1417 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1419 OnInsertCollectionBefore_();
1423 //------------------------------------------------------------------------
1424 void WidgetShowNPoints::InsertCollectionAfter_()
1426 mActualCollection++;
1428 RefreshCollectionText();
1429 RefreshColourCollection();
1434 //------------------------------------------------------------------------
1435 void WidgetShowNPoints::OnInsertCollectionAfter_()
1437 InsertCollectionAfter_();
1438 CreatePointsIntoNewCollection();
1439 UndoRedo_SaveCollection();
1442 //------------------------------------------------------------------------
1443 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1445 OnInsertCollectionAfter_();
1448 //------------------------------------------------------------------------
1449 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1451 int c1 = mActualCollection-1;
1452 int c2 = mActualCollection+1;
1453 int modelSize = lstModelShowNPoints.size();
1454 if (aux_mesh_type==2) // SplineClose2
1456 if (c1==-1) { c1=modelSize-1; }
1457 if (c2==modelSize) { c2=0; }
1458 } // if aux_mesh_type
1460 if ( (c1!=c2) && (c1>=0) && (c1<modelSize) && (c2>=0) && (c2<modelSize) )
1462 std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1463 std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1464 std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1465 std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1466 std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1467 std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1468 std::vector<double> c1LstXX;
1469 std::vector<double> c1LstYY;
1470 std::vector<double> c1LstZZ;
1471 std::vector<double> c2LstXX;
1472 std::vector<double> c2LstYY;
1473 std::vector<double> c2LstZZ;
1474 creaContoursFactory f;
1475 manualContourModel *m;
1478 int sc; // sizeContour
1480 if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1482 // ----------------- Spline 1 --------------------
1484 size = c1LstX.size();
1485 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1486 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1487 m->SetNumberOfPointsSpline( sc );
1488 m->SetCloseContour( false );
1489 for (i=0;i<size;i++)
1491 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1496 m->GetSpline_i_Point(i,&x,&y,&z);
1497 c1LstXX.push_back(x);
1498 c1LstYY.push_back(y);
1499 c1LstZZ.push_back(z);
1502 // ----------------- Spline 2 --------------------
1503 size = c2LstX.size();
1504 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1505 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1506 m->SetNumberOfPointsSpline( sc );
1507 m->SetCloseContour( false );
1508 for (i=0;i<size;i++)
1510 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1515 m->GetSpline_i_Point(i,&x,&y,&z);
1516 c2LstXX.push_back(x);
1517 c2LstYY.push_back(y);
1518 c2LstZZ.push_back(z);
1521 // ----------------- Add new Points --------------------
1522 vtkPoints *points = NULL;
1523 vtkStaticPointLocator *pointLocator = NULL;
1526 points = aux_mesh->GetPoints();
1527 pointLocator = vtkStaticPointLocator::New();
1528 pointLocator->SetDataSet( aux_mesh );
1529 pointLocator->BuildLocator();
1533 if ( c1LstX.size()<c2LstX.size() ) { size=c2LstX.size(); } else { size=c1LstX.size(); }
1534 for (ii=0;ii<size;ii++)
1536 i = (int) ((double)ii/((double)size-1)*(sc-1));
1537 x = (c1LstXX[i]+c2LstXX[i])/2;
1538 y = (c1LstYY[i]+c2LstYY[i])/2;
1539 z = (c1LstZZ[i]+c2LstZZ[i])/2;
1542 p[0] = x * aux_mesh_spc[0];
1543 p[1] = y * aux_mesh_spc[1];
1544 p[2] = z * aux_mesh_spc[2];
1545 points->GetPoint( pointLocator->FindClosestPoint(p) , pM );
1546 x = pM[0] / aux_mesh_spc[0];
1547 y = pM[1] / aux_mesh_spc[1];
1548 z = pM[2] / aux_mesh_spc[2];
1552 if (pointLocator!=NULL) { pointLocator->Delete(); }
1553 RefreshCollectionText();
1554 RefreshColourCollection();
1555 } // if size of c1LstX c2LstX
1559 //------------------------------------------------------------------------
1560 void WidgetShowNPoints::DeleteCollection_()
1562 if ( lstModelShowNPoints.size()>1 )
1564 DeleteAllPoints_(); // Actual Collection
1565 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1566 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1567 if ( mActualCollection>=lstModelShowNPoints.size() )
1569 mActualCollection--;
1572 DeleteAllPoints_(); // Actual Collection
1576 //------------------------------------------------------------------------
1577 void WidgetShowNPoints::OnDeleteCollection_()
1579 DeleteCollection_();
1581 GetViewShowNPoints()->Render();
1582 RefreshCollectionText();
1583 RefreshColourCollection();
1585 UndoRedo_SaveCollection();
1588 //------------------------------------------------------------------------
1589 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1591 OnDeleteCollection_();
1594 //------------------------------------------------------------------------
1595 void WidgetShowNPoints::ResetCollections_()
1597 int i,size=lstModelShowNPoints.size();
1598 for (i=0;i<size;i++)
1600 DeleteCollection_();
1602 GetViewShowNPoints()->Render();
1603 RefreshCollectionText();
1604 RefreshColourCollection();
1609 //------------------------------------------------------------------------
1610 void WidgetShowNPoints::OnResetCollections_()
1612 ResetCollections_();
1613 UndoRedo_SaveCollection();
1617 //------------------------------------------------------------------------
1618 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1620 OnResetCollections_();
1623 //------------------------------------------------------------------------
1624 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1626 mActualCollection--;
1627 if ( mActualCollection <0 )
1629 // mActualCollection=0;
1630 mActualCollection = lstModelShowNPoints.size()-1;
1632 RefreshCollectionText();
1633 RefreshColourCollection();
1635 UndoRedo_SaveCollection();
1638 //------------------------------------------------------------------------
1639 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1641 mActualCollection++;
1642 if ( mActualCollection >=lstModelShowNPoints.size() )
1644 // mActualCollection = lstModelShowNPoints.size()-1;
1645 mActualCollection = 0;
1646 } //if mActualCollection >= size
1647 RefreshCollectionText();
1648 RefreshColourCollection();
1650 UndoRedo_SaveCollection();
1653 //------------------------------------------------------------------------
1654 void WidgetShowNPoints::DetectCollectionActive()
1657 int i,size=lstModelShowNPoints.size();
1658 for (i=0;i<size;i++)
1660 id = lstModelShowNPoints[i]->IdInsidePoint();
1663 mActualCollection=i;
1666 RefreshCollectionText();
1667 RefreshColourCollection();
1670 //------------------------------------------------------------------------
1671 void WidgetShowNPoints::RefreshColourCollection()
1674 std::vector<double> colourAll;
1675 colourAll.push_back(1);
1676 colourAll.push_back(0);
1677 colourAll.push_back(0);
1678 std::vector<double> colourActualGroup;
1679 colourActualGroup.push_back(1);
1680 colourActualGroup.push_back(1);
1681 colourActualGroup.push_back(0);
1683 // For all collections
1684 SetColour( colourAll );
1685 int i,size=lstViewShowNPoints.size();
1686 for (i=0;i<size;i++)
1688 lstViewShowNPoints[i] -> mcolour = colourAll;
1689 lstViewShowNPoints[i] -> ratioRadio = 1;
1690 if ((cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==true))
1692 lstViewShowNPoints[i] -> mopacity = 0.0;
1694 lstViewShowNPoints[i] -> mopacity = sCtrlOpacity->GetValue()*10.0/100.0;
1696 lstViewShowNPoints[i]->RefreshEachPoint();
1699 // Actual collection
1700 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1701 lstViewShowNPoints[mActualCollection] -> mopacity = sCtrlOpacity->GetValue()*10.0/100.0;
1702 lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.1;
1703 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1706 int curPnt = lstModelShowNPoints[mActualCollection] -> GetIdCurrentPoint();
1707 size=lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1708 if ((curPnt>=0) && (curPnt<size ) )
1710 std::vector<double> colourActualPoint;
1711 colourActualPoint.push_back(0);
1712 colourActualPoint.push_back(0);
1713 colourActualPoint.push_back(1);
1714 double radio = GetModelShowNPoints()->GetRadio();
1715 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1716 lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt );
1717 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1719 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1722 //------------------------------------------------------------------------
1723 void WidgetShowNPoints::RefreshCollectionText()
1725 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1728 strTmp.Printf(_T(" %d/%d"), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1729 txtNrCollections->SetLabel( strTmp );
1735 //------------------------------------------------------------------------
1736 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1739 ff = fopen( filename.c_str() , "w+" );
1742 int i,size = lstModelShowNPoints.size();
1743 fprintf(ff,"NumberOfGroups %d \n",size);
1744 for (i=0 ; i<size ; i++)
1746 lstModelShowNPoints[i]->SavePoints_(ff);
1750 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1756 //------------------------------------------------------------------------
1757 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1759 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1760 #if wxMAJOR_VERSION <= 2
1761 wxFileDialog* FD = new wxFileDialog( 0,
1762 _T("Save groups of points .."),
1765 _T("(*.xls)|*.xls"),
1766 wxSAVE | wxOVERWRITE_PROMPT,
1769 wxFileDialog* FD = new wxFileDialog( 0,
1770 _T("Save groups of points .."),
1773 _T("(*.xls)|*.xls"),
1774 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1778 int result_FD = FD->ShowModal();
1779 // This line is need it by windows //EED
1780 FD->SetReturnCode( result_FD );
1781 if (FD->GetReturnCode()==wxID_OK)
1783 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1784 OnSaveCollections_( filename );
1789 //------------------------------------------------------------------------
1790 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1792 bool okEraseFirstGroup=false;
1793 if (lstModelShowNPoints.size()==1)
1795 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1797 FILE *ff = fopen( filename.c_str() , "r+" );
1801 int iGroup,sizeGroups;
1802 int iPoint,numberPointsRead;
1804 fscanf(ff," %s %d",chartmp,&sizeGroups);
1805 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1807 mActualCollection = lstModelShowNPoints.size();
1809 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1810 for (i=0;i<numberPointsRead;i++)
1814 GetViewShowNPoints()->AddVtkPoint();
1820 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1822 if (okEraseFirstGroup==true)
1824 mActualCollection=0;
1825 DeleteCollection_();
1826 mActualCollection = lstModelShowNPoints.size()-1;
1828 GetViewShowNPoints()->Render();
1829 RefreshCollectionText();
1830 RefreshColourCollection();
1834 //------------------------------------------------------------------------
1835 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1837 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1838 #if wxMAJOR_VERSION <= 2
1839 wxFileDialog* FD = new wxFileDialog( 0,
1840 _T("Load groups of points .."),
1843 _T("(*.xls)|*.xls"),
1844 wxOPEN | wxFILE_MUST_EXIST,
1847 wxFileDialog* FD = new wxFileDialog( 0,
1848 _T("Load groups of points .."),
1851 _T("(*.xls)|*.xls"),
1852 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1855 int result_FD = FD->ShowModal();
1856 // This line is need it by windows //EED
1857 FD->SetReturnCode( result_FD );
1858 if (FD->GetReturnCode()==wxID_OK)
1860 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1861 OnLoadCollections_( filename );
1862 UndoRedo_SaveCollection();
1866 //------------------------------------------------------------------------
1867 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1870 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1875 //------------------------------------------------------------------------
1876 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1878 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1880 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1881 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1884 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1887 //------------------------------------------------------------------------
1888 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1892 return GetModelShowNPoints()->GetLstPointsX();
1894 std::vector<double> lst;
1896 int iG,sG=lstModelShowNPoints.size();
1897 for (iG=0 ; iG<sG ; iG++)
1899 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1901 for (iP=0 ; iP<s ; iP++)
1903 lst.push_back( lstTmp[iP] );
1910 //------------------------------------------------------------------------
1911 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1915 return GetModelShowNPoints()->GetLstPointsY();
1917 std::vector<double> lst;
1919 int iG,sG=lstModelShowNPoints.size();
1920 for (iG=0 ; iG<sG ; iG++)
1922 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1924 for (iP=0 ; iP<s ; iP++)
1926 lst.push_back( lstTmp[iP] );
1933 //------------------------------------------------------------------------
1934 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1938 return GetModelShowNPoints()->GetLstPointsZ();
1940 std::vector<double> lst;
1942 int iG,sG=lstModelShowNPoints.size();
1943 for (iG=0 ; iG<sG ; iG++)
1945 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1947 for (iP=0 ; iP<s ; iP++)
1949 lst.push_back( lstTmp[iP] );
1957 //------------------------------------------------------------------------
1958 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1962 return GetModelShowNPoints()->GetLstLabels();
1964 std::vector< std::string > lst;
1966 int iG,sG=lstModelShowNPoints.size();
1967 for (iG=0 ; iG<sG ; iG++)
1969 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1971 for (iP=0 ; iP<s ; iP++)
1973 lst.push_back( lstTmp[iP] );
1980 //------------------------------------------------------------------------
1981 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1983 std::vector<int> lstIndexs;
1986 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1988 int iG,sG=lstModelShowNPoints.size();
1989 for (iG=0 ; iG<sG ; iG++)
1991 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1997 //------------------------------------------------------------------------
1998 std::vector<int> WidgetShowNPoints::GetLstSelectedIndexs()
2000 std::vector<int> lstSelectedIndexs;
2001 if ( (cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==true) )
2003 lstSelectedIndexs.push_back( mActualCollection );
2005 return lstSelectedIndexs;
2008 //------------------------------------------------------------------------
2009 int WidgetShowNPoints::GetLstModelShowNPointsSize()
2011 return lstModelShowNPoints.size();
2014 //------------------------------------------------------------------------
2015 void WidgetShowNPoints::InvertLstPoints_()
2017 int i,size=lstModelShowNPoints.size();
2019 for (i=0 ; i < size ; i++)
2021 lstModelShowNPoints[i]->InversLstPoints();
2025 ModelShowNPoints* tmpModel;
2027 for (i=0 ; i < size2 ; i++)
2029 tmpModel = lstModelShowNPoints[i];
2030 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
2031 lstModelShowNPoints[size-1-i] = tmpModel;
2036 //------------------------------------------------------------------------
2037 void WidgetShowNPoints::OnInvertLstPoints_()
2039 StopAutoAddPoints();
2043 UndoRedo_SaveCollection();
2047 //------------------------------------------------------------------------
2048 std::string WidgetShowNPoints::GetUndoRedoFileName()
2051 sprintf(buff,"%p_%d",this, idUndoRedo);
2052 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
2056 //------------------------------------------------------------------------
2057 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
2059 ResetCollections_();
2060 // if (idUndoRedo==maxUndoRedo+1)
2063 // } // if idUndoRedo+1
2070 OnLoadCollections_( GetUndoRedoFileName() );
2076 //------------------------------------------------------------------------
2077 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
2079 if (idUndoRedo>maxUndoRedo)
2081 idUndoRedo=maxUndoRedo+1;
2083 ResetCollections_();
2084 OnLoadCollections_( GetUndoRedoFileName() );
2089 //------------------------------------------------------------------------
2090 void WidgetShowNPoints::UndoRedo_SaveCollection()
2092 OnSaveCollections_( GetUndoRedoFileName() );
2093 maxUndoRedo = idUndoRedo;
2097 //------------------------------------------------------------------------
2098 void WidgetShowNPoints::SetAuxMesh(vtkPolyData* mesh, std::vector<double> spc, std::vector<double> params)
2102 if (params.size()==1)
2104 aux_mesh_type = params[0];
2110 //------------------------------------------------------------------------
2111 void WidgetShowNPoints::OnVisuActualCollection(wxCommandEvent &event)
2113 printf("EED WidgetShowNPoints::OnVisuActualCollection \n");
2114 RefreshCollectionText();
2115 RefreshColourCollection();