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("Cur.") , 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("Current group") );
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)
672 if (GetViewShowNPoints()->renderer==NULL)
676 UndoRedo_SaveCollection(); //A
677 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
680 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
682 } else {//mpoint.size
683 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
685 RefreshCollectionText();
686 RefreshColourCollection();
687 UndoRedo_SaveCollection(); //B
690 //------------------------------------------------------------------------
691 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
696 //------------------------------------------------------------------------
697 void WidgetShowNPoints::OnAddPoint__()
700 //if (this->renderer==NULL)
701 if (GetViewShowNPoints()->renderer==NULL)
705 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
708 UndoRedo_SaveCollection(); //A
709 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
712 //renderer->GetRenderWindow()->Render();
713 GetViewShowNPoints()->Render();
714 UndoRedo_SaveCollection(); //B
715 } else {//mpoint.size
716 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
720 void WidgetShowNPoints::OnAddPoint_()
727 //------------------------------------------------------------------------
728 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
733 //------------------------------------------------------------------------
734 void WidgetShowNPoints::AutoAddPoints()
736 if ( cbAutoAddPoints->GetValue() == true )
739 RefreshCollectionText();
740 RefreshColourCollection();
741 } // if cbAutoAddPoints
744 //------------------------------------------------------------------------
745 void WidgetShowNPoints::OnAutoAddPoints_tool()
748 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
751 //------------------------------------------------------------------------
752 void WidgetShowNPoints::OnAutoAddPoints_()
757 //------------------------------------------------------------------------
758 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
763 //------------------------------------------------------------------------
764 void WidgetShowNPoints::StopAutoAddPoints( )
766 cbAutoAddPoints->SetValue(false);
769 //------------------------------------------------------------------------
770 void WidgetShowNPoints::SetOutputBox()
773 if (GetModelShowNPoints()->GetIdCurrentPoint()<0)
775 strTmp.Printf(_T(" -/%d") , GetModelShowNPoints()->GetLstPointsSize() );
777 strTmp.Printf(_T(" %d/%d"), GetModelShowNPoints()->GetIdCurrentPoint()+1 , GetModelShowNPoints()->GetLstPointsSize() );
779 txtNrPoints->SetLabel( strTmp );
783 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
784 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
785 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
786 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
787 // mbbShowNPoints->bbSignalOutputModification();
791 //------------------------------------------------------------------------
792 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
795 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
796 #if wxMAJOR_VERSION <= 2
797 wxFileDialog* FD = new wxFileDialog( 0,
798 _T("Save points .."),
802 wxSAVE | wxOVERWRITE_PROMPT,
805 wxFileDialog* FD = new wxFileDialog( 0,
806 _T("Save points .."),
810 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
814 int result_FD = FD->ShowModal();
815 // This line is need it by windows //EED
816 FD->SetReturnCode( result_FD );
817 if (FD->GetReturnCode()==wxID_OK)
819 std::string filename= (const char*) ( FD->GetPath().mb_str() );
820 GetModelShowNPoints()->SavePoints( filename );
825 //------------------------------------------------------------------------
826 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
829 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
830 #if wxMAJOR_VERSION <= 2
831 wxFileDialog* FD = new wxFileDialog( 0,
832 _T("Load points .."),
836 wxOPEN | wxFILE_MUST_EXIST,
839 wxFileDialog* FD = new wxFileDialog( 0,
840 _T("Load points .."),
844 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
849 int result_FD = FD->ShowModal();
850 // This line is need it by windows //EED
851 FD->SetReturnCode( result_FD );
852 if (FD->GetReturnCode()==wxID_OK)
855 std::string filename= (const char*) ( FD->GetPath().mb_str() );
856 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
857 for (i=0;i<numberPointsRead;i++)
861 GetViewShowNPoints()->AddVtkPoint();
866 GetViewShowNPoints()->RefreshPoints();
870 //------------------------------------------------------------------------
871 void WidgetShowNPoints::OnSetPoint_()
873 UndoRedo_SaveCollection(); //A
878 //int id=GetModelShowNPoints()->GetNearestPoint();
879 int id=GetModelShowNPoints()->GetIdCurrentPoint();
881 if((id==-1) && (mtype==1))
889 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
892 //renderer->GetRenderWindow()->Render();
893 GetViewShowNPoints()->RefreshPoint(id);
894 GetViewShowNPoints()->Render();
896 RefreshCollectionText();
897 RefreshColourCollection();
899 UndoRedo_SaveCollection(); //B
902 //------------------------------------------------------------------------
903 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
908 //------------------------------------------------------------------------
909 void WidgetShowNPoints::MovePoint_(double step)
914 int id=GetModelShowNPoints()->GetIdCurrentPoint();
917 if((GetLstModelShowNPointsSize()>=2) //Check condition
918 && (GetModelShowNPoints()->GetLstPointsSize()>0)
919 && (aux_mesh != NULL)
920 && (aux_mesh_spc.size() == 3))
924 double normal[3]; // point to modify and normal
925 std::vector<double> pN(3); // new point
926 vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New();
927 pointLocator->SetDataSet( aux_mesh );
928 pointLocator->BuildLocator();
930 // int idControlPoint = wsp->GetModelShowNPoints()->GetNearestPoint();
931 int idControlPoint = GetModelShowNPoints()->GetIdCurrentPoint();
932 if(idControlPoint >= 0)
934 GetModelShowNPoints()->GetIdPoint(idControlPoint, &x, &y, &z);
935 p[0] = x * aux_mesh_spc[0];
936 p[1] = y * aux_mesh_spc[1];
937 p[2] = z * aux_mesh_spc[2];
938 long int idMeshPoint = pointLocator->FindClosestPoint(p);
939 vtkDataArray *dataArrayNormals = aux_mesh->GetPointData()->GetNormals();
940 if (dataArrayNormals!=NULL)
942 dataArrayNormals->GetTuple(idMeshPoint, normal);
943 int direction = step;
944 // pN[0] = p[0] / spc[0] + direction*normal[0];
945 // pN[1] = p[1] / spc[1] + direction*normal[1];
946 // pN[2] = p[2] / spc[2] + direction*normal[2];
947 pN[0] = x + (direction * normal[0]);
948 pN[1] = y + (direction * normal[1]);
949 pN[2] = z + (direction * normal[2]);
950 UndoRedo_SaveCollection(); //A
951 GetModelShowNPoints()->SetPointById(idControlPoint, pN);
952 // GetViewShowNPoints()->RefreshPoint(idControlPoint);
953 // RefreshCollectionText();
954 // RefreshColourCollection();
956 UndoRedo_SaveCollection(); //B
958 printf("Error! WidgetShowNPoints::MovePoint_ Missing normals in aux_mesh \n");
960 } // if idControlPoint
961 } // if wsp->GetLstModelShowNPointsSiz->size()>=2
966 double minX=max,minY=max,minZ=max;
967 double maxX=-max,maxY=-max,maxZ=-max;
968 sizeG = lstModelShowNPoints.size();
969 for (i=0; i<sizeG; i++)
971 std::vector<double> lstX = lstModelShowNPoints[i]->GetLstPointsX();
972 std::vector<double> lstY = lstModelShowNPoints[i]->GetLstPointsY();
973 std::vector<double> lstZ = lstModelShowNPoints[i]->GetLstPointsZ();
975 for (j=0; j<sizeP; j++)
977 if ( lstX[j]<minX ) { minX=lstX[j]; }
978 if ( lstY[j]<minY ) { minY=lstY[j]; }
979 if ( lstZ[j]<minZ ) { minZ=lstZ[j]; }
980 if ( lstX[j]>maxX ) { maxX=lstX[j]; }
981 if ( lstY[j]>maxY ) { maxY=lstY[j]; }
982 if ( lstZ[j]>maxZ ) { maxZ=lstZ[j]; }
986 pc[0]=(minX+maxX) /2 ; pc[1]=(minY+maxY) /2 ; pc[2]=(minZ+maxZ) /2 ;
988 p[0]=GetModelShowNPoints()->GetLstPointsX()[id];
989 p[1]=GetModelShowNPoints()->GetLstPointsY()[id];
990 p[2]=GetModelShowNPoints()->GetLstPointsZ()[id];
995 double mag=sqrt ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
996 std::vector<double> point;
1007 UndoRedo_SaveCollection(); //A
1008 point.push_back( p[0] + step*v[0] );
1009 point.push_back( p[1] + step*v[1] );
1010 point.push_back( p[2] + step*v[2] );
1011 GetModelShowNPoints()->SetPointById(id,point);
1012 UndoRedo_SaveCollection(); //B
1015 RefreshCollectionText();
1016 RefreshColourCollection();
1019 //------------------------------------------------------------------------
1020 void WidgetShowNPoints::OnMovePointUp(wxCommandEvent& event)
1025 //------------------------------------------------------------------------
1026 void WidgetShowNPoints::OnMovePointDown(wxCommandEvent& event)
1031 //------------------------------------------------------------------------
1032 void WidgetShowNPoints::TrackingPoint( )
1034 if ( cbTrackPoint->GetValue() == true )
1036 // int id = GetModelShowNPoints()->IdInsidePoint();
1042 // int idTrack = GetModelShowNPoints()->GetIdCurrentPoint();
1043 int idTrack = GetModelShowNPoints()->GetNearestPoint();
1048 UndoRedo_SaveCollection(); //A
1049 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
1051 RefreshCollectionText();
1052 RefreshColourCollection();
1054 // GetViewShowNPoints()->RefreshPoint(idTrack);
1055 // GetViewShowNPoints()->Render();
1056 UndoRedo_SaveCollection(); //B
1058 } // if trackPointFlag
1061 //------------------------------------------------------------------------
1062 void WidgetShowNPoints::OnTrackPoint_tool()
1064 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
1068 //------------------------------------------------------------------------
1069 void WidgetShowNPoints::OnTrackPoint_()
1071 StopAutoAddPoints();
1074 if ( cbTrackPoint->GetValue() == true )
1077 // idTrack = GetModelShowNPoints()->IdInsidePoint();
1078 // idTrack = GetModelShowNPoints()->GetIdCurrentPoint();
1079 } // if trackPointFlag
1082 //------------------------------------------------------------------------
1083 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
1088 //------------------------------------------------------------------------
1089 void WidgetShowNPoints::StopTrackPoint( )
1091 cbTrackPoint->SetValue(false);
1095 //------------------------------------------------------------------------
1096 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
1098 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
1102 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1103 //renderer->GetRenderWindow()->Render();
1104 UndoRedo_SaveCollection(); //A
1105 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1106 GetViewShowNPoints()->Render();
1108 UndoRedo_SaveCollection(); //B
1112 //------------------------------------------------------------------------
1113 bool WidgetShowNPoints::ErasePoint(int id)
1116 //if (this->renderer!=NULL)
1118 if (GetViewShowNPoints()->renderer!=NULL)
1123 //renderer->RemoveActor( lstActorsSphere[id] );
1124 //renderer->RemoveActor( lstActorsText[id] );
1125 //lstActorsSphere[id]->Delete();
1126 //lstActorsText[id]->Delete();
1127 //lstSourceSphere[id]->Delete();
1128 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
1129 //lstActorsText.erase( lstActorsText.begin()+id );
1130 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
1131 GetViewShowNPoints()->ErasePoint(id);
1132 GetModelShowNPoints()->ErasePoint(id);
1139 //------------------------------------------------------------------------
1140 void WidgetShowNPoints::OnErasePoint_()
1142 StopAutoAddPoints();
1145 //ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
1146 UndoRedo_SaveCollection(); //A
1147 if (ErasePoint( GetModelShowNPoints()->GetIdCurrentPoint() ) == true)
1151 //renderer->GetRenderWindow()->Render();
1152 // GetViewShowNPoints()->Render();
1153 RefreshCollectionText();
1154 RefreshColourCollection();
1156 UndoRedo_SaveCollection(); //B
1160 //------------------------------------------------------------------------
1161 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
1166 //------------------------------------------------------------------------
1167 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
1170 //ErasePoint( lstActorsSphere.size()-1 );
1171 //renderer->GetRenderWindow()->Render();
1172 StopAutoAddPoints();
1175 UndoRedo_SaveCollection(); //A
1176 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
1179 RefreshCollectionText();
1180 RefreshColourCollection();
1182 UndoRedo_SaveCollection(); //B
1183 GetViewShowNPoints()->Render();
1188 //------------------------------------------------------------------------
1189 void WidgetShowNPoints::DeleteAllPoints_()
1192 //int id,size=lstActorsSphere.size();
1193 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
1194 for (id=size-1;id>=0;id--)
1200 void WidgetShowNPoints::OnDeleteAllPoints_()
1202 StopAutoAddPoints();
1205 UndoRedo_SaveCollection(); //A
1207 UndoRedo_SaveCollection(); //B
1210 //------------------------------------------------------------------------
1211 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
1213 OnDeleteAllPoints_();
1215 GetViewShowNPoints()->Render();
1218 //NTU: Method for updating points opacity and Radio
1220 //------------------------------------------------------------------------
1221 void WidgetShowNPoints::UpdatePoints_()
1224 //this->mopacity = sdrOpacity->GetValue()/100.0;
1225 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
1228 // double opacity = sdrOpacity->GetValue()/100.0;
1229 // double radio = sdrRadio->GetValue();
1230 double opacity = (sCtrlOpacity->GetValue()*10)/100.0;
1231 double radio = sCtrlRadio->GetValue();
1233 int i,size = lstViewShowNPoints.size();
1234 for (i=0 ; i<size ; i++)
1236 lstViewShowNPoints[i]->mopacity = opacity;
1237 lstModelShowNPoints[i]->SetRadio( radio ) ;
1239 // GetViewShowNPoints()->RefreshPoints();
1242 //------------------------------------------------------------------------
1243 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
1245 RefreshColourCollection();
1248 //------------------------------------------------------------------------
1249 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
1251 GetModelShowNPoints()->SetReferencePoint(point);
1252 int i,size=lstModelShowNPoints.size();
1253 for (i=0;i<size;i++)
1255 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
1259 //------------------------------------------------------------------------
1260 void WidgetShowNPoints::SetActualCollection( int actual )
1267 if (actual>lstModelShowNPoints.size()-1 )
1269 actual=lstModelShowNPoints.size()-1;
1272 mActualCollection=actual;
1276 //------------------------------------------------------------------------
1277 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
1279 if (GetViewShowNPoints()->renderer==NULL)
1285 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1286 int ii,iIndexs,sizeIndexs;
1288 sizeX = (int)initLstPointsX.size();
1289 sizeY = (int)initLstPointsY.size();
1290 sizeZ = (int)initLstPointsZ.size();
1291 sizeLabels = (int)initLstLabels.size();
1292 sizeIndexs = (int)initLstIndexs.size();
1296 initLstIndexs.push_back(sizeX);
1297 sizeIndexs = (int)initLstIndexs.size();
1300 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1303 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1307 InsertCollectionAfter_();
1309 sizeTmp = initLstIndexs[iIndexs];
1310 for (ii=0;ii<sizeTmp;ii++)
1312 x = initLstPointsX[i];
1313 y = initLstPointsY[i];
1314 z = initLstPointsZ[i];
1317 label = initLstLabels[i];
1321 AddPoint( x,y,z,label );
1328 // renderer->GetRenderWindow()->Render();
1337 //if (this->renderer==NULL)
1338 if (GetViewShowNPoints()->renderer==NULL)
1342 int i,sizeX,sizeY,sizeZ,sizeLabels;
1343 sizeX = (int)initLstPointsX.size();
1344 sizeY = (int)initLstPointsY.size();
1345 sizeZ = (int)initLstPointsZ.size();
1346 sizeLabels = (int)initLstLabels.size();
1349 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1351 for (i=0;i<sizeX;i++)
1353 x = initLstPointsX[i];
1354 y = initLstPointsY[i];
1355 z = initLstPointsZ[i];
1358 label = initLstLabels[i];
1362 AddPoint( x,y,z,label );
1365 // renderer->GetRenderWindow()->Render();
1371 //------------------------------------------------------------------------
1372 void WidgetShowNPoints::SetType(int type)
1377 //------------------------------------------------------------------------
1378 int WidgetShowNPoints::GetType()
1384 //------------------------------------------------------------------------
1385 double WidgetShowNPoints::GetRadio()
1387 // return sdrRadio->GetValue();
1388 return sCtrlRadio->GetValue();
1390 //------------------------------------------------------------------------
1391 double WidgetShowNPoints::GetOpacity()
1393 // return sdrOpacity->GetValue()/100;
1394 return (sCtrlOpacity->GetValue()*10)/100.0;
1397 //------------------------------------------------------------------------
1398 void WidgetShowNPoints::InsertCollection()
1400 ModelShowNPoints* model = new ModelShowNPoints();
1401 ViewShowNPoints* view = new ViewShowNPoints( model );
1402 view->mopacity = lstViewShowNPoints[0]->mopacity;
1403 view->renderer = lstViewShowNPoints[0]->renderer;
1404 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1405 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1406 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1409 //------------------------------------------------------------------------
1410 void WidgetShowNPoints::InsertCollectionBefore_()
1413 RefreshCollectionText();
1414 RefreshColourCollection();
1418 //------------------------------------------------------------------------
1419 void WidgetShowNPoints::OnInsertCollectionBefore_()
1421 UndoRedo_SaveCollection(); //A
1422 InsertCollectionBefore_();
1423 CreatePointsIntoNewCollection();
1424 UndoRedo_SaveCollection(); //B
1428 //------------------------------------------------------------------------
1429 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1431 OnInsertCollectionBefore_();
1435 //------------------------------------------------------------------------
1436 void WidgetShowNPoints::InsertCollectionAfter_()
1438 mActualCollection++;
1440 RefreshCollectionText();
1441 RefreshColourCollection();
1446 //------------------------------------------------------------------------
1447 void WidgetShowNPoints::OnInsertCollectionAfter_()
1449 UndoRedo_SaveCollection(); //A
1450 InsertCollectionAfter_();
1451 CreatePointsIntoNewCollection();
1452 UndoRedo_SaveCollection(); //B
1455 //------------------------------------------------------------------------
1456 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1458 OnInsertCollectionAfter_();
1461 //------------------------------------------------------------------------
1462 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1464 int c1 = mActualCollection-1;
1465 int c2 = mActualCollection+1;
1466 int modelSize = lstModelShowNPoints.size();
1467 if (aux_mesh_type==2) // SplineClose2
1469 if (c1==-1) { c1=modelSize-1; }
1470 if (c2==modelSize) { c2=0; }
1471 } // if aux_mesh_type
1473 if ( (c1!=c2) && (c1>=0) && (c1<modelSize) && (c2>=0) && (c2<modelSize) )
1475 std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1476 std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1477 std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1478 std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1479 std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1480 std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1481 std::vector<double> c1LstXX;
1482 std::vector<double> c1LstYY;
1483 std::vector<double> c1LstZZ;
1484 std::vector<double> c2LstXX;
1485 std::vector<double> c2LstYY;
1486 std::vector<double> c2LstZZ;
1487 creaContoursFactory f;
1488 manualContourModel *m;
1491 int sc; // sizeContour
1493 if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1495 // ----------------- Spline 1 --------------------
1497 size = c1LstX.size();
1498 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1499 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1500 m->SetNumberOfPointsSpline( sc );
1501 m->SetCloseContour( false );
1502 for (i=0;i<size;i++)
1504 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1509 m->GetSpline_i_Point(i,&x,&y,&z);
1510 c1LstXX.push_back(x);
1511 c1LstYY.push_back(y);
1512 c1LstZZ.push_back(z);
1515 // ----------------- Spline 2 --------------------
1516 size = c2LstX.size();
1517 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1518 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1519 m->SetNumberOfPointsSpline( sc );
1520 m->SetCloseContour( false );
1521 for (i=0;i<size;i++)
1523 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1528 m->GetSpline_i_Point(i,&x,&y,&z);
1529 c2LstXX.push_back(x);
1530 c2LstYY.push_back(y);
1531 c2LstZZ.push_back(z);
1534 // ----------------- Add new Points --------------------
1535 vtkPoints *points = NULL;
1536 vtkStaticPointLocator *pointLocator = NULL;
1539 points = aux_mesh->GetPoints();
1540 pointLocator = vtkStaticPointLocator::New();
1541 pointLocator->SetDataSet( aux_mesh );
1542 pointLocator->BuildLocator();
1546 if ( c1LstX.size()<c2LstX.size() ) { size=c2LstX.size(); } else { size=c1LstX.size(); }
1547 for (ii=0;ii<size;ii++)
1549 i = (int) ((double)ii/((double)size-1)*(sc-1));
1550 x = (c1LstXX[i]+c2LstXX[i])/2;
1551 y = (c1LstYY[i]+c2LstYY[i])/2;
1552 z = (c1LstZZ[i]+c2LstZZ[i])/2;
1555 p[0] = x * aux_mesh_spc[0];
1556 p[1] = y * aux_mesh_spc[1];
1557 p[2] = z * aux_mesh_spc[2];
1558 points->GetPoint( pointLocator->FindClosestPoint(p) , pM );
1559 x = pM[0] / aux_mesh_spc[0];
1560 y = pM[1] / aux_mesh_spc[1];
1561 z = pM[2] / aux_mesh_spc[2];
1565 if (pointLocator!=NULL) { pointLocator->Delete(); }
1566 RefreshCollectionText();
1567 RefreshColourCollection();
1568 } // if size of c1LstX c2LstX
1572 //------------------------------------------------------------------------
1573 void WidgetShowNPoints::DeleteCollection_()
1575 if ( lstModelShowNPoints.size()>1 )
1577 DeleteAllPoints_(); // Actual Collection
1578 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1579 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1580 if ( mActualCollection>=lstModelShowNPoints.size() )
1582 mActualCollection--;
1585 DeleteAllPoints_(); // Actual Collection
1589 //------------------------------------------------------------------------
1590 void WidgetShowNPoints::OnDeleteCollection_()
1592 UndoRedo_SaveCollection(); //A
1593 DeleteCollection_();
1595 GetViewShowNPoints()->Render();
1596 RefreshCollectionText();
1597 RefreshColourCollection();
1599 UndoRedo_SaveCollection(); //B
1602 //------------------------------------------------------------------------
1603 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1605 OnDeleteCollection_();
1608 //------------------------------------------------------------------------
1609 void WidgetShowNPoints::ResetCollections_()
1611 int i,size=lstModelShowNPoints.size();
1612 for (i=0;i<size;i++)
1614 DeleteCollection_();
1616 GetViewShowNPoints()->Render();
1617 RefreshCollectionText();
1618 RefreshColourCollection();
1623 //------------------------------------------------------------------------
1624 void WidgetShowNPoints::OnResetCollections_()
1626 UndoRedo_SaveCollection(); //A
1627 ResetCollections_();
1628 UndoRedo_SaveCollection(); //B
1632 //------------------------------------------------------------------------
1633 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1635 OnResetCollections_();
1638 //------------------------------------------------------------------------
1639 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1641 mActualCollection--;
1642 if ( mActualCollection <0 )
1644 // mActualCollection=0;
1645 mActualCollection = lstModelShowNPoints.size()-1;
1647 RefreshCollectionText();
1648 RefreshColourCollection();
1650 // UndoRedo_SaveCollection();
1653 //------------------------------------------------------------------------
1654 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1656 mActualCollection++;
1657 if ( mActualCollection >=lstModelShowNPoints.size() )
1659 // mActualCollection = lstModelShowNPoints.size()-1;
1660 mActualCollection = 0;
1661 } //if mActualCollection >= size
1662 RefreshCollectionText();
1663 RefreshColourCollection();
1665 // UndoRedo_SaveCollection();
1668 //------------------------------------------------------------------------
1669 void WidgetShowNPoints::DetectCollectionActive()
1672 int i,size=lstModelShowNPoints.size();
1673 for (i=0;i<size;i++)
1675 id = lstModelShowNPoints[i]->IdInsidePoint();
1678 mActualCollection=i;
1681 RefreshCollectionText();
1682 RefreshColourCollection();
1688 //------------------------------------------------------------------------
1689 void WidgetShowNPoints::RefreshColourCollection()
1692 std::vector<double> colourAll;
1693 colourAll.push_back(0);
1694 colourAll.push_back(1);
1695 colourAll.push_back(1);
1696 std::vector<double> colourActualGroup;
1697 colourActualGroup.push_back(1);
1698 colourActualGroup.push_back(0);
1699 colourActualGroup.push_back(0);
1700 // For all collections
1701 SetColour( colourAll );
1703 int iCollection,sizeLstCollection=lstViewShowNPoints.size();
1704 for ( iCollection=0 ; iCollection<sizeLstCollection ; iCollection++ )
1706 if (iCollection==mActualCollection)
1708 // Actual collection
1709 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1710 lstViewShowNPoints[mActualCollection] -> mopacity = sCtrlOpacity->GetValue()*10.0/100.0;
1711 lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.2;
1712 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1715 int curPnt = lstModelShowNPoints[mActualCollection]->GetIdCurrentPoint();
1716 sizeLstPoints = lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1717 if ((curPnt>=0) && (curPnt<sizeLstPoints ) )
1719 std::vector<double> colourActualPoint;
1720 colourActualPoint.push_back(1);
1721 colourActualPoint.push_back(1);
1722 colourActualPoint.push_back(0);
1723 double radio = GetModelShowNPoints()->GetRadio();
1724 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1725 lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt );
1726 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1728 lstViewShowNPoints[mActualCollection]->TryToShowActorsInRender(true);
1730 lstViewShowNPoints[iCollection] -> mcolour = colourAll;
1731 lstViewShowNPoints[iCollection] -> ratioRadio = 1;
1732 if ((cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==true))
1734 lstViewShowNPoints[iCollection]->TryToShowActorsInRender(false);
1735 // lstViewShowNPoints[i] -> mopacity = 0.0;
1737 lstViewShowNPoints[iCollection]->TryToShowActorsInRender(true);
1738 // lstViewShowNPoints[i] -> mopacity = sCtrlOpacity->GetValue()*10.0/100.0;
1740 lstViewShowNPoints[iCollection]->RefreshEachPoint();
1741 }// if mActualCollection
1743 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1746 //------------------------------------------------------------------------
1747 void WidgetShowNPoints::RefreshCollectionText()
1749 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1752 strTmp.Printf(_T(" %d/%d"), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1753 txtNrCollections->SetLabel( strTmp );
1759 //------------------------------------------------------------------------
1760 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1763 ff = fopen( filename.c_str() , "w+" );
1766 int i,size = lstModelShowNPoints.size();
1767 fprintf(ff,"NumberOfGroups %d \n",size);
1768 for (i=0 ; i<size ; i++)
1770 lstModelShowNPoints[i]->SavePoints_(ff);
1774 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1779 //------------------------------------------------------------------------
1780 void WidgetShowNPoints::OnSaveCollectionsIdsCurrent_( std::string filename )
1783 ff = fopen( filename.c_str() , "w+" );
1786 int i,size = lstModelShowNPoints.size();
1787 fprintf(ff,"ActualCollection %d \n",mActualCollection);
1788 fprintf(ff,"NumberOfGroups %d \n",size);
1789 for (i=0 ; i<size ; i++)
1791 fprintf(ff,"CurrentIdPoint %d \n",lstModelShowNPoints[i]->GetIdCurrentPoint());
1795 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1799 //------------------------------------------------------------------------
1800 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1802 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1803 #if wxMAJOR_VERSION <= 2
1804 wxFileDialog* FD = new wxFileDialog( 0,
1805 _T("Save groups of points .."),
1808 _T("(*.xls)|*.xls"),
1809 wxSAVE | wxOVERWRITE_PROMPT,
1812 wxFileDialog* FD = new wxFileDialog( 0,
1813 _T("Save groups of points .."),
1816 _T("(*.xls)|*.xls"),
1817 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1821 int result_FD = FD->ShowModal();
1822 // This line is need it by windows //EED
1823 FD->SetReturnCode( result_FD );
1824 if (FD->GetReturnCode()==wxID_OK)
1826 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1827 OnSaveCollections_( filename );
1832 //------------------------------------------------------------------------
1833 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1835 bool okEraseFirstGroup=false;
1836 if (lstModelShowNPoints.size()==1)
1838 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1840 FILE *ff = fopen( filename.c_str() , "r+" );
1844 int iGroup,sizeGroups;
1845 int iPoint,numberPointsRead;
1847 fscanf(ff," %s %d",chartmp,&sizeGroups);
1848 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1850 mActualCollection = lstModelShowNPoints.size();
1852 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1853 for (i=0;i<numberPointsRead;i++)
1857 GetViewShowNPoints()->AddVtkPoint();
1863 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1865 if (okEraseFirstGroup==true)
1867 mActualCollection=0;
1868 DeleteCollection_();
1869 mActualCollection = lstModelShowNPoints.size()-1;
1871 GetViewShowNPoints()->Render();
1872 RefreshCollectionText();
1873 RefreshColourCollection();
1878 //------------------------------------------------------------------------
1879 void WidgetShowNPoints::OnLoadCollectionsIdsCurrent_( std::string filename )
1881 FILE *ff = fopen( filename.c_str() , "r+" );
1882 int iGroup,sizeGroups;
1885 fscanf(ff," %s %d",chartmp,&mActualCollection); // ActualCollection
1886 fscanf(ff," %s %d",chartmp,&sizeGroups); // NumberOfGroups
1887 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1889 fscanf(ff," %s %d",chartmp,&IdCurrentPoint); // CurrentPointId
1890 lstModelShowNPoints[iGroup]->SetIdCurrentPoint( IdCurrentPoint );
1893 GetViewShowNPoints()->Render();
1894 RefreshCollectionText();
1895 RefreshColourCollection();
1902 //------------------------------------------------------------------------
1903 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1905 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1906 #if wxMAJOR_VERSION <= 2
1907 wxFileDialog* FD = new wxFileDialog( 0,
1908 _T("Load groups of points .."),
1911 _T("(*.xls)|*.xls"),
1912 wxOPEN | wxFILE_MUST_EXIST,
1915 wxFileDialog* FD = new wxFileDialog( 0,
1916 _T("Load groups of points .."),
1919 _T("(*.xls)|*.xls"),
1920 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1923 int result_FD = FD->ShowModal();
1924 // This line is need it by windows //EED
1925 FD->SetReturnCode( result_FD );
1926 if (FD->GetReturnCode()==wxID_OK)
1928 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1929 UndoRedo_SaveCollection(); // A
1930 OnLoadCollections_( filename );
1931 UndoRedo_SaveCollection(); // B
1935 //------------------------------------------------------------------------
1936 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1939 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1944 //------------------------------------------------------------------------
1945 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1947 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1949 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1950 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1953 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1956 //------------------------------------------------------------------------
1957 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1961 return GetModelShowNPoints()->GetLstPointsX();
1963 std::vector<double> lst;
1965 int iG,sG=lstModelShowNPoints.size();
1966 for (iG=0 ; iG<sG ; iG++)
1968 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1970 for (iP=0 ; iP<s ; iP++)
1972 lst.push_back( lstTmp[iP] );
1979 //------------------------------------------------------------------------
1980 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1984 return GetModelShowNPoints()->GetLstPointsY();
1986 std::vector<double> lst;
1988 int iG,sG=lstModelShowNPoints.size();
1989 for (iG=0 ; iG<sG ; iG++)
1991 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1993 for (iP=0 ; iP<s ; iP++)
1995 lst.push_back( lstTmp[iP] );
2002 //------------------------------------------------------------------------
2003 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
2007 return GetModelShowNPoints()->GetLstPointsZ();
2009 std::vector<double> lst;
2011 int iG,sG=lstModelShowNPoints.size();
2012 for (iG=0 ; iG<sG ; iG++)
2014 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
2016 for (iP=0 ; iP<s ; iP++)
2018 lst.push_back( lstTmp[iP] );
2026 //------------------------------------------------------------------------
2027 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
2031 return GetModelShowNPoints()->GetLstLabels();
2033 std::vector< std::string > lst;
2035 int iG,sG=lstModelShowNPoints.size();
2036 for (iG=0 ; iG<sG ; iG++)
2038 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
2040 for (iP=0 ; iP<s ; iP++)
2042 lst.push_back( lstTmp[iP] );
2049 //------------------------------------------------------------------------
2050 std::vector<int> WidgetShowNPoints::GetLstIndexs()
2052 std::vector<int> lstIndexs;
2055 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
2057 int iG,sG=lstModelShowNPoints.size();
2058 for (iG=0 ; iG<sG ; iG++)
2060 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
2066 //------------------------------------------------------------------------
2067 std::vector<int> WidgetShowNPoints::GetLstSelectedIndexs()
2069 std::vector<int> lstSelectedIndexs;
2070 if ( (cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==true) )
2072 lstSelectedIndexs.push_back( mActualCollection );
2074 return lstSelectedIndexs;
2077 //------------------------------------------------------------------------
2078 int WidgetShowNPoints::GetLstModelShowNPointsSize()
2080 return lstModelShowNPoints.size();
2083 //------------------------------------------------------------------------
2084 void WidgetShowNPoints::InvertLstPoints_()
2086 int i,size=lstModelShowNPoints.size();
2088 for (i=0 ; i < size ; i++)
2090 lstModelShowNPoints[i]->InversLstPoints();
2094 ModelShowNPoints* tmpModel;
2096 for (i=0 ; i < size2 ; i++)
2098 tmpModel = lstModelShowNPoints[i];
2099 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
2100 lstModelShowNPoints[size-1-i] = tmpModel;
2105 //------------------------------------------------------------------------
2106 void WidgetShowNPoints::OnInvertLstPoints_()
2108 UndoRedo_SaveCollection(); // A
2109 StopAutoAddPoints();
2113 UndoRedo_SaveCollection(); // B
2117 //------------------------------------------------------------------------
2118 std::string WidgetShowNPoints::GetUndoRedoFileName()
2121 sprintf(buff,"%p_%d",this, idUndoRedo);
2122 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
2126 //------------------------------------------------------------------------
2127 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
2129 ResetCollections_();
2130 // if (idUndoRedo==maxUndoRedo+1)
2133 // } // if idUndoRedo+1
2140 OnLoadCollections_( GetUndoRedoFileName() );
2141 OnLoadCollectionsIdsCurrent_( GetUndoRedoFileName()+".current" );
2147 //------------------------------------------------------------------------
2148 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
2150 if (idUndoRedo>maxUndoRedo)
2152 idUndoRedo=maxUndoRedo+1;
2154 ResetCollections_();
2155 OnLoadCollections_( GetUndoRedoFileName() );
2156 OnLoadCollectionsIdsCurrent_( GetUndoRedoFileName()+".current" );
2161 //------------------------------------------------------------------------
2162 void WidgetShowNPoints::UndoRedo_SaveCollection()
2164 OnSaveCollections_( GetUndoRedoFileName() );
2165 OnSaveCollectionsIdsCurrent_( GetUndoRedoFileName()+".current" );
2166 maxUndoRedo = idUndoRedo;
2170 //------------------------------------------------------------------------
2171 void WidgetShowNPoints::SetAuxMesh(vtkPolyData* mesh, std::vector<double> spc, std::vector<double> params)
2175 if (params.size()==1)
2177 aux_mesh_type = params[0];
2183 //------------------------------------------------------------------------
2184 void WidgetShowNPoints::OnVisuActualCollection(wxCommandEvent &event)
2186 printf("EED WidgetShowNPoints::OnVisuActualCollection \n");
2187 RefreshCollectionText();
2188 RefreshColourCollection();