3 #include "vtkSphereSource.h"
4 #include "vtkRenderer.h"
5 #include "vtkTextActor3D.h"
11 #include <wx/filedlg.h>
12 #include <wx/msgdlg.h>
13 #include <wx/notebook.h>
15 #include "WidgetShowNPoints.h"
18 //----------------------------------------------------------------------
19 //----------------------------------------------------------------------
20 //----------------------------------------------------------------------
21 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
24 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
26 printf("EED WidgetShowNPoints::WidgetShowNPoints Start \n");
28 // mmodelShowNPoints = new ModelShowNPoints();
30 ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
31 lstModelShowNPoints.push_back( modelShowNPoints );
32 lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
36 wxPanel* panelParent = this;
37 wxSizer* sizer = NULL;
38 wxSizer* MNPsizer = NULL;
40 wxNotebook* bookSetPoints = NULL;
41 wxNotebook* bookGroupManager = NULL;
42 wxPanel* panel = NULL;
43 wxPanel* panel2 = NULL;
48 bookSetPoints = new wxNotebook(panelParent,
53 panel = new wxPanel(bookSetPoints);
59 bookGroupManager = new wxNotebook(panelParent, //bbGetWxParent(),
64 panel2 = new wxPanel(bookGroupManager);
65 txtNrCollections = new wxStaticText(panel2,-1, _T("1 / 1 "));
66 wxButton *btnBackCollection = new wxButton( panel2, -1, _T("<"));
67 wxButton *btnNextCollection = new wxButton( panel2, -1, _T(">"));
68 wxButton *btnInsertCollectionBefore = new wxButton( panel2, -1, _T("Insert Before"));
69 wxButton *btnInsertCollectionAfter = new wxButton( panel2, -1, _T("Insert After"));
70 wxButton *btnDeleteCollection = new wxButton( panel2, -1, _T("Delete"));
72 Connect(btnInsertCollectionBefore->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionBefore);
73 Connect(btnInsertCollectionAfter->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnInsertCollectionAfter);
74 Connect(btnDeleteCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteCollection);
75 Connect(btnBackCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection);
76 Connect(btnNextCollection->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection);
78 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
79 wxFlexGridSizer *sizer2 = new wxFlexGridSizer(2);
81 sizer2->Add( btnBackCollection );
82 sizer2->Add( btnNextCollection );
84 sizer1->Add( txtNrCollections );
85 sizer1->Add( sizer2 );
86 sizer1->Add( btnInsertCollectionBefore );
87 sizer1->Add( btnInsertCollectionAfter );
88 sizer1->Add( btnDeleteCollection );
90 panel2->SetSizer( MNPsizer );
91 panel2->SetAutoLayout(true);
93 bookGroupManager->AddPage(panel2 , _T("Collection") );
96 if ( (mtype==0) || (mtype==3) || (mtype==4) )
99 askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR
100 textCtrl = new wxTextCtrl(panel, -1);
101 wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point"));
102 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("Insert Point"));//CFT
103 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
104 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point"));
105 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point"));
106 wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point"));
107 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
108 wxButton *btnSavePoints = NULL;
109 wxButton *btnLoadPoints = NULL;
110 if ( (mtype==0) || (mtype==4) )
112 btnSavePoints = new wxButton( panel, -1, _T("Save points"));
113 btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
115 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
117 //NTU: Sliders for opacity and radio change
118 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
119 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
120 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radius ")));
121 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
123 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
124 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
125 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
126 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
127 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
128 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
129 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
130 if ((mtype==0) || (mtype==4) )
132 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
133 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
136 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
137 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
139 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
140 sizer1->Add(askPointLabel); // JPR
141 sizer1->Add(textCtrl);
142 sizer1->Add(btnAddPoint);
143 sizer1->Add(btnInsertPoint);//CFT
144 sizer1->Add(btnSetPositionPoint);
145 sizer1->Add(btnRenamePoint);
146 sizer1->Add(btnErasePoint);
147 sizer1->Add(btnEraseLastPoint);
148 sizer1->Add(btnDeleteAllPoints);
149 sizer1->Add(txtNrPoints);
150 sizer1->Add(txOpacity);
151 sizer1->Add(sdrOpacity,1,wxGROW );
152 sizer1->Add(txRadio);
153 sizer1->Add(sdrRadio,1,wxGROW );
154 if ((mtype==0) || (mtype==4) )
156 sizer1->Add(btnSavePoints);
157 sizer1->Add(btnLoadPoints);
165 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
166 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
168 //NTU: Sliders for opacity and radio change
169 wxStaticText* txOpacity = new wxStaticText(panel, -1, wxString(_T(" Points Opacity ")));
170 sdrOpacity = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
171 wxStaticText* txRadio = new wxStaticText(panel, -1, wxString(_T(" Points Radio ")));
172 sdrRadio = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
173 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
174 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
175 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
177 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
178 sizer1->Add(btnSetPositionPoint);
179 sizer1->Add(txtNrPoints);
180 sizer1->Add(txOpacity);
181 sizer1->Add(sdrOpacity,1,wxGROW );
182 sizer1->Add(txRadio);
183 sizer1->Add(sdrRadio,1,wxGROW );
189 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
190 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
191 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
192 wxStaticText *spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
193 textCtrl = new wxTextCtrl(panel, -1);
194 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
195 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
196 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
197 sizer1->Add(askPointLabel);
198 sizer1->Add(btnAddPoint);
199 sizer1->Add(btnDeleteAllPoints);
201 sizer1->Add(textCtrl);
202 // sdrOpacity = new wxSlider();
203 // sdrRadio = new wxSlider();
204 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
206 } // bbGetInputType 2
209 panel->SetSizer(sizer);
210 panel->SetAutoLayout(true);
212 bookSetPoints->AddPage(panel , _T("Set Points") );
214 if ((mtype >= 0) && (mtype <= 3) )
218 wxFlexGridSizer *sizerParent = new wxFlexGridSizer(1);
219 sizerParent->Add( bookSetPoints );
220 panelParent->SetSizer( sizerParent );
221 panelParent->SetAutoLayout(true);
222 panelParent->Layout();
224 } // if mtype 0 1 2 3
228 if ((sizer!=NULL) && (MNPsizer!=NULL))
230 wxFlexGridSizer *sizerG = new wxFlexGridSizer(2);
231 sizerG->Add(bookGroupManager);
232 sizerG->Add(bookSetPoints);
233 panelParent->SetSizer(sizerG);
234 panelParent->SetAutoLayout(true);
235 panelParent->Layout();
240 //------------------------------------------------------------------------
241 WidgetShowNPoints::~WidgetShowNPoints()
245 //------------------------------------------------------------------------
246 ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
249 // return mmodelShowNPoints;
250 return lstModelShowNPoints[ mActualCollection ];
254 //------------------------------------------------------------------------
255 ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
257 return lstViewShowNPoints[ mActualCollection ];
261 //------------------------------------------------------------------------
262 void WidgetShowNPoints::SetRadio(double radio)
265 // GetModelShowNPoints()->SetRadio(radio);
266 int i,size = lstModelShowNPoints.size();
269 lstModelShowNPoints[i]->SetRadio( radio );
272 sdrRadio->SetValue(radio);
275 //------------------------------------------------------------------------
276 void WidgetShowNPoints::SetColour(std::vector<double> colour)
279 //this->mcolour = colour;
280 int i,size = lstViewShowNPoints.size();
281 for (i=0 ; i<size ; i++)
283 lstViewShowNPoints[i]->mcolour = colour;
287 //------------------------------------------------------------------------
288 void WidgetShowNPoints::SetImage(vtkImageData* image)
291 //GetModelShowNPoints()->SetImage(image);
292 int i,size = lstModelShowNPoints.size();
293 for (i=0 ; i<size ; i++)
295 lstModelShowNPoints[i]->SetImage(image);
299 //------------------------------------------------------------------------
300 void WidgetShowNPoints::SetOpacity(double opacity)
303 //this->mopacity=opacity;
304 int i,size = lstViewShowNPoints.size();
305 for (i=0 ; i<size ; i++)
307 lstViewShowNPoints[i]->mopacity = opacity;
310 sdrOpacity->SetValue( opacity*100.0 );
314 //------------------------------------------------------------------------
315 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
318 //this->renderer = renderer;
319 int i,size = lstViewShowNPoints.size();
320 for (i=0 ; i<size ; i++)
322 lstViewShowNPoints[i]->renderer = renderer;
327 //------------------------------------------------------------------------
329 void WidgetShowNPoints::RefreshPoint(int id)
333 GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
334 GetModelShowNPoints()->GetImage()->GetSpacing(spc);
335 std::string label = GetModelShowNPoints()->GetIdLabel(id);
336 double radio = GetModelShowNPoints()->GetRadio();
337 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
338 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
339 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
340 lstSourceSphere[id]->SetRadius( radio );
341 //EED 2017-01-01 Migration VTK7
342 #if VTK_MAJOR_VERSION <= 5
345 lstSourceSphere[id]->Update();
347 lstActorsText[id]->SetInput( label.c_str() );
348 lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
351 //------------------------------------------------------------------------
352 void WidgetShowNPoints::RefreshPoints()
354 int id,size=lstActorsSphere.size();
355 for (id=0;id<size;id++)
359 renderer->GetRenderWindow()->Render();
362 //------------------------------------------------------------------------
363 void WidgetShowNPoints::AddVtkPoint()
366 vtkSphereSource *vtksphere = vtkSphereSource::New();
367 vtksphere->SetThetaResolution (20);
368 vtksphere->SetPhiResolution (20);
369 vtksphere->SetRadius( 1 );
370 //NTU: For updating points
371 lstSourceSphere.push_back(vtksphere);
372 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
374 //EED 2017-01-01 Migration VTK7
375 #if VTK_MAJOR_VERSION <= 5
376 sphereMapper->SetInput( vtksphere->GetOutput() );
379 sphereMapper->SetInputData( vtksphere->GetOutput() );
382 vtkActor *sphereActor = vtkActor::New();
383 sphereActor->SetMapper(sphereMapper);
384 sphereActor->SetOrigin(0, 0, 0);
386 lstActorsSphere.push_back(sphereActor);
388 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
392 renderer->AddActor( sphereActor );
394 vtkTextActor3D *textActor = vtkTextActor3D::New();
395 // textActor->SetInput( strLabel.c_str() );
396 renderer->AddActor( textActor );
397 lstActorsText.push_back(textActor);
402 //------------------------------------------------------------------------
403 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
405 GetModelShowNPoints()->AddPoint(x,y,z, label );
408 //RefreshPoint(lstActorsSphere.size()-1);
409 GetViewShowNPoints()->AddPoint();
412 //------------------------------------------------------------------------
413 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
416 //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
420 // AddPoint(x,y,z,label);
423 if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
425 GetViewShowNPoints()->AddVtkPoint();
427 AddPoint(x,y,z,label);
429 GetViewShowNPoints()->RefreshPoints();
433 //------------------------------------------------------------------------
434 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
437 //if (this->renderer==NULL)
438 if (GetViewShowNPoints()->renderer==NULL)
443 std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
446 AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
449 //renderer->GetRenderWindow()->Render();
450 GetViewShowNPoints()->Render();
451 } else {//mpoint.size
452 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
456 //------------------------------------------------------------------------
457 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
460 //if (this->renderer==NULL)
461 if (GetViewShowNPoints()->renderer==NULL)
466 std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
469 InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
471 } else {//mpoint.size
472 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
477 //------------------------------------------------------------------------
478 void WidgetShowNPoints::SetOutputBox()
480 //EED renderer->GetRenderWindow()->Render();
482 strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
483 txtNrPoints->SetLabel( strTmp );
487 // mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
488 // mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
489 // mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
490 // mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
491 // mbbShowNPoints->bbSignalOutputModification();
495 //------------------------------------------------------------------------
496 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
499 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
500 #if wxMAJOR_VERSION <= 2
501 wxFileDialog* FD = new wxFileDialog( 0,
502 _T("Save points .."),
506 wxSAVE | wxOVERWRITE_PROMPT,
509 wxFileDialog* FD = new wxFileDialog( 0,
510 _T("Save points .."),
514 wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
518 int result_FD = FD->ShowModal();
519 // This line is need it by windows //EED
520 FD->SetReturnCode( result_FD );
521 if (FD->GetReturnCode()==wxID_OK)
523 std::string filename= (const char*) ( FD->GetPath().mb_str() );
524 GetModelShowNPoints()->SavePoints( filename );
529 //------------------------------------------------------------------------
530 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
533 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
534 #if wxMAJOR_VERSION <= 2
535 wxFileDialog* FD = new wxFileDialog( 0,
536 _T("Load points .."),
540 wxOPEN | wxFILE_MUST_EXIST,
543 wxFileDialog* FD = new wxFileDialog( 0,
544 _T("Load points .."),
548 wxFD_OPEN | wxFD_FILE_MUST_EXIST,
553 int result_FD = FD->ShowModal();
554 // This line is need it by windows //EED
555 FD->SetReturnCode( result_FD );
556 if (FD->GetReturnCode()==wxID_OK)
559 std::string filename= (const char*) ( FD->GetPath().mb_str() );
560 int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
561 for (i=0;i<numberPointsRead;i++)
565 GetViewShowNPoints()->AddVtkPoint();
570 GetViewShowNPoints()->RefreshPoints();
574 //------------------------------------------------------------------------
575 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
577 int id=GetModelShowNPoints()->GetNearestPoint();
578 if((id==-1) && (mtype==1))
587 GetModelShowNPoints()->SetPointId_mReferencePoint(id);
590 //renderer->GetRenderWindow()->Render();
591 GetViewShowNPoints()->RefreshPoint(id);
592 GetViewShowNPoints()->Render();
597 //------------------------------------------------------------------------
598 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
600 int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
604 //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
605 //renderer->GetRenderWindow()->Render();
606 GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
607 GetViewShowNPoints()->Render();
612 //------------------------------------------------------------------------
613 void WidgetShowNPoints::ErasePoint(int id)
616 //if (this->renderer!=NULL)
617 if (GetViewShowNPoints()->renderer!=NULL)
622 //renderer->RemoveActor( lstActorsSphere[id] );
623 //renderer->RemoveActor( lstActorsText[id] );
624 //lstActorsSphere[id]->Delete();
625 //lstActorsText[id]->Delete();
626 //lstSourceSphere[id]->Delete();
627 //lstActorsSphere.erase( lstActorsSphere.begin()+id );
628 //lstActorsText.erase( lstActorsText.begin()+id );
629 //lstSourceSphere.erase( lstSourceSphere.begin()+id );
630 GetViewShowNPoints()->ErasePoint(id);
631 GetModelShowNPoints()->ErasePoint(id);
636 //------------------------------------------------------------------------
637 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
639 ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
642 //renderer->GetRenderWindow()->Render();
643 GetViewShowNPoints()->Render();
646 //------------------------------------------------------------------------
647 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
650 //ErasePoint( lstActorsSphere.size()-1 );
651 //renderer->GetRenderWindow()->Render();
652 int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
654 GetViewShowNPoints()->Render();
658 //------------------------------------------------------------------------
659 void WidgetShowNPoints::DeleteAllPoints()
662 //int id,size=lstActorsSphere.size();
663 int id,size=GetViewShowNPoints()->lstActorsSphere.size();
664 for (id=size-1;id>=0;id--)
670 //renderer->GetRenderWindow()->Render();
671 GetViewShowNPoints()->Render();
674 //------------------------------------------------------------------------
675 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
680 //NTU: Method for updating points opacity and Radio
682 //------------------------------------------------------------------------
683 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
686 //this->mopacity = sdrOpacity->GetValue()/100.0;
687 //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
690 double opacity = sdrOpacity->GetValue()/100.0;
691 double radio = sdrRadio->GetValue();
692 int i,size = lstViewShowNPoints.size();
693 for (i=0 ; i<size ; i++)
695 lstViewShowNPoints[i]->mopacity = opacity;
696 lstModelShowNPoints[i]->SetRadio( radio ) ;
698 GetViewShowNPoints()->RefreshPoints();
701 //------------------------------------------------------------------------
702 void WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
704 GetModelShowNPoints()->SetReferencePoint(point);
707 //------------------------------------------------------------------------
708 void WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
711 //if (this->renderer==NULL)
712 if (GetViewShowNPoints()->renderer==NULL)
716 int i,sizeX,sizeY,sizeZ,sizeLabels;
717 sizeX = (int)initLstPointsX.size();
718 sizeY = (int)initLstPointsY.size();
719 sizeZ = (int)initLstPointsZ.size();
720 sizeLabels = (int)initLstLabels.size();
723 if ( (sizeX==sizeY) && (sizeX==sizeZ) )
725 for (i=0;i<sizeX;i++)
727 x = initLstPointsX[i];
728 y = initLstPointsY[i];
729 z = initLstPointsZ[i];
732 label = initLstLabels[i];
736 AddPoint( x,y,z,label );
739 // renderer->GetRenderWindow()->Render();
743 //------------------------------------------------------------------------
744 void WidgetShowNPoints::SetType(int type)
749 //------------------------------------------------------------------------
750 int WidgetShowNPoints::GetType()
756 //------------------------------------------------------------------------
757 double WidgetShowNPoints::GetRadio()
759 return sdrRadio->GetValue();
761 //------------------------------------------------------------------------
762 double WidgetShowNPoints::GetOpacity()
764 return sdrOpacity->GetValue()/100;
767 //------------------------------------------------------------------------
768 void WidgetShowNPoints::InsertCollection()
770 ModelShowNPoints* model = new ModelShowNPoints();
771 ViewShowNPoints* view = new ViewShowNPoints( model );
772 model->SetImage( lstModelShowNPoints[0]->GetImage() );
773 view->mopacity = lstViewShowNPoints[0]->mopacity;
774 view->renderer = lstViewShowNPoints[0]->renderer;
775 lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
776 lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
777 RefreshCollectionText();
780 //------------------------------------------------------------------------
781 void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
786 //------------------------------------------------------------------------
787 void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
793 //------------------------------------------------------------------------
794 void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
796 if ( lstModelShowNPoints.size()>1 )
798 DeleteAllPoints(); // Actual Collection
799 lstModelShowNPoints.erase( lstModelShowNPoints.begin()+mActualCollection );
800 lstViewShowNPoints.erase( lstViewShowNPoints.begin()+mActualCollection );
801 if ( mActualCollection>=lstModelShowNPoints.size() )
806 RefreshCollectionText();
809 //------------------------------------------------------------------------
810 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
813 if ( mActualCollection <0 )
817 RefreshCollectionText();
820 //------------------------------------------------------------------------
821 void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
824 if ( mActualCollection >=lstModelShowNPoints.size() )
826 mActualCollection = lstModelShowNPoints.size()-1;
828 RefreshCollectionText();
831 //------------------------------------------------------------------------
832 void WidgetShowNPoints::RefreshCollectionText()
835 strTmp.Printf(_T("%d / %d "), (int)mActualCollection+1, (int)lstModelShowNPoints.size() );
836 txtNrCollections->SetLabel( strTmp );