1 | #include <stdlib.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <string.h>
|
---|
4 | #include <math.h>
|
---|
5 |
|
---|
6 | #include <iostream.h>
|
---|
7 |
|
---|
8 | #include "pisysdep.h"
|
---|
9 |
|
---|
10 | #include PIAPP_H
|
---|
11 | #include PIMENU_H
|
---|
12 | #include PISTDWDG_H
|
---|
13 | #include PIWIN_H
|
---|
14 | #include PIPERIODIC_H
|
---|
15 |
|
---|
16 | #include "pidrawwin.h"
|
---|
17 | #include "piscdrawwdg.h"
|
---|
18 | #include "piimage.h"
|
---|
19 | #include "parradapter.h"
|
---|
20 |
|
---|
21 | #include "psfile.h"
|
---|
22 |
|
---|
23 | #include "piimgtools.h"
|
---|
24 | #include "pidrwtools.h"
|
---|
25 |
|
---|
26 | #include "pisurfdr.h"
|
---|
27 | #include "pi3dwdg.h"
|
---|
28 | #include "piyfxdrw.h"
|
---|
29 |
|
---|
30 | // ---------- classe PITApp -----------------------
|
---|
31 | class PITApp : public PIApplication {
|
---|
32 | public:
|
---|
33 | PITApp(int narg=0, char* arg[]=NULL);
|
---|
34 | ~PITApp();
|
---|
35 | virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
36 |
|
---|
37 | PIMenu* m[3];
|
---|
38 | PIText* txt;
|
---|
39 | PIPixmap* zoom;
|
---|
40 | PICMapView* cmapv;
|
---|
41 | PIWindow *mCurW;
|
---|
42 | PIColorMap midas_cmap;
|
---|
43 | };
|
---|
44 |
|
---|
45 | /* Tableau pour lire les composantes RGB de MIDAS_ITT */
|
---|
46 | static double rgb_r[512];
|
---|
47 | static double rgb_g[512];
|
---|
48 | static double rgb_b[512];
|
---|
49 | static int rgb_ncol = 0;
|
---|
50 |
|
---|
51 | /* --Methode-- */
|
---|
52 | PITApp::PITApp(int narg, char* arg[])
|
---|
53 | : PIApplication(360, 130, narg, arg) , midas_cmap("MIDAS_ColMap", rgb_ncol)
|
---|
54 | {
|
---|
55 |
|
---|
56 | m[0] = new PIMenu(Menubar(),"Fichier");
|
---|
57 | m[0]->AppendItem("Info", 10101);
|
---|
58 | m[0]->AppendItem("Close", 10110);
|
---|
59 | m[0]->AppendItem("Exit", 10150);
|
---|
60 | // On accroche le menu au Menubar
|
---|
61 | AppendMenu(m[0]);
|
---|
62 |
|
---|
63 | // 2eme Menu
|
---|
64 |
|
---|
65 | m[1] = new PIMenu(Menubar(),"Graphics");
|
---|
66 | m[1]->AppendItem("Sin(x)/x", 10201);
|
---|
67 | m[1]->AppendItem("YfXDrawer", 10202);
|
---|
68 | m[1]->AppendItem("2-Drawers", 10203);
|
---|
69 | m[1]->AppendItem("Surf-3D", 10204);
|
---|
70 | m[1]->AppendItem("Surf-3D-Color", 10205);
|
---|
71 | m[1]->AppendItem("Image", 10206);
|
---|
72 | m[1]->AppendItem("Image Gauss", 10207);
|
---|
73 |
|
---|
74 | AppendMenu(m[1]);
|
---|
75 |
|
---|
76 |
|
---|
77 | m[2] = new PIMenu(Menubar(),"Tools");
|
---|
78 | m[2]->AppendItem("ShowImageTools", 10301);
|
---|
79 | m[2]->AppendItem("ShowDrawerTools", 10302);
|
---|
80 | m[2]->AppendItem("PostScript (EPS)", 10305);
|
---|
81 | AppendMenu(m[2]);
|
---|
82 |
|
---|
83 | MainWin()->SetSize(360,130);
|
---|
84 | zoom = new PIPixmap(MainWin(), "Zoom", 90, 90, 5, 5);
|
---|
85 | zoom->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
86 | // zoom->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_elastic,PIBK_fixed);
|
---|
87 | cmapv = new PICMapView(MainWin(), "CMapView", 350, 25, 5, 100);
|
---|
88 | cmapv->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
89 | // cmapv->SetBinding(PIBK_fixed,PIBK_free,PIBK_fixed,PIBK_free);
|
---|
90 | // Creation d' zone texte multiligne
|
---|
91 | txt = new PIText(MainWin(), "mltext", 250, 90, 105, 5);
|
---|
92 | txt->SetBinding(PIBK_elastic,PIBK_elastic,PIBK_elastic,PIBK_elastic);
|
---|
93 | // txt->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed,PIBK_free);
|
---|
94 | txt->SetMutiLineMode(true);
|
---|
95 | txt->SetTextEditable(false);
|
---|
96 | txt->SetText("");
|
---|
97 |
|
---|
98 | // On alloue les couleurs de la MIDAS_ITT
|
---|
99 | cout << " Allocating MIDAS ITT colors in midas_cmap NCol=" << rgb_ncol << endl;
|
---|
100 | PIColor col; // Les couleurs PI sont des entiers de 0 a 65535 (16 bits)
|
---|
101 | for(int kc=0; kc<rgb_ncol; kc++) {
|
---|
102 | col.red = (short unsigned)(rgb_r[kc]*65535);
|
---|
103 | col.green = (short unsigned)(rgb_g[kc]*65535);
|
---|
104 | col.blue = (short unsigned)(rgb_b[kc]*65535);
|
---|
105 | midas_cmap.AllocColor(col, kc);
|
---|
106 | }
|
---|
107 | SetReady();
|
---|
108 | }
|
---|
109 |
|
---|
110 | /* --Methode-- */
|
---|
111 | PITApp::~PITApp()
|
---|
112 | {
|
---|
113 | for(int i=0; i<3; i++) delete m[i];
|
---|
114 | delete txt;
|
---|
115 | delete cmapv;
|
---|
116 | delete zoom;
|
---|
117 | }
|
---|
118 |
|
---|
119 |
|
---|
120 | static int nbwin = 0;
|
---|
121 | static int numpsf = 0;
|
---|
122 | static int fgswcol = 0;
|
---|
123 |
|
---|
124 | static double fsinc(double x) {if ( (x>-1.e-8) && (x<1.e-8) ) return(0.); else return (sin(x)/x);}
|
---|
125 |
|
---|
126 | /* --Methode-- */
|
---|
127 | void PITApp::Process(PIMessage msg, PIMsgHandler* sender, void* data)
|
---|
128 | {
|
---|
129 | char strg[64];
|
---|
130 | int i,j;
|
---|
131 |
|
---|
132 | if ( ( ModMsg(msg) == PIMsg_Active) || (ModMsg(msg) == PIMsg_Close) ) {
|
---|
133 | PIWdg *sndw;
|
---|
134 | sndw = (PIWdg *)sender;
|
---|
135 | if (sndw->kind() == PIWindow::ClassId) {
|
---|
136 | if (ModMsg(msg) == PIMsg_Close) {
|
---|
137 | printf("PITApp::Process()/Debug : Closing Window %lx \n", (long)sender);
|
---|
138 | delete (PIWindow *)sender;
|
---|
139 | mCurW = NULL; }
|
---|
140 | else mCurW = (PIWindow *)sender;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | else
|
---|
144 | {
|
---|
145 | switch(UserMsg(msg))
|
---|
146 | {
|
---|
147 |
|
---|
148 | // --------- 1er menu ----------
|
---|
149 | case 10101:
|
---|
150 | txt->SetText("pitgr: PI Graphics Tests \n * 2-D graphics \n * 3-D Graphics \n Image display ");
|
---|
151 | break;
|
---|
152 |
|
---|
153 | case 10110 :
|
---|
154 | if (mCurW) { mCurW->Hide(); delete mCurW;}
|
---|
155 | mCurW = NULL;
|
---|
156 | break;
|
---|
157 |
|
---|
158 | case 10150: // Sortie d'application
|
---|
159 | Stop();
|
---|
160 | break;
|
---|
161 |
|
---|
162 |
|
---|
163 | // ---------- 3eme menu --------
|
---|
164 | case 10301 :
|
---|
165 | PIImgTools::ShowPIImgTools();
|
---|
166 | break;
|
---|
167 | case 10302 :
|
---|
168 | PIDrwTools::ShowPIDrwTools();
|
---|
169 | break;
|
---|
170 | case 10305 :
|
---|
171 | if(mCurW) {
|
---|
172 | char buff[64];
|
---|
173 | sprintf(buff, "pigr_%d.eps", numpsf); numpsf++;
|
---|
174 | printf("Creating EPS File %s (Encapsulated PostScript) \n", buff);
|
---|
175 | PSFile *mps;
|
---|
176 | mps = new PSFile(buff);
|
---|
177 | mCurW->PSPrint(mps,0,0);
|
---|
178 | delete mps;
|
---|
179 | }
|
---|
180 | break;
|
---|
181 |
|
---|
182 | // ---------- 2eme menu --------
|
---|
183 |
|
---|
184 | case 10201 : // Trace de la fonction sin(x)/x
|
---|
185 | {
|
---|
186 | SetBusy(); // souris -> montre
|
---|
187 | txt->SetText("PIScDrawWdg Creation\n Sin(x)/x \n Button 1 -> Coord \n Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
|
---|
188 |
|
---|
189 | PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
|
---|
190 | mfd->GetGraphicAtt().SetColAtt(PI_Gold);
|
---|
191 | mfd->GetGraphicAtt().SetLineAtt(PI_NormalLine);
|
---|
192 | nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
|
---|
193 | PIWindow* wp = new PIWindow(this, strg, PIWK_normal, 300, 300, 150, 150);
|
---|
194 | wp->SetAutoDelChilds(true);
|
---|
195 | PIScDrawWdg* scd = new PIScDrawWdg(wp, "scwdg-sinc", 300, 300, 0, 0);
|
---|
196 | scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
197 | scd->SetLimits(0.1, 30., -1., 1.);
|
---|
198 | scd->AddScDrawer(mfd,true);
|
---|
199 | PIGraphicAtt gatt;
|
---|
200 | gatt.SetColAtt(PI_Red);
|
---|
201 | scd->BaseDrawer()->ElDrwMgr().ElAddText(2., 0.8, "Y = Sin(x)/x", gatt, 0);
|
---|
202 |
|
---|
203 | scd->SetTitles(" --- PIFuncDrawer (Sin(x)/x) --- ","");
|
---|
204 | wp->Show(); // On affiche la fenetre
|
---|
205 | SetReady(); // souris->pointeur , on n'est plus occupe
|
---|
206 | }
|
---|
207 | break;
|
---|
208 |
|
---|
209 |
|
---|
210 | case 10202 : // Trace Test de PIYfXDrawer
|
---|
211 | {
|
---|
212 | SetBusy(); // souris -> montre
|
---|
213 | txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer \n Button 1 -> Coord \n Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
|
---|
214 |
|
---|
215 | float* vpx = new float[30];
|
---|
216 | float* vpy = new float[30];
|
---|
217 | int i; double x;
|
---|
218 | for(i=0; i<30; i++) { x = 8.*i/30; vpx[i] = x; vpy[i] = 3*cos(x)+2*sin(x); }
|
---|
219 | PIYfXDrawer* mxyd = new PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true),
|
---|
220 | new P1DAdapter<float>(vpy, 30, true), true);
|
---|
221 | mxyd->GetGraphicAtt().SetColAtt(PI_Red);
|
---|
222 | mxyd->GetGraphicAtt().SetMarkerAtt(7, PI_FTriangleMarker);
|
---|
223 |
|
---|
224 | nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
|
---|
225 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 300, 300, 300, 300);
|
---|
226 | PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 300, 300, 0, 0);
|
---|
227 | scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
228 | scd->AddScDrawer(mxyd,true);
|
---|
229 | scd->SetTitles(" --- PIYfXDrawer (3*cons(x)+2*sin(x)) --- ","");
|
---|
230 | awp->SetAutoDelChilds(true);
|
---|
231 | awp->Show();
|
---|
232 | SetReady();
|
---|
233 | }
|
---|
234 | break;
|
---|
235 |
|
---|
236 | case 10203 : // FunDrawer + PIYfXDrawer
|
---|
237 | {
|
---|
238 | SetBusy(); // souris -> montre
|
---|
239 | txt->SetText("PIScDrawWdg Creation\n PIYfXDrawer + FuncDrawer(Sin(x)/x) \n Button 1 -> Coord \n Button 2 Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
|
---|
240 |
|
---|
241 | float* vpx = new float[30];
|
---|
242 | float* vpy = new float[30];
|
---|
243 | int i; double x;
|
---|
244 | for(i=0; i<30; i++) { x = 8.*i/30; vpx[i] = x; vpy[i] = 3*cos(x)+2*sin(x); }
|
---|
245 | PIYfXDrawer* mxyd = new PIYfXDrawer( new P1DAdapter<float>(vpx, 30, true),
|
---|
246 | new P1DAdapter<float>(vpy, 30, true), true);
|
---|
247 |
|
---|
248 | mxyd->GetGraphicAtt().SetColAtt(PI_Magenta);
|
---|
249 | mxyd->GetGraphicAtt().SetMarkerAtt(7, PI_FBoxMarker);
|
---|
250 |
|
---|
251 | PIFuncDrawer* mfd = new PIFuncDrawer(fsinc);
|
---|
252 | mfd->GetGraphicAtt().SetColAtt(PI_Blue);
|
---|
253 | mfd->GetGraphicAtt().SetLineAtt(PI_NormalLine);
|
---|
254 |
|
---|
255 | nbwin++; sprintf(strg,"2D Graphics (PI W %d)", nbwin);
|
---|
256 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 400, 400, 300, 300);
|
---|
257 | PIScDrawWdg* scd = new PIScDrawWdg(awp, "scwdg-YfX", 400, 400, 0, 0);
|
---|
258 | scd->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed);
|
---|
259 | scd->AddScDrawer(mxyd,true);
|
---|
260 | scd->AddScDrawer(mfd,true);
|
---|
261 | scd->SetTitles(" --- PIYfXDrawer + PIFuncDrawer --- ","");
|
---|
262 | awp->SetAutoDelChilds(true);
|
---|
263 | awp->Show();
|
---|
264 |
|
---|
265 | SetReady();
|
---|
266 | }
|
---|
267 | break;
|
---|
268 |
|
---|
269 | case 10207 :
|
---|
270 | {
|
---|
271 | SetBusy(); // souris -> montre
|
---|
272 | txt->SetText("PIImage Creation\n Image Display \n Button 1 -> Coord/value \n Button 2 Select Rectangle \n Butt on 3 Move \n <Alt>O <Alt>V <Alt>C \n Try ImageTools");
|
---|
273 |
|
---|
274 | int sx=400, sy=600;
|
---|
275 | printf(" Creating Image (%dx%d) ... ", sx, sy);
|
---|
276 | float* img = new float[sx*sy];
|
---|
277 | int i, j;
|
---|
278 | for(i=0;i<sx;i++) {
|
---|
279 | double x = (i-sx/2.)/(sx/5.);
|
---|
280 | for(j=0;j<sy;j++) {
|
---|
281 | double y = (j-sy/2.)/(sy/5.);
|
---|
282 | y = -0.5*(x*x+y*y);
|
---|
283 | if(y<-80.) y=0.;
|
---|
284 | img[j*sx+i] = 1000.*exp(-0.5*(x*x+y*y));
|
---|
285 | }
|
---|
286 | }
|
---|
287 | printf(" >> OK \n");
|
---|
288 | nbwin++; sprintf(strg,"Image (PI W %d)", nbwin);
|
---|
289 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, sx, sy, 300, 300);
|
---|
290 | PIImage * pii = new PIImage(awp, "fitsimage", sx, sy, 0, 0);
|
---|
291 | pii->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
|
---|
292 | pii->SetZoomWin(zoom, false);
|
---|
293 | pii->SetCMapWin(cmapv, false);
|
---|
294 | pii->ShowCursor(true);
|
---|
295 | pii->SetColMap(&midas_cmap, false);
|
---|
296 | awp->SetAutoDelChilds(true);
|
---|
297 | awp->Show();
|
---|
298 | pii->SetImage(new P2DAdapter<float>(img, sx, sy, true), true);
|
---|
299 | SetReady();
|
---|
300 | }
|
---|
301 | break;
|
---|
302 |
|
---|
303 | case 10206 :
|
---|
304 | {
|
---|
305 | SetBusy(); // souris -> montre
|
---|
306 | txt->SetText("PIImage Creation\n Image Display \n Button 1 -> Coord/value \n Button 2 Select Rectangle \n Butt on 3 Move \n <Alt>O <Alt>V <Alt>C \n Try ImageTools");
|
---|
307 |
|
---|
308 | int sx, sy;
|
---|
309 | sx = 400;
|
---|
310 | sy = 600;
|
---|
311 | printf(" Creating Image (%dx%d) ... ", sx, sy);
|
---|
312 | float* img = new float[sx*sy];
|
---|
313 | int i, j, k, kk, i0, j0;
|
---|
314 | double lamp, amp,x,y;
|
---|
315 | for(k=0; k<sx*sy; k++) img[k] = 1000.+(random()%200-100);
|
---|
316 | // On genere 500 etoiles
|
---|
317 | for(k=0; k<500; k++) {
|
---|
318 | i0 = 20+random()%(sx-20);
|
---|
319 | j0 = 20+random()%(sy-20);
|
---|
320 | lamp = 2.0+0.012*(random()%100);
|
---|
321 | amp = pow(10., lamp);
|
---|
322 | // if (k%5 == 0) printf(" DBG %d %d - %g \n", i0, j0, flux);
|
---|
323 | for(i=i0-15; i<i0+15; i++) {
|
---|
324 | if(i<0 || i>=sx) continue;
|
---|
325 | for(j=j0-15; j<j0+15; j++) {
|
---|
326 | if(j<0 || j>=sy) continue;
|
---|
327 | x = i-i0; y = j-j0;
|
---|
328 | kk = j*sx+i;
|
---|
329 | img[kk] += amp*exp(-(x*x)/7.-(y*y)/8.);
|
---|
330 | }
|
---|
331 | }
|
---|
332 | }
|
---|
333 | printf(" >> OK \n");
|
---|
334 |
|
---|
335 | nbwin++; sprintf(strg,"Image (PI W %d)", nbwin);
|
---|
336 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, sx, sy, 300, 300);
|
---|
337 | PIImage * pii = new PIImage(awp, "fitsimage", sx, sy, 0, 0);
|
---|
338 | pii->SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed);
|
---|
339 | pii->SetZoomWin(zoom, false);
|
---|
340 | pii->SetCMapWin(cmapv, false);
|
---|
341 | pii->ShowCursor(true);
|
---|
342 | pii->SetColMap(&midas_cmap, false);
|
---|
343 | awp->SetAutoDelChilds(true);
|
---|
344 | awp->Show();
|
---|
345 | pii->SetImage(new P2DAdapter<float>(img, sx, sy, true), true);
|
---|
346 | SetReady();
|
---|
347 | }
|
---|
348 | break;
|
---|
349 |
|
---|
350 |
|
---|
351 | // Dessins 3D
|
---|
352 | case 10204:
|
---|
353 | {
|
---|
354 | SetBusy(); // souris -> montre
|
---|
355 | txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
|
---|
356 |
|
---|
357 | printf(" Creating Matrix 80x60 ... ");
|
---|
358 | float* tf = new float[60*80];
|
---|
359 | int i,j,k;
|
---|
360 | double xp,yp,rp;
|
---|
361 | for(i=0; i<80; i++)
|
---|
362 | for(j=0; j<60; j++) {
|
---|
363 | xp = i-30; yp = j-20;
|
---|
364 | rp = (xp*xp)/16.+(yp*yp)/9.;
|
---|
365 | tf[j*80+i] = 10.*exp(-rp);
|
---|
366 | xp = i-50; yp = j-28;
|
---|
367 | rp = (xp*xp)/9.+(yp*yp)/9.;
|
---|
368 | tf[j*80+i] += 4.*exp(-rp);
|
---|
369 | }
|
---|
370 | printf(" >> OK \n");
|
---|
371 |
|
---|
372 | nbwin++; sprintf(strg,"3D Surf (PI W %d)", nbwin);
|
---|
373 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
|
---|
374 | PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 80, 60, true), true, true, true);
|
---|
375 | PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 500, 500, 0, 0);
|
---|
376 | drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
|
---|
377 | drw3->AddDrawer3D(sd, false);
|
---|
378 | drw3->SetTitles(" --- PISurfaceDrawer (80x60) --- ","");
|
---|
379 | awp->SetAutoDelChilds(true);
|
---|
380 | awp->Show();
|
---|
381 | SetReady();
|
---|
382 | }
|
---|
383 | break;
|
---|
384 |
|
---|
385 | case 10205:
|
---|
386 | {
|
---|
387 | SetBusy(); // souris -> montre
|
---|
388 | txt->SetText("PIDraw3DWdg Creation\n 3-D Surf Display \n Button 1 \n (Shift) Button 2 Rotate \n Button Zoom \n <Alt>O <Alt>V \n Try DrawerTools");
|
---|
389 |
|
---|
390 | printf(" Creating Matrix 50x50 ... ");
|
---|
391 | float * tf = new float[2500];
|
---|
392 | int i,j;
|
---|
393 | double xp,yp,rp;
|
---|
394 | for(i=0; i<50; i++)
|
---|
395 | for(j=0; j<50; j++) {
|
---|
396 | xp = i-15; yp = j-25;
|
---|
397 | rp = (xp*xp)/16.+(yp*yp)/16.;
|
---|
398 | tf[j*50+i] = 11.*exp(-rp);
|
---|
399 | xp = i-35; yp = j-15;
|
---|
400 | rp = (xp*xp)/9.+(yp*yp)/9.;
|
---|
401 | tf[j*50+i] += 3.*exp(-rp);
|
---|
402 | xp = i-45; yp = j-40;
|
---|
403 | rp = (xp*xp)/10.+(yp*yp)/20.;
|
---|
404 | tf[j*50+i] += 6.*exp(-rp);
|
---|
405 | }
|
---|
406 | printf(" >> OK \n");
|
---|
407 |
|
---|
408 | nbwin++; sprintf(strg,"PI W# %d 3D Surf", nbwin);
|
---|
409 | PIWindow* awp = new PIWindow(this, strg, PIWK_normal, 500, 500, 200, 200);
|
---|
410 | PISurfaceDrawer* sd = new PISurfaceDrawer(new P2DAdapter<float>(tf, 50, 50, true), true, true, true);
|
---|
411 | if (fgswcol%3 == 0) sd->GetGraphicAtt().SetColMapId(CMAP_COLRJ32);
|
---|
412 | else if (fgswcol%3 == 1) sd->GetGraphicAtt().SetColMapId(CMAP_COLBR32);
|
---|
413 | else sd->GetGraphicAtt().SetColMapId(CMAP_COLRV32);
|
---|
414 | fgswcol++;
|
---|
415 | PIDraw3DWdg* drw3 = new PIDraw3DWdg(awp, "ex3ddrw", 600, 600, 0, 0);
|
---|
416 | drw3->SetBinding(PIBK_fixed , PIBK_fixed , PIBK_fixed, PIBK_fixed);
|
---|
417 | drw3->AddDrawer3D(sd, false);
|
---|
418 | drw3->SetTitles(" --- PISurfaceDrawer (50x50) --- ","");
|
---|
419 | awp->SetAutoDelChilds(true);
|
---|
420 | awp->Show();
|
---|
421 | SetReady();
|
---|
422 | }
|
---|
423 | break;
|
---|
424 |
|
---|
425 | default :
|
---|
426 | // printf("PITApp::Process() Msg= %d (%d - %d)??? \n",
|
---|
427 | // (int)msg, (int)UserMsg(msg),(int)ModMsg(msg));
|
---|
428 | break;
|
---|
429 | }
|
---|
430 | }
|
---|
431 | return;
|
---|
432 | }
|
---|
433 |
|
---|
434 |
|
---|
435 | // ................................................................
|
---|
436 | // programme principal
|
---|
437 | // ................................................................
|
---|
438 |
|
---|
439 |
|
---|
440 |
|
---|
441 | int main(int narg, char *arg[])
|
---|
442 | {
|
---|
443 |
|
---|
444 | if ( (narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
|
---|
445 | printf("midasitt : MIDAS ITT color table test \n");
|
---|
446 | printf(" Usage : midasitt MIDAS_ITT_File [Xt options] \n");
|
---|
447 | return(0);
|
---|
448 | }
|
---|
449 |
|
---|
450 |
|
---|
451 | string midas_itt_file = arg[1];
|
---|
452 |
|
---|
453 | cout << " Reading RGB values from MIDAS_ITT file " << (string)arg[1];
|
---|
454 | FILE * fip = fopen(arg[1], "r");
|
---|
455 | if (fip == NULL) {
|
---|
456 | cout << "midasitt ERROR opening file " << (string)arg[1] << endl;
|
---|
457 | return(2);
|
---|
458 | }
|
---|
459 |
|
---|
460 | char lineb[512];
|
---|
461 | int nlread = 0;
|
---|
462 | int numl = 0;
|
---|
463 | while ( (fgets(lineb,512,fip) != NULL) && (nlread < 512) ) {
|
---|
464 | lineb[9] = '\0';
|
---|
465 | numl = atoi(lineb);
|
---|
466 | if (numl != (nlread+1) ) continue;
|
---|
467 | lineb[25] = '\0';
|
---|
468 | rgb_r[nlread] = atof(lineb+14);
|
---|
469 | lineb[41] = '\0';
|
---|
470 | rgb_g[nlread] = atof(lineb+30);
|
---|
471 | lineb[60] = '\0';
|
---|
472 | rgb_b[nlread] = atof(lineb+46);
|
---|
473 | nlread++;
|
---|
474 | }
|
---|
475 |
|
---|
476 | fclose(fip);
|
---|
477 | if (nlread != 256) {
|
---|
478 | cout << "midasitt ERROR number of lines != 256 " << nlread << endl;
|
---|
479 | return(3);
|
---|
480 | }
|
---|
481 | rgb_ncol = nlread;
|
---|
482 |
|
---|
483 | int kl;
|
---|
484 | cout << "MIDAS_ITT: RGB - Red ( File" << (string)arg[1] << ")" << endl;
|
---|
485 | for(kl=0; kl<rgb_ncol; kl++) {
|
---|
486 | cout << rgb_r[kl] << ", " ;
|
---|
487 | if ((kl%8) == 0) cout << endl;
|
---|
488 | }
|
---|
489 | cout << endl;
|
---|
490 | cout << "MIDAS_ITT: RGB - Green ( File" << (string)arg[1] << ")" << endl;
|
---|
491 | for(kl=0; kl<rgb_ncol; kl++) {
|
---|
492 | cout << rgb_g[kl] << ", " ;
|
---|
493 | if ((kl%8) == 0) cout << endl;
|
---|
494 | }
|
---|
495 | cout << endl;
|
---|
496 | cout << "MIDAS_ITT: RGB - Blue ( File" << (string)arg[1] << ")" << endl;
|
---|
497 | for(kl=0; kl<rgb_ncol; kl++) {
|
---|
498 | cout << rgb_b[kl] << ", " ;
|
---|
499 | if ((kl%8) == 0) cout << endl;
|
---|
500 | }
|
---|
501 |
|
---|
502 | cout << "\n \n" << endl;
|
---|
503 |
|
---|
504 |
|
---|
505 | PITApp* app = new PITApp(narg, arg);
|
---|
506 | int sx,sy;
|
---|
507 | PIApplicationPrefCompSize(sx, sy);
|
---|
508 | printf("##### pit-main() PrefCompSize= %d %d ##### \n", sx, sy);
|
---|
509 | PIApplicationScreenSize(sx, sy);
|
---|
510 | printf("##### pit-main() ScreenSize= %d %d ##### \n", sx, sy);
|
---|
511 | PIColorMap* cmap = new PIColorMap(CMAP_GREY32);
|
---|
512 | printf("##### pit-main() NbTotColors=%d Already Allocated= %d ##### \n",
|
---|
513 | cmap->TotNbColors(), cmap->NbAllocColors());
|
---|
514 |
|
---|
515 |
|
---|
516 | app->Run();
|
---|
517 |
|
---|
518 | delete cmap;
|
---|
519 | delete app;
|
---|
520 | exit(0);
|
---|
521 | }
|
---|
522 |
|
---|
523 |
|
---|