source: Sophya/trunk/SophyaPI/PIext/pisiadw.cc@ 332

Last change on this file since 332 was 332, checked in by ercodmgr, 26 years ago

Probleme avec les const ... Reza 29/6/99

File size: 6.1 KB
Line 
1#include "machdefs.h"
2#include <stdlib.h>
3#include <stdio.h>
4#include <string.h>
5
6#include <typeinfo>
7
8#include "perrors.h"
9#include "ctimer.h"
10
11#include "nbmath.h"
12
13#include "pistdimgapp.h"
14#include "nobjmgr.h"
15#include "servnobjm.h"
16
17
18
19/* ........................................................... */
20/* Classe ObjMgrWind interface de gestion d'objets nommes */
21/* ........................................................... */
22
23/* --Methode-- */
24ObjMgrWind::ObjMgrWind(PIStdImgApp *par)
25: PIWindow((PIMsgHandler *)par, "objmgr", PIWK_dialog,
26 400, 300, 250, 250)
27{
28int i;
29dap = par;
30
31int bsx, bsy;
32int tsx, tsy;
33int spx, spy;
34// On definit la taille a partir de la taille par defaut des composantes
35PIApplicationPrefCompSize(bsx, bsy);
36spx = bsx/4; spy = bsy/3;
37tsx = 5*bsx+6*spx; tsy = 7*bsy+4*spy;
38SetSize(tsx,tsy);
39objlist = new PIList(this, "objlist", tsx-spx, tsy-4*spy-bsy, spx/2, spy/2);
40objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
41objlist->SetBorderWidth(2);
42
43int py = tsy-2*spy-bsy;
44int px = spx;
45mBut[0] = new PIButton(this, "Display", 100, bsx, bsy, px, py); px += (bsx+spx);
46mBut[1] = new PIButton(this, "Print", 200, bsx, bsy, px, py); px += (bsx+spx);
47mBut[2] = new PIButton(this, "SavePPF", 300, bsx, bsy, px, py); px += (bsx+spx);
48mBut[3] = new PIButton(this, "Delete", 400, bsx, bsy, px, py); px += (bsx+spx);
49mBut[4] = new PIButton(this, "Dismiss", 900, bsx, bsy, px, py); px += (bsx+spx);
50
51for(i=0; i<5; i++)
52 mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
53
54// FinishCreate(); pas necessaire ?
55}
56
57/* --Methode-- */
58ObjMgrWind::~ObjMgrWind()
59{
60int i;
61delete objlist;
62for(i=0; i<5; i++) delete mBut[i];
63}
64
65/* --Methode-- */
66void ObjMgrWind::Show()
67{
68dap->SetBlocked();
69PIWindow::Show();
70return;
71}
72
73/* --Methode-- */
74void ObjMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
75{
76
77 // PIMessage ssg = ModMsg(msg);
78msg = UserMsg(msg);
79if (msg == 900) {
80 dap->SetReady();
81 this->Hide();
82 return;
83}
84
85string nom = "";
86if ( (msg == 100) || (msg == 200) || (msg == 300) || (msg == 400) ) {
87 string sel = objlist->GetSelectionStr();
88 // size_t p = sel.find_first_not_of(" \t");
89 // if (p<0) p = 0;
90 size_t l = sel.length();
91 size_t q = sel.find_first_of(" \t");
92 if (q > l) q = l;
93 nom = sel.substr(0, q);
94}
95
96NamedObjMgr* om = dap->ObjMgr();
97if (om == NULL) return;
98if (nom == "") return;
99
100switch (msg)
101 {
102 case 100:
103 om->DisplayObj(nom);
104 break;
105 case 200:
106 om->PrintObj(nom);
107 break;
108 case 300:
109 if (dap->mPpfout) om->SaveObj(nom, *(dap->mPpfout));
110 break;
111 case 400:
112 om->DelObj(nom);
113 break;
114
115 case 900:
116 dap->SetReady();
117 Hide();
118 break;
119
120 default:
121 // printf("DEBUG/ObjMgrW::Process %d %d \n", (int)msg, (int)ssg);
122 break;
123 }
124
125return;
126}
127
128
129/* ........................................................... */
130/* Classe PPInMgrWind interface de gestion d'objets nommes */
131/* ........................................................... */
132
133/* --Methode-- */
134PPInMgrWind::PPInMgrWind(PIStdImgApp *par)
135: PIWindow((PIMsgHandler *)par, "PPF-FileManager", PIWK_dialog,
136 400, 300, 250, 250)
137{
138int i;
139dap = par;
140
141int bsx, bsy;
142int tsx, tsy;
143int spx, spy;
144// On definit la taille a partir de la taille par defaut des composantes
145PIApplicationPrefCompSize(bsx, bsy);
146spx = bsx/4; spy = bsy/3;
147bsx *= 1.25;
148ttx = tsx = 3*bsx+8*spx; tty = tsy = 7*bsy+5*spy;
149SetSize(tsx,tsy);
150
151mLab[0] = new PILabel(this, "filename", tsx-spx, bsy-spy, spx/2, spy/2);
152mLab[0]->SetLabel("");
153mLab[0]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic,PIBK_elastic);
154mLab[0]->SetBorderWidth(1);
155
156polx = spx/2; poly = bsy+1.5*spy;
157tolx = tsx-spx; toly = tsy-2*bsy-5*spy;
158int py = tsy-2*spy-bsy;
159int px = 2*spx;
160mBut[0] = new PIButton(this, "Read", 2500, bsx, bsy, px, py); px += (bsx+2*spx);
161mBut[1] = new PIButton(this, "ReadAll", 2600, bsx, bsy, px, py); px += (bsx+2*spx);
162mBut[2] = new PIButton(this, "Close", 2700, bsx, bsy, px, py); px += (bsx+2*spx);
163
164for(i=0; i<3; i++)
165 mBut[i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
166
167objlist = NULL;
168mLab[1] = NULL;
169mPin = NULL;
170
171// FinishCreate(); pas necessaire
172}
173
174/* --Methode-- */
175PPInMgrWind::~PPInMgrWind()
176{
177int i;
178if (objlist) delete objlist;
179delete mLab[0];
180for(i=0; i<3; i++) delete mBut[i];
181}
182
183/* --Methode-- */
184void PPInMgrWind::SetFile(string flnm)
185{
186char strg[128];
187char* nom;
188char noms[32];
189int i, cid, key, ln;
190
191bool ok = true;
192
193TRY {
194 mPin = new PInPersist(flnm);
195} CATCH(merr)
196 { printf("ObjMgrWind::SetFile Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
197 ok = false; } ENDTRY;
198
199if (!ok) { mPin = NULL; dap->SetReady(); return; }
200
201if (mPin->NbTags() < 1) {
202 delete mPin; mPin = NULL;
203 string no="";
204 dap->ObjMgr()->ReadObj(flnm,no);
205 return;
206}
207
208if (objlist) delete objlist;
209SetSize(ttx,tty);
210mLab[0]->SetLabel(flnm);
211objlist = new PIList(this, "infileobjlist", tolx, toly, polx, poly);
212objlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
213objlist->SetBorderWidth(2);
214
215
216for(i=0; i<mPin->NbTags(); i++) {
217 key = mPin->TagKey(i, cid, ln);
218 if (ln <= 0) nom = "?";
219 else { strncpy(noms, mPin->TagName(i).c_str(), 31); noms[31] = '\0'; nom = noms; }
220// sprintf(strg, "%s (T=%s, Key=%d)", nom, dap->ObjMgr()->GetServiceObj()->PClassIdToClassName(cid), key);
221 sprintf(strg, "%s (T=%s, Key=%d)", nom, " DataObject ?", key);
222 objlist->AppendItem(strg, 5000+i);
223}
224
225}
226
227/* --Methode-- */
228void PPInMgrWind::Show()
229{
230if (mPin == NULL) return;
231dap->SetBlocked();
232PIWindow::Show();
233return;
234}
235
236/* --Methode-- */
237void PPInMgrWind::Process(PIMessage msg, PIMsgHandler* /*sender*/, void* /*data*/)
238{
239
240int sel;
241msg = UserMsg(msg);
242
243if (msg == 2700) {
244 delete mPin; mPin = NULL;
245 delete objlist; objlist = NULL;
246 dap->SetReady();
247 this->Hide();
248 return;
249}
250
251NamedObjMgr* om = dap->ObjMgr();
252switch (msg)
253 {
254 case 2500:
255 sel = (PIMessage)objlist->GetSelection() - 5000;
256 if (sel >= 0) om->ReadObj((*mPin), sel);
257 break;
258 case 2600:
259 om->ReadObj((*mPin), -1);
260 dap->SetReady();
261 this->Hide();
262 break;
263
264 default:
265 break;
266 }
267
268return;
269}
Note: See TracBrowser for help on using the repository browser.