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

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

1) ajout de commande pour trace de champ de vecteur
2) modif pour compil sous peida (pawexecut.cc) OP 06/03/2002

File size: 5.6 KB
Line 
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
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-- */
47ContModExecutor::~ContModExecutor()
48{
49}
50
51/* --Methode-- */
52int ContModExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
53{
54
55int nz=-1;
56double z0,dz;
57
58if ( 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 bool fgsr = true;
109 cout << " dopt " << dopt<<endl;
110 int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
111
112 string name = "contour";
113 cout << " ContModExecutor::Execute() : name "<<name<<" " <<" opt |"<<opt<<"| dopt |"<<dopt<<"| contdrw |"<<contdrw<<endl;
114 wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, opt);
115 cout << " fin de ContModExecutor::Execute() "<< endl;
116
117
118 if (fgsr) omg.GetImgApp()->RestoreGraphicAtt();
119 // Ne pas oublier d'associer le wrsid a l'objet si on utilise le P2DArrayAdapter* arr
120 // Il semble que cela ne soit pas accessible pour le moment depuis l'exterieur ds NamedObjMgr
121
122
123
124
125 }
126if ( kw == "ntcont"){
127 NamedObjMgr omg;
128 PIContourDrawer * contdrw = NULL;
129 string dopt="";
130 bool adel;
131 //cout << " essai avec ntuple "<<tokens.size()<<endl;
132 if (tokens.size() < 4) {
133 cout << "Usage: contour NtName varx vary varz [graphic_att]"
134 << endl;
135 return(0);
136 }
137 dopt="";
138 NObjMgrAdapter* obja = omg.GetObjAdapter(tokens[0]);
139 if (obja == NULL) {
140 cout << "ntcont Error , No NTuple with name " << tokens[0] << endl;
141 return(0);
142 }
143
144 NTupleInterface *ntin = obja->GetNTupleInterface(adel);
145 //cout << " tokens.size() "<< tokens.size()<<endl;
146 //for (int k=0; k<tokens.size() ; k++)cout<<"| k "<<k<<" tok |"<<tokens[k];
147 //cout <<endl;
148 if (tokens.size() > 4) dopt = tokens[4];
149 if (tokens.size() > 6){
150 dz = atof(tokens[6].c_str());
151 z0 = atof(tokens[7].c_str());
152 cout << " ContModExecutor::Execute [NT] nz,z,dz : "<<nz<<" , "<<z0 << " , " << dz<<endl;
153 contdrw = new PIContourDrawer(ntin,adel,&nz,&z0,&dz);
154 }
155 if (tokens.size() > 5){
156 nz = atoi(tokens[5].c_str());
157 cout << " ContModExecutor::Execute [NT] nz : "<<nz<< endl;
158 contdrw = new PIContourDrawer(ntin,adel,&nz );
159 }else {
160 contdrw = new PIContourDrawer(ntin,adel );
161 }
162 cout << " ntcont: Creating PIContourDrawer() for object " << tokens[0] << endl;
163
164 cout << " ntcont : Determination of contour lines ..." <<endl;
165 contdrw->CalcContour();
166
167 NTuple *out = contdrw->MyIso();
168 if(out!=NULL){
169 NTuple *truc = new NTuple(*out);
170 string nom = "isoc";
171 //truc->Write("isocur.ppf");
172 //out->Write("outcur.ppf");
173 omg.AddObj(truc,nom );
174 }
175 /****************/
176 cout << " ===>>> success ! "<<endl;
177
178 // On affiche le Drawer
179 int wrsid = 0;
180 bool fgsr = true;
181
182 int opt = omg.GetServiceObj()->DecodeDispOption(dopt, fgsr);
183
184 string name = "contour";
185
186 wrsid = omg.GetImgApp()->DispScDrawer(contdrw, name, opt);
187
188
189
190 if (fgsr) omg.GetImgApp()->RestoreGraphicAtt();
191
192 }
193
194
195
196return(0);
197
198}
199
200
201
Note: See TracBrowser for help on using the repository browser.