Changeset 2469 in Sophya


Ignore:
Timestamp:
Dec 2, 2003, 8:36:10 PM (22 years ago)
Author:
cmv
Message:

gestion trace linges avec DrawPolygon cmv 02/12/03

Location:
trunk/SophyaPI/PIext
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pihisto.cc

    r2388 r2469  
    7979  if( typeid(*mHisto)==typeid(HProf) ) mHisto->UpdateHisto();
    8080
    81   bool drawmarker=false, drawerr=false, oktrace=false;
    82   // Tracer les marqueurs si demande ou si HProf
     81  bool oktrace=false;
     82  // Tracer des marqueurs si demande ou si HProf
     83  bool drawmarker=false;
    8384  if( (GetGraphicAtt().GetMarker() != PI_NotDefMarker) || 
    8485      (typeid(*mHisto) == typeid(HProf)) ) drawmarker = true;
     86  // Tracer des erreurs ?
     87  bool drawerr=false;
    8588  if(error==0) {  // Gestion automatique des erreurs
    8689    // Tracer les erreurs si HProf
     
    8891    // Trace les erreurs si marqueurs demandes
    8992    if(drawmarker) drawerr=true;
    90   } else if(error>0) drawerr=true;
     93  }
     94  else if(error>0) drawerr=true;
     95  else if(error<0) drawerr=false;
    9196
    9297  // Trace des marqeurs
     
    101106
    102107  // Trace des erreurs
    103   // Si Marqeurs definis OU HProf => marqueurs+Erreurs si il y en a
    104108  if(drawerr) {
    105109    if(GetGraphicAtt().GetLineAtt()==PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
     
    122126
    123127  // Trace de la ligne continue
    124   if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) {
    125     double x1,y1, x2, y2; oktrace = true;
    126     x1 = mHisto->BinLowEdge(0);
    127     y1 = 0;
     128  // Si on ne demande pas de ligne (PI_NotDefLineAtt)
     129  // et que l'on a rien trace auparavent, on trace un FPolygon
     130  if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt || !oktrace) {
     131    PIGrCoord* x1 = new PIGrCoord[2*mHisto->NBins()+2];
     132    PIGrCoord* y1 = new PIGrCoord[2*mHisto->NBins()+2];
     133    double dx = mHisto->BinWidth();
     134    int npt=0;
     135    x1[npt] = mHisto->BinLowEdge(0);
     136    y1[npt] = 0;
     137    npt++;
    128138    for(int i=0; i<mHisto->NBins(); i++) {
    129       x2 = x1;
    130       y2 = (*mHisto)(i);
    131       g->DrawLine(x1,y1, x2, y2);
    132       y1 = y2;
    133       x2 = mHisto->BinHighEdge(i);
    134       g->DrawLine(x1,y1, x2, y2);
    135       x1 = x2;
    136     }
    137     y2 = 0; g->DrawLine(x1,y1, x2, y2);
    138   }
    139 
    140   // Si rien n'a ete trace
    141   if( !oktrace ) {
    142     for(int i=0; i<mHisto->NBins(); i++) {
    143       double left   = mHisto->BinLowEdge(i);
    144       double width  = mHisto->BinWidth();
    145       double bottom = 0;
    146       double height = (*mHisto)(i);
    147       g->DrawFBox(left,bottom,width,height);
    148       g->DrawLine(left, bottom, left, bottom+height); // Au moins une ligne...
    149     }
     139      x1[npt] = mHisto->BinLowEdge(i);
     140      y1[npt] = (*mHisto)(i);
     141      npt++;
     142      x1[npt] = (double)x1[npt-1] + dx;
     143      y1[npt] = y1[npt-1];
     144      npt++;
     145    }
     146    x1[npt] = x1[npt-1];
     147    y1[npt] = 0;
     148    npt++;
     149    if(GetGraphicAtt().GetLineAtt() != PI_NotDefLineAtt) {
     150      g->DrawPolygon(x1,y1,npt,false);
     151      oktrace = true;
     152    }
     153    if(!oktrace) g->DrawFPolygon(x1,y1,npt,false);
     154    delete[] x1;  delete[] y1;
    150155  }
    151156
  • trunk/SophyaPI/PIext/pihisto.h

    r2383 r2469  
    1919  // fg=-1 pas de barre d'erreur, 1=barres d'erreurs,
    2020  // 0=barres d'erreurs automatiques: trace si HProf ou markeur demande
    21   inline  void       SetError(unsigned short fg=0) {error=fg;}
     21  inline  void       SetError(short fg=0) {error=fg;}
    2222  inline  Histo*     Histogram() {return(mHisto);}
    2323
     
    3030  Histo* mHisto;
    3131  bool mAdDO;
    32   bool stats,error;
     32  bool stats;
     33  short error;
    3334  float spoX, spoY; // Stat pos offset par rapport a position defaut
    3435};
  • trunk/SophyaPI/PIext/pintuple.cc

    r2388 r2469  
    140140
    141141/* --Methode-- */
     142#define NMXMULTP_LOCAL  30   // Pour multipoint sans new
    142143void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
    143144{
    144145double xp,yp,xer,yer,wp;
    145146double xl,yl;
    146 int nok;
     147int nok,npolyg;
    147148
    148149if (!mNT) return;
     
    158159PIColorMap * cmap = NULL;
    159160double dwc = 1.;
    160 double nwc = 1.;
     161int nwc = 1;
    161162bool revcmap;
    162163CMapId mcmapid = GetGraphicAtt().GetColMapId(revcmap);
     
    165166  cmap->ReverseColorIndex(revcmap);
    166167  nwc = cmap->NCol();
    167   dwc = (wMax-wMin)/nwc;
     168  dwc = (wMax-wMin)/(double)nwc;
    168169}
    169170
     
    187188nok = 0; 
    188189xp = yp = xl = yl = 0;
     190PIGrCoord xpolyg[NMXMULTP_LOCAL], ypolyg[NMXMULTP_LOCAL];
     191npolyg = 0; 
    189192for (long i=0; i<(long)mNT->NbLines(); i++) {
    190   xl = xp;  yl = yp; 
     193  xl = xp;  yl = yp;
    191194  xp = mNT->GetCell(i, xK);
    192195  yp = mNT->GetCell(i, yK);
     
    213216  }
    214217
    215   if ( (i > 0) && connectPts )   
    216     g->DrawLine(xl, yl, xp, yp);  // On relie les points ...
     218  // Trace d'une ligne reliant les points
     219  if( connectPts ) {
     220    if(npolyg==0) {xpolyg[0]=xl; ypolyg[0]=yl; npolyg=1;}
     221    if(npolyg<NMXMULTP_LOCAL)
     222      {xpolyg[npolyg]=xp; ypolyg[npolyg]=yp; npolyg++;}
     223    if(npolyg==NMXMULTP_LOCAL)
     224      {g->DrawPolygon(xpolyg,ypolyg,npolyg,false); npolyg=0;}
     225  }
     226
     227  // Trace des erreurs selon X et Y
    217228  if ( xebK >= 0 ) {
    218229    xer = mNT->GetCell(i, xebK);
     
    223234    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
    224235  }
     236
    225237  // Trace du marker
    226238  if ((wK >= 0)||(lK < 0)||(mmrk != PI_NotDefMarker))  g->DrawMarker(xp, yp);
     239
    227240  // Trace eventuel du label
    228241  if (lK >= 0) g->DrawString(xp, yp, mNT->GetCelltoString(i, lK).c_str());
    229242
    230243}
     244
     245// Fin du trace d'une ligne reliant les points  si necessaire
     246if( connectPts && npolyg>1 )
     247  {g->DrawPolygon(xpolyg,ypolyg,npolyg,false); npolyg=0;}
    231248
    232249if (stats) { // Trace de stats
     
    262279return;
    263280}
     281#undef NMXMULTP_LOCAL
    264282
    265283/* --Methode-- */
Note: See TracChangeset for help on using the changeset viewer.