Changeset 1269 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Nov 1, 2000, 6:30:27 PM (25 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/cxxexecutor.cc
r1268 r1269 13 13 CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */) 14 14 : mUserCodeFn(""), mUserFctFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("") 15 , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx") 15 , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(1) 16 16 { 17 17 mIncList.resize(0); … … 121 121 return(1); 122 122 } 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); 128 124 129 125 } else if(kw == "c++execfrf") { … … 132 128 return(1); 133 129 } 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]); 137 132 rc = CrFile(); if(rc) return(1); 138 133 rc = Compile(); if(rc) return(1); … … 158 153 return(1); 159 154 } 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]); 163 157 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1); 164 158 … … 199 193 200 194 /* --Methode-- */ 195 int CxxExecutor::ExecuteCXX(string usercode,string userfct) 196 { 197 int rc=0; 198 rc = FillUserCode(usercode,0); if(rc) return(1); 199 rc = FillUserFctFrS(userfct); 200 rc = CrFile(); if(rc) return(1); 201 rc = Compile(); if(rc) return(1); 202 rc = Link(); if(rc) return(1); 203 rc = Call(); if(rc) return(1); 204 return 0; 205 } 206 207 /* --Methode-- */ 201 208 int CxxExecutor::CrFile(string cfilename,string func) 202 209 { … … 216 223 217 224 os<<"//-------------------------------------------------//"<<endl; 218 os<<"//------------- Fonctions utilisateur-------------//"<<endl;225 os<<"//----------------- User Functions ----------------//"<<endl; 219 226 os<<"//-------------------------------------------------//"<<endl; 220 227 if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl; … … 239 246 240 247 os<<"//--------------------------------------------//"<<endl; 241 os<<"//------------- Code utilisateur-------------//"<<endl;248 os<<"//----------------- User Code ----------------//"<<endl; 242 249 os<<"//--------------------------------------------//"<<endl; 243 os<<endl; 244 os<<"#include \""<<mUserCodeFn<<"\""<<endl; 250 if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl; 245 251 os<<endl; 246 252 … … 248 254 os<<"}"<<endl; 249 255 250 cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl; 251 cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl; 256 if(mPrtLevel) 257 cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl; 258 if(mPrtLevel && mUserCodeFn.size()>0) 259 cout<<" User code was in file "<<mUserCodeFn<<endl; 260 if(mPrtLevel && mUserFctFn.size()>0) 261 cout<<" User function code was in file "<<mUserFctFn<<endl; 252 262 return 0; 253 263 } … … 364 374 { 365 375 mUserCodeFn = ""; 366 mUserFctFn = "";367 376 368 377 // get the string part which is after word "first" … … 389 398 if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open " 390 399 <<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. 400 os<<code<<endl; 401 if(mPrtLevel) 402 cout<<"User code filled from standard input into "<<mUserCodeFn<<endl; 403 return 0; 404 } 405 406 /* --Methode-- */ 407 int CxxExecutor::FillUserFctFrS(string userfct) 408 // - Fill user Fonction code from string "userfct" 409 // It is put into file "TmpDir/cxx_spiapp_fct.h". 410 { 411 mUserFctFn = ""; 412 if(userfct.size()<1) return 0; 413 mUserFctFn = mDefTmp + mDefRoot + "_fct.h"; 414 ofstream os(mUserFctFn.c_str(),ios::out); 415 if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open " 416 <<mUserFctFn<<endl; mUserFctFn = ""; return 1;} 417 os<<userfct<<endl; 418 if(mPrtLevel) 419 cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl; 420 return 0; 421 } 422 423 /* --Methode-- */ 424 int CxxExecutor::FillUserCode(string filename) 425 // User code is read from "filename". 399 426 { 400 427 mUserCodeFn = filename; 401 mUserFctFn = filefctname; 402 cout<<"User code filled from file "<<filename<<endl; 428 if(mPrtLevel && mUserCodeFn.size()>0) 429 cout<<"User code filled from file "<<mUserCodeFn<<endl; 430 return 0; 431 } 432 433 /* --Methode-- */ 434 int CxxExecutor::FillUserFctFrF(string filefctname="") 435 { 436 mUserFctFn = filefctname; 437 if(mPrtLevel && mUserFctFn.size()>0) 438 cout<<"User Function code filled from file "<<mUserFctFn<<endl; 403 439 return 0; 404 440 } … … 408 444 { 409 445 if(rootfilename.size()<1) rootfilename = mDefRoot; 410 cout<<"Compile: "<<rootfilename<<endl;446 if(mPrtLevel) cout<<"Compile: "<<rootfilename<<endl; 411 447 int rc = 0; 412 448 rc = CrMakefile(); … … 477 513 string toks = libname + " " + func; 478 514 int rc = mpiac->ExecuteCommand(key,arg,toks); 479 cout<<"Link from "<<libname<<" for function "<<func480 <<" (rc="<<rc<<")"<<endl;515 if(mPrtLevel) cout<<"Link from "<<libname<<" for function "<<func 516 <<" (rc="<<rc<<")"<<endl; 481 517 return 0; 482 518 } -
trunk/SophyaPI/PIext/cxxexecutor.h
r1268 r1269 25 25 virtual int Execute(string& keyw,vector<string>& args, string& toks); 26 26 27 inline void SetPrtLevel(uint_2 lp=0) {mPrtLevel = lp;} 28 29 int ExecuteCXX(string usercode,string userfct=""); 30 27 31 int CrFile(string cfilename="",string func=""); 28 32 void PutInclude(ofstream& os); … … 32 36 33 37 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=""); 35 42 36 43 int Compile(string rootfilename=""); … … 72 79 string mDefRoot; 73 80 string mDefFunc; 81 82 uint_2 mPrtLevel; 74 83 }; 75 84 -
trunk/SophyaPI/PIext/cxxexecwin.cc
r1268 r1269 2 2 // Classe CxxExecOptWindow : Option Window for CxxExecutor 3 3 // (c) DAPNIA (CEA) LAL (IN2P3/CNRS) 4 // R. Ansari 10/20004 // R. Ansari C.Magneville 10/2000 5 5 6 6 #include "cxxexecutor.h" 7 7 #include "cxxexecwin.h" 8 8 9 // -------------------------------------------------------------------- 10 // -------------------------------------------------------------------- 11 // ------------- Fenetre dde commande pour le CxxExecutor ------------- 12 // -------------------------------------------------------------------- 13 // -------------------------------------------------------------------- 14 9 15 /* --Methode-- */ 10 16 CxxExecWind::CxxExecWind(PIStdImgApp* par, CxxExecutor * cxxexec) … … 13 19 dap = par; 14 20 cxxex = cxxexec; 21 mFName[0] = ""; 22 mFName[1] = ""; 15 23 16 24 int bsx, bsy, szx, szy; 17 25 int px, py, spx, spy; 26 int xtext, ytext; 27 28 //////////////////////////////////// 29 // Window Definition // 30 //////////////////////////////////// 31 18 32 // On definit la taille a partir de la taille par defaut des composantes 19 33 PIApplicationPrefCompSize(bsx, bsy); … … 21 35 spx = bsx/6; 22 36 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; 25 41 SetSize(szx, szy); 26 42 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 //////////////////////////////////// 37 46 38 47 // 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 60 126 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++) 61 129 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 64 134 pfc = new PIFileChooser(this,"CxxExec-FileChooser", 5000); 65 135 } … … 68 138 CxxExecWind::~CxxExecWind() 69 139 { 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]; 73 143 delete pfc; 74 144 } 75 145 76 77 146 /* --Methode-- */ 78 147 void CxxExecWind::Show() 79 148 { 80 mLab->SetLabel(flnm); 81 PIWindow::Show(); 149 mLab[3]->SetLabel(mFName[0]); 150 mLab[4]->SetLabel(mFName[1]); 151 PIWindow::Show(); 82 152 } 83 153 … … 85 155 void CxxExecWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* data) 86 156 { 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++ 92 160 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(); 100 164 dap->SetReady(); 101 165 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; 105 173 pfc->AcceptNewFile(false); 106 pfc->SetMsg(5500 );174 pfc->SetMsg(5500+i); 107 175 dap->SetBlocked(); 108 176 pfc->Show(); 109 177 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; 112 214 dap->SetBusy(); 113 215 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); 118 220 } 119 221 dap->SetReady(); 120 222 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 } 151 231 } 152 232 153 233 // In case of compile errors, we end-up here ! 154 mBut[ 0]->SetSensitive();234 mBut[8]->SetSensitive(); 155 235 dap->SetReady(); 156 236 return; 157 237 } 158 238 159 // -------------------------------------------------------------------- 239 /* --Methode-- */ 240 void CxxExecWind::filefrstring(string filename,string& code) 241 { 242 if(filename.size()<1) return; 243 if(code.size()<1) return; 244 ofstream os(filename.c_str(),ios::out); 245 if(!os) 246 {cout<<"CxxExecWind::filefrstring: unable to open "<<filename<<endl; 247 return;} 248 os<<code<<endl; 249 } 250 251 /* --Methode-- */ 252 string CxxExecWind::stringfrfile(string filename) 253 { 254 string code = ""; 255 if(filename.size()<1) return code; 256 ifstream is(filename.c_str(),ios::in); 257 if(!is) 258 {cout<<"CxxExecWind::stringfrfile: unable to open "<<filename<<endl; 259 return code;} 260 char c; 261 while(is.get(c)) code += c; 262 return code; 263 } 264 265 // -------------------------------------------------------------------- 266 // -------------------------------------------------------------------- 267 // --------------- Fenetre d'option pour le CxxExecutor --------------- 160 268 // -------------------------------------------------------------------- 161 269 // -------------------------------------------------------------------- … … 171 279 int bsx, bsy, szx, szy; 172 280 int px, py, spx, spy; 281 int xtext; 173 282 // On definit la taille a partir de la taille par defaut des composantes 174 283 PIApplicationPrefCompSize(bsx, bsy); 175 284 // On redefinit la taille de la fenetre 176 spx = bsx/ 6;285 spx = bsx/12; if(spx<2) spx=2; 177 286 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; 180 290 SetSize(szx, szy); 181 291 182 292 // 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); 186 296 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); 203 304 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); 206 311 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); 209 318 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); 212 325 mText[3]->SetText(""); 213 326 214 327 // Creation de bouton d'action 215 328 216 p y += 3*spy+bsy;217 p x = (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); 223 336 224 337 // Taille et position proportionnelles a la taille de la fenetre pour les elements 225 338 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++) 228 340 mLab[i]->SetBinding(PIBK_elastic , PIBK_elastic , PIBK_elastic , PIBK_elastic); 229 341 for(int i=0; i<4; i++) 230 342 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); 235 345 } 236 346 … … 238 348 CxxOptionWind::~CxxOptionWind() 239 349 { 240 for(int i=0; i<4; i++) {241 delete mLab[i];242 delete mText[i];243 }244 350 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 } 250 355 251 356 /* --Methode-- */ … … 255 360 mText[1]->SetText(cxxex->GetCompileOpt()); 256 361 mText[2]->SetText(cxxex->GetLinkOpt()); 257 mText[ 2]->SetText(cxxex->GetLinkLibs());362 mText[3]->SetText(cxxex->GetLinkLibs()); 258 363 PIWindow::Show(); 259 364 } … … 262 367 void CxxOptionWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/) 263 368 { 264 265 369 string opt; 266 267 370 switch (UserMsg(msg)) { 268 269 371 case 500: // Bouton Set Options 270 // On recupere les textes des 3 champs :271 372 opt = mText[0]->GetText(); 272 373 cxxex->FillInclude(opt); … … 278 379 cxxex->FillLinkLibs(opt); 279 380 break; 280 281 381 case 600: // Bouton Get Options 282 382 mText[0]->SetText(cxxex->GetInclude()); 283 383 mText[1]->SetText(cxxex->GetCompileOpt()); 284 384 mText[2]->SetText(cxxex->GetLinkOpt()); 285 mText[2]->SetText(cxxex->GetLinkLibs()); 286 break; 287 385 mText[3]->SetText(cxxex->GetLinkLibs()); 386 break; 288 387 case 700: // Bouton Dismiss - On cache la fenetre 289 388 this->Hide(); 290 389 break; 291 390 } 292 293 391 return; 294 392 } 295 296 -
trunk/SophyaPI/PIext/cxxexecwin.h
r1251 r1269 3 3 // Classe CxxOptionWind : Option Window for CxxExecutor 4 4 // (c) DAPNIA (CEA) LAL (IN2P3/CNRS) 5 // R. Ansari 10/20005 // R. Ansari C.Magneville 10/2000 6 6 7 7 #ifndef CXXEXECWIN_H_SEEN … … 18 18 class CxxExecutor; 19 19 20 //----------------------------------------------------------------------- 21 //----------------------------------------------------------------------- 22 //----------------------------------------------------------------------- 20 23 class CxxExecWind : public PIWindow { 21 24 public : … … 26 29 27 30 private: 31 virtual void filefrstring(string filename,string& code); 32 virtual string stringfrfile(string filename); 28 33 PIStdImgApp* dap; 29 34 CxxExecutor* cxxex; 30 PILabel * mLab ;31 PIButton * mBut[ 5];32 PIText * mText;35 PILabel * mLab[5]; 36 PIButton * mBut[10]; 37 PIText * mText[4]; 33 38 PIFileChooser * pfc; // Pour les fichiers user C++ 34 string flnm;35 39 string mFName[2]; 40 }; 36 41 37 42 //----------------------------------------------------------------------- 43 //----------------------------------------------------------------------- 44 //----------------------------------------------------------------------- 38 45 class CxxOptionWind : public PIWindow { 39 46 public : … … 44 51 45 52 private: 46 PIStdImgApp * dap;47 CxxExecutor * cxxex;53 PIStdImgApp * dap; 54 CxxExecutor * cxxex; 48 55 PILabel * mTit; 49 56 PILabel * mLab[4]; 50 57 PIButton * mBut[3]; 51 PIText * mText[4];52 58 PIText * mText[4]; 59 }; 53 60 54 61 -
trunk/SophyaPI/PIext/piacmd.cc
r1268 r1269 553 553 return(99); 554 554 } 555 string localkey = "c++exec", localstr;556 vector<string> localtokens;557 555 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))); 561 557 } else { // Avec substitution de variables $ 562 558 string s2; 563 559 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))); 567 561 } 568 562 }
Note:
See TracChangeset
for help on using the changeset viewer.