Changeset 9 in Sophya
- Timestamp:
- Mar 6, 1996, 11:52:37 PM (30 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 2 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Makefile
r8 r9 77 77 #------------------------------------------------- End of Makefile.h ------- 78 78 79 all: $(LIB)libPI.a $(SLB)libPI.so80 $(LIB)libPI.a : $(OBJ)ex_dessin.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piw dgxt.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)sc_sample.o79 all: $(LIB)libPI.a 80 $(LIB)libPI.a : $(OBJ)ex_dessin.o $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o 81 81 ar -rs $@ $? 82 83 $(SLB)libPI.so : $(LIB)libPI.a 84 ld -S -shared -o $(SLB)libPI.so -all -L$(LIB) $(LIB)libPI.a 2>/dev/null 82 85 83 $(OBJ)ex_dessin.o: ex_dessin.cc ex_dessin.h pisysdep.h pibwdgx.h pibwdggen.h \ 86 84 piwdgx.h piwdggen.h pimsghandler.h … … 170 168 $(OBJ)piwdgx.o: piwdgx.cc piwdgx.h piwdggen.h pimsghandler.h picontainerx.h \ 171 169 pisysdep.h picontainergen.h 172 $(OBJ)piwdgxt.o: piwdgxt.cc piwdggen.h pimsghandler.h picontainergen.h \173 pisysdep.h piwdgx.h174 170 $(OBJ)piwindowgen.o: piwindowgen.cc piwindowgen.h pisysdep.h picontainerx.h \ 175 171 picontainergen.h piwdgx.h piwdggen.h pimsghandler.h … … 213 209 $(INC)fitskeys.h \ 214 210 $(INC)utils.h $(INC)peida.h 211 215 212 piapp : $(EXE)piapp 216 213 217 $(EXE)piapp : $(OBJ)pidemo.o $(OBJ)pidemoup.o $(LIB)libPI.a 218 g++ -o $(EXE)piapp $(OBJ)pidemo.o $(OBJ)pidemoup.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm 214 $(EXE)piapp : $(OBJ)pidemo.o $(OBJ)pidemoup.o \ 215 $(SLB)libPI.so $(SLB)libpeida.so $(SLB)liberosc.so 216 cc -o $(EXE)piapp $(OBJ)pidemo.o $(OBJ)pidemoup.o \ 217 -L$(SLB) -lPI -lpeida -lerosc -lgcxx -lXm -lXt -lX11 -lm 219 218 220 219 $(OBJ)pitestapp.o: pitestapp.cc pisysdep.h piapplx.h piapplgen.h \ … … 235 234 236 235 $(EXE)pitest : $(OBJ)pitestapp.o $(LIB)libPI.a 237 g++ - o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm236 g++ -v -o $(EXE)pitest $(OBJ)pitestapp.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm -
trunk/SophyaPI/PI/ex_dessin.cc
r2 r9 64 64 SelLine(PI_ThickLine); 65 65 DrawLine(70, 120, 100, 120); 66 67 SelForeground(PI_Magenta); 68 DrawFCircle(120, 30, 15); 69 SelForeground(PI_Grey); 70 DrawFCircle(120, 60, 15); 66 71 67 72 return; -
trunk/SophyaPI/PI/pi.rsc
r7 r9 1 PeidaInt*activeBackground: LightBlue2 PeidaInt*default*activeBackground: LightBlue3 PeidaInt*activeBottomShadowColor: Black4 PeidaInt*default*activeBottomShadowColor: Black5 PeidaInt*activeForeground: LightBlue6 PeidaInt*default*activeForeground: LightBlue7 PeidaInt*default*highlightColor: LightBlue8 PeidaInt*activeTopShadowColor: White9 PeidaInt*default*activeTopShadowColor: White10 1 PeidaInt*background: LightGrey 11 2 PeidaInt*default*background: LightGrey … … 31 22 PeidaInt*fontList: -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1 32 23 PeidaInt*default*fontList: -*-helvetica-bold-r-normal-*-12-*-*-*-*-*-ISO8859-1 33 PidaInt*fontList: -*-*-Bold-*-*-*-12-*-*-*-*-*-*-* 34 PidaInt*default*fontList: -*-*-Bold-*-*-*-12-*-*-*-*-*-*-* 24 25 # Attention, ne pas mettre de blanc a la fin du nom de fonte 26 PeidaInt*fontFamilyName: *-helvetica 35 27 36 28 PeidaInt*XmToggleButton*selectColor: Red -
trunk/SophyaPI/PI/pibwdggen.h
r8 r9 9 9 enum PIKeyModifier { PIKM_Blank = 0, PIKM_Shift = 1, PIKM_Alt = 2, PIKM_Cntl = 4 } ; 10 10 11 enum PIColors { PI_Black = 0, PI_White = 1, 12 PI_Red = 2, PI_Blue = 3, PI_Green = 4,13 PI_Yellow = 5 11 enum PIColors { PI_Black = 0, PI_White = 1, PI_Grey = 2, 12 PI_Red = 3, PI_Blue = 4, PI_Green = 5, 13 PI_Yellow = 5, PI_Magenta =6} ; 14 14 enum PIFontSize {PI_SmallSizeFont = 1, PI_NormalSizeFont = 2, PI_BigSizeFont = 3 }; 15 15 enum PIFontAtt {PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 }; … … 47 47 virtual void DrawFCircle(int x0, int y0, int r) = 0; 48 48 49 virtual int CalcStringWidth(char const* s) = 0; 50 49 51 virtual void SelForeground(PIColors col=PI_Black) = 0; 50 52 virtual void SelBackground(PIColors col=PI_White) = 0; -
trunk/SophyaPI/PI/pibwdgmac.cc
r2 r9 4 4 #include "pibwdgmac.h" 5 5 #include "piupdattachment.h" 6 #include <algobase.h> 7 #include <string.h> 6 8 7 9 // Les methodes de la classe PIBWdgGen … … 63 65 ::MoveTo(pt.h, pt.v); 64 66 LStr255 ps = s; 67 ::TextFont(applFont); 65 68 ::DrawString(ps); 66 69 } 67 70 } 71 72 73 /* --Methode-- */ 74 int PIBaseWdgMac::CalcStringWidth(char const* s) 75 { 76 if (mPane->FocusDraw()) 77 ::TextFont(applFont); 78 return ::TextWidth(s,0,strlen(s)); 79 } 80 68 81 69 82 /* --Methode-- */ … … 87 100 mPane->LocalToPortPoint(pt); 88 101 Rect r = {pt.v, pt.h, pt.v+dy, pt.h+dx}; 102 if (r.top > r.bottom) swap(r.top, r.bottom); 103 if (r.left > r.right) swap(r.left, r.right); 104 r.right++; r.bottom++; 89 105 ::FrameRect(&r); 90 106 } … … 99 115 mPane->LocalToPortPoint(pt); 100 116 Rect r = {pt.v, pt.h, pt.v+dy, pt.h+dx}; 117 if (r.top > r.bottom) swap(r.top, r.bottom); 118 if (r.left > r.right) swap(r.left, r.right); 119 r.right++; r.bottom++; 101 120 ::PaintRect(&r); 102 121 } … … 110 129 mPane->LocalToPortPoint(pt); 111 130 Rect rr = {pt.v-r, pt.h-r, pt.v+r, pt.h+r}; 131 if (rr.top > rr.bottom) swap(rr.top, rr.bottom); 132 if (rr.left > rr.right) swap(rr.left, rr.right); 112 133 ::FrameOval(&rr); 113 134 } … … 121 142 mPane->LocalToPortPoint(pt); 122 143 Rect rr = {pt.v-r, pt.h-r, pt.v+r, pt.h+r}; 144 if (rr.top > rr.bottom) swap(rr.top, rr.bottom); 145 if (rr.left > rr.right) swap(rr.left, rr.right); 123 146 ::PaintOval(&rr); 124 147 } … … 191 214 { 192 215 if (mPane->FocusDraw()) { 216 ::TextFont(applFont); 193 217 switch(sz) { 194 218 case PI_SmallSizeFont: … … 202 226 break; 203 227 } 228 switch(att) { 229 case PI_RomanFont: 230 ::TextFace(0); 231 break; 232 case PI_BoldFont: 233 ::TextFace(bold); 234 break; 235 case PI_ItalicFont: 236 ::TextFace(italic); 237 break; 238 } 239 } 240 } 241 242 /* --Methode-- */ 243 void PIBaseWdgMac::SelFontSzPt(int npt, PIFontAtt att) 244 { 245 if (mPane->FocusDraw()) { 246 ::TextFont(applFont); 247 ::TextSize(npt); 204 248 switch(att) { 205 249 case PI_RomanFont: -
trunk/SophyaPI/PI/pibwdgmac.h
r2 r9 32 32 virtual void DrawCircle(int x0, int y0, int r); 33 33 virtual void DrawFCircle(int x0, int y0, int r); 34 virtual int CalcStringWidth(char const* s); 34 35 35 36 virtual void SelForeground(PIColors col=PI_White); … … 37 38 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, 38 39 PIFontAtt att=PI_RomanFont); 40 virtual void SelFontSzPt(int npt=12, PIFontAtt att=PI_RomanFont); 39 41 virtual void SelLine(PILineAtt att=PI_NormalLine); 40 42 virtual void SelPointerShape(PIPointer ptr); -
trunk/SophyaPI/PI/pibwdgx.cc
r8 r9 16 16 /* Variables globales pour modifier les GC */ 17 17 #define NMAXFONTSZ 5 18 static Font fnt[NMAXFONTSZ][3];19 static int fntsz[NMAXFONTSZ] = { 9,10,12,14,16};18 static XFontStruct * fntst[NMAXFONTSZ][3]; 19 static int fntsz[NMAXFONTSZ] = {7,10,12,14,16}; 20 20 static PIFontAtt fntatt[3] = { PI_RomanFont, PI_BoldFont, PI_ItalicFont }; 21 21 #define NMAXCOL 10 … … 182 182 } 183 183 184 /* --Methode-- */ 185 int PIBaseWdgX::CalcStringWidth(char const* s) 186 { 187 return(XTextWidth(mFSt, s, strlen(s))); 188 } 184 189 185 190 /* --Methode-- */ … … 254 259 mFAtt = fntatt[jat]; 255 260 mFSize = fntsz[isz]; 256 XSetFont(XtDisplay(XtWdg()), DefGC(), fnt[isz][jat]); 261 mFSt = fntst[isz][jat]; 262 XSetFont(XtDisplay(XtWdg()), DefGC(), fntst[isz][jat]->fid); 257 263 return; 258 264 } … … 319 325 320 326 /* --Methode-- */ 321 void PIBaseWdgX::Draw(int x0, int y0, int dx, int dy)327 void PIBaseWdgX::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 322 328 { 323 329 this->Draw(); … … 374 380 375 381 /* --Methode-- */ 376 void PIBaseWdgX::But2Press(int x, int y)377 { 378 return; 379 } 380 381 /* --Methode-- */ 382 void PIBaseWdgX::But2Release(int x, int y)383 { 384 return; 385 } 386 387 /* --Methode-- */ 388 void PIBaseWdgX::But3Press(int x, int y)389 { 390 return; 391 } 392 393 /* --Methode-- */ 394 void PIBaseWdgX::But3Release(int x, int y)395 { 396 return; 397 } 398 399 400 /* --Methode-- */ 401 void PIBaseWdgX::Ptr1Move(int x, int y)382 void PIBaseWdgX::But2Press(int /* x */, int /* y */) 383 { 384 return; 385 } 386 387 /* --Methode-- */ 388 void PIBaseWdgX::But2Release(int /* x */, int /* y */) 389 { 390 return; 391 } 392 393 /* --Methode-- */ 394 void PIBaseWdgX::But3Press(int /* x */, int /* y */) 395 { 396 return; 397 } 398 399 /* --Methode-- */ 400 void PIBaseWdgX::But3Release(int /* x */, int /* y */) 401 { 402 return; 403 } 404 405 406 /* --Methode-- */ 407 void PIBaseWdgX::Ptr1Move(int x, int y ) 402 408 { 403 409 #ifdef DEBUG_PIBWDGX … … 408 414 409 415 /* --Methode-- */ 410 void PIBaseWdgX::Ptr2Move(int x, int y)411 { 412 return; 413 } 414 415 416 /* --Methode-- */ 417 void PIBaseWdgX::Ptr3Move(int x, int y)416 void PIBaseWdgX::Ptr2Move(int /* x */, int /* y */) 417 { 418 return; 419 } 420 421 422 /* --Methode-- */ 423 void PIBaseWdgX::Ptr3Move(int /* x */, int /* y */) 418 424 { 419 425 return; … … 434 440 static bool fgbwdg = false ; 435 441 442 // Le bazar pour recuperer des resources de .Xdefault et autres 443 typedef struct 444 { 445 String fntFam; 446 } myAppData; 447 static myAppData apd; 448 449 static XtResource resources[] = { 450 { "fontFamilyName", "FontFamilyName", XtRString, sizeof(String), 451 /*XtOffset(apdp, fntFam)*/ 0, XtRString, "*-helvetica" } 452 }; 453 454 static char * fnbi_b[4] = { "medium-r-normal", "bold-r-normal", 455 "medium-o-normal", "medium-i-normal" }; 456 436 457 /* --Methode-- */ 437 458 void PIBaseWdgX::Init() 438 459 { 439 char buff[200]; 440 int i,j; 460 char buff[256]; 461 int i,j,jj,k, count; 462 char **list; 463 XFontStruct * defnt; 464 char * fnbi[3]; 441 465 442 466 if (fgbwdg) return; … … 447 471 XColor exact,mycol; 448 472 Colormap cmap; 449 Status rc;450 473 451 474 mdsp = PIXDisplay(); 452 475 scr = XDefaultScreen(mdsp); 453 476 477 XtGetApplicationResources(PIXtTopWdg(), &apd, resources, 478 XtNumber(resources), NULL, 0); 479 sprintf(buff,"-%s-*-*-*-*-*-*-*-*-*-*-*-*", apd.fntFam); 480 list = XListFonts(mdsp, buff, 15, &count); 481 XFreeFontNames(list); 482 if (count < 5) 483 { 484 printf("PIBaseWdgX::Init %d fonts found for %s , switching to helvetica\n", 485 count, apd.fntFam); 486 apd.fntFam = "*-helvetica"; 487 } 488 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[0]); 489 list = XListFonts(mdsp, buff, 10, &count); 490 XFreeFontNames(list); 491 if (count < 2) fnbi[0] = "*-*-*"; 492 else fnbi[0] = fnbi_b[0]; 493 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[1]); 494 list = XListFonts(mdsp, buff, 10, &count); 495 XFreeFontNames(list); 496 if (count < 2) fnbi[1] = "*-*-*"; 497 else fnbi[1] = fnbi_b[1]; 498 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[2]); 499 list = XListFonts(mdsp, buff, 10, &count); 500 XFreeFontNames(list); 501 fnbi[2] = fnbi_b[2]; 502 if (count < 2) 503 { 504 sprintf(buff,"-%s-%s-*-*-*-*-*-*-*-*-*", apd.fntFam, fnbi_b[3]); 505 list = XListFonts(mdsp, buff, 10, &count); 506 XFreeFontNames(list); 507 fnbi[2] = fnbi_b[3]; 508 } 509 if (count < 2) fnbi[2] = "*-*-*"; 510 511 sprintf(buff,"-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*"); 512 list = XListFonts(mdsp, buff, 10, &count); 513 XFreeFontNames(list); 514 if (count < 1) 515 { 516 sprintf(buff,"fixed"); 517 list = XListFonts(mdsp, buff, 10, &count); 518 XFreeFontNames(list); 519 } 520 if (count < 1) 521 { 522 strcpy(buff,""); 523 list = XListFonts(mdsp, buff, 10, &count); 524 XFreeFontNames(list); 525 printf("PIBaseWdgX::Init/ Erreur, no font found ... \n"); 526 defnt = NULL; 527 } 528 else defnt = XLoadQueryFont(mdsp, buff); 529 454 530 /* Allocation des fonts */ 455 531 for (i=0; i<NMAXFONTSZ; i++) 532 for (j=0; j<3; j++) 456 533 { 457 sprintf(buff,"-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]); 458 fnt[i][0] = XLoadFont(mdsp, buff); 459 if (fnt[i][0] == 0) printf("PIBaseWdgX::Init: Pb font %s \n", buff); 460 sprintf(buff,"-*-helvetica-bold-r-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]); 461 fnt[i][1] = XLoadFont(mdsp, buff); 462 if (fnt[i][0] == 0) printf("PIBaseWdgX::Init: Pb font %s \n", buff); 463 sprintf(buff,"-*-helvetica-medium-o-normal-*-%d-*-*-*-*-*-ISO8859-1", fntsz[i]); 464 fnt[i][2] = XLoadFont(mdsp, buff); 465 if (fnt[i][0] == 0) printf("PIBaseWdgX::Init: Pb font %s \n", buff); 466 } 467 468 for(i=0; i<NMAXFONTSZ; i++) 469 for(j=0; j<3; j++) 470 if (fnt[i][j] == 0) XLoadFont(mdsp, "fixed"); 534 for (k=0; k<5; k++) 535 { 536 sprintf(buff,"-%s-%s-*-%d-*-*-*-*-*-*-*", apd.fntFam, fnbi[j], fntsz[i]+k); 537 list = XListFonts(mdsp, buff, 10, &count); 538 XFreeFontNames(list); 539 if (count > 0) break; 540 } 541 if (count > 0) 542 { 543 fntst[i][j] = XLoadQueryFont(mdsp, buff); 544 // printf("PIBaseWdgX::Init: font %s loaded \n", buff); 545 } 546 else 547 { 548 printf("PIBaseWdgX::Init: Pb font %s \n", buff); 549 fntst[i][j] = defnt; 550 } 551 } 471 552 472 553 … … 477 558 colpix[PI_Black] = XBlackPixel(mdsp, scr); 478 559 colpix[PI_White] = XWhitePixel(mdsp, scr); 479 480 if ( XAllocNamedColor (mdsp, cmap, "Red", &mycol, &exact) ) 560 if ( XAllocNamedColor (mdsp, cmap, "LightGray", &mycol, &exact) ) 561 colpix[PI_Grey] = mycol.pixel; 562 if ( XAllocNamedColor (mdsp, cmap, "red", &mycol, &exact) ) 481 563 colpix[PI_Red] = mycol.pixel; 482 if ( XAllocNamedColor (mdsp, cmap, " Blue", &mycol, &exact) )564 if ( XAllocNamedColor (mdsp, cmap, "blue", &mycol, &exact) ) 483 565 colpix[PI_Blue] = mycol.pixel; 484 if ( XAllocNamedColor (mdsp, cmap, " Green", &mycol, &exact) )566 if ( XAllocNamedColor (mdsp, cmap, "green", &mycol, &exact) ) 485 567 colpix[PI_Green] = mycol.pixel; 486 if ( XAllocNamedColor (mdsp, cmap, " Yellow", &mycol, &exact) )568 if ( XAllocNamedColor (mdsp, cmap, "yellow", &mycol, &exact) ) 487 569 colpix[PI_Yellow] = mycol.pixel; 570 if ( XAllocNamedColor (mdsp, cmap, "magenta", &mycol, &exact) ) 571 colpix[PI_Magenta] = mycol.pixel; 488 572 489 573 curs[0] = XCreateFontCursor(mdsp, XC_X_cursor); -
trunk/SophyaPI/PI/pibwdgx.h
r8 r9 31 31 virtual void DrawCircle(int x0, int y0, int r); 32 32 virtual void DrawFCircle(int x0, int y0, int r); 33 34 virtual int CalcStringWidth(char const* s); 33 35 34 36 virtual void SelForeground(PIColors col=PI_Black); … … 71 73 PIFontAtt mFAtt; 72 74 int mFSize; 75 XFontStruct *mFSt; 73 76 }; 74 77 -
trunk/SophyaPI/PI/pidemo.cc
r8 r9 1 1 #include <stdlib.h> 2 2 #include <stdio.h> 3 #include <string.h> 4 #include <dlfcn.h> 3 5 4 6 #include "perrors.h" … … 6 8 7 9 #include "pidemo.h" 8 #include "pidemoup.h" 9 10 11 10 #include "piup.h" 11 12 13 /* Pour le link dynamique */ 14 typedef FitsImageR4 * (* UsPrFunc) (FitsImageR4 * myimg, int xp, int yp, 15 char * arg1, char * arg2); 16 static UsPrFunc userFunc[3] = { NULL, NULL, NULL }; 17 static void *dlhandle = NULL; 18 19 static char userlibname[256]; 20 21 static int DynLink(char *usln); 22 23 int DynLink(char *usln) 24 { 25 UsPrFunc uf; 26 int i, rc; 27 28 if (usln != NULL) strncpy(userlibname, usln, 255); userlibname[255] = '\0'; 29 30 printf("PIDemo_DynLink(): Relinking from %s \n", userlibname); 31 if (dlhandle != NULL) dlclose(dlhandle); 32 for(i=0; i<3; i++) userFunc[i] = NULL; 33 dlhandle = dlopen(userlibname, RTLD_NOW); 34 if (dlhandle == NULL) 35 { printf("PIDemo_DynLink(), Erreur d'ouverture UserShLib %s \n", userlibname); 36 return(100); } 37 rc = 0; 38 printf("PIDemo_DynLink(): Searching for PIUserProc_1 (Rc=%d) \n", rc); 39 uf = dlsym(dlhandle, "PIUserProc_1__FPt9FitsImage1ZfiiPcT3"); 40 if (uf != NULL) userFunc[0] = uf; 41 else rc += 2; 42 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 43 uf = dlsym(dlhandle, "PIUserProc_2__FPt9FitsImage1ZfiiPcT3"); 44 if (uf != NULL) userFunc[1] = uf; 45 else rc += 4; 46 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 47 uf = dlsym(dlhandle, "PIUserProc_3__FPt9FitsImage1ZfiiPcT3"); 48 if (uf != NULL) userFunc[2] = uf; 49 else rc += 8; 50 51 if (rc != 0) printf("PIDemo_DynLink() / Erreur, Rc = %d \n", rc); 52 return(rc); 53 } 12 54 13 55 /* ........................................................... */ … … 28 70 m[0]->AppendItem("Close", 10102); 29 71 m[0]->AppendItem("Save", 10103); 30 m[0]->AppendItem("Exit", 10104); 72 m[0]->AppendItem("Relink", 10104); 73 m[0]->AppendItem("Exit", 10105); 31 74 32 75 m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Image"); … … 188 231 189 232 case 10104: 233 SetBusy(); 234 DynLink(NULL); 235 SetReady(); 236 break; 237 238 case 10105: 190 239 Stop(); 191 240 break; … … 407 456 int n; 408 457 if ((n=GetNumCurrent()) < 0) return; 458 zoom->SetPixmap(NULL,0,0); 459 zoom->EraseWindow(); 460 labimg->SetLabel(""); 409 461 wpii[n]->Hide(); 410 462 delete pii[n]; 411 463 delete img[n]; 412 464 delete wpii[n]; 413 zoom->EraseWindow(); 414 labimg->SetLabel(""); 415 pii[n] = pii[mNimg]; 416 wpii[n] = wpii[mNimg]; 417 img[n] = img[mNimg]; 465 pii[n] = pii[mNimg-1]; 466 wpii[n] = wpii[mNimg-1]; 467 img[n] = img[mNimg-1]; 418 468 mNimg--; 419 469 mCur = NULL; … … 648 698 { 649 699 case 1 : 650 oimg = PIUserProc_1(mimg, xp, yp, 700 case 2 : 701 case 3 : 702 oimg = userFunc[mUpr-1] (mimg, xp, yp, 651 703 (char *) (mText[1]->GetText().c_str()), 652 704 (char *) (mText[2]->GetText().c_str())); 653 705 break; 654 706 /* 655 707 case 2 : 656 708 oimg = PIUserProc_2(mimg, xp, yp, … … 664 716 (char *) (mText[2]->GetText().c_str())); 665 717 break; 666 718 */ 667 719 } 668 720 if (oimg) dap->AddImage(oimg,mText[0]->GetText()); … … 680 732 681 733 char *path; 734 int rc; 682 735 683 736 if (narg > 1) path = arg[1]; 684 737 else path = NULL; 685 738 739 if (narg > 2) rc = DynLink(arg[2]); 740 else rc = DynLink("piup.so"); 741 if (rc != 0) 742 { 743 printf("PIApp:: Erreur d'ouverture UserProcFunc Shared-Object ... \n"); 744 exit(0); 745 } 746 686 747 PIDemoApp app(path); 687 748 688 749 app.Run(); 689 750 751 dlclose(dlhandle); 690 752 exit(0); 691 753 } -
trunk/SophyaPI/PI/pidrawwin.cc
r8 r9 22 22 23 23 void 24 PIDrawWindow::SetAxes Kind(int axesKind, int tickLevel, int markLevel)24 PIDrawWindow::SetAxesFlags(int flags) 25 25 { 26 mDrawWdg->SetAxes Kind(axesKind, tickLevel, markLevel);26 mDrawWdg->SetAxesFlags(flags); 27 27 } 28 28 -
trunk/SophyaPI/PI/pidrawwin.h
r8 r9 16 16 17 17 virtual void AddDrawer(PIScDrawer*); 18 virtual void SetAxes Kind(int axesChoice=1, int tickLevel=1, int markLevel=1);18 virtual void SetAxesFlags(int flags=-1); 19 19 private: 20 20 PIScDrawWdg* mDrawWdg; … … 22 22 23 23 24 #endif 24 25 25 #endif -
trunk/SophyaPI/PI/pifilechomac.cc
r2 r9 10 10 11 11 string fName; 12 int i = dir.rfind(' /');12 int i = dir.rfind(':'); 13 13 if (i == NPOS) 14 14 fName = dir; … … 27 27 p2cstr(reply.sfFile.name); 28 28 29 return directory + '/' + (char*)reply.sfFile.name; 29 // return directory + '/' + (char*)reply.sfFile.name; 30 return directory + ':' + (char*)reply.sfFile.name; 30 31 } 31 32 … … 42 43 p2cstr(reply.sfFile.name); 43 44 44 return directory + '/' + (char*)reply.sfFile.name; 45 // return directory + '/' + (char*)reply.sfFile.name; 46 return directory + ':' + (char*)reply.sfFile.name; 45 47 } 46 48 … … 62 64 err = PBGetCatInfoSync(CInfoPBPtr(&block)); 63 65 p2cstr(directoryName); 64 fullPathName = '/' + ((char*)directoryName + fullPathName); 66 if (fullPathName != "") fullPathName = ':' + fullPathName; 67 fullPathName = ((char*)directoryName + fullPathName); 68 // fullPathName = '/' + ((char*)directoryName + fullPathName); 65 69 } while (block.ioDrDirID != 2); 66 70 return fullPathName; -
trunk/SophyaPI/PI/pifilechomac.h
r2 r9 28 28 typedef PIFileChooserMac PIFileChooser ; 29 29 30 #define FILESEP ':' 31 30 32 #endif 31 33 -
trunk/SophyaPI/PI/pihisto.cc
r8 r9 1 #include <stdio.h> 1 2 #include "pihisto.h" 2 3 … … 26 27 27 28 double xmin = mHisto->XMin(); 28 double xmax = (mHisto->XMax())*1.2; 29 double margeH = (xmax-xmin)/10; 30 xmin -= margeH; 31 xmax += margeH; 29 double xmax = (mHisto->XMax()); 32 30 33 double ymax = (*mHisto)(mHisto->IMax()); 34 double margeV = ymax / 10; 35 double ymin = -margeV; 36 ymax += margeV; 31 double ymax = (*mHisto)(mHisto->IMax())*1.2; 32 double ymin = 0; 37 33 38 34 mDrawWdg->SetLimits(xmin, xmax, ymin, ymax); 39 mDrawWdg->Set BBoxMargin(margeH, margeV);35 mDrawWdg->SetAxesFlags(kBoxAxes | kExtTicks | kLabels); 40 36 } 41 37 … … 45 41 { 46 42 if (!mDrawWdg) return; 47 mDrawWdg->DrawBBox(1,2,1);48 43 for (int i=0; i<mHisto->NBins(); i++) { 49 44 double left = mHisto->BinLowEdge(i); … … 52 47 double height = (*mHisto)(i); 53 48 mDrawWdg->ScDrawFBox(left,bottom,width,height); 54 // mDrawWdg->ScDrawLine(left, bottom, left, bottom + height); 49 mDrawWdg->ScDrawLine(left, bottom, left, bottom + height); // Au moins une ligne... 55 50 } 51 DrawStats(); 52 } 53 54 void 55 PIHisto::DrawStats() 56 { 57 // Une boite dans le coin superieur droit 58 if (!mDrawWdg) return; 59 double cellHeight = (mDrawWdg->YMax() - mDrawWdg->YMin()) * 0.05; 60 double cellWidth = (mDrawWdg->XMax() - mDrawWdg->XMin()) * 0.23; 61 mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax(), 62 mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight); 63 mDrawWdg->ScDrawLine(mDrawWdg->XMax() - cellWidth, mDrawWdg->YMax() - cellHeight, 64 mDrawWdg->XMax() , mDrawWdg->YMax() - cellHeight); 65 char label[50]; 66 sprintf(label, "N = %.6g", mHisto->NData()); 67 mDrawWdg->ScSelFontSz((mDrawWdg->YMax() - mDrawWdg->YMin())/30); 68 mDrawWdg->ScDrawString(mDrawWdg->XMax() - cellWidth*0.9, mDrawWdg->YMax() - cellHeight*0.8, label); 69 56 70 } 57 71 -
trunk/SophyaPI/PI/pihisto.h
r8 r9 11 11 virtual ~PIHisto(); 12 12 virtual void Draw(); 13 virtual void DrawStats(); 13 14 virtual void Refresh(); // Recalcule les limites, et reaffiche 14 15 protected: -
trunk/SophyaPI/PI/piimage.cc
r8 r9 173 173 { 174 174 // printf("PIImage::Resize\n"); 175 PIPixmapX::Resize(); 175 176 SetPave(); 176 177 Apply(); … … 393 394 ofy = ypav+(ywsz*zm/2); 394 395 } 396 if (ofx < 0) ofx = 0; 397 if (ofy < 0) ofy = 0; 395 398 396 399 zpixm = ComputePixmap(ofx, ofy, zm, xwsz, ywsz, zpixm, &xszpxm, &yszpxm); -
trunk/SophyaPI/PI/pimenumac.cc
r2 r9 26 26 PIMenuMac::FindItemByMsg(long msg) 27 27 { 28 if (mMsgs.size() == 0) return -1; 28 29 int i = find(mMsgs.begin(), mMsgs.end(), msg) - mMsgs.begin(); 29 30 return (i>=mMsgs.size()) ? -1 : i; … … 53 54 PIMenuMac::CheckItemNum(int n, bool st) 54 55 { 56 if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ? 55 57 ::CheckItem(macMenu->GetMacMenuH(), n, st); 56 58 } … … 75 77 PIMenuMac::DeleteItemNum(int n) 76 78 { 79 if (n<0 || n >= mMsgs.size()) return; // $CHECK$ exception ? 77 80 macMenu->RemoveItem(n+1); 78 81 mMsgs.erase(mMsgs.begin()+n); … … 100 103 PIMenuMac::ItemSelected(int item) 101 104 { 105 if (item<0 || item >= mMsgs.size()) return; // $CHECK$ exception ? 102 106 Send(mMsgs[item], (void*) GetMenuItemText(item).c_str()); 103 107 } … … 106 110 void 107 111 PIMenuMac::Show() 112 {} 113 114 void 115 PIMenuMac::Show(PIWdg *w, int px, int py) 108 116 {} 109 117 … … 141 149 PIMenuMac::GetMenuItemText(int item) 142 150 { 151 if (item<0 || item >= mMsgs.size()) return ""; // $CHECK$ exception ? 143 152 MenuHandle h = GetMacMenuHandle(); 144 153 Str255 txt; … … 147 156 return (char*) txt; 148 157 } 158 159 PIMenuMac::GetMenuItemMsg(int item) 160 { 161 if (item<0 || item >= mMsgs.size()) return -1; // $CHECK$ exception ? 162 return mMsgs[item]; 163 } 164 149 165 150 166 -
trunk/SophyaPI/PI/pimenumac.h
r2 r9 24 24 25 25 virtual void Show(); 26 virtual void Show(PIWdg *w, int px, int py); 27 26 28 virtual void Hide(); 27 29 … … 29 31 void ItemSelected(int item); 30 32 31 static PIMenuMac* findMenu(int id);32 MenuHandle GetMacMenuHandle();33 ResIDT GetMacMenuID();34 33 string GetMenuItemText(int item); 34 int GetMenuItemMsg(int item); 35 int FindItemByMsg(long msg); 36 int FindItemByName(string const& nom); 35 37 36 38 protected: 39 static PIMenuMac* findMenu(int id); 37 40 LMenu* macMenu; 38 41 int mMenuId; … … 42 45 43 46 friend class PIMenubarMac; 47 friend class PIOptMenuMac; 48 friend class PIPPMenuBar; 49 MenuHandle GetMacMenuHandle(); 50 ResIDT GetMacMenuID(); 44 51 45 int FindItemByMsg(long msg);46 int FindItemByName(string const& nom);47 52 48 53 }; -
trunk/SophyaPI/PI/pioptmenumac.cc
r2 r9 2 2 3 3 /* --Methode-- */ 4 PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIP DMenu *pdm,4 PIOptMenuMac::PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm, 5 5 int sx, int sy, int px, int py) 6 : PIOptMenuGen(par, pdm, sx, sy, px, py), mP DMenu(pdm)6 : PIOptMenuGen(par, pdm, sx, sy, px, py), mPUMenu(pdm) 7 7 { 8 8 delete mPane; … … 41 41 42 42 void 43 PIOptMenuMac::ListenToMessage(MessageT inMessage, void *)43 PIOptMenuMac::ListenToMessage(MessageT /*inMessage*/, void *) 44 44 { 45 45 // if (inMessage == msg_Click) 46 mP DMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1);46 mPUMenu->ItemSelected(((LStdPopupMenu*)mPane)->GetValue()-1); 47 47 } 48 48 … … 52 52 mStext = txt; mSmsg = msg; 53 53 } 54 55 /* --Methode-- */ 56 void PIOptMenuMac::SetValueStr(string & s) 57 { 58 int n; 59 n=mPUMenu->FindItemByName((char *)s.c_str()); 60 if (n < 0) return; 61 62 ((LStdPopupMenu*)mPane)->SetValue(n+1); 63 mStext = s; 64 mSmsg = mPUMenu->GetMenuItemMsg(n); 65 66 return; 67 } 68 69 /* --Methode-- */ 70 void PIOptMenuMac::SetValue(long msg) 71 { 72 int n; 73 n=mPUMenu->FindItemByMsg(msg); 74 if (n < 0) return; 75 76 ((LStdPopupMenu*)mPane)->SetValue(n+1); 77 mStext = mPUMenu->GetMenuItemText(n); 78 mSmsg = msg; 79 80 return; 81 } 82 -
trunk/SophyaPI/PI/pioptmenumac.h
r2 r9 6 6 class PIOptMenuMac : public PIOptMenuGen { 7 7 public: 8 PIOptMenuMac(PIContainerGen* par, PIP DMenu *pdm,8 PIOptMenuMac(PIContainerGen* par, PIPUMenu *pdm, 9 9 int sx=10, int sy=10, int px=0, int py=0); 10 10 ~PIOptMenuMac(); … … 15 15 virtual string GetValueStr() { return(mStext); } 16 16 virtual long GetValue() { return(mSmsg); } 17 virtual void SetValueStr(string & s); 18 virtual void SetValue(long msg); 17 19 18 20 inline void Select(char *txt, long msg); // public ou protege ??? … … 23 25 long mSmsg; 24 26 //MenuHandle macMenu; 25 PIP DMenu* mPDMenu;27 PIPUMenu* mPUMenu; 26 28 }; 27 29 -
trunk/SophyaPI/PI/pipixmapx.cc
r6 r9 15 15 { 16 16 Init(); 17 AllocXImg(); 17 18 } 18 19 … … 20 21 /* --Methode-- */ 21 22 PIPixmapX::~PIPixmapX() 22 {} 23 { 24 delete[] myximg->data; 25 XFree(myximg); 26 } 23 27 28 /* --Methode-- */ 29 void PIPixmapX::Refresh() 30 { 31 int i,j; 32 unsigned char *pp; 33 34 for(j=0; j<ny; j++) 35 { 36 pp = pixmap+j*nx; 37 for(i=0; i<nx; i++) 38 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 39 } 40 41 for(j=ny; j<YSize(); j++) 42 for(i=nx; i<XSize(); i++) 43 XPutPixel(myximg, i, j, 0 ); 44 45 PIBaseWdgX::Refresh(); 46 } 24 47 25 48 26 49 /* --Methode-- */ 50 void PIPixmapX::Resize() 51 { 52 delete[] myximg->data; 53 XFree(myximg); 54 AllocXImg(); 55 } 56 /* --Methode-- */ 27 57 void PIPixmapX::Draw() 28 58 { 29 Window xw; 30 Display * mdsp; 31 xw = XtWindow(XtWdg()); 32 mdsp = PIXDisplay(); 33 if (nx < XSize()) XClearArea(mdsp, xw, nx, 0, XSize()-nx, YSize(), False); 34 if (ny < YSize()) XClearArea(mdsp, xw, 0, ny, XSize(), YSize()-ny, False); 35 Draw(0,0,XSize(),YSize()); 59 Draw(0, 0, XSize(), YSize()); 36 60 } 37 61 … … 39 63 void PIPixmapX::Draw(int x0, int y0, int dx, int dy) 40 64 { 41 int depth;42 XImage * ximg;43 65 Window xw; 44 66 Display * mdsp; 45 int scr; 46 47 int i,j; 48 unsigned char *pp; 49 50 51 if ((pixmap == NULL) || (cmap == NULL)) return; 67 if ((myximg == NULL) || (cmap == NULL)) return; 52 68 53 69 xw = XtWindow(XtWdg()); 54 70 mdsp = PIXDisplay(); 55 scr = PIXScreen();56 71 57 72 if (x0 < 0) x0 = 0; 58 73 if (y0 < 0) y0 = 0; 59 74 60 if (dx > ( nx-x0)) dx = nx-x0;61 if (dy > ( ny-y0)) dy = ny-y0;75 if (dx > (XSize()-x0)) dx = XSize()-x0; 76 if (dy > (YSize()-y0)) dy = YSize()-y0; 62 77 if ((dx <= 0) || (dy <= 0)) return; 63 78 64 depth = DefaultDepth(mdsp,scr); 65 ximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr), 66 depth,ZPixmap,0,NULL,dx,dy,8,0); 67 if (ximg == NULL) return; 68 ximg->data = new char [dy*ximg->bytes_per_line]; 69 if (ximg->data == NULL) { XFree(ximg); return; } 79 if ( (nx < x0 ) || (ny < y0) ) 80 { XClearArea(mdsp, xw, x0, y0, dx, dy, False); return; } 70 81 71 for(j=0; j<dy; j++) 72 { 73 pp = pixmap+(j+y0)*nx+x0; 74 for(i=0; i<dx; i++) 75 { XPutPixel(ximg, i, j, cmap->Color(*pp) ); pp++; } 76 } 77 XPutImage(mdsp, xw, mygc, ximg, 0,0, x0, y0, nx, ny); 82 if (nx < (x0+dx)) 83 { XClearArea(mdsp, xw, nx, y0, x0+dx-nx, dy, False); dx = nx-x0; } 84 if (ny < (y0+dy)) 85 { XClearArea(mdsp, xw, x0, ny, dx, y0+dy-ny, False); dy = ny-y0; } 86 87 XPutImage(mdsp, xw, mygc, myximg, x0, y0, x0, y0, dx, dy); 78 88 XSync(mdsp, 0); 79 89 80 delete[] ximg->data;81 XFree(ximg);82 90 return; 83 91 … … 111 119 return; 112 120 } 121 122 123 /* --Methode-- */ 124 void PIPixmapX::AllocXImg() 125 { 126 Window xw; 127 Display * mdsp; 128 int scr; 129 int depth; 130 int pad; 131 132 xw = XtWindow(XtWdg()); 133 mdsp = PIXDisplay(); 134 scr = PIXScreen(); 135 136 depth = DefaultDepth(mdsp,scr); 137 pad = (depth > 8) ? 32 : 8; 138 myximg = XCreateImage (mdsp,DefaultVisual(mdsp,scr), 139 depth,ZPixmap,0,NULL, XSize(), YSize(), pad,0); 140 if (myximg == NULL) return; 141 myximg->data = new char [YSize()*myximg->bytes_per_line]; 142 if (myximg->data == NULL) XFree(myximg); 143 return; 144 } -
trunk/SophyaPI/PI/pipixmapx.h
r2 r9 11 11 virtual ~PIPixmapX(); 12 12 13 virtual void Refresh(); 14 virtual void Resize(); 13 15 virtual void Draw(); 14 16 virtual void Draw(int x0, int y0, int dx, int dy); … … 17 19 protected: 18 20 void Init(); 21 void AllocXImg(); 22 XImage * myximg; 19 23 }; 20 24 -
trunk/SophyaPI/PI/pippapplmac.cc
r2 r9 21 21 } 22 22 } 23 24 25 // $CHECK$ 26 // Gerer AllowSubRemoval, qui envoie un evenement a l'application PI. 27 // Eventuellement avoir des fenetres qui se cachent lors d'un close et d'autres 28 // qui se detruisent ?? -
trunk/SophyaPI/PI/piscdrawwdg.cc
r8 r9 3 3 #include <algo.h> 4 4 5 6 5 PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom, 7 6 int sx, int sy, int px, int py) … … 11 10 limitsFixed = 0; 12 11 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 12 SetAxesFlags(kAxesDflt); 13 clip = true; 13 14 } 14 15 … … 51 52 PIScDrawWdg::CalcScale() 52 53 { 53 xScale = XSize() / (xMax-xMin); 54 yScale = -YSize() / (yMax-yMin); 55 xOrg = -xMin * xScale + XPos(); 56 yOrg = -yMax * yScale + YPos(); 54 double margeH = (xMax-xMin)*0.2; 55 double margeV = (yMax-yMin)*0.2; 56 xScale = XSize() / (xMax-xMin + 2*margeH); 57 yScale = -YSize() / (yMax-yMin + 2*margeV); 58 xOrg = (-xMin + margeH) * xScale + XPos(); 59 yOrg = (-yMax - margeV) * yScale + YPos(); 57 60 } 58 61 … … 81 84 if (yFirstMinTick < yMin) yFirstMinTick += yMinTickStep; 82 85 83 xMajTickLen = -2/yScale; 84 xMinTickLen = -1/yScale; 85 yMajTickLen = 2/xScale; 86 yMinTickLen = 1/xScale; 86 // xMajTickLen = -2/yScale; 87 // xMinTickLen = -1/yScale; 88 // yMajTickLen = 2/xScale; 89 // yMinTickLen = 1/xScale; 90 91 yMajTickLen = (xMax-xMin)/100; 92 yMinTickLen = (xMax-xMin)/250; 93 xMajTickLen = (yMax-yMin)/100; 94 xMinTickLen = (yMax-yMin)/250; 95 87 96 } 88 97 … … 108 117 dypix = int(dy*yScale + .5); 109 118 } 119 120 double 121 PIScDrawWdg::ScStringWidth(char const* s) 122 { 123 return CalcStringWidth(s) / xScale; 124 } 125 126 void 127 PIScDrawWdg::ScSelFontSz(double size, PIFontAtt att) 128 { 129 int npt = int(fabs(size * yScale)+.5); 130 if (npt < 8) npt = 8; 131 if (npt > 127) npt = 127; 132 SelFontSzPt(npt, att); 133 } 134 110 135 111 136 void … … 120 145 PIScDrawWdg::ScDrawLine(double x1, double y1, double x2, double y2) 121 146 { 147 148 if (clip) { 149 if (x2 < xMin && x1 < xMin) return; 150 if (x2 > xMax && x1 > xMax) return; 151 if (y1 < yMin && y2 < yMin) return; 152 if (y2 > yMax && y2 > yMax) return; 153 if (x2 < x1) { 154 swap(x1,x2); 155 swap(y1,y2); 156 } 157 if (x2>xMax) { 158 y2 = y1 + (y2-y1)/(x2-x1)*(xMax-x1); 159 x2 = xMax; 160 } 161 if (x1<xMin) { 162 y1 = y2 + (y1-y2)/(x1-x2)*(xMin-x2); 163 x1 = xMin; 164 } 165 if (y2 < y1) { 166 swap(x1,x2); 167 swap(y1,y2); 168 } 169 if (y2>yMax) { 170 x2 = x1 + (x2-x1)/(y2-y1)*(yMax-y1); 171 y2 = yMax; 172 } 173 if (y1<yMin) { 174 x1 = x2 + (x1-x2)/(y1-y2)*(yMin-y2); 175 y1 = yMin; 176 } 177 } 122 178 int x1Pix, y1Pix, x2Pix, y2Pix; 123 179 Sc2Local(x1, y1, x1Pix, y1Pix); … … 129 185 PIScDrawWdg::ScDrawBox(double x, double y, double dx, double dy) 130 186 { 187 if (clip) { 188 if (dx < 0) { 189 x = x+dx; 190 dx = -dx; 191 } 192 if (dy < 0) { 193 y = y+dy; 194 dy = -dy; 195 } 196 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return; 197 if (x < xMin) { 198 dx -= (xMin-x); 199 x = xMin; 200 } 201 if (y < yMin) { 202 dy -= (yMin-y); 203 y = yMin; 204 } 205 if (x+dx > xMax) 206 dx = (xMax-x); 207 if (y+dy > yMax) 208 dy = (yMax-y); 209 } 131 210 int xPix, yPix, x2Pix, y2Pix; 132 211 Sc2Local(x, y, xPix, yPix); … … 138 217 PIScDrawWdg::ScDrawFBox(double x, double y, double dx, double dy) 139 218 { 219 if (clip) { 220 if (dx < 0) { 221 x = x+dx; 222 dx = -dx; 223 } 224 if (dy < 0) { 225 y = y+dy; 226 dy = -dy; 227 } 228 if (x > xMax || x+dx < xMin || y > yMax || y+dy < yMin) return; 229 if (x < xMin) { 230 dx -= (xMin-x); 231 x = xMin; 232 } 233 if (y < yMin) { 234 dy -= (yMin-y); 235 y = yMin; 236 } 237 if (x+dx > xMax) 238 dx = (xMax-x); 239 if (y+dy > yMax) 240 dy = (yMax-y); 241 } 140 242 int xPix, yPix, x2Pix, y2Pix; 141 243 Sc2Local(x, y, xPix, yPix); … … 163 265 164 266 void 165 PIScDrawWdg::DrawAxes(int tickLevel, int markLevel) 166 { 167 // Les axes 168 169 ScDrawLine(xMin, 0, xMax, 0); 170 ScDrawLine(0, yMin, 0, yMax); 171 172 // Les ticks majeurs 173 174 if (tickLevel > 0) { 175 for (double x=xFirstMajTick; x<=xMax; x += xMajTickStep) 176 ScDrawLine(x, -xMajTickLen, x, xMajTickLen); 177 for (double y=yFirstMajTick; y<=yMax; y += yMajTickStep) 178 ScDrawLine(-yMajTickLen, y, yMajTickLen, y); 179 } 180 181 // Les ticks mineurs 182 183 if (tickLevel > 1) { 184 for (double x=xFirstMinTick; x<=xMax; x += xMinTickStep) 185 ScDrawLine(x, -xMinTickLen, x, xMinTickLen); 186 for (double y=yFirstMinTick; y<=yMax; y += yMinTickStep) 187 ScDrawLine(-yMinTickLen, y, yMinTickLen, y); 188 } 189 190 191 } 192 193 void 194 PIScDrawWdg::SetBBoxMargin(double h, double v) 195 { 196 bbmargeh = h; 197 bbmargev = v; 198 } 199 200 void 201 PIScDrawWdg::DrawBBox(int tickLevel, int tickFlags, int markLevel) 202 { 203 204 double xLow = xMin + bbmargeh; 205 double xHig = xMax - bbmargeh; 206 double yLow = yMin + bbmargev; 207 double yHig = yMax - bbmargev; 208 209 double extXMajTickLen = tickFlags&2 ? xMajTickLen : 0; 210 double intXMajTickLen = tickFlags&1 ? xMajTickLen : 0; 211 double extXMinTickLen = tickFlags&2 ? xMinTickLen : 0; 212 double intXMinTickLen = tickFlags&1 ? xMinTickLen : 0; 213 double extYMajTickLen = tickFlags&2 ? yMajTickLen : 0; 214 double intYMajTickLen = tickFlags&1 ? yMajTickLen : 0; 215 double extYMinTickLen = tickFlags&2 ? yMinTickLen : 0; 216 double intYMinTickLen = tickFlags&1 ? yMinTickLen : 0; 217 218 219 // Les bordures 220 221 ScDrawLine(xLow, yLow, xHig, yLow); 222 ScDrawLine(xHig, yLow, xHig, yHig); 223 ScDrawLine(xHig, yHig, xLow, yHig); 224 ScDrawLine(xLow, yHig, xLow, yLow); 225 226 // Les ticks majeurs 227 228 if (tickLevel > 0) { 229 for (double x=xFirstMajTick; x<=xHig; x += xMajTickStep) { 230 ScDrawLine(x, yLow - extXMajTickLen, x, yLow + intXMajTickLen); 231 ScDrawLine(x, yHig + extXMajTickLen, x, yHig + intXMajTickLen); 232 } 233 for (double y=yFirstMajTick; y<=yHig; y += yMajTickStep) { 234 ScDrawLine(xLow - extYMajTickLen, y, xLow + intYMajTickLen, y); 235 ScDrawLine(xHig + extYMajTickLen, y, xHig - intYMajTickLen, y); 236 } 237 } 238 239 240 // Les ticks mineurs 241 242 if (tickLevel > 1) { 243 for (double x=xFirstMinTick; x<=xHig; x += xMinTickStep) { 244 ScDrawLine(x, yLow - extXMinTickLen, x, yLow + intXMinTickLen); 245 ScDrawLine(x, yHig + extXMinTickLen, x, yHig + intXMinTickLen); 246 } 247 for (double y=yFirstMinTick; y<=yHig; y += yMinTickStep) { 248 ScDrawLine(xLow - extYMinTickLen, y, xLow + intYMinTickLen, y); 249 ScDrawLine(xHig + extYMinTickLen, y, xHig - intYMinTickLen, y); 250 } 251 } 252 253 // Les labels 254 if (markLevel > 0) { 255 for (double x=xFirstMajTick; x<=xHig; x += xMajTickStep) { 267 PIScDrawWdg::DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep) 268 { 269 for (double x=xBeg; x<=xMax; x += xStep) 270 ScDrawLine(x, y-tickDown, x, y+tickUp); 271 } 272 273 void 274 PIScDrawWdg::DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep) 275 { 276 for (double y=yBeg; y<=yMax; y += yStep) 277 ScDrawLine(x-tickLeft, y, x+tickRight, y); 278 } 279 280 void 281 PIScDrawWdg::DrawHLabels(double y, double xBeg, double xStep, int just) 282 { 283 double xOffset = 0; 284 285 ScSelFontSz(xMajTickLen*4); 286 for (double x=xBeg; x<=xMax; x += xStep) { 256 287 char label[20]; sprintf(label, "%-6g", x); 257 ScDrawString(x, yLow - 8 * xMajTickLen, label); 258 ScDrawString(x, yHig + 2 * xMajTickLen, label); 259 } 260 for (double y=yFirstMajTick; y<=yHig; y += yMajTickStep) { 288 double largeur = ScStringWidth(label); 289 if (just == 1) 290 xOffset = -largeur; 291 else if (just == 0) 292 xOffset = -largeur/2; 293 else 294 xOffset = 0; 295 ScDrawString(x+xOffset, y, label); 296 } 297 } 298 299 void 300 PIScDrawWdg::DrawVLabels(double x, double yBeg, double yStep, int just) 301 { 302 double xOffset = 0; 303 ScSelFontSz(xMajTickLen*4); 304 for (double y=yBeg; y<=yMax; y += yStep) { 261 305 char label[20]; sprintf(label, "%-6g", y); 262 ScDrawString(xLow - 8 * yMajTickLen, y, label); 263 ScDrawString(xHig + 2 * yMajTickLen, y, label); 264 } 265 } 266 } 306 double largeur = ScStringWidth(label); 307 if (just == 1) 308 xOffset = -largeur; 309 else if (just == 0) 310 xOffset = -largeur/2; 311 else 312 xOffset = 0; 313 ScDrawString(x+xOffset, y, label); 314 } 315 } 316 317 318 void 319 PIScDrawWdg::DrawAxes(int flags) 320 { 321 NoClip(); 322 if (flags == -1) 323 flags = axesFlags; 324 325 326 if (flags & kStdAxes) { 327 328 // Les axes 329 330 ScDrawLine(xMin, 0, xMax, 0); 331 ScDrawLine(0, yMin, 0, yMax); 332 333 // Les ticks majeurs 334 335 if (flags & kMajTicks) { 336 DrawHTicks(0, xMajTickLen, xMajTickLen, xFirstMajTick, xMajTickStep); 337 DrawVTicks(0, yMajTickLen, yMajTickLen, yFirstMajTick, yMajTickStep); 338 } 339 340 // Les ticks mineurs 341 342 if (flags & kMinTicks) { 343 DrawHTicks(0, xMinTickLen, xMinTickLen, xFirstMinTick, xMinTickStep); 344 DrawVTicks(0, yMinTickLen, yMinTickLen, yFirstMinTick, yMinTickStep); 345 } 346 347 // Les labels 348 349 if (flags & kLabels) { 350 DrawHLabels(-xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 351 DrawVLabels(-yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 352 } 353 354 } 355 356 if (flags & kBoxAxes) { 357 358 // La boite 359 360 ScDrawLine(xMin, yMin, xMax, yMin); 361 ScDrawLine(xMax, yMin, xMax, yMax); 362 ScDrawLine(xMax, yMax, xMin, yMax); 363 ScDrawLine(xMin, yMax, xMin, yMin); 364 365 // Longueur des ticks 366 367 double extXMajTickLen = flags&kExtTicks ? xMajTickLen : 0; 368 double intXMajTickLen = flags&kIntTicks ? xMajTickLen : 0; 369 double extXMinTickLen = flags&kExtTicks ? xMinTickLen : 0; 370 double intXMinTickLen = flags&kIntTicks ? xMinTickLen : 0; 371 double extYMajTickLen = flags&kExtTicks ? yMajTickLen : 0; 372 double intYMajTickLen = flags&kIntTicks ? yMajTickLen : 0; 373 double extYMinTickLen = flags&kExtTicks ? yMinTickLen : 0; 374 double intYMinTickLen = flags&kIntTicks ? yMinTickLen : 0; 375 376 // Les ticks majeurs 377 378 if (flags & kMajTicks) { 379 DrawHTicks(yMin, intXMajTickLen, extXMajTickLen, xFirstMajTick, xMajTickStep); 380 DrawHTicks(yMax, extXMajTickLen, intXMajTickLen, xFirstMajTick, xMajTickStep); 381 DrawVTicks(xMin, extYMajTickLen, intYMajTickLen, yFirstMajTick, yMajTickStep); 382 DrawVTicks(xMax, intYMajTickLen, extYMajTickLen, yFirstMajTick, yMajTickStep); 383 } 384 385 // Les ticks mineurs 386 387 if (flags & kMinTicks) { 388 DrawHTicks(yMin, intXMinTickLen, extXMinTickLen, xFirstMinTick, xMinTickStep); 389 DrawHTicks(yMax, extXMinTickLen, intXMinTickLen, xFirstMinTick, xMinTickStep); 390 DrawVTicks(xMin, extYMinTickLen, intYMinTickLen, yFirstMinTick, yMinTickStep); 391 DrawVTicks(xMax, intYMinTickLen, extYMinTickLen, yFirstMinTick, yMinTickStep); 392 } 393 394 395 // Les labels 396 397 if (flags & kLabels) { 398 DrawHLabels(yMin-xMajTickLen*8, xFirstMajTick, xMajTickStep,0); 399 DrawHLabels(yMax+xMajTickLen*2, xFirstMajTick, xMajTickStep,0); 400 DrawVLabels(xMin-yMajTickLen*2, yFirstMajTick, yMajTickStep,1); 401 DrawVLabels(xMax+yMajTickLen*2, yFirstMajTick, yMajTickStep,-1); 402 } 403 } 404 Clip(); 405 } 406 407 267 408 268 409 void … … 302 443 303 444 void 304 PIScDrawWdg::SetAxesKind(int axesKind, int tickLevel, int markLevel) 305 { 306 axesChoice = axesKind; 307 tickChoice = tickLevel; 308 labelChoice = markLevel; 445 PIScDrawWdg::SetAxesFlags(int flags) 446 { 447 axesFlags = flags; 448 if (axesFlags & (kIntTicks | kExtTicks | kMajTicks | kMinTicks)) 449 axesFlags |= kTicks; 450 if ((axesFlags & (kTicks | kIntTicks | kExtTicks)) == kTicks) 451 axesFlags |= kIntTicks | kExtTicks; 452 if ((axesFlags & (kTicks | kMajTicks | kMinTicks)) == kTicks) 453 axesFlags |= kMajTicks; 309 454 } 310 455 … … 313 458 { 314 459 EraseWindow(); 315 if (axesChoice == 1) 316 DrawAxes(tickChoice, labelChoice); 317 else if (axesChoice == 2) 318 DrawBBox(tickChoice, labelChoice); 460 DrawAxes(); 319 461 CallDrawers(); 462 DrawSelf(); 320 463 } 321 464 … … 329 472 xEndDrag = xBegDrag = x; 330 473 yEndDrag = yBegDrag = y; 331 PIBeep();332 474 } 333 475 … … 429 571 PIScGFFDrawer::PIScGFFDrawer(GeneralFitFunction* f) 430 572 : mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms]) 431 {} 573 { 574 ASSERT(f->NVar() == 1); 575 } 432 576 433 577 PIScGFFDrawer::~PIScGFFDrawer() … … 437 581 438 582 void 439 PIScGFFDrawer::SetParms(double const*) 440 {} 583 PIScGFFDrawer::SetParms(double const* p) 584 { 585 for (int i=0; i<mNParms; i++) 586 mParms[i] = p[i]; 587 } 441 588 442 589 … … 444 591 PIScGFFDrawer::Draw() 445 592 { 446 } 447 593 if (!mDrawWdg) return; 594 double xMax = mDrawWdg->XMax(); 595 double xMin = mDrawWdg->XMin(); 596 double yMax = mDrawWdg->YMax(); 597 double yMin = mDrawWdg->YMin(); 598 double xStep = (xMax - xMin)/100; 599 double xOld = xMin; 600 double yOld = 0; 601 // double yOld = f->Value(&xMin, mParms); 602 for (double x = xMin+xStep; x<xMax; x+=xStep) { 603 double y = 0; // $CHECK$ 604 // double y = f->Value(&x, mParms); 605 if (y>yMin && yOld>yMin && 606 y<yMax && yOld<yMax) 607 mDrawWdg->ScDrawLine(xOld, yOld, x, y); 608 xOld = x; 609 yOld = y; 610 } 611 } 612 -
trunk/SophyaPI/PI/piscdrawwdg.h
r8 r9 7 7 8 8 #include <list.h> 9 10 enum { 11 kStdAxes = 0x0001, 12 kBoxAxes = 0x0002, 13 kTicks = 0x0004, 14 kIntTicks = 0x0010, 15 kExtTicks = 0x0020, 16 kMajTicks = 0x0040, 17 kMinTicks = 0x0080, 18 kLabels = 0x1000, 19 kAxesDflt = kStdAxes | kTicks | kLabels 20 }; 21 9 22 10 23 class PIScDrawWdg : public PIBaseWdg { … … 22 35 virtual void ScDrawCircle(double x0, double y0, double r); 23 36 virtual void ScDrawFCircle(double x0, double y0, double r); 37 virtual double ScStringWidth(char const*); 38 virtual void ScSelFontSz(double size, PIFontAtt att=PI_RomanFont); 24 39 25 virtual void DrawAxes(int tickLevel=1, int markLevel=1); 26 virtual void DrawBBox(int tickLevel=1, int tickFlags=3, int markLevel=1); 27 virtual void SetBBoxMargin(double h, double v); 40 virtual void DrawAxes(int flags = -1); 41 virtual void DrawSelf() {} 28 42 29 43 virtual void Resize(); … … 44 58 static void CallDrawer(PIScDrawer*); 45 59 virtual void CallDrawers(); 46 virtual void SetAxes Kind(int axesChoice=1, int tickLevel=1, int markLevel=1);60 virtual void SetAxesFlags(int flags=kAxesDflt); 47 61 48 62 double XMin() const {return xMin;} … … 52 66 int LimitsFixed() const {return limitsFixed;} 53 67 void FreeLimits() {limitsFixed = 0;} 68 void NoClip() {clip = false;} 69 void Clip() {clip = true;} 54 70 55 71 … … 71 87 72 88 int limitsFixed; 73 int axesChoice, tickChoice, labelChoice; 74 double bbmargeh, bbmargev; 89 int axesFlags; 75 90 list<PIScDrawer*> mDrawers; 76 91 77 92 int xBegDrag, yBegDrag; 78 93 int xEndDrag, yEndDrag; 94 95 bool clip; 96 97 private: 98 void DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep); 99 void DrawVTicks(double x, double tickLeft, double tickRight, double yBeg, double yStep); 100 void DrawHLabels(double y, double xBeg, double xStep, int just=0); 101 void DrawVLabels(double x, double yBeg, double yStep, int just=0); 79 102 }; 80 103 -
trunk/SophyaPI/PI/pistdwdgmac.cc
r2 r9 23 23 24 24 PIButtonMac::PIButtonMac(PIContainerGen *par, char *nom, long msg, 25 int sx, int sy, int px, int py )26 : PIButtonGen(par, nom, msg, sx, sy, px, py )25 int sx, int sy, int px, int py, PIBtnSign bsgn) 26 : PIButtonGen(par, nom, msg, sx, sy, px, py, bsgn) 27 27 { 28 28 delete mPane; -
trunk/SophyaPI/PI/pistdwdgmac.h
r2 r9 17 17 public: 18 18 PIButtonMac(PIContainerGen *par, char *nom, long msg = PIMsg_Click, 19 int sx=10, int sy=10, int px=0, int py=0); 19 int sx=10, int sy=10, int px=0, int py=0, 20 PIBtnSign bsgn = PIBtn_Label); 20 21 virtual ~PIButtonMac(); 21 22 virtual void ListenToMessage(MessageT inMessage, void *ioParam); -
trunk/SophyaPI/PI/piupdattachment.cc
r2 r9 6 6 PIUpdAttachment* PIUpdAttachment::lastCursPane = NULL; 7 7 bool PIUpdAttachment::hit = false; 8 bool PIUpdAttachment::down = false;8 int PIUpdAttachment::down = 0; 9 9 10 10 PIUpdAttachment::PIUpdAttachment(PIBaseWdgMac* wdg) … … 12 12 { 13 13 14 } 15 16 PIUpdAttachment::~PIUpdAttachment() 17 { 18 SysBeep(1); 14 19 } 15 20 … … 28 33 break; 29 34 case msg_Click: { 30 down = true;31 35 SMouseDownEvent* evt = (SMouseDownEvent*) data; 32 36 EventModifiers mod = evt->macEvent.modifiers; 33 37 if ((mod & cmdKey) && (mod & optionKey)) 34 myWdg->But3Press(evt->whereLocal.h,evt->whereLocal.v);38 { myWdg->But3Press(evt->whereLocal.h,evt->whereLocal.v); down = 3;} 35 39 else if (mod & cmdKey) 36 myWdg->But2Press(evt->whereLocal.h,evt->whereLocal.v);40 { myWdg->But2Press(evt->whereLocal.h,evt->whereLocal.v); down = 2;} 37 41 else 38 myWdg->But1Press(evt->whereLocal.h,evt->whereLocal.v);42 { myWdg->But1Press(evt->whereLocal.h,evt->whereLocal.v); down = 1;} 39 43 break; 40 44 } … … 63 67 SetExecuteHost(!myWdg->AdjustCursor()); 64 68 // Est-ce un move, i.e. le bouton est-il toujours appuye depuis le dernier MouseDown ? 65 if (::StillDown()) { 66 down = true; 69 if (::StillDown() && down) { 67 70 Point pt = evt->where; 68 71 myWdg->mPane->GlobalToPortPoint(pt); … … 79 82 } 80 83 } else if (down) { // A changer le jour ou les attachements recoivent les mouseup. 81 down = false;82 84 Point pt = evt->where; 83 85 myWdg->mPane->GlobalToPortPoint(pt); 84 86 myWdg->mPane->PortToLocalPoint(pt); 85 87 EventModifiers mod = evt->modifiers; 86 if ((mod & cmdKey) && (mod & optionKey)) 88 //if ((mod & cmdKey) && (mod & optionKey)) 89 if (down == 3) 87 90 myWdg->But3Release(pt.h,pt.v); 88 else if (mod & cmdKey) 91 //else if (mod & cmdKey) 92 else if (down == 2) 89 93 myWdg->But2Release(pt.h,pt.v); 90 94 else 91 95 myWdg->But1Release(pt.h,pt.v); 96 down = 0; 92 97 } 93 98 break; -
trunk/SophyaPI/PI/piupdattachment.h
r2 r9 7 7 public: 8 8 PIUpdAttachment(PIBaseWdgMac* wdg); 9 ~PIUpdAttachment(); 9 10 10 11 protected: … … 18 19 static PIUpdAttachment* lastCursPane; 19 20 static bool hit; 20 static booldown;21 static int down; 21 22 Point lastPt; 22 23 }; 24 -
trunk/SophyaPI/PI/piwdgmac.cc
r2 r9 7 7 #include <LString.h> 8 8 9 9 void PIBeep() 10 { 11 ::SysBeep(1); 12 } 10 13 11 14 -
trunk/SophyaPI/PI/piwdgmac.h
r2 r9 19 19 virtual void SetSize(int sx, int sy); 20 20 virtual void SetPos(int px, int py); 21 virtual void SetBorderWidth(int /*bw*/) {} 21 22 virtual void SetBinding(bool left, bool top, bool right, bool bottom); 22 23 virtual int XSize(); -
trunk/SophyaPI/PI/piwindowmac.cc
r2 r9 14 14 windAttr_TitleBar | 15 15 windAttr_SizeBox | 16 windAttr_CloseBox | 16 17 windAttr_Resizable; 17 18 mWindowInfo.layer = windLayer_Regular; -
trunk/SophyaPI/PI/sc_sample.cc
r8 r9 18 18 ScSample::Draw() 19 19 { 20 DrawAxes( 1,0);20 DrawAxes(); 21 21 PlotFunc(f); 22 22 } -
trunk/SophyaPI/PI/so_locations
r8 r9 1 libPeidaInter.so \2 :st = .text 0x000003ffbff e0000, 0x0000000000020000:\1 piup.so \ 2 :st = .text 0x000003ffbfff0000, 0x0000000000010000:\ 3 3 :st = .data 0x000003ffffff0000, 0x0000000000010000:\ 4 4 5 libPI.so \6 :st = .text 0x000003ffbff b0000, 0x0000000000030000:\5 piup_def.so \ 6 :st = .text 0x000003ffbffe0000, 0x0000000000010000:\ 7 7 :st = .data 0x000003fffffe0000, 0x0000000000010000:\ 8 8 9 user.so \ 10 :st = .text 0x000003ffbffd0000, 0x0000000000010000:\ 11 :st = .data 0x000003fffffd0000, 0x0000000000010000:\ 12
Note:
See TracChangeset
for help on using the changeset viewer.