+//------------------------------------------------------------------------
+
+ int WidgetShowNPoints::GetNearestPoint()
+ {
+ int id=-1;
+ int i, size=(int)(lstActorsSphere.size());
+ double spc[3];
+
+ if(mimage ==NULL){
+ wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
+ diag->ShowModal();
+ return -1;
+ }else{
+
+ mimage->GetSpacing(spc);
+
+ for ( i=0 ; i<size; i++ )
+ {
+ double rx = spc[0]*(mpoint[0] - lstPointsX [i]);
+ double ry = spc[1]*(mpoint[1] - lstPointsY [i]);
+ double rz = spc[2]*(mpoint[2] - lstPointsZ [i]);
+ if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
+ {
+ id=i;
+ } // if
+ } // for
+
+ return id;
+ }
+ }
+
+//------------------------------------------------------------------------
+ void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
+ {
+ int id=GetNearestPoint();
+ if (id>=0)
+ {
+ std::string strLabel = CleanSpaces( (const char*) ( textCtrl->GetValue().mb_str() ) );
+ lstLabels[id] = CleanSpaces( (const char*) (textCtrl->GetValue().mb_str()) ) ;
+ lstActorsText[id]->SetInput( lstLabels[id].c_str() );
+ SetOutputBox();
+ }
+ }
+
+//------------------------------------------------------------------------
+ void WidgetShowNPoints::ErasePoint(int id)
+ {
+ if (this->renderer!=NULL){
+ if (id>=0){
+ renderer->RemoveActor( lstActorsSphere[id] );
+ renderer->RemoveActor( lstActorsText[id] );
+ lstActorsSphere[id]->Delete();
+ lstActorsText[id]->Delete();
+ lstSourceSphere[id]->Delete();
+ lstActorsSphere.erase( lstActorsSphere.begin()+id );
+ lstActorsText.erase( lstActorsText.begin()+id );
+ lstSourceSphere.erase( lstSourceSphere.begin()+id );
+
+ lstPointsX.erase( lstPointsX.begin()+id );
+ lstPointsY.erase( lstPointsY.begin()+id );
+ lstPointsZ.erase( lstPointsZ.begin()+id );
+ lstLabels.erase( lstLabels.begin()+id );
+
+ SetOutputBox();
+
+ } // if id
+ } // if renderer
+ }
+
+//------------------------------------------------------------------------
+ void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
+ {
+ ErasePoint( GetNearestPoint() );
+ }
+
+//------------------------------------------------------------------------
+ void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
+ {
+ ErasePoint(lstActorsSphere.size()-1);
+ }