Changeset 326 in Sophya for trunk/SophyaPI/PIext/nobjmgr.cc
- Timestamp:
- Jun 23, 1999, 4:41:47 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 //////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.