Changeset 1886 in Sophya
- Timestamp:
- Jan 28, 2002, 12:33:12 AM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pigraphgen.cc
r1851 r1886 6 6 7 7 #include "pigraphgen.h" 8 9 //++ 10 // Class PILineAtt 11 // Lib PI 12 // include pigraphgen.h 13 //-- 14 15 /* --Methode-- */ 16 PILineAtt::PILineAtt(PILineTyp ltyp) 17 { 18 _ljoincap = PI_JoinMiter*PI_CapButt*256; 19 switch (ltyp) { 20 case PI_NotDefLineAtt : 21 _lwidth = 0; _ldash=PI_LineSolid; 22 break; 23 case PI_NormalLine : 24 _lwidth = 2*8; _ldash=PI_LineSolid; 25 break; 26 case PI_ThinLine : 27 _lwidth = 8; _ldash=PI_LineSolid; 28 break; 29 case PI_ThickLine : 30 _lwidth = 8*4; _ldash=PI_LineSolid; 31 break; 32 case PI_DashedLine : 33 _lwidth = 2*8; _ldash=PI_LineDashed; 34 break; 35 case PI_ThinDashedLine : 36 _lwidth = 8; _ldash=PI_LineDashed; 37 break; 38 case PI_ThickDashedLine : 39 _lwidth = 8*4; _ldash=PI_LineDashed; 40 break; 41 case PI_DottedLine : 42 _lwidth = 2*8; _ldash=PI_LineDotted; 43 break; 44 case PI_ThinDottedLine : 45 _lwidth = 8; _ldash=PI_LineDotted; 46 break; 47 case PI_ThickDottedLine : 48 _lwidth = 8*4; _ldash=PI_LineDotted; 49 break; 50 default : 51 _lwidth = 0; _ldash=PI_LineSolid; 52 break; 53 54 } 55 } 8 56 9 57 //++ … … 67 115 myWdg = NULL; 68 116 myGrb = NULL; 117 SelArrowMarker(); 69 118 } 70 119 … … 74 123 myWdg = wdg; 75 124 myGrb = NULL; 125 SelArrowMarker(); 76 126 } 77 127 … … 81 131 myWdg = NULL; 82 132 myGrb = grb; 133 SelArrowMarker(); 83 134 } 84 135 … … 127 178 //| PI_VerticalBottom PI_VerticalCenter PI_VerticalTop 128 179 //-- 180 181 /* --Methode-- */ 182 void 183 PIGraphicGen::DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 184 const char* s_up, const char* s_dn, int pos) 185 { 186 // AFAIREREZA012002 187 } 129 188 130 189 //++ … … 175 234 //-- 176 235 236 /* --Methode-- */ 237 void 238 PIGraphicGen::DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) 239 { 240 // AFAIREREZA012002 241 } 242 177 243 //++ 178 244 // Titre Tracé d'images (pixmap) … … 230 296 // 231 297 //-- 298 299 void 300 PIGraphicGen::SelArrowMarker(int arrsz, PIArrowMarker arrmrk) 301 { 302 if (arrsz > 0) myArrowMrkSz = arrsz; 303 myArrowMrk = arrmrk; 304 } 232 305 233 306 //++ … … 274 347 275 348 /* --Methode-- */ 349 PIArrowMarker PIGraphicGen::GetArrowMarker() 350 { 351 return(myArrowMrk); 352 } 353 354 /* --Methode-- */ 355 int PIGraphicGen::GetArrowMarkerSize() 356 { 357 return(myArrowMrkSz); 358 } 359 360 /* --Methode-- */ 276 361 PIGrCoord PIGraphicGen::GetFontHeight(PIGrCoord& asc, PIGrCoord& desc) 277 362 { … … 343 428 sMrk = GetMarker(); 344 429 sMrkSz = GetMarkerSize(); 430 sArrowMrk = GetArrowMarker(); 431 sArrowMrkSz = GetArrowMarkerSize(); 345 432 return; 346 433 } … … 355 442 SelLine(sLAtt); 356 443 SelMarker(sMrkSz, sMrk); 444 SelArrowMarker(sArrowMrkSz, sArrowMrk); 357 445 return; 358 446 } -
trunk/SophyaPI/PI/pigraphgen.h
r1851 r1886 15 15 #include "picolist.h" // enum PIColors 16 16 17 18 enum PILineAtt { PI_NotDefLineAtt = -1, 19 PI_NormalLine = 0, PI_ThinLine = 1, PI_ThickLine = 2 , 20 PI_DashedLine = 64, PI_ThinDashedLine = 65, PI_ThickDashedLine = 66 , 21 PI_DottedLine = 128, PI_ThinDottedLine = 129, PI_ThickDottedLine = 130 }; 22 17 // Line drawing attributes 18 enum PILineJoin { PI_JoinMiter=0, PI_JoinRound=1, PI_JoinBevel=2}; 19 enum PILineCap { PI_CapButt=0, PI_CapRound=1, PI_CapProjecting=2}; 20 enum PILineDash { PI_LineSolid, PI_LineDashed, PI_LineDotted, 21 PI_LineDashedDotted}; 22 // Predefined line types 23 enum PILineTyp { PI_NotDefLineAtt = -1, 24 PI_NormalLine, PI_ThinLine, PI_ThickLine, 25 PI_DashedLine, PI_ThinDashedLine, PI_ThickDashedLine, 26 PI_DottedLine, PI_ThinDottedLine, PI_ThickDottedLine }; 27 28 // Marker types 23 29 enum PIMarker { PI_NotDefMarker = -1, 24 30 PI_DotMarker = 0, PI_PlusMarker=1, PI_CrossMarker=2, … … 28 34 PI_StarMarker=9, PI_FStarMarker=10 }; 29 35 30 36 // ArrowMarker types (oriented markers) 37 enum PIArrowMarker { PI_NotDefArrowMarker, PI_BasicArrowMarker, 38 PI_TriangleArrowMarker, PI_FTriangleArrowMarker, 39 PI_ArrowShapedArrowMarker, PI_FArrowShapedArrowMarker }; 40 41 // Flag de positionnement 31 42 enum PIGrPosHorizontal // Flags de positionnement horizontal 32 43 // PI_HorizontalPosition regroupe l'ensemble des bits utilisables … … 66 77 }; 67 78 79 // Classe pour gerer les attributs de lignes 80 class PILineAtt { 81 public: 82 inline PILineAtt(int width=1, PILineDash dash=PI_LineSolid, 83 PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt) 84 { _lwidth = width*8; _ldash=dash; _ljoincap=join+cap*256; } 85 inline PILineAtt(double width, PILineDash dash=PI_LineSolid, 86 PILineJoin join=PI_JoinMiter, PILineCap cap=PI_CapButt) 87 { _lwidth = (unsigned short)(width*8.); _ldash=dash; _ljoincap=join+cap*256; } 88 inline PILineAtt(PILineAtt const& b) 89 { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; } 90 91 PILineAtt(PILineTyp ltyp); 92 93 inline ~PILineAtt() {} 94 95 inline PILineAtt& operator = (PILineAtt const& b) 96 { _lwidth=b._lwidth; _ldash=b._ldash; _ljoincap=b._ljoincap; return(*this); } 97 inline bool operator == (PILineAtt const& b) 98 { return ((_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); } 99 inline bool operator == (PILineTyp ltyp) 100 { return ((*this) == PILineAtt(ltyp)); } 101 inline bool operator != (PILineAtt const& b) 102 { return (!(_lwidth==b._lwidth)&&(_ldash==b._ldash)&&(_ljoincap==b._ljoincap)); } 103 inline bool operator != (PILineTyp ltyp) 104 { return ((*this) != PILineAtt(ltyp)); } 105 106 inline int GetLineWidth() const { return (_lwidth/8); } 107 inline int GetLineWidthx8() const { return (_lwidth); } 108 inline double GetLineWidthD() const { return ((double)_lwidth/8.); } 109 inline PILineDash GetLineDash() const { return _ldash; } 110 inline PILineJoin GetLineJoin() const { return (PILineJoin)(_ljoincap%256); } 111 inline PILineCap GetLineCap() const { return (PILineCap)(_ljoincap/256); } 112 113 inline void SetLineWidth(int lw) { _lwidth = lw*8; } 114 inline void SetLineWidth(double lw) { _lwidth = (unsigned short)(lw*8.); } 115 inline void SetLineDash(PILineDash ld) { _ldash = ld; } 116 inline void SetLineJoin(PILineJoin lj) { _ljoincap = lj+(_ljoincap&0xFF00); } 117 inline void SetLineCap(PILineCap lc) { _ljoincap = lc*256+(_ljoincap&0x00FF); } 118 119 protected: 120 unsigned short _lwidth; // en 1/8 de pixels (ou points) 121 unsigned short _ljoincap; 122 PILineDash _ldash; 123 }; 124 125 // Les differents types de classes PIGraphic 68 126 enum PIGraphicsType { PI_UnknownGraphics = 0, 69 127 PI_ScrWindowGraphics = 2, PI_ScrBufferGraphics = 3, … … 88 146 // Trace graphiques 89 147 virtual void Erase(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0; 148 90 149 virtual void DrawString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) = 0; 91 150 virtual void DrawOpaqueString(PIGrCoord x, PIGrCoord y, const char* s, int pos = 0) = 0; 151 virtual void DrawCompString(PIGrCoord x, PIGrCoord y, const char* s, 152 const char* s_up, const char* s_dn, int pos = 0); 153 92 154 virtual void DrawLine(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2) = 0; 93 155 virtual void DrawBox(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy) = 0; … … 103 165 virtual void DrawFArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, 104 166 double degdeb, double degfin) = 0; 167 105 168 virtual void DrawMarker(PIGrCoord x0, PIGrCoord y0) = 0; 106 169 virtual void DrawMarkers(PIGrCoord *x, PIGrCoord *y, int n) = 0; 170 virtual void DrawArrowMarker(PIGrCoord x1, PIGrCoord y1, PIGrCoord x2, PIGrCoord y2); 171 107 172 virtual void DrawPixmap(PIGrCoord x, PIGrCoord y, unsigned char *pix, 108 173 int sx, int sy, PIColorMap* cmap) = 0; … … 115 180 virtual void SelGOMode(PIGOMode mod=PI_GOCopy) = 0; 116 181 virtual void SelLine(PILineAtt att=PI_NormalLine) = 0; 182 inline void SelLine(PILineTyp lt) { SelLine(PILineAtt(lt)); } 117 183 virtual void SelMarker(int msz=3, PIMarker mrk=PI_DotMarker) = 0; 184 virtual void SelArrowMarker(int arrsz=5, 185 PIArrowMarker arrmrk=PI_BasicArrowMarker); 118 186 // Modifications de fonte 119 187 virtual void SelFont(PIFont & fnt) = 0; … … 133 201 virtual PIMarker GetMarker() = 0; 134 202 virtual int GetMarkerSize() = 0; 203 virtual PIArrowMarker GetArrowMarker(); 204 virtual int GetArrowMarkerSize(); 135 205 136 206 // Acces a la fonte et ses attributs … … 151 221 152 222 PIFont myFont; 223 PIArrowMarker myArrowMrk; 224 int myArrowMrkSz; 153 225 PIColors sFCol, sBCol; 154 226 PIGOMode sGOm; … … 158 230 PIMarker sMrk; 159 231 int sMrkSz; 232 PIArrowMarker sArrowMrk; 233 int sArrowMrkSz; 234 160 235 }; 161 236 -
trunk/SophyaPI/PI/pigraphx.cc
r1848 r1886 472 472 void PIGraphicX::SelLine(PILineAtt att) 473 473 { 474 unsigned int lt=0; 474 475 if (att == mLAtt) return; 476 477 478 unsigned int lw = att.GetLineWidth(); 475 479 int lstyle=LineSolid; 476 char dash[2]= {3,3}; 477 478 if (att == mLAtt) return; 479 480 switch (att) 481 { 482 case PI_NormalLine : 483 lt = 2; 484 lstyle = LineSolid; 485 break; 486 case PI_ThickLine : 487 lt = 4; 488 lstyle = LineSolid; 489 break; 490 case PI_ThinLine : 491 lt = 0; 492 lstyle = LineSolid; 493 break; 494 495 case PI_DashedLine : 496 lt = 2; 497 lstyle = LineOnOffDash; 498 dash[0] = dash[1] = 6; 499 break; 500 case PI_ThickDashedLine : 501 lt = 4; 502 lstyle = LineOnOffDash; 503 dash[0] = dash[1] = 6; 504 break; 505 case PI_ThinDashedLine : 506 lt = 0; 507 lstyle = LineOnOffDash; 508 dash[0] = dash[1] = 6; 509 break; 510 511 case PI_DottedLine : 512 lt = 2; 513 lstyle = LineOnOffDash; 514 dash[0] = 2; dash[1] = 6; 515 break; 516 case PI_ThickDottedLine : 517 lt = 4; 518 lstyle = LineOnOffDash; 519 dash[0] = 2; dash[1] = 6; 520 break; 521 case PI_ThinDottedLine : 522 lt = 0; 523 lstyle = LineOnOffDash; 524 dash[0] = 2; dash[1] = 6; 525 break; 526 527 default: 528 lt = 0; 529 lstyle=LineSolid; 530 break; 531 } 480 int dashlen = 2; 481 char dash[4]= {3,3,3,3}; 482 483 switch (att.GetLineDash()) { 484 case PI_LineSolid : 485 lstyle = LineSolid; 486 break; 487 case PI_LineDashed : 488 lstyle = LineOnOffDash; 489 dash[0] = dash[1] = 6; 490 dashlen = 2; 491 break; 492 case PI_LineDotted : 493 lstyle = LineOnOffDash; 494 dash[0] = 2; dash[1] = 6; 495 dashlen = 2; 496 break; 497 case PI_LineDashedDotted : 498 lstyle = LineOnOffDash; 499 dash[0] = 2; dash[1] = 6; 500 dash[2] = 6; dash[1] = 6; 501 dashlen = 4; 502 break; 503 default : 504 lstyle = LineSolid; 505 break; 506 } 507 508 int ljoin = JoinMiter; 509 switch (att.GetLineJoin()) { 510 case PI_JoinMiter : 511 ljoin = JoinMiter; 512 break; 513 case PI_JoinRound : 514 ljoin = JoinRound; 515 break; 516 case PI_JoinBevel : 517 ljoin = JoinBevel; 518 break; 519 default : 520 ljoin = JoinMiter; 521 break; 522 } 523 524 int lcap = CapButt; 525 switch (att.GetLineCap()) { 526 case PI_CapButt : 527 lcap = CapButt; 528 break; 529 case PI_CapRound : 530 lcap = CapRound; 531 break; 532 case PI_CapProjecting : 533 lcap = CapProjecting; 534 break; 535 default : 536 lcap = CapButt; 537 break; 538 } 532 539 533 540 if (lstyle != LineSolid) 534 XSetDashes( mDisp, DefGC(), 0, dash, 2);541 XSetDashes( mDisp, DefGC(), 0, dash, dashlen); 535 542 536 XSetLineAttributes(mDisp, DefGC(), l t, lstyle, CapButt, JoinMiter);543 XSetLineAttributes(mDisp, DefGC(), lw, lstyle, lcap, ljoin); 537 544 mLAtt = att; 538 545 return; -
trunk/SophyaPI/PI/psfile.cc
r1855 r1886 128 128 /sc {scale} bind def /S {gs 1 -1 sc show gr} bind def \n\ 129 129 /slw {setlinewidth} bind def\n\ 130 /sljoin {setlinejoin} bind def\n\ 131 /slcap {setlinecap} bind def\n\ 132 /slsolid {[] 0 setdash} bind def %% Solid-Line \n\ 133 /sldash {[6 6] 0 setdash} bind def %% Dashed-Line \n\ 134 /sldott {[2 6] 0 setdash} bind def %% Dotted-Line \n\ 135 /sldashdott {[2 6 6 6] 0 setdash} bind def %% Dash-Dotted-Line \n\ 130 136 /ff {findfont} bind def /sf {setfont} bind def /scf {scalefont} bind def\n\ 131 137 /rl {rlineto} bind def /tr {translate} bind def\n\ … … 951 957 PILineAtt LineAtt) { 952 958 953 int lw = 0 ; 954 955 switch(LineAtt) { 956 case PI_NotDefLineAtt: 957 break ; 958 case PI_NormalLine: 959 lw = 2. ; 960 break ; 961 case PI_ThinLine: 962 lw = 1 ; 963 break ; 964 case PI_ThickLine: 965 lw = 4 ; 966 break ; 967 } 968 969 /* Line Att */ 970 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) { 971 mLineAtt = LineAtt; 972 fprintf(mPSFile, "%d slw ", lw) ; 973 } 959 960 /* Line Att */ 961 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 962 SelectLine(LineAtt); 974 963 975 964 /* Couleurs */ … … 990 979 PILineAtt LineAtt) { 991 980 981 /* Line Att */ 982 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 983 SelectLine(LineAtt); 984 992 985 /* Changement couleurs ? */ 993 986 if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) { … … 996 989 } 997 990 998 /* Line Att */999 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {1000 mLineAtt = LineAtt;1001 fprintf(mPSFile, "%d slw ", mLineAtt) ;1002 }1003 991 1004 992 /* On dessine */ … … 1013 1001 PILineAtt LineAtt) { 1014 1002 1015 /* Line Att */ 1016 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) { 1017 mLineAtt = LineAtt; 1018 fprintf(mPSFile, "%d slw ", mLineAtt) ; 1019 } 1003 /* Line Att */ 1004 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1005 SelectLine(LineAtt); 1020 1006 1021 1007 /* Dessin du fond */ … … 1041 1027 PILineAtt LineAtt) { 1042 1028 1029 /* Line Att */ 1030 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1031 SelectLine(LineAtt); 1032 1043 1033 /* Couleurs */ 1044 1034 if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) { … … 1047 1037 } 1048 1038 1049 /* Line Att */1050 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {1051 mLineAtt = LineAtt;1052 fprintf(mPSFile, "%d slw ", mLineAtt);1053 }1054 1039 1055 1040 /* Dessin */ … … 1064 1049 PILineAtt LineAtt) { 1065 1050 1066 /* Line Att */ 1067 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) { 1068 mLineAtt = LineAtt; 1069 fprintf(mPSFile, "%d slw ", mLineAtt) ; 1070 } 1051 /* Line Att */ 1052 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1053 SelectLine(LineAtt); 1071 1054 1072 1055 /* Dessin du fond */ … … 1094 1077 PILineAtt LineAtt, bool cinc) { 1095 1078 1096 /* Line Att */ 1097 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) { 1098 mLineAtt = LineAtt; 1099 fprintf(mPSFile, "%d slw ", mLineAtt) ; 1100 } 1079 /* Line Att */ 1080 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1081 SelectLine(LineAtt); 1101 1082 1102 1083 /* Couleur */ … … 1124 1105 PILineAtt LineAtt, bool cinc) { 1125 1106 1126 /* Line Att */ 1127 if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) { 1128 mLineAtt = LineAtt; 1129 fprintf(mPSFile, "%d slw ", mLineAtt) ; 1130 } 1107 /* Line Att */ 1108 if ( (LineAtt != PI_NotDefLineAtt) && (LineAtt != mLineAtt) ) 1109 SelectLine(LineAtt); 1131 1110 1132 1111 const char* cmd ; … … 1251 1230 } 1252 1231 1232 1233 void PSFile::SelectLine(PILineAtt att) 1234 { 1235 1236 fprintf(mPSFile, "%d slw ", att.GetLineWidth()) ; 1237 switch (att.GetLineDash()) { 1238 case PI_LineSolid : 1239 fprintf(mPSFile, "slsolid "); 1240 break; 1241 case PI_LineDashed : 1242 fprintf(mPSFile, "sldash "); 1243 break; 1244 case PI_LineDotted : 1245 fprintf(mPSFile, "sldott "); 1246 break; 1247 case PI_LineDashedDotted : 1248 fprintf(mPSFile, "sldashdott "); 1249 break; 1250 default : 1251 fprintf(mPSFile, "slsolid "); 1252 break; 1253 } 1254 1255 switch (att.GetLineJoin()) { 1256 case PI_JoinMiter : 1257 fprintf(mPSFile, "0 sljoin "); 1258 break; 1259 case PI_JoinRound : 1260 fprintf(mPSFile, "1 sljoin "); 1261 break; 1262 case PI_JoinBevel : 1263 fprintf(mPSFile, "2 sljoin "); 1264 break; 1265 default : 1266 fprintf(mPSFile, "0 sljoin "); 1267 break; 1268 } 1269 1270 switch (att.GetLineCap()) { 1271 case PI_CapButt : 1272 fprintf(mPSFile, "0 slcap \n"); 1273 break; 1274 case PI_CapRound : 1275 fprintf(mPSFile, "1 slcap \n"); 1276 break; 1277 case PI_CapProjecting : 1278 fprintf(mPSFile, "2 slcap \n"); 1279 break; 1280 default : 1281 fprintf(mPSFile, "0 slcap \n"); 1282 break; 1283 } 1284 mLineAtt = att; 1285 } 1286 1253 1287 /* 1254 1288 * Conversion -
trunk/SophyaPI/PI/psfile.h
r1848 r1886 180 180 181 181 private: 182 void SelectLine(PILineAtt att); // attributs de ligne ds le fichier PS 182 183 183 184 /* Fichier ps/eps */ … … 198 199 199 200 /* Attributs graphiques, initialises par constructeur */ 200 enumPIColors mDrawColor; /* Couleur de trace courante */201 enumPIColors mFillColor; /* Couleur de remplissage courante */202 enumPIFontAtt mFontAtt;201 PIColors mDrawColor; /* Couleur de trace courante */ 202 PIColors mFillColor; /* Couleur de remplissage courante */ 203 PIFontAtt mFontAtt; 203 204 // enum PIFontSize mFontSize; 204 205 int mFontSize; 205 enumPIFontName mFontName;206 enumPILineAtt mLineAtt; /* Epaisseur d une ligne */207 enumPIMarker mMarker; /* Marker courant */208 int 206 PIFontName mFontName; 207 PILineAtt mLineAtt; /* Epaisseur d une ligne */ 208 PIMarker mMarker; /* Marker courant */ 209 int mMarkerSize; /* Taille (en points) du marker courant */ 209 210 bool setFontDone ; /* Pour forcer la selection de Marker apres DrawString() */ 210 211
Note:
See TracChangeset
for help on using the changeset viewer.