[165] | 1 | #include <stdio.h>
|
---|
| 2 | #include "pigfd1.h"
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | /* --Methode-- */
|
---|
| 6 | PIGenFitDat::PIGenFitDat(GeneralFitData* gfd, bool ad)
|
---|
| 7 | : PIDrawer(), mGFD(gfd), mAdDO(ad), VarX(0), ErrX(false), ErrY(false)
|
---|
| 8 | {
|
---|
| 9 | SelectX(0);
|
---|
| 10 | SelectErrBar(false,false);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | PIGenFitDat::~PIGenFitDat()
|
---|
| 14 | {
|
---|
| 15 | if(mAdDO && mGFD) delete mGFD;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | /* --Methode-- */
|
---|
| 19 | void PIGenFitDat::SelectX(int varx)
|
---|
| 20 | {
|
---|
| 21 | VarX = -1;
|
---|
| 22 | if(mGFD == NULL) return;
|
---|
| 23 | if(varx<0 || varx>=mGFD->NVar()) return;
|
---|
| 24 | VarX = varx;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | /* --Methode-- */
|
---|
| 28 | void PIGenFitDat::SelectErrBar(bool erbx,bool erby)
|
---|
| 29 | {
|
---|
| 30 | ErrX = erbx; ErrY = erby;
|
---|
| 31 | if(mGFD == NULL) {ErrX = ErrY = false; return;}
|
---|
| 32 | if(!mGFD->HasXErrors()) ErrX = false;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | /* --Methode-- */
|
---|
| 36 | void PIGenFitDat::UpdateLimits()
|
---|
| 37 | {
|
---|
| 38 | if(!mGFD) return;
|
---|
| 39 | if(mGFD->NData()<=0) return;
|
---|
| 40 | if(VarX<0) return;
|
---|
| 41 | double dx, dy;
|
---|
| 42 | double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19;
|
---|
| 43 | mGFD->GetMinMax(10*VarX+2,xmin,xmax);
|
---|
| 44 | mGFD->GetMinMax(0,ymin, ymax);
|
---|
| 45 | if(xmax<=xmin) xmax = xmin+1.;
|
---|
| 46 | if(ymax<=ymin) ymax = ymin+1.;
|
---|
| 47 | dx = 0.02*(xmax-xmin);
|
---|
| 48 | dy = 0.02*(ymax-ymin);
|
---|
| 49 | SetLimits((float)xmin-dx,(float)xmax+dx,(float)ymin-dy,(float)ymax+dy);
|
---|
| 50 | SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | /* --Methode-- */
|
---|
| 54 | void PIGenFitDat::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
|
---|
| 55 | {
|
---|
| 56 | if (!mGFD) return;
|
---|
| 57 | if(mGFD->NData()<=0) return;
|
---|
| 58 | if(VarX<0) return;
|
---|
| 59 | // On plotte les barre d'erreurs ligne demandee explicitement
|
---|
| 60 | if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true);
|
---|
| 61 | float xp,yp,er;
|
---|
| 62 | for (int i=0; i<mGFD->NData(); i++) {
|
---|
| 63 | xp = mGFD->Absc(VarX,i);
|
---|
| 64 | yp = mGFD->Val(i);
|
---|
| 65 | if(xp<xmin || xp>xmax || yp<ymin || yp>ymax) continue;
|
---|
| 66 | if(ErrX) {
|
---|
| 67 | er = mGFD->EAbsc(VarX,i);
|
---|
| 68 | if(er>0.) g->DrawLine(xp-er,yp,xp+er,yp);
|
---|
| 69 | }
|
---|
| 70 | if(ErrY) {
|
---|
| 71 | er = mGFD->EVal(i);
|
---|
| 72 | if(er>0.) g->DrawLine(xp,yp-er,xp,yp+er);
|
---|
| 73 | }
|
---|
| 74 | g->DrawMarker(xp, yp);
|
---|
| 75 | }
|
---|
| 76 | return;
|
---|
| 77 | }
|
---|