4 #include <wx/filedlg.h>
6 #include <wx/notebook.h>
7 #include <wx/spinctrl.h>
10 #include <vtkStaticPointLocator.h>
11 #include <vtkPointData.h>
12 #include <vtkDataArray.h>
14 #include <vtkStaticPointLocator.h>
15 #include <vtkPoints.h>
17 #include "vtkSphereSource.h"
18 #include "vtkRenderer.h"
19 #include "vtkTextActor3D.h"
21 #include "WidgetShowNPoints.h"
22 #include <creaContoursFactory.h>
25 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
29 //----------------------------------------------------------------------
30 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
31 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
34 aux_mesh_spc.push_back(1);
35 aux_mesh_spc.push_back(1);
36 aux_mesh_spc.push_back(1);
37 aux_mesh_type = 0; // 0:Patch 1:CloseSpline1 2:CloseSpline2
40 // mmodelShowNPoints = new ModelShowNPoints();
44 char * val = getenv( "TEMP" );
47 UndoRedoDir = std::string("");
49 UndoRedoDir = std::string(val)+"\\creatools";
50 std::string cmd1 = "mkdir "+ UndoRedoDir;
51 system( cmd1.c_str() );
52 // Erasing files of more than 1 day old ( -1 )
53 std::string cmd2 = "ForFiles /p \"" + UndoRedoDir + "\" /s /d -1 /c \"cmd /c del @file \"";
54 system( cmd2.c_str() );
56 #elif defined(__GNUC__)
60 UndoRedoDir = "/tmp/creatools";
62 UndoRedoDir = "/tmp/creatools";
65 std::string cmd1 = "mkdir "+ UndoRedoDir;
66 system( cmd1.c_str() );
67 // Erasing files of more than 1 day old ( +1 )
68 std::string cmd= "find "+UndoRedoDir+" -name \"UndoRedo_collection_*.undoredo\" -type f -mtime +1 -delete";
69 system( cmd.c_str() );
76 mActualCollection = 0;
77 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
78 lstModelShowNPoints.push_back( modelShowNPoints );
79 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
83 wxPanel* panelParent = this;
84 wxSizer* sizer = NULL;
85 wxSizer* MNPsizer = NULL;
86 wxNotebook* bookSetPoints = NULL;
87 wxNotebook* bookGroupManager = NULL;
88 wxPanel* panel = NULL;
89 wxPanel* panel2 = NULL;
90 txtNrCollections = NULL;
92 bookSetPoints = new wxNotebook(panelParent,
97 panel = new wxPanel(bookSetPoints);
99 wxSize sizeButton( 50 , -1 );
100 wxSize sizeSlider( 90 , -1 );
105 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
110 panel2 = new wxPanel(bookGroupManager);
111 wxCheckBox *cbVisuActualCollection = new wxCheckBox ( panel2,-1, _T("A.V.") , wxDefaultPosition, sizeButton );
112 txtNrCollections = new wxStaticText ( panel2,-1, _T(" 1/1 "));
113 wxButton *btnBackCollection = new wxButton ( panel2, -1, _T("<") , wxDefaultPosition, sizeButton );
114 wxButton *btnNextCollection = new wxButton ( panel2, -1, _T(">") , wxDefaultPosition, sizeButton );
115 wxButton *btnInsertCollectionBefore = new wxButton ( panel2, -1, _T("+<") , wxDefaultPosition, sizeButton );
116 wxButton *btnInsertCollectionAfter = new wxButton ( panel2, -1, _T("+>") , wxDefaultPosition, sizeButton );
117 wxButton *btnDeleteCollection = new wxButton ( panel2, -1, _T("-") , wxDefaultPosition, sizeButton );
118 wxButton *btnResetCollection = new wxButton ( panel2, -1, _T("--") , wxDefaultPosition, sizeButton );
119 wxButton *btnSaveCollection = new wxButton ( panel2, -1, _T("Save") , wxDefaultPosition, sizeButton );
120 wxButton *btnLoadCollection = new wxButton ( panel2, -1, _T("Load") , wxDefaultPosition, sizeButton );
121 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
122 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
123 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(3);
124 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
125 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
126 wxFlexGridSizer *sizer5a = new wxFlexGridSizer(2);
127 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
128 wxFlexGridSizer *sizer7 = new wxFlexGridSizer(2);
129 // wxStaticText* txOpacity = new wxStaticText(panel2, -1, wxString(_T("Op:")));
131 cbVisuActualCollection -> SetToolTip( _T("Visu actual collection") );
132 btnInsertCollectionBefore -> SetToolTip( _T("+ Add group before") );
133 btnInsertCollectionAfter -> SetToolTip( _T("+> Add group after") );
134 btnDeleteCollection -> SetToolTip( _T("- Erase group") );
135 btnResetCollection -> SetToolTip( _T("-- Reset : Erase all groups") );
137 sdrOpacity = new wxSlider(panel2, -1, 0, 0, 100, wxDefaultPosition, sizeSlider, wxSL_LABELS);
138 // wxStaticText* txRadio = new wxStaticText(panel2, -1, wxString(_T("R:")));
139 sdrRadio = new wxSlider(panel2, -1, 0, 1, 50, wxDefaultPosition, sizeSlider, wxSL_LABELS);
141 sdrRadio -> SetToolTip( _T("Radio") );
142 sdrOpacity -> SetToolTip( _T("Opacity") );
144 Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection );
145 Connect(btnNextCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection );
146 Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore );
147 Connect(btnInsertCollectionAfter->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter );
148 Connect(btnDeleteCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection );
149 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) & WidgetShowNPoints::UpdatePoints );
150 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED, (wxObjectEventFunction) & WidgetShowNPoints::UpdatePoints );
151 Connect(btnSaveCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnSaveCollections );
152 Connect(btnLoadCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnLoadCollections );
153 Connect(btnResetCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnResetCollections );
155 sizer2->Add( btnBackCollection );
156 sizer2->Add( btnNextCollection );
157 sizer3->Add( btnInsertCollectionBefore );
158 sizer3->Add( btnInsertCollectionAfter );
159 sizer4->Add( btnLoadCollection );
160 sizer4->Add( btnSaveCollection );
161 // sizer5->Add( txRadio ,wxGROW );
162 sizer5->Add( sdrRadio ,wxGROW );
163 // sizer5->Add( txOpacity ,wxGROW );
164 sizer5->Add( sdrOpacity ,wxGROW );
167 wxChoice *wxchoiceA = new wxChoice ( panel2 , -1, wxDefaultPosition,sizeButton2);
168 wxChoice *wxchoiceB = new wxChoice ( panel2 , -1, wxDefaultPosition,sizeButton2);
169 wxchoiceA->Append(_T("0") );
170 wxchoiceA->Append(_T("1") );
171 wxchoiceA->Append(_T("2") );
172 wxchoiceA->Append(_T("3") );
173 wxchoiceA->Append(_T("4") );
174 wxchoiceA->Append(_T("5") );
175 wxchoiceA->Append(_T("6") );
176 wxchoiceA->Append(_T("7") );
177 wxchoiceA->Append(_T("8") );
178 wxchoiceA->Append(_T("9") );
179 wxchoiceA->Append(_T("10") );
180 wxchoiceB->Append(_T("0%") );
181 wxchoiceB->Append(_T("10%") );
182 wxchoiceB->Append(_T("20%") );
183 wxchoiceB->Append(_T("30%") );
184 wxchoiceB->Append(_T("40%") );
185 wxchoiceB->Append(_T("50%") );
186 wxchoiceB->Append(_T("60%") );
187 wxchoiceB->Append(_T("70%") );
188 wxchoiceB->Append(_T("80%") );
189 wxchoiceB->Append(_T("90") );
190 wxchoiceB->Append(_T("100") );
193 wxSpinCtrl *mwxSpinButtonA = new wxSpinCtrl( panel2, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
194 mwxSpinButtonA->SetRange(1,10);
195 mwxSpinButtonA->SetValue( 2 );
196 wxSpinCtrl *mwxSpinButtonB = new wxSpinCtrl( panel2, -1 , wxEmptyString, wxDefaultPosition, sizeButton );
197 mwxSpinButtonB->SetRange(0,10);
198 mwxSpinButtonB->SetValue( 10 );
201 // sizer5a->Add( wxchoiceA ,wxGROW );
202 // sizer5a->Add( wxchoiceB ,wxGROW );
203 sizer5a->Add( mwxSpinButtonA ,wxGROW );
204 sizer5a->Add( mwxSpinButtonB ,wxGROW );
207 sizer6->Add( btnDeleteCollection );
208 sizer6->Add( btnResetCollection );
210 sizer7->Add( cbVisuActualCollection );
211 sizer7->Add( txtNrCollections );
213 sizer1->Add( sizer7 );
214 sizer1->Add( sizer2 );
215 sizer1->Add( sizer3 );
216 sizer1->Add( sizer6 );
217 sizer1->Add( sizer4 );
218 sizer1->Add( sizer5a );
220 sizer1->Add( sizer5 ,wxGROW );
223 panel2->SetSizer( MNPsizer );
224 panel2->SetAutoLayout(true);
226 bookGroupManager->AddPage(panel2 , _T("Groups") );
229 if ( (mtype==0) || (mtype==3) || (mtype==4) )
232 // askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR
233 textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton);
234 wxButton *btnBackPoint = new wxButton( panel, -1, _T("<") , wxDefaultPosition, sizeButton );
235 wxButton *btnNextPoint = new wxButton( panel, -1, _T(">") , wxDefaultPosition, sizeButton );
236 wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton );
237 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );
238 cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton );
239 wxButton *btnMovePointUp = new wxButton( panel, -1, _T("<-") , wxDefaultPosition, sizeButton );
240 wxButton *btnMovePointDown = new wxButton( panel, -1, _T("->") , wxDefaultPosition, sizeButton );
242 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton );
243 cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton );
244 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton );
245 wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton );
246 // wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton );
247 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton );
248 wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton );
249 wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton );
250 wxButton *btnSavePoints = NULL;
251 wxButton *btnLoadPoints = NULL;
254 btnBackPoint -> SetToolTip( _T("Select befor point") );
255 btnNextPoint -> SetToolTip( _T("Select next point") );
256 cbAutoAddPoints -> SetToolTip( _T("Auto Add point") );
257 btnAddPoint -> SetToolTip( _T("+ Add point") );
258 btnInsertPoint -> SetToolTip( _T("(-) Insert point") );
259 btnMovePointUp -> SetToolTip( _T("Move point Up in the normal direction") );
260 btnMovePointDown -> SetToolTip( _T("Move point Down in the normal direction") );
262 btnErasePoint -> SetToolTip( _T("- Erase point") );
263 // btnEraseLastPoint -> SetToolTip( _T("- lst Erase last point") );
264 btnDeleteAllPoints -> SetToolTip( _T("-- Erase all points") );
268 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
269 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
270 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
271 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
273 txtNrPoints = new wxStaticText(panel,-1, _T(" -/-"));
275 wxStaticText* txOpacity;
276 wxStaticText* txRadio;
277 if ( (mtype==0) || (mtype==3) )
279 //NTU: Sliders for opacity and radio change
280 txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
281 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
282 txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
283 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
285 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
286 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
288 Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints);
289 Connect(btnBackPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnBackPoint);
290 Connect(btnNextPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnNextPoint);
291 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
292 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
293 Connect(btnMovePointUp->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnMovePointUp);
294 Connect(btnMovePointDown->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnMovePointDown);
295 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
296 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
297 // Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
298 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
299 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
300 Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
301 Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo);
302 Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo);
303 wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1);
304 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(2);
305 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(3);
306 wxFlexGridSizer *sizer3 = new wxFlexGridSizer(2);
307 wxFlexGridSizer *sizer4 = new wxFlexGridSizer(3);
308 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2);
309 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
310 wxFlexGridSizer *sizer7 = new wxFlexGridSizer(2);
311 wxFlexGridSizer *sizer8 = new wxFlexGridSizer(2);
312 sizer1->Add( textCtrl );
313 sizer1->Add( btnRenamePoint );
314 sizer2->Add( btnAddPoint );
315 sizer2->Add( btnInsertPoint );
316 // sizer2->Add( cbAutoAddPoints );
317 sizer3->Add( btnSetPositionPoint );
318 sizer3->Add( cbTrackPoint );
319 sizer4->Add( btnErasePoint );
320 // sizer4->Add( btnEraseLastPoint );
321 sizer4->Add( btnDeleteAllPoints );
322 sizer5->Add( btnUndo );
323 sizer5->Add( btnRedo );
324 sizer6->Add( btnBackPoint );
325 sizer6->Add( btnNextPoint );
326 sizer7->Add( btnMovePointUp );
327 sizer7->Add( btnMovePointDown );
328 sizer8->Add( cbAutoAddPoints );
329 sizer8->Add( txtNrPoints );
331 // sizer0->Add(askPointLabel); // JPR
340 if ( (mtype==0) || (mtype==3) )
342 wxFlexGridSizer *sizer5 = new wxFlexGridSizer(1);
343 sizer5->Add(txRadio);
344 sizer5->Add(sdrRadio,1,wxGROW );
345 sizer5->Add(txOpacity);
346 sizer5->Add(sdrOpacity,1,wxGROW );
351 wxFlexGridSizer *sizer6 = new wxFlexGridSizer(2);
352 sizer6->Add(btnSavePoints);
353 sizer6->Add(btnLoadPoints);
362 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
363 txtNrPoints = new wxStaticText(panel,-1, _T("-/-"));
365 //NTU: Sliders for opacity and radio change
366 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
367 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
368 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
369 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
370 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
371 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
372 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
374 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
375 sizer1->Add(btnSetPositionPoint);
376 sizer1->Add(txtNrPoints);
377 sizer1->Add(txRadio);
378 sizer1->Add(sdrRadio,1,wxGROW );
379 sizer1->Add(txOpacity);
380 sizer1->Add(sdrOpacity,1,wxGROW );
386 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
387 wxButton *btnAddPoint = new wxButton(panel , -1, _T(" Add Point "));
388 wxButton *btnDeleteAllPoints = new wxButton(panel , -1, _T(" Delete All "));
389 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
390 textCtrl = new wxTextCtrl(panel, -1);
391 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
392 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
393 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
394 sizer1->Add(askPointLabel);
395 sizer1->Add(btnAddPoint);
396 sizer1->Add(btnDeleteAllPoints);
398 sizer1->Add(textCtrl);
399 // sdrOpacity = new wxSlider();
400 // sdrRadio = new wxSlider();
401 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
403 } // bbGetInputType 2
405 panel->SetSizer(sizer);
406 panel->SetAutoLayout(true);
408 bookSetPoints->AddPage(panel , _T("Points") );
410 if ((mtype >= 0) && (mtype <= 3) )
414 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
415 sizerParent->Add( bookSetPoints );
416 panelParent->SetSizer( sizerParent );
417 panelParent->SetAutoLayout(true);
418 panelParent->Layout();
420 } // if mtype 0 1 2 3
424 if ((sizer!=NULL) && (MNPsizer!=NULL))
426 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
427 sizerG->Add(bookGroupManager);
428 sizerG->Add(bookSetPoints);
429 panelParent->SetSizer(sizerG);
430 panelParent->SetAutoLayout(true);
431 panelParent->Layout();
436 //------------------------------------------------------------------------
437 WidgetShowNPoints::~WidgetShowNPoints()
441 //------------------------------------------------------------------------
442 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
445 // return mmodelShowNPoints;
446 return lstModelShowNPoints[ mActualCollection ];
449 //------------------------------------------------------------------------
450 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id)
452 if(id >= 0 && id < lstModelShowNPoints.size())
454 return lstModelShowNPoints[ id ];
459 //------------------------------------------------------------------------
460 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
462 return lstViewShowNPoints[ mActualCollection ];
466 //------------------------------------------------------------------------
467 void WidgetShowNPoints::SetRadio(double radio)
470 // GetModelShowNPoints()->SetRadio(radio);
471 int i,size = lstModelShowNPoints.size();
474 lstModelShowNPoints[i]->SetRadio( radio );
477 sdrRadio->SetValue(radio);
480 //------------------------------------------------------------------------
481 void WidgetShowNPoints::SetColour(std::vector<double> colour)
484 //this->mcolour = colour;
485 int i,size = lstViewShowNPoints.size();
486 for (i=0 ; i<size ; i++)
488 lstViewShowNPoints[i]->mcolour = colour;
492 //------------------------------------------------------------------------
493 void WidgetShowNPoints::SetImage(vtkImageData* image)
496 //GetModelShowNPoints()->SetImage(image);
497 int i,size = lstModelShowNPoints.size();
498 for (i=0 ; i<size ; i++)
500 lstModelShowNPoints[i]->SetImage(image);
504 //------------------------------------------------------------------------
505 void WidgetShowNPoints::SetOpacity(double opacity)
508 //this->mopacity=opacity;
509 int i,size = lstViewShowNPoints.size();
510 for (i=0 ; i<size ; i++)
512 lstViewShowNPoints[i]->mopacity = opacity;
515 sdrOpacity->SetValue( opacity*100.0 );
519 //------------------------------------------------------------------------
520 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
523 //this->renderer = renderer;
524 int i,size = lstViewShowNPoints.size();
525 for (i=0 ; i<size ; i++)
527 lstViewShowNPoints[i]->renderer = renderer;
532 //------------------------------------------------------------------------
534 void WidgetShowNPoints::RefreshPoint(int id)
538 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
539 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
540 std::string label = GetModelShowNPoints()->GetIdLabel(id);
541 double radio = GetModelShowNPoints()->GetRadio();
542 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
543 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
544 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
545 lstSourceSphere[id]->SetRadius( radio );
546 //EED 2017-01-01 Migration VTK7
547 #if VTK_MAJOR_VERSION <= 5
550 lstSourceSphere[id]->Update();
552 lstActorsText[id]->SetInput( label.c_str() );
553 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
556 //------------------------------------------------------------------------
557 void WidgetShowNPoints::RefreshPoints()
559 int id,size=lstActorsSphere.size();
560 for (id=0;id<size;id++)
564 renderer->GetRenderWindow()->Render();
567 //------------------------------------------------------------------------
568 void WidgetShowNPoints::AddVtkPoint()
571 vtkSphereSource *vtksphere = vtkSphereSource::New();
572 vtksphere->SetThetaResolution (20);
573 vtksphere->SetPhiResolution (20);
574 vtksphere->SetRadius( 1 );
575 //NTU: For updating points
576 lstSourceSphere.push_back(vtksphere);
577 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
579 //EED 2017-01-01 Migration VTK7
580 #if VTK_MAJOR_VERSION <= 5
581 sphereMapper->SetInput( vtksphere->GetOutput() );
584 sphereMapper->SetInputData( vtksphere->GetOutput() );
587 vtkActor *sphereActor = vtkActor::New();
588 sphereActor->SetMapper(sphereMapper);
589 sphereActor->SetOrigin(0, 0, 0);
591 lstActorsSphere.push_back(sphereActor);
593 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
597 renderer->AddActor( sphereActor );
599 vtkTextActor3D *textActor = vtkTextActor3D::New();
600 // textActor->SetInput( strLabel.c_str() );
601 renderer->AddActor( textActor );
602 lstActorsText.push_back(textActor);
607 void WidgetShowNPoints::SetCurrentPoint(int idCurrentPoint )
609 int size = GetModelShowNPoints()->GetLstPointsSize();
610 if (idCurrentPoint<0) { idCurrentPoint = size-1; }
611 if (idCurrentPoint>=size ) { idCurrentPoint = 0; }
612 GetModelShowNPoints()->SetIdCurrentPoint( idCurrentPoint );
613 RefreshCollectionText();
614 RefreshColourCollection();
617 void WidgetShowNPoints::OnBackPoint(wxCommandEvent &event)
619 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() - 1 );
622 void WidgetShowNPoints::OnNextPoint(wxCommandEvent &event)
624 SetCurrentPoint( GetModelShowNPoints()->GetIdCurrentPoint() + 1 );
628 //------------------------------------------------------------------------
629 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
631 GetModelShowNPoints()->AddPoint(x,y,z, label );
634 //RefreshPoint(lstActorsSphere.size()-1);
635 GetViewShowNPoints()->AddPoint();
638 //------------------------------------------------------------------------
639 void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
642 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
646 // AddPoint(x,y,z,label);
649 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
651 GetViewShowNPoints()->AddVtkPoint();
653 AddPoint(x,y,z,label);
655 GetViewShowNPoints()->RefreshPoints();
658 //------------------------------------------------------------------------
659 void WidgetShowNPoints::OnInsertPoint_()
662 //if (this->renderer==NULL)
666 if (GetViewShowNPoints()->renderer==NULL)
670 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
673 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
675 } else {//mpoint.size
676 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
678 RefreshCollectionText();
679 RefreshColourCollection();
681 UndoRedo_SaveCollection();
684 //------------------------------------------------------------------------
685 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
690 //------------------------------------------------------------------------
691 void WidgetShowNPoints::OnAddPoint__()
694 //if (this->renderer==NULL)
695 if (GetViewShowNPoints()->renderer==NULL)
699 std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
702 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
705 //renderer->GetRenderWindow()->Render();
706 GetViewShowNPoints()->Render();
707 UndoRedo_SaveCollection();
708 } else {//mpoint.size
709 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
713 void WidgetShowNPoints::OnAddPoint_()
720 //------------------------------------------------------------------------
721 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
726 //------------------------------------------------------------------------
727 void WidgetShowNPoints::AutoAddPoints()
729 if ( cbAutoAddPoints->GetValue() == true )
732 RefreshCollectionText();
733 RefreshColourCollection();
734 } // if cbAutoAddPoints
737 //------------------------------------------------------------------------
738 void WidgetShowNPoints::OnAutoAddPoints_tool()
741 cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() );
744 //------------------------------------------------------------------------
745 void WidgetShowNPoints::OnAutoAddPoints_()
750 //------------------------------------------------------------------------
751 void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
756 //------------------------------------------------------------------------
757 void WidgetShowNPoints::StopAutoAddPoints( )
759 cbAutoAddPoints->SetValue(false);
762 //------------------------------------------------------------------------
763 void WidgetShowNPoints::SetOutputBox()
766 if (GetModelShowNPoints()->GetIdCurrentPoint()<0)
768 strTmp.Printf(_T(" -/%d") , GetModelShowNPoints()->GetLstPointsSize() );
770 strTmp.Printf(_T(" %d/%d"), GetModelShowNPoints()->GetIdCurrentPoint()+1 , GetModelShowNPoints()->GetLstPointsSize() );
772 txtNrPoints->SetLabel( strTmp );
776 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
777 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
778 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
779 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
780 // mbbShowNPoints->bbSignalOutputModification();
784 //------------------------------------------------------------------------
785 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
788 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
789 #if wxMAJOR_VERSION <= 2
790 wxFileDialog* FD = new wxFileDialog( 0,
791 _T("Save points .."),
795 wxSAVE | wxOVERWRITE_PROMPT,
798 wxFileDialog* FD = new wxFileDialog( 0,
799 _T("Save points .."),
803 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
807 int result_FD = FD->ShowModal();
808 // This line is need it by windows //EED
809 FD->SetReturnCode( result_FD );
810 if (FD->GetReturnCode()==wxID_OK)
812 std::string filename= (const char*) ( FD->GetPath().mb_str() );
813 GetModelShowNPoints()->SavePoints( filename );
818 //------------------------------------------------------------------------
819 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
822 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
823 #if wxMAJOR_VERSION <= 2
824 wxFileDialog* FD = new wxFileDialog( 0,
825 _T("Load points .."),
829 wxOPEN | wxFILE_MUST_EXIST,
832 wxFileDialog* FD = new wxFileDialog( 0,
833 _T("Load points .."),
837 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
842 int result_FD = FD->ShowModal();
843 // This line is need it by windows //EED
844 FD->SetReturnCode( result_FD );
845 if (FD->GetReturnCode()==wxID_OK)
848 std::string filename= (const char*) ( FD->GetPath().mb_str() );
849 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
850 for (i=0;i<numberPointsRead;i++)
854 GetViewShowNPoints()->AddVtkPoint();
859 GetViewShowNPoints()->RefreshPoints();
863 //------------------------------------------------------------------------
864 void WidgetShowNPoints::OnSetPoint_()
869 //int id=GetModelShowNPoints()->GetNearestPoint();
870 int id=GetModelShowNPoints()->GetIdCurrentPoint();
872 if((id==-1) && (mtype==1))
880 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
883 //renderer->GetRenderWindow()->Render();
884 GetViewShowNPoints()->RefreshPoint(id);
885 GetViewShowNPoints()->Render();
887 RefreshCollectionText();
888 RefreshColourCollection();
890 UndoRedo_SaveCollection();
893 //------------------------------------------------------------------------
894 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
899 //------------------------------------------------------------------------
900 void WidgetShowNPoints::MovePoint_(double step)
905 int id=GetModelShowNPoints()->GetIdCurrentPoint();
908 if((GetLstModelShowNPointsSize()>=2) //Check condition
909 && (GetModelShowNPoints()->GetLstPointsSize()>0)
910 && (aux_mesh != NULL)
911 && (aux_mesh_spc.size() == 3))
915 double normal[3]; // point to modify and normal
916 std::vector<double> pN(3); // new point
917 vtkStaticPointLocator *pointLocator = vtkStaticPointLocator::New();
918 pointLocator->SetDataSet( aux_mesh );
919 pointLocator->BuildLocator();
921 // int idControlPoint = wsp->GetModelShowNPoints()->GetNearestPoint();
922 int idControlPoint = GetModelShowNPoints()->GetIdCurrentPoint();
923 if(idControlPoint >= 0)
925 GetModelShowNPoints()->GetIdPoint(idControlPoint, &x, &y, &z);
926 p[0] = x * aux_mesh_spc[0];
927 p[1] = y * aux_mesh_spc[1];
928 p[2] = z * aux_mesh_spc[2];
929 long int idMeshPoint = pointLocator->FindClosestPoint(p);
930 vtkDataArray *dataArrayNormals = aux_mesh->GetPointData()->GetNormals();
931 if (dataArrayNormals!=NULL)
933 dataArrayNormals->GetTuple(idMeshPoint, normal);
935 int direction = step;
936 // pN[0] = p[0] / spc[0] + direction*normal[0];
937 // pN[1] = p[1] / spc[1] + direction*normal[1];
938 // pN[2] = p[2] / spc[2] + direction*normal[2];
939 pN[0] = x + (direction * normal[0]);
940 pN[1] = y + (direction * normal[1]);
941 pN[2] = z + (direction * normal[2]);
942 GetModelShowNPoints()->SetPointById(idControlPoint, pN);
943 // GetViewShowNPoints()->RefreshPoint(idControlPoint);
944 // RefreshCollectionText();
945 // RefreshColourCollection();
947 UndoRedo_SaveCollection();
949 printf("Error! WidgetShowNPoints::MovePoint_ Missing normals in aux_mesh \n");
951 } // if idControlPoint
952 } // if wsp->GetLstModelShowNPointsSiz->size()>=2
957 double minX=max,minY=max,minZ=max;
958 double maxX=-max,maxY=-max,maxZ=-max;
959 sizeG = lstModelShowNPoints.size();
960 for (i=0; i<sizeG; i++)
962 std::vector<double> lstX = lstModelShowNPoints[i]->GetLstPointsX();
963 std::vector<double> lstY = lstModelShowNPoints[i]->GetLstPointsY();
964 std::vector<double> lstZ = lstModelShowNPoints[i]->GetLstPointsZ();
966 for (j=0; j<sizeP; j++)
968 if ( lstX[j]<minX ) { minX=lstX[j]; }
969 if ( lstY[j]<minY ) { minY=lstY[j]; }
970 if ( lstZ[j]<minZ ) { minZ=lstZ[j]; }
971 if ( lstX[j]>maxX ) { maxX=lstX[j]; }
972 if ( lstY[j]>maxY ) { maxY=lstY[j]; }
973 if ( lstZ[j]>maxZ ) { maxZ=lstZ[j]; }
977 pc[0]=(minX+maxX) /2 ; pc[1]=(minY+maxY) /2 ; pc[2]=(minZ+maxZ) /2 ;
979 p[0]=GetModelShowNPoints()->GetLstPointsX()[id];
980 p[1]=GetModelShowNPoints()->GetLstPointsY()[id];
981 p[2]=GetModelShowNPoints()->GetLstPointsZ()[id];
986 double mag=sqrt ( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] );
987 std::vector<double> point;
998 point.push_back( p[0] + step*v[0] );
999 point.push_back( p[1] + step*v[1] );
1000 point.push_back( p[2] + step*v[2] );
1001 GetModelShowNPoints()->SetPointById(id,point);
1002 UndoRedo_SaveCollection();
1005 RefreshCollectionText();
1006 RefreshColourCollection();
1009 //------------------------------------------------------------------------
1010 void WidgetShowNPoints::OnMovePointUp(wxCommandEvent& event)
1015 //------------------------------------------------------------------------
1016 void WidgetShowNPoints::OnMovePointDown(wxCommandEvent& event)
1021 //------------------------------------------------------------------------
1022 void WidgetShowNPoints::TrackingPoint( )
1024 if ( cbTrackPoint->GetValue() == true )
1026 int id = GetModelShowNPoints()->IdInsidePoint();
1034 GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
1036 RefreshCollectionText();
1037 RefreshColourCollection();
1039 // GetViewShowNPoints()->RefreshPoint(idTrack);
1040 // GetViewShowNPoints()->Render();
1041 UndoRedo_SaveCollection();
1043 } // if trackPointFlag
1046 //------------------------------------------------------------------------
1047 void WidgetShowNPoints::OnTrackPoint_tool()
1049 cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
1053 //------------------------------------------------------------------------
1054 void WidgetShowNPoints::OnTrackPoint_()
1056 StopAutoAddPoints();
1059 if ( cbTrackPoint->GetValue() == true )
1062 // idTrack = GetModelShowNPoints()->IdInsidePoint();
1063 idTrack = GetModelShowNPoints()->GetIdCurrentPoint();
1064 } // if trackPointFlag
1067 //------------------------------------------------------------------------
1068 void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
1073 //------------------------------------------------------------------------
1074 void WidgetShowNPoints::StopTrackPoint( )
1076 cbTrackPoint->SetValue(false);
1080 //------------------------------------------------------------------------
1081 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
1083 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
1087 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1088 //renderer->GetRenderWindow()->Render();
1089 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
1090 GetViewShowNPoints()->Render();
1092 UndoRedo_SaveCollection();
1096 //------------------------------------------------------------------------
1097 bool WidgetShowNPoints::ErasePoint(int id)
1100 //if (this->renderer!=NULL)
1102 if (GetViewShowNPoints()->renderer!=NULL)
1107 //renderer->RemoveActor( lstActorsSphere[id] );
1108 //renderer->RemoveActor( lstActorsText[id] );
1109 //lstActorsSphere[id]->Delete();
1110 //lstActorsText[id]->Delete();
1111 //lstSourceSphere[id]->Delete();
1112 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
1113 //lstActorsText.erase( lstActorsText.begin()+id );
1114 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
1115 GetViewShowNPoints()->ErasePoint(id);
1116 GetModelShowNPoints()->ErasePoint(id);
1123 //------------------------------------------------------------------------
1124 void WidgetShowNPoints::OnErasePoint_()
1126 StopAutoAddPoints();
1129 //ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
1130 if (ErasePoint( GetModelShowNPoints()->GetIdCurrentPoint() ) == true)
1134 //renderer->GetRenderWindow()->Render();
1135 // GetViewShowNPoints()->Render();
1136 RefreshCollectionText();
1137 RefreshColourCollection();
1139 UndoRedo_SaveCollection();
1143 //------------------------------------------------------------------------
1144 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
1149 //------------------------------------------------------------------------
1150 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
1153 //ErasePoint( lstActorsSphere.size()-1 );
1154 //renderer->GetRenderWindow()->Render();
1155 StopAutoAddPoints();
1158 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
1161 RefreshCollectionText();
1162 RefreshColourCollection();
1164 UndoRedo_SaveCollection();
1165 GetViewShowNPoints()->Render();
1170 //------------------------------------------------------------------------
1171 void WidgetShowNPoints::DeleteAllPoints_()
1174 //int id,size=lstActorsSphere.size();
1175 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
1176 for (id=size-1;id>=0;id--)
1182 void WidgetShowNPoints::OnDeleteAllPoints_()
1184 StopAutoAddPoints();
1188 UndoRedo_SaveCollection();
1191 //------------------------------------------------------------------------
1192 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
1194 OnDeleteAllPoints_();
1196 GetViewShowNPoints()->Render();
1199 //NTU: Method for updating points opacity and Radio
1201 //------------------------------------------------------------------------
1202 void WidgetShowNPoints::UpdatePoints_()
1205 //this->mopacity = sdrOpacity->GetValue()/100.0;
1206 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
1209 double opacity = sdrOpacity->GetValue()/100.0;
1210 double radio = sdrRadio->GetValue();
1211 int i,size = lstViewShowNPoints.size();
1212 for (i=0 ; i<size ; i++)
1214 lstViewShowNPoints[i]->mopacity = opacity;
1215 lstModelShowNPoints[i]->SetRadio( radio ) ;
1217 // GetViewShowNPoints()->RefreshPoints();
1220 //------------------------------------------------------------------------
1221 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
1223 RefreshColourCollection();
1226 //------------------------------------------------------------------------
1227 void WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
1229 GetModelShowNPoints()->SetReferencePoint(point);
1230 int i,size=lstModelShowNPoints.size();
1231 for (i=0;i<size;i++)
1233 lstModelShowNPoints[i]->SetReferencePoint(point); // All collection
1237 //------------------------------------------------------------------------
1238 void WidgetShowNPoints::SetActualCollection( int actual )
1245 if (actual>lstModelShowNPoints.size()-1 )
1247 actual=lstModelShowNPoints.size()-1;
1250 mActualCollection=actual;
1254 //------------------------------------------------------------------------
1255 void WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX, std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels, std::vector<int> initLstIndexs )
1257 if (GetViewShowNPoints()->renderer==NULL)
1263 int i,sizeX,sizeY,sizeZ,sizeTmp,sizeLabels;
1264 int ii,iIndexs,sizeIndexs;
1266 sizeX = (int)initLstPointsX.size();
1267 sizeY = (int)initLstPointsY.size();
1268 sizeZ = (int)initLstPointsZ.size();
1269 sizeLabels = (int)initLstLabels.size();
1270 sizeIndexs = (int)initLstIndexs.size();
1274 initLstIndexs.push_back(sizeX);
1275 sizeIndexs = (int)initLstIndexs.size();
1278 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1281 for (iIndexs=0;iIndexs<sizeIndexs;iIndexs++ )
1285 InsertCollectionAfter_();
1287 sizeTmp = initLstIndexs[iIndexs];
1288 for (ii=0;ii<sizeTmp;ii++)
1290 x = initLstPointsX[i];
1291 y = initLstPointsY[i];
1292 z = initLstPointsZ[i];
1295 label = initLstLabels[i];
1299 AddPoint( x,y,z,label );
1306 // renderer->GetRenderWindow()->Render();
1315 //if (this->renderer==NULL)
1316 if (GetViewShowNPoints()->renderer==NULL)
1320 int i,sizeX,sizeY,sizeZ,sizeLabels;
1321 sizeX = (int)initLstPointsX.size();
1322 sizeY = (int)initLstPointsY.size();
1323 sizeZ = (int)initLstPointsZ.size();
1324 sizeLabels = (int)initLstLabels.size();
1327 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
1329 for (i=0;i<sizeX;i++)
1331 x = initLstPointsX[i];
1332 y = initLstPointsY[i];
1333 z = initLstPointsZ[i];
1336 label = initLstLabels[i];
1340 AddPoint( x,y,z,label );
1343 // renderer->GetRenderWindow()->Render();
1349 //------------------------------------------------------------------------
1350 void WidgetShowNPoints::SetType(int type)
1355 //------------------------------------------------------------------------
1356 int WidgetShowNPoints::GetType()
1362 //------------------------------------------------------------------------
1363 double WidgetShowNPoints::GetRadio()
1365 return sdrRadio->GetValue();
1367 //------------------------------------------------------------------------
1368 double WidgetShowNPoints::GetOpacity()
1370 return sdrOpacity->GetValue()/100;
1373 //------------------------------------------------------------------------
1374 void WidgetShowNPoints::InsertCollection()
1376 ModelShowNPoints* model = new ModelShowNPoints();
1377 ViewShowNPoints* view = new ViewShowNPoints( model );
1378 view->mopacity = lstViewShowNPoints[0]->mopacity;
1379 view->renderer = lstViewShowNPoints[0]->renderer;
1380 model->SetImage( lstModelShowNPoints[0]->GetImage() );
1381 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
1382 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
1385 //------------------------------------------------------------------------
1386 void WidgetShowNPoints::InsertCollectionBefore_()
1389 RefreshCollectionText();
1390 RefreshColourCollection();
1394 //------------------------------------------------------------------------
1395 void WidgetShowNPoints::OnInsertCollectionBefore_()
1397 InsertCollectionBefore_();
1398 CreatePointsIntoNewCollection();
1399 UndoRedo_SaveCollection();
1403 //------------------------------------------------------------------------
1404 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
1406 OnInsertCollectionBefore_();
1410 //------------------------------------------------------------------------
1411 void WidgetShowNPoints::InsertCollectionAfter_()
1413 mActualCollection++;
1415 RefreshCollectionText();
1416 RefreshColourCollection();
1421 //------------------------------------------------------------------------
1422 void WidgetShowNPoints::OnInsertCollectionAfter_()
1424 InsertCollectionAfter_();
1425 CreatePointsIntoNewCollection();
1426 UndoRedo_SaveCollection();
1429 //------------------------------------------------------------------------
1430 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
1432 OnInsertCollectionAfter_();
1435 //------------------------------------------------------------------------
1436 void WidgetShowNPoints::CreatePointsIntoNewCollection()
1438 int c1 = mActualCollection-1;
1439 int c2 = mActualCollection+1;
1440 int modelSize = lstModelShowNPoints.size();
1441 if (aux_mesh_type==2) // SplineClose2
1443 if (c1==-1) { c1=modelSize-1; }
1444 if (c2==modelSize) { c2=0; }
1445 } // if aux_mesh_type
1447 if ( (c1!=c2) && (c1>=0) && (c1<modelSize) && (c2>=0) && (c2<modelSize) )
1449 std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
1450 std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
1451 std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
1452 std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
1453 std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
1454 std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
1455 std::vector<double> c1LstXX;
1456 std::vector<double> c1LstYY;
1457 std::vector<double> c1LstZZ;
1458 std::vector<double> c2LstXX;
1459 std::vector<double> c2LstYY;
1460 std::vector<double> c2LstZZ;
1461 creaContoursFactory f;
1462 manualContourModel *m;
1465 int sc; // sizeContour
1467 if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
1469 // ----------------- Spline 1 --------------------
1471 size = c1LstX.size();
1472 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1473 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1474 m->SetNumberOfPointsSpline( sc );
1475 m->SetCloseContour( false );
1476 for (i=0;i<size;i++)
1478 m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
1483 m->GetSpline_i_Point(i,&x,&y,&z);
1484 c1LstXX.push_back(x);
1485 c1LstYY.push_back(y);
1486 c1LstZZ.push_back(z);
1489 // ----------------- Spline 2 --------------------
1490 size = c2LstX.size();
1491 m = (manualContourModel*)f.getContourModel( 1 ); // Spline
1492 // m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
1493 m->SetNumberOfPointsSpline( sc );
1494 m->SetCloseContour( false );
1495 for (i=0;i<size;i++)
1497 m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
1502 m->GetSpline_i_Point(i,&x,&y,&z);
1503 c2LstXX.push_back(x);
1504 c2LstYY.push_back(y);
1505 c2LstZZ.push_back(z);
1508 // ----------------- Add new Points --------------------
1509 vtkPoints *points = NULL;
1510 vtkStaticPointLocator *pointLocator = NULL;
1513 points = aux_mesh->GetPoints();
1514 pointLocator = vtkStaticPointLocator::New();
1515 pointLocator->SetDataSet( aux_mesh );
1516 pointLocator->BuildLocator();
1520 if ( c1LstX.size()<c2LstX.size() ) { size=c2LstX.size(); } else { size=c1LstX.size(); }
1521 for (ii=0;ii<size;ii++)
1523 i = (int) ((double)ii/((double)size-1)*(sc-1));
1524 x = (c1LstXX[i]+c2LstXX[i])/2;
1525 y = (c1LstYY[i]+c2LstYY[i])/2;
1526 z = (c1LstZZ[i]+c2LstZZ[i])/2;
1529 p[0] = x * aux_mesh_spc[0];
1530 p[1] = y * aux_mesh_spc[1];
1531 p[2] = z * aux_mesh_spc[2];
1532 points->GetPoint( pointLocator->FindClosestPoint(p) , pM );
1533 x = pM[0] / aux_mesh_spc[0];
1534 y = pM[1] / aux_mesh_spc[1];
1535 z = pM[2] / aux_mesh_spc[2];
1539 if (pointLocator!=NULL) { pointLocator->Delete(); }
1540 RefreshCollectionText();
1541 RefreshColourCollection();
1542 } // if size of c1LstX c2LstX
1546 //------------------------------------------------------------------------
1547 void WidgetShowNPoints::DeleteCollection_()
1549 if ( lstModelShowNPoints.size()>1 )
1551 DeleteAllPoints_(); // Actual Collection
1552 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
1553 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
1554 if ( mActualCollection>=lstModelShowNPoints.size() )
1556 mActualCollection--;
1559 DeleteAllPoints_(); // Actual Collection
1563 //------------------------------------------------------------------------
1564 void WidgetShowNPoints::OnDeleteCollection_()
1566 DeleteCollection_();
1568 GetViewShowNPoints()->Render();
1569 RefreshCollectionText();
1570 RefreshColourCollection();
1572 UndoRedo_SaveCollection();
1575 //------------------------------------------------------------------------
1576 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
1578 OnDeleteCollection_();
1581 //------------------------------------------------------------------------
1582 void WidgetShowNPoints::ResetCollections_()
1584 int i,size=lstModelShowNPoints.size();
1585 for (i=0;i<size;i++)
1587 DeleteCollection_();
1589 GetViewShowNPoints()->Render();
1590 RefreshCollectionText();
1591 RefreshColourCollection();
1596 //------------------------------------------------------------------------
1597 void WidgetShowNPoints::OnResetCollections_()
1599 ResetCollections_();
1600 UndoRedo_SaveCollection();
1604 //------------------------------------------------------------------------
1605 void WidgetShowNPoints::OnResetCollections(wxCommandEvent &event)
1607 OnResetCollections_();
1610 //------------------------------------------------------------------------
1611 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
1613 mActualCollection--;
1614 if ( mActualCollection <0 )
1616 // mActualCollection=0;
1617 mActualCollection = lstModelShowNPoints.size()-1;
1619 RefreshCollectionText();
1620 RefreshColourCollection();
1622 UndoRedo_SaveCollection();
1625 //------------------------------------------------------------------------
1626 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
1628 mActualCollection++;
1629 if ( mActualCollection >=lstModelShowNPoints.size() )
1631 // mActualCollection = lstModelShowNPoints.size()-1;
1632 mActualCollection = 0;
1633 } //if mActualCollection >= size
1634 RefreshCollectionText();
1635 RefreshColourCollection();
1637 UndoRedo_SaveCollection();
1640 //------------------------------------------------------------------------
1641 void WidgetShowNPoints::DetectCollectionActive()
1644 int i,size=lstModelShowNPoints.size();
1645 for (i=0;i<size;i++)
1647 id = lstModelShowNPoints[i]->IdInsidePoint();
1650 mActualCollection=i;
1653 RefreshCollectionText();
1654 RefreshColourCollection();
1657 //------------------------------------------------------------------------
1658 void WidgetShowNPoints::RefreshColourCollection()
1661 std::vector<double> colourAll;
1662 colourAll.push_back(1);
1663 colourAll.push_back(0);
1664 colourAll.push_back(0);
1665 std::vector<double> colourActualGroup;
1666 colourActualGroup.push_back(1);
1667 colourActualGroup.push_back(1);
1668 colourActualGroup.push_back(0);
1670 // For all collections
1671 SetColour( colourAll );
1672 int i,size=lstViewShowNPoints.size();
1673 for (i=0;i<size;i++)
1675 lstViewShowNPoints[i] -> mcolour = colourAll;
1676 lstViewShowNPoints[i] -> ratioRadio = 1;
1677 lstViewShowNPoints[i]->RefreshEachPoint();
1680 // Actual collection
1681 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1682 lstViewShowNPoints[mActualCollection] -> ratioRadio = 1.1;
1683 lstViewShowNPoints[mActualCollection] -> RefreshEachPoint();
1686 int curPnt = lstModelShowNPoints[mActualCollection] -> GetIdCurrentPoint();
1687 size=lstModelShowNPoints[mActualCollection]->GetLstPointsSize();
1688 if ((curPnt>=0) && (curPnt<size ) )
1690 std::vector<double> colourActualPoint;
1691 colourActualPoint.push_back(0);
1692 colourActualPoint.push_back(0);
1693 colourActualPoint.push_back(1);
1694 double radio = GetModelShowNPoints()->GetRadio();
1695 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualPoint;
1696 lstViewShowNPoints[mActualCollection]->RefreshPoint( curPnt );
1697 lstViewShowNPoints[mActualCollection] -> mcolour = colourActualGroup;
1699 lstViewShowNPoints[mActualCollection] -> renderer->GetRenderWindow()->Render();
1702 //------------------------------------------------------------------------
1703 void WidgetShowNPoints::RefreshCollectionText()
1705 if ((mtype==4) && (txtNrCollections!=NULL)) // Just for Collection interface
1708 strTmp.Printf(_T(" %d/%d"), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
1709 txtNrCollections->SetLabel( strTmp );
1715 //------------------------------------------------------------------------
1716 void WidgetShowNPoints::OnSaveCollections_( std::string filename )
1719 ff = fopen( filename.c_str() , "w+" );
1722 int i,size = lstModelShowNPoints.size();
1723 fprintf(ff,"NumberOfGroups %d \n",size);
1724 for (i=0 ; i<size ; i++)
1726 lstModelShowNPoints[i]->SavePoints_(ff);
1730 printf("WidgetShowNPoints::Save Groups Points ...Error... creating file \n");
1736 //------------------------------------------------------------------------
1737 void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
1739 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1740 #if wxMAJOR_VERSION <= 2
1741 wxFileDialog* FD = new wxFileDialog( 0,
1742 _T("Save groups of points .."),
1745 _T("(*.xls)|*.xls"),
1746 wxSAVE | wxOVERWRITE_PROMPT,
1749 wxFileDialog* FD = new wxFileDialog( 0,
1750 _T("Save groups of points .."),
1753 _T("(*.xls)|*.xls"),
1754 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
1758 int result_FD = FD->ShowModal();
1759 // This line is need it by windows //EED
1760 FD->SetReturnCode( result_FD );
1761 if (FD->GetReturnCode()==wxID_OK)
1763 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1764 OnSaveCollections_( filename );
1769 //------------------------------------------------------------------------
1770 void WidgetShowNPoints::OnLoadCollections_( std::string filename )
1772 bool okEraseFirstGroup=false;
1773 if (lstModelShowNPoints.size()==1)
1775 if (GetModelShowNPoints()->GetLstPointsSize()==0) { okEraseFirstGroup=true; }
1777 FILE *ff = fopen( filename.c_str() , "r+" );
1781 int iGroup,sizeGroups;
1782 int iPoint,numberPointsRead;
1784 fscanf(ff," %s %d",chartmp,&sizeGroups);
1785 for (iGroup=0;iGroup<sizeGroups;iGroup++)
1787 mActualCollection = lstModelShowNPoints.size();
1789 int numberPointsRead= lstModelShowNPoints[mActualCollection]->ReadPoints_(ff);
1790 for (i=0;i<numberPointsRead;i++)
1794 GetViewShowNPoints()->AddVtkPoint();
1800 printf("WidgetShowNPoints::Load Group of Points ...Error... reading file");
1802 if (okEraseFirstGroup==true)
1804 mActualCollection=0;
1805 DeleteCollection_();
1806 mActualCollection = lstModelShowNPoints.size()-1;
1808 GetViewShowNPoints()->Render();
1809 RefreshCollectionText();
1810 RefreshColourCollection();
1814 //------------------------------------------------------------------------
1815 void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
1817 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
1818 #if wxMAJOR_VERSION <= 2
1819 wxFileDialog* FD = new wxFileDialog( 0,
1820 _T("Load groups of points .."),
1823 _T("(*.xls)|*.xls"),
1824 wxOPEN | wxFILE_MUST_EXIST,
1827 wxFileDialog* FD = new wxFileDialog( 0,
1828 _T("Load groups of points .."),
1831 _T("(*.xls)|*.xls"),
1832 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
1835 int result_FD = FD->ShowModal();
1836 // This line is need it by windows //EED
1837 FD->SetReturnCode( result_FD );
1838 if (FD->GetReturnCode()==wxID_OK)
1840 std::string filename= (const char*) ( FD->GetPath().mb_str() );
1841 OnLoadCollections_( filename );
1842 UndoRedo_SaveCollection();
1846 //------------------------------------------------------------------------
1847 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
1850 lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
1855 //------------------------------------------------------------------------
1856 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
1858 if(idCol >= 0 && idCol < lstModelShowNPoints.size())
1860 lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
1861 lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
1864 printf("WidgetShowNPoints::SetCollectionPoint ...Error... Invalid collection, out of range");
1867 //------------------------------------------------------------------------
1868 std::vector<double> WidgetShowNPoints::GetLstPointsX()
1872 return GetModelShowNPoints()->GetLstPointsX();
1874 std::vector<double> lst;
1876 int iG,sG=lstModelShowNPoints.size();
1877 for (iG=0 ; iG<sG ; iG++)
1879 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
1881 for (iP=0 ; iP<s ; iP++)
1883 lst.push_back( lstTmp[iP] );
1890 //------------------------------------------------------------------------
1891 std::vector<double> WidgetShowNPoints::GetLstPointsY()
1895 return GetModelShowNPoints()->GetLstPointsY();
1897 std::vector<double> lst;
1899 int iG,sG=lstModelShowNPoints.size();
1900 for (iG=0 ; iG<sG ; iG++)
1902 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
1904 for (iP=0 ; iP<s ; iP++)
1906 lst.push_back( lstTmp[iP] );
1913 //------------------------------------------------------------------------
1914 std::vector<double> WidgetShowNPoints::GetLstPointsZ()
1918 return GetModelShowNPoints()->GetLstPointsZ();
1920 std::vector<double> lst;
1922 int iG,sG=lstModelShowNPoints.size();
1923 for (iG=0 ; iG<sG ; iG++)
1925 std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
1927 for (iP=0 ; iP<s ; iP++)
1929 lst.push_back( lstTmp[iP] );
1937 //------------------------------------------------------------------------
1938 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
1942 return GetModelShowNPoints()->GetLstLabels();
1944 std::vector< std::string > lst;
1946 int iG,sG=lstModelShowNPoints.size();
1947 for (iG=0 ; iG<sG ; iG++)
1949 std::vector< std::string > lstTmp = lstModelShowNPoints[iG]->GetLstLabels();
1951 for (iP=0 ; iP<s ; iP++)
1953 lst.push_back( lstTmp[iP] );
1960 //------------------------------------------------------------------------
1961 std::vector<int> WidgetShowNPoints::GetLstIndexs()
1963 std::vector<int> lstIndexs;
1966 lstIndexs.push_back( GetModelShowNPoints()->GetLstPointsSize() );
1968 int iG,sG=lstModelShowNPoints.size();
1969 for (iG=0 ; iG<sG ; iG++)
1971 lstIndexs.push_back( lstModelShowNPoints[iG]->GetLstPointsSize() );
1976 //------------------------------------------------------------------------
1977 int WidgetShowNPoints::GetLstModelShowNPointsSize()
1979 return lstModelShowNPoints.size();
1982 //------------------------------------------------------------------------
1983 void WidgetShowNPoints::InvertLstPoints_()
1985 int i,size=lstModelShowNPoints.size();
1987 for (i=0 ; i < size ; i++)
1989 lstModelShowNPoints[i]->InversLstPoints();
1993 ModelShowNPoints* tmpModel;
1995 for (i=0 ; i < size2 ; i++)
1997 tmpModel = lstModelShowNPoints[i];
1998 lstModelShowNPoints[i] = lstModelShowNPoints[size-1-i];
1999 lstModelShowNPoints[size-1-i] = tmpModel;
2004 //------------------------------------------------------------------------
2005 void WidgetShowNPoints::OnInvertLstPoints_()
2007 StopAutoAddPoints();
2011 UndoRedo_SaveCollection();
2015 //------------------------------------------------------------------------
2016 std::string WidgetShowNPoints::GetUndoRedoFileName()
2019 sprintf(buff,"%p_%d",this, idUndoRedo);
2020 return UndoRedoDir+"/"+"UndoRedo_collection_" + std::string(buff) + ".undoredo";
2024 //------------------------------------------------------------------------
2025 void WidgetShowNPoints::OnUndo(wxCommandEvent &event)
2027 ResetCollections_();
2028 // if (idUndoRedo==maxUndoRedo+1)
2031 // } // if idUndoRedo+1
2038 OnLoadCollections_( GetUndoRedoFileName() );
2044 //------------------------------------------------------------------------
2045 void WidgetShowNPoints::OnRedo(wxCommandEvent &event)
2047 if (idUndoRedo>maxUndoRedo)
2049 idUndoRedo=maxUndoRedo+1;
2051 ResetCollections_();
2052 OnLoadCollections_( GetUndoRedoFileName() );
2057 //------------------------------------------------------------------------
2058 void WidgetShowNPoints::UndoRedo_SaveCollection()
2060 OnSaveCollections_( GetUndoRedoFileName() );
2061 maxUndoRedo = idUndoRedo;
2065 //------------------------------------------------------------------------
2066 void WidgetShowNPoints::SetAuxMesh(vtkPolyData* mesh, std::vector<double> spc, std::vector<double> params)
2070 if (params.size()==1)
2072 aux_mesh_type = params[0];