Changeset 326 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Jun 23, 1999, 4:41:47 PM (26 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/basexecut.cc
r312 r326 13 13 #include "pistdimgapp.h" 14 14 #include "nobjmgr.h" 15 #include "servnobjm.h" 15 16 16 17 #include "histos.h" … … 252 253 np = atoi(tokens[3].c_str()); 253 254 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str()); 254 mObjMgr->PlotFunc(tokens[0], xmin, xmax, np, opt); 255 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], xmin, xmax, np, opt); 256 } 257 else if ( (kw == "funcff") ) { 258 if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); } 259 string opt = "n"; 260 if (tokens.size() > 5) opt = tokens[5]; 261 int np; 262 float xmin, xmax; 263 np = 100; 264 xmin = 0.; xmax = 1.; 265 np = atoi(tokens[4].c_str()); 266 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str()); 267 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], xmin, xmax, np, opt); 255 268 } 256 269 else if ( (kw == "func2d") ) { … … 271 284 string opt = "n"; 272 285 if (tokens.size() > 7) opt = tokens[7]; 273 mObjMgr->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt); 286 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], xmin, xmax, ymin, ymax, npx, npy, opt); 287 } 288 else if ( (kw == "func2dff") ) { 289 if (tokens.size() < 8) { 290 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty opt" << endl; 291 return(0); 292 } 293 int npx, npy; 294 float xmin, xmax; 295 float ymin, ymax; 296 npx = npy = 50; 297 xmin = 0.; xmax = 1.; 298 ymin = 0.; ymax = 1.; 299 npx = atoi(tokens[4].c_str()); 300 npy = atoi(tokens[7].c_str()); 301 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str()); 302 ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str()); 303 string opt = "n"; 304 if (tokens.size() > 8) opt = tokens[8]; 305 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], xmin, xmax, ymin, ymax, npx, npy, opt); 274 306 } 275 307 … … 551 583 usage = "Displays a function y=f(x) (Fills a vector with function values)"; 552 584 usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]"; 553 usage += "\n Related commands: func2d "; 585 usage += "\n Related commands: funcff func2d func2dff "; 586 mpiac->RegisterCommand(kw, usage, this); 587 kw = "funcff"; 588 usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)"; 589 usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]"; 590 usage += "\n Related commands: func func2d func2dff "; 554 591 mpiac->RegisterCommand(kw, usage, this); 555 592 kw = "func2d"; … … 557 594 usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]"; 558 595 usage += "\n Related commands: func"; 596 mpiac->RegisterCommand(kw, usage, this); 597 kw = "func2dff"; 598 usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)"; 599 usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]"; 600 usage += "\n Related commands: func funcff func2d "; 559 601 mpiac->RegisterCommand(kw, usage, this); 560 602 -
trunk/SophyaPI/PIext/nobjmgr.cc
r321 r326 23 23 #include "matrix.h" 24 24 #include "cvector.h" 25 #include "ntuple.h" 25 26 26 27 // EVOL-PLANCK … … 616 617 if (!myImgApp) return; 617 618 618 if (typeid(*obj) != typeid(NTuple)) { 619 NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj); 620 if (nt == NULL) { 621 // if (typeid(*obj) != typeid(NTupleInterface)) { 619 622 string ctyp = typeid(*obj).name(); 620 623 cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl; … … 624 627 int wrsid = 0; 625 628 bool fgsr = true; 629 dopt = "defline," + dopt; 626 630 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 627 631 628 632 if (nmz.length()>0) { // Display 3D 629 PINTuple3D* pin = new PINTuple3D( ((NTuple*)obj), false);633 PINTuple3D* pin = new PINTuple3D(nt, false); 630 634 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str()); 631 635 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str()); … … 634 638 } 635 639 else { 636 PINTuple* pin = new PINTuple( ((NTuple*)obj), false);640 PINTuple* pin = new PINTuple(nt, false); 637 641 pin->SelectXY(nmx.c_str(), nmy.c_str()); 638 642 pin->SelectErrBar(erx.c_str(), ery.c_str()); … … 773 777 774 778 bool fgsr = true; 779 dopt = "defline," + dopt; 775 780 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 776 781 string titre = nom + ":" + expy + "%" + expx; … … 808 813 pin->SelectXYZ(ntn[0], ntn[1], ntn[2]); 809 814 bool fgsr = true; 815 dopt = "defline," + dopt; 810 816 int opt = servnobjm->DecodeDispOption(dopt, fgsr); 811 817 … … 852 858 return; 853 859 } 854 floatxmin, xmax;860 double xmin, xmax; 855 861 nt->GetMinMax(0, xmin, xmax); 856 862 h1 = new Histo(xmin, xmax, 100); … … 901 907 return; 902 908 } 903 floatxmin, xmax, ymin, ymax;909 double xmin, xmax, ymin, ymax; 904 910 nt->GetMinMax(0, xmin, xmax); 905 911 nt->GetMinMax(0, ymin, ymax); … … 962 968 return; 963 969 } 964 floatxmin, xmax;970 double xmin, xmax; 965 971 nt->GetMinMax(0, xmin, xmax); 966 972 hprof = new HProf(xmin, xmax, 100); … … 1117 1123 } 1118 1124 1119 /* --Methode-- */1120 void NamedObjMgr::PlotFunc(string& expfunc, float xmin, float xmax, int np, string dopt)1121 {1122 FILE *fip;1123 string fname = (*TmpDir) + "func1_pia_dl.c";1124 string fnamer = (*TmpDir) + "func1_pia_dl";1125 string cmd;1126 int rc;1127 1128 if (!myImgApp) return;1129 1130 cmd = "rm -f " + fname;1131 rc = system(cmd.c_str());1132 printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);1133 1134 if ((fip = fopen(fname.c_str(), "w")) == NULL) {1135 string sn = fname;1136 cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;1137 return;1138 }1139 1140 // constitution du fichier a compiler1141 fputs("#include <math.h> \n", fip);1142 fputs("double func1_pia_dl_func(double x) \n{\n", fip);1143 fprintf(fip,"return(%s); \n}\n", expfunc.c_str());1144 fclose(fip);1145 1146 DlFunctionOfX f = (DlFunctionOfX) servnobjm->LinkFunctionFromFile(fnamer, "func1_pia_dl_func");1147 if (!f) return;1148 PlotFunc(f, xmin, xmax, np, dopt);1149 servnobjm->CloseDLL();1150 return;1151 }1152 1153 /* --Methode-- */1154 void NamedObjMgr::PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax,1155 int npx, int npy, string dopt)1156 {1157 FILE *fip;1158 string fname = (*TmpDir) + "func2_pia_dl.c";1159 string fnamer = (*TmpDir) + "func2_pia_dl";1160 string cmd;1161 int rc;1162 1163 if (!myImgApp) return;1164 1165 cmd = "rm " + fname;1166 rc = system(cmd.c_str());1167 printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);1168 1169 if ((fip = fopen(fname.c_str(), "w")) == NULL) {1170 string sn = fname;1171 cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;1172 return;1173 }1174 1175 // constitution du fichier a compiler1176 fputs("#include <math.h> \n", fip);1177 fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);1178 fprintf(fip,"return(%s); \n}\n", expfunc.c_str());1179 fclose(fip);1180 1181 DlFunctionOfXY f = (DlFunctionOfXY) servnobjm->LinkFunctionFromFile(fnamer, "func2_pia_dl_func");1182 if (!f) return;1183 PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);1184 servnobjm->CloseDLL();1185 return;1186 }1187 1188 /* --Methode-- */1189 void NamedObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)1190 {1191 if (!myImgApp) return;1192 1193 int k;1194 if (np < 1) np = 1;1195 if (xmax <= xmin) xmax = xmin+1.;1196 Vector* vpy = new Vector(np);1197 1198 double xx;1199 double dx = (xmax-xmin)/np;1200 TRY {1201 for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }1202 } CATCH(merr) {1203 fflush(stdout);1204 cout << endl;1205 cerr << endl;1206 string es = PeidaExc(merr);1207 cerr << "NamedObjMgr::PlotFunc() Exception :" << merr << es;1208 delete vpy;1209 vpy = NULL;1210 } ENDTRY;1211 1212 1213 if (vpy) {1214 string nom = "Func";1215 AddObj(vpy, nom);1216 P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);1217 vya->DefineXCoordinate(xmin, (xmax-xmin)/np);1218 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;1219 bool fgsr = true;1220 dopt = "thinline," + dopt;1221 int opt = servnobjm->DecodeDispOption(dopt, fgsr);1222 int wrsid = myImgApp->DispScDrawer(dr, nom, opt);1223 if(wrsid >= 0) {1224 NObjList::iterator it = myObjs->find(nom);1225 if (it == myObjs->end()) return;1226 (*it).second.wrsid.push_back(wrsid);1227 }1228 if (fgsr) myImgApp->RestoreGraphicAtt();1229 }1230 1231 return;1232 }1233 1234 /* --Methode-- */1235 void NamedObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax,1236 int npx, int npy, string dopt)1237 {1238 if (!myImgApp) return;1239 1240 if (npx < 1) npx = 1;1241 if (npy < 1) npy = 1;1242 if (xmax <= xmin) xmax = xmin+1.;1243 if (ymax <= ymin) ymax = ymin+1.;1244 1245 Matrix* mtx = new Matrix(npy, npx);1246 1247 int i,j;1248 double xx, yy;1249 double dx = (xmax-xmin)/npx;1250 double dy = (ymax-ymin)/npy;1251 // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);1252 TRY {1253 for(j=0; j<npy; j++) {1254 yy = ymin+dy*j;1255 for(i=0; i<npx; i++) {1256 xx = xmin+dx*i;1257 (*mtx)(j, i) = f(xx, yy);1258 }1259 }1260 } CATCH(merr) {1261 fflush(stdout);1262 cout << endl;1263 cerr << endl;1264 string es = PeidaExc(merr);1265 cerr << "NamedObjMgr::PlotFunc2D() Exception :" << merr << es;1266 delete mtx; mtx = NULL;1267 } ENDTRY;1268 1269 if (mtx) {1270 string nom = "Func2";1271 AddObj(mtx, nom);1272 DisplaySurf3D(nom, dopt);1273 }1274 1275 return;1276 }1277 1125 1278 1126 ///////////////////// Fit 1D et 2D ////////////////////////// -
trunk/SophyaPI/PIext/nobjmgr.h
r295 r326 78 78 string& experr, string& expcut, string& nomgfd); 79 79 80 // Trace de fonctions 1-D , 2-D81 virtual void PlotFunc(string& expfunc, float xmin, float xmax, int np=100, string dopt="");82 virtual void PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax,83 int npx=50, int npy=50, string dopt="");84 virtual void PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt="");85 virtual void PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax,86 int npx=50, int npy=50, string dopt="");87 88 80 // Methodes de fit, a rajouter (pour CMV , deux methodes H1 H2 ou 1 seule ??) ... 89 81 virtual void Fit12D(string const& nom, string& func, -
trunk/SophyaPI/PIext/nomhistadapter.cc
r295 r326 83 83 84 84 /* --Methode-- */ 85 uint_4 NTupInt_Histo::NbLines() 85 uint_4 NTupInt_Histo::NbLines() const 86 86 { 87 87 return(mHis->NBins()); … … 89 89 90 90 /* --Methode-- */ 91 uint_4 NTupInt_Histo::NbColumns() 91 uint_4 NTupInt_Histo::NbColumns() const 92 92 { 93 93 return(4); … … 95 95 96 96 /* --Methode-- */ 97 r_8* NTupInt_Histo::GetLineD(int k) 97 r_8* NTupInt_Histo::GetLineD(int k) const 98 98 { 99 99 int i; … … 108 108 109 109 /* --Methode-- */ 110 string NTupInt_Histo::VarList_C(const char* nx) 110 string NTupInt_Histo::VarList_C(const char* nx) const 111 111 { 112 112 string nomx; … … 199 199 200 200 /* --Methode-- */ 201 uint_4 NTupInt_Histo2D::NbLines() 201 uint_4 NTupInt_Histo2D::NbLines() const 202 202 { 203 203 return(mHis->NBinX()*mHis->NBinY()); … … 205 205 206 206 /* --Methode-- */ 207 uint_4 NTupInt_Histo2D::NbColumns() 207 uint_4 NTupInt_Histo2D::NbColumns() const 208 208 { 209 209 return(6); … … 211 211 212 212 /* --Methode-- */ 213 r_8* NTupInt_Histo2D::GetLineD(int n) 213 r_8* NTupInt_Histo2D::GetLineD(int n) const 214 214 { 215 215 int i,j; … … 228 228 229 229 /* --Methode-- */ 230 string NTupInt_Histo2D::VarList_C(const char* nx) 230 string NTupInt_Histo2D::VarList_C(const char* nx) const 231 231 { 232 232 string nomx; … … 309 309 310 310 /* --Methode-- */ 311 uint_4 NTupInt_NTuple::NbLines() 311 uint_4 NTupInt_NTuple::NbLines() const 312 312 { 313 313 return(mNt->NEntry()); … … 315 315 316 316 /* --Methode-- */ 317 uint_4 NTupInt_NTuple::NbColumns() 317 uint_4 NTupInt_NTuple::NbColumns() const 318 318 { 319 319 return(mNt->NVar()); … … 321 321 322 322 /* --Methode-- */ 323 r_8* NTupInt_NTuple::GetLineD(int n) 323 r_8* NTupInt_NTuple::GetLineD(int n) const 324 324 { 325 325 return(mNt->GetVecD(n)); … … 327 327 328 328 /* --Methode-- */ 329 string NTupInt_NTuple::VarList_C(const char* nx) 329 string NTupInt_NTuple::VarList_C(const char* nx) const 330 330 { 331 331 return(mNt->VarList_C(nx)); -
trunk/SophyaPI/PIext/nomhistadapter.h
r295 r326 41 41 NTupInt_Histo(Histo* h); 42 42 virtual ~NTupInt_Histo(); 43 virtual uint_4 NbLines() ;44 virtual uint_4 NbColumns() ;45 virtual r_8 * GetLineD(int n) ;46 virtual string VarList_C(const char* nomx=NULL) ;43 virtual uint_4 NbLines() const ; 44 virtual uint_4 NbColumns() const ; 45 virtual r_8 * GetLineD(int n) const ; 46 virtual string VarList_C(const char* nomx=NULL) const ; 47 47 protected: 48 48 Histo* mHis; 49 r_8 mRet[4];49 mutable r_8 mRet[4]; 50 50 }; 51 51 … … 79 79 NTupInt_Histo2D(Histo2D* h); 80 80 virtual ~NTupInt_Histo2D(); 81 virtual uint_4 NbLines() ;82 virtual uint_4 NbColumns() ;83 virtual r_8 * GetLineD(int n) ;84 virtual string VarList_C(const char* nomx=NULL) ;81 virtual uint_4 NbLines() const ; 82 virtual uint_4 NbColumns() const ; 83 virtual r_8 * GetLineD(int n) const ; 84 virtual string VarList_C(const char* nomx=NULL) const ; 85 85 protected: 86 86 Histo2D* mHis; 87 r_8 mRet[6];87 mutable r_8 mRet[6]; 88 88 }; 89 89 … … 116 116 NTupInt_NTuple(NTuple* nt); 117 117 virtual ~NTupInt_NTuple(); 118 virtual uint_4 NbLines() ;119 virtual uint_4 NbColumns() ;120 virtual r_8 * GetLineD(int n) ;121 virtual string VarList_C(const char* nomx=NULL) ;118 virtual uint_4 NbLines() const ; 119 virtual uint_4 NbColumns() const ; 120 virtual r_8 * GetLineD(int n) const ; 121 virtual string VarList_C(const char* nomx=NULL) const ; 122 122 protected: 123 123 NTuple* mNt; -
trunk/SophyaPI/PIext/nomimagadapter.cc
r311 r326 106 106 /* --Methode-- */ 107 107 template <class T> 108 uint_4 NTupInt_Image<T>::NbLines() 108 uint_4 NTupInt_Image<T>::NbLines() const 109 109 { 110 110 return( mImg->XSize() * mImg->YSize() ); … … 113 113 /* --Methode-- */ 114 114 template <class T> 115 uint_4 NTupInt_Image<T>::NbColumns() 115 uint_4 NTupInt_Image<T>::NbColumns() const 116 116 { 117 117 return(3); … … 120 120 /* --Methode-- */ 121 121 template <class T> 122 r_8* NTupInt_Image<T>::GetLineD(int n) 122 r_8* NTupInt_Image<T>::GetLineD(int n) const 123 123 { 124 124 int i,j; … … 134 134 /* --Methode-- */ 135 135 template <class T> 136 string NTupInt_Image<T>::VarList_C(const char* nx) 136 string NTupInt_Image<T>::VarList_C(const char* nx) const 137 137 { 138 138 string nomx; -
trunk/SophyaPI/PIext/nomimagadapter.h
r295 r326 43 43 NTupInt_Image(Image<T> * m); 44 44 virtual ~NTupInt_Image(); 45 virtual uint_4 NbLines() ;46 virtual uint_4 NbColumns() ;47 virtual r_8 * GetLineD(int n) ;48 virtual string VarList_C(const char* nomx=NULL) ;45 virtual uint_4 NbLines() const ; 46 virtual uint_4 NbColumns() const ; 47 virtual r_8 * GetLineD(int n) const ; 48 virtual string VarList_C(const char* nomx=NULL) const ; 49 49 protected: 50 50 Image<T> * mImg; 51 r_8 mRet[3];51 mutable r_8 mRet[3]; 52 52 }; 53 53 -
trunk/SophyaPI/PIext/nommatvecadapter.cc
r295 r326 81 81 82 82 /* --Methode-- */ 83 uint_4 NTupInt_Vector::NbLines() 83 uint_4 NTupInt_Vector::NbLines() const 84 84 { 85 85 return(mVec->NElts()); … … 87 87 88 88 /* --Methode-- */ 89 uint_4 NTupInt_Vector::NbColumns() 89 uint_4 NTupInt_Vector::NbColumns() const 90 90 { 91 91 return(2); … … 93 93 94 94 /* --Methode-- */ 95 r_8* NTupInt_Vector::GetLineD(int n) 95 r_8* NTupInt_Vector::GetLineD(int n) const 96 96 { 97 97 int i; … … 105 105 106 106 /* --Methode-- */ 107 string NTupInt_Vector::VarList_C(const char* nx) 107 string NTupInt_Vector::VarList_C(const char* nx) const 108 108 { 109 109 string nomx; … … 190 190 191 191 /* --Methode-- */ 192 uint_4 NTupInt_Matrix::NbLines() 192 uint_4 NTupInt_Matrix::NbLines() const 193 193 { 194 194 return( mMtx->NRows()*mMtx->NCol() ); … … 196 196 197 197 /* --Methode-- */ 198 uint_4 NTupInt_Matrix::NbColumns() 198 uint_4 NTupInt_Matrix::NbColumns() const 199 199 { 200 200 return(3); … … 202 202 203 203 /* --Methode-- */ 204 r_8* NTupInt_Matrix::GetLineD(int n) 204 r_8* NTupInt_Matrix::GetLineD(int n) const 205 205 { 206 206 int i,j; … … 215 215 216 216 /* --Methode-- */ 217 string NTupInt_Matrix::VarList_C(const char* nx) 217 string NTupInt_Matrix::VarList_C(const char* nx) const 218 218 { 219 219 string nomx; -
trunk/SophyaPI/PIext/nommatvecadapter.h
r295 r326 39 39 NTupInt_Vector(Vector* v); 40 40 virtual ~NTupInt_Vector(); 41 virtual uint_4 NbLines() ;42 virtual uint_4 NbColumns() ;43 virtual r_8 * GetLineD(int n) ;44 virtual string VarList_C(const char* nomx=NULL) ;41 virtual uint_4 NbLines() const ; 42 virtual uint_4 NbColumns() const ; 43 virtual r_8 * GetLineD(int n) const ; 44 virtual string VarList_C(const char* nomx=NULL) const ; 45 45 protected: 46 46 Vector* mVec; 47 r_8 mRet[2];47 mutable r_8 mRet[2]; 48 48 }; 49 49 … … 79 79 NTupInt_Matrix(Matrix* m); 80 80 virtual ~NTupInt_Matrix(); 81 virtual uint_4 NbLines() ;82 virtual uint_4 NbColumns() ;83 virtual r_8 * GetLineD(int n) ;84 virtual string VarList_C(const char* nomx=NULL) ;81 virtual uint_4 NbLines() const ; 82 virtual uint_4 NbColumns() const ; 83 virtual r_8 * GetLineD(int n) const ; 84 virtual string VarList_C(const char* nomx=NULL) const ; 85 85 protected: 86 86 Matrix* mMtx; 87 r_8 mRet[3];87 mutable r_8 mRet[3]; 88 88 }; 89 89 -
trunk/SophyaPI/PIext/nomstladapter.cc
r314 r326 84 84 85 85 /* --Methode-- */ 86 uint_4 NTupInt_StarList::NbLines() 86 uint_4 NTupInt_StarList::NbLines() const 87 87 { 88 88 return(mStl->NbStars()); … … 90 90 91 91 /* --Methode-- */ 92 uint_4 NTupInt_StarList::NbColumns() 92 uint_4 NTupInt_StarList::NbColumns() const 93 93 { 94 94 return(11); … … 96 96 97 97 /* --Methode-- */ 98 r_8* NTupInt_StarList::GetLineD(int n) 98 r_8* NTupInt_StarList::GetLineD(int n) const 99 99 { 100 100 BStar* bst = mStl->Star(n); … … 118 118 119 119 /* --Methode-- */ 120 string NTupInt_StarList::VarList_C(const char* nx) 120 string NTupInt_StarList::VarList_C(const char* nx) const 121 121 { 122 122 string nomx; -
trunk/SophyaPI/PIext/nomstladapter.h
r314 r326 39 39 NTupInt_StarList(StarList* stl); 40 40 virtual ~NTupInt_StarList(); 41 virtual uint_4 NbLines() ;42 virtual uint_4 NbColumns() ;43 virtual r_8 * GetLineD(int n) ;44 virtual string VarList_C(const char* nomx=NULL) ;41 virtual uint_4 NbLines() const ; 42 virtual uint_4 NbColumns() const ; 43 virtual r_8 * GetLineD(int n) const ; 44 virtual string VarList_C(const char* nomx=NULL) const ; 45 45 protected: 46 46 StarList* mStl; 47 r_8 mRet[12];47 mutable r_8 mRet[12]; 48 48 }; 49 49 -
trunk/SophyaPI/PIext/pintup3d.cc
r205 r326 4 4 5 5 /* --Methode-- */ 6 PINTuple3D::PINTuple3D(NTuple * nt, bool ad)6 PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad) 7 7 : PIDrawer3D() 8 8 { … … 21 21 void PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz) 22 22 { 23 string name; 23 24 if (mNT == NULL) xK = yK = zK = -1; 25 if (mNT == NULL) xK = yK = -1; 24 26 if (px == NULL) xK = -1; 25 else xK = mNT->IndexNom(px);27 else { name = px; xK = mNT->ColumnIndex(name); } 26 28 if (py == NULL) yK = -1; 27 else yK = mNT->IndexNom(py);29 else { name = py; yK = mNT->ColumnIndex(name); } 28 30 if (pz == NULL) zK = -1; 29 else zK = mNT->IndexNom(pz);31 else { name = pz; zK = mNT->ColumnIndex(name); } 30 32 } 31 33 … … 33 35 void PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz) 34 36 { 37 string name; 35 38 if (mNT == NULL) xebK = yebK = zebK = -1; 36 39 if (erbx == NULL) xebK = -1; 37 else xebK = mNT->IndexNom(erbx);40 else { name = erbx; xebK = mNT->ColumnIndex(name); } 38 41 if (erby == NULL) yebK = -1; 39 else yebK = mNT->IndexNom(erby);42 else { name = erby; yebK = mNT->ColumnIndex(name); } 40 43 if (erbz == NULL) zebK = -1; 41 else zebK = mNT->IndexNom(erbz);44 else { name = erbz; zebK = mNT->ColumnIndex(name); } 42 45 } 43 46 … … 46 49 void PINTuple3D::UpdateLimits() 47 50 { 48 if (!mNT) return; 49 if (mNT->N Entry() <= 0) return;51 if (!mNT) return; 52 if (mNT->NbLines() <= 0) return; 50 53 if ( (xK < 0) || (yK < 0) || (zK < 0) ) return; 51 54 52 55 // Commencer par trouver nos limites 53 floatxmin, xmax, ymin, ymax, zmin, zmax;56 double xmin, xmax, ymin, ymax, zmin, zmax; 54 57 xmin = ymin = 9.e19; 55 58 xmax = ymax = -9.e19; … … 76 79 z3Max = zmax; // + 0.05*(zmax-zmin); 77 80 78 // printf("PINTuple3D::UpdateLimits() : %g -%g %g-%g %g-%g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);81 // printf("PINTuple3D::UpdateLimits() : %g .. %g %g .. %g %g .. %g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D); 79 82 // printf("PINTuple3D::UpdateLimits() : %g %g %g << %g %g %g \n", 80 83 // (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5, … … 87 90 { 88 91 double xp,yp,zp,xer,yer,zer; 92 double xl,yl,zl; 89 93 int nok; 90 94 … … 104 108 105 109 nok = 0; 106 for (int i=0; i<mNT->NEntry(); i++) { 107 xp = mNT->GetVal(i, xK); 108 yp = mNT->GetVal(i, yK); 109 zp = mNT->GetVal(i, zK); 110 xp = yp = zp = xl = yl = zl = 0; 111 for (int i=0; i<mNT->NbLines(); i++) { 112 xl = xp; yl = yp; zl = zp; 113 xp = mNT->GetCell(i, xK); 114 yp = mNT->GetCell(i, yK); 115 zp = mNT->GetCell(i, zK); 116 if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) ) // On relie les points ... 117 g3->DrawLine3D(xl, yl, zl, xp, yp, zp); 110 118 nok++; 111 119 g3->DrawMarker3D(xp, yp, zp); 112 120 if ( xebK >= 0 ) { 113 xer = mNT->Get Val(i, xebK);121 xer = mNT->GetCell(i, xebK); 114 122 g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp); 115 123 } 116 124 if ( yebK >= 0 ) { 117 yer = mNT->Get Val(i, yebK);125 yer = mNT->GetCell(i, yebK); 118 126 g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp); 119 127 } 120 128 if ( zebK >= 0 ) { 121 zer = mNT->Get Val(i, zebK);129 zer = mNT->GetCell(i, zebK); 122 130 g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer); 123 131 } -
trunk/SophyaPI/PIext/pintup3d.h
r205 r326 2 2 #define PINTUPLE3D_H 3 3 4 #include "ntup le.h"4 #include "ntupintf.h" 5 5 #include "pi3ddrw.h" 6 6 7 7 class PINTuple3D : public PIDrawer3D { 8 8 public: 9 PINTuple3D(NTuple * nt, bool ad=false);9 PINTuple3D(NTupleInterface* nt, bool ad=false); 10 10 virtual ~PINTuple3D(); 11 11 … … 18 18 19 19 protected: 20 NTuple * mNT;20 NTupleInterface* mNT; 21 21 bool mAdDO; 22 22 int xK, yK, zK; // Index du nom de variable en X/Y/Z ds le ntuple -
trunk/SophyaPI/PIext/pintuple.cc
r205 r326 4 4 5 5 /* --Methode-- */ 6 PINTuple::PINTuple(NTuple * nt, bool ad)6 PINTuple::PINTuple(NTupleInterface* nt, bool ad) 7 7 : PIDrawer() 8 8 { … … 21 21 void PINTuple::SelectXY(const char* px, const char* py) 22 22 { 23 string name; 23 24 if (mNT == NULL) xK = yK = -1; 24 25 if (px == NULL) xK = -1; 25 else xK = mNT->IndexNom(px);26 else { name = px; xK = mNT->ColumnIndex(name); } 26 27 if (py == NULL) yK = -1; 27 else yK = mNT->IndexNom(py);28 else { name = py; yK = mNT->ColumnIndex(name); } 28 29 } 29 30 … … 31 32 void PINTuple::SelectErrBar(const char* erbx, const char* erby) 32 33 { 34 string name; 33 35 if (mNT == NULL) xebK = yebK = -1; 34 36 if (erbx == NULL) xebK = -1; 35 else xebK = mNT->IndexNom(erbx);37 else { name = erbx; xebK = mNT->ColumnIndex(name); } 36 38 if (erby == NULL) yebK = -1; 37 else yebK = mNT->IndexNom(erby);39 else { name = erby; yebK = mNT->ColumnIndex(name); } 38 40 } 39 41 … … 43 45 { 44 46 if (!mNT) return; 45 if (mNT->N Entry() <= 0) return;47 if (mNT->NbLines() <= 0) return; 46 48 if ( (xK < 0) || (yK < 0) ) return; 47 49 48 50 // Commencer par trouver nos limites 49 floatdx, dy;50 floatxmin, xmax, ymin, ymax;51 double dx, dy; 52 double xmin, xmax, ymin, ymax; 51 53 xmin = ymin = 9.e19; 52 54 xmax = ymax = -9.e19; … … 66 68 { 67 69 double xp,yp,xer,yer; 70 double xl,yl; 68 71 int nok; 69 72 … … 71 74 if ( (xK < 0) || (yK < 0) ) return; 72 75 if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine); 76 73 77 nok = 0; 74 for (int i=0; i<mNT->NEntry(); i++) { 75 xp = mNT->GetVal(i, xK); 76 yp = mNT->GetVal(i, yK); 78 xp = yp = xl = yl = 0; 79 for (int i=0; i<mNT->NbLines(); i++) { 80 xl = xp; yl = yp; 81 xp = mNT->GetCell(i, xK); 82 yp = mNT->GetCell(i, yK); 77 83 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue; 84 if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) ) // On relie les points ... 85 g->DrawLine(xl, yl, xp, yp); 78 86 nok++; 79 87 if ( xebK >= 0 ) { 80 xer = mNT->Get Val(i, xebK);88 xer = mNT->GetCell(i, xebK); 81 89 if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp); 82 90 } 83 91 if ( yebK >= 0 ) { 84 yer = mNT->Get Val(i, yebK);92 yer = mNT->GetCell(i, yebK); 85 93 if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer); 86 94 } -
trunk/SophyaPI/PIext/pintuple.h
r205 r326 2 2 #define PINTUPLE_H 3 3 4 #include "ntup le.h"4 #include "ntupintf.h" 5 5 #include "pidrawer.h" 6 6 7 7 class PINTuple : public PIDrawer { 8 8 public: 9 PINTuple(NTuple * nt, bool ad);9 PINTuple(NTupleInterface* nt, bool ad); 10 10 virtual ~PINTuple(); 11 11 … … 18 18 19 19 protected: 20 NTuple * mNT;20 NTupleInterface* mNT; 21 21 bool mAdDO; 22 22 int xK, yK; // Index du nom de variable en X/Y ds le ntuple -
trunk/SophyaPI/PIext/servnobjm.cc
r295 r326 24 24 #include "ntuple.h" 25 25 #include "hisprof.h" 26 27 #include "piscdrawwdg.h" 28 #include "pisurfdr.h" 29 #include "pipodrw.h" 26 30 27 31 … … 122 126 FILE *fip; 123 127 string fname = TmpDir + "expf_pia_dl.c"; 124 string fnamer = TmpDir + "expf_pia_dl";125 128 string cmd; 126 129 int rc; … … 147 150 fputs("return(1); \n} \n", fip); 148 151 fclose(fip); 149 150 return((PlotExprFunc)LinkFunctionFromFile(fnamer, "expf_pia_dl_func")); 151 } 152 153 154 /* --Methode-- */ 155 DlFunction Services2NObjMgr::LinkFunctionFromFile(string& fnamer, char* funcname) 156 { 157 string fname = fnamer + ".c" ; 158 string fnameobj = fnamer + ".o" ; 159 string fnameso = fnamer + ".so"; 160 152 string func = "expf_pia_dl_func"; 153 return((PlotExprFunc)LinkFunctionFromFile(fname, func)); 154 } 155 156 157 /* --Methode-- */ 158 DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname) 159 { 161 160 // Le link dynamique 162 161 CloseDLL(); 163 162 dynlink = PDynLinkMgr::BuildFromCFile(fname); 164 163 if (dynlink == NULL) { 165 cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur ouverture SO " << endl;164 cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl; 166 165 return(NULL); 167 166 } … … 181 180 { 182 181 if (dynlink) delete dynlink; dynlink = NULL; 182 } 183 184 /* --Methode-- */ 185 void Services2NObjMgr::PlotFunc(string const & expfunc, float xmin, float xmax, int np, string dopt) 186 { 187 FILE *fip; 188 string fname = TmpDir + "func1_pia_dl.c"; 189 string cmd; 190 int rc; 191 192 if (!mImgapp) return; 193 194 cmd = "rm -f " + fname; 195 rc = system(cmd.c_str()); 196 // printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc); 197 198 if ((fip = fopen(fname.c_str(), "w")) == NULL) { 199 string sn = fname; 200 cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl; 201 return; 202 } 203 204 // constitution du fichier a compiler 205 fputs("#include <math.h> \n", fip); 206 fputs("double func1_pia_dl_func(double x) \n{\n", fip); 207 fprintf(fip,"return(%s); \n}\n", expfunc.c_str()); 208 fclose(fip); 209 210 string func = "func1_pia_dl_func"; 211 DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func); 212 if (!f) return; 213 PlotFunc(f, xmin, xmax, np, dopt); 214 CloseDLL(); 215 return; 216 } 217 218 /* --Methode-- */ 219 void Services2NObjMgr::PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 220 int npx, int npy, string dopt) 221 { 222 FILE *fip; 223 string fname = TmpDir + "func2_pia_dl.c"; 224 string cmd; 225 int rc; 226 227 if (!mImgapp) return; 228 229 cmd = "rm " + fname; 230 rc = system(cmd.c_str()); 231 // printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc); 232 233 if ((fip = fopen(fname.c_str(), "w")) == NULL) { 234 string sn = fname; 235 cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl; 236 return; 237 } 238 239 // constitution du fichier a compiler 240 fputs("#include <math.h> \n", fip); 241 fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip); 242 fprintf(fip,"return(%s); \n}\n", expfunc.c_str()); 243 fclose(fip); 244 245 string func = "func2_pia_dl_func"; 246 DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func); 247 if (!f) return; 248 PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt); 249 CloseDLL(); 250 return; 251 } 252 253 /* --Methode-- */ 254 void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 255 int np, string dopt) 256 { 257 DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func); 258 if (!f) return; 259 PlotFunc(f, xmin, xmax, np, dopt); 260 CloseDLL(); 261 return; 262 } 263 264 /* --Methode-- */ 265 void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 266 float ymin, float ymax, int npx, int npy, string dopt) 267 { 268 DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func); 269 if (!f) return; 270 PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt); 271 CloseDLL(); 272 return; 273 } 274 275 /* --Methode-- */ 276 void Services2NObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt) 277 { 278 if (!mImgapp) return; 279 280 int k; 281 if (np < 1) np = 1; 282 if (xmax <= xmin) xmax = xmin+1.; 283 Vector* vpy = new Vector(np); 284 285 double xx; 286 double dx = (xmax-xmin)/np; 287 TRY { 288 for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); } 289 } CATCH(merr) { 290 fflush(stdout); 291 cout << endl; 292 cerr << endl; 293 string es = PeidaExc(merr); 294 cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es; 295 delete vpy; 296 vpy = NULL; 297 } ENDTRY; 298 299 300 if (vpy) { 301 string nom = "Func"; 302 P1DArrayAdapter* vya = new POVectorAdapter(vpy, true); 303 vya->DefineXCoordinate(xmin, (xmax-xmin)/np); 304 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ; 305 bool fgsr = true; 306 dopt = "thinline," + dopt; 307 int opt = DecodeDispOption(dopt, fgsr); 308 int wrsid = mImgapp->DispScDrawer(dr, nom, opt); 309 if (fgsr) mImgapp->RestoreGraphicAtt(); 310 } 311 312 return; 313 } 314 315 /* --Methode-- */ 316 void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 317 int npx, int npy, string dopt) 318 { 319 if (!mImgapp) return; 320 321 if (npx < 3) npx = 3; 322 if (npy < 3) npy = 3; 323 if (npx > 250) npx = 250; 324 if (npy > 250) npy = 250; 325 if (xmax <= xmin) xmax = xmin+1.; 326 if (ymax <= ymin) ymax = ymin+1.; 327 328 Matrix* mtx = new Matrix(npy, npx); 329 330 int i,j; 331 double xx, yy; 332 double dx = (xmax-xmin)/npx; 333 double dy = (ymax-ymin)/npy; 334 // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax); 335 TRY { 336 for(j=0; j<npy; j++) { 337 yy = ymin+dy*j; 338 for(i=0; i<npx; i++) { 339 xx = xmin+dx*i; 340 (*mtx)(j, i) = f(xx, yy); 341 } 342 } 343 } CATCH(merr) { 344 fflush(stdout); 345 cout << endl; 346 cerr << endl; 347 string es = PeidaExc(merr); 348 cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es; 349 delete mtx; mtx = NULL; 350 } ENDTRY; 351 352 if (mtx) { 353 string nom = "Func2"; 354 int wrsid = 0; 355 bool fgsr = true; 356 int opt = DecodeDispOption(dopt, fgsr); 357 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true); 358 arr->DefineXYCoordinates(xmin, ymin, dx, dy); 359 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true); 360 wrsid = mImgapp->Disp3DDrawer(sdr, nom, opt); 361 if (fgsr) mImgapp->RestoreGraphicAtt(); 362 } 363 364 return; 183 365 } 184 366 … … 211 393 if (fgsrgr) mImgapp->SaveGraphicAtt(); 212 394 213 if ( gratt.substr(0,3) == "def") { // Remise aux valeurs par defaut = non defini395 if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini 214 396 mImgapp->SetColAtt(); 215 397 mImgapp->SetLineAtt(); -
trunk/SophyaPI/PIext/servnobjm.h
r295 r326 45 45 PlotExprFunc LinkExprFunc(string& vardec, string& expx, string& expy, string& expz, 46 46 string& wt, string& cut); 47 DlFunction LinkFunctionFromFile(string & fnamer, char*funcname);47 DlFunction LinkFunctionFromFile(string const & fname, string const & funcname); 48 48 void CloseDLL(); 49 49 50 // Trace de fonctions 1-D , 2-D 51 virtual void PlotFunc(string const & expfunc, float xmin, float xmax, int np=100, string dopt=""); 52 virtual void PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax, 53 int npx=50, int npy=50, string dopt=""); 54 virtual void PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax, 55 int np=100, string dopt=""); 56 virtual void PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax, 57 float ymin, float ymax, int npx=50, int npy=50, string dopt=""); 58 virtual void PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np=100, string dopt=""); 59 virtual void PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax, 60 int npx=50, int npy=50, string dopt=""); 61 62 // Utilitaires divers 50 63 string FileName2Name(string const & fn); 51 64 int DecodeDispOption(string& dopt, bool& fgsrgr);
Note:
See TracChangeset
for help on using the changeset viewer.