1 | // Module PI : Peida Interactive PIImage
|
---|
2 | // Affichage d'image R. Ansari 05/95
|
---|
3 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
4 | // Refonte Reza 10/95
|
---|
5 |
|
---|
6 |
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <string.h>
|
---|
10 |
|
---|
11 | #include "piimage.h"
|
---|
12 | #include "piimgtools.h"
|
---|
13 | #include "pidrwtools.h"
|
---|
14 | #include PIAPP_H
|
---|
15 |
|
---|
16 | //++
|
---|
17 | // Class PIImage
|
---|
18 | // Lib PI
|
---|
19 | // include piimage.h
|
---|
20 | //
|
---|
21 | // Classe pour la l'affichage et la manipulation d'images.
|
---|
22 | // Peut contrôler un PIPixmap pour l'affichage d'une zone
|
---|
23 | // agrandie (zoom) et un PIPixmap pour l'affichage de toute
|
---|
24 | // l'image (réduite).
|
---|
25 | // Utilise les adaptateur de tableaux 2D manipuler le
|
---|
26 | // contenu des images ("P2DArrayAdapter").
|
---|
27 | //
|
---|
28 | // * Bouton-1 : Envoie le message "PIMsg_Active" et affiche
|
---|
29 | // les coordonnées courantes et la valeur du pixel,
|
---|
30 | // et positionne le pavé.
|
---|
31 | // * Bouton-2 : Permet de définir une zone de l'image et repositionne le pavé.
|
---|
32 | // * Bouton-3 : Permet de déplacer l'image dans la fenêtre
|
---|
33 | //
|
---|
34 | // Gestion du clavier :
|
---|
35 | // * <Alt>O : Affichage de la fenêtre de contrôle des paramètres de visualisation.
|
---|
36 | // * <Alt>G : Affichage de la fenêtre de changement des attributs graphiques
|
---|
37 | // * <Alt>R : Rafraîchit l'affichage.
|
---|
38 | // * <Alt>V : Copier/*Coller* Ajout du texte du buffer copier/coller
|
---|
39 | // sur l'objet à la position courante.
|
---|
40 | // * <Alt>C : *Copier*/Coller Permet de copier le contenu de la zone sélectionnée
|
---|
41 | // de l'image sous forme texte.
|
---|
42 | // * <Alt>Z : Supprime les textes et signes ajoutés au dessin.
|
---|
43 | // * Touches Curseurs : déplace la pavé.
|
---|
44 | //--
|
---|
45 | //++
|
---|
46 | // Links Parents
|
---|
47 | // PIPixmap
|
---|
48 | //--
|
---|
49 |
|
---|
50 | //++
|
---|
51 | // Titre Constructeurs, méthodes
|
---|
52 | //--
|
---|
53 | //++
|
---|
54 | // PIImage(PIContainerGen *par, char *nom=NULL, int sx=0, int sy=0, int px=0, int py=0)
|
---|
55 | // Créateur
|
---|
56 | //
|
---|
57 | //--
|
---|
58 |
|
---|
59 | // --------------------------------------------------------------------------------
|
---|
60 | // ----------------------------- Classe PIImage -----------------------------------
|
---|
61 | // --------------------------------------------------------------------------------
|
---|
62 | // Variable globale pour la gestion de l'image courante
|
---|
63 | PIImage* PIImage::cur_piimage = NULL;
|
---|
64 | /* --Methode-- */
|
---|
65 | PIImage* PIImage::CurrentPIImage()
|
---|
66 | {
|
---|
67 | return(cur_piimage);
|
---|
68 | }
|
---|
69 |
|
---|
70 | /* --Methode-- */
|
---|
71 | void PIImage::SetCurrentPIImage(PIImage* curimg)
|
---|
72 | {
|
---|
73 | cur_piimage = curimg;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /* --Methode-- */
|
---|
77 | PIImage::PIImage(PIContainerGen *par, char *nom,
|
---|
78 | int sx, int sy, int px, int py) :
|
---|
79 | PIPixmap(par, nom, sx, sy, px, py)
|
---|
80 | {
|
---|
81 |
|
---|
82 | img = NULL;
|
---|
83 | aisup = false;
|
---|
84 | curshow = true;
|
---|
85 | winovis = true; // $CHECK$ Reza A enlever si possible 17/6/96
|
---|
86 |
|
---|
87 |
|
---|
88 | zow = NULL; // Widget zoom
|
---|
89 | gvw = NULL; // widget vue globale
|
---|
90 | cmvw = NULL; // widget ColorMapView
|
---|
91 | // Fenetre transient et Label pour affichage de l'info (texte PixVal)
|
---|
92 | int tx, ty;
|
---|
93 | PIApplicationPrefCompSize(tx, ty);
|
---|
94 | tx *= 5; ty = (int)(ty*0.8);
|
---|
95 | trtw = new PIWindow(this, "PixVal", PIWK_transient, tx, ty, 0, 0);
|
---|
96 | trtw->SetAutoDelChilds(true);
|
---|
97 | trtlb = new PILabel(trtw, "PixVal", tx, ty, 0, 0);
|
---|
98 | trtlb->SetBinding(PIBK_fixed,PIBK_fixed, PIBK_fixed,PIBK_fixed);
|
---|
99 | ustrtw = atrtw = false;
|
---|
100 | if ((sx < 300) || (sy < 150) ) atrtw = true;
|
---|
101 | showinfo = false;
|
---|
102 |
|
---|
103 | gpixm = zpixm = pixm = NULL;
|
---|
104 | xsgpxm = xszpxm = xspxm = 0;
|
---|
105 | ysgpxm = yszpxm = yspxm = 0;
|
---|
106 | lut = NULL;
|
---|
107 | offx = offy = 0;
|
---|
108 | xpav = ypav = 0;
|
---|
109 | xpv0 = ypv0 = 0;
|
---|
110 | xszpav = yszpav = 1;
|
---|
111 | xmv0 = ymv0 = -1;
|
---|
112 | dxmv = dymv = 0;
|
---|
113 | xcurs = ycurs = -1;
|
---|
114 | zoom = 1;
|
---|
115 | zmgv = 1;
|
---|
116 |
|
---|
117 | mdrw = new PIElDrawer();
|
---|
118 | gvdrw = new PIElDrawer();
|
---|
119 | AddDrawer(mdrw, true, false, false);
|
---|
120 |
|
---|
121 | SetLut(0., 32000., kLutType_Lin, 0, false);
|
---|
122 | SetColMapId(CMAP_COLRJ32);
|
---|
123 | // pour le copier-coller
|
---|
124 | cpbuffer = NULL;
|
---|
125 | cpbuflen = 0;
|
---|
126 |
|
---|
127 | SetBackgroundColor(PI_Black);
|
---|
128 |
|
---|
129 | ActivateKeyboard();
|
---|
130 | ActivateButton(1);
|
---|
131 | ActivateMove(1);
|
---|
132 | ActivateButton(2);
|
---|
133 | ActivateMove(2);
|
---|
134 | ActivateButton(3);
|
---|
135 | ActivateMove(3);
|
---|
136 |
|
---|
137 | cur_piimage = this;
|
---|
138 | }
|
---|
139 |
|
---|
140 | /* --Methode-- */
|
---|
141 | PIImage::~PIImage()
|
---|
142 | {
|
---|
143 | if (pixm) delete pixm;
|
---|
144 | if (zpixm) delete zpixm;
|
---|
145 | if (zow)
|
---|
146 | {
|
---|
147 | zow->SetPixmap(NULL,0,0);
|
---|
148 | zow->EraseWindow();
|
---|
149 | }
|
---|
150 | if (gpixm) delete gpixm;
|
---|
151 | if (gvw)
|
---|
152 | {
|
---|
153 | gvw->SetPixmap(NULL,0,0);
|
---|
154 | gvw->EraseWindow();
|
---|
155 | gvw->SetMsg(0); gvw->SetMsgParent(NULL);
|
---|
156 | gvw->SetUserData(NULL, 0);
|
---|
157 | }
|
---|
158 | if (cmvw) cmvw->SetColMap(NULL, 1., -1., true);
|
---|
159 | if (lut) delete lut;
|
---|
160 | delete mdrw;
|
---|
161 | delete gvdrw;
|
---|
162 | if (aisup && img) delete img; // Suppression automatique d'image
|
---|
163 | delete trtw;
|
---|
164 | if (cpbuffer) delete[] cpbuffer;
|
---|
165 | if (this == cur_piimage) cur_piimage = NULL;
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* --Methode-- */
|
---|
169 | void PIImage::Process(PIMessage msg, PIMsgHandler* sender, void* data)
|
---|
170 | {
|
---|
171 | if (UserMsg(msg) == (Msg()+626))
|
---|
172 | {
|
---|
173 | if (ModMsg(msg) == PIMsg_Click)
|
---|
174 | { int* pxy=(int *)data; SetPave(pxy[0]*zmgv, pxy[1]*zmgv); }
|
---|
175 | if (ModMsg(msg) == PIMsg_Resize)
|
---|
176 | { ComputeGloVPixmap(); SetGloVPixmap(); }
|
---|
177 | }
|
---|
178 | else ReSend(msg, sender, data);
|
---|
179 | return;
|
---|
180 | }
|
---|
181 |
|
---|
182 | /* --Methode-- */
|
---|
183 | void PIImage::SetImage(P2DArrayAdapter *pim, bool ad, bool refr)
|
---|
184 | {
|
---|
185 |
|
---|
186 | offx = offy = 0;
|
---|
187 | xpav = ypav = 0;
|
---|
188 | xszpav = yszpav = 1;
|
---|
189 | img = pim;
|
---|
190 | if (gpixm) delete gpixm;
|
---|
191 | gpixm = NULL;
|
---|
192 | xsgpxm = ysgpxm = 0;
|
---|
193 | zmgv = 1;
|
---|
194 |
|
---|
195 | if (img) {
|
---|
196 | // SetSize(img->XSize(), img->YSize());
|
---|
197 | CenterPave();
|
---|
198 | double min=1., max=-1., moy, sig;
|
---|
199 | int nbnul, nbsat;
|
---|
200 | img->CheckDyn(min, max, moy, sig, nbnul, nbsat);
|
---|
201 | SetLut(min, max, kLutType_Lin, 1, refr);
|
---|
202 | aisup = ad;
|
---|
203 | }
|
---|
204 | else aisup = false;
|
---|
205 | return;
|
---|
206 | }
|
---|
207 |
|
---|
208 | /* --Methode-- */
|
---|
209 | void PIImage::ChangeAxesConfiguration(bool ix, bool iy, bool xy, bool refr)
|
---|
210 | {
|
---|
211 | if (!img) return;
|
---|
212 | bool invx, invy, exy;
|
---|
213 | img->GetAxesConfiguration(invx, invy, exy);
|
---|
214 | if (ix) invx = !invx;
|
---|
215 | if (iy) invy = !invy;
|
---|
216 | if (xy) exy = !exy;
|
---|
217 | img->ConfigureAxes(invx, invy, exy);
|
---|
218 | ComputeGloVPixmap();
|
---|
219 | if (refr) Apply();
|
---|
220 | }
|
---|
221 |
|
---|
222 | /* --Methode-- */
|
---|
223 | void PIImage::SetZoomWin(PIPixmap * zw, bool refr)
|
---|
224 | {
|
---|
225 | zow = zw;
|
---|
226 | if (zow && refr && img)
|
---|
227 | ComputeZoomPixmap();
|
---|
228 | return;
|
---|
229 | }
|
---|
230 |
|
---|
231 | /* --Methode-- */
|
---|
232 | void PIImage::SetGloVWin(PIPixmap * zw, bool refr)
|
---|
233 | {
|
---|
234 | gvw = zw;
|
---|
235 | if (gvw && img)
|
---|
236 | { ComputeGloVPixmap();
|
---|
237 | if (refr) SetGloVPixmap(); }
|
---|
238 | return;
|
---|
239 | }
|
---|
240 |
|
---|
241 | /* --Methode-- */
|
---|
242 | void PIImage::SetCMapWin(PICMapView * cw, bool refr)
|
---|
243 | {
|
---|
244 | cmvw = cw;
|
---|
245 | if (cmvw && refr) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 | /* --Methode-- */
|
---|
250 | void PIImage::UseInfoWin(bool trw)
|
---|
251 | {
|
---|
252 | ustrtw = trw;
|
---|
253 | }
|
---|
254 |
|
---|
255 | /* --Methode-- */
|
---|
256 | void PIImage::ShowInfo(bool si)
|
---|
257 | {
|
---|
258 | if (showinfo == si) return;
|
---|
259 | showinfo = si;
|
---|
260 | if (showinfo && img) {
|
---|
261 | char buff[256];
|
---|
262 | double x,y;
|
---|
263 | img->XYCoord(xpav, ypav, x, y);
|
---|
264 | sprintf(buff," X= %g , Y= %g Pix= %g (%d,%d) ",
|
---|
265 | x, y , (*img)(xpav, ypav), xpav, ypav );
|
---|
266 | DrawInfo(mWGrC, buff);
|
---|
267 | }
|
---|
268 | else DrawInfo(mWGrC, NULL);
|
---|
269 | }
|
---|
270 |
|
---|
271 | /* --Methode-- */
|
---|
272 | void PIImage::ShowCursor(bool sc)
|
---|
273 | {
|
---|
274 | if (curshow == sc) return;
|
---|
275 | curshow = sc;
|
---|
276 | if (curshow) DrawCursor(mWGrC);
|
---|
277 | else DrawCursor(mWGrC, -1, -1);
|
---|
278 | return;
|
---|
279 | }
|
---|
280 |
|
---|
281 | /* --Methode-- */
|
---|
282 | void PIImage::SetLut(double min, double max, int typlut, int lauto, bool refr)
|
---|
283 | {
|
---|
284 | if (lut) delete(lut);
|
---|
285 | if (lauto && img)
|
---|
286 | {
|
---|
287 | int nbsig = lauto;
|
---|
288 | double fracmax = 1. - 0.05*nbsig;
|
---|
289 | img->ComputeLut_PicHisto(min, max, nbsig, fracmax);
|
---|
290 | }
|
---|
291 |
|
---|
292 | lut = new LUT(min, max, NbCol(), typlut);
|
---|
293 |
|
---|
294 | ComputeGloVPixmap();
|
---|
295 | if (refr) Apply();
|
---|
296 | return;
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | /* --Methode-- */
|
---|
301 | void PIImage::SetLut(LUT *clut, bool refr)
|
---|
302 | {
|
---|
303 | LUT * olut = lut;
|
---|
304 | lut = new LUT(clut->Min(), clut->Max(), NbCol(), clut->Type());
|
---|
305 | if (olut) delete olut;
|
---|
306 |
|
---|
307 | ComputeGloVPixmap();
|
---|
308 | if (refr) Apply();
|
---|
309 | return;
|
---|
310 | }
|
---|
311 |
|
---|
312 | /* --Methode-- */
|
---|
313 | void PIImage::SetZoomF(float fzm, bool refr)
|
---|
314 | {
|
---|
315 | int zm;
|
---|
316 |
|
---|
317 | if (fzm < 0.01) return;
|
---|
318 | if (fzm < 1.) zm = (int)(-(1./fzm));
|
---|
319 | else zm = (int)(fzm+0.25);
|
---|
320 | SetZoom(zm, refr);
|
---|
321 | return;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /* --Methode-- */
|
---|
325 | void PIImage::SetZoom(int zm, bool refr)
|
---|
326 | {
|
---|
327 | if ((zm == 0) || (zm == -1) ) zoom = 1;
|
---|
328 | else if (zm > 20) zoom = 20;
|
---|
329 | else if (zm < -20) zoom = -20;
|
---|
330 | else zoom = zm;
|
---|
331 | if (img)
|
---|
332 | { SetOffsetFromPave();
|
---|
333 | if (refr) Apply(); }
|
---|
334 | return;
|
---|
335 | }
|
---|
336 |
|
---|
337 | /* --Methode-- */
|
---|
338 | float PIImage::GetZoomF()
|
---|
339 | {
|
---|
340 | if (zoom >= 1) return((float)zoom);
|
---|
341 | else return(-1./(float)zoom);
|
---|
342 | }
|
---|
343 |
|
---|
344 |
|
---|
345 | /* --Methode-- */
|
---|
346 | void PIImage::SetOffset(int ox, int oy, bool refr)
|
---|
347 | {
|
---|
348 | if (img == NULL) {offx = offy = 0; return; }
|
---|
349 | if (ox < 0) ox = 0;
|
---|
350 | if (ox >= (img->XSize()-1)) ox = img->XSize()-2;
|
---|
351 | if (oy < 0) oy = 0;
|
---|
352 | if (oy >= (img->YSize()-1)) oy = img->YSize()-2;
|
---|
353 | offx = ox; offy = oy;
|
---|
354 | CenterPave();
|
---|
355 | if (refr) Apply();
|
---|
356 | return;
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | /* --Methode-- */
|
---|
361 | void PIImage::SetPave(int x, int y, bool refr, bool cent)
|
---|
362 | {
|
---|
363 | int xc, yc;
|
---|
364 |
|
---|
365 | if (img == NULL)
|
---|
366 | { offx = offy = 0;
|
---|
367 | xpav = ypav = 0;
|
---|
368 | return; }
|
---|
369 |
|
---|
370 | if ( (x >= (img->XSize()-1)) || ( x < 0) ||
|
---|
371 | (y >= (img->YSize()-1)) || ( y < 0) ) return;
|
---|
372 |
|
---|
373 | if ( (x == xpav) && (y == ypav) ) return;
|
---|
374 | xpav = x; ypav = y;
|
---|
375 |
|
---|
376 | if ( PosImg2W(xpav,ypav,&xc, &yc) || cent) // Il faut recenter l'image
|
---|
377 | { SetOffsetFromPave();
|
---|
378 | if (refr) Apply(true); }
|
---|
379 | else if (refr)
|
---|
380 | { Apply(false); if (curshow) DrawCursor(mWGrC); }
|
---|
381 |
|
---|
382 | return;
|
---|
383 | }
|
---|
384 |
|
---|
385 | /* --Methode-- */
|
---|
386 | void PIImage::SetColMap(PIColorMap* cmp, bool refr)
|
---|
387 | {
|
---|
388 | if (!cmp) return;
|
---|
389 | int cmapid = cmp->Type();
|
---|
390 | if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
|
---|
391 | (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) mdrw->SetColAtt(PI_Red);
|
---|
392 | else mdrw->SetColAtt(PI_White);
|
---|
393 | PIPixmap::SetColMap(cmp, refr);
|
---|
394 | if (zow) zow->SetColMap(cmp, refr);
|
---|
395 | if (gvw) gvw->SetColMap(cmp, refr);
|
---|
396 | if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), refr);
|
---|
397 | return;
|
---|
398 | }
|
---|
399 |
|
---|
400 | /* --Methode-- */
|
---|
401 | void PIImage::SetColMapId(CMapId cmapid, bool refr)
|
---|
402 | {
|
---|
403 | if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
|
---|
404 | (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) mdrw->SetColAtt(PI_Red);
|
---|
405 | else mdrw->SetColAtt(PI_White);
|
---|
406 | PIPixmap::SetColMapId(cmapid, refr);
|
---|
407 | if (zow) zow->SetColMapId(cmapid, refr);
|
---|
408 | if (gvw) gvw->SetColMapId(cmapid, refr);
|
---|
409 | if (cmvw) cmvw->SetColMapId(cmapid, Lut()->Min(), Lut()->Max(), refr);
|
---|
410 | return;
|
---|
411 | }
|
---|
412 |
|
---|
413 |
|
---|
414 | /* --Methode-- */
|
---|
415 | void PIImage::Apply(bool mw)
|
---|
416 | {
|
---|
417 | if (img == NULL) return;
|
---|
418 | if (mw) {
|
---|
419 | ComputePixmap();
|
---|
420 | Send(Msg(), PIMsg_Active);
|
---|
421 | cur_piimage = this;
|
---|
422 | PIDrwTools::SetCurrentBaseWdg(this);
|
---|
423 | }
|
---|
424 | else {
|
---|
425 | char buff[256];
|
---|
426 | double x,y;
|
---|
427 | img->XYCoord(xpav, ypav, x, y);
|
---|
428 | sprintf(buff," X= %g , Y= %g Pix= %g (%d,%d) ",
|
---|
429 | x, y , (*img)(xpav, ypav), xpav, ypav );
|
---|
430 | if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
|
---|
431 | else DrawInfo(mWGrC, buff);
|
---|
432 | }
|
---|
433 | if (zow != NULL) ComputeZoomPixmap();
|
---|
434 | if (gvw != NULL)
|
---|
435 | if ( (gvw->UserData() != this) || (mw) ) SetGloVPixmap();
|
---|
436 | if (cmvw) cmvw->SetColMap(cmap, Lut()->Min(), Lut()->Max(), true);
|
---|
437 |
|
---|
438 | return;
|
---|
439 | }
|
---|
440 |
|
---|
441 | /* --Methode-- */
|
---|
442 | void PIImage::Resize()
|
---|
443 | {
|
---|
444 | // printf("PIImage::Resize\n");
|
---|
445 | // On bascule sur la fenetre transient pour l'affichage des valeurs si fenetre trop petite
|
---|
446 | if ((XSize() < 300) || (YSize() < 150) ) atrtw = true;
|
---|
447 | else atrtw = false;
|
---|
448 | PIPixmap::Resize();
|
---|
449 | CenterPave();
|
---|
450 | Apply();
|
---|
451 | return;
|
---|
452 | }
|
---|
453 |
|
---|
454 | /* --Methode-- */
|
---|
455 | void PIImage::Draw(PIGraphic* g, int x0, int y0, int dx, int dy)
|
---|
456 | {
|
---|
457 | PIPixmap::Draw(g, x0, y0, dx, dy);
|
---|
458 | winovis = false; // $CHECK$ Reza A enlever si possible 17/6/96
|
---|
459 | if (curshow) {
|
---|
460 | int xc,yc;
|
---|
461 | PosImg2W(xpav, ypav, &xc, &yc);
|
---|
462 | if ((xc >= x0) && (xc < x0+dx) &&
|
---|
463 | (yc >= y0) && (yc < y0+dy) ) DrawCursor(g, xc, yc);
|
---|
464 | }
|
---|
465 |
|
---|
466 | if (showinfo && img) {
|
---|
467 | char buff[256];
|
---|
468 | double x,y;
|
---|
469 | img->XYCoord(xpav, ypav, x, y);
|
---|
470 | sprintf(buff," X= %g , Y= %g Pix= %g (%d,%d) ",
|
---|
471 | x, y , (*img)(xpav, ypav), xpav, ypav );
|
---|
472 | DrawInfo(mWGrC, buff);
|
---|
473 | }
|
---|
474 |
|
---|
475 | return;
|
---|
476 | }
|
---|
477 |
|
---|
478 | /* --Methode-- */
|
---|
479 | void PIImage::Keyboard(int key, PIKeyModifier kmod)
|
---|
480 | {
|
---|
481 | cur_piimage = this;
|
---|
482 | if (kmod == PIKM_Alt) {
|
---|
483 | if (key == 'R' || key == 'r') Apply(true); // Pour tout rafraichir
|
---|
484 | else if (key == 'V' || key == 'v') RequestSelection(); // Pour coller (copier/coller)
|
---|
485 | else if (key == 'Z' || key == 'z') { mdrw->ElDelAll(); Refresh(); } // Pour supprimer tous les signes
|
---|
486 | else if (key == 'O' || key == 'o') PIImgTools::ShowPIImgTools(); // Fentre LUT et options
|
---|
487 | else if (key == 'G' || key == 'g') { // Fentre attributs graphiques
|
---|
488 | PIDrwTools::SetCurrentBaseWdg(this);
|
---|
489 | PIDrwTools::ShowPIDrwTools(); // Fentre axes et options de trace
|
---|
490 | }
|
---|
491 | // ---- Le copier ----
|
---|
492 | else if ((key == 'C' || key == 'c') && img) {
|
---|
493 | // On limite la taille a 48x48
|
---|
494 | int i1 = XPave();
|
---|
495 | int i2 = ( XSzPave() < 48 ) ? i1+XSzPave() : i1+48;
|
---|
496 | int j1 = YPave();
|
---|
497 | int j2 = ( YSzPave() < 48 ) ? j1+YSzPave() : i1+48;
|
---|
498 | if ( ( (i2-i1) < 1 ) || ((j2-j1) < 1) ) return;
|
---|
499 | if (!ClaimSelection()) return; // On n'a pas pu prendre possession de la zone d'echange
|
---|
500 | if (cpbuffer) delete[] cpbuffer;
|
---|
501 | cpbuflen = (j2-j1)*(i2-i1+2)*12+(j2-j1)+128;
|
---|
502 | cpbuffer = new char[cpbuflen];
|
---|
503 | sprintf(cpbuffer,"PIImage: Pave(%dx%d) en (%d, %d) MaxCopie= 48x48 \n",
|
---|
504 | XSzPave(), YSzPave(), i1, j1);
|
---|
505 | int i,j;
|
---|
506 | int l = strlen(cpbuffer);
|
---|
507 | for(j=j1; j<j2; j++) {
|
---|
508 | sprintf(cpbuffer+l,"L %3d:",j);
|
---|
509 | l += 6;
|
---|
510 | for(i=i1; i<i2; i++) { sprintf(cpbuffer+l," %10g", (*img)(i, j)); l += 11; }
|
---|
511 | cpbuffer[l] = '\n'; l++;
|
---|
512 | }
|
---|
513 | cpbuffer[l] = '\0';
|
---|
514 | cpbuflen = l+1;
|
---|
515 | }
|
---|
516 | }
|
---|
517 |
|
---|
518 |
|
---|
519 | else if (kmod == PIKM_Blank) {
|
---|
520 | switch (key) {
|
---|
521 | case PIK_Up :
|
---|
522 | SetPave(xpav, ypav-1, true, false);
|
---|
523 | break;
|
---|
524 | case PIK_Down :
|
---|
525 | SetPave(xpav, ypav+1, true, false);
|
---|
526 | break;
|
---|
527 | case PIK_Left :
|
---|
528 | SetPave(xpav-1, ypav, true, false);
|
---|
529 | break;
|
---|
530 | case PIK_Right :
|
---|
531 | SetPave(xpav+1, ypav, true, false);
|
---|
532 | break;
|
---|
533 | default :
|
---|
534 | break;
|
---|
535 | }
|
---|
536 | }
|
---|
537 |
|
---|
538 | }
|
---|
539 |
|
---|
540 |
|
---|
541 | /* --Methode-- */
|
---|
542 | void PIImage::But1Press(int x, int y)
|
---|
543 | {
|
---|
544 | int xp, yp;
|
---|
545 |
|
---|
546 | Send(Msg(), PIMsg_Active);
|
---|
547 | cur_piimage = this;
|
---|
548 | PIDrwTools::SetCurrentBaseWdg(this);
|
---|
549 | if (img == NULL) return;
|
---|
550 | if ( PosW2Img(x, y, &xp, &yp) ) return;
|
---|
551 | SelPointerShape(PI_CrossPointer);
|
---|
552 | xpav = xp; ypav = yp;
|
---|
553 | if (ustrtw || atrtw) ShowTrTxW();
|
---|
554 | Apply(false);
|
---|
555 | if (curshow) DrawCursor(mWGrC, -1,-1);
|
---|
556 | return;
|
---|
557 | }
|
---|
558 |
|
---|
559 |
|
---|
560 | /* --Methode-- */
|
---|
561 | void PIImage::Ptr1Move(int x, int y)
|
---|
562 | {
|
---|
563 | int xp, yp;
|
---|
564 | if (img == NULL) return;
|
---|
565 | if ( PosW2Img(x, y, &xp, &yp) ) return;
|
---|
566 | xpav = xp; ypav = yp;
|
---|
567 | Apply(false);
|
---|
568 | return;
|
---|
569 | }
|
---|
570 |
|
---|
571 |
|
---|
572 | /* --Methode-- */
|
---|
573 | void PIImage::But1Release(int /*x*/, int /*y*/)
|
---|
574 | {
|
---|
575 | SelPointerShape(PI_ArrowPointer);
|
---|
576 | if (curshow) DrawCursor(mWGrC);
|
---|
577 | if (ustrtw || atrtw) trtw->Hide();
|
---|
578 | else if (!showinfo) DrawInfo(mWGrC, NULL);
|
---|
579 | return;
|
---|
580 | }
|
---|
581 |
|
---|
582 |
|
---|
583 | /* --Methode-- */
|
---|
584 | void PIImage::But2Press(int x, int y)
|
---|
585 | {
|
---|
586 |
|
---|
587 | Send(Msg(), PIMsg_Active);
|
---|
588 | cur_piimage = this;
|
---|
589 | PIDrwTools::SetCurrentBaseWdg(this);
|
---|
590 | if (img == NULL) return;
|
---|
591 | if ( PosW2Img(x, y, &xpv0, &ypv0) ) { xmv0 = -1; return; }
|
---|
592 | xmv0 = x; ymv0 = y; dxmv = dymv = 0;
|
---|
593 | if (curshow) DrawCursor(mWGrC,-1,-1);
|
---|
594 | mWGrC->SelGOMode(PI_GOXOR);
|
---|
595 | if (GetColMapId() == CMAP_COLRJ32)
|
---|
596 | mWGrC->SelForeground(PI_Yellow);
|
---|
597 | else mWGrC->SelForeground(PI_Magenta);
|
---|
598 | mWGrC->SelLine(PI_NormalLine);
|
---|
599 | if (ustrtw || atrtw) ShowTrTxW();
|
---|
600 | return;
|
---|
601 | }
|
---|
602 |
|
---|
603 | /* --Methode-- */
|
---|
604 | void PIImage::Ptr2Move(int x, int y)
|
---|
605 | {
|
---|
606 | int xp, yp;
|
---|
607 | if (img == NULL) return;
|
---|
608 | if (xmv0 < 0) return;
|
---|
609 | if ( PosW2Img(x, y, &xp, &yp) ) return;
|
---|
610 | mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
|
---|
611 | dxmv = x-xmv0; dymv = y-ymv0;
|
---|
612 | mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
|
---|
613 |
|
---|
614 | {
|
---|
615 | char buff[256];
|
---|
616 | double x,y;
|
---|
617 | img->XYCoord(xp, yp, x, y);
|
---|
618 | sprintf(buff," X= %g , Y= %g Pix= %g (C= %d,%d) ",
|
---|
619 | x, y , (*img)(xp, yp), (xp+xpv0)/2, (yp+ypv0)/2 );
|
---|
620 | if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
|
---|
621 | else DrawInfo(mWGrC, buff);
|
---|
622 | }
|
---|
623 |
|
---|
624 | return;
|
---|
625 | }
|
---|
626 |
|
---|
627 | /* --Methode-- */
|
---|
628 | void PIImage::But2Release(int x, int y)
|
---|
629 | {
|
---|
630 | int xp2, yp2;
|
---|
631 |
|
---|
632 | if (img == NULL) return;
|
---|
633 | if (xmv0 < 0) return;
|
---|
634 | mWGrC->DrawBox(xmv0, ymv0, dxmv, dymv);
|
---|
635 | mWGrC->SelGOMode(PI_GOCopy);
|
---|
636 | mWGrC->SelForeground(PI_White);
|
---|
637 | if ( PosW2Img(x, y, &xp2, &yp2) )
|
---|
638 | PosW2Img(xmv0+dxmv, ymv0+dymv, &xp2, &yp2);
|
---|
639 | xpav = (xpv0+xp2)/2;
|
---|
640 | ypav = (ypv0+yp2)/2;
|
---|
641 | xszpav = ((xp2-xpv0) > 0) ? (xp2-xpv0) : 1;
|
---|
642 | yszpav = ((yp2-ypv0) > 0) ? (yp2-ypv0) : 1;
|
---|
643 |
|
---|
644 | Apply(false);
|
---|
645 | if (curshow) DrawCursor(mWGrC);
|
---|
646 | if (ustrtw || atrtw) trtw->Hide();
|
---|
647 | else if (!showinfo) DrawInfo(mWGrC, NULL);
|
---|
648 | return;
|
---|
649 | }
|
---|
650 |
|
---|
651 |
|
---|
652 | /* --Methode-- */
|
---|
653 | void PIImage::But3Press(int x, int y)
|
---|
654 | {
|
---|
655 | int xp, yp;
|
---|
656 |
|
---|
657 | Send(Msg(), PIMsg_Active);
|
---|
658 | cur_piimage = this;
|
---|
659 | PIDrwTools::SetCurrentBaseWdg(this);
|
---|
660 | if (img == NULL) return;
|
---|
661 | if ( PosW2Img(x, y, &xp, &yp) ) { xmv0 = -1; return; }
|
---|
662 | if (curshow) DrawCursor(mWGrC,-1,-1);
|
---|
663 | if (ustrtw || atrtw) ShowTrTxW();
|
---|
664 | SelPointerShape(PI_TDLRArrowPointer);
|
---|
665 | xmv0 = xp;
|
---|
666 | ymv0 = yp;
|
---|
667 | return;
|
---|
668 | }
|
---|
669 |
|
---|
670 |
|
---|
671 | /* --Methode-- */
|
---|
672 | void PIImage::Ptr3Move(int x, int y)
|
---|
673 | {
|
---|
674 | int xp, yp;
|
---|
675 | if (img == NULL) return;
|
---|
676 | if (xmv0 < 0) return;
|
---|
677 | if ( PosW2Img(x, y, &xp, &yp) ) return;
|
---|
678 |
|
---|
679 | char buff[256];
|
---|
680 | sprintf(buff," DelX= %d , DelY= %d ", xp-xmv0, yp-ymv0);
|
---|
681 | if (ustrtw || atrtw) trtlb->SetLabel((string)buff);
|
---|
682 | else DrawInfo(mWGrC, buff);
|
---|
683 | }
|
---|
684 |
|
---|
685 | /* --Methode-- */
|
---|
686 | void PIImage::But3Release(int x, int y)
|
---|
687 | {
|
---|
688 | int xp, yp;
|
---|
689 |
|
---|
690 | SelPointerShape(PI_ArrowPointer);
|
---|
691 | if (ustrtw || atrtw) trtw->Hide();
|
---|
692 | if (img == NULL) return;
|
---|
693 | if (xmv0 < 0) return;
|
---|
694 | if ( PosW2Img(x, y, &xp, &yp) ) return;
|
---|
695 |
|
---|
696 | offx -= (xp-xmv0);
|
---|
697 | offy -= (yp-ymv0);
|
---|
698 |
|
---|
699 | if (offx < 0) offx = 0;
|
---|
700 | if (offy < 0) offy = 0;
|
---|
701 | if (offx >= img->XSize()) offx = img->XSize();
|
---|
702 | if (offy >= img->YSize()) offy = img->YSize();
|
---|
703 | xpav = xmv0; ypav = ymv0;
|
---|
704 | xmv0 = ymv0 = -1;
|
---|
705 | Apply();
|
---|
706 | return;
|
---|
707 | }
|
---|
708 |
|
---|
709 |
|
---|
710 | /* --Methode-- */
|
---|
711 | void PIImage::PasteSelection(unsigned int typ, void *pdata, unsigned int l)
|
---|
712 | {
|
---|
713 | if (!img) return;
|
---|
714 | if (typ != PICP_string) return;
|
---|
715 | int ll = (l<256) ? l+1 : 256;
|
---|
716 | char pc[256];
|
---|
717 | strncpy(pc, (char*)pdata, ll-1); pc[ll-1] = '\0';
|
---|
718 | double fx, fy;
|
---|
719 | img->Coord(xpav, ypav, fx, fy);
|
---|
720 | mdrw->ElAddText(fx, fy, pc );
|
---|
721 | mdrw->Refresh();
|
---|
722 | }
|
---|
723 |
|
---|
724 | /* --Methode-- */
|
---|
725 | void * PIImage::ProvideSelection(unsigned int& typ, unsigned int& len)
|
---|
726 | {
|
---|
727 | typ = PICP_string;
|
---|
728 | len = cpbuflen;
|
---|
729 | return(cpbuffer);
|
---|
730 | }
|
---|
731 |
|
---|
732 | /* --Methode-- */
|
---|
733 | void PIImage::SelectionLost()
|
---|
734 | {
|
---|
735 | if (cpbuffer) delete[] cpbuffer;
|
---|
736 | cpbuffer = NULL;
|
---|
737 | cpbuflen = 0;
|
---|
738 | return;
|
---|
739 | }
|
---|
740 |
|
---|
741 |
|
---|
742 |
|
---|
743 | /* --Methode-- */
|
---|
744 | void PIImage::ComputePixmap()
|
---|
745 | {
|
---|
746 | unsigned int xwsz, ywsz;
|
---|
747 |
|
---|
748 | if (img == NULL) return;
|
---|
749 | xwsz = XSize();
|
---|
750 | ywsz = YSize();
|
---|
751 |
|
---|
752 | pixm = img->ComputePixmap(lut, offx, offy, zoom, xwsz, ywsz, pixm, &xspxm, &yspxm);
|
---|
753 | int xw1, yw1, xw2, yw2;
|
---|
754 | xw1 = (xwsz-xspxm)/2;
|
---|
755 | if (xw1 < 0) xw1 = 0;
|
---|
756 | yw1 = (ywsz-yspxm)/2;
|
---|
757 | if (yw1 < 0) yw1 = 0;
|
---|
758 | xw2 = xspxm+xw1;
|
---|
759 | yw2 = yspxm+yw1;
|
---|
760 | SetDefaultDrawRectangle(xw1, yw1, xw2, yw2, false);
|
---|
761 | // printf("--DBG-- ComputePixmap() %d %d $ %d %d :: %d %d , %d %d \n", xwsz, ywsz, xspxm, yspxm, xw1, yw1, xw2, yw2);
|
---|
762 | int x1,y1, x2,y2;
|
---|
763 | ofx = xw1; ofy = yw1;
|
---|
764 | PosW2Img(xw1, yw1, &x1, &y1);
|
---|
765 | PosW2Img(xw2, yw2, &x2, &y2);
|
---|
766 | double fx1,fy1, fx2, fy2;
|
---|
767 | img->Coord(x1,y1, fx1, fy2); // fy1 et fy2 echange expres pour utiliser kAxeDirAuto
|
---|
768 | img->Coord(x2,y2, fx2, fy1); // En effet Image de haut vers bas, Axes de bas vers haut par defaut
|
---|
769 | SetDefaultDrawerLimits(fx1, fx2, fy1, fy2, kAxeDirAuto, kAxeDirAuto);
|
---|
770 | // printf("--DBG2-- ComputePixmap() %g %g %g %g \n", fx1, fx2, fy1, fy2);
|
---|
771 | xcurs = ycurs = -1;
|
---|
772 | SetPixmap(pixm, xspxm, yspxm, true, xw1, yw1);
|
---|
773 | // Refresh();
|
---|
774 | return;
|
---|
775 | }
|
---|
776 |
|
---|
777 |
|
---|
778 | /* --Methode-- */
|
---|
779 | void PIImage::ComputeZoomPixmap()
|
---|
780 | {
|
---|
781 | unsigned int xwsz, ywsz;
|
---|
782 | int lofx, lofy;
|
---|
783 | int zm;
|
---|
784 |
|
---|
785 | if (zow == NULL) return;
|
---|
786 | if (img == NULL) return;
|
---|
787 |
|
---|
788 | xwsz = zow->XSize();
|
---|
789 | ywsz = zow->YSize();
|
---|
790 |
|
---|
791 | zm = zoom+4;
|
---|
792 | if ( (zm==-1) || (zm == 0) ) zm = 1;
|
---|
793 | if (zm > 0)
|
---|
794 | {
|
---|
795 | lofx = xpav-(xwsz/2/zm);
|
---|
796 | lofy = ypav-(ywsz/2/zm);
|
---|
797 | }
|
---|
798 | else
|
---|
799 | {
|
---|
800 | lofx = xpav+(xwsz*zm/2);
|
---|
801 | lofy = ypav+(ywsz*zm/2);
|
---|
802 | }
|
---|
803 | if (lofx < 0) lofx = 0;
|
---|
804 | if (lofy < 0) lofy = 0;
|
---|
805 |
|
---|
806 | zpixm = img->ComputePixmap(lut, lofx, lofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm);
|
---|
807 | zow->SetColMap(cmap, false);
|
---|
808 | zow->SetPixmap(zpixm, xszpxm, yszpxm);
|
---|
809 | zow->SetUserData((void *)this, 0);
|
---|
810 | // zow->Refresh();
|
---|
811 | return;
|
---|
812 |
|
---|
813 | }
|
---|
814 |
|
---|
815 |
|
---|
816 | /* --Methode-- */
|
---|
817 | void PIImage::ComputeGloVPixmap()
|
---|
818 | {
|
---|
819 | unsigned int xwsz, ywsz;
|
---|
820 | int zmx,zmy;
|
---|
821 |
|
---|
822 | if (gvw == NULL) return;
|
---|
823 | if (img == NULL) return;
|
---|
824 |
|
---|
825 | xwsz = gvw->XSize();
|
---|
826 | ywsz = gvw->YSize();
|
---|
827 |
|
---|
828 | zmx = img->XSize()/xwsz;
|
---|
829 | zmy = img->YSize()/ywsz;
|
---|
830 |
|
---|
831 | if (zmx < zmy) zmx = zmy;
|
---|
832 | if (zmx < 1) zmx = 1;
|
---|
833 | zmgv = zmx;
|
---|
834 | if (zmx > 1) zmx = -zmx;
|
---|
835 | gpixm = img->ComputePixmap(lut, 0, 0, zmx, xwsz, ywsz, gpixm, &xsgpxm, &ysgpxm);
|
---|
836 | // printf("DEBUG-ComputeGloVPixmap() %d-%d , (%d,%d) , %d-%d \n", xwsz, ywsz, zmx, zmy, xsgpxm, ysgpxm);
|
---|
837 | return;
|
---|
838 | }
|
---|
839 |
|
---|
840 | /* --Methode-- */
|
---|
841 | void PIImage::SetGloVPixmap()
|
---|
842 | {
|
---|
843 | float zm;
|
---|
844 | int x,y, dx,dy;
|
---|
845 |
|
---|
846 | int xw1, yw1, xw2, yw2;
|
---|
847 | xw1 = (gvw->XSize()-xsgpxm)/2;
|
---|
848 | if (xw1 < 0) xw1 = 0;
|
---|
849 | yw1 = (gvw->YSize()-ysgpxm)/2;
|
---|
850 | if (yw1 < 0) yw1 = 0;
|
---|
851 | xw2 = xsgpxm+xw1;
|
---|
852 | yw2 = ysgpxm+yw1;
|
---|
853 |
|
---|
854 | if (zoom > 0) zm = zmgv*zoom;
|
---|
855 | else zm = (float)zmgv/(float)(-zoom);
|
---|
856 | x = offx/zmgv+1+xw1;
|
---|
857 | y = offy/zmgv+1+yw1;
|
---|
858 | dx = (int) ( (float)XSize()/zm-1. );
|
---|
859 | dy = (int) ( (float)YSize()/zm-1. );
|
---|
860 |
|
---|
861 | gvw->DeleteDrawers();
|
---|
862 | gvdrw->ElDelAll();
|
---|
863 | gvdrw->SetLimits(xw1, xw2, yw1, yw2, kAxeDirLtoR, kAxeDirUpDown);
|
---|
864 | int cmapid = cmap->Type();
|
---|
865 | if ( (cmapid == CMAP_GREY32) || (cmapid == CMAP_GREYINV32) ||
|
---|
866 | (cmapid == CMAP_GREY128) || (cmapid == CMAP_GREYINV128)) gvdrw->SetColAtt(PI_Red);
|
---|
867 | else gvdrw->SetColAtt(PI_Yellow);
|
---|
868 | gvdrw->SetLineAtt(PI_NormalLine);
|
---|
869 | gvdrw->ElAddRect(x,y,dx,dy);
|
---|
870 | gvw->AddDrawer(gvdrw, xw1, yw1, xw2, yw2, false);
|
---|
871 | gvw->SetColMap(cmap, false);
|
---|
872 | gvw->SetPixmap(gpixm, xsgpxm, ysgpxm, true, xw1, yw1);
|
---|
873 | gvw->SetUserData((void *)this, 0);
|
---|
874 | gvw->SetMsg(Msg()+626);
|
---|
875 | gvw->SetMsgParent(this);
|
---|
876 |
|
---|
877 | return;
|
---|
878 | }
|
---|
879 |
|
---|
880 | /* --Methode-- */
|
---|
881 | void PIImage::DrawCursor(PIGraphic* g)
|
---|
882 | {
|
---|
883 | int xc, yc;
|
---|
884 | if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(g, -1, -1);
|
---|
885 | else DrawCursor(g, xc, yc);
|
---|
886 | return;
|
---|
887 | }
|
---|
888 |
|
---|
889 | #define CURSHSIZE 25
|
---|
890 |
|
---|
891 | /* --Methode-- */
|
---|
892 | void PIImage::DrawCursor(PIGraphic* g, int xc, int yc)
|
---|
893 | {
|
---|
894 |
|
---|
895 | if (winovis) return; // $CHECK$ Reza A enlever si possible 17/6/96
|
---|
896 |
|
---|
897 | g->SelGOMode(PI_GOCopy);
|
---|
898 | if ( (GetColMapId() == CMAP_GREY32) || (GetColMapId() == CMAP_GREYINV32) ||
|
---|
899 | (GetColMapId() == CMAP_GREY128) || (GetColMapId() == CMAP_GREYINV128) ) g->SelForeground(PI_Red);
|
---|
900 | else g->SelForeground(PI_White);
|
---|
901 |
|
---|
902 | if (zoom < 3) g->SelLine(PI_NormalLine);
|
---|
903 | else g->SelLine(PI_ThickLine);
|
---|
904 |
|
---|
905 | if ((xcurs>=0) && (ycurs>=0) && (g->kind() != PI_PSFileGraphics ) ) {
|
---|
906 | PIPixmap::Draw(g, xcurs-3, ycurs-CURSHSIZE, 6, CURSHSIZE*2);
|
---|
907 | PIPixmap::Draw(g, xcurs-CURSHSIZE, ycurs-3, CURSHSIZE*2, 6);
|
---|
908 | }
|
---|
909 | if ((xc >= 0) && (yc >= 0))
|
---|
910 | {
|
---|
911 | xcurs = xc; ycurs = yc;
|
---|
912 | g->DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs);
|
---|
913 | g->DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs);
|
---|
914 | g->DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4);
|
---|
915 | g->DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE);
|
---|
916 | }
|
---|
917 | else { xcurs = ycurs = -1; }
|
---|
918 |
|
---|
919 | g->SelGOMode(PI_GOCopy);
|
---|
920 | g->SelLine(PI_NormalLine);
|
---|
921 | g->SelForeground(PI_White);
|
---|
922 | return;
|
---|
923 | }
|
---|
924 |
|
---|
925 |
|
---|
926 | /* --Methode-- */
|
---|
927 | void PIImage::DrawInfo(PIGraphic* g, char* txt)
|
---|
928 | {
|
---|
929 | g->SelFont(PI_NormalSizeFont, PI_RomanFont);
|
---|
930 | if (txt) {
|
---|
931 | PIColors fgc = g->GetForeground();
|
---|
932 | PIGOMode gm = g->GetGOMode();
|
---|
933 | g->SelGOMode(PI_GOCopy);
|
---|
934 | g->SelForeground(PI_White);
|
---|
935 | g->SelBackground(PI_Black);
|
---|
936 | g->DrawOpaqueString(20, YSize()-5, txt);
|
---|
937 | g->SelGOMode(gm);
|
---|
938 | g->SelForeground(fgc);
|
---|
939 | }
|
---|
940 | else {
|
---|
941 | int a,d,h;
|
---|
942 | h = g->GetFontHeight(a, d);
|
---|
943 | if (g->kind() != PI_PSFileGraphics ) PIPixmap::Draw(g, 0, YSize()-10-h, XSize(), h+10);
|
---|
944 | }
|
---|
945 | return;
|
---|
946 | }
|
---|
947 |
|
---|
948 | /* --Methode-- */
|
---|
949 | void PIImage::ShowTrTxW()
|
---|
950 | {
|
---|
951 | if (trtw)
|
---|
952 | {
|
---|
953 | int tpx, tpy;
|
---|
954 | GetScreenPos(tpx, tpy);
|
---|
955 | tpy -= (trtw->YSize()+5);
|
---|
956 | if (tpy < 0) tpy = 0;
|
---|
957 | trtw->SetPos(tpx, tpy);
|
---|
958 | trtw->Show();
|
---|
959 | }
|
---|
960 |
|
---|
961 | return;
|
---|
962 | }
|
---|
963 |
|
---|
964 | /* --Methode-- */
|
---|
965 | int PIImage::PosW2Img(int xiw, int yiw, int * xp, int * yp)
|
---|
966 | {
|
---|
967 | if (!img) { *xp = *yp = 0; return(1); }
|
---|
968 | xiw -= ofx; yiw -= ofy; // Offset d'affichage du pixmap
|
---|
969 | if (zoom > 0)
|
---|
970 | {
|
---|
971 | *xp = xiw/zoom+offx;
|
---|
972 | *yp = yiw/zoom+offy;
|
---|
973 | }
|
---|
974 | else
|
---|
975 | {
|
---|
976 | *xp = offx-xiw*zoom;
|
---|
977 | *yp = offy-yiw*zoom;
|
---|
978 | }
|
---|
979 |
|
---|
980 | if ( (*xp >= 0) && (*xp < img->XSize() ) &&
|
---|
981 | (*yp >= 0) && (*yp < img->YSize() ) ) return(0);
|
---|
982 | else return(1);
|
---|
983 | }
|
---|
984 |
|
---|
985 |
|
---|
986 | /* --Methode-- */
|
---|
987 | int PIImage::PosImg2W(int xp, int yp, int * xiw, int * yiw)
|
---|
988 | {
|
---|
989 | if (!img) { *xiw = *yiw = -1; return(1); }
|
---|
990 | if (zoom > 0)
|
---|
991 | {
|
---|
992 | *xiw = (xp-offx)*zoom+(zoom/2);
|
---|
993 | *yiw = (yp-offy)*zoom+(zoom/2);
|
---|
994 | }
|
---|
995 | else
|
---|
996 | {
|
---|
997 | *xiw = (offx-xp)/zoom;
|
---|
998 | *yiw = (offy-yp)/zoom;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | *xiw += ofx; *yiw += ofy; // Offset d'affichage du pixmap
|
---|
1002 | if (*xiw > XSize()) *xiw = -1;
|
---|
1003 | if (*yiw > YSize()) *yiw = -1;
|
---|
1004 |
|
---|
1005 | if ((*xiw < 0) || (*yiw < 0)) return(1);
|
---|
1006 | else return(0);
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 |
|
---|
1010 | /* --Methode-- */
|
---|
1011 | void PIImage::SetOffsetFromPave()
|
---|
1012 | {
|
---|
1013 | if (!img) { offx = offy = 0; return; }
|
---|
1014 | if (zoom > 0)
|
---|
1015 | {
|
---|
1016 | offx = xpav-XSize()/2/zoom;
|
---|
1017 | offy = ypav-YSize()/2/zoom;
|
---|
1018 | }
|
---|
1019 | else
|
---|
1020 | {
|
---|
1021 | offx = xpav+XSize()/2*zoom;
|
---|
1022 | offy = ypav+YSize()/2*zoom;
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | if (offx < 0) offx = 0;
|
---|
1026 | if (offx >= (img->XSize()-1)) offx = img->XSize()-2;
|
---|
1027 | if (offy < 0) offy = 0;
|
---|
1028 | if (offy >= (img->YSize()-1)) offy = img->YSize()-2;
|
---|
1029 |
|
---|
1030 | return;
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 | /* --Methode-- */
|
---|
1034 | void PIImage::CenterPave()
|
---|
1035 | {
|
---|
1036 | int xwsz, ywsz;
|
---|
1037 |
|
---|
1038 | if (zoom > 0)
|
---|
1039 | { xwsz = XSize()/zoom;
|
---|
1040 | ywsz = YSize()/zoom; }
|
---|
1041 | else
|
---|
1042 | { xwsz = -(XSize()*zoom);
|
---|
1043 | ywsz = -(YSize()*zoom); }
|
---|
1044 |
|
---|
1045 | if (img) {
|
---|
1046 | if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx);
|
---|
1047 | if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy);
|
---|
1048 | }
|
---|
1049 | xpav = offx+xwsz/2;
|
---|
1050 | ypav = offx+ywsz/2;
|
---|
1051 | xszpav = ((xwsz+ywsz)/20) ;
|
---|
1052 | if (xszpav < 1) xszpav = 1;
|
---|
1053 | yszpav = xszpav;
|
---|
1054 |
|
---|
1055 | return;
|
---|
1056 | }
|
---|