| [2615] | 1 | #include "sopnamsp.h"
 | 
|---|
| [1828] | 2 | #include "contmodex.h"
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | #include "pigncont.h"
 | 
|---|
 | 5 | #include <typeinfo>
 | 
|---|
 | 6 | 
 | 
|---|
 | 7 | #include <vector>
 | 
|---|
 | 8 | #include <string>
 | 
|---|
 | 9 | #include "nobjmgr.h"
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | #include "pidrawer.h"
 | 
|---|
 | 12 | #include "nomgadapter.h"
 | 
|---|
 | 13 | #include "servnobjm.h"
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | /* --Methode-- */
 | 
|---|
 | 17 | ContModExecutor::ContModExecutor(PIACmd* mpiac, PIStdImgApp* app)
 | 
|---|
 | 18 | {
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 |   //PIACmd * mpiac;
 | 
|---|
 | 21 |   //NamedObjMgr omg;
 | 
|---|
 | 22 |   //mpiac = omg.GetImgApp()->CmdInterpreter();
 | 
|---|
 | 23 | 
 | 
|---|
 | 24 |   //cout << " ContModExecutor::ContModExecutor() mpiac = " << (unsigned long)mpiac << endl;
 | 
|---|
 | 25 |   cout << " registration of contour commands "<<endl;
 | 
|---|
 | 26 |   string hgrp,kw,usage;
 | 
|---|
 | 27 |   
 | 
|---|
| [1920] | 28 |   hgrp = "Obj. Display";
 | 
|---|
 | 29 |   
 | 
|---|
| [1828] | 30 |   kw = "contour";
 | 
|---|
 | 31 |   usage = "Creates and displays a ContourDrawer ";
 | 
|---|
| [2251] | 32 |   usage += "\n Usage: contour objectName [graphic_att/specific_opt] ";
 | 
|---|
 | 33 |   usage += "\n Specific Options ";
 | 
|---|
 | 34 |   usage += "\n    ncont=[number of contours (automatic levels) ] ";
 | 
|---|
 | 35 |   usage += "\n    niv/lev=[values for contours, separated by ','] ";
 | 
|---|
 | 36 |   usage += "\n    lstep=[nomber,first_value,increment for contours ] ";
 | 
|---|
 | 37 |   usage += "\n    bspline : use bspline algo for contour " ;
 | 
|---|
 | 38 |   usage += "\n    3spl : use cubic spline algo for contour " ;
 | 
|---|
 | 39 |   usage += "\n    labon : put labels for contours " ;
 | 
|---|
 | 40 | 
 | 
|---|
| [1828] | 41 |   mpiac->RegisterCommand(kw, usage, this, hgrp);
 | 
|---|
 | 42 |   
 | 
|---|
| [1920] | 43 |   hgrp = "Obj. Display";
 | 
|---|
| [1828] | 44 |   kw = "ntcont";
 | 
|---|
 | 45 |   usage = "Creates and displays a ContourDrawer (from a NTuple)";
 | 
|---|
| [2251] | 46 |   usage += "\n Usage: ntcont NTupleName varx vary varz [graphic_att/specific_opt] ";
 | 
|---|
 | 47 |   usage += "\n        specific options ";
 | 
|---|
 | 48 |   usage += "\n    ncont=[number of contours (automatic levels) ] ";
 | 
|---|
 | 49 |   usage += "\n    niv/lev=[values for contours, separated by ','] ";
 | 
|---|
 | 50 |   usage += "\n    lstep=[nomber,first_value,increment for contours ] ";
 | 
|---|
 | 51 |   usage += "\n    bspline : use bspline algo for contour " ;
 | 
|---|
 | 52 |   usage += "\n    3spl : use cubic spline algo for contour " ;
 | 
|---|
 | 53 |   usage += "\n    labon : put labels for contours " ;
 | 
|---|
| [1828] | 54 |   mpiac->RegisterCommand(kw, usage, this, hgrp);
 | 
|---|
 | 55 | 
 | 
|---|
 | 56 |   //cout << " Out of ContModExecutor::ContModExecutor() " << endl;
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 | }
 | 
|---|
 | 59 |  
 | 
|---|
 | 60 | 
 | 
|---|
 | 61 | 
 | 
|---|
 | 62 | /* --Methode-- */
 | 
|---|
 | 63 | ContModExecutor::~ContModExecutor()
 | 
|---|
 | 64 | {
 | 
|---|
 | 65 | }
 | 
|---|
 | 66 | 
 | 
|---|
 | 67 | /* --Methode-- */
 | 
|---|
 | 68 | int ContModExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
 | 
