Changeset 326 in Sophya for trunk/SophyaPI/PIext/nobjmgr.cc


Ignore:
Timestamp:
Jun 23, 1999, 4:41:47 PM (26 years ago)
Author:
ercodmgr
Message:

1/ NTupleInterface mis ds Outils++ et complete -
2/ Les PINtuple et PINtup3D utilisent maintenant NTupleInterface
3/ Debut modification interface NObjMgr - Reza 23/6/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/nobjmgr.cc

    r321 r326  
    2323#include "matrix.h"
    2424#include "cvector.h"
     25#include "ntuple.h"
    2526
    2627// EVOL-PLANCK
     
    616617if (!myImgApp)  return;
    617618
    618 if (typeid(*obj) != typeid(NTuple)) {
     619NTupleInterface * nt = dynamic_cast<NTupleInterface *>(obj);
     620if (nt == NULL) {
     621// if (typeid(*obj) != typeid(NTupleInterface)) {
    619622  string ctyp = typeid(*obj).name();
    620623  cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl;
     
    624627int wrsid = 0;
    625628bool fgsr = true;
     629dopt = "defline," + dopt;
    626630int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    627631
    628632if (nmz.length()>0)  { // Display 3D
    629   PINTuple3D* pin = new PINTuple3D(((NTuple*)obj), false);
     633  PINTuple3D* pin = new PINTuple3D(nt, false);
    630634  pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
    631635  pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
     
    634638}
    635639else {
    636   PINTuple* pin = new PINTuple(((NTuple*)obj), false);
     640  PINTuple* pin = new PINTuple(nt, false);
    637641  pin->SelectXY(nmx.c_str(), nmy.c_str());
    638642  pin->SelectErrBar(erx.c_str(), ery.c_str());
     
    773777
    774778bool fgsr = true;
     779dopt = "defline," + dopt;
    775780int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    776781string titre =  nom + ":" + expy + "%" + expx;
     
    808813pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
    809814bool fgsr = true;
     815dopt = "defline," + dopt;
    810816int opt = servnobjm->DecodeDispOption(dopt, fgsr);
    811817
     
    852858    return;
    853859    }
    854   float xmin, xmax;
     860  double xmin, xmax;
    855861  nt->GetMinMax(0, xmin, xmax);
    856862  h1 = new Histo(xmin, xmax, 100);
     
    901907    return;
    902908    }
    903   float xmin, xmax, ymin, ymax;
     909  double xmin, xmax, ymin, ymax;
    904910  nt->GetMinMax(0, xmin, xmax);
    905911  nt->GetMinMax(0, ymin, ymax);
     
    962968    return;
    963969  }
    964   float xmin, xmax;
     970  double xmin, xmax;
    965971  nt->GetMinMax(0, xmin, xmax);
    966972  hprof = new HProf(xmin, xmax, 100);
     
    11171123}
    11181124
    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 compiler
    1141 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 compiler
    1176 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 }
    12771125
    12781126///////////////////// Fit 1D et 2D //////////////////////////
Note: See TracChangeset for help on using the changeset viewer.