+
+ //------------------------------------------------------------------------
+ void WidgetShowNPoints::OnSavePoints(wxCommandEvent& event)
+ {
+
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Save points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxSAVE | wxOVERWRITE_PROMPT,
+ wxDefaultPosition);
+ //EED
+
+ int result_FD = FD->ShowModal();
+
+ // This line is need it by windows //EED
+ FD->SetReturnCode( result_FD );
+
+ if (FD->GetReturnCode()==wxID_OK)
+ {
+ FILE *ff;
+ std::string filename= (const char*) ( FD->GetPath().mb_str() );
+ ff = fopen( filename.c_str() , "w+" );
+ if (ff!=NULL)
+ {
+ int i , size = (int) (lstActorsSphere.size());
+ fprintf(ff,"NumberOfPoints %d \n",size);
+ fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
+ int x, y, z;
+ double value;
+ for (i=0; i<size; i++)
+ {
+ x=lstPointsX[i];
+ y=lstPointsY[i];
+ z=lstPointsZ[i];
+ value= mimage->GetScalarComponentAsDouble(x,y,z,0);
+ fprintf(ff,"%d\t %d\t %d\t %f\t %s\n", x , y , z , value , lstLabels[i].c_str());
+ } // for
+ fclose(ff);
+ } else { // else ff
+ printf("WidgetShowNPoints::OnSavePoints ...Error... creating file");
+ } //ff
+ } // dialog box
+
+ }
+
+ //------------------------------------------------------------------------
+ void WidgetShowNPoints::OnLoadPoints(wxCommandEvent& event)
+ {
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Load points .."),
+ _T(""),
+ _T(""),
+ _T("(*.xls)|*.xls"),
+ wxOPEN | wxFILE_MUST_EXIST,
+ wxDefaultPosition);
+ //EED
+
+ int result_FD = FD->ShowModal();
+
+ // This line is need it by windows //EED
+ FD->SetReturnCode( result_FD );
+
+ if (FD->GetReturnCode()==wxID_OK)
+ {
+ FILE *ff;
+ std::string filename= (const char*) ( FD->GetPath().mb_str() );
+ ff = fopen( filename.c_str() , "r+" );
+ if (ff!=NULL)
+ {
+ int i,size;
+ char chartmp[256];
+ fscanf(ff," %s %d",chartmp,&size);
+ fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
+
+ float value;
+ int x,y,z;
+ for (i=0; i<size; i++)
+ {
+ fscanf(ff," %d %d %d %f %s",&x,&y,&z,&value,chartmp ); // x,y,z,value,label
+ AddPoint(x,y,z, chartmp );
+ }
+ fclose(ff);
+ } else { // else ff
+ printf("WidgetShowNPoints::OnLoadPoints ...Error... reading file");
+ } //ff
+ } // dialog box
+
+
+ }
+
+ 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();
+ }
+ }
+