version 1.22, 2015/08/06 10:01:53 |
version 1.25, 2018/03/29 01:32:55 |
|
|
* 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.21 2014/08/20 16:51:34 ohara Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/plotp.c,v 1.24 2017/08/31 08:52:27 ohara Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#define EXP10(a) pow(10.0,a) |
#define EXP10(a) pow(10.0,a) |
#endif |
#endif |
|
|
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
static POINT oldpos; |
static POINT oldpos; |
#endif |
#endif |
|
|
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
extern Pixel BackPixel; |
extern Pixel BackPixel; |
unsigned long GetColor(Display *, char *); |
unsigned long GetColor(Display *, char *); |
|
|
unsigned long GetColor(Display *dis, char *color_name) |
unsigned long GetColor(Display *dis, char *color_name) |
{ |
{ |
Colormap cmap; |
Colormap cmap; |
XColor near_color, true_color; |
XColor near_color, true_color; |
|
|
cmap = DefaultColormap( dis, 0 ); |
cmap = DefaultColormap( dis, 0 ); |
XAllocNamedColor( dis, cmap, color_name, &near_color, &true_color ); |
XAllocNamedColor( dis, cmap, color_name, &near_color, &true_color ); |
return( near_color.pixel ); |
return( near_color.pixel ); |
} |
} |
|
|
void area_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
void area_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
int ix,iy,width,height,wc,**mask; |
int ix,iy,width,height,wc,**mask; |
XImage *image; |
XImage *image; |
DRAWABLE pix; |
DRAWABLE pix; |
unsigned int color,black,white,c2; |
unsigned int color,black,white,c2; |
//unsigned long color,black,white,c2; |
//unsigned long color,black,white,c2; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
//GXcode 0:new 1:cp 2:and 3:or 4:xor |
//GXcode 0:new 1:cp 2:and 3:or 4:xor |
width=can->width; |
width=can->width; |
height=can->height; |
height=can->height; |
pix=can->pix; |
pix=can->pix; |
mask=(int **)ALLOCA((width)*sizeof(int *)); |
mask=(int **)ALLOCA((width)*sizeof(int *)); |
for(ix=0;ix<width;ix++)mask[ix]=(int *)ALLOCA((height)*sizeof(int)); |
for(ix=0;ix<width;ix++)mask[ix]=(int *)ALLOCA((height)*sizeof(int)); |
// create mask table values boundary:0 positive:1 negativ:-1 |
// create mask table values boundary:0 positive:1 negativ:-1 |
for(ix=0;ix<width;ix++)for(iy=0;iy<height;iy++) |
for(ix=0;ix<width;ix++)for(iy=0;iy<height;iy++) |
if((tab[ix][iy]>0)&&(tab[ix+1][iy]>0)&&(tab[ix][iy+1]>0)&& |
if((tab[ix][iy]>0)&&(tab[ix+1][iy]>0)&&(tab[ix][iy+1]>0)&& |
(tab[ix+1][iy+1]>0)) mask[ix][iy]=1;//all postive |
(tab[ix+1][iy+1]>0)) mask[ix][iy]=1;//all postive |
else if((tab[ix][iy]<0)&&(tab[ix+1][iy]<0)&&(tab[ix][iy+1]<0)&& |
else if((tab[ix][iy]<0)&&(tab[ix+1][iy]<0)&&(tab[ix][iy+1]<0)&& |
(tab[ix+1][iy+1]<0)) mask[ix][iy]=-1;//all negativ |
(tab[ix+1][iy+1]<0)) mask[ix][iy]=-1;//all negativ |
else mask[ix][iy]=0;//boundary |
else mask[ix][iy]=0;//boundary |
flush(); |
flush(); |
black=GetColor(display,"black"); |
black=GetColor(display,"black"); |
white=GetColor(display,"white"); |
white=GetColor(display,"white"); |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
color=can->color; |
color=can->color; |
image=XGetImage(display,pix,0,0,width,height,-1,ZPixmap); |
image=XGetImage(display,pix,0,0,width,height,-1,ZPixmap); |
for(ix=0;ix<width;ix++){ |
for(ix=0;ix<width;ix++){ |
for(iy=0;iy<height;iy++){ |
for(iy=0;iy<height;iy++){ |
c2=XGetPixel(image,ix,height-iy-1); |
c2=XGetPixel(image,ix,height-iy-1); |
if(c2==white)wc=-1; |
if(c2==white)wc=-1; |
else if(c2==black)wc=0; |
else if(c2==black)wc=0; |
else wc=1; |
else wc=1; |
if(wc!=0){//XPutPixel(image,ix,iy,black); |
if(wc!=0){//XPutPixel(image,ix,iy,black); |
if(mask[ix][iy]==0)XPutPixel(image,ix,height-iy-1,black);//boundary |
if(mask[ix][iy]==0)XPutPixel(image,ix,height-iy-1,black);//boundary |
else { |
else { |
switch (GXcode){ |
switch (GXcode){ |
case 0: //new window |
case 0: //new window |
case 1: //cp |
case 1: //cp |
if(mask[ix][iy]==1)XPutPixel(image,ix,height-iy-1,color); |
if(mask[ix][iy]==1)XPutPixel(image,ix,height-iy-1,color); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
break; |
break; |
case 2: //and |
case 2: //and |
if((mask[ix][iy]==1)&&(wc==1))XPutPixel(image,ix,height-iy-1,color); |
if((mask[ix][iy]==1)&&(wc==1))XPutPixel(image,ix,height-iy-1,color); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
break; |
break; |
case 3: //or |
case 3: //or |
if((mask[ix][iy]==1)||(wc==1))XPutPixel(image,ix,height-iy-1,color); |
if((mask[ix][iy]==1)||(wc==1))XPutPixel(image,ix,height-iy-1,color); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
break; |
break; |
case 4: //xor |
case 4: //xor |
if((mask[ix][iy]==1)^(wc==1))XPutPixel(image,ix,height-iy-1,color); |
if((mask[ix][iy]==1)^(wc==1))XPutPixel(image,ix,height-iy-1,color); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
else XPutPixel(image,ix,height-iy-1,BackPixel); |
break; |
break; |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
XPutImage(display,pix,drawGC,image,0,0,0,0,width,height); |
XPutImage(display,pix,drawGC,image,0,0,0,0,width,height); |
count_and_flush(); |
count_and_flush(); |
flush(); |
flush(); |
} |
} |
#else |
#else |
void area_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
void area_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
Line 146 void area_print(DISPLAY *display,double **tab,struct c |
|
Line 146 void area_print(DISPLAY *display,double **tab,struct c |
|
#endif |
#endif |
|
|
void over_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
void over_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
int ix,iy,width,height; |
int ix,iy,width,height; |
DRAWABLE pix; |
DRAWABLE pix; |
double vmin,vmax; |
double vmin,vmax; |
//GXcode 0:over 1:cp 2:and 3:or 4:xor |
//GXcode 0:over 1:cp 2:and 3:or 4:xor |
pix=can->pix; width=can->width; height=can->height; |
pix=can->pix; width=can->width; height=can->height; |
for(ix=0;ix<width;ix++){ |
for(ix=0;ix<width;ix++){ |
for(iy=0;iy<height;iy++){ |
for(iy=0;iy<height;iy++){ |
vmax= |
vmax= |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
vmin= |
vmin= |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
if(vmin<=0.0&vmax>=0.0)DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
if(vmin<=0.0 && vmax>=0.0) DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
} |
} |
count_and_flush(); |
count_and_flush(); |
} |
} |
flush(); |
flush(); |
} |
} |
|
|
void if_printNG(DISPLAY *display,double **tab,struct canvas *can,int cond){ |
void if_printNG(DISPLAY *display,double **tab,struct canvas *can,int cond){ |
int ix,iy,width,height; |
int ix,iy,width,height; |
double zst,zed,zsp; |
double zst,zed,zsp; |
DRAWABLE pix; |
DRAWABLE pix; |
width=can->width; height=can->height; pix=can->pix; |
width=can->width; height=can->height; pix=can->pix; |
if(cond==0){ |
if(cond==0){ |
//IFPLOTB |
//IFPLOTB |
for(iy=0;iy<height-1;iy++)for(ix=0;ix<width-1;ix++) |
for(iy=0;iy<height-1;iy++)for(ix=0;ix<width-1;ix++) |
if(tab[ix][iy]==0.0) DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
if(tab[ix][iy]==0.0) DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
} else if(cond==1) { |
} else if(cond==1) { |
//IFPLOT,IFPLOTD,IFPLOTQ |
//IFPLOT,IFPLOTD,IFPLOTQ |
for(iy=0;iy<height-1;iy++)for(ix=0;ix<width-1;ix++){ |
for(iy=0;iy<height-1;iy++)for(ix=0;ix<width-1;ix++){ |
if(tab[ix][iy]==0.0) DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
if(tab[ix][iy]==0.0) DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
else if(tab[ix][iy]>0){ |
else if(tab[ix][iy]>0){ |
if(tab[ix+1][iy+1]<0||tab[ix][iy+1]<0||tab[ix+1][iy]<0) |
if(tab[ix+1][iy+1]<0||tab[ix][iy+1]<0||tab[ix+1][iy]<0) |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
} else if(tab[ix+1][iy+1]>0||tab[ix][iy+1]>0||tab[ix+1][iy]>0) |
} else if(tab[ix+1][iy+1]>0||tab[ix][iy+1]>0||tab[ix+1][iy]>0) |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
count_and_flush(); |
count_and_flush(); |
} |
} |
} |
} |
flush(); |
flush(); |
} |
} |
|
|
void polar_print(DISPLAY *display,struct canvas *can){ |
void polar_print(DISPLAY *display,struct canvas *can){ |
int len,i,j,x,y; |
int len,i,j,x,y; |
unsigned int color; |
unsigned int color; |
POINT *pa; |
POINT *pa; |
|
|
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
HPEN pen,oldpen; |
HPEN pen,oldpen; |
len=can->pa[0].length; |
len=can->pa[0].length; |
color=can->color; |
color=can->color; |
pa=can->pa[0].pos; |
pa=can->pa[0].pos; |
for(i=1;i<len;i++){ |
for(i=1;i<len;i++){ |
j=i-1; |
j=i-1; |
if(color){ |
if(color){ |
pen=CreatePen(PS_SOLID,1,color); |
pen=CreatePen(PS_SOLID,1,color); |
oldpen=SelectObject(can->pix,pen); |
oldpen=SelectObject(can->pix,pen); |
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
SelectObject(can->pix,oldpen); |
SelectObject(can->pix,oldpen); |
|
|
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
oldpen = SelectObject(dc,pen); |
oldpen = SelectObject(dc,pen); |
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
SelectObject(dc,oldpen); |
SelectObject(dc,oldpen); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
|
|
DeleteObject(pen); |
DeleteObject(pen); |
} else { |
} else { |
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
} |
} |
} |
} |
#else |
#else |
len=can->pa[0].length; |
len=can->pa[0].length; |
color=can->color; |
color=can->color; |
pa=can->pa[0].pos; |
pa=can->pa[0].pos; |
for(i=1;i<len;i++){ |
for(i=1;i<len;i++){ |
j=i-1; |
j=i-1; |
DRAWLINE(display,can->pix,cdrawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
DRAWLINE(display,can->pix,cdrawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
} |
} |
XFlush(display); |
XFlush(display); |
#endif |
#endif |
} |
} |
|
|
|
|
void if_print(DISPLAY *display,double **tab,struct canvas *can){ |
void if_print(DISPLAY *display,double **tab,struct canvas *can){ |
int ix,iy,width,height; |
int ix,iy,width,height; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
DRAWABLE pix; |
DRAWABLE pix; |
|
|
if ( can->mode == modeNO(CONPLOT) ) { |
if ( can->mode == modeNO(CONPLOT) ) { |
con_print(display,tab,can); return; |
con_print(display,tab,can); return; |
} |
} |
flush(); |
flush(); |
width = can->width; height = can->height; pix = can->pix; |
width = can->width; height = can->height; pix = can->pix; |
for( ix=0; ix<width-1; ix++ ) |
for( ix=0; ix<width-1; ix++ ) |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) || |
if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) || |
((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) { |
((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) { |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
count_and_flush(); |
count_and_flush(); |
} |
} |
flush(); |
flush(); |
/* |
/* |
int i,ix,iy,width,height; |
int i,ix,iy,width,height; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
double **vmax,**vmin,*zst,zstep,zv,u,l; |
double **vmax,**vmin,*zst,zstep,zv,u,l; |
DRAWABLE pix; |
DRAWABLE pix; |
POINT *pa,*pa1; |
POINT *pa,*pa1; |
struct pa *parray; |
struct pa *parray; |
|
|
if(can->mode==modeNO(CONPLOT)){ |
if(can->mode==modeNO(CONPLOT)){ |
width=can->width;height=can->height;pix=can->pix; |
width=can->width;height=can->height;pix=can->pix; |
//con_print(display,tab,can); |
//con_print(display,tab,can); |
// calc all cell max,min value |
// calc all cell max,min value |
vmax=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmax=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmin=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmin=((double **)ALLOCA((width+1)*sizeof(double *))); |
for(i=0;i<width;i++){ |
for(i=0;i<width;i++){ |
vmax[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmax[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmin[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmin[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
} |
} |
for(ix=0;ix<width;ix++){ |
for(ix=0;ix<width;ix++){ |
for(iy=0;iy<height;iy++){ |
for(iy=0;iy<height;iy++){ |
vmax[ix][iy]= |
vmax[ix][iy]= |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
vmin[ix][iy]= |
vmin[ix][iy]= |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
} |
} |
} |
} |
if(can->zmax==can->zmin)zstep=(can->vmax-can->vmin)/can->nzstep; |
if(can->zmax==can->zmin)zstep=(can->vmax-can->vmin)/can->nzstep; |
else zstep=(can->zmax-can->zmin)/can->nzstep; |
else zstep=(can->zmax-can->zmin)/can->nzstep; |
zst=(double *)ALLOCA((can->nzstep+1)*sizeof(double)); |
zst=(double *)ALLOCA((can->nzstep+1)*sizeof(double)); |
zv=can->xmin; |
zv=can->xmin; |
for(i=0,zv=can->xmin;i<can->nzstep;zv+=zstep,i++)zst[i]=zv; |
for(i=0,zv=can->xmin;i<can->nzstep;zv+=zstep,i++)zst[i]=zv; |
for(iy=0;iy<height-1;iy++){ |
for(iy=0;iy<height-1;iy++){ |
for(ix=0;ix<width-1;ix++){ |
for(ix=0;ix<width-1;ix++){ |
for(i=0;i<can->nzstep;i++){ |
for(i=0;i<can->nzstep;i++){ |
if(vmin[ix][iy]<=zst[i] && vmax[ix][iy]>=zst[i]){ |
if(vmin[ix][iy]<=zst[i] && vmax[ix][iy]>=zst[i]){ |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
break; |
break; |
} |
} |
count_and_flush(); |
count_and_flush(); |
} |
} |
} |
} |
} |
} |
} else { |
} else { |
width=can->width;height=can->height;pix=can->pix; |
width=can->width;height=can->height;pix=can->pix; |
for(ix=0;ix<width-1;ix++) |
for(ix=0;ix<width-1;ix++) |
for(iy=0,px=tab[ix],px1=tab[ix+1],px2=px+1;iy<height-1; |
for(iy=0,px=tab[ix],px1=tab[ix+1],px2=px+1;iy<height-1; |
iy++,px++,px1++,px2++) |
iy++,px++,px1++,px2++) |
if(((*px>=0)&&((*px1<=0)||(*px2<=0)))|| |
if(((*px>=0)&&((*px1<=0)||(*px2<=0)))|| |
((*px<=0)&&((*px1>=0)||(*px2>=0)))){ |
((*px<=0)&&((*px1>=0)||(*px2>=0)))){ |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
count_and_flush(); |
count_and_flush(); |
} |
} |
} |
} |
flush(); |
flush(); |
*/ |
*/ |
} |
} |
|
|
#define MEMORY_DRAWPOINT(a,len,x,y) (((a)[(len)*(y)+((x)>>3)]) |= (1<<((x)&7))) |
#define MEMORY_DRAWPOINT(a,len,x,y) (((a)[(len)*(y)+((x)>>3)]) |= (1<<((x)&7))) |
|
|
void memory_if_print(double **tab,struct canvas *can,BYTEARRAY *bytes){ |
void memory_if_print(double **tab,struct canvas *can,BYTEARRAY *bytes){ |
int ix,iy,width,height; |
int ix,iy,width,height; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
unsigned char *array; |
unsigned char *array; |
int scan_len; |
int scan_len; |
if ( can->mode==modeNO(CONPLOT)){ |
if ( can->mode==modeNO(CONPLOT)){ |
memory_con_print(tab,can,bytes); |
memory_con_print(tab,can,bytes); |
return; |
return; |
} |
} |
width = can->width; height = can->height; |
width = can->width; height = can->height; |
// scan_len = byte length of the scan line |
// scan_len = byte length of the scan line |
scan_len = (width+7)/8; |
scan_len = (width+7)/8; |
MKBYTEARRAY(*bytes,scan_len*height); |
MKBYTEARRAY(*bytes,scan_len*height); |
array = BDY(*bytes); |
array = BDY(*bytes); |
for( ix=0; ix<width-1; ix++ ) |
for( ix=0; ix<width-1; ix++ ) |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) || |
if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) || |
((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) { |
((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) { |
MEMORY_DRAWPOINT(array,scan_len,ix,height-iy-1); |
MEMORY_DRAWPOINT(array,scan_len,ix,height-iy-1); |
} |
} |
} |
} |
|
|
void con_print(DISPLAY *display,double **tab,struct canvas *can){ |
void con_print(DISPLAY *display,double **tab,struct canvas *can){ |
int i,ix,iy,width,height; |
int i,ix,iy,width,height; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
double **vmax,**vmin,*zst,zstep,zv,u,l; |
double **vmax,**vmin,*zst,zstep,zv,u,l; |
DRAWABLE pix; |
DRAWABLE pix; |
POINT *pa,*pa1; |
POINT *pa,*pa1; |
struct pa *parray; |
struct pa *parray; |
|
|
width=can->width;height=can->height;pix=can->pix; |
width=can->width;height=can->height;pix=can->pix; |
vmax=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmax=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmin=((double **)ALLOCA((width+1)*sizeof(double *))); |
vmin=((double **)ALLOCA((width+1)*sizeof(double *))); |
for(i=0;i<width;i++){ |
for(i=0;i<width;i++){ |
vmax[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmax[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmin[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
vmin[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
} |
} |
for(ix=0;ix<width;ix++){ |
for(ix=0;ix<width;ix++){ |
for(iy=0;iy<height;iy++){ |
for(iy=0;iy<height;iy++){ |
vmax[ix][iy]= |
vmax[ix][iy]= |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
MAX(MAX(tab[ix][iy],tab[ix][iy+1]),MAX(tab[ix+1][iy],tab[ix+1][iy+1])); |
vmin[ix][iy]= |
vmin[ix][iy]= |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
MIN(MIN(tab[ix][iy],tab[ix][iy+1]),MIN(tab[ix+1][iy],tab[ix+1][iy+1])); |
} |
} |
} |
} |
if(can->zmax==can->zmin)zstep=(can->vmax-can->vmin)/can->nzstep; |
if(can->zmax==can->zmin)zstep=(can->vmax-can->vmin)/can->nzstep; |
else zstep=(can->zmax-can->zmin)/can->nzstep; |
else zstep=(can->zmax-can->zmin)/can->nzstep; |
zst=(double *)ALLOCA((can->nzstep+1)*sizeof(double)); |
zst=(double *)ALLOCA((can->nzstep+1)*sizeof(double)); |
zv=can->xmin; |
zv=can->xmin; |
for(i=0,zv=can->xmin;i<can->nzstep;zv+=zstep,i++)zst[i]=zv; |
for(i=0,zv=can->xmin;i<can->nzstep;zv+=zstep,i++)zst[i]=zv; |
for(iy=0;iy<height-1;iy++){ |
for(iy=0;iy<height-1;iy++){ |
for(ix=0;ix<width-1;ix++){ |
for(ix=0;ix<width-1;ix++){ |
for(i=0;i<can->nzstep;i++){ |
for(i=0;i<can->nzstep;i++){ |
if(vmin[ix][iy]<=zst[i] && vmax[ix][iy]>=zst[i]){ |
if(vmin[ix][iy]<=zst[i] && vmax[ix][iy]>=zst[i]){ |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
break; |
break; |
} |
} |
count_and_flush(); |
count_and_flush(); |
} |
} |
} |
} |
} |
} |
flush(); |
flush(); |
} |
} |
|
|
void memory_con_print(double **tab,struct canvas *can,BYTEARRAY *bytes){ |
void memory_con_print(double **tab,struct canvas *can,BYTEARRAY *bytes){ |
int ix,iy,iz,width,height,pas,pai,len; |
int ix,iy,iz,width,height,pas,pai,len; |
double zstep,z; |
double zstep,z; |
double *px,*px1,*px2; |
double *px,*px1,*px2; |
POINT *pa,*pa1; |
POINT *pa,*pa1; |
struct pa *parray; |
struct pa *parray; |
unsigned char *array; |
unsigned char *array; |
int scan_len; |
int scan_len; |
|
|
width = can->width; height = can->height; |
width = can->width; height = can->height; |
zstep = (can->zmax-can->zmin)/can->nzstep; |
zstep = (can->zmax-can->zmin)/can->nzstep; |
can->pa = (struct pa *)MALLOC((can->nzstep+1)*sizeof(struct pa)); |
can->pa = (struct pa *)MALLOC((can->nzstep+1)*sizeof(struct pa)); |
pas = width; |
pas = width; |
pa = (POINT *)ALLOCA(pas*sizeof(POINT)); |
pa = (POINT *)ALLOCA(pas*sizeof(POINT)); |
for ( z = can->zmin, iz = 0; z <= can->zmax; z += zstep, iz++ ) { |
for ( z = can->zmin, iz = 0; z <= can->zmax; z += zstep, iz++ ) { |
pai = 0; |
pai = 0; |
for( ix=0; ix<width-1; ix++ ) |
for( ix=0; ix<width-1; ix++ ) |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
iy<height-1 ;iy++, px++, px1++, px2++ ) |
if ( ((*px >= z) && ((*px1 <= z) || (*px2 <= z))) || |
if ( ((*px >= z) && ((*px1 <= z) || (*px2 <= z))) || |
((*px <= z) && ((*px1 >= z) || (*px2 >= z))) ) { |
((*px <= z) && ((*px1 >= z) || (*px2 >= z))) ) { |
if ( pai == pas ) { |
if ( pai == pas ) { |
pa1 = (POINT *)ALLOCA(2*pas*sizeof(POINT)); |
pa1 = (POINT *)ALLOCA(2*pas*sizeof(POINT)); |
bcopy((char *)pa,(char *)pa1,pas*sizeof(POINT)); pa = pa1; |
bcopy((char *)pa,(char *)pa1,pas*sizeof(POINT)); pa = pa1; |
pas += pas; |
pas += pas; |
} |
} |
XC(pa[pai]) = ix; YC(pa[pai]) = height-iy-1; pai++; |
XC(pa[pai]) = ix; YC(pa[pai]) = height-iy-1; pai++; |
} |
} |
can->pa[iz].length = pai; |
can->pa[iz].length = pai; |
if ( pai ) { |
if ( pai ) { |
pa1 = (POINT *)MALLOC(pai*sizeof(POINT)); |
pa1 = (POINT *)MALLOC(pai*sizeof(POINT)); |
bcopy((char *)pa,(char *)pa1,pai*sizeof(POINT)); |
bcopy((char *)pa,(char *)pa1,pai*sizeof(POINT)); |
can->pa[iz].pos = pa1; |
can->pa[iz].pos = pa1; |
} |
} |
} |
} |
/* scan_len = byte length of the scan line */ |
/* scan_len = byte length of the scan line */ |
scan_len = (width+7)/8; |
scan_len = (width+7)/8; |
MKBYTEARRAY(*bytes,scan_len*height); |
MKBYTEARRAY(*bytes,scan_len*height); |
array = BDY(*bytes); |
array = BDY(*bytes); |
for ( parray = can->pa, iz = 0; iz <= can->nzstep; iz++, parray++ ) |
for ( parray = can->pa, iz = 0; iz <= can->nzstep; iz++, parray++ ) |
for ( pa = parray->pos, len = parray->length, ix = 0; ix < len; ix++ ) { |
for ( pa = parray->pos, len = parray->length, ix = 0; ix < len; ix++ ) { |
MEMORY_DRAWPOINT(array,scan_len,XC(pa[ix]),YC(pa[ix])); |
MEMORY_DRAWPOINT(array,scan_len,XC(pa[ix]),YC(pa[ix])); |
} |
} |
} |
} |
|
|
void memory_print(struct canvas *can,BYTEARRAY *bytes){ |
void memory_print(struct canvas *can,BYTEARRAY *bytes){ |
int len,scan_len,i; |
int len,scan_len,i; |
POINT *pa; |
POINT *pa; |
char *array; |
char *array; |
|
|
/* scan_len = byte length of the scan line */ |
/* scan_len = byte length of the scan line */ |
scan_len = (can->width+7)/8; |
scan_len = (can->width+7)/8; |
MKBYTEARRAY(*bytes,scan_len*can->height); |
MKBYTEARRAY(*bytes,scan_len*can->height); |
array = (char*)BDY(*bytes); |
array = (char*)BDY(*bytes); |
|
|
len = can->pa[0].length; |
len = can->pa[0].length; |
pa = can->pa[0].pos; |
pa = can->pa[0].pos; |
for ( i = 0; i < len; i++ ) { |
for ( i = 0; i < len; i++ ) { |
MEMORY_DRAWPOINT(array,scan_len,pa[i].x,pa[i].y); |
MEMORY_DRAWPOINT(array,scan_len,pa[i].x,pa[i].y); |
} |
} |
} |
} |
|
|
void qif_print(DISPLAY *display,char **tab,struct canvas *can){ |
void qif_print(DISPLAY *display,char **tab,struct canvas *can){ |
int ix,iy,width,height; |
int ix,iy,width,height; |
char *px; |
char *px; |
DRAWABLE pix; |
DRAWABLE pix; |
|
|
flush(); |
flush(); |
width = can->width; height = can->height; pix = can->pix; |
width = can->width; height = can->height; pix = can->pix; |
for( ix = 0; ix < width; ix++ ) |
for( ix = 0; ix < width; ix++ ) |
for(iy = 0, px = tab[ix]; iy < height ;iy++, px++ ) |
for(iy = 0, px = tab[ix]; iy < height ;iy++, px++ ) |
if ( *px ) { |
if ( *px ) { |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
count_and_flush(); |
count_and_flush(); |
} |
} |
flush(); |
flush(); |
} |
} |
|
|
void plot_print(DISPLAY *display,struct canvas *can){ |
void plot_print(DISPLAY *display,struct canvas *can){ |
int len; |
int len; |
POINT *pa; |
POINT *pa; |
|
|
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
len = can->pa[0].length; |
len = can->pa[0].length; |
pa = can->pa[0].pos; |
pa = can->pa[0].pos; |
|
|
Polyline(can->pix,pa,len); |
Polyline(can->pix,pa,len); |
// for ( i = 0; i < len-1; i++ ) { |
// 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); |
// DRAWLINE(display,can->pix,drawGC,pa[i].x,pa[i].y,pa[i+1].x,pa[i+1].y); |
// } |
// } |
#else |
#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 |
#endif |
} |
} |
|
|
void draw_point(DISPLAY *display,struct canvas *can,int x,int y,unsigned int color){ |
void draw_point(DISPLAY *display,struct canvas *can,int x,int y,unsigned int color){ |
//void draw_point(DISPLAY *display,struct canvas *can,int x,int y,int color){ |
//void draw_point(DISPLAY *display,struct canvas *can,int x,int y,int color){ |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
|
|
SetPixel(can->pix,x,y,(COLORREF)color); |
SetPixel(can->pix,x,y,(COLORREF)color); |
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
SetPixel(dc,x,y,(COLORREF)color); |
SetPixel(dc,x,y,(COLORREF)color); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
#else |
#else |
set_drawcolor(color); |
set_drawcolor(color); |
DRAWPOINT(display,can->pix,cdrawGC,x,y); |
DRAWPOINT(display,can->pix,cdrawGC,x,y); |
DRAWPOINT(display,can->window,cdrawGC,x,y); |
DRAWPOINT(display,can->window,cdrawGC,x,y); |
XFlush(display); |
XFlush(display); |
#endif |
#endif |
} |
} |
|
|
void draw_line( |
void draw_line( |
DISPLAY *display,struct canvas *can,int x,int y,int u,int v,unsigned int color){ |
DISPLAY *display,struct canvas *can,int x,int y,int u,int v,unsigned int color){ |
//DISPLAY *display,struct canvas *can,int x,int y,int u,int v,int color){ |
//DISPLAY *display,struct canvas *can,int x,int y,int u,int v,int color){ |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
HPEN pen,oldpen; |
HPEN pen,oldpen; |
|
|
if ( color ) { |
if ( color ) { |
pen = CreatePen(PS_SOLID,1,color); |
pen = CreatePen(PS_SOLID,1,color); |
oldpen = SelectObject(can->pix,pen); |
oldpen = SelectObject(can->pix,pen); |
DRAWLINE(display,can->pix,drawGC,x,y,u,v); |
DRAWLINE(display,can->pix,drawGC,x,y,u,v); |
SelectObject(can->pix,oldpen); |
SelectObject(can->pix,oldpen); |
|
|
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
oldpen = SelectObject(dc,pen); |
oldpen = SelectObject(dc,pen); |
DRAWLINE(display,dc,drawGC,x,y,u,v); |
DRAWLINE(display,dc,drawGC,x,y,u,v); |
SelectObject(dc,oldpen); |
SelectObject(dc,oldpen); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
|
|
DeleteObject(pen); |
DeleteObject(pen); |
} else { |
} else { |
DRAWLINE(display,can->pix,drawGC,x,y,u,v); |
DRAWLINE(display,can->pix,drawGC,x,y,u,v); |
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
DRAWLINE(display,dc,drawGC,x,y,u,v); |
DRAWLINE(display,dc,drawGC,x,y,u,v); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
} |
} |
#else |
#else |
set_drawcolor(color); |
set_drawcolor(color); |
DRAWLINE(display,can->pix,cdrawGC,x,y,u,v); |
DRAWLINE(display,can->pix,cdrawGC,x,y,u,v); |
DRAWLINE(display,can->window,cdrawGC,x,y,u,v); |
DRAWLINE(display,can->window,cdrawGC,x,y,u,v); |
XFlush(display); |
XFlush(display); |
#endif |
#endif |
} |
} |
|
|
void draw_character_string( |
void draw_character_string( |
DISPLAY *display,struct canvas *can,int x,int y,char *str,unsigned int color){ |
DISPLAY *display,struct canvas *can,int x,int y,char *str,unsigned int color){ |
//DISPLAY *display,struct canvas *can,int x,int y,char *str,int color){ |
//DISPLAY *display,struct canvas *can,int x,int y,char *str,int color){ |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
COLORREF oldcolor; |
COLORREF oldcolor; |
|
|
if ( color ) { |
if ( color ) { |
oldcolor = SetTextColor(can->pix,color); |
oldcolor = SetTextColor(can->pix,color); |
DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str)); |
SetTextColor(can->pix,oldcolor); |
SetTextColor(can->pix,oldcolor); |
|
|
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
oldcolor = SetTextColor(dc,color); |
oldcolor = SetTextColor(dc,color); |
DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str)); |
SetTextColor(dc,oldcolor); |
SetTextColor(dc,oldcolor); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
} else { |
} else { |
DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,can->pix,drawGC,x,y,str,strlen(str)); |
dc = GetDC(can->hwnd); |
dc = GetDC(can->hwnd); |
DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,dc,drawGC,x,y,str,strlen(str)); |
ReleaseDC(can->hwnd,dc); |
ReleaseDC(can->hwnd,dc); |
} |
} |
#else |
#else |
set_drawcolor(color); |
set_drawcolor(color); |
DRAWSTRING(display,can->pix,cdrawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,can->pix,cdrawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,can->window,cdrawGC,x,y,str,strlen(str)); |
DRAWSTRING(display,can->window,cdrawGC,x,y,str,strlen(str)); |
XFlush(display); |
XFlush(display); |
#endif |
#endif |
} |
} |
|
|
#define D 5 |
#define D 5 |
|
|
void pline(DISPLAY *display,struct canvas *can,DRAWABLE d){ |
void pline(DISPLAY *display,struct canvas *can,DRAWABLE d){ |
double w,w1,e,n; |
double w,w1,e,n; |
int x0,y0,x,y,xadj,yadj; |
int x0,y0,x,y,xadj,yadj; |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
double adjust_scale(); |
double adjust_scale(); |
|
|
/* XXX : should be cleaned up */ |
/* XXX : should be cleaned up */ |
if ( can->noaxis || (can->mode==modeNO(PLOT)&& !can->pa) ) |
if ( can->noaxis || (can->mode==modeNO(PLOT)&& !can->pa) ) |
return; |
return; |
if ( can->mode==modeNO(INTERACTIVE)) |
if ( can->mode==modeNO(INTERACTIVE)) |
return; |
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)*(-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-D; |
x0 = can->width-D; |
if ( (can->ymin < 0) && (can->ymax > 0) ) { |
if ( (can->ymin < 0) && (can->ymax > 0) ) { |
y0 = (int)((can->height)*(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; |
y0 = can->height; |
else |
else |
y0 = D; |
y0 = D; |
|
|
/* scale on x-axis */ |
/* 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); |
for ( n = ceil(can->xmin/e); n*e<= can->xmax; n++ ) { |
for ( n = ceil(can->xmin/e); n*e<= can->xmax; n++ ) { |
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+2,buf,strlen(buf)); |
DRAWSTRING(display,d,scaleGC,x+2,y0+2,buf,strlen(buf)); |
} |
} |
|
|
/* scale on y-axis */ |
/* 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); |
for ( n = ceil(can->ymin/e); n*e<= can->ymax; n++ ) { |
for ( n = ceil(can->ymin/e); n*e<= can->ymax; n++ ) { |
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) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
xadj = TEXTWIDTH(sffs,buf,strlen(buf)); |
xadj = TEXTWIDTH(sffs,buf,strlen(buf)); |
#else |
#else |
SIZE size; |
SIZE size; |
|
|
GetTextExtentPoint32(d,buf,strlen(buf),&size); |
GetTextExtentPoint32(d,buf,strlen(buf),&size); |
xadj = size.cx; |
xadj = size.cx; |
#endif |
#endif |
} |
} |
DRAWSTRING(display,d,scaleGC,x0+2-xadj,y+2,buf,strlen(buf)); |
DRAWSTRING(display,d,scaleGC,x0+2-xadj,y+2,buf,strlen(buf)); |
} |
} |
} |
} |
|
|
double adjust_scale(double e,double w){ |
double adjust_scale(double e,double w){ |
switch ( (int)floor(w/e) ) { |
switch ( (int)floor(w/e) ) { |
case 1: |
case 1: |
return e/4; break; |
return e/4; break; |
case 2: case 3: |
case 2: case 3: |
return e/2; break; |
return e/2; break; |
case 4: case 5: case 6: case 7: |
case 4: case 5: case 6: case 7: |
return e; break; |
return e; break; |
break; |
break; |
case 8: case 9: case 10: default: |
case 8: case 9: case 10: default: |
return 2*e; break; |
return 2*e; break; |
} |
} |
} |
} |
|
|
void initmarker(struct canvas *can,char *message){ |
void initmarker(struct canvas *can,char *message){ |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
can->real_can->percentage = 0; |
can->real_can->percentage = 0; |
can->real_can->prefix = message; |
can->real_can->prefix = message; |
#else |
#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 |
#endif |
} |
} |
|
|
void marker(struct canvas *can,int dir,int p){ |
void marker(struct canvas *can,int dir,int p){ |
#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) |
#if defined(VISUAL) || defined(__MINGW32__) |
if ( dir == DIR_X ) |
if ( dir == DIR_X ) |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->width*100); |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->width*100); |
else if ( dir == DIR_Y ) |
else if ( dir == DIR_Y ) |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->height*100); |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->height*100); |
else |
else |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->nzstep*100); |
can->real_can->percentage = (int)ceil((float)p/(float)can->real_can->nzstep*100); |
#else |
#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(); |
} else if ( dir == DIR_Y ) { |
} else if ( dir == DIR_Y ) { |
XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->height,0.05); |
XawScrollbarSetThumb(can->ydone,1.0-(float)p/(float)can->height,0.05); |
count_and_flush(); |
count_and_flush(); |
} else { |
} else { |
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 |
#endif |
} |
} |
|
|
void define_cursor(WINDOW w,CURSOR cur){ |
void define_cursor(WINDOW w,CURSOR cur){ |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
XDefineCursor(display,w,cur); flush(); |
XDefineCursor(display,w,cur); flush(); |
#endif |
#endif |
} |
} |
|
|
Line 680 static int flush_count; |
|
Line 680 static int flush_count; |
|
#endif |
#endif |
|
|
void count_and_flush(){ |
void count_and_flush(){ |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
if ( ++flush_count == MAX_COUNT ) |
if ( ++flush_count == MAX_COUNT ) |
flush(); |
flush(); |
#endif |
#endif |
} |
} |
|
|
void flush(){ |
void flush(){ |
#if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
flush_count = 0; |
flush_count = 0; |
XFlush(display); |
XFlush(display); |
#endif |
#endif |
} |
} |