source: Sophya/trunk/SophyaPI/PIext/contmodex.cc@ 1828

Last change on this file since 1828 was 1828, checked in by perderos, 24 years ago

Ajout du command executor pour trace de contour - Olivier 19/12/2001

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