#include "machdefs.h" #include #include #include #include #include #include #include #include "ctimer.h" #include "piacmd.h" #include "nobjmgr.h" #include "pistdimgapp.h" #include "pidrawer.h" #include "nomgadapter.h" #include "histos.h" #include "histos2.h" #include "hisprof.h" #include "ntuple.h" #include "servnobjm.h" #include #include "picntools.h" #include "pigncont.h" //A-Virer #include "pidrwtools.h" //A-Virer #include "piaxestools.h" extern "C" { #include "contour.h" #include "alloc.h" #include "set.h" } TBOOLEAN multiplot; double zero =0; TBOOLEAN polar; int xleft, xright, ybot, ytop; float xsize; float ysize; float xoffset, yoffset; GNUPlotContour::GNUPlotContour(struct iso_curve * iso){ int k=0; iso1 = iso; struct iso_curve *iso_cur = iso ; struct iso_curve *iso_old; _xmin = 1.e37; _ymin = 1.e37; _xmax = -1.e37; _ymax = -1.e37; _myiso = NULL; _zmin = 1.e37; _zmax = -1.e37; while(iso_cur){ k++; iso_cur = iso_cur->next; _ny = iso_cur->p_count; for(int k=0 ; k<_ny ; k++){ double xx=iso->points[k].x; double yy=iso->points[k].y; double zz=iso->points[k].z; if(xx<_xmin) _xmin = xx; if(xx>_xmax) _xmax = xx; if(yy<_ymin) _ymin = yy; if(yy>_ymax) _ymax = yy; if(zz<_zmin) _zmin = zz; if(zz>_zmax) _zmax = zz; } } _nx = k; _contours = NULL; My_Levels = NULL; _npolys=-1; _Dxp =_Dyp =1.; _Exy =_Invy =_Invy = FALSE ; } GNUPlotContour::GNUPlotContour(NTupleInterface *nt,int *nz=NULL,double *z=NULL,double *dz=NULL){ _xmin = 1.e37; _ymin = 1.e37; _xmax = -1.e37; _ymax = -1.e37; _zmin = 1.e37; _zmax = -1.e37; char *nom[4]={"x","y","z","niso"}; _myiso = new NTuple(4,nom); //_myiso->Show(); float xnt[4]; double mn,mx; nt->GetMinMax(0,_xmin,_xmax); nt->GetMinMax(1,_ymin,_ymax); nt->GetMinMax(2,_zmin,_zmax); struct iso_curve *istmp = NULL ; struct iso_curve *iso = NULL ; struct iso_curve *iso_old = NULL ; double x,y; int nen = nt->NbLines(); // histo des y for(int k= 0 ; k<1000 ; k++){ istmp = iso_alloc(100); iso_free(istmp); } #define NUMPTMIN 25 #define MAXISO 100 #define MINISO 5 Histo prep(_ymin,_ymax,nen); for(int ix=0 ; ixGetCell(ix,1),1.); Histo Intg = prep; Intg.HInteg(0); //prep.Print(); //Intg.Print(); float *bin; int *cnt; int niso = sqrt( (double)nen); bin = new float[niso+1]; cnt = new int[niso+1]; for(int i=0 ; i0){ numx = numx>numy ? numx : numy ; numi = numy>numi ? numi : numy ; } } if (numi<=0) { return; } _nx = 0; for(int i=0;iGetCell(ix,1)>=ymi&&nt->GetCell(ix,1)points[ip].type = INRANGE; istmp->points[ip].x = nt->GetCell(ix,0); istmp->points[ip].y = nt->GetCell(ix,1); istmp->points[ip].z = nt->GetCell(ix,2); indx[ip] = ip; xp[ip++] = nt->GetCell(ix,0); } } // tri des points de l'iso_curve // istmp->p_count = ip; tri_double(xp,indx,ip); // remplissage structure finale iso = iso_alloc(numx) ; if( _nx == 0 ) iso1 = iso; //premiere structure remplie if (iso_old) iso_old->next = iso; for(int ix=0 ; ixpoints[ix].type = INRANGE ; iso->points[ix].x = istmp->points[jx].x ; iso->points[ix].y = istmp->points[jx].y ; iso->points[ix].z = istmp->points[jx].z ; xnt[0] = iso->points[ix].x; xnt[1] = iso->points[ix].y; xnt[2] = iso->points[ix].z; xnt[3] = _nx; //cout << " fill avec "<Show(); _myiso->Fill(xnt); } //cout << " completion "<> "<points[ix].type = INRANGE ; iso->points[ix].x = istmp->points[jmx].x ; iso->points[ix].y = istmp->points[jmx].y ; iso->points[ix].z = istmp->points[jmx].z ; xnt[0] = iso->points[ix].x; xnt[1] = iso->points[ix].y; xnt[2] = iso->points[ix].z; xnt[3] = _nx; //cout << " fill avec "<Fill(xnt); //_myiso->Show(); } iso->p_count = numx; iso_old = iso; _nx++; //cout << " destruction structure tempo "<<_nx <Write("myiso.ppf"); //cout << " fin du remplissage des iso_curves xmin,max "<< _xmin<<","<<_xmax<<" ymin,max "<<_ymin<<","<<_ymax<XSize()-1; // _ny = arr->YSize()-1; _nx = arr->XSize() ; _ny = arr->YSize() ; //cout << " size x,y "<<_nx<<" , "<<_ny <XYfromxy(0,0,x,y); arr->XYfromxy(1,1,x1,y1); _Dxp = (x1-x); _Dyp = (y1-y); double zz; for(int ix=0 ; ix<_nx ; ix++){ iso = iso_alloc(_ny) ; if(ix==0) iso1 = iso; if (iso_old) iso_old->next = iso; for(int iy = 0 ; iy<_ny ; iy++){ /*i = ix*100+iy;*/ arr->XYfromxy(ix,iy,x,y); iso->points[iy].type = INRANGE; iso->points[iy].x = x + _Dxp/2.; iso->points[iy].y = y + _Dyp/2.; zz=arr->Value(ix,iy); iso->points[iy].z = zz; //iso->points[iy].z = ((x-25)*(x-25) + (y-25)*(y-25))*.05 ; if(x <_xmin) _xmin = x; if(x >_xmax) _xmax = x; if(y <_ymin) _ymin = y; if(y >_ymax) _ymax = y; if(zz <_zmin) _zmin = zz; if(zz >_zmax) _zmax = zz; //printf("ix=%d iy=%d x=%f y=%f z=%f \n",ix,iy,iso->points[iy].x,iso->points[iy].y,iso->points[iy].z); xnt[0] = iso->points[iy].x; xnt[1] = iso->points[iy].y; xnt[2] = iso->points[iy].z; xnt[3] = _nx; _myiso->Fill(xnt); } iso->p_count = _ny; iso_old = iso; /*printf(" remplissage %lx old %lx old next %lx \n",iso,iso_old,iso->next,iso_old->next);*/ /*iso->next = iso ;*/ } //cout << " fin du remplissage des iso_curves xmin,max "<< _xmin<<","<<_xmax<<" ymin,max "<<_ymin<<","<<_ymax<next; iso_free(iso_cur);iso_cur = NULL; iso_cur = iso_nx; } iso1 = NULL; struct gnuplot_contours *cntcur = _contours; struct gnuplot_contours *cntold; while(cntcur) { //cout << " ~GNUPlotContour() : destruction de _contours" << _contours <next; gp_free(cntold); cntold=NULL; } _contours = NULL; if(My_Levels) { //cout << " ~GNUPlotContour() : destruction de MyLevels "<next; gp_free(cntold); } _contours = NULL; } //struct gnuplot_contours *cntcur; //struct gnuplot_contours *cntold; _contours = contour (_nx,iso1); //free_contour_levels_list(); } //_+_ Methode void GNUPlotContour::SetMyLevels(double *ptr,int k){ if(My_Levels!=NULL) delete My_Levels; My_Levels = new double[k]; for(int i=0 ; iSaveGraphicAtt(); struct gnuplot_contours *cntcur; struct gnuplot_contours *cntold; cntcur = _contours; double a,b; int tot=0; bool Invx, Invy, Exy; PIColorMap * cmap = NULL; if(mCmapid !=CMAP_OTHER ){ cmap = new PIColorMap(mCmapid); } int numdr = 0; while(cntcur){ int npts = cntcur->num_pts ; if(npts<0) continue; xx = new PIGrCoord[npts]; yy = new PIGrCoord[npts]; double lev = (cntcur->coords)[0].z ; for(int l=0 ; l< npts ; l++){ a = (cntcur->coords)[l].x; b = (cntcur->coords)[l].y; xx[l] = a ; yy[l] = b ; } // choix de la couleur g->SelForeground(mFCol); if(mCmapid !=CMAP_OTHER ){ if(_zmax-_zmin!=0){ int kc = ((lev - _zmin)/(_zmax-_zmin))*cmap->NCol(); g->SelForeground(*cmap,kc); } } // traitement des des markers if(IsMarkOn()==true){ g->SelMarker(mMSz,mMrk); g->DrawMarkers(xx,yy,npts); } // traitement des lignes if(mLineOn==true){ g->SelLine(mLAtt); g->DrawPolygon(xx,yy,npts,false); } // traitement des labels // SIMPLISTE POUR L'INSTANT : UN AFFICHAGE if(mLabelOn==true){ // char strg[10]; sprintf(strg,"%g",lev); PIFont myfont(mFName); myfont.SetFontAtt(mFAtt); myfont.SetFontSz(mFSz); g->SelFont(myfont); double px,py; px = (cntcur->coords)[0].x+2*(Xmax()-Xmin())/100.; py = (cntcur->coords)[0].y; g->DrawString(px,py,strg, PI_HorizontalCenter&&PI_VerticalCenter ); } numdr++; delete[] xx; xx=NULL; delete[] yy; yy=NULL; cntcur = cntcur->next; tot++; } //cout << "PIContourDrawer::Draw fin de trace des "<RestoreGraphicAtt(); } /* --Methode-- */ void PIContourDrawer::UpdateLimits() { // Doit calculer les limites double xmn = _xmin; double xmx = _xmax; double ymn = _ymin; double ymx = _ymax; SetLimits(xmn, xmx, ymn, ymx); } /* --Methode-- */ void PIContourDrawer::ShowControlWindow(PIBaseWdgGen* wdg) { PICnTools::SetCurrentBaseWdg(wdg); PICnTools::SetCurrentCnDrw(this); PICnTools::ShowPICnTools(); } /* --Methode-- */ bool PIContourDrawer::IsLabelOn(){ return (mLabelOn); } bool PIContourDrawer::IsLineOn(){ return (mLineOn); } bool PIContourDrawer::IsMarkOn(){ return (mMarkOn); } void PIContourDrawer::SetLabelOn(bool state){ mLabelOn = state; } void PIContourDrawer::SetMarkOn(bool state){ mMarkOn = state; } void PIContourDrawer::SetLineOn(bool state){ mLineOn = state; } void PIContourDrawer::InitAtts(){ mLineOn = false; mMarkOn = true; mLabelOn = false; }