1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuShowNPoints.h"
27 #include "bbcreaMaracasVisuPackage.h"
29 #include "vtkProperty.h"
30 #include "vtkSphereSource.h"
31 #include "vtkPolyDataMapper.h"
32 #include "vtkRenderWindow.h"
33 #include "vtkTextActor3D.h"
34 #include <vtkTextProperty.h>
36 namespace bbcreaMaracasVisu
39 //----------------------------------------------------------------------
40 WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, bbcreaMaracasVisu::ShowNPoints *box)
41 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
44 this->renderer = NULL;
45 wxPanel *panel = this;
46 wxSizer *sizer = NULL;
48 if (mbbShowNPoints->bbGetInputType()==0)
51 askPointLabel = new wxStaticText(panel, -1, _T("Point label :")); // JPR
52 textCtrl = new wxTextCtrl(panel, -1);
53 wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point"));
54 wxButton *btnInsertPoint = new wxButton( panel, -1, _T("Insert Point"));//CFT
55 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
56 wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Rename point"));
57 wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point"));
58 wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point"));
59 wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
60 wxButton *btnSavePoints = new wxButton( panel, -1, _T("Save points"));
61 wxButton *btnLoadPoints = new wxButton( panel, -1, _T("Load points"));
62 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
64 //NTU: Sliders for opacity and radio change
65 wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T(" Points Opacity ")));
66 sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
67 wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T(" Points Radio ")));
68 sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
70 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
71 // sizer1->Add(new wxStaticText(panel,-1,_T(" ")));
73 Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
74 Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT
75 Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
76 Connect(btnRenamePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRenamePoint);
77 Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
78 Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
79 Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
80 Connect(btnSavePoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
81 Connect(btnLoadPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
84 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
85 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
87 sizer1->Add(askPointLabel); // JPR
88 sizer1->Add(textCtrl);
89 sizer1->Add(btnAddPoint);
90 sizer1->Add(btnInsertPoint);//CFT
91 sizer1->Add(btnSetPositionPoint);
92 sizer1->Add(btnRenamePoint);
93 sizer1->Add(btnErasePoint);
94 sizer1->Add(btnEraseLastPoint);
95 sizer1->Add(btnDeleteAllPoints);
96 sizer1->Add(txtNrPoints);
97 sizer1->Add(txOpacity);
98 sizer1->Add(sdrOpacity,1,wxGROW );
100 sizer1->Add(sdrRadio,1,wxGROW );
101 sizer1->Add(btnSavePoints);
102 sizer1->Add(btnLoadPoints);
106 if (mbbShowNPoints->bbGetInputType()==1)
109 wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set nearest point"));
110 txtNrPoints = new wxStaticText(panel,-1, _T(" "));
112 //NTU: Sliders for opacity and radio change
113 wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T(" Points Opacity ")));
114 sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
115 wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T(" Points Radio ")));
116 sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
117 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
118 Connect(btnSetPositionPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
119 Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
120 Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
122 sizer1->Add(btnSetPositionPoint);
123 sizer1->Add(txtNrPoints);
124 sizer1->Add(txOpacity);
125 sizer1->Add(sdrOpacity,1,wxGROW );
126 sizer1->Add(txRadio);
127 sizer1->Add(sdrRadio,1,wxGROW );
131 if (mbbShowNPoints->bbGetInputType() == 2) {
132 askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
134 wxButton *btnAddPoint = new wxButton(panel, -1, _T(" Add Point "));
135 wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T(" Delete All "));
136 wxStaticText* spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
137 textCtrl = new wxTextCtrl(panel, -1);
139 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
141 Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
142 Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
144 sizer1->Add(askPointLabel);
145 sizer1->Add(btnAddPoint);
146 sizer1->Add(btnDeleteAllPoints);
148 sizer1->Add(textCtrl);
150 sdrOpacity = new wxSlider();
151 sdrRadio = new wxSlider();
153 txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
159 panel->SetSizer(sizer);
160 panel->SetAutoLayout(true);
165 //------------------------------------------------------------------------
166 WidgetShowNPoints::~WidgetShowNPoints()
170 //------------------------------------------------------------------------
171 void WidgetShowNPoints::SetRadio(double radio)
175 sdrRadio->SetValue(this->mradio);
178 //------------------------------------------------------------------------
179 std::vector<int> WidgetShowNPoints::GetLstPointsX()
184 //------------------------------------------------------------------------
185 std::vector<int> WidgetShowNPoints::GetLstPointsY()
190 //------------------------------------------------------------------------
191 std::vector<int> WidgetShowNPoints::GetLstPointsZ()
196 //------------------------------------------------------------------------
197 std::vector<std::string> WidgetShowNPoints::GetLstLabels()
202 //------------------------------------------------------------------------
203 void WidgetShowNPoints::SetPoint(std::vector<int> ppoint)
208 //------------------------------------------------------------------------
209 void WidgetShowNPoints::SetColour(std::vector<double> colour)
211 this->mcolour = colour;
214 //------------------------------------------------------------------------
215 void WidgetShowNPoints::SetOpacity(double opacity)
217 this->mopacity=opacity;
219 sdrOpacity->SetValue(this->mopacity*100.0);
222 //------------------------------------------------------------------------
223 void WidgetShowNPoints::SetImage(vtkImageData *image)
228 //------------------------------------------------------------------------
229 void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
231 this->renderer = renderer;
234 //------------------------------------------------------------------------
236 std::string WidgetShowNPoints::CleanSpaces(std::string ss)
239 while( (i=ss.find(32))>=0 )
247 //------------------------------------------------------------------------
249 void WidgetShowNPoints::RefreshPoint(int id)
251 int x = lstPointsX[id];
252 int y = lstPointsY[id];
253 int z = lstPointsZ[id];
256 mimage->GetSpacing(spc);
258 lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
259 lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
260 lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
262 lstActorsText[id]->SetPosition( mradio+spc[0]*x , spc[1]*y , spc[2]*z );
266 //------------------------------------------------------------------------
267 void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
269 lstPointsX.push_back( x );
270 lstPointsY.push_back( y );
271 lstPointsZ.push_back( z );
273 std::string strLabel = CleanSpaces( label );
275 lstLabels.push_back( strLabel );
278 vtkSphereSource *vtksphere = vtkSphereSource::New();
279 vtksphere->SetThetaResolution (20);
280 vtksphere->SetPhiResolution (20);
281 vtksphere->SetRadius( mradio );
283 //NTU: For updating points
285 lstSourceSphere.push_back(vtksphere);
287 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
288 sphereMapper->SetInput( vtksphere->GetOutput() );
289 vtkActor *sphereActor = vtkActor::New();
290 sphereActor->SetMapper(sphereMapper);
291 sphereActor->SetOrigin(0, 0, 0);
296 wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
300 mimage->GetSpacing(spc);
301 sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
302 sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
303 sphereActor->GetProperty()->SetOpacity( mopacity );
306 lstActorsSphere.push_back(sphereActor);
308 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
312 renderer->AddActor( sphereActor );
315 vtkTextActor3D *textActor = vtkTextActor3D::New();
317 textActor->SetPosition( mradio+spc[0]*x , spc[1]*y , spc[2]*z );
319 textActor->SetInput( strLabel.c_str() );
320 renderer->AddActor( textActor );
321 lstActorsText.push_back(textActor);
323 RefreshPoint(lstPointsX.size()-1);
326 //------------------------------------------------------------------------
327 double WidgetShowNPoints::Distance(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1)//CFT
329 return sqrt((dX1 - dX0)*(dX1 - dX0) + (dY1 - dY0)*(dY1 - dY0) + (dZ1 - dZ0)*(dZ1 - dZ0));
332 //------------------------------------------------------------------------
333 void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
335 std::cout<<"WidgetShowNPoints::InsertPoint begin "<<std::endl;
336 std::vector<int> dTotal;
339 //Calcule distance for each pair of points
340 for(int i = 0; i<lstPointsX.size()-1 ; i++)
342 a = Distance(x, y, z, lstPointsX[i], lstPointsY[i], lstPointsZ[i]);
343 b = Distance(x, y, z, lstPointsX[i+1], lstPointsY[i+1], lstPointsZ[i+1]);
345 dTotal.push_back (res);
347 //Gets the smallest distance
348 int small = dTotal[0];
349 for (int j = 0; j < dTotal.size(); j++)
358 std::vector<int>::iterator it;
359 //Insert the point in the list of points
360 it = lstPointsX.begin();
361 lstPointsX.insert( it+pos, x );
362 it = lstPointsY.begin();
363 lstPointsY.insert( it+pos, y );
364 it = lstPointsZ.begin();
365 lstPointsZ.insert( it+pos, z );
367 std::string strLabel = CleanSpaces( label );
369 std::vector<std::string>::iterator itS;
370 itS = lstLabels.begin();
371 //Insert Label in list of labels
372 lstLabels.insert( itS+pos, strLabel );
375 vtkSphereSource *vtksphere = vtkSphereSource::New();
376 vtksphere->SetThetaResolution (20);
377 vtksphere->SetPhiResolution (20);
378 vtksphere->SetRadius( mradio );
380 //NTU: For updating points
381 std::vector<vtkSphereSource*>::iterator itSS;
382 itSS = lstSourceSphere.begin();
383 lstSourceSphere.insert( itSS+pos, vtksphere);
385 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
386 sphereMapper->SetInput( vtksphere->GetOutput() );
387 vtkActor *sphereActor = vtkActor::New();
388 sphereActor->SetMapper(sphereMapper);
389 sphereActor->SetOrigin(0, 0, 0);
391 std::vector<vtkActor*>::iterator itAS;
392 itAS = lstActorsSphere.begin();
393 lstActorsSphere.insert( itAS+pos, sphereActor);
395 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
399 renderer->AddActor( sphereActor );
402 vtkTextActor3D *textActor = vtkTextActor3D::New();
404 textActor->SetInput( strLabel.c_str() );
405 renderer->AddActor( textActor );
406 std::vector<vtkTextActor3D*>::iterator itTA;
407 itTA = lstActorsText.begin();
408 lstActorsText.insert( itTA+pos , textActor);
411 std::cout<<"WidgetShowNPoints::InsertPoint end"<<std::endl;
414 //------------------------------------------------------------------------
415 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
418 wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
423 if (this->renderer!=NULL){
424 if (mpoint.size()==3){
425 AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
427 } else {//mpoint.size
428 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
433 //------------------------------------------------------------------------
434 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
436 std::cout<<"WidgetShowNPoints::OnInsertPoint begin"<<std::endl;
438 wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
443 if (this->renderer!=NULL){
444 if (mpoint.size()==3){
445 InsertPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
447 } else {//mpoint.size
448 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
451 std::cout<<"WidgetShowNPoints::OnInsertPoint end"<<std::endl;
455 //------------------------------------------------------------------------
456 void WidgetShowNPoints::SetOutputBox()
458 renderer->GetRenderWindow()->Render();
460 strTmp.Printf(_T("Nbr of points: %d"), (int)(lstPointsX.size()) );
461 txtNrPoints->SetLabel( strTmp );
464 mbbShowNPoints->bbSetOutputlstPointsX( lstPointsX );
465 mbbShowNPoints->bbSetOutputlstPointsY( lstPointsY );
466 mbbShowNPoints->bbSetOutputlstPointsZ( lstPointsZ );
467 mbbShowNPoints->bbSetOutputlstLabels( lstLabels );
469 mbbShowNPoints->bbSignalOutputModification();
472 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
473 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
474 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
475 // mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
478 //------------------------------------------------------------------------
479 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
481 wxFileDialog* FD = new wxFileDialog( 0,
482 _T("Save points .."),
486 wxSAVE | wxOVERWRITE_PROMPT,
490 int result_FD = FD->ShowModal();
491 std::string tmpLabel;
493 // This line is need it by windows //EED
494 FD->SetReturnCode( result_FD );
496 if (FD->GetReturnCode()==wxID_OK)
499 std::string filename= (const char*) ( FD->GetPath().mb_str() );
500 ff = fopen( filename.c_str() , "w+" );
503 int i , size = (int) (lstActorsSphere.size());
504 fprintf(ff,"NumberOfPoints %d \n",size);
505 fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
508 for (i=0; i<size; i++)
513 value= mimage->GetScalarComponentAsDouble(x,y,z,0);
514 if (lstLabels[i]!="")
516 tmpLabel=lstLabels[i];
520 fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
524 printf("WidgetShowNPoints::OnSavePoints ...Error... creating file");
529 //------------------------------------------------------------------------
530 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
532 wxFileDialog* FD = new wxFileDialog( 0,
533 _T("Load points .."),
537 wxOPEN | wxFILE_MUST_EXIST,
541 int result_FD = FD->ShowModal();
543 // This line is need it by windows //EED
544 FD->SetReturnCode( result_FD );
546 if (FD->GetReturnCode()==wxID_OK)
549 std::string filename= (const char*) ( FD->GetPath().mb_str() );
550 ff = fopen( filename.c_str() , "r+" );
555 fscanf(ff," %s %d",chartmp,&size);
556 fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
560 for (i=0; i<size; i++)
562 fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
563 if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
564 AddPoint(x,y,z, chartmp );
569 printf("WidgetShowNPoints::OnLoadPoints ...Error... reading file");
576 //------------------------------------------------------------------------
578 int WidgetShowNPoints::GetNearestPoint()
581 int i, size=(int)(lstActorsSphere.size());
582 double radioMin=10000000;
585 wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
590 for ( i=0 ; i<size; i++ )
592 double rx = mpoint[0] - lstPointsX [i];
593 double ry = mpoint[1] - lstPointsY [i];
594 double rz = mpoint[2] - lstPointsZ [i];
595 double radio = rx*rx + ry*ry + rz*rz;
596 if ( radio <= radioMin)
608 //------------------------------------------------------------------------
609 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
611 int id=GetNearestPoint();
612 if((id==-1) && (mbbShowNPoints->bbGetInputType()==1))
622 printf("WidgetShowNPoints::OnSetPoint \n");
623 lstPointsX[id] = mpoint[0];
624 lstPointsY[id] = mpoint[1];
625 lstPointsZ[id] = mpoint[2];
628 this->lstActorsSphere[id]->SetPosition( spc[0]*mpoint[0]+difradio, spc[1]*mpoint[1], spc[2]* mpoint[2] );
629 this->lstActorsText[id]->SetPosition( spc[0]*mpoint[0]+difradio, spc[1]*mpoint[1], spc[2]* mpoint[2] );
636 //------------------------------------------------------------------------
638 int WidgetShowNPoints::IdInsidePoint()
641 int i, size=(int)(lstActorsSphere.size());
645 wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
650 mimage->GetSpacing(spc);
652 for ( i=0 ; i<size; i++ )
654 double rx = spc[0]*(mpoint[0] - lstPointsX [i]);
655 double ry = spc[1]*(mpoint[1] - lstPointsY [i]);
656 double rz = spc[2]*(mpoint[2] - lstPointsZ [i]);
657 if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
667 //------------------------------------------------------------------------
668 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
670 int id=IdInsidePoint();
673 std::string strLabel = CleanSpaces( (const char*) ( textCtrl->GetValue().mb_str() ) );
674 lstLabels[id] = CleanSpaces( (const char*) (textCtrl->GetValue().mb_str()) ) ;
675 lstActorsText[id]->SetInput( lstLabels[id].c_str() );
680 //------------------------------------------------------------------------
681 void WidgetShowNPoints::ErasePoint(int id)
683 if (this->renderer!=NULL){
685 renderer->RemoveActor( lstActorsSphere[id] );
686 renderer->RemoveActor( lstActorsText[id] );
687 lstActorsSphere[id]->Delete();
688 lstActorsText[id]->Delete();
689 lstSourceSphere[id]->Delete();
690 lstActorsSphere.erase( lstActorsSphere.begin()+id );
691 lstActorsText.erase( lstActorsText.begin()+id );
692 lstSourceSphere.erase( lstSourceSphere.begin()+id );
694 lstPointsX.erase( lstPointsX.begin()+id );
695 lstPointsY.erase( lstPointsY.begin()+id );
696 lstPointsZ.erase( lstPointsZ.begin()+id );
697 lstLabels.erase( lstLabels.begin()+id );
705 //------------------------------------------------------------------------
706 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
708 ErasePoint( IdInsidePoint() );
711 //------------------------------------------------------------------------
712 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
714 ErasePoint(lstActorsSphere.size()-1);
717 //------------------------------------------------------------------------
718 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
720 int id,size=lstActorsSphere.size();
721 for (id=size-1;id>=0;id--)
727 //NTU: Method for updating points opacity and Radio
729 //------------------------------------------------------------------------
730 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
732 //Difference in Radio for text placement
733 int difradio = sdrRadio->GetValue() - this->mradio;
735 this->mopacity = sdrOpacity->GetValue()/100.0;
736 this->mradio = sdrRadio->GetValue();
738 //NTU refresh the inputs
739 mbbShowNPoints->bbSetInputOpacity(this->mopacity);
740 mbbShowNPoints->bbSetInputRadio(this->mradio);
742 int size = (int) this->lstActorsSphere.size();
744 for(i = 0; i < size; i ++)
746 this->lstSourceSphere[i]->SetRadius(mradio);
747 this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity);
748 this->lstActorsText[i]->GetTextProperty()->SetOpacity(mopacity);
749 this->lstActorsText[i]->SetPosition(this->lstActorsText[i]->GetPosition()[0]+difradio,this->lstActorsText[i]->GetPosition()[1], this->lstActorsText[i]->GetPosition()[2]);
753 //EED SetOutputBox();
754 renderer->GetRenderWindow()->Render();
758 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
759 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
761 //-----------------------------------------------------------------
762 void ShowNPoints::Process()
766 mwxwidget->SetRenderer( bbGetInputRenderer() );
767 mwxwidget->SetPoint( bbGetInputIn() );
768 mwxwidget->SetImage( bbGetInputImage() );
769 mwxwidget->SetColour( bbGetInputColour() );
770 mwxwidget->SetOpacity( bbGetInputOpacity() );
771 mwxwidget->SetRadio( bbGetInputRadio() );
773 bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
774 bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
775 bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
776 bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
781 //-----------------------------------------------------------------
782 void ShowNPoints::CreateWidget(wxWindow* parent)
784 mwxwidget = new WidgetShowNPoints( parent, this);
785 bbSetOutputWidget( mwxwidget );
788 //-----------------------------------------------------------------
789 void ShowNPoints::bbUserSetDefaultValues()
794 bbSetInputOpacity(1);
796 std::vector<double> colour;
797 colour.push_back(1.0);
798 colour.push_back(0.0);
799 colour.push_back(0.0);
800 bbSetInputColour(colour);
802 bbSetInputImage(NULL);
804 bbSetInputRenderer(NULL);
807 //-----------------------------------------------------------------
808 void ShowNPoints::bbUserInitializeProcessing()
812 //-----------------------------------------------------------------
813 void ShowNPoints::bbUserFinalizeProcessing()
817 //-----------------------------------------------------------------
820 // EO namespace bbcreaMaracasVisu