Changeset 1897 in Sophya


Ignore:
Timestamp:
Feb 10, 2002, 6:51:58 PM (24 years ago)
Author:
ansari
Message:

Optimisation implementation PIGraphX::DrawMarker - Reza 10/02/2002

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/pidrawer.cc

    r1892 r1897  
    274274
    275275void
     276PIDrawer::SetArrowMarkerAtt(int sz, PIArrowMarker mrk)
     277{
     278  mArrowMrkSz = sz;
     279  mArrowMrk = mrk;
     280}
     281
     282void
    276283PIDrawer::SetColMapId(CMapId cid, bool rev)
    277284{
  • trunk/SophyaPI/PI/pidrawer.h

    r1884 r1897  
    7777  virtual void       SetFont(PIFontName fn, PIFontSize fsz=PI_NotDefFontSize,
    7878                             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);
    8081  virtual void       SetColMapId(CMapId cid=CMAP_OTHER, bool rev=false);
    8182
     
    9192  inline int         GetMarkerSz()  { return(mMSz);  }
    9293  inline PIMarker    GetMarker()    { return(mMrk);  }
     94  inline int           GetArrowMarkerSz()  { return(mArrowMrkSz);  }
     95  inline PIArrowMarker GetArrowMarker()  { return(mArrowMrk);  }
    9396  inline CMapId      GetColMapId()  { return(mCmapid); }
    9497  inline CMapId      GetColMapId(bool & rev)  { rev = mRevCmap; return(mCmapid); }
     
    170173  int                mMSz;
    171174  PIMarker           mMrk; 
     175  int                mArrowMrkSz;
     176  PIArrowMarker      mArrowMrk;
    172177  CMapId             mCmapid;
    173178  bool               mRevCmap;
  • trunk/SophyaPI/PI/pigraphgen.cc

    r1896 r1897  
    238238
    239239  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);
    241242    xs = (int)x+sw_s+deltaposx;
    242243    ys = (int)y+dyu;
    243244    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);
    245246    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);
    247248  }
    248249  else {
     
    254255      xs = (int)xs+deltaposx;
    255256      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);
    257258      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);     
    259260    }
    260261    else if (posh == PI_HorizontalCenter) {
     
    265266      xs = (int)xs+deltaposx;
    266267      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);
    268269      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);           
    270271    }
    271272    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);
    273275      SelFont(fnt_ss);
    274276      xs = (int)x+sw_s+deltaposx;
    275277      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);
    277279      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);
    279281    }
    280282  }
  • trunk/SophyaPI/PI/pigraphx.cc

    r1890 r1897  
    3838xgv.plane_mask = ~0;
    3939mDefGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
    40 
     40mMrkGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
     41mFgMrkGCOK = false;
    4142Init();
    4243}
     
    5556xgv.plane_mask = ~0;
    5657mDefGC = XCreateGC (mDisp, mWId, GCFunction | GCPlaneMask, &xgv);
     58mMrkGC = XCreateGC (PIXDisplay(), XtWindow(PIXtTopWdg()), GCFunction | GCPlaneMask, &xgv);
     59mFgMrkGCOK = false;
    5760Init();
    5861}
     
    7174SelMarker(1, PI_DotMarker); 
    7275mFCfMap = colpix[PI_Black];  mBCfMap = colpix[PI_White];
     76mFgMrkGCOK = false;
    7377}
    7478
     
    7781{
    7882XFreeGC(mDisp, mDefGC);
     83XFreeGC(mDisp, mMrkGC);
    7984}
    8085
     
    238243}
    239244
     245
    240246/* --Methode-- */
    241247void PIGraphicX::DrawArc(PIGrCoord x0, PIGrCoord y0, PIGrCoord dx, PIGrCoord dy,
     
    262268void PIGraphicX::DrawMarker(PIGrCoord x0, PIGrCoord y0)
    263269{
    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
     271if (mMrk == PI_DotMarker) {
    271272  XDrawPoint(mDisp, mWId, DefGC(), (int)x0, (int)y0);
    272 
     273  return;
     274}
    273275else  {
    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();
    276282  switch (mMrk) {
    277283    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);
    280290      break;
    281291    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);
    284296      break; 
    285297    case PI_CircleMarker :
    286       DrawCircle(x0, y0, hmsz);
    287       break;
    288298    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);
    290304      break;
    291305    case PI_BoxMarker :
    292       DrawBox((float)x0-hmsz, (float)y0-hmsz, mMrkSz, mMrkSz);
    293       break;
    294306    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);
    296314      break;
    297315    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;
    302316    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);
    306321      break;
    307322    case  PI_StarMarker :
    308323    case  PI_FStarMarker :
    309324      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);
    312327        }
    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);
    316331      break;
    317332    default :
     
    319334      break;
    320335    }
    321   SelLine(clatt);
     336  if (fgcgc) mFgMrkGCOK = false;
    322337  }
    323338
     
    340355  if (n > NMXXPOINTS)  delete[] pxp; 
    341356  }
    342 else for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
    343 
     357else {
     358  SetupMrkGC();
     359  for(i=0; i<n; i++) DrawMarker(x[i], y[i]);
     360  mFgMrkGCOK = false;
     361}
    344362return;
    345363}
     
    385403return;
    386404}
     405
     406/* --Methode-- */
     407bool PIGraphicX::SetupMrkGC()
     408{
     409if (mFgMrkGCOK) return(false);
     410XCopyGC(mDisp, DefGC(), GCFunction|GCForeground|GCBackground|GCPlaneMask, mMrkGC);
     411XSetLineAttributes(mDisp, mMrkGC, 1, LineSolid, CapButt, JoinMiter);
     412mFgMrkGCOK = true;
     413return true;
     414}
     415
     416/* --Methode-- */
     417void PIGraphicX::MrkDrawPolygon(XPoint *pxp, int n, bool cinc)
     418{
     419
     420if (n <= 0)  return;
     421int mode = CoordModeOrigin;
     422if (cinc) mode =  CoordModePrevious;
     423XDrawLines(mDisp, mWId, mMrkGC, pxp, n, mode);
     424
     425return;
     426}
     427
     428
     429/* --Methode-- */
     430void PIGraphicX::MrkDrawFPolygon(XPoint *pxp, int n, bool cinc)
     431{
     432int mode = CoordModeOrigin;
     433if (cinc) mode =  CoordModePrevious;
     434XFillPolygon(XtDisplay (MyWdg()), mWId, mMrkGC, pxp, n,
     435                        Complex, mode);
     436return;
     437}
     438
    387439
    388440
  • trunk/SophyaPI/PI/pigraphx.h

    r1890 r1897  
    9191    {XSetForeground(mDisp, DefGC(), col);  mFCol = PI_ColorFromMap; mFCfMap = col; }
    9292
     93  bool           SetupMrkGC();
     94  void           MrkDrawPolygon(XPoint* pxp, int n, bool cinc);
     95  void           MrkDrawFPolygon(XPoint* pxp, int n, bool cinc);
     96
    9397//  Structure et identificateur XWindow  associe
    9498  GC mDefGC;
     99  GC mMrkGC;
     100  bool mFgMrkGCOK;
    95101  Display* mDisp;  // Display X associe
    96102  Drawable mWId;   // Identificateur Window/Drawable X
Note: See TracChangeset for help on using the changeset viewer.