Changeset 2999 in Sophya for trunk/SophyaPI/PIext
- Timestamp:
- Jul 2, 2006, 7:20:56 PM (19 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/basexecut.cc
r2975 r2999 444 444 } 445 445 446 m ObjMgr->SetVar(tokens[1], v2str);446 mpiac->SetVar(tokens[1], v2str); 447 447 } 448 448 // Une ligne du NTuple/NTupleInterface -> variable interpreteur … … 509 509 } 510 510 } 511 m ObjMgr->SetVar(tokens[2], v2str);511 mpiac->SetVar(tokens[2], v2str); 512 512 if (adel) delete nti; 513 } 514 // Operation sur objets a travers l'adaptateur NObjMgrAdapter::PerformOperation() 515 else if (kw == "objaoper") { 516 if (tokens.size() < 2) { 517 cout << "Usage: objaoper objname operation [args ...]" << endl; 518 return(0); 519 } 520 NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]); 521 if(oa == NULL) { 522 cerr << "objaoper Error , No such object " << tokens[0] << endl; 523 return(0); 524 } 525 tokens.erase(tokens.begin()); 526 return oa->PerformOperation(tokens); 513 527 } 514 528 … … 626 640 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]); 627 641 } 642 else if (kw == "plot3dw" ) { 643 if (tokens.size() < 5) { 644 cout << "Usage: plot3dw nomobj expx expy expz expwt [expcut opt loop_par]" << endl; 645 return(0); 646 } 647 if (tokens.size() < 6) tokens.push_back("1"); 648 while (tokens.size() < 8) tokens.push_back(""); 649 srvo->DisplayPoints3DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], 650 tokens[6], tokens[7]); 651 } 628 652 629 653 else if (kw == "projh1d" ) { … … 1086 1110 usage += " Related commands: vec2var ntline2var"; 1087 1111 mpiac->RegisterCommand(kw, usage, this, "Objects"); 1112 kw = "objaoper"; 1113 usage = "Perform an operation through the object adapter NObjMgrAdapter::PerformOperation()\n"; 1114 usage += " Usage: objaoper objname operation [arg1 ...] \n"; 1115 usage += " Examples of defined operations : \n"; 1116 usage += " Matrices: row indx_row , col indx_col \n"; 1117 usage += " Arrays: slicexy indx_Z , slicexz indx_Y, sliceyz indxX \n"; 1118 mpiac->RegisterCommand(kw, usage, this, "Objects"); 1088 1119 1089 1120 //------- Commandes trace de fonctions … … 1132 1163 usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)"; 1133 1164 usage += "\nThe default Cut() expression in true (=1) for all"; 1134 usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d";1135 usage += "\n projh1d projh2d projprof fillvec fillmtx ";1136 usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... ";1165 usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d plot3dw"; 1166 usage += "\n projh1d projh2d projprof fillvec fillmtx "; 1167 usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... "; 1137 1168 grp = "Expr. Plotting"; 1138 1169 mpiac->RegisterHelp(kw, usage, grp); … … 1140 1171 usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :"; 1141 1172 usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]"; 1142 usage += "\n Related commands: plot2de plot2dw plot3d ObjectExpressions ...";1173 usage += "\n Related commands: plot2de plot2dw plot3d plot3dw ObjectExpressions ..."; 1143 1174 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); 1144 1175 kw = "plot2de"; … … 1153 1184 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); 1154 1185 kw = "plot3d"; 1155 usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs";1186 usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object)"; 1156 1187 usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]"; 1157 usage += "\n Related commands: plot2d plot2dw plot2de plot3d ObjectExpressions ..."; 1188 usage += "\n Related commands: plot2d plot2de plot3dw ObjectExpressions ..."; 1189 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); 1190 kw = "plot3dw"; 1191 usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) with Weight W=k(Object) "; 1192 usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() k_Wt() [Cut() graphic_attributes loop_param]"; 1193 usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; 1158 1194 mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); 1159 1195 -
trunk/SophyaPI/PIext/nobjmgr.cc
r2975 r2999 564 564 565 565 myNObj++; 566 if ((nobj.length() < 1) || (! isalpha(nobj[0]) ) ) { 567 cout << "NamedObjMgr::AddObj() bad object name " << nobj ; 566 if ( !CheckName(nobj) ) { 568 567 sprintf(buff,"O%d", myNObj); 569 nobj = buff;570 cout << " changed to " << nobj << endl;571 568 cout << "NamedObjMgr::AddObj() Name changed: " << nom << " -> " << buff << endl; 569 nom = buff; 570 } 572 571 573 572 nom = '/' + nrep + '/' + nobj; … … 663 662 return(false); 664 663 } 665 if ((n2.length() < 1) || (! isalpha(n2[0])) ) { 664 665 if ( !CheckName(n2) ) { 666 666 cout << "NamedObjMgr::RenameObj() Error - bad new object name" << n2 << endl; 667 667 return(false); … … 671 671 cout << "NamedObjMgr::RenameObj() Error - Object " << nomnew << " exist !" << endl; 672 672 return(false); 673 674 673 } 674 675 675 if ( (*itr1).second.lock || (*itr2).second.lock ) { 676 676 cout << "NamedObjMgr::RenameObj() Error - Source or destination directory locked !" … … 1734 1734 } 1735 1735 1736 /* Nouvelle-Fonction */ 1737 bool NamedObjMgr::CheckName(string const & nom) 1738 { 1739 if (nom.length() < 1) return false; 1740 if (! isalpha(nom[0]) ) return false; 1741 for(int k=0; k<nom.length(); k++) 1742 if ((!isalnum(nom[k])) && (nom[k] != '_')) return false; 1743 return true; 1744 } -
trunk/SophyaPI/PIext/nobjmgr.h
r2975 r2999 109 109 static bool CheckDirName(string & nom); 110 110 static int ParseObjectName(string & nom, string & nomrep, string & nomobj); 111 // return true if name is valid 112 static bool CheckName(string const & nom); 111 113 112 114 protected: -
trunk/SophyaPI/PIext/nomgadapter.cc
r2975 r2999 57 57 { 58 58 char buff[128]; 59 sprintf( "%s@%lx", typeid(*mObj).name(), (long)mObj);59 sprintf(buff,"%s@%lx", typeid(*mObj).name(), (long)mObj); 60 60 return(buff); 61 61 } … … 70 70 71 71 /* --Methode-- */ 72 string NObjMgrAdapter::GetInfoString( int /*lev*/)72 string NObjMgrAdapter::GetInfoString(vector<string>& /*opts*/) 73 73 { 74 74 char buff[128]; 75 sprintf( "Type: %s @ %lx", typeid(*mObj).name(), (long)mObj);75 sprintf(buff, "Type: %s @ %lx", typeid(*mObj).name(), (long)mObj); 76 76 return(buff); 77 } 78 79 /* --Methode-- */ 80 int NObjMgrAdapter::PerformOperation(vector<string>& /*opts*/) 81 { 82 cout << "No operation defined for " << typeid(*mObj).name() << endl; 83 return 1; 77 84 } 78 85 -
trunk/SophyaPI/PIext/nomgadapter.h
r2975 r2999 43 43 virtual void FillFromString(); 44 44 45 // Returns a string with synthetic information about the object (lev-> Level of details) 46 virtual string GetInfoString(int lev=0); 45 // Returns a string with synthetic information about the object 46 // opts : additional optional argument 47 virtual string GetInfoString(vector<string>& opts); 48 // Perform an operation on the object definded 49 // opts : operation definition 50 virtual int PerformOperation(vector<string>& opts); 47 51 48 52 virtual void SavePPF(POutPersist& s, string const & nom); -
trunk/SophyaPI/PIext/nomtarradapter.cc
r2975 r2999 16 16 #include "fioarr.h" 17 17 18 #include "nobjmgr.h" 18 19 19 20 … … 65 66 } 66 67 68 /* --Methode-- */ 69 template <class T> 70 string NOMAdapter_TArray<T>::GetInfoString(vector<string>& opts) 71 { 72 if (opts.size() == 0) return mArr->InfoString(); 73 else { 74 char buff[128]; 75 if (opts[0] == "rank") { 76 sprintf(buff,"%d", (int)mArr->Rank()); 77 return string(buff); 78 } 79 if (opts[0] == "sizes") { 80 for(int_4 kd=0; kd<mArr->Rank(); kd++) 81 sprintf(buff,"%ld ", (long)mArr->Size(kd)); 82 return string(buff); 83 } 84 else if ((opts[0] == "size") || (opts[0] == "nelts")) { 85 sprintf(buff, "%ld", (long)mArr->Size()); 86 return string(buff); 87 } 88 else if (opts[0] == "sum") { 89 MuTyV mtv(mArr->Sum()); 90 string s; 91 return mtv.Convert(s); 92 } 93 else return mArr->InfoString(); 94 } 95 } 96 97 /* --Methode-- */ 98 template <class T> 99 int NOMAdapter_TArray<T>::PerformOperation(vector<string>& opts) 100 { 101 bool ok = false; 102 if ((mArr->Rank() >= 3) && (opts.size() >= 2)) { 103 int_4 ks = atoi(opts[1].c_str()); 104 TMatrix<T> * slice = new TMatrix<T>; 105 char buff[40]; 106 if (opts[0] == "slicexy") { 107 slice->Share(mArr->SubArray(Range::all(), Range::all(), Range(ks), 108 Range::first(), Range::first()) ); 109 ok = true; 110 sprintf(buff,"slicexy_%ld",(long)ks); 111 cout << "PerformOperation(): Extracting SliceXY(" << ks << ") from array" << endl; 112 } 113 else if (opts[0] == "sliceyz") { 114 slice->Share(mArr->SubArray(Range(ks), Range::all(), Range::all(), 115 Range::first(), Range::first()) ); 116 ok = true; 117 sprintf(buff,"sliceyz_%ld",(long)ks); 118 cout << "PerformOperation(): Extracting SliceYZ(" << ks << ") from array" << endl; 119 } 120 else if (opts[0] == "slicexz") { 121 slice->Share(mArr->SubArray(Range::all(), Range(ks), Range::all(), 122 Range::first(), Range::first()) ); 123 ok = true; 124 sprintf(buff,"slicexz_%ld",(long)ks); 125 cout << "PerformOperation(): Extracting SliceYZ(" << ks << ") from array" << endl; 126 } 127 if (ok) { 128 string nslice; 129 if (opts.size() > 2) nslice = opts[2]; 130 else nslice = buff; 131 NamedObjMgr omg; 132 omg.AddObj(slice, nslice, true); 133 return 0; 134 } 135 } 136 137 cout << "NOMAdapter_TArray<T>::PerformOperation(): Error operation/arguments !" << endl; 138 return 1; 139 } 67 140 68 141 /* --Methode-- */ -
trunk/SophyaPI/PIext/nomtarradapter.h
r2975 r2999 26 26 27 27 virtual AnyDataObj* CloneDataObj(bool share=false); 28 29 // Returns a string with synthetic information about the object 30 // opts : additional optional argument 31 virtual string GetInfoString(vector<string>& opts); 32 // Perform an operation on the object definded 33 // opts : operation definition 34 virtual int PerformOperation(vector<string>& opts); 28 35 29 36 virtual void SavePPF(POutPersist& s, string const & nom); -
trunk/SophyaPI/PIext/nomtmatvecadapter.cc
r2975 r2999 17 17 #include "fioarr.h" 18 18 19 #include "nobjmgr.h" 19 20 20 21 //---------------------------------------------------------------- … … 71 72 } 72 73 74 /* --Methode-- */ 75 template <class T> 76 string NOMAdapter_TMatrix<T>::GetInfoString(vector<string>& opts) 77 { 78 if (opts.size() == 0) return mMtx->InfoString(); 79 else { 80 if (opts[0] == "rank") return string("2"); 81 else if (opts[0] == "sizes") { 82 char buff[64]; 83 TVector<T>* v = dynamic_cast<TVector<T> *>(mMtx); 84 if (v != NULL) sprintf(buff, "%ld", (long)mMtx->Size()); 85 else sprintf(buff, "%ld %ld", (long)mMtx->NRows(), (long)mMtx->NCols()); 86 return string(buff); 87 } 88 else if ((opts[0] == "size") || (opts[0] == "nelts")) { 89 char buff[32]; 90 sprintf(buff, "%ld", (long)mMtx->Size()); 91 return string(buff); 92 } 93 else if (opts[0] == "sum") { 94 MuTyV mtv(mMtx->Sum()); 95 string s; 96 return mtv.Convert(s); 97 } 98 else return mMtx->InfoString(); 99 } 100 } 101 102 /* --Methode-- */ 103 template <class T> 104 int NOMAdapter_TMatrix<T>::PerformOperation(vector<string>& opts) 105 { 106 bool ok = false; 107 if (opts.size() >= 2) { 108 int_4 kk = atoi(opts[1].c_str()); 109 TVector<T> * vrc = new TVector<T>; 110 char buff[40]; 111 if ((opts[0] == "row") || (opts[0] == "line")) { 112 vrc->Share(mMtx->Row((sa_size_t)kk)); 113 ok = true; 114 sprintf(buff,"row_%ld",(long)kk); 115 cout << "PerformOperation(): Extracting Row(" << kk << ") from matrix" << endl; 116 } 117 else if ((opts[0] == "col") || (opts[0] == "column")) { 118 vrc->Share(mMtx->Column((sa_size_t)kk)); 119 ok = true; 120 sprintf(buff,"col_%ld",(long)kk); 121 cout << "PerformOperation(): Extracting Column(" << kk << ") from matrix" << endl; 122 } 123 if (ok) { 124 string nvrc; 125 if (opts.size() > 2) nvrc = opts[2]; 126 else nvrc = buff; 127 NamedObjMgr omg; 128 omg.AddObj(vrc, nvrc, true); 129 return 0; 130 } 131 } 132 133 cout << "NOMAdapter_TMatrix<T>::PerformOperation(): Error operation/arguments !" << endl; 134 return 1; 135 } 73 136 74 137 /* --Methode-- */ -
trunk/SophyaPI/PIext/nomtmatvecadapter.h
r2975 r2999 27 27 28 28 virtual AnyDataObj* CloneDataObj(bool share=false); 29 30 // Returns a string with synthetic information about the object 31 // opts : additional optional argument 32 virtual string GetInfoString(vector<string>& opts); 33 // Perform an operation on the object definded 34 // opts : operation definition 35 virtual int PerformOperation(vector<string>& opts); 29 36 30 37 virtual void SavePPF(POutPersist& s, string const & nom); -
trunk/SophyaPI/PIext/piacmd.cc
r2812 r2999 322 322 } 323 323 324 /* --Methode-- */ 325 bool PIACmd::GetVarApp(string const & vn, string & vv) 326 { 327 vv = ""; 328 if (mObjMgr == NULL) return false; 329 vector<string> opts; 330 SplitStringToVString(vn, opts, '.'); 331 string nom = opts[0]; 332 opts.erase(opts.begin()); 333 NObjMgrAdapter* obja = mObjMgr->GetObjAdapter(nom); 334 if (obja == NULL) return false; 335 vv = obja->GetInfoString(opts); 336 return true; 337 } 324 338 325 339 /* --Methode-- */ -
trunk/SophyaPI/PIext/piacmd.h
r2781 r2999 59 59 virtual void UpdateHelpList(PIAHelpWind* hw, int gid); 60 60 61 // Acces aux objets transforme en string 62 virtual bool GetVarApp(string const & vn, string & vv); 63 61 64 protected: 62 65 virtual int ExecuteCommandLine(string & kw, vector<string> & tokens, -
trunk/SophyaPI/PIext/servnobjm.cc
r2924 r2999 509 509 510 510 /* --Methode-- */ 511 void Services2NObjMgr::DisplayPoints3DW(string& nom, string& expx, string& expy, string& expz, 512 string& expwt, string& expcut, string dopt, string loop) 513 { 514 NObjMgrAdapter* obja=NULL; 515 obja = MyObjMgr()->GetObjAdapter(nom); 516 if (obja == NULL) { 517 cout << "Services2NObjMgr::DisplayPoints3D() Error , No such object " << nom << endl; 518 return; 519 } 520 if (!mImgapp) return; 521 522 char* ntn[4] = {"expx","expy","expz","expw"}; 523 NTuple* nt = new NTuple(4,ntn); // Creation NTuple 524 525 ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL); 526 527 if (nt->NEntry() < 1) { 528 cout << "Services2NObjMgr::DisplayPoints3DW() Warning Zero points satisfy cut !" << endl; 529 delete nt; 530 return; 531 } 532 //DBG nt->Show(); 533 //DBG nt->Print(0,10); 534 PINTuple3D* pin = new PINTuple3D(nt, true); 535 pin->SelectXYZ(ntn[0], ntn[1], ntn[2]); 536 pin->SelectWt(ntn[3]); 537 pin->UseColorScale(true); 538 dopt = "defline " + dopt; 539 540 // Pour plot a partir de DispScDrawer 541 // string nomdisp = "_NT3D_"; 542 // mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt); 543 // Pour plot a partir de Disp3DDrawer 544 string titre = nom + ":" + expy + "%" + expx + " W=" + expwt; 545 mImgapp->Disp3DDrawer(pin, titre, dopt); 546 547 return; 548 } 549 550 /* --Methode-- */ 511 551 void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt, 512 552 string& expcut, string& nomh1, string dopt, string loop) -
trunk/SophyaPI/PIext/servnobjm.h
r2755 r2999 80 80 virtual void DisplayPoints2DW(string & nom, string& expx, string& expy, 81 81 string& expwt, string& expcut, string dopt="", string loop=""); 82 virtual void DisplayPoints3DW(string & nom, string& expx, string& expy, string& expz, 83 string& expwt, string& expcut, string dopt="", string loop=""); 84 82 85 // Projection d'expressions dans histogramme, vecteur/matrices (et trace) 83 86 virtual void ProjectH1(string & nom, string& expx, string& expwt, string& expcut,
Note:
See TracChangeset
for help on using the changeset viewer.