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