Changeset 1848 in Sophya
- Timestamp:
- Jan 6, 2002, 7:00:35 PM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pigraphgen.cc
r1592 r1848 288 288 } 289 289 290 /* --Methode-- */ 291 bool PIGraphicGen::CalcStringPositionShift(char const* s, int pos, 292 int& dx, int& dy) 293 { 294 dx = 0; 295 dy = 0; 296 cout << " PIGraphicGen::CalcStringPositionShift - DBG - pos= " 297 << pos << endl; 298 if (pos == 0) return(false); 299 else { 300 int posh = pos & PI_HorizontalPosition; 301 int posv = pos & PI_VerticalPosition; 302 if ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBottom)) 303 return(false); 304 if (posh != PI_HorizontalLeft) { 305 int wx = myFont.GetStringWidth(s); 306 if (posh == PI_HorizontalCenter) dx = wx/2; 307 else if (posh == PI_HorizontalRight) dx = wx; 308 else wx = 0; 309 } 310 if (posv != PI_VerticalBottom) { 311 int a,d; 312 int wy = myFont.GetFontHeight(a, d); 313 if (posv == PI_VerticalCenter) dy = -wy/2; 314 else if (posv == PI_VerticalTop) dy = -wy; 315 else dy = 0; 316 } 317 cout << " PIGraphicGen::CalcStringPositionShift - DBG2 - dx= " 318 << dx << " dy=" << dy << endl; 319 return(true); 320 } 321 } 322 323 290 324 //++ 291 325 // Titre Sauvegarde et rappel des attributs graphiques -
trunk/SophyaPI/PI/pigraphgen.h
r1592 r1848 28 28 PI_StarMarker=9, PI_FStarMarker=10 }; 29 29 30 enum PIGrPosHorizontal { PI_HorizontalLeft = 0, PI_HorizontalCenter = 1,31 PI_HorizontalRight = 2 };32 enum PIGrPosVertical { PI_VerticalBottom = 32, PI_VerticalCenter = 36,33 PI_VerticalTop = 40 };34 30 31 enum PIGrPosHorizontal // Flags de positionnement horizontal 32 // PI_HorizontalPosition regroupe l'ensemble des bits utilisables 33 { PI_HorizontalLeft = 0x1, PI_HorizontalCenter = 0x2, 34 PI_HorizontalRight = 0x3, PI_HorizontalPosition = 0xF }; 35 36 enum PIGrPosVertical // Flags de positionnement vertical 37 // PI_VerticalPosition regroupe l'ensemble des bits utilisables 38 { PI_VerticalBottom = 0x10, PI_VerticalCenter = 0x20, 39 PI_VerticalTop = 0x30, PI_VerticalPosition = 0xF0 }; 40 41 // Les differents modes de trace graphique disponible 35 42 enum PIGOMode { PI_GOCopy = 0, PI_GOXOR = 1, PI_GOInvert = 2 }; 36 43 … … 130 137 virtual PIGrCoord GetFontHeight(PIGrCoord& asc, PIGrCoord& desc); 131 138 virtual PIGrCoord CalcStringWidth(char const* s); 139 virtual bool CalcStringPositionShift(char const* s, int pos, 140 int& dx, int& dy); 132 141 133 142 // Sauvegarde des attributs graphiques -
trunk/SophyaPI/PI/pigraphps.cc
r1538 r1848 112 112 113 113 /* --Methode-- */ 114 void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)114 void PIGraphicPS::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos) 115 115 { 116 116 if(mPSOut) 117 117 // mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 118 118 mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 119 myFont.GetFontAtt(), myFont.GetFontSize()*0.9); /* $CHECK$ x 0.9 - Reza 4/11/99 */ 119 myFont.GetFontAtt(), myFont.GetFontSize(), 120 pos); /* $CHECK$ x 0.9 - Reza 4/11/99 - enleve 3/01/2002 */ 120 121 // Calculez la taille de la boite occupe par la fonte 121 122 // myFont.GetFontHeight(int& asc, int& desc) Tres proche de myFont.GetFontSize() en principe … … 125 126 126 127 /* --Methode-- */ 127 void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/)128 void PIGraphicPS::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos) 128 129 { 129 130 if(mPSOut) 130 131 // mPSOut->DrawString((double)x,(double)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 131 132 mPSOut->DrawString((double)x,(double)y,s,mFCol, myFont.GetFontName(), 132 myFont.GetFontAtt(), myFont.GetFontSize()*0.9); /* $CHECK$ x 0.9 - Reza 4/11/99 */ 133 myFont.GetFontAtt(), myFont.GetFontSize(), 134 pos); /* $CHECK$ x 0.9 - Reza 4/11/99 */ 133 135 // Idem taille ici 134 136 return; -
trunk/SophyaPI/PI/pigraphx.cc
r1846 r1848 103 103 104 104 /* --Methode-- */ 105 void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/) 106 { 105 void PIGraphicX::DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos) 106 { 107 int dx, dy, xi, yi; 108 xi = x; yi = y; 109 if (CalcStringPositionShift(s, pos, dx, dy)) { 110 xi -= dx; yi -= dy; } 107 111 XDrawString (XtDisplay (MyWdg()),mWId, 108 DefGC(), (int)x, (int)y, s, strlen(s)); 109 return; 110 } 111 112 /* --Methode-- */ 113 void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int /*pos*/) 114 { 112 DefGC(), xi, yi, s, strlen(s)); 113 return; 114 } 115 116 /* --Methode-- */ 117 void PIGraphicX::DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos) 118 { 119 int dx, dy, xi, yi; 120 xi = x; yi = y; 121 if (CalcStringPositionShift(s, pos, dx, dy)) { 122 xi -= dx; yi -= dy; } 115 123 XDrawImageString (XtDisplay (MyWdg()),mWId, 116 DefGC(), (int)x, (int)y, s, strlen(s));124 DefGC(), xi, yi, s, strlen(s)); 117 125 return; 118 126 } -
trunk/SophyaPI/PI/psfile.cc
r1846 r1848 130 130 /ff {findfont} bind def /sf {setfont} bind def /scf {scalefont} bind def\n\ 131 131 /rl {rlineto} bind def /tr {translate} bind def\n\ 132 /rmv {rmoveto} bind def \n\ 133 %% Trace de chaine avec justification diverse \n\ 134 %% hxvyshstr stack: TheString \n\ 135 %% hx (x=r,c,l) Horizontal-X Right,Center,Left \n\ 136 %% vy (y=t,c,b) Vertical-Y Top,Center,Bottom \n\ 137 /hlvbshstr %% Horizontal-left Vertical-Bottom justified \n\ 138 { gs 1 -1 sc show gr } bind def \n\ 139 /hcvbshstr %% Horizontal-Center Vertical-Bottom justified \n\ 140 { dup stringwidth pop 2 div neg %% get minus(string length/2) \n\ 141 0 rmoveto gs 1 -1 sc show gr } bind def \n\ 142 /hrvbshstr %% Horizontal-Right Vertical-Bottom justified \n\ 143 { dup stringwidth pop neg %% get minus(string width) \n\ 144 0 rmoveto gs 1 -1 sc show gr } bind def \n\ 145 /hlvcshstr %% Horizontal-left Vertical-Center justified \n\ 146 { dup stringwidth exch pop 2 div %% get (string height)/2 \n\ 147 0 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 148 /hcvcshstr %% Horizontal-Center Vertical-Center justified \n\ 149 { dup stringwidth 2 div exch 2 div neg %% s_wy/2 -s_wx/2 \n\ 150 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 151 /hrvcshstr %% Horizontal-Right Vertical-Center justified \n\ 152 { dup stringwidth 2 div exch neg %% s_wy/2 -s_wx \n\ 153 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 154 /hlvtshstr %% Horizontal-left Vertical-Top justified \n\ 155 { dup stringwidth exch pop %% get s_wy \n\ 156 0 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 157 /hcvtshstr %% Horizontal-Center Vertical-Top justified \n\ 158 { dup stringwidth exch 2 div neg %% s_wy -s_wx/2 \n\ 159 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 160 /hrvtshstr %% Horizontal-Right Vertical-Top justified \n\ 161 { dup stringwidth exch neg %% s_wy -s_wx \n\ 162 exch rmoveto gs 1 -1 sc show gr } bind def \n\ 132 163 %% Tx Ty X0 Y0 box\n\ 133 164 /box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\ … … 795 826 PIFontName FontName, 796 827 PIFontAtt FontAtt, 797 int FontSize) { 828 int FontSize, 829 int pos) { 798 830 bool change = false; 799 831 … … 861 893 setFontDone = true ; // $CHECK$ - doit etre fait uniquement a ce moment 862 894 } 863 864 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 895 if (pos == 0) 896 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 897 else { 898 int posh = pos & PI_HorizontalPosition; 899 int posv = pos & PI_VerticalPosition; 900 if ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBottom)) 901 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) hlvbshstr gr\n", 902 x, y, s) ; 903 else { 904 char ssvp = 'b'; 905 char sshp = 'l'; 906 if (posh != PI_HorizontalLeft) { 907 if (posh == PI_HorizontalCenter) sshp = 'c'; 908 else if (posh == PI_HorizontalRight) sshp = 'r'; 909 else sshp = 'l'; 910 } 911 if (posv != PI_VerticalBottom) { 912 if (posv == PI_VerticalCenter) ssvp = 'c'; 913 else if (posv == PI_VerticalTop) ssvp = 't'; 914 } 915 fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) h%cv%cshstr gr\n", 916 x, y, s, sshp, ssvp) ; 917 } 918 } 865 919 } 866 920 -
trunk/SophyaPI/PI/psfile.h
r1846 r1848 112 112 PIFontName FontName = PI_DefaultFont, 113 113 PIFontAtt FontAtt = PI_NotDefFontAtt, 114 int FontSize = 8); 114 int FontSize = 8, 115 int pos = 0); 115 116 virtual void DrawLine (double x1, double y1, double x2, double y2, 116 117 PIColors DrawColor = PI_NotDefColor,
Note:
See TracChangeset
for help on using the changeset viewer.