[165] | 1 | #include <stdio.h>
|
---|
| 2 | #include "pigfd2.h"
|
---|
| 3 |
|
---|
| 4 | /* --Methode-- */
|
---|
| 5 | PIGenFitDat3D::PIGenFitDat3D(GeneralFitData* gfd, bool ad)
|
---|
| 6 | : PIDrawer3D(), mGFD(gfd), mAdDO(ad)
|
---|
| 7 | , VarX(0), VarY(1), ErrX(false), ErrY(false), ErrZ(false)
|
---|
| 8 | {
|
---|
| 9 | SelectXY(0,1);
|
---|
| 10 | SelectErrBar(false,false,false);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | PIGenFitDat3D::~PIGenFitDat3D()
|
---|
| 14 | {
|
---|
| 15 | if(mAdDO && mGFD) delete mGFD;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | /* --Methode-- */
|
---|
| 19 | void PIGenFitDat3D::SelectXY(int varx,int vary)
|
---|
| 20 | {
|
---|
| 21 | VarX = VarY = -1;
|
---|
| 22 | if(mGFD == NULL) return;
|
---|
| 23 | if(varx<0 || varx>=mGFD->NVar()) return;
|
---|
| 24 | if(vary<0 || vary>=mGFD->NVar()) return;
|
---|
| 25 | VarX = varx; VarY = vary;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | /* --Methode-- */
|
---|
| 29 | void PIGenFitDat3D::SelectErrBar(bool erbx,bool erby,bool erbz)
|
---|
| 30 | {
|
---|
| 31 | ErrX = erbx; ErrY = erby; ErrZ = erbz;
|
---|
| 32 | if(mGFD == NULL) {ErrX = ErrY = ErrZ = false; return;}
|
---|
| 33 | if(!mGFD->HasXErrors()) ErrX = ErrY = false;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | /* --Methode-- */
|
---|
| 37 | void PIGenFitDat3D::UpdateLimits()
|
---|
| 38 | {
|
---|
| 39 | if(!mGFD) return;
|
---|
| 40 | if(mGFD->NData()<=0) return;
|
---|
| 41 | if(VarX<0 || VarY<0) return;
|
---|
| 42 | double xmin=9.e19, xmax=-9.e19, ymin=9.e19, ymax=-9.e19, zmin=9.e19, zmax=-9.e19;
|
---|
| 43 | mGFD->GetMinMax(10*VarX+2,xmin,xmax);
|
---|
| 44 | mGFD->GetMinMax(10*VarY+2,ymin,ymax);
|
---|
| 45 | mGFD->GetMinMax(0,zmin, zmax);
|
---|
| 46 | if(xmax<=xmin) xmax = xmin+1.;
|
---|
| 47 | if(ymax<=ymin) ymax = ymin+1.;
|
---|
| 48 | if(zmax<=zmin) zmax = zmin+1.;
|
---|
| 49 | // Voir commentaires pintuple3d.cc
|
---|
| 50 | float D = xmax-xmin;
|
---|
| 51 | if (D < (ymax-ymin)) D = ymax-ymin;
|
---|
| 52 | D *= 1.4;
|
---|
| 53 | Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2.,
|
---|
| 54 | (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.2, 0.3, 0.3);
|
---|
[171] | 55 |
|
---|
| 56 | xMin = xmin - 0.05*(xmax-xmin);
|
---|
| 57 | xMax = xmax + 0.05*(xmax-xmin);
|
---|
| 58 | yMin = ymin - 0.05*(ymax-ymin);
|
---|
| 59 | yMax = ymax + 0.05*(ymax-ymin);
|
---|
| 60 | zMin = zmin - 0.05*(zmax-zmin);
|
---|
| 61 | zMax = zmax + 0.05*(zmax-zmin);
|
---|
| 62 |
|
---|
[165] | 63 | }
|
---|
| 64 |
|
---|
| 65 | /* --Methode-- */
|
---|
| 66 | void PIGenFitDat3D::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
|
---|
| 67 | {
|
---|
| 68 | if (!mGFD) return;
|
---|
| 69 | if(mGFD->NData()<=0) return;
|
---|
| 70 | if(VarX<0 || VarY<0) return;
|
---|
| 71 | // On plotte les barre d'erreurs ligne demandee explicitement
|
---|
| 72 | if(mLAtt!=PI_NotDefLineAtt) SelectErrBar(true,true,true);
|
---|
| 73 |
|
---|
| 74 | #if defined(__DECCXX) || defined(__KCC__)
|
---|
| 75 | PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
|
---|
| 76 | #else
|
---|
| 77 | PIGraphic3D* g3 = (PIGraphic3D*)(g);
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
| 80 | if (mLAtt == PI_NotDefLineAtt) g3->SelLine(PI_ThinLine);
|
---|
| 81 |
|
---|
| 82 | float xp,yp,zp,er;
|
---|
| 83 | for (int i=0; i<mGFD->NData(); i++) {
|
---|
| 84 | xp = mGFD->Absc(VarX,i);
|
---|
| 85 | yp = mGFD->Absc(VarY,i);
|
---|
| 86 | zp = mGFD->Val(i);
|
---|
| 87 | if(ErrX) {
|
---|
| 88 | er = mGFD->EAbsc(VarX,i);
|
---|
| 89 | if(er>0.) g3->DrawLine3D(xp-er,yp,zp,xp+er,yp,zp);
|
---|
| 90 | }
|
---|
| 91 | if(ErrY) {
|
---|
| 92 | er = mGFD->EAbsc(VarY,i);
|
---|
| 93 | g3->DrawLine3D(xp,yp-er,zp,xp,yp+er,zp);
|
---|
| 94 | }
|
---|
| 95 | if(ErrZ) {
|
---|
| 96 | er = mGFD->EVal(i);
|
---|
| 97 | g3->DrawLine3D(xp,yp,zp-er,xp,yp,zp+er);
|
---|
| 98 | }
|
---|
| 99 | g3->DrawMarker3D(xp,yp,zp);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | return;
|
---|
| 103 | }
|
---|