Changeset 144 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Sep 18, 1998, 10:37:09 AM (27 years ago)
Author:
ercodmgr
Message:

modifs pour display des HProf cmv 18/9/98

File:
1 edited

Legend:

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

    r136 r144  
    11#include <stdio.h>
    22#include "pihisto.h"
     3#include "hisprof.h"
    34
    45PIHisto::PIHisto(Histo* histo, bool ad)
     
    1011PIHisto::~PIHisto()
    1112{
    12   if (mAdDO)
    13     delete mHisto;
     13  if (mAdDO) delete mHisto;
    1414}
    15 
    16 
    1715
    1816void
    1917PIHisto::UpdateLimits()
    2018{
    21   if (!mHisto)  return; 
    22   SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->VMin(), mHisto->VMax()*1.2);
     19  if (!mHisto)  return;
     20  float hmin = mHisto->VMin();
     21  float hmax = mHisto->VMax()+0.2*(mHisto->VMax()-mHisto->VMin());
     22  // si HBProf min,max calcules en tenant compte des erreurs
     23  if( mHisto->ClassId() == HProf::classId ) {
     24    float v1,v2;
     25    for (int i=1; i<mHisto->NBins(); i++) {
     26      v1 = (*mHisto)(i) - mHisto->Error(i);
     27      v2 = (*mHisto)(i) + mHisto->Error(i);
     28      if(v1<hmin) hmin = v1;
     29      if(v2>hmax) hmax = v2;
     30    }
     31    v1 = 0.1*(hmax-hmin);
     32    hmin -= v1;   hmax += v1;
     33  }
     34  SetLimits(mHisto->XMin(), mHisto->XMax(), hmin, hmax);
    2335  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
    2436}
    25 
    2637
    2738void
    2839PIHisto::Draw(PIGraphicUC* g, float /*xmin*/, float /*ymin*/, float /*xmax*/, float /*ymax*/)
    2940{
     41  bool oktrace = false;
    3042  if (!mHisto)  return; 
     43  if (mMrk != PI_NotDefMarker || mHisto->ClassId() == HProf::classId ) {
     44    // Marqeurs definis OU HBProf => marqueurs+Erreurs si il y en a
     45    float x1,y1, x2,y2;
     46    float bw = mHisto->BinWidth();
     47    for (int i=0; i<mHisto->NBins(); i++) {
     48      // barres d'erreur verticales
     49      x1 = x2 = mHisto->BinCenter(i);
     50      y1 = (*mHisto)(i) - mHisto->Error(i);
     51      y2 = (*mHisto)(i) + mHisto->Error(i);
     52      g->DrawLine(x1,y1, x1, y2);
     53      // limites de barres d'erreurs (horizontales)
     54      x1 -= bw/3.;  x2 += bw/3.;
     55      g->DrawLine(x1,y1, x2, y1);
     56      g->DrawLine(x1,y2, x2, y2);
     57      // le marqueur
     58      x1 = mHisto->BinCenter(i);
     59      y1 = (*mHisto)(i);
     60      g->DrawMarker(x1,y1);
     61    }
     62    oktrace = true;
     63  }
    3164  if (mLAtt != PI_NotDefLineAtt) {
    3265    float x1,y1, x2, y2;
    3366    x1 = mHisto->BinLowEdge(0);
    34     y1 = 0; 
     67    y1 = 0;
    3568    for (int i=0; i<mHisto->NBins(); i++) {
    36       x2 = x1; 
     69      x2 = x1;
    3770      y2 = (*mHisto)(i);
    3871      g->DrawLine(x1,y1, x2, y2);
    39       y1 = y2; 
     72      y1 = y2;
    4073      x2 = mHisto->BinHighEdge(i);
    4174      g->DrawLine(x1,y1, x2, y2);
    42       x1 = x2;
    43       }
    44       y2 = 0; g->DrawLine(x1,y1, x2, y2);
     75      x1 = x2;
    4576    }
    46   else for (int i=0; i<mHisto->NBins(); i++) {
    47                 float left   = mHisto->BinLowEdge(i);
    48                 float width  = mHisto->BinWidth();
    49                 float bottom = 0;
    50                 float height = (*mHisto)(i);
    51                 g->DrawFBox(left,bottom,width,height);
    52                 g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
    53         }
     77    y2 = 0; g->DrawLine(x1,y1, x2, y2);
     78    oktrace = true;
     79  }
     80  if( !oktrace ) {
     81    for(int i=0; i<mHisto->NBins(); i++) {
     82      float left   = mHisto->BinLowEdge(i);
     83      float width  = mHisto->BinWidth();
     84      float bottom = 0;
     85      float height = (*mHisto)(i);
     86      g->DrawFBox(left,bottom,width,height);
     87      g->DrawLine(left, bottom, left, bottom + height); // Au moins une ligne...
     88    }
     89  }
    5490  DrawStats(g);
    5591}
     
    72108                       
    73109}
     110
Note: See TracChangeset for help on using the changeset viewer.