Changeset 326 in Sophya for trunk


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

Location:
trunk/SophyaPI/PIext
Files:
1 deleted
17 edited

Legend:

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

    r312 r326  
    1313#include "pistdimgapp.h"
    1414#include "nobjmgr.h"
     15#include "servnobjm.h"
    1516
    1617#include "histos.h"
     
    252253  np = atoi(tokens[3].c_str());
    253254  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  }
     257else 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);
    255268  }
    256269else if ( (kw == "func2d") ) {
     
    271284  string opt = "n";
    272285  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  }
     288else 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);
    274306  }
    275307
     
    551583usage = "Displays a function y=f(x) (Fills a vector with function values)";
    552584usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
    553 usage += "\n  Related commands: func2d "; 
     585usage += "\n  Related commands: funcff func2d func2dff "; 
     586mpiac->RegisterCommand(kw, usage, this);
     587kw = "funcff";
     588usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
     589usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
     590usage += "\n  Related commands: func func2d func2dff "; 
    554591mpiac->RegisterCommand(kw, usage, this);
    555592kw = "func2d";
     
    557594usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
    558595usage += "\n  Related commands: func"; 
     596mpiac->RegisterCommand(kw, usage, this);
     597kw = "func2dff";
     598usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
     599usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
     600usage += "\n  Related commands: func funcff func2d "; 
    559601mpiac->RegisterCommand(kw, usage, this);
    560602
  • 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 //////////////////////////
  • trunk/SophyaPI/PIext/nobjmgr.h

    r295 r326  
    7878                               string& experr, string& expcut, string& nomgfd);
    7979
    80 // Trace de fonctions 1-D , 2-D
    81   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 
    8880//   Methodes de fit, a rajouter  (pour CMV , deux methodes H1 H2 ou 1 seule ??) ...
    8981  virtual void          Fit12D(string const& nom, string& func,
  • trunk/SophyaPI/PIext/nomhistadapter.cc

    r295 r326  
    8383
    8484/* --Methode-- */
    85 uint_4 NTupInt_Histo::NbLines()
     85uint_4 NTupInt_Histo::NbLines() const
    8686{
    8787return(mHis->NBins());
     
    8989
    9090/* --Methode-- */
    91 uint_4 NTupInt_Histo::NbColumns()
     91uint_4 NTupInt_Histo::NbColumns() const
    9292{
    9393return(4);
     
    9595
    9696/* --Methode-- */
    97 r_8* NTupInt_Histo::GetLineD(int k)
     97r_8* NTupInt_Histo::GetLineD(int k) const
    9898{
    9999int i;
     
    108108
    109109/* --Methode-- */
    110 string NTupInt_Histo::VarList_C(const char* nx)
     110string NTupInt_Histo::VarList_C(const char* nx) const
    111111{
    112112string nomx;
     
    199199
    200200/* --Methode-- */
    201 uint_4 NTupInt_Histo2D::NbLines()
     201uint_4 NTupInt_Histo2D::NbLines() const
    202202{
    203203return(mHis->NBinX()*mHis->NBinY());
     
    205205
    206206/* --Methode-- */
    207 uint_4 NTupInt_Histo2D::NbColumns()
     207uint_4 NTupInt_Histo2D::NbColumns() const
    208208{
    209209return(6);
     
    211211
    212212/* --Methode-- */
    213 r_8* NTupInt_Histo2D::GetLineD(int n)
     213r_8* NTupInt_Histo2D::GetLineD(int n) const
    214214{
    215215int i,j;
     
    228228
    229229/* --Methode-- */
    230 string NTupInt_Histo2D::VarList_C(const char* nx)
     230string NTupInt_Histo2D::VarList_C(const char* nx) const
    231231{
    232232string nomx;
     
    309309
    310310/* --Methode-- */
    311 uint_4 NTupInt_NTuple::NbLines()
     311uint_4 NTupInt_NTuple::NbLines() const
    312312{
    313313return(mNt->NEntry());
     
    315315
    316316/* --Methode-- */
    317 uint_4 NTupInt_NTuple::NbColumns()
     317uint_4 NTupInt_NTuple::NbColumns() const
    318318{
    319319return(mNt->NVar());
     
    321321
    322322/* --Methode-- */
    323 r_8* NTupInt_NTuple::GetLineD(int n)
     323r_8* NTupInt_NTuple::GetLineD(int n) const
    324324{
    325325return(mNt->GetVecD(n));
     
    327327
    328328/* --Methode-- */
    329 string NTupInt_NTuple::VarList_C(const char* nx)
     329string NTupInt_NTuple::VarList_C(const char* nx) const
    330330{
    331331return(mNt->VarList_C(nx));
  • trunk/SophyaPI/PIext/nomhistadapter.h

    r295 r326  
    4141                        NTupInt_Histo(Histo* h);
    4242  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 ;
    4747protected:
    4848  Histo* mHis;
    49   r_8 mRet[4];
     49  mutable r_8 mRet[4];
    5050};
    5151
     
    7979                        NTupInt_Histo2D(Histo2D* h);
    8080  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 ;
    8585protected:
    8686  Histo2D* mHis;
    87   r_8 mRet[6];
     87  mutable r_8 mRet[6];
    8888};
    8989
     
    116116                        NTupInt_NTuple(NTuple* nt);
    117117  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 ;
    122122protected:
    123123  NTuple* mNt;
  • trunk/SophyaPI/PIext/nomimagadapter.cc

    r311 r326  
    106106/* --Methode-- */
    107107template <class T>
    108 uint_4 NTupInt_Image<T>::NbLines()
     108uint_4 NTupInt_Image<T>::NbLines() const
    109109{
    110110return( mImg->XSize() * mImg->YSize() );
     
    113113/* --Methode-- */
    114114template <class T>
    115 uint_4 NTupInt_Image<T>::NbColumns()
     115uint_4 NTupInt_Image<T>::NbColumns() const
    116116{
    117117return(3);
     
    120120/* --Methode-- */
    121121template <class T>
    122 r_8* NTupInt_Image<T>::GetLineD(int n)
     122r_8* NTupInt_Image<T>::GetLineD(int n) const
    123123{
    124124int i,j;
     
    134134/* --Methode-- */
    135135template <class T>
    136 string NTupInt_Image<T>::VarList_C(const char* nx)
     136string NTupInt_Image<T>::VarList_C(const char* nx) const
    137137{
    138138string nomx;
  • trunk/SophyaPI/PIext/nomimagadapter.h

    r295 r326  
    4343                        NTupInt_Image(Image<T> * m);
    4444  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 ;
    4949protected:
    5050  Image<T> * mImg;
    51   r_8 mRet[3];
     51  mutable r_8 mRet[3];
    5252};
    5353
  • trunk/SophyaPI/PIext/nommatvecadapter.cc

    r295 r326  
    8181
    8282/* --Methode-- */
    83 uint_4 NTupInt_Vector::NbLines()
     83uint_4 NTupInt_Vector::NbLines() const
    8484{
    8585return(mVec->NElts());
     
    8787
    8888/* --Methode-- */
    89 uint_4 NTupInt_Vector::NbColumns()
     89uint_4 NTupInt_Vector::NbColumns() const
    9090{
    9191return(2);
     
    9393
    9494/* --Methode-- */
    95 r_8* NTupInt_Vector::GetLineD(int n)
     95r_8* NTupInt_Vector::GetLineD(int n) const
    9696{
    9797int i;
     
    105105
    106106/* --Methode-- */
    107 string NTupInt_Vector::VarList_C(const char* nx)
     107string NTupInt_Vector::VarList_C(const char* nx) const
    108108{
    109109string nomx;
     
    190190
    191191/* --Methode-- */
    192 uint_4 NTupInt_Matrix::NbLines()
     192uint_4 NTupInt_Matrix::NbLines() const
    193193{
    194194return( mMtx->NRows()*mMtx->NCol() );
     
    196196
    197197/* --Methode-- */
    198 uint_4 NTupInt_Matrix::NbColumns()
     198uint_4 NTupInt_Matrix::NbColumns() const
    199199{
    200200return(3);
     
    202202
    203203/* --Methode-- */
    204 r_8* NTupInt_Matrix::GetLineD(int n)
     204r_8* NTupInt_Matrix::GetLineD(int n) const
    205205{
    206206int i,j;
     
    215215
    216216/* --Methode-- */
    217 string NTupInt_Matrix::VarList_C(const char* nx)
     217string NTupInt_Matrix::VarList_C(const char* nx) const
    218218{
    219219string nomx;
  • trunk/SophyaPI/PIext/nommatvecadapter.h

    r295 r326  
    3939                        NTupInt_Vector(Vector* v);
    4040  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 ;
    4545protected:
    4646  Vector* mVec;
    47   r_8 mRet[2];
     47  mutable r_8 mRet[2];
    4848};
    4949
     
    7979                        NTupInt_Matrix(Matrix* m);
    8080  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 ;
    8585protected:
    8686  Matrix* mMtx;
    87   r_8 mRet[3];
     87  mutable r_8 mRet[3];
    8888};
    8989
  • trunk/SophyaPI/PIext/nomstladapter.cc

    r314 r326  
    8484
    8585/* --Methode-- */
    86 uint_4 NTupInt_StarList::NbLines()
     86uint_4 NTupInt_StarList::NbLines() const
    8787{
    8888return(mStl->NbStars());
     
    9090
    9191/* --Methode-- */
    92 uint_4 NTupInt_StarList::NbColumns()
     92uint_4 NTupInt_StarList::NbColumns() const
    9393{
    9494return(11);
     
    9696
    9797/* --Methode-- */
    98 r_8* NTupInt_StarList::GetLineD(int n)
     98r_8* NTupInt_StarList::GetLineD(int n) const
    9999{
    100100BStar* bst = mStl->Star(n);
     
    118118
    119119/* --Methode-- */
    120 string NTupInt_StarList::VarList_C(const char* nx)
     120string NTupInt_StarList::VarList_C(const char* nx) const
    121121{
    122122string nomx;
  • trunk/SophyaPI/PIext/nomstladapter.h

    r314 r326  
    3939                        NTupInt_StarList(StarList* stl);
    4040  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 ;
    4545protected:
    4646  StarList* mStl;
    47   r_8 mRet[12];
     47  mutable r_8 mRet[12];
    4848};
    4949
  • trunk/SophyaPI/PIext/pintup3d.cc

    r205 r326  
    44 
    55/* --Methode-- */
    6 PINTuple3D::PINTuple3D(NTuple* nt, bool ad)
     6PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad)
    77: PIDrawer3D()
    88{
     
    2121void  PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
    2222{
     23string name;
    2324if (mNT == NULL)  xK = yK = zK = -1;
     25if (mNT == NULL)  xK = yK = -1;
    2426if (px == NULL) xK = -1;
    25 else xK = mNT->IndexNom(px);
     27else { name = px; xK = mNT->ColumnIndex(name); }
    2628if (py == NULL) yK = -1;
    27 else yK = mNT->IndexNom(py);
     29else { name = py; yK = mNT->ColumnIndex(name); }
    2830if (pz == NULL) zK = -1;
    29 else zK = mNT->IndexNom(pz);
     31else { name = pz; zK = mNT->ColumnIndex(name); }
    3032}
    3133
     
    3335void  PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
    3436{
     37string name;
    3538if (mNT == NULL)  xebK = yebK = zebK = -1;
    3639if (erbx == NULL) xebK = -1;
    37 else xebK = mNT->IndexNom(erbx);
     40else { name = erbx;  xebK = mNT->ColumnIndex(name); }
    3841if (erby == NULL) yebK = -1;
    39 else yebK = mNT->IndexNom(erby);
     42else { name = erby;  yebK = mNT->ColumnIndex(name); }
    4043if (erbz == NULL) zebK = -1;
    41 else zebK = mNT->IndexNom(erbz);
     44else { name = erbz;  zebK = mNT->ColumnIndex(name); }
    4245}
    4346
     
    4649void PINTuple3D::UpdateLimits()
    4750{
    48   if (!mNT) return;
    49   if (mNT->NEntry() <= 0)  return;
     51  if (!mNT) return; 
     52  if (mNT->NbLines() <= 0)  return;
    5053  if ( (xK < 0) || (yK < 0)  || (zK < 0) )   return;
    5154
    5255  // Commencer par trouver nos limites
    53   float xmin, xmax, ymin, ymax, zmin, zmax;
     56  double xmin, xmax, ymin, ymax, zmin, zmax;
    5457  xmin = ymin = 9.e19;
    5558  xmax = ymax = -9.e19;
     
    7679  z3Max = zmax;  // + 0.05*(zmax-zmin);
    7780
    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);
    7982//  printf("PINTuple3D::UpdateLimits() :  %g %g %g << %g %g %g \n",
    8083//         (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5,
     
    8790{
    8891double xp,yp,zp,xer,yer,zer;
     92double xl,yl,zl;
    8993int nok;
    9094
     
    104108
    105109nok = 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);
     110xp = yp = zp = xl = yl = zl = 0;
     111for (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);
    110118  nok++;
    111119  g3->DrawMarker3D(xp, yp, zp);
    112120  if ( xebK >= 0 ) {
    113     xer = mNT->GetVal(i, xebK);
     121    xer = mNT->GetCell(i, xebK);
    114122    g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
    115123  }
    116124  if ( yebK >= 0 ) {
    117     yer = mNT->GetVal(i, yebK);
     125    yer = mNT->GetCell(i, yebK);
    118126    g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
    119127  }
    120128  if ( zebK >= 0 ) {
    121     zer = mNT->GetVal(i, zebK);
     129    zer = mNT->GetCell(i, zebK);
    122130    g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
    123131  }
  • trunk/SophyaPI/PIext/pintup3d.h

    r205 r326  
    22#define PINTUPLE3D_H
    33
    4 #include "ntuple.h"
     4#include "ntupintf.h"
    55#include "pi3ddrw.h"
    66
    77class PINTuple3D : public PIDrawer3D {
    88public:
    9                      PINTuple3D(NTuple* nt, bool ad=false);
     9                     PINTuple3D(NTupleInterface* nt, bool ad=false);
    1010  virtual           ~PINTuple3D();
    1111 
     
    1818       
    1919protected:
    20   NTuple* mNT;
     20  NTupleInterface* mNT;
    2121  bool mAdDO;
    2222  int xK, yK, zK;           // Index du nom de variable en X/Y/Z ds le ntuple
  • trunk/SophyaPI/PIext/pintuple.cc

    r205 r326  
    44 
    55/* --Methode-- */
    6 PINTuple::PINTuple(NTuple* nt, bool ad)
     6PINTuple::PINTuple(NTupleInterface* nt, bool ad)
    77: PIDrawer()
    88{
     
    2121void  PINTuple::SelectXY(const char* px, const char* py)
    2222{
     23string name;
    2324if (mNT == NULL)  xK = yK = -1;
    2425if (px == NULL) xK = -1;
    25 else xK = mNT->IndexNom(px);
     26else { name = px; xK = mNT->ColumnIndex(name); }
    2627if (py == NULL) yK = -1;
    27 else yK = mNT->IndexNom(py);
     28else { name = py; yK = mNT->ColumnIndex(name); }
    2829}
    2930
     
    3132void  PINTuple::SelectErrBar(const char* erbx, const char* erby)
    3233{
     34string name;
    3335if (mNT == NULL)  xebK = yebK = -1;
    3436if (erbx == NULL) xebK = -1;
    35 else xebK = mNT->IndexNom(erbx);
     37else { name = erbx;  xebK = mNT->ColumnIndex(name); }
    3638if (erby == NULL) yebK = -1;
    37 else yebK = mNT->IndexNom(erby);
     39else { name = erby;  yebK = mNT->ColumnIndex(name); }
    3840}
    3941
     
    4345{
    4446  if (!mNT) return;
    45   if (mNT->NEntry() <= 0)  return;
     47  if (mNT->NbLines() <= 0)  return;
    4648  if ( (xK < 0) || (yK < 0) )   return;
    4749
    4850  // Commencer par trouver nos limites
    49   float dx, dy;
    50   float xmin, xmax, ymin, ymax;
     51  double dx, dy;
     52  double xmin, xmax, ymin, ymax;
    5153  xmin = ymin = 9.e19;
    5254  xmax = ymax = -9.e19;
     
    6668{
    6769double xp,yp,xer,yer;
     70double xl,yl;
    6871int nok;
    6972
     
    7174if ( (xK < 0) || (yK < 0) )  return;
    7275if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
     76
    7377nok = 0; 
    74 for (int i=0; i<mNT->NEntry(); i++) {
    75   xp = mNT->GetVal(i, xK);
    76   yp = mNT->GetVal(i, yK);
     78xp = yp = xl = yl = 0;
     79for (int i=0; i<mNT->NbLines(); i++) {
     80  xl = xp;  yl = yp;
     81  xp = mNT->GetCell(i, xK);
     82  yp = mNT->GetCell(i, yK);
    7783  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);
    7886  nok++;
    7987  if ( xebK >= 0 ) {
    80     xer = mNT->GetVal(i, xebK);
     88    xer = mNT->GetCell(i, xebK);
    8189    if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
    8290  }
    8391  if ( yebK >= 0 ) {
    84     yer = mNT->GetVal(i, yebK);
     92    yer = mNT->GetCell(i, yebK);
    8593    if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
    8694  }
  • trunk/SophyaPI/PIext/pintuple.h

    r205 r326  
    22#define PINTUPLE_H
    33
    4 #include "ntuple.h"
     4#include "ntupintf.h"
    55#include "pidrawer.h"
    66
    77class PINTuple : public PIDrawer {
    88public:
    9                      PINTuple(NTuple* nt, bool ad);
     9                     PINTuple(NTupleInterface* nt, bool ad);
    1010  virtual           ~PINTuple();
    1111 
     
    1818       
    1919protected:
    20   NTuple* mNT;
     20  NTupleInterface* mNT;
    2121  bool mAdDO;
    2222  int xK, yK;          // Index du nom de variable en X/Y ds le ntuple
  • trunk/SophyaPI/PIext/servnobjm.cc

    r295 r326  
    2424#include "ntuple.h"
    2525#include "hisprof.h"
     26
     27#include "piscdrawwdg.h"
     28#include "pisurfdr.h"
     29#include "pipodrw.h"
    2630
    2731
     
    122126FILE *fip;
    123127string fname = TmpDir + "expf_pia_dl.c";
    124 string fnamer = TmpDir + "expf_pia_dl";
    125128string cmd;
    126129int rc;
     
    147150fputs("return(1); \n} \n", fip);
    148151fclose(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 
     152string func = "expf_pia_dl_func";
     153return((PlotExprFunc)LinkFunctionFromFile(fname, func));
     154}
     155
     156
     157/* --Methode-- */
     158DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
     159{
    161160//  Le link dynamique
    162161CloseDLL();
    163162dynlink = PDynLinkMgr::BuildFromCFile(fname);
    164163if (dynlink == NULL) {
    165   cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur ouverture SO " << endl;
     164  cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
    166165  return(NULL);
    167166  }
     
    181180{
    182181if (dynlink) delete dynlink;   dynlink = NULL;
     182}
     183
     184/* --Methode-- */
     185void Services2NObjMgr::PlotFunc(string const & expfunc, float xmin, float xmax, int np, string dopt)
     186{
     187FILE *fip;
     188string fname = TmpDir + "func1_pia_dl.c";
     189string  cmd;
     190int rc;
     191
     192if (!mImgapp)  return;
     193
     194cmd = "rm -f " + fname;
     195rc = system(cmd.c_str());
     196// printf("PlotFunc_Do> %s  (Rc=%d)\n", cmd.c_str(), rc);
     197
     198if ((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
     205fputs("#include <math.h> \n", fip);
     206fputs("double func1_pia_dl_func(double x) \n{\n", fip);
     207fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
     208fclose(fip);
     209
     210string func = "func1_pia_dl_func";
     211DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
     212if (!f) return;
     213PlotFunc(f, xmin, xmax, np, dopt);
     214CloseDLL();
     215return;
     216}
     217
     218/* --Methode-- */
     219void Services2NObjMgr::PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax,
     220                             int npx, int npy, string dopt)
     221{
     222FILE *fip;
     223string fname = TmpDir + "func2_pia_dl.c";
     224string cmd;
     225int rc;
     226
     227if (!mImgapp)  return;
     228
     229cmd = "rm " + fname;
     230rc = system(cmd.c_str());
     231// printf("PlotFunc2D_Do> %s  (Rc=%d)\n", cmd.c_str(), rc);
     232
     233if ((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
     240fputs("#include <math.h> \n", fip);
     241fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
     242fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
     243fclose(fip);
     244
     245string func = "func2_pia_dl_func";
     246DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
     247if (!f)  return;
     248PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
     249CloseDLL();
     250return;
     251}
     252
     253/* --Methode-- */
     254void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax,
     255                                       int np, string dopt)
     256{
     257DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
     258if (!f) return;
     259PlotFunc(f, xmin, xmax, np, dopt);
     260CloseDLL();
     261return;
     262}
     263
     264/* --Methode-- */
     265void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax,
     266                                         float ymin, float ymax, int npx, int npy, string dopt)
     267{
     268DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
     269if (!f)  return;
     270PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
     271CloseDLL();
     272return;
     273}
     274
     275/* --Methode-- */
     276void Services2NObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
     277{
     278if (!mImgapp)  return;
     279
     280int k;
     281if (np < 1) np = 1;
     282if (xmax <= xmin) xmax = xmin+1.;
     283Vector* vpy = new Vector(np);
     284
     285double xx;
     286double dx = (xmax-xmin)/np;
     287TRY {
     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
     300if (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
     312return;
     313}
     314
     315/* --Methode-- */
     316void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax,
     317                             int npx, int npy, string dopt)
     318{
     319if (!mImgapp)  return;
     320
     321if (npx < 3) npx = 3;
     322if (npy < 3) npy = 3;
     323if (npx > 250) npx = 250;
     324if (npy > 250) npy = 250;
     325if (xmax <= xmin) xmax = xmin+1.;
     326if (ymax <= ymin) ymax = ymin+1.;
     327
     328Matrix* mtx = new Matrix(npy, npx);
     329
     330int i,j;
     331double xx, yy;
     332double dx = (xmax-xmin)/npx;
     333double dy = (ymax-ymin)/npy;
     334// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
     335TRY {
     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
     352if (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
     364return;
    183365}
    184366
     
    211393if (fgsrgr) mImgapp->SaveGraphicAtt();
    212394
    213 if (gratt.substr(0,3) == "def")  {  // Remise aux valeurs par defaut = non defini
     395if ( (gratt == "def") || (gratt == "default") )  {  // Remise aux valeurs par defaut = non defini
    214396  mImgapp->SetColAtt();
    215397  mImgapp->SetLineAtt();
  • trunk/SophyaPI/PIext/servnobjm.h

    r295 r326  
    4545  PlotExprFunc  LinkExprFunc(string& vardec, string& expx, string& expy, string& expz,
    4646                             string& wt, string& cut);
    47   DlFunction    LinkFunctionFromFile(string& fnamer, char* funcname);
     47  DlFunction    LinkFunctionFromFile(string const & fname, string const & funcname);
    4848  void          CloseDLL(); 
    4949
     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
    5063  string        FileName2Name(string const & fn);
    5164  int           DecodeDispOption(string& dopt, bool& fgsrgr);
Note: See TracChangeset for help on using the changeset viewer.