source: Sophya/trunk/Poubelle/PIext/pipodrw.cc@ 678

Last change on this file since 678 was 223, checked in by ansari, 26 years ago

Creation module DPC/PIext Reza 09/04/99

File size: 2.9 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 "pipodrw.h"
6#include "generalfit.h"
7
8
9//================================================================
10// PIGFFDrawer
11//================================================================
12
13PIGFFDrawer::PIGFFDrawer(GeneralFunction* f)
14: mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms])
15{
16 ASSERT(f->NVar() == 1);
17}
18
19PIGFFDrawer::~PIGFFDrawer()
20{
21 delete[] mParms;
22}
23
24void
25PIGFFDrawer::SetParms(double const* p)
26{
27 for (int i=0; i<mNParms; i++)
28 mParms[i] = p[i];
29}
30
31
32void
33PIGFFDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/)
34{
35 PIGrCoord x1, x2, y1, y2;
36 g->GetGrSpace(x1, x2, y1, y2);
37 double xMax = x2;
38 double xMin = x1;
39 double yMax = y2;
40 double yMin = y1;
41 double xStep = (xMax - xMin)/100;
42 double xOld = xMin;
43 double yOld = 0;
44// double yOld = f->Value(&xMin, mParms);
45 for (double x = xMin+xStep; x<xMax; x+=xStep) {
46 double y = 0; // $CHECK$
47// double y = f->Value(&x, mParms);
48 if (y>yMin && yOld>yMin &&
49 y<yMax && yOld<yMax)
50 g->DrawLine(xOld, yOld, x, y);
51 xOld = x;
52 yOld = y;
53 }
54}
55
56// ----------------------------------------------------------
57// Adaptateur de vecteurs Peida++ a P1DArrayAdapter
58// ----------------------------------------------------------
59
60/* --Methode-- */
61POVectorAdapter::POVectorAdapter(Vector* v, bool ad)
62 : P1DArrayAdapter(v->NElts())
63{
64aDel = ad; mVec = v;
65}
66
67/* --Methode-- */
68POVectorAdapter::~POVectorAdapter()
69{
70if (aDel) delete mVec;
71}
72
73/* --Methode-- */
74double POVectorAdapter::Value(int i)
75{
76return((*mVec)(i));
77}
78
79// ----------------------------------------------------------
80// Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter
81// ----------------------------------------------------------
82
83/* --Methode-- */
84POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad)
85 : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY())
86{
87aDel = ad; mH2d = h2d;
88DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() );
89}
90
91/* --Methode-- */
92POH2DAdapter::~POH2DAdapter()
93{
94if (aDel) delete mH2d;
95}
96
97/* --Methode-- */
98double POH2DAdapter::Value(int ix, int iy)
99{
100return((*mH2d)(ix, iy));
101}
102
103// ----------------------------------------------------------
104// Adaptateur de matrice Peida++ a P2DArrayAdapter
105// Attention Y: Lignes (rows) X: Colonnes
106// ----------------------------------------------------------
107
108/* --Methode-- */
109POMatrixAdapter::POMatrixAdapter(Matrix* mtx, bool ad)
110 : P2DArrayAdapter(mtx->NCol(), mtx->NRows())
111{
112aDel = ad; mMtx = mtx;
113}
114
115/* --Methode-- */
116POMatrixAdapter::~POMatrixAdapter()
117{
118if (aDel) delete mMtx;
119}
120
121/* --Methode-- */
122double POMatrixAdapter::Value(int ix, int iy)
123{
124// Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col)
125return((*mMtx)(iy, ix));
126}
127
128
Note: See TracBrowser for help on using the repository browser.