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