|---|
 | 69 | {
 | 
|---|
 | 70 |   
 | 
|---|
 | 71 | int nz=-1;
 | 
|---|
 | 72 | double z0,dz;
 | 
|---|
 | 73 |   
 | 
|---|
 | 74 | if ( kw == "contour") {
 | 
|---|
 | 75 |    NamedObjMgr omg;
 | 
|---|
 | 76 |    PIContourDrawer * contdrw = NULL;
 | 
|---|
 | 77 |    string dopt="";
 | 
|---|
 | 78 |  
 | 
|---|
 | 79 |    if (tokens.size() < 1) {
 | 
|---|
| [2251] | 80 |      cout << "Usage: contour ObjName [graphic_att/specficic_opt: SEE HELP] " << endl;
 | 
|---|
| [1828] | 81 |      return(0);
 | 
|---|
 | 82 |    }
 | 
|---|
 | 83 | 
 | 
|---|
 | 84 |    //   dopt = "same,thinline";  Si tu veux des valeurs par defaut
 | 
|---|
 | 85 |    //if (tokens.size() > 1)  dopt = tokens[1];
 | 
|---|
 | 86 |    //omg.PrintObj(tokens[0]);
 | 
|---|
 | 87 |    NObjMgrAdapter* obja = omg.GetObjAdapter(tokens[0]);
 | 
|---|
 | 88 |    if (obja == NULL) {
 | 
|---|
 | 89 |      cout << "contour Error , No object with name " << tokens[0] << endl; 
 | 
|---|
 | 90 |      return(0);
 | 
|---|
 | 91 |    }
 | 
|---|
 | 92 |    string ctyp = typeid(*obja).name();
 | 
|---|
 | 93 |    cout << " objet de type "<<ctyp <<endl;
 | 
|---|
 | 94 |    AnyDataObj* ob = obja->GetDataObj();
 | 
|---|
 | 95 |    if (ob == NULL) {
 | 
|---|
 | 96 |      cerr << "Error - NULL object ! in " <<  tokens[0] << endl;
 | 
|---|
 | 97 |      return(0);
 | 
|---|
 | 98 |    }
 | 
|---|
 | 99 |    ctyp = typeid(*ob).name();
 | 
|---|
 | 100 |    cout << " objet de type "<<ctyp <<endl;
 | 
|---|
 | 101 |    cout << " ContModExecutor::Execute recuperation du p2darrayadapter "<<endl;
 | 
|---|
 | 102 |    if (tokens.size() > 1) dopt = tokens[1];
 | 
|---|
 | 103 |    P2DArrayAdapter* arr = obja->Get2DArray(dopt);
 | 
|---|
 | 104 |    if (arr != NULL) {
 | 
|---|
 | 105 |        contdrw = new PIContourDrawer(arr,true           );
 | 
|---|
 | 106 |    }else{
 | 
|---|
 | 107 |      cout <<"contour ERREUR : OBJET "<<tokens[0]<<" N'A PAS DE P2DARRADAPTOR "<<endl;
 | 
|---|
 | 108 |      return(0);
 | 
|---|
 | 109 |    }
 | 
|---|
 | 110 | 
 | 
|---|
 | 111 |    
 | 
|---|
 | 112 |    cout << " contour: Creating PIContourDrawer() for object" << tokens[0] << endl;
 | 
|---|
 | 113 |    
 | 
|---|
 | 114 |    cout << " contour: Determination of contour lines ..."<< contdrw <<endl;
 | 
|---|
 | 115 |    contdrw->CalcContour();
 | 
|---|
 | 116 |    //NTuple *out = contdrw->MyIso();
 | 
|---|
 | 117 |    //NTuple *truc = new NTuple(*out);
 | 
|---|
 | 118 |    //string nom = "isoc";
 | 
|---|
 | 119 |    //if(out!=NULL) omg.AddObj(truc,nom   );
 | 
|---|
 | 120 |    cout << " ===>>> success ! "<< contdrw <<endl;
 | 
|---|
 | 121 | 
 | 
|---|
 | 122 |    // On affiche le Drawer
 | 
|---|
 | 123 |    int wrsid = 0;
 | 
|---|
 | 124 |    
 | 
|---|
 | 125 |    string name = "contour";
 | 
|---|
| [1971] | 126 |    cout << " ContModExecutor::Execute() : name "<<name<<" " <<"| dopt |"<<dopt<<"| contdrw |"<<contdrw<<endl;
 | 
|---|
 | 127 |    wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, dopt); 
 | 
|---|
| [1828] | 128 |    cout << " fin de ContModExecutor::Execute() "<< endl;
 | 
|---|
 | 129 |    
 | 
|---|
 | 130 | 
 | 
|---|
 | 131 |    // Ne pas oublier d'associer le wrsid a l'objet si on utilise le P2DArrayAdapter* arr
 | 
|---|
| [1971] | 132 |    omg.AddWRsId(tokens[0], wrsid);
 | 
|---|
 | 133 |    
 | 
|---|
| [1828] | 134 | 
 | 
|---|
 | 135 |    }
 | 
