[BACK]Return to plotp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / plot

Diff for /OpenXM_contrib2/asir2000/plot/plotp.c between version 1.3 and 1.6

version 1.3, 2000/08/21 08:31:51 version 1.6, 2000/11/09 01:51:13
Line 23 
Line 23 
  * shall be made on your publication or presentation in any form of the   * shall be made on your publication or presentation in any form of the
  * results obtained by use of the SOFTWARE.   * results obtained by use of the SOFTWARE.
  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by   * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
  * e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification   * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
  * for such modification or the source code of the modified part of the   * for such modification or the source code of the modified part of the
  * SOFTWARE.   * SOFTWARE.
  *   *
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM: OpenXM_contrib2/asir2000/plot/plotp.c,v 1.2 2000/03/07 01:32:44 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/plot/plotp.c,v 1.5 2000/11/07 06:06:40 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
Line 59 
Line 59 
 #define EXP10(a) pow(10.0,a)  #define EXP10(a) pow(10.0,a)
 #endif  #endif
   
   #if defined(VISUAL)
   static POINT oldpos;
   #endif
   
 if_print(display,tab,can)  if_print(display,tab,can)
 DISPLAY *display;  DISPLAY *display;
 double **tab;  double **tab;
Line 160  struct canvas *can;
Line 164  struct canvas *can;
 {  {
         int len,i;          int len,i;
         POINT *pa;          POINT *pa;
   
   #if defined(VISUAL)
           len = can->pa[0].length;
           pa = can->pa[0].pos;
   
           Polyline(can->pix,pa,len);
   //      for ( i = 0; i < len-1; i++ ) {
   //              DRAWLINE(display,can->pix,drawGC,pa[i].x,pa[i].y,pa[i+1].x,pa[i+1].y);
   //      }
   #else
         XDrawLines(display,can->pix,drawGC,          XDrawLines(display,can->pix,drawGC,
                 can->pa[0].pos,can->pa[0].length,CoordModeOrigin);                  can->pa[0].pos,can->pa[0].length,CoordModeOrigin);
         XFlush(display);          XFlush(display);
   #endif
 }  }
   
   draw_point(display,can,x,y,color)
   DISPLAY *display;
   struct canvas *can;
   int x,y;
   int color;
   {
   #if defined(VISUAL)
           HDC dc;
   
           SetPixel(can->pix,x,y,(COLORREF)color);
           dc = GetDC(can->hwnd);
           SetPixel(dc,x,y,(COLORREF)color);
           ReleaseDC(can->hwnd,dc);
   #else
           DRAWPOINT(display,can->pix,drawGC,x,y);
           DRAWPOINT(display,can->window,drawGC,x,y);
           XFlush(display);
   #endif
   }
   
   draw_line(display,can,x,y,u,v,color)
   DISPLAY *display;
   struct canvas *can;
   int x,y,u,v;
   int color;
   {
   #if defined(VISUAL)
           HDC dc;
           HPEN pen,oldpen;
   
           if ( color ) {
                   pen = CreatePen(PS_SOLID,1,color);
                   oldpen = SelectObject(can->pix,pen);
                   DRAWLINE(display,can->pix,drawGC,x,y,u,v);
                   SelectObject(can->pix,oldpen);
   
                   dc = GetDC(can->hwnd);
                   oldpen = SelectObject(dc,pen);
                   DRAWLINE(display,dc,drawGC,x,y,u,v);
                   SelectObject(dc,oldpen);
                   ReleaseDC(can->hwnd,dc);
   
                   DeleteObject(pen);
           } else {
                   DRAWLINE(display,can->pix,drawGC,x,y,u,v);
                   dc = GetDC(can->hwnd);
                   DRAWLINE(display,dc,drawGC,x,y,u,v);
                   ReleaseDC(can->hwnd,dc);
           }
   #else
           DRAWLINE(display,can->pix,drawGC,x,y,u,v);
           DRAWLINE(display,can->window,drawGC,x,y,u,v);
           XFlush(display);
   #endif
   }
   
 #define D 5  #define D 5
   
 pline(display,can,d)  pline(display,can,d)
Line 178  DRAWABLE d;
Line 248  DRAWABLE d;
         char buf[BUFSIZ];          char buf[BUFSIZ];
         double adjust_scale();          double adjust_scale();
   
         if ( can->noaxis )          /* XXX : should be cleaned up */
           if ( can->noaxis || (can->mode == MODE_PLOT && !can->pa) )
                 return;                  return;
           if ( can->mode == MODE_INTERACTIVE )
                   return;
   
         xadj = yadj = 0;          xadj = yadj = 0;
         if ( (can->xmin < 0) && (can->xmax > 0) ) {          if ( (can->xmin < 0) && (can->xmax > 0) ) {
                 x0 = (int)((can->width-1)*(-can->xmin/(can->xmax-can->xmin)));                  x0 = (int)((can->width)*(-can->xmin/(can->xmax-can->xmin)));
                 DRAWLINE(display,d,dashGC,x0,0,x0,can->height);                  DRAWLINE(display,d,dashGC,x0,0,x0,can->height);
         } else if ( can->xmin >= 0 )          } else if ( can->xmin >= 0 )
                 x0 = 0;                  x0 = 0;
         else          else
                 x0 = can->width-1-D;                  x0 = can->width-D;
         if ( (can->ymin < 0) && (can->ymax > 0) ) {          if ( (can->ymin < 0) && (can->ymax > 0) ) {
                 y0 = (int)((can->height-1)*(can->ymax/(can->ymax-can->ymin)));                  y0 = (int)((can->height)*(can->ymax/(can->ymax-can->ymin)));
                 DRAWLINE(display,d,dashGC,0,y0,can->width,y0);                  DRAWLINE(display,d,dashGC,0,y0,can->width,y0);
         } else if ( can->ymin >= 0 )          } else if ( can->ymin >= 0 )
                 y0 = can->height-1;                  y0 = can->height;
         else          else
                 y0 = D;                  y0 = D;
   
           /* scale on x-axis */
         w = can->xmax-can->xmin;          w = can->xmax-can->xmin;
         w1 = w * DEFAULTWIDTH/can->width;          w1 = w * DEFAULTWIDTH/can->width;
         e = adjust_scale(EXP10(floor(log10(w1))),w1);          e = adjust_scale(EXP10(floor(log10(w1))),w1);
