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;
337 if(lstPointsX.size()>1)
339 std::vector<int> dTotal;
343 //Calcule distance for each pair of points
344 for(int i = 0; i<lstPointsX.size()-1 ; i++)
346 a = Distance(x, y, z, lstPointsX[i], lstPointsY[i], lstPointsZ[i]);
347 b = Distance(x, y, z, lstPointsX[i+1], lstPointsY[i+1], lstPointsZ[i+1]);
349 dTotal.push_back (res);
351 //Gets the smallest distance
352 int smallTMP = dTotal[0];
353 for (int j = 0; j < dTotal.size(); j++)
355 if(dTotal[j]<smallTMP)
362 std::vector<int>::iterator it;
363 //Insert the point in the list of points
364 it = lstPointsX.begin();
365 lstPointsX.insert( it+pos, x );
366 it = lstPointsY.begin();
367 lstPointsY.insert( it+pos, y );
368 it = lstPointsZ.begin();
369 lstPointsZ.insert( it+pos, z );
371 std::string strLabel = CleanSpaces( label );
373 std::vector<std::string>::iterator itS;
374 itS = lstLabels.begin();
375 //Insert Label in list of labels
376 lstLabels.insert( itS+pos, strLabel );
379 vtkSphereSource *vtksphere = vtkSphereSource::New();
380 vtksphere->SetThetaResolution (20);
381 vtksphere->SetPhiResolution (20);
382 vtksphere->SetRadius( mradio );
384 //NTU: For updating points
385 std::vector<vtkSphereSource*>::iterator itSS;
386 itSS = lstSourceSphere.begin();
387 lstSourceSphere.insert( itSS+pos, vtksphere);
389 vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
390 sphereMapper->SetInput( vtksphere->GetOutput() );
391 vtkActor *sphereActor = vtkActor::New();
392 sphereActor->SetMapper(sphereMapper);
393 sphereActor->SetOrigin(0, 0, 0);
395 std::vector<vtkActor*>::iterator itAS;
396 itAS = lstActorsSphere.begin();
397 lstActorsSphere.insert( itAS+pos, sphereActor);
399 wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
403 renderer->AddActor( sphereActor );
406 vtkTextActor3D *textActor = vtkTextActor3D::New();
408 textActor->SetInput( strLabel.c_str() );
409 renderer->AddActor( textActor );
410 std::vector<vtkTextActor3D*>::iterator itTA;
411 itTA = lstActorsText.begin();
412 lstActorsText.insert( itTA+pos , textActor);
416 std::cout<<"WidgetShowNPoints::InsertPoint end"<<std::endl;
419 //------------------------------------------------------------------------
420 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
423 wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
428 if (this->renderer!=NULL){
429 if (mpoint.size()==3){
430 AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
432 } else {//mpoint.size
433 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
438 //------------------------------------------------------------------------
439 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
441 std::cout<<"WidgetShowNPoints::OnInsertPoint begin"<<std::endl;
443 wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
448 if (this->renderer!=NULL){
449 if (mpoint.size()==3){
450 InsertPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
452 } else {//mpoint.size
453 printf("creaMaracasVisu::ShowNPoints (not match point) \n");
456 std::cout<<"WidgetShowNPoints::OnInsertPoint end"<<std::endl;
460 //------------------------------------------------------------------------
461 void WidgetShowNPoints::SetOutputBox()
463 renderer->GetRenderWindow()->Render();
465 strTmp.Printf(_T("Nbr of points: %d"), (int)(lstPointsX.size()) );
466 txtNrPoints->SetLabel( strTmp );
469 mbbShowNPoints->bbSetOutputlstPointsX( lstPointsX );
470 mbbShowNPoints->bbSetOutputlstPointsY( lstPointsY );
471 mbbShowNPoints->bbSetOutputlstPointsZ( lstPointsZ );
472 mbbShowNPoints->bbSetOutputlstLabels( lstLabels );
474 mbbShowNPoints->bbSignalOutputModification();
477 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
478 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
479 // mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
480 // mbbShowNPoints->bbSignalOutputModification(std::string("lstLabels"));
483 //------------------------------------------------------------------------
484 void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
486 wxFileDialog* FD = new wxFileDialog( 0,
487 _T("Save points .."),
491 wxSAVE | wxOVERWRITE_PROMPT,
495 int result_FD = FD->ShowModal();
496 std::string tmpLabel;
498 // This line is need it by windows //EED
499 FD->SetReturnCode( result_FD );
501 if (FD->GetReturnCode()==wxID_OK)
504 std::string filename= (const char*) ( FD->GetPath().mb_str() );
505 ff = fopen( filename.c_str() , "w+" );
508 int i , size = (int) (lstActorsSphere.size());
509 fprintf(ff,"NumberOfPoints %d \n",size);
510 fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
513 for (i=0; i<size; i++)
518 value= mimage->GetScalarComponentAsDouble(x,y,z,0);
519 if (lstLabels[i]!="")
521 tmpLabel=lstLabels[i];
525 fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value , tmpLabel.c_str());
529 printf("WidgetShowNPoints::OnSavePoints ...Error... creating file");
534 //------------------------------------------------------------------------
535 void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
537 wxFileDialog* FD = new wxFileDialog( 0,
538 _T("Load points .."),
542 wxOPEN | wxFILE_MUST_EXIST,
546 int result_FD = FD->ShowModal();
548 // This line is need it by windows //EED
549 FD->SetReturnCode( result_FD );
551 if (FD->GetReturnCode()==wxID_OK)
554 std::string filename= (const char*) ( FD->GetPath().mb_str() );
555 ff = fopen( filename.c_str() , "r+" );
560 fscanf(ff," %s %d",chartmp,&size);
561 fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
565 for (i=0; i<size; i++)
567 fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
568 if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
569 AddPoint(x,y,z, chartmp );
574 printf("WidgetShowNPoints::OnLoadPoints ...Error... reading file");
581 //------------------------------------------------------------------------
583 int WidgetShowNPoints::GetNearestPoint()
586 int i, size=(int)(lstActorsSphere.size());
587 double radioMin=10000000;
590 wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
595 for ( i=0 ; i<size; i++ )
597 double rx = mpoint[0] - lstPointsX [i];
598 double ry = mpoint[1] - lstPointsY [i];
599 double rz = mpoint[2] - lstPointsZ [i];
600 double radio = rx*rx + ry*ry + rz*rz;
601 if ( radio <= radioMin)
613 //------------------------------------------------------------------------
614 void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
616 int id=GetNearestPoint();
617 if((id==-1) && (mbbShowNPoints->bbGetInputType()==1))
627 printf("WidgetShowNPoints::OnSetPoint \n");
628 lstPointsX[id] = mpoint[0];
629 lstPointsY[id] = mpoint[1];
630 lstPointsZ[id] = mpoint[2];
633 this->lstActorsSphere[id]->SetPosition( spc[0]*mpoint[0]+difradio, spc[1]*mpoint[1], spc[2]* mpoint[2] );
634 this->lstActorsText[id]->SetPosition( spc[0]*mpoint[0]+difradio, spc[1]*mpoint[1], spc[2]* mpoint[2] );
641 //------------------------------------------------------------------------
643 int WidgetShowNPoints::IdInsidePoint()
646 int i, size=(int)(lstActorsSphere.size());
650 wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
655 mimage->GetSpacing(spc);
657 for ( i=0 ; i<size; i++ )
659 double rx = spc[0]*(mpoint[0] - lstPointsX [i]);
660 double ry = spc[1]*(mpoint[1] - lstPointsY [i]);
661 double rz = spc[2]*(mpoint[2] - lstPointsZ [i]);
662 if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
672 //------------------------------------------------------------------------
673 void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
675 int id=IdInsidePoint();
678 std::string strLabel = CleanSpaces( (const char*) ( textCtrl->GetValue().mb_str() ) );
679 lstLabels[id] = CleanSpaces( (const char*) (textCtrl->GetValue().mb_str()) ) ;
680 lstActorsText[id]->SetInput( lstLabels[id].c_str() );
685 //------------------------------------------------------------------------
686 void WidgetShowNPoints::ErasePoint(int id)
688 if (this->renderer!=NULL){
690 renderer->RemoveActor( lstActorsSphere[id] );
691 renderer->RemoveActor( lstActorsText[id] );
692 lstActorsSphere[id]->Delete();
693 lstActorsText[id]->Delete();
694 lstSourceSphere[id]->Delete();
695 lstActorsSphere.erase( lstActorsSphere.begin()+id );
696 lstActorsText.erase( lstActorsText.begin()+id );
697 lstSourceSphere.erase( lstSourceSphere.begin()+id );
699 lstPointsX.erase( lstPointsX.begin()+id );
700 lstPointsY.erase( lstPointsY.begin()+id );
701 lstPointsZ.erase( lstPointsZ.begin()+id );
702 lstLabels.erase( lstLabels.begin()+id );
710 //------------------------------------------------------------------------
711 void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
713 ErasePoint( IdInsidePoint() );
716 //------------------------------------------------------------------------
717 void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
719 ErasePoint(lstActorsSphere.size()-1);
722 //------------------------------------------------------------------------
723 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
725 int id,size=lstActorsSphere.size();
726 for (id=size-1;id>=0;id--)
732 //NTU: Method for updating points opacity and Radio
734 //------------------------------------------------------------------------
735 void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
737 //Difference in Radio for text placement
738 int difradio = sdrRadio->GetValue() - this->mradio;
740 this->mopacity = sdrOpacity->GetValue()/100.0;
741 this->mradio = sdrRadio->GetValue();
743 //NTU refresh the inputs
744 mbbShowNPoints->bbSetInputOpacity(this->mopacity);
745 mbbShowNPoints->bbSetInputRadio(this->mradio);
747 int size = (int) this->lstActorsSphere.size();
749 for(i = 0; i < size; i ++)
751 this->lstSourceSphere[i]->SetRadius(mradio);
752 this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity);
753 this->lstActorsText[i]->GetTextProperty()->SetOpacity(mopacity);
754 this->lstActorsText[i]->SetPosition(this->lstActorsText[i]->GetPosition()[0]+difradio,this->lstActorsText[i]->GetPosition()[1], this->lstActorsText[i]->GetPosition()[2]);
758 //EED SetOutputBox();
759 renderer->GetRenderWindow()->Render();
763 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
764 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
766 //-----------------------------------------------------------------
767 void ShowNPoints::Process()
771 mwxwidget->SetRenderer( bbGetInputRenderer() );
772 mwxwidget->SetPoint( bbGetInputIn() );
773 mwxwidget->SetImage( bbGetInputImage() );
774 mwxwidget->SetColour( bbGetInputColour() );
775 mwxwidget->SetOpacity( bbGetInputOpacity() );
776 mwxwidget->SetRadio( bbGetInputRadio() );
778 bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
779 bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
780 bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
781 bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
786 //-----------------------------------------------------------------
787 void ShowNPoints::CreateWidget(wxWindow* parent)
789 mwxwidget = new WidgetShowNPoints( parent, this);
790 bbSetOutputWidget( mwxwidget );
793 //-----------------------------------------------------------------
794 void ShowNPoints::bbUserSetDefaultValues()
799 bbSetInputOpacity(1);
801 std::vector<double> colour;
802 colour.push_back(1.0);
803 colour.push_back(0.0);
804 colour.push_back(0.0);
805 bbSetInputColour(colour);
807 bbSetInputImage(NULL);
809 bbSetInputRenderer(NULL);
812 //-----------------------------------------------------------------
813 void ShowNPoints::bbUserInitializeProcessing()
817 //-----------------------------------------------------------------
818 void ShowNPoints::bbUserFinalizeProcessing()
822 //-----------------------------------------------------------------
825 // EO namespace bbcreaMaracasVisu