Changeset 1269 in Sophya for trunk/SophyaPI/PIext


Ignore:
Timestamp:
Nov 1, 2000, 6:30:27 PM (25 years ago)
Author:
ercodmgr
Message:

Retour de ExecuteCXX pour CxxExecWind
Finalisation de CxxExecWind cmv 1/11/00

Location:
trunk/SophyaPI/PIext
Files:
5 edited

Legend:

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

    r1268 r1269  
    1313CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
    1414  : mUserCodeFn(""), mUserFctFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("")
    15   , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx")
     15  , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(1)
    1616{
    1717mIncList.resize(0);
     
    121121    return(1);
    122122  }
    123   rc = FillUserCode(toks,0); if(rc) return(1);
    124   rc = CrFile();   if(rc) return(1);
    125   rc = Compile();  if(rc) return(1);
    126   rc = Link();     if(rc) return(1);
    127   rc = Call();     if(rc) return(1);
     123  rc = ExecuteCXX(toks); if(rc) return(1);
    128124
    129125} else if(kw == "c++execfrf") {
     
    132128    return(1);
    133129  }
    134   if(tokens.size()>1) rc = FillUserCode(tokens[0],tokens[1]);
    135     else              rc = FillUserCode(tokens[0]);
    136   if(rc) return(1);
     130  rc = FillUserCode(tokens[0]); if(rc) return(1);
     131  if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
    137132  rc = CrFile();   if(rc) return(1);
    138133  rc = Compile();  if(rc) return(1);
     
    158153    return(1);
    159154  }
    160   if(tokens.size()>3) rc = FillUserCode(tokens[2],tokens[3]);
    161     else              rc = FillUserCode(tokens[2]);
    162   if(rc) return(1);
     155  rc = FillUserCode(tokens[2]); if(rc) return(1);
     156  if(tokens.size()>3) FillUserFctFrF(tokens[3]);
    163157  rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
    164158
     
    199193
    200194/* --Methode-- */
     195int  CxxExecutor::ExecuteCXX(string usercode,string userfct)
     196{
     197int rc=0;
     198rc = FillUserCode(usercode,0); if(rc) return(1);
     199rc = FillUserFctFrS(userfct);
     200rc = CrFile();   if(rc) return(1);
     201rc = Compile();  if(rc) return(1);
     202rc = Link();     if(rc) return(1);
     203rc = Call();     if(rc) return(1);
     204return 0;
     205}
     206
     207/* --Methode-- */
    201208int CxxExecutor::CrFile(string cfilename,string func)
    202209{
     
    216223
    217224os<<"//-------------------------------------------------//"<<endl;
    218 os<<"//------------- Fonctions utilisateur -------------//"<<endl;
     225os<<"//----------------- User Functions ----------------//"<<endl;
    219226os<<"//-------------------------------------------------//"<<endl;
    220227if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
     
    239246
    240247os<<"//--------------------------------------------//"<<endl;
    241 os<<"//------------- Code utilisateur -------------//"<<endl;
     248os<<"//----------------- User Code ----------------//"<<endl;
    242249os<<"//--------------------------------------------//"<<endl;
    243 os<<endl;
    244 os<<"#include \""<<mUserCodeFn<<"\""<<endl;
     250if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
    245251os<<endl;
    246252
     
    248254os<<"}"<<endl;
    249255
    250 cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl;
    251 cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl;
     256if(mPrtLevel)
     257  cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
     258if(mPrtLevel && mUserCodeFn.size()>0)
     259  cout<<"  User code was in file "<<mUserCodeFn<<endl;
     260if(mPrtLevel && mUserFctFn.size()>0)
     261  cout<<"  User function code was in file "<<mUserFctFn<<endl;
    252262return 0;
    253263}
     
    364374{
    365375mUserCodeFn = "";
    366 mUserFctFn  = "";
    367376
    368377// get the string part which is after word "first"
     
    389398if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
    390399             <<mUserCodeFn<<endl;  mUserCodeFn = ""; return 1;}
    391 os<<" "<<code;
    392 cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
    393 return 0;
    394 }
    395 
    396 /* --Methode-- */
    397 int CxxExecutor::FillUserCode(string filename,string filefctname)
    398 // User code is read from "filename" an optionally from filefctname.
     400os<<code<<endl;
     401if(mPrtLevel)
     402  cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
     403return 0;
     404}
     405
     406/* --Methode-- */
     407int CxxExecutor::FillUserFctFrS(string userfct)
     408// - Fill user Fonction code from string "userfct"
     409// It is put into file "TmpDir/cxx_spiapp_fct.h".
     410{
     411mUserFctFn  = "";
     412if(userfct.size()<1) return 0;
     413mUserFctFn  = mDefTmp + mDefRoot + "_fct.h";
     414ofstream os(mUserFctFn.c_str(),ios::out);
     415if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
     416             <<mUserFctFn<<endl;  mUserFctFn = ""; return 1;}
     417os<<userfct<<endl;
     418if(mPrtLevel)
     419  cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl;
     420return 0;
     421}
     422
     423/* --Methode-- */
     424int CxxExecutor::FillUserCode(string filename)
     425// User code is read from "filename".
    399426{
    400427mUserCodeFn = filename;
    401 mUserFctFn  = filefctname;
    402 cout<<"User code filled from file "<<filename<<endl;
     428if(mPrtLevel && mUserCodeFn.size()>0)
     429  cout<<"User code filled from file "<<mUserCodeFn<<endl;
     430return 0;
     431}
     432
     433/* --Methode-- */
     434int CxxExecutor::FillUserFctFrF(string filefctname="")
     435{
     436mUserFctFn = filefctname;
     437if(mPrtLevel && mUserFctFn.size()>0)
     438  cout<<"User Function code filled from file "<<mUserFctFn<<endl;
    403439return 0;
    404440}
     
    408444{
    409445if(rootfilename.size()<1) rootfilename = mDefRoot;
    410 cout<<"Compile: "<<rootfilename<<endl;
     446if(mPrtLevel) cout<<"Compile: "<<rootfilename<<endl;
    411447int rc = 0;
    412448rc = CrMakefile();
     
    477513string toks = libname + " " + func;
    478514int rc = mpiac->ExecuteCommand(key,arg,toks);
    479 cout<<"Link from "<<libname<<" for function "<<func
    480     <<" (rc="<<rc<<")"<<endl;
     515if(mPrtLevel) cout<<"Link from "<<libname<<" for function "<<func
     516                 <<" (rc="<<rc<<")"<<endl;
    481517return 0;
    482518}
  • trunk/SophyaPI/PIext/cxxexecutor.h

    r1268 r1269  
    2525  virtual int Execute(string& keyw,vector<string>& args, string& toks);
    2626
     27  inline void SetPrtLevel(uint_2 lp=0) {mPrtLevel = lp;}
     28
     29  int  ExecuteCXX(string usercode,string userfct="");
     30
    2731  int  CrFile(string cfilename="",string func="");
    2832       void PutInclude(ofstream& os);
     
    3236
    3337  int  FillUserCode(string& usercode,uint_4 first);
    34   int  FillUserCode(string filename,string filefctname="");
     38  int  FillUserCode(string filename);
     39
     40  int  FillUserFctFrS(string userfct="");
     41  int  FillUserFctFrF(string filefctname="");
    3542
    3643  int  Compile(string rootfilename="");
     
    7279  string mDefRoot;
    7380  string mDefFunc;
     81
     82  uint_2 mPrtLevel;
    7483};
    7584
  • trunk/SophyaPI/PIext/cxxexecwin.cc

    r1268 r1269  
    22// Classe CxxExecOptWindow : Option Window for CxxExecutor
    33// (c) DAPNIA (CEA)                 LAL (IN2P3/CNRS)
    4 //                           R. Ansari  10/2000
     4//                           R. Ansari  C.Magneville 10/2000
    55
    66#include "cxxexecutor.h"
    77#include "cxxexecwin.h"
    88
     9// --------------------------------------------------------------------
     10// --------------------------------------------------------------------
     11// ------------- Fenetre dde commande pour le CxxExecutor -------------
     12// --------------------------------------------------------------------
     13// --------------------------------------------------------------------
     14
    915/* --Methode-- */
    1016CxxExecWind::CxxExecWind(PIStdImgApp* par, CxxExecutor * cxxexec)
     
    1319  dap = par;
    1420  cxxex = cxxexec;
     21  mFName[0] = "";
     22  mFName[1] = "";
    1523
    1624  int bsx, bsy, szx, szy;
    1725  int px, py, spx, spy;
     26  int xtext, ytext;
     27
     28  ////////////////////////////////////
     29  //       Window Definition        //
     30  ////////////////////////////////////
     31
    1832  // On definit la taille a partir de la taille par defaut des composantes
    1933  PIApplicationPrefCompSize(bsx, bsy);
     
    2135  spx = bsx/6;
    2236  spy = bsy/6;
    23   szx = 8*bsx+2*spx;   
    24   szy = 10*bsy+8*spy;
     37  xtext = 8*bsx;
     38  ytext = 8*bsy;
     39  szx = xtext+2*spx;   
     40  szy = 2*ytext+5*bsy+10*spy;
    2541  SetSize(szx, szy);
    2642
    27 // Creation de champs "labels"
    28   px = (szx-6*bsx)/2;
    29   py = 2*spy;
    30   mLab = new PILabel(this, "File", bsx*6, bsy, bsx, py);
    31   mLab->SetLabel("No File Name");
    32   mLab->SetBorderWidth(1);
    33   mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    34  
    35   px = spx;
    36   py = 4*spy+bsy;
     43  ////////////////////////////////////
     44  //       User Function Code       //
     45  ////////////////////////////////////
    3746
    3847// Creation du champ texte
    39   mText = new PIText(this, "helptext", true, true, bsx*8, 8*bsy, px, py);
    40 // mText->SetMutiLineMode(true);
    41   mText->SetTextEditable(true);
    42   mText->SetText("");
    43   mText->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    44 
    45 // Creation de bouton d'action
    46 
    47   py += 2*spy+8*bsy;
    48   px = (szx-6*bsx-8*spx)/2;
    49   mBut[0] = new PIButton(this, "Exec",  400, bsx*1.2, bsy, px, py);
    50   px += 1.2*bsx+2*spx;
    51   mBut[1] = new PIButton(this, "Open",  500, bsx*1.2, bsy, px, py);
    52   px += 1.2*bsx+2*spx;
    53   mBut[2] = new PIButton(this, "Save",  600, bsx*1.2, bsy, px, py);
    54   px += 1.2*bsx+2*spx;
    55   mBut[3] = new PIButton(this, "Save As",  660, bsx*1.2, bsy, px, py);
    56   px += 1.2*bsx+2*spx;
    57   mBut[4] = new PIButton(this, "Dismiss",  700, bsx*1.2, bsy, px, py);
    58 
    59 //  Taille et position proportionnelles a la taille de la fenetre pour les elements
     48  px = spx;
     49  py = spy;
     50  mText[0] = new PIText(this,"helptext",true,true,xtext,0.75*ytext,px,py);
     51  mText[0]->SetTextEditable(true);
     52  mText[0]->SetText("");
     53
     54// Creation du champ titre, des boutons d'action et label fichier
     55  px = spx;
     56  py += (int)(spy+0.75*ytext);
     57  mLab[3] = new PILabel(this,"FileFunc",xtext,bsy,px,py);
     58  mLab[3]->SetLabel("");
     59  mLab[3]->SetBorderWidth(1);
     60  px = spx;
     61  py += spy+bsy;
     62  mLab[0] = new PILabel(this,"Function",2*bsx,bsy,px,py);
     63  mLab[0]->SetLabel("User Function Code");
     64  mLab[0]->SetBorderWidth(1);
     65  px += spx+2*bsx;
     66  mBut[0] = new PIButton(this,"Open",500,bsx,bsy,px,py);
     67  px += bsx+spx;
     68  mBut[1] = new PIButton(this,"Save",510,bsx,bsy,px,py);
     69  px += bsx+spx;
     70  mBut[2] = new PIButton(this,"Save As",520,bsx,bsy,px,py);
     71  px += bsx+spx;
     72  mBut[3] = new PIButton(this,"Reset Name",530,1.5*bsx,bsy,px,py);
     73
     74  ////////////////////////////////////
     75  //           User Code            //
     76  ////////////////////////////////////
     77
     78// Creation du champ texte
     79  px = spx;
     80  py += 2*spy+bsy;
     81  mText[1] = new PIText(this,"helptext",true,true,xtext,1.25*ytext,px,py);
     82  mText[1]->SetTextEditable(true);
     83  mText[1]->SetText("");
     84
     85// Creation du champ titre, des boutons d'action et label fichier
     86  px = spx;
     87  py += (int)(spy+1.25*ytext);
     88  mLab[4] = new PILabel(this,"FileCode",xtext,bsy,px,py);
     89  mLab[4]->SetLabel("");
     90  mLab[4]->SetBorderWidth(1);
     91  px = spx;
     92  py += spy+bsy;
     93  mLab[1] = new PILabel(this,"Code",2*bsx,bsy,px,py);
     94  mLab[1]->SetLabel("User Code");
     95  mLab[1]->SetBorderWidth(1);
     96  px += spx+2*bsx;
     97  mBut[4] = new PIButton(this,"Open",501,bsx,bsy,px,py);
     98  px += bsx+spx;
     99  mBut[5] = new PIButton(this,"Save",511,bsx,bsy,px,py);
     100  px += bsx+spx;
     101  mBut[6] = new PIButton(this,"Save As",521,bsx,bsy,px,py);
     102  px += bsx+spx;
     103  mBut[7] = new PIButton(this,"Reset Name",531,1.5*bsx,bsy,px,py);
     104
     105  ////////////////////////////////////
     106  //     Buttons for execution      //
     107  ////////////////////////////////////
     108
     109// Creation du champ titre pour le code
     110  px = spx;
     111  py += 2*spy+bsy;
     112  mLab[2] = new PILabel(this, "Execute",2*bsx,bsy,px,py);
     113  mLab[2]->SetLabel("Execute :");
     114  mLab[2]->SetBorderWidth(1);
     115
     116// Creation des boutons d'action
     117  px += (int)(szx/2 - 1.2*bsx - spx);
     118  mBut[8] = new PIButton(this,"Exec",600,1.2*bsx,bsy,px,py);
     119  px += (int)(1.2*bsx+spx);
     120  mBut[9] = new PIButton(this,"Dismiss",601,1.2*bsx,bsy,px,py);
     121
     122  ////////////////////////////////////
     123  //  Set Attributes for Elements   //
     124  ////////////////////////////////////
     125
    60126  for(int ii=0; ii<5; ii++)
     127    mLab[ii]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     128  for(int ii=0; ii<10; ii++)
    61129    mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    62 
    63   // Notre File Chooser
     130  for(int ii=0; ii<2; ii++)
     131    mText[ii]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     132
     133  // File Chooser
    64134  pfc = new PIFileChooser(this,"CxxExec-FileChooser", 5000);
    65135}
     
    68138CxxExecWind::~CxxExecWind()
    69139{
    70   delete mLab;
    71   delete mText;
    72   for(int i=0; i<5; i++)   delete mBut[i];
     140  for(int i=0; i<5; i++)  delete mLab[i];
     141  for(int i=0; i<10; i++) delete mBut[i];
     142  for(int i=0; i<2; i++)  delete mText[i];
    73143  delete pfc;
    74144}
    75145
    76 
    77146/* --Methode-- */
    78147void CxxExecWind::Show()
    79148{
    80   mLab->SetLabel(flnm);
    81   PIWindow::Show();
     149mLab[3]->SetLabel(mFName[0]);
     150mLab[4]->SetLabel(mFName[1]);
     151PIWindow::Show();
    82152}
    83153
     
    85155void CxxExecWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data)
    86156{
    87 
    88   switch (UserMsg(msg))  {
    89 
    90     case 400:    // Bouton Execute C++
    91       {
     157  msg = UserMsg(msg);
     158  switch (msg)  {
     159    case 600:    // Bouton Execute C++
    92160      dap->SetBusy();
    93       mBut[0]->SetUnSensitive();
    94       string localkey = "c++exec";
    95       vector<string> localtokens;
    96       string localstr = mText->GetText();
    97       localtokens.push_back(localstr);
    98       cxxex->Execute(localkey,localtokens,localstr);
    99       mBut[0]->SetSensitive();
     161      mBut[8]->SetUnSensitive();
     162      cxxex->ExecuteCXX(mText[1]->GetText(),mText[0]->GetText());
     163      mBut[8]->SetSensitive();
    100164      dap->SetReady();
    101165      break;
    102       }
    103 
    104     case 500:    // Open File
     166    case 601:   // Bouton Dismiss - On cache la fenetre
     167      this->Hide();
     168      break;
     169    case 500:    // Open File for Function
     170    case 501:    // Open File for Code
     171      {
     172      int i = msg-500;
    105173      pfc->AcceptNewFile(false);
    106       pfc->SetMsg(5500);
     174      pfc->SetMsg(5500+i);
    107175      dap->SetBlocked();
    108176      pfc->Show();
    109177      break;
    110    
    111     case 5500:  // Return from open-file dialog
     178      }
     179    case 5500:  // Return from open-file dialog for Function
     180    case 5501:  // Return from open-file dialog for Code
     181      {
     182      int i = msg-5500;
     183      dap->SetBusy();
     184      if(data) {
     185        mFName[i] = pfc->GetFileName();
     186        mLab[3+i]->SetLabel(mFName[i]);
     187        string code = stringfrfile(mFName[i]);
     188        mText[i]->SetText(code);
     189      }
     190      dap->SetReady();
     191      break;
     192      }
     193    case 510:  // Save for Function
     194    case 511:  // Save for Code
     195    case 520:  // Save-File for Function
     196    case 521:  // Save-File for Code
     197      {
     198      int i = msg%10;
     199      if( msg<515 && mFName[i].length()>0 ) {
     200        string code = mText[i]->GetText();
     201        filefrstring(mFName[i],code);
     202      } else {
     203        pfc->AcceptNewFile(true);
     204        pfc->SetMsg(5520+i);
     205        dap->SetBlocked();
     206        pfc->Show();   
     207      }
     208      break;
     209      }
     210    case 5520:  // Return from Save-file dialog for Function
     211    case 5521:  // Return from Save-file dialog for Code
     212      {
     213      int i = msg-5520;
    112214      dap->SetBusy();
    113215      if (data) {
    114         flnm = pfc->GetFileName();
    115         mLab->SetLabel(flnm);
    116         // We have to read the file
    117         mText->SetText("REZA A FAIRE \n Fichier non lu !");
     216        mFName[i] = pfc->GetFileName();
     217        mLab[3+i]->SetLabel(mFName[i]);
     218        string code = mText[i]->GetText();
     219        filefrstring(mFName[i],code);
    118220      }
    119221      dap->SetReady();
    120222      break;
    121 
    122     case 600:
    123     case 660:
    124       if ( (UserMsg(msg) == 600) && (flnm.length() > 0) ) {
    125         cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier "
    126              << flnm << endl;
    127       }
    128       else {
    129         pfc->AcceptNewFile(true);
    130         pfc->SetMsg(5600);
    131         dap->SetBlocked();
    132         pfc->Show();   
    133       }
    134       break;
    135 
    136     case 5600:  // Return from Save-file dialog
    137       dap->SetBusy();
    138       if (data) {
    139         flnm = pfc->GetFileName();
    140         mLab->SetLabel(flnm);
    141         // We have to save to the file
    142         cerr << " REZA A FAIRE ! Il faut sauver le champ texte ds fichier (2)"
    143              << flnm << endl;
    144       }
    145       dap->SetReady();
    146       break;
    147 
    148     case 700:   // Bouton Dismiss - On cache la fenetre
    149       this->Hide();
    150       break;
     223      }
     224    case 530:  // Reset name for Function
     225    case 531:  // Reset name for Code
     226      {
     227      int i = msg-530;
     228      mFName[i] = "";
     229      mLab[3+i]->SetLabel(mFName[i]);
     230      }
    151231  }
    152232
    153233  // In case of compile errors, we end-up here !   
    154   mBut[0]->SetSensitive();
     234  mBut[8]->SetSensitive();
    155235  dap->SetReady();
    156236  return;
    157237}
    158238
    159 // --------------------------------------------------------------------
     239/* --Methode-- */
     240void CxxExecWind::filefrstring(string filename,string& code)
     241{
     242if(filename.size()<1) return;
     243if(code.size()<1) return;
     244ofstream os(filename.c_str(),ios::out);
     245if(!os)
     246  {cout<<"CxxExecWind::filefrstring: unable to open "<<filename<<endl;
     247   return;}
     248os<<code<<endl;
     249}
     250
     251/* --Methode-- */
     252string CxxExecWind::stringfrfile(string filename)
     253{
     254string code = "";
     255if(filename.size()<1) return code;
     256ifstream is(filename.c_str(),ios::in);
     257if(!is)
     258  {cout<<"CxxExecWind::stringfrfile: unable to open "<<filename<<endl;
     259   return code;}
     260char c;
     261while(is.get(c)) code += c;
     262return code;
     263}
     264
     265// --------------------------------------------------------------------
     266// --------------------------------------------------------------------
     267// --------------- Fenetre d'option pour le CxxExecutor ---------------
    160268// --------------------------------------------------------------------
    161269// --------------------------------------------------------------------
     
    171279  int bsx, bsy, szx, szy;
    172280  int px, py, spx, spy;
     281  int xtext;
    173282  // On definit la taille a partir de la taille par defaut des composantes
    174283  PIApplicationPrefCompSize(bsx, bsy);
    175284  // On redefinit la taille de la fenetre
    176   spx = bsx/6;
     285  spx = bsx/12; if(spx<2) spx=2;
    177286  spy = bsy/6;
    178   szx = 7*bsx+5*spx;   
    179   szy = 6*bsy+12*spy;
     287  xtext = 7*bsx;
     288  szx = (int)(xtext+1.5*bsx+3*spx);
     289  szy = 6*bsy+7*spy;
    180290  SetSize(szx, szy);
    181291
    182292// Creation de champs "labels"
    183   px = (szx-6*bsx)/2;
    184   py = 2*spy;
    185   mTit = new PILabel(this, "CxxExecutor Options", bsx*6, bsy, bsx, py);
     293  px = (szx-xtext)/2;
     294  py = spy;
     295  mTit = new PILabel(this,"CxxExecutor Options",xtext,bsy,px,py);
    186296  mTit->SetBorderWidth(1);
    187  
    188   px = 2*spx;
    189   py = 4*spy+bsy;
    190   mLab[0] = new PILabel(this, "Include Files", bsx*2, bsy, px, py);
    191   py += spy+bsy;
    192   mLab[1] = new PILabel(this, "Compile Options", bsx*2, bsy, px, py);
    193   py += spy+bsy;
    194   mLab[2] = new PILabel(this, "Link Options", bsx*2, bsy, px, py);
    195   py += spy+bsy;
    196   mLab[3] = new PILabel(this, "Libraries", bsx*2, bsy, px, py);
    197 
    198   px = 3*spx+2*bsx;
    199   py = 4*spy+bsy;
    200 
    201 // Creation de champs textes
    202   mText[0] = new PIText(this, "IncFiles", bsx*5, bsy, px, py);
     297
     298// Creation des labels et des champs texte
     299  px = spx;
     300  py += spy+bsy;
     301  mLab[0] = new PILabel(this,"Include Files",1.5*bsx,bsy,px,py);
     302  px += (int)(1.5*bsx+spx);
     303  mText[0] = new PIText(this,"IncFiles",xtext,bsy,px,py);
    203304  mText[0]->SetText("");
    204   py += spy+bsy;
    205   mText[1] = new PIText(this, "CompOpt", bsx*5, bsy, px, py);
     305
     306  px = spx;
     307  py += spy+bsy;
     308  mLab[1] = new PILabel(this,"Compile Opt.",1.5*bsx,bsy,px,py);
     309  px += (int)(1.5*bsx+spx);
     310  mText[1] = new PIText(this,"CompOpt",xtext,bsy,px,py);
    206311  mText[1]->SetText("");
    207   py += spy+bsy;
    208   mText[2] = new PIText(this, "LinkOpt", bsx*5, bsy, px, py);
     312
     313  px = spx;
     314  py += spy+bsy;
     315  mLab[2] = new PILabel(this,"Link Options",1.5*bsx,bsy,px,py);
     316  px += (int)(1.5*bsx+spx);
     317  mText[2] = new PIText(this,"LinkOpt",xtext,bsy,px,py);
    209318  mText[2]->SetText("");
    210   py += spy+bsy;
    211   mText[3] = new PIText(this, "LinkLib", bsx*5, bsy, px, py);
     319
     320  px = spx;
     321  py += spy+bsy;
     322  mLab[3] = new PILabel(this,"Libraries",1.5*bsx,bsy,px,py);
     323  px += (int)(1.5*bsx+spx);
     324  mText[3] = new PIText(this,"LinkLib",xtext,bsy,px,py);
    212325  mText[3]->SetText("");
    213326
    214327// Creation de bouton d'action
    215328
    216   py += 3*spy+bsy;
    217   px = (szx-6*bsx-6*spx)/2;
    218   mBut[0] = new PIButton(this, "Set Options",  500, bsx*2, bsy, px, py);
    219   px += 2*bsx+2*spx;
    220   mBut[1] = new PIButton(this, "Get Option",  600, bsx*2, bsy, px, py);
    221   px += 2*bsx+2*spx;
    222   mBut[2] = new PIButton(this, "Dismiss",  700, bsx*2, bsy, px, py);
     329  px = (int)(szx/2 - 1.5*bsx - spx - 1.5*bsx/2.);
     330  py += spy+bsy;
     331  mBut[0] = new PIButton(this,"Set Options",500,1.5*bsx,bsy,px,py);
     332  px += (int)(1.5*bsx+spx);
     333  mBut[1] = new PIButton(this,"Get Options",600,1.5*bsx,bsy,px,py);
     334  px += (int)(1.5*bsx+spx);
     335  mBut[2] = new PIButton(this,"Dismiss",700,1.5*bsx, bsy,px,py);
    223336
    224337//  Taille et position proportionnelles a la taille de la fenetre pour les elements
    225338  mTit->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    226 
    227   for(int i=0; i<4; i++) {
     339  for(int i=0; i<4; i++)
    228340    mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    229 
     341  for(int i=0; i<4; i++)
    230342    mText[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    231   }
    232   for(int ii=0; ii<3; ii++)
    233     mBut[ii]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    234 
     343  for(int i=0; i<3; i++)
     344    mBut[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic);
    235345}
    236346
     
    238348CxxOptionWind::~CxxOptionWind()
    239349{
    240   for(int i=0; i<4; i++) {
    241     delete mLab[i];
    242     delete mText[i];
    243   }
    244350  delete mTit;
    245   delete mBut[0];
    246   delete mBut[1];
    247   delete mBut[2];
    248 }
    249 
     351  for(int i=0; i<4; i++) delete mLab[i];
     352  for(int i=0; i<3; i++) delete mBut[i];
     353  for(int i=0; i<4; i++) delete mText[i];
     354}
    250355
    251356/* --Methode-- */
     
    255360  mText[1]->SetText(cxxex->GetCompileOpt());
    256361  mText[2]->SetText(cxxex->GetLinkOpt());
    257   mText[2]->SetText(cxxex->GetLinkLibs());
     362  mText[3]->SetText(cxxex->GetLinkLibs());
    258363  PIWindow::Show();
    259364}
     
    262367void CxxOptionWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
    263368{
    264 
    265369  string opt;
    266  
    267370  switch (UserMsg(msg))  {
    268 
    269371    case 500:    // Bouton Set Options
    270 // On recupere les textes des 3 champs :
    271372      opt = mText[0]->GetText();
    272373      cxxex->FillInclude(opt);
     
    278379      cxxex->FillLinkLibs(opt);
    279380      break;
    280 
    281381    case 600:    // Bouton Get Options
    282382      mText[0]->SetText(cxxex->GetInclude());
    283383      mText[1]->SetText(cxxex->GetCompileOpt());
    284384      mText[2]->SetText(cxxex->GetLinkOpt());
    285       mText[2]->SetText(cxxex->GetLinkLibs());
    286       break;
    287 
     385      mText[3]->SetText(cxxex->GetLinkLibs());
     386      break;
    288387    case 700:   // Bouton Dismiss - On cache la fenetre
    289388      this->Hide();
    290389      break;
    291390  }
    292    
    293391return;
    294392}
    295 
    296 
  • trunk/SophyaPI/PIext/cxxexecwin.h

    r1251 r1269  
    33// Classe CxxOptionWind : Option Window for CxxExecutor
    44// (c) DAPNIA (CEA)                 LAL (IN2P3/CNRS)
    5 //                           R. Ansari  10/2000
     5//                           R. Ansari  C.Magneville 10/2000
    66
    77#ifndef CXXEXECWIN_H_SEEN
     
    1818class CxxExecutor;
    1919
     20//-----------------------------------------------------------------------
     21//-----------------------------------------------------------------------
     22//-----------------------------------------------------------------------
    2023class CxxExecWind : public PIWindow {
    2124public :
     
    2629
    2730private:
     31  virtual void filefrstring(string filename,string& code);
     32  virtual string stringfrfile(string filename);
    2833  PIStdImgApp* dap;
    2934  CxxExecutor* cxxex;
    30   PILabel  * mLab;
    31   PIButton * mBut[5];
    32   PIText * mText;
     35  PILabel  * mLab[5];
     36  PIButton * mBut[10];
     37  PIText   * mText[4];
    3338  PIFileChooser * pfc;   // Pour les fichiers user C++
    34   string flnm;
    35   };
     39  string mFName[2];
     40};
    3641
    37 
     42//-----------------------------------------------------------------------
     43//-----------------------------------------------------------------------
     44//-----------------------------------------------------------------------
    3845class CxxOptionWind : public PIWindow {
    3946public :
     
    4451
    4552private:
    46   PIStdImgApp* dap;
    47   CxxExecutor* cxxex;
     53  PIStdImgApp * dap;
     54  CxxExecutor * cxxex;
    4855  PILabel  * mTit;
    4956  PILabel  * mLab[4];
    5057  PIButton * mBut[3];
    51   PIText * mText[4];
    52   };
     58  PIText   * mText[4];
     59};
    5360
    5461
  • trunk/SophyaPI/PIext/piacmd.cc

    r1268 r1269  
    553553    return(99);
    554554  }
    555   string localkey = "c++exec", localstr;
    556   vector<string> localtokens;
    557555  if (s[1] == '@') { // Sans substitution des variables $
    558     localstr = s.substr(2);
    559     localtokens.push_back(localstr);
    560     return(cxxe->Execute(localkey,localtokens,localstr));
     556    return(cxxe->ExecuteCXX(s.substr(2)));
    561557  } else { // Avec substitution de variables $
    562558    string s2;
    563559    SubstituteVars(s, s2);
    564     localstr = s2.substr(1);
    565     localtokens.push_back(localstr);
    566     return(cxxe->Execute(localkey,localtokens,localstr));   
     560    return(cxxe->ExecuteCXX(s2.substr(1)));   
    567561  }
    568562}
Note: See TracChangeset for help on using the changeset viewer.