source: Sophya/trunk/SophyaPI/PIext/nommatvecadapter.cc@ 422

Last change on this file since 422 was 344, checked in by ercodmgr, 26 years ago

1/ Extension de fonctionalites de gestion de repertoires (Lock, ...)
2/ Plus de NTupIntf_Adapter quand les objets heritent de NTupleInterface
3/ Support pour affichage info texte, ds PINtuple et PIStarList

File size: 4.4 KB
Line 
1#include "machdefs.h"
2#include <stdlib.h>
3#include <typeinfo>
4#include <iostream.h>
5#include <string>
6
7#include "nommatvecadapter.h"
8#include "piscdrawwdg.h"
9#include "pipodrw.h"
10
11//---------------------------------------------------------------
12// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Vector
13//---------------------------------------------------------------
14
15/* --Methode-- */
16NOMAdapter_Vector::NOMAdapter_Vector(Vector* o)
17 : NObjMgrAdapter(o)
18{
19mVec = o;
20}
21
22/* --Methode-- */
23NOMAdapter_Vector::~NOMAdapter_Vector()
24{
25}
26
27/* --Methode-- */
28NObjMgrAdapter* NOMAdapter_Vector::Clone(AnyDataObj* o)
29{
30Vector* v = dynamic_cast<Vector *>(o);
31if (v) return ( new NOMAdapter_Vector(v) );
32return ( new NObjMgrAdapter(o) );
33}
34
35
36/* --Methode-- */
37void NOMAdapter_Vector::SavePPF(POutPersist& pos, string const & nom)
38{
39#ifdef SANS_EVOLPLANCK
40// PEIDA-EROS L'histo est lui-meme PPersist
41string tag = nom; // A cause de const
42mVec->Write(pos,0,tag);
43#else
44string s = typeid(*mObj).name();
45cout << "NOMAdapter_Vector::SavePPF() - Error : Not supported for " << s << endl;
46#endif
47}
48
49/* --Methode-- */
50void NOMAdapter_Vector::Print(ostream& os)
51{
52os << (*mVec);
53}
54
55/* --Methode-- */
56PIDrawer* NOMAdapter_Vector::GetDrawer(string & dopt)
57{
58dopt = "thinline," + dopt;
59return( new PIYfXDrawer( new POVectorAdapter(mVec, false), NULL, true) );
60}
61
62/* --Methode-- */
63NTupleInterface* NOMAdapter_Vector::GetNTupleInterface(bool& adel)
64{
65adel = true;
66return( new NTupInt_Vector(mVec) );
67}
68
69
70// -------------------------------------------------------------
71
72/* --Methode-- */
73NTupInt_Vector::NTupInt_Vector(Vector* v)
74{
75mVec = v;
76}
77
78/* --Methode-- */
79NTupInt_Vector::~NTupInt_Vector()
80{
81}
82
83/* --Methode-- */
84uint_4 NTupInt_Vector::NbLines() const
85{
86return(mVec->NElts());
87}
88
89/* --Methode-- */
90uint_4 NTupInt_Vector::NbColumns() const
91{
92return(2);
93}
94
95/* --Methode-- */
96r_8* NTupInt_Vector::GetLineD(int n) const
97{
98int i;
99if ((n < 0) || (n >= mVec->NElts() ))
100 for(i=0; i<2; i++) mRet[i] = 0.;
101else {
102 mRet[0] = n; mRet[1] = (*mVec)(n);
103 }
104return(mRet);
105}
106
107/* --Methode-- */
108string NTupInt_Vector::VarList_C(const char* nx) const
109{
110string nomx;
111if (nx) nomx = nx;
112else nomx = "_xh_";
113string vardec = "double i,val; \n";
114vardec += "i = " + nomx + "[0]; val = " + nomx + "[1]; \n";
115return(vardec);
116}
117
118
119//---------------------------------------------------------------
120// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Matrix
121//---------------------------------------------------------------
122
123
124/* --Methode-- */
125NOMAdapter_Matrix::NOMAdapter_Matrix(Matrix* o)
126 : NObjMgrAdapter(o)
127{
128mMtx = o;
129}
130
131/* --Methode-- */
132NOMAdapter_Matrix::~NOMAdapter_Matrix()
133{
134}
135
136/* --Methode-- */
137NObjMgrAdapter* NOMAdapter_Matrix::Clone(AnyDataObj* o)
138{
139Matrix* m = dynamic_cast<Matrix *>(o);
140if (m) return ( new NOMAdapter_Matrix(m) );
141return ( new NObjMgrAdapter(o) );
142}
143
144
145/* --Methode-- */
146void NOMAdapter_Matrix::SavePPF(POutPersist& pos, string const & nom)
147{
148#ifdef SANS_EVOLPLANCK
149// PEIDA-EROS L'histo est lui-meme PPersist
150string tag = nom; // A cause de const
151mMtx->Write(pos,0,tag);
152#else
153string s = typeid(*mObj).name();
154cout << "NOMAdapter_Matrix::SavePPF() - Error : Not supported for " << s << endl;
155#endif
156}
157
158/* --Methode-- */
159void NOMAdapter_Matrix::Print(ostream& os)
160{
161os << (*mMtx);
162}
163
164
165/* --Methode-- */
166P2DArrayAdapter* NOMAdapter_Matrix::Get2DArray(string &)
167{
168return ( new POMatrixAdapter(mMtx, false) );
169}
170
171/* --Methode-- */
172NTupleInterface* NOMAdapter_Matrix::GetNTupleInterface(bool& adel)
173{
174adel = true;
175return( new NTupInt_Matrix(mMtx) );
176}
177
178
179
180// -------------------------------------------------------------
181
182/* --Methode-- */
183NTupInt_Matrix::NTupInt_Matrix(Matrix* m)
184{
185mMtx = m;
186}
187
188/* --Methode-- */
189NTupInt_Matrix::~NTupInt_Matrix()
190{
191}
192
193/* --Methode-- */
194uint_4 NTupInt_Matrix::NbLines() const
195{
196return( mMtx->NRows()*mMtx->NCol() );
197}
198
199/* --Methode-- */
200uint_4 NTupInt_Matrix::NbColumns() const
201{
202return(3);
203}
204
205/* --Methode-- */
206r_8* NTupInt_Matrix::GetLineD(int n) const
207{
208int i,j;
209if ((n < 0) || (n >= mMtx->NRows()*mMtx->NCol() ))
210 for(i=0; i<3; i++) mRet[i] = 0.;
211else {
212 i = n/mMtx->NCol(); j = n%mMtx->NCol();
213 mRet[0] = i; mRet[1] = j; mRet[2] = (*mMtx)(i,j);
214 }
215return(mRet);
216}
217
218/* --Methode-- */
219string NTupInt_Matrix::VarList_C(const char* nx) const
220{
221string nomx;
222if (nx) nomx = nx;
223else nomx = "_xh_";
224string vardec = "double i,j,val; \n";
225vardec += "i = " + nomx + "[0]; j = " + nomx + "[1]; val = " + nomx + "[2]; \n";
226return(vardec);
227}
Note: See TracBrowser for help on using the repository browser.