|---|
 | 136 | if ( kw == "ntcont"){  
 | 
|---|
 | 137 |      NamedObjMgr omg;
 | 
|---|
 | 138 |      PIContourDrawer * contdrw = NULL;
 | 
|---|
 | 139 |      string dopt="";
 | 
|---|
 | 140 |      bool adel;
 | 
|---|
 | 141 |      //cout << " essai avec ntuple "<<tokens.size()<<endl;
 | 
|---|
 | 142 |      if (tokens.size() < 4) {
 | 
|---|
| [2251] | 143 |        cout << "Usage: contour NtName varx vary varz [graphic_att/specific_opt: SEE HELP]"
 | 
|---|
| [1828] | 144 |             << endl;
 | 
|---|
 | 145 |        return(0);
 | 
|---|
 | 146 |      }
 | 
|---|
 | 147 |      dopt="";
 | 
|---|
 | 148 |      NObjMgrAdapter* obja = omg.GetObjAdapter(tokens[0]);
 | 
|---|
 | 149 |      if (obja == NULL) {
 | 
|---|
 | 150 |        cout << "ntcont Error , No NTuple with name " << tokens[0] << endl; 
 | 
|---|
 | 151 |        return(0);
 | 
|---|
 | 152 |      }
 | 
|---|
 | 153 |     
 | 
|---|
 | 154 |      NTupleInterface *ntin = obja->GetNTupleInterface(adel);
 | 
|---|
 | 155 |      //cout << " tokens.size() "<< tokens.size()<<endl;
 | 
|---|
 | 156 |      //for (int k=0; k<tokens.size() ; k++)cout<<"| k "<<k<<" tok |"<<tokens[k];
 | 
|---|
 | 157 |      //cout <<endl;
 | 
|---|
 | 158 |      if (tokens.size() > 4) dopt = tokens[4];
 | 
|---|
 | 159 |      if (tokens.size() > 6){
 | 
|---|
 | 160 |          dz = atof(tokens[6].c_str());
 | 
|---|
 | 161 |          z0 = atof(tokens[7].c_str());
 | 
|---|
 | 162 |          cout << " ContModExecutor::Execute [NT] nz,z,dz : "<<nz<<" , "<<z0 << " , " << dz<<endl;
 | 
|---|
 | 163 |          contdrw = new PIContourDrawer(ntin,adel,&nz,&z0,&dz);
 | 
|---|
 | 164 |      }
 | 
|---|
 | 165 |      if (tokens.size() > 5){
 | 
|---|
 | 166 |          nz = atoi(tokens[5].c_str()); 
 | 
|---|
 | 167 |          cout << " ContModExecutor::Execute [NT] nz : "<<nz<< endl;
 | 
|---|
 | 168 |          contdrw = new PIContourDrawer(ntin,adel,&nz           );
 | 
|---|
 | 169 |      }else {
 | 
|---|
 | 170 |        contdrw = new PIContourDrawer(ntin,adel           );
 | 
|---|
 | 171 |      }
 | 
|---|
 | 172 |      cout << " ntcont: Creating PIContourDrawer() for object " << tokens[0] << endl;
 | 
|---|
 | 173 |    
 | 
|---|
 | 174 |      cout << " ntcont : Determination of contour lines ..." <<endl;
 | 
|---|
 | 175 |      contdrw->CalcContour();
 | 
|---|
 | 176 |     
 | 
|---|
 | 177 |      NTuple *out = contdrw->MyIso();
 | 
|---|
 | 178 |      if(out!=NULL){
 | 
|---|
 | 179 |         NTuple *truc = new NTuple(*out);
 | 
|---|
 | 180 |         string nom = "isoc";
 | 
|---|
 | 181 |         //truc->Write("isocur.ppf");
 | 
|---|
 | 182 |         //out->Write("outcur.ppf");
 | 
|---|
 | 183 |         omg.AddObj(truc,nom   );
 | 
|---|
 | 184 |      }
 | 
|---|
 | 185 |      /****************/
 | 
|---|
 | 186 |      cout << " ===>>> success ! "<<endl;
 | 
|---|
 | 187 | 
 | 
|---|
 | 188 |    // On affiche le Drawer
 | 
|---|
 | 189 |      int wrsid = 0;
 | 
|---|
 | 190 |      bool fgsr = true;
 | 
|---|
 | 191 |      
 | 
|---|
 | 192 |      string name = "contour";
 | 
|---|
 | 193 |      
 | 
|---|
| [1971] | 194 |      wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, dopt); 
 | 
|---|
| [1828] | 195 |      
 | 
|---|
| [1971] | 196 |      // Ne pas oublier d'associer le wrsid a l'objet si on utilise le P2DArrayAdapter* arr
 | 
|---|
 | 197 |      omg.AddWRsId(tokens[0], wrsid);
 | 
|---|
| [1828] | 198 | 
 | 
|---|
 | 199 |    }
 | 
|---|
 | 200 |    
 | 
|---|
 | 201 | 
 | 
|---|
 | 202 | 
 | 
|---|
 | 203 | return(0);
 | 
|---|
 | 204 | 
 | 
|---|
 | 205 | }
 | 
|---|
 | 206 | 
 | 
|---|
 | 207 | 
 | 
|---|
 | 208 | 
 | 
|---|