Changeset 1897 in Sophya
- Timestamp:
- Feb 10, 2002, 6:51:58 PM (24 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pidrawer.cc
r1892 r1897 274 274 275 275 void 276 PIDrawer::SetArrowMarkerAtt(int sz, PIArrowMarker mrk) 277 { 278 mArrowMrkSz = sz; 279 mArrowMrk = mrk; 280 } 281 282 void 276 283 PIDrawer::SetColMapId(CMapId cid, bool rev) 277 284 { -
trunk/SophyaPI/PI/pidrawer.h
r1884 r1897 77 77 virtual void SetFont(PIFontName fn, PIFontSize fsz=PI_NotDefFontSize, 78 78 PIFontAtt fat=PI_NotDefFontAtt); 79 virtual void SetMarkerAtt(int sz=-1, PIMarker mrk=PI_NotDefMarker); 79 virtual void SetMarkerAtt(int sz=1, PIMarker mrk=PI_NotDefMarker); 80 virtual void SetArrowMarkerAtt(int sz=5, PIArrowMarker mrk=PI_NotDefArrowMarker); 80 81 virtual void SetColMapId(CMapId cid=CMAP_OTHER, bool rev=false); 81 82 … … 91 92 inline int GetMarkerSz() { return(mMSz); } 92 93 inline PIMarker GetMarker() { return(mMrk); } 94 inline int GetArrowMarkerSz() { return(mArrowMrkSz); } 95 inline PIArrowMarker GetArrowMarker() { return(mArrowMrk); } 93 96 inline CMapId GetColMapId() { return(mCmapid); } 94 97 inline CMapId GetColMapId(bool & rev) { rev = mRevCmap; return(mCmapid); } … … 170 173 int mMSz; 171 174 PIMarker mMrk; 175 int mArrowMrkSz; 176 PIArrowMarker mArrowMrk; 172 177 CMapId mCmapid; 173 178 bool mRevCmap; -
trunk/SophyaPI/PI/pigraphgen.cc
r1896 r1897 238 238 239 239 if ((pos == 0) || ((posh == PI_HorizontalLeft) && (posv == PI_VerticalBaseLine))) { 240 if (s != NULL) DrawString(x, y, s, 0); 240 xs = (int)x+sw_s; 241 if (s != NULL) DrawString(xs, y, s, PI_HorizontalRight); 241 242 xs = (int)x+sw_s+deltaposx; 242 243 ys = (int)y+dyu; 243 244 SelFont(fnt_ss); 244 if (s_up != NULL) DrawString(xs, ys, s_up, 0);245 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 245 246 ys = (int)y+dyd; 246 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0);247 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 247 248 } 248 249 else { … … 254 255 xs = (int)xs+deltaposx; 255 256 ys = (int)y+dyu; 256 if (s_up != NULL) DrawString(xs, ys, s_up, 0);257 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 257 258 ys = (int)y+dyd; 258 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0);259 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 259 260 } 260 261 else if (posh == PI_HorizontalCenter) { … … 265 266 xs = (int)xs+deltaposx; 266 267 ys = (int)y+dyu; 267 if (s_up != NULL) DrawString(xs, ys, s_up, 0);268 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 268 269 ys = (int)y+dyd; 269 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0);270 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 270 271 } 271 272 else { 272 if (s != NULL) DrawString(x, y, s, posv); 273 xs = (int)x+sw_s; 274 if (s != NULL) DrawString(x, y, s, PI_HorizontalRight | posv); 273 275 SelFont(fnt_ss); 274 276 xs = (int)x+sw_s+deltaposx; 275 277 ys = (int)y+dyu; 276 if (s_up != NULL) DrawString(xs, ys, s_up, 0);278 if (s_up != NULL) DrawString(xs, ys, s_up, PI_HorizontalLeft); 277 279 ys = (int)y+dyd; 278 if (s_dn != NULL) DrawString(xs, ys, s_dn, 0);280 if (s_dn != NULL) DrawString(xs, ys, s_dn, PI_HorizontalLeft); 279 281 } 280 282 } -
trunk/SophyaPI/PI/pigraphx.cc
r1890 r1897 38 38 xgv.plane_mask = ~0; 39 39 mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv); 40 40 mMrkGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv); 41 mFgMrkGCOK = false; 41 42 Init(); 42 43 } … … 55 56 xgv.plane_mask = ~0; 56 57 mDefGC = XCreateGC (mDisp, mWId, GCFunction | GCPlaneMask, &xgv); 58 mMrkGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv); 59 mFgMrkGCOK = false; 57 60 Init(); 58 61 } … … 71 74 SelMarker(1, PI_DotMarker); 72 75 mFCfMap = colpix[PI_Black]; mBCfMap = colpix[PI_White]; 76 mFgMrkGCOK = false; 73 77 } 74 78 … … 77 81 { 78 82 XFreeGC(mDisp, mDefGC); 83 XFreeGC(mDisp, mMrkGC); 79 84 } 80 85 … … 238 243 } 239 244 245 240 246 /* --Methode-- */ 241 247 void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy, … … 262 268 void PIGraphicX::DrawMarker(PIGrCoord x0, PIGrCoord y0) 263 269 { 264 float hmsz = mMrkSz/2; 265 float dmsz = mMrkSz-hmsz; 266 PIGrCoord x[11],y[11]; 267 int k; 268 PILineAtt clatt; 269 270 if (mMrk == PI_DotMarker) 270 271 if (mMrk == PI_DotMarker) { 271 272 XDrawPoint(mDisp, mWId, DefGC(), (int)x0, (int)y0); 272 273 return; 274 } 273 275 else { 274 clatt = mLAtt; 275 SelLine(PI_ThinLine); 276 int x1,x2,y1,y2,r; 277 float hmsz = mMrkSz/2; 278 float dmsz = mMrkSz-hmsz; 279 XPoint pxp[12]; 280 int k; 281 bool fgcgc = SetupMrkGC(); 276 282 switch (mMrk) { 277 283 case PI_PlusMarker : 278 DrawLine((float)x0-hmsz, y0, (float)x0+dmsz, y0); 279 DrawLine(x0, (float)y0-hmsz, x0, (float)y0+dmsz); 284 x1 = (float)x0-hmsz; y1 = y0; 285 x2 = (float)x0+dmsz; y2 = y1; 286 XDrawLine(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y1, x2, y2); 287 x1 = x0; y1 = (float)y0-hmsz; 288 x2 = x1; y2 = (float)y0+dmsz; 289 XDrawLine(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y1, x2, y2); 280 290 break; 281 291 case PI_CrossMarker : 282 DrawLine((float)x0-hmsz, (float)y0-hmsz, (float)x0+dmsz, (float)y0+dmsz); 283 DrawLine((float)x0-hmsz, (float)y0+dmsz, (float)x0+dmsz, (float)y0-hmsz); 292 x1 = (float)x0-hmsz; y1 = (float)y0-hmsz; 293 x2 = (float)x0+dmsz; y2 = (float)y0+dmsz; 294 XDrawLine(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y1, x2, y2); 295 XDrawLine(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y2, x2, y1); 284 296 break; 285 297 case PI_CircleMarker : 286 DrawCircle(x0, y0, hmsz);287 break;288 298 case PI_FCircleMarker : 289 DrawFCircle(x0, y0, hmsz); 299 r = hmsz; 300 x1 = (int)x0-r; y1 = (int)y0-r; 301 if (mMrk == PI_CircleMarker) 302 XDrawArc(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y1, 2*r, 2*r, 0, 360*64); 303 else XFillArc(XtDisplay (MyWdg()), mWId, mMrkGC, x1, y1, 2*r, 2*r, 0, 360*64); 290 304 break; 291 305 case PI_BoxMarker : 292 DrawBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);293 break;294 306 case PI_FBoxMarker : 295 DrawFBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz); 307 pxp[0].x = (int)x0-hmsz; pxp[0].y = (int)y0-hmsz; 308 pxp[1].x = (int)x0+hmsz; pxp[1].y = (int)y0-hmsz; 309 pxp[2].x = (int)x0+hmsz; pxp[2].y = (int)y0+hmsz; 310 pxp[3].x = (int)x0-hmsz; pxp[3].y = (int)y0+hmsz; 311 pxp[4].x = (int)x0-hmsz; pxp[4].y = (int)y0-hmsz; 312 if (mMrk == PI_BoxMarker) MrkDrawPolygon(pxp, 5, false); 313 else MrkDrawFPolygon(pxp, 5, false); 296 314 break; 297 315 case PI_TriangleMarker : 298 x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz;299 x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz;300 DrawPolygon(x, y, 4);301 break;302 316 case PI_FTriangleMarker : 303 x[1] = mMrkSz; y[1] = 0; x[2] = -hmsz; y[2] = -mMrkSz; 304 x[3] = -dmsz; y[3] = +mMrkSz; x[0] = (float)x0-hmsz; y[0] = (float)y0+hmsz; 305 DrawFPolygon(x, y, 4); 317 pxp[1].x = mMrkSz; pxp[1].y = 0; pxp[2].x = -hmsz; pxp[2].y = -mMrkSz; 318 pxp[3].x = -dmsz; pxp[3].y = +mMrkSz; pxp[0].x = (float)x0-hmsz; pxp[0].y = (float)y0+hmsz; 319 if (mMrk == PI_TriangleMarker) MrkDrawPolygon(pxp, 4, true); 320 else MrkDrawFPolygon(pxp, 4, true); 306 321 break; 307 322 case PI_StarMarker : 308 323 case PI_FStarMarker : 309 324 for(k=0; k<10; k++) { 310 x[k]= (int)(starcoordx[k]*hmsz+(float)x0+0.5);311 y[k]= (int)(starcoordy[k]*hmsz+(float)y0+0.5);325 pxp[k].x = (int)(starcoordx[k]*hmsz+(float)x0+0.5); 326 pxp[k].y = (int)(starcoordy[k]*hmsz+(float)y0+0.5); 312 327 } 313 x[10] = x[0]; y[10] = y[0];314 if (mMrk == PI_StarMarker) DrawPolygon(x, y, 11, false);315 else DrawFPolygon(x, y, 11, false);328 pxp[10].x = pxp[0].x; pxp[10].y = pxp[0].y; 329 if (mMrk == PI_StarMarker) MrkDrawPolygon(pxp, 11, false); 330 else MrkDrawFPolygon(pxp, 11, false); 316 331 break; 317 332 default : … … 319 334 break; 320 335 } 321 SelLine(clatt);336 if (fgcgc) mFgMrkGCOK = false; 322 337 } 323 338 … … 340 355 if (n > NMXXPOINTS) delete[] pxp; 341 356 } 342 else for(i=0; i<n; i++) DrawMarker(x[i], y[i]); 343 357 else { 358 SetupMrkGC(); 359 for(i=0; i<n; i++) DrawMarker(x[i], y[i]); 360 mFgMrkGCOK = false; 361 } 344 362 return; 345 363 } … … 385 403 return; 386 404 } 405 406 /* --Methode-- */ 407 bool PIGraphicX::SetupMrkGC() 408 { 409 if (mFgMrkGCOK) return(false); 410 XCopyGC(mDisp, DefGC(), GCFunction|GCForeground|GCBackground|GCPlaneMask, mMrkGC); 411 XSetLineAttributes(mDisp, mMrkGC, 1, LineSolid, CapButt, JoinMiter); 412 mFgMrkGCOK = true; 413 return true; 414 } 415 416 /* --Methode-- */ 417 void PIGraphicX::MrkDrawPolygon(XPoint *pxp, int n, bool cinc) 418 { 419 420 if (n <= 0) return; 421 int mode = CoordModeOrigin; 422 if (cinc) mode = CoordModePrevious; 423 XDrawLines(mDisp, mWId, mMrkGC, pxp, n, mode); 424 425 return; 426 } 427 428 429 /* --Methode-- */ 430 void PIGraphicX::MrkDrawFPolygon(XPoint *pxp, int n, bool cinc) 431 { 432 int mode = CoordModeOrigin; 433 if (cinc) mode = CoordModePrevious; 434 XFillPolygon(XtDisplay (MyWdg()), mWId, mMrkGC, pxp, n, 435 Complex, mode); 436 return; 437 } 438 387 439 388 440 -
trunk/SophyaPI/PI/pigraphx.h
r1890 r1897 91 91 {XSetForeground(mDisp, DefGC(), col); mFCol = PI_ColorFromMap; mFCfMap = col; } 92 92 93 bool SetupMrkGC(); 94 void MrkDrawPolygon(XPoint* pxp, int n, bool cinc); 95 void MrkDrawFPolygon(XPoint* pxp, int n, bool cinc); 96 93 97 // Structure et identificateur XWindow associe 94 98 GC mDefGC; 99 GC mMrkGC; 100 bool mFgMrkGCOK; 95 101 Display* mDisp; // Display X associe 96 102 Drawable mWId; // Identificateur Window/Drawable X
Note:
See TracChangeset
for help on using the changeset viewer.