source: Sophya/trunk/SophyaPI/PIext/pipodrw.cc@ 3139

Last change on this file since 3139 was 3139, checked in by cmv, 19 years ago

modifs mineures et intro POHe2DAdapter cmv 17/01/2007

File size: 3.5 KB
Line 
1// Adaptateurs et Drawers divers pour Outils PEIDA++
2// R. Ansari 06-08/98
3// LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
4
5#include "sopnamsp.h"
6#include "pipodrw.h"
7#include "generalfit.h"
8
9
10//================================================================
11// PIGFFDrawer
12//================================================================
13
14PIGFFDrawer::PIGFFDrawer(GeneralFunction* f)
15: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
16{
17 ASSERT(f->NVar() == 1);
18}
19
20PIGFFDrawer::~PIGFFDrawer()
21{
22 delete[] mParms;
23}
24
25void
26PIGFFDrawer::SetParms(double const* p)
27{
28 for (int i=0; i<mNParms; i++)
29 mParms[i] = p[i];
30}
31
32
33void
34PIGFFDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
35{
36 PIGrCoord x1, x2, y1, y2;
37 g->GetGrSpace(x1, x2, y1, y2);
38 double xMax = x2;
39 double xMin = x1;
40 double yMax = y2;
41 double yMin = y1;
42 double xStep = (xMax - xMin)/100;
43 double xOld = xMin;
44 double yOld = 0;
45// double yOld = f->Value(&xMin, mParms);
46 for (double x = xMin+xStep; x<xMax; x+=xStep) {
47 double y = 0; // $CHECK$
48// double y = f->Value(&x, mParms);
49 if (y>yMin && yOld>yMin &&
50 y<yMax && yOld<yMax)
51 g->DrawLine(xOld, yOld, x, y);
52 xOld = x;
53 yOld = y;
54 }
55}
56
57
58// ----------------------------------------------------------
59// Adaptateur d'Histo-2D a P2DArrayAdapter
60// ----------------------------------------------------------
61
62/* --Methode-- */
63POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
64 : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
65{
66aDel = ad; mH2d = h2d;
67DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
68}
69
70/* --Methode-- */
71POH2DAdapter::~POH2DAdapter()
72{
73if (aDel) delete mH2d;
74}
75
76/* --Methode-- */
77double POH2DAdapter::Value(int ix, int iy)
78{
79return((*mH2d)(ix, iy));
80}
81
82// ----------------------------------------------------------
83// Adaptateur d'Histo2DErr a P2DArrayAdapter
84// ----------------------------------------------------------
85
86/* --Methode-- */
87POHe2DAdapter::POHe2DAdapter(Histo2DErr* he2d, bool ad)
88 : P2DArrayAdapter(he2d->NBinX(), he2d->NBinY())
89{
90aDel = ad; mHe2d = he2d;
91DefineXYCoordinates(he2d->XMin(), he2d->YMin(), he2d->WBinX(), he2d->WBinY() );
92}
93
94/* --Methode-- */
95POHe2DAdapter::~POHe2DAdapter()
96{
97if (aDel) delete mHe2d;
98}
99
100/* --Methode-- */
101double POHe2DAdapter::Value(int ix, int iy)
102{
103return((*mHe2d)(ix, iy));
104}
105
106
107#ifdef SANS_EVOLPLANCK
108
109// ----------------------------------------------------------
110// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
111// ----------------------------------------------------------
112
113/* --Methode-- */
114POVectorAdapter::POVectorAdapter(Vector* v, bool ad)
115 : P1DArrayAdapter(v->NElts())
116{
117aDel = ad; mVec = v;
118}
119
120/* --Methode-- */
121POVectorAdapter::~POVectorAdapter()
122{
123if (aDel) delete mVec;
124}
125
126/* --Methode-- */
127double POVectorAdapter::Value(int i)
128{
129return((*mVec)(i));
130}
131
132// ----------------------------------------------------------
133// Adaptateur de matrice Peida++ a P2DArrayAdapter
134// Attention Y: Lignes (rows) X: Colonnes
135// ----------------------------------------------------------
136
137/* --Methode-- */
138POMatrixAdapter::POMatrixAdapter(Matrix* mtx, bool ad)
139 : P2DArrayAdapter(mtx->NCol(), mtx->NRows())
140{
141aDel = ad; mMtx = mtx;
142}
143
144/* --Methode-- */
145POMatrixAdapter::~POMatrixAdapter()
146{
147if (aDel) delete mMtx;
148}
149
150/* --Methode-- */
151double POMatrixAdapter::Value(int ix, int iy)
152{
153// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)
154return((*mMtx)(iy, ix));
155}
156
157#endif // SANS_EVOLPLANCK
158
Note: See TracBrowser for help on using the repository browser.