Changeset 382 in Sophya
- Timestamp:
- Aug 12, 1999, 11:04:27 AM (26 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Tests/pit1.cc
r323 r382 104 104 g->DrawFBox(10, 60, 120, 20); 105 105 106 PIFont f0; 107 g->SelFont(f0); 106 108 g->SelForeground(PI_Black); 107 109 g->DrawString(20, 110, str); 110 PIFont f(PI_TimesFont); 111 g->SelFont(f); 112 g->DrawString(20, 130, "Times-Font"); 113 PIFont f2(14,PI_CourierFont,PI_BoldFont); 114 g->SelFont(f2); 115 g->DrawString(20, 150, "Courier-Font"); 116 PIFont f3(14,PI_TimesFont,PI_BoldFont); 117 g->SelFont(f3); 118 g->DrawString(20, 170, "Times-Font"); 119 PIFont f4(14,PI_HelveticaFont,PI_BoldFont); 120 g->SelFont(f4); 121 g->DrawString(20, 190, "Helvetica-Font"); 122 PIFont f5(14,PI_SymbolFont,PI_BoldFont); 123 g->SelFont(f5); 124 g->DrawString(20, 210, "Symbol-Font"); 125 108 126 109 127 g->SelLine(PI_ThinLine); … … 118 136 g->SelForeground(PI_Grey); 119 137 g->DrawFCircle(120, 60, 15); 138 139 140 120 141 121 142 PIGrCoord x[5] = { 20, 35, 50, 65, 80 }; … … 367 388 m[0]->AppendItem("New ExBwdg", 10102); 368 389 m[0]->AppendItem("New ScSample", 10103); 390 m[0]->AppendItem("->eps", 10111); 369 391 m[0]->AppendItem("Exit", 10105); 370 392 // On accroche le menu au Menubar … … 398 420 } 399 421 422 static int numpsf = 0; 400 423 static int nbwin = 0; 401 424 /* --Methode-- */ … … 460 483 break; 461 484 485 case 10111: // -> eps 486 if (mcurwin) { 487 char buff[64]; 488 sprintf(buff, "pit_%d.eps", numpsf); numpsf++; 489 printf("Creating EPS File %s (Encapsulated PostScript) \n", buff); 490 PSFile *mps; 491 mps = new PSFile(buff); 492 mcurwin->PSPrint(mps,0,0); 493 delete mps; 494 } 495 break; 462 496 case 10105: // Sortie d'application 463 497 Stop(); -
trunk/SophyaPI/PI/pigraphps.cc
r316 r382 82 82 mLAtt = PI_ThinLine; 83 83 SelLine(); 84 mFAtt = PI_BoldFont; mFSize = 0; 84 // mFAtt = PI_BoldFont; mFSize = 0; $CHECK$ Plus besoin 85 85 SelFont(); 86 86 SelMarker(1, PI_DotMarker); … … 111 111 { 112 112 if(mPSOut) 113 mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 113 // mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 114 mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 115 myFont.GetFontAtt(), myFont.GetFontSize()); 116 // Calculez la taille de la boite occupe par la fonte 117 // myFont.GetFontHeight(int& asc, int& desc) Tres proche de myFont.GetFontSize() en principe 118 // myFont.GetStringWidth(char const* s) Largeur occupe par la chaine 114 119 return; 115 120 } … … 119 124 { 120 125 if(mPSOut) 121 mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 126 // mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 127 mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 128 myFont.GetFontAtt(), myFont.GetFontSize()); 129 // Idem taille ici 122 130 return; 123 131 } … … 251 259 if(mPSOut) 252 260 mPSOut->DrawMarker((double)x0,(double)y0,mMrk,mFCol,mMrkSz); 261 // $CHECK$ Ajouter starmarker 262 // /* Coordonnees pour une etoile a 5 branches */ 263 // double pio5 = M_PI/2.5; 264 // double pio52 = pio5/2.; 265 // double cpi2 = M_PI/2.-pio5; 266 // double re = 1.2; // Rayon externe 267 // double ri = 0.5; // rayon interne pour rext=1.2 268 // for(int k=0; k<5; k++) { 269 // starcoordx[2*k] = cos(k*pio5+cpi2)*re; 270 // starcoordy[2*k] = -sin(k*pio5+cpi2)*re; 271 // starcoordx[2*k+1] = cos(k*pio5+pio52+cpi2)*ri; 272 // starcoordy[2*k+1] = -sin(k*pio5+pio52+cpi2)*ri; 273 // } 274 253 275 return; 254 276 } … … 331 353 { 332 354 // $CHECK$ - Reza 13/06/99 333 SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt()); 355 if (myFont == fnt) return; 356 myFont = fnt; 357 // C'est peu-etre mieux 358 // SelFontSzPt(fnt.GetFontSize(), fnt.GetFontAtt()); 359 } 360 361 362 static int fntsz[5] = {8,10,12,14,16}; 363 364 /* --Methode-- */ 365 void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att) 366 { 367 // $CHECK$ - Reza 13/06/99 368 PIFont fnt(myFont.GetFontName()); 369 fnt.SetFontAtt(att); 370 fnt.SetFontSz(sz); 371 SelFont(fnt); 372 return; 334 373 } 335 374 … … 338 377 { 339 378 // $CHECK$ - Reza 13/06/99 340 myFont.SetFontSzPt(npt); 341 myFont.SetFontAtt(att); 342 mFSize = npt; 343 mFAtt = att; 344 return; 345 } 346 347 static int fntsz[5] = {8,10,12,14,16}; 348 349 /* --Methode-- */ 350 void PIGraphicPS::SelFont(PIFontSize sz, PIFontAtt att) 351 { 352 // $CHECK$ - Reza 13/06/99 353 int i; 354 switch (sz) { 355 case PI_SmallSizeFont: 356 i = 0; 357 break; 358 case PI_NormalSizeFont: 359 i = 2; 360 break; 361 case PI_BigSizeFont: 362 i = 4; 363 break; 364 default: 365 i=2; 366 break; 367 } 368 myFont.SetFontSz(sz); 369 myFont.SetFontAtt(att); 370 mFSize = fntsz[i]; 371 mFAtt = att; 372 return; 379 PIFont fnt(npt, myFont.GetFontName(), att); 380 SelFont(fnt); 373 381 } 374 382 -
trunk/SophyaPI/PI/pigraphps.h
r316 r382 83 83 PIColor mFCfMap, mBCfMap; 84 84 PIGOMode mGOm; 85 PIFontAtt mFAtt; 85 // PIFontAtt mFAtt; Plus besoin Reza + NR 07/08/99 86 86 PILineAtt mLAtt; 87 int mFSize; 87 // int mFSize; Plus besoin Reza + NR 07/08/99 88 88 PIMarker mMrk; 89 89 int mMrkSz; -
trunk/SophyaPI/PI/piwdggen.cc
r329 r382 258 258 psf->DrawBox(0., 0., (double)XSize(), (double)YSize()); 259 259 sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str()); 260 psf->DrawString(12., 12., str, PI_Black, PI_RomanFont, 10); 260 // N.R. 07/08/99 FontName specifie dans DrawString() 261 psf->DrawString(12., 12., str, PI_Black, PI_DefaultFont, PI_RomanFont, 10); 261 262 psf->EndBloc(); 262 263 -
trunk/SophyaPI/PI/psfile.cc
r292 r382 6 6 * Modification le 01/03/96 7 7 * - fusion psfile.cc - psdict.cc 8 * 9 * 10 * 07/08/99 : Gestion des fontes ; ajout Times/Helvetica/Symbol 11 * 12 * 13 * 8 14 * 9 15 */ … … 77 83 /C%-2d {0.195 0.800 0.195 setrgbcolor} bind def %% PI_LimeGreen\n\ 78 84 /C%-2d {0.996 0.840 0.0 setrgbcolor} bind def %% PI_Gold\n\ 79 /F%-2d {/Courier findfont} bind def %% PI_RomanFont\n\80 /F%-2d {/Courier-Bold findfont} bind def 81 /F%-2d {/Courier-Italic findfont} bind def 85 /F%-2d {/Courier findfont} bind def %% PI_RomanFont\n\ 86 /F%-2d {/Courier-Bold findfont} bind def %% PI_BoldFont\n\ 87 /F%-2d {/Courier-Italic findfont} bind def %% PI_ItalicFont\n\ 82 88 /F%-2d {}\ 83 89 bind def %% PI_NotDefFontAtt\n\ … … 268 274 #define HEADER "\ 269 275 %%%%Title: %s\n\ 270 %%%%Creator: PSFile \n\276 %%%%Creator: PSFile (N.R. 07/08/99)\n\ 271 277 %%%%CreationDate: %s\ 272 278 %%%%Pages: (atend)\n\ … … 308 314 mFillColor(PI_Black), 309 315 mFontAtt(PI_RomanFont), 310 mFontSize(PI_NormalSizeFont), 316 mFontSize(0), 317 mFontName(PI_DefaultFont), 311 318 mLineAtt(PI_NormalLine), 312 319 mMarker(PI_DotMarker), … … 370 377 mFillColor(PI_Black), 371 378 mFontAtt(PI_RomanFont), 372 mFontSize(PI_NormalSizeFont), 379 mFontSize(0), 380 mFontName(PI_DefaultFont), 373 381 mLineAtt(PI_NormalLine), 374 382 mMarker(PI_DotMarker), … … 448 456 } 449 457 450 PIFontSize PSFile::GetFontSize() { 458 // N.R. 07/08/99 return val PIFontSize --> int 459 int PSFile::GetFontSize() { 451 460 452 461 return(mFontSize); … … 551 560 552 561 if(currentPage->orientation == PI_Portrait) { 553 // if( (tw/Dx) < (th/Dy) )554 // scale = tw/Dx ;555 // scale = tw/Tw ;556 // else557 // scale = th/Dy;558 // scale = th/Th;559 // fprintf(mPSFile,560 // "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",561 // Dx, Dy,562 // Dx*scale, Dy*scale,563 // Tw*scale, Th*scale,564 // 0.5*(Tw-tw), -0.5*(Th+th)) ;562 // if( (tw/Dx) < (th/Dy) ) 563 // scale = tw/Dx ; 564 // scale = tw/Tw ; 565 // else 566 // scale = th/Dy; 567 // scale = th/Th; 568 // fprintf(mPSFile, 569 // "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n", 570 // Dx, Dy, 571 // Dx*scale, Dy*scale, 572 // Tw*scale, Th*scale, 573 // 0.5*(Tw-tw), -0.5*(Th+th)) ; 565 574 scale = (tw/Dx)<(th/Dy) ? tw/Dx : th/Dy ; 566 575 tw = scale*Dx ; th = scale*Dy ; … … 698 707 void PSFile::DrawString (double x, double y, const char *s, 699 708 PIColors DrawColor, 709 PIFontName FontName, 700 710 PIFontAtt FontAtt, 701 711 int FontSize) { … … 703 713 704 714 /* Couleurs */ 705 if ( (DrawColor != PI_NotDefColor) ||(DrawColor != mDrawColor) ) {715 if ( (DrawColor != PI_NotDefColor) && (DrawColor != mDrawColor) ) { 706 716 mDrawColor = DrawColor; 707 717 fprintf(mPSFile, "C%d ", mDrawColor) ; 708 718 } 709 719 /* Choix des fontes */ 710 if ( (FontAtt != PI_NotDefFontAtt) || (FontAtt != mFontAtt) ) { 711 mFontAtt = FontAtt; 712 change = 1;} 713 if ( (FontSize != PI_NotDefFontSize) || (FontSize != mFontSize) ) { 714 mFontSize = (PIFontSize) FontSize; // $CHECK$ EA ajoute le cast un peu au pif 715 change = 1;} 716 if (change) 717 fprintf(mPSFile, "F%d %d FS ", mFontAtt, FontSize) ; 718 720 if ( (FontAtt != PI_NotDefFontAtt) && (FontAtt != mFontAtt) ) { 721 printf("PSFile::DrawString(%s) : FontAtt a change : %d %d \n", s, mFontAtt, FontAtt) ; 722 mFontAtt = FontAtt; 723 change = 1; 724 } 725 if ( (FontSize != PI_NotDefFontSize) && (FontSize != mFontSize) ) { 726 printf("PSFile::DrawString(%s) : FontSize a change : %d %d \n", s, mFontSize, FontSize) ; 727 mFontSize = (PIFontSize) FontSize; // $CHECK$ EA ajoute le cast un peu au pif 728 change = 1; 729 } 730 if( (FontName != mFontName) ) { 731 printf("PSFile::DrawString(%s) : FontName a change : %d %d \n", s, mFontName, FontName) ; 732 mFontName = (PIFontName) FontName ; 733 change = 1 ; 734 } 735 if (change) { 736 string fname ; 737 switch(mFontName) { 738 case PI_DefaultFont: 739 case PI_CourierFont: 740 fprintf(mPSFile, "/Courier") ; 741 break ; 742 case PI_HelveticaFont: 743 fprintf(mPSFile, "/Helvetica") ; 744 break ; 745 case PI_TimesFont: 746 fprintf(mPSFile, "/Times") ; 747 break ; 748 case PI_SymbolFont: 749 fprintf(mPSFile, "/Symbol ") ; 750 break ; 751 } // endsw 752 753 switch(mFontAtt) { 754 case PI_NotDefFontAtt: 755 case PI_RomanFont: 756 fprintf(mPSFile, " ") ; 757 break ; 758 case PI_BoldFont: 759 if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Bold ") ; 760 break ; 761 case PI_ItalicFont: 762 if(mFontName != PI_SymbolFont) fprintf(mPSFile, "-Italic ") ; 763 break ; 764 } // endsw 765 fprintf(mPSFile, " ff %d FS ", FontSize) ; 766 } 767 768 719 769 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 720 770 setFontDone = true ; … … 723 773 724 774 void PSFile::DrawLine (double x1, double y1, double x2, double y2, 725 PIColors DrawColor,726 PILineAtt LineAtt) {775 PIColors DrawColor, 776 PILineAtt LineAtt) { 727 777 728 778 int lw = 0 ; -
trunk/SophyaPI/PI/psfile.h
r292 r382 25 25 #endif 26 26 #include "pisysdep.h" 27 27 #include "pifontgen.h" 28 28 29 29 #include "pigraphgen.h" // Types enumeres repris de Peida:PIFontSize... … … 92 92 virtual PIColors GetFillColor(); 93 93 virtual PIFontAtt GetFontAtt(); 94 virtual PIFontSizeGetFontSize();94 virtual int GetFontSize(); 95 95 virtual PILineAtt GetLineAtt(); 96 96 virtual PIMarker GetMarker(); … … 108 108 virtual void DrawString (double x, double y, const char *s, 109 109 PIColors DrawColor = PI_NotDefColor, 110 PIFontName FontName = PI_DefaultFont, 110 111 PIFontAtt FontAtt = PI_NotDefFontAtt, 111 112 int FontSize = 8); … … 196 197 enum PIColors mFillColor; /* Couleur de remplissage courante */ 197 198 enum PIFontAtt mFontAtt; 198 enum PIFontSize mFontSize; 199 // enum PIFontSize mFontSize; 200 int mFontSize; 201 enum PIFontName mFontName; 199 202 enum PILineAtt mLineAtt; /* Epaisseur d une ligne */ 200 203 enum PIMarker mMarker; /* Marker courant */
Note:
See TracChangeset
for help on using the changeset viewer.