Line 203  DRAWABLE d;
Line 278  DRAWABLE d;
                 x = (int)can->width*(n*e-can->xmin)/w;                  x = (int)can->width*(n*e-can->xmin)/w;
                 DRAWLINE(display,d,drawGC,x,y0,x,y0-D);                  DRAWLINE(display,d,drawGC,x,y0,x,y0-D);
                 sprintf(buf,"%g",n*e);                  sprintf(buf,"%g",n*e);
                 DRAWSTRING(display,d,scaleGC,x+2,y0,buf,strlen(buf));                  DRAWSTRING(display,d,scaleGC,x+2,y0+2,buf,strlen(buf));
         }          }
   
           /* scale on y-axis */
         w = can->ymax-can->ymin;          w = can->ymax-can->ymin;
         w1 = w * DEFAULTHEIGHT/can->height;          w1 = w * DEFAULTHEIGHT/can->height;
         e = adjust_scale(EXP10(floor(log10(w1))),w1);          e = adjust_scale(EXP10(floor(log10(w1))),w1);
Line 212  DRAWABLE d;
Line 289  DRAWABLE d;
                 y = (int)can->height*(1-(n*e-can->ymin)/w);                  y = (int)can->height*(1-(n*e-can->ymin)/w);
                 DRAWLINE(display,d,drawGC,x0,y,x0+D,y);                  DRAWLINE(display,d,drawGC,x0,y,x0+D,y);
                 sprintf(buf,"%g",n*e);                  sprintf(buf,"%g",n*e);
                 if ( can->xmax <= 0 )                  if ( can->xmax <= 0 ) {
   #if !defined(VISUAL)
                         xadj = TEXTWIDTH(sffs,buf,strlen(buf));                          xadj = TEXTWIDTH(sffs,buf,strlen(buf));
                 DRAWSTRING(display,d,scaleGC,x0-xadj,y,buf,strlen(buf));  #else
                           SIZE size;
   
                           GetTextExtentPoint32(d,buf,strlen(buf),&size);
                           xadj = size.cx;
   #endif
                   }
                   DRAWSTRING(display,d,scaleGC,x0+2-xadj,y+2,buf,strlen(buf));
         }          }
 }  }
   
Line 238  initmarker(can,message)
Line 323  initmarker(can,message)
 struct canvas *can;  struct canvas *can;
 char *message;  char *message;
 {  {
   #if defined(VISUAL)
           can->real_can->percentage = 0;
           can->real_can->prefix = message;
   #else
         XawScrollbarSetThumb(can->xdone,0.0,0.0);          XawScrollbarSetThumb(can->xdone,0.0,0.0);
         XawScrollbarSetThumb(can->ydone,1.0,0.0);          XawScrollbarSetThumb(can->ydone,1.0,0.0);
         XFlush(display);          XFlush(display);
   #endif
 }  }
   
 marker(can,dir,p)  marker(can,dir,p)
 struct canvas *can;  struct canvas *can;
 int dir,p;  int dir,p;
 {  {
   #if defined(VISUAL)
           if ( dir == DIR_X )
                   can->real_can->percentage = ceil((float)p/(float)can->real_can->width*100);
           else if ( dir == DIR_Y )
                   can->real_can->percentage = ceil((float)p/(float)can->real_can->height*100);
           else
                   can->real_can->percentage = ceil((float)p/(float)can->real_can->nzstep*100);
   #else
         if ( dir == DIR_X ) {          if ( dir == DIR_X ) {
                 XawScrollbarSetThumb(can->xdone,(float)p/(float)can->width,0.05);                  XawScrollbarSetThumb(can->xdone,(float)p/(float)can->width,0.05);
                 count_and_flush();                  count_and_flush();
Line 257  int dir,p;
Line 355  int dir,p;
                 XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->nzstep,0.05);                  XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->nzstep,0.05);
                 flush();                  flush();
         }          }
   #endif
 }  }
   
 define_cursor(w,cur)  define_cursor(w,cur)
 WINDOW w;  WINDOW w;
 CURSOR cur;  CURSOR cur;
 {  {
   #if !defined(VISUAL)
         XDefineCursor(display,w,cur); flush();          XDefineCursor(display,w,cur); flush();
   #endif
 }  }
   
 static int flush_count;  static int flush_count;
Line 274  static int flush_count;
Line 375  static int flush_count;
 #endif  #endif
   
 count_and_flush() {  count_and_flush() {
   #if !defined(VISUAL)
         if ( ++flush_count == MAX_COUNT )          if ( ++flush_count == MAX_COUNT )
                 flush();                  flush();
   #endif
 }  }
   
 flush() {  flush() {
   #if !defined(VISUAL)
         flush_count = 0;          flush_count = 0;
         XFlush(display);          XFlush(display);
   #endif
 }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>