version 1.16, 2013/12/19 05:48:25 |
version 1.24, 2017/08/31 08:52:27 |
|
|
* 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.15 2011/08/11 06:25:06 saito Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/plotp.c,v 1.23 2015/08/14 13:51:56 fujimoto 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) |
#if defined(VISUAL) || defined(__MINGW32__) |
static POINT oldpos; |
static POINT oldpos; |
#endif |
#endif |
|
|
#if defined(INTERVAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
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) |
Line 80 void area_print(DISPLAY *display,double **tab,struct c |
|
Line 81 void area_print(DISPLAY *display,double **tab,struct c |
|
int ix,iy,width,height,wc,**mask; |
int ix,iy,width,height,wc,**mask; |
XImage *image; |
XImage *image; |
DRAWABLE pix; |
DRAWABLE pix; |
unsigned long color,black,white,c2; |
unsigned int 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; |
Line 137 void area_print(DISPLAY *display,double **tab,struct c |
|
Line 139 void area_print(DISPLAY *display,double **tab,struct c |
|
count_and_flush(); |
count_and_flush(); |
flush(); |
flush(); |
} |
} |
|
#else |
|
void area_print(DISPLAY *display,double **tab,struct canvas *can,int GXcode){ |
|
/* not implemented */ |
|
} |
|
#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; |
Line 150 void over_print(DISPLAY *display,double **tab,struct c |
|
Line 157 void over_print(DISPLAY *display,double **tab,struct c |
|
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(); |
} |
} |
#endif |
|
|
|
void if_print(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){ |
//MODE_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 { |
} else if(cond==1) { |
//MODE_IFPLOT,MODE_IFPLOTD,MODE_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){ |
Line 182 void if_print(DISPLAY *display,double **tab,struct can |
|
Line 188 void if_print(DISPLAY *display,double **tab,struct can |
|
flush(); |
flush(); |
} |
} |
|
|
void if_printOld(DISPLAY *display,double **tab,struct canvas *can){ |
void polar_print(DISPLAY *display,struct canvas *can){ |
|
int len,i,j,x,y; |
|
unsigned int color; |
|
POINT *pa; |
|
|
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
HDC dc; |
|
HPEN pen,oldpen; |
|
len=can->pa[0].length; |
|
color=can->color; |
|
pa=can->pa[0].pos; |
|
for(i=1;i<len;i++){ |
|
j=i-1; |
|
if(color){ |
|
pen=CreatePen(PS_SOLID,1,color); |
|
oldpen=SelectObject(can->pix,pen); |
|
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
|
SelectObject(can->pix,oldpen); |
|
|
|
dc = GetDC(can->hwnd); |
|
oldpen = SelectObject(dc,pen); |
|
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
|
SelectObject(dc,oldpen); |
|
ReleaseDC(can->hwnd,dc); |
|
|
|
DeleteObject(pen); |
|
} else { |
|
DRAWLINE(display,can->pix,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
|
dc = GetDC(can->hwnd); |
|
DRAWLINE(display,dc,drawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
|
ReleaseDC(can->hwnd,dc); |
|
} |
|
} |
|
#else |
|
len=can->pa[0].length; |
|
color=can->color; |
|
pa=can->pa[0].pos; |
|
for(i=1;i<len;i++){ |
|
j=i-1; |
|
DRAWLINE(display,can->pix,cdrawGC,XC(pa[j]),YC(pa[j]),XC(pa[i]),YC(pa[i])); |
|
} |
|
XFlush(display); |
|
#endif |
|
} |
|
|
|
|
|
void if_print(DISPLAY *display,double **tab,struct canvas *can){ |
|
int ix,iy,width,height; |
|
double *px,*px1,*px2; |
|
DRAWABLE pix; |
|
|
|
if ( can->mode == modeNO(CONPLOT) ) { |
|
con_print(display,tab,can); return; |
|
} |
|
flush(); |
|
width = can->width; height = can->height; pix = can->pix; |
|
for( ix=0; ix<width-1; ix++ ) |
|
for(iy=0, px=tab[ix], px1 = tab[ix+1], px2 = px+1; |
|
iy<height-1 ;iy++, px++, px1++, px2++ ) |
|
if ( ((*px >= 0) && ((*px1 <= 0) || (*px2 <= 0))) || |
|
((*px <= 0) && ((*px1 >= 0) || (*px2 >= 0))) ) { |
|
DRAWPOINT(display,pix,cdrawGC,ix,height-iy-1); |
|
count_and_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; |
Line 190 void if_printOld(DISPLAY *display,double **tab,struct |
|
Line 261 void if_printOld(DISPLAY *display,double **tab,struct |
|
POINT *pa,*pa1; |
POINT *pa,*pa1; |
struct pa *parray; |
struct pa *parray; |
|
|
if(can->mode==MODE_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 |
Line 236 void if_printOld(DISPLAY *display,double **tab,struct |
|
Line 307 void if_printOld(DISPLAY *display,double **tab,struct |
|
} |
} |
} |
} |
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))) |
Line 245 void memory_if_print(double **tab,struct canvas *can,B |
|
Line 317 void memory_if_print(double **tab,struct canvas *can,B |
|
double *px,*px1,*px2; |
double *px,*px1,*px2; |
unsigned char *array; |
unsigned char *array; |
int scan_len; |
int scan_len; |
if ( can->mode == MODE_CONPLOT ){ |
if ( can->mode==modeNO(CONPLOT)){ |
memory_con_print(tab,can,bytes); |
memory_con_print(tab,can,bytes); |
return; |
return; |
} |
} |
Line 358 void memory_print(struct canvas *can,BYTEARRAY *bytes) |
|
Line 430 void memory_print(struct canvas *can,BYTEARRAY *bytes) |
|
/* 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 = 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; |
Line 387 void plot_print(DISPLAY *display,struct canvas *can){ |
|
Line 459 void plot_print(DISPLAY *display,struct canvas *can){ |
|
int len; |
int len; |
POINT *pa; |
POINT *pa; |
|
|
#if defined(VISUAL) |
#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; |
|
|
Line 402 void plot_print(DISPLAY *display,struct canvas *can){ |
|
Line 474 void plot_print(DISPLAY *display,struct canvas *can){ |
|
#endif |
#endif |
} |
} |
|
|
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,unsigned int color){ |
#if defined(VISUAL) |
//void draw_point(DISPLAY *display,struct canvas *can,int x,int y,int color){ |
|
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
|
|
SetPixel(can->pix,x,y,(COLORREF)color); |
SetPixel(can->pix,x,y,(COLORREF)color); |
Line 419 void draw_point(DISPLAY *display,struct canvas *can,in |
|
Line 492 void draw_point(DISPLAY *display,struct canvas *can,in |
|
} |
} |
|
|
void draw_line( |
void draw_line( |
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,unsigned int color){ |
#if defined(VISUAL) |
//DISPLAY *display,struct canvas *can,int x,int y,int u,int v,int color){ |
|
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
HPEN pen,oldpen; |
HPEN pen,oldpen; |
|
|
|
|
} |
} |
|
|
void draw_character_string( |
void draw_character_string( |
DISPLAY *display,struct canvas *can,int x,int y,char *str,int color){ |
DISPLAY *display,struct canvas *can,int x,int y,char *str,unsigned int color){ |
#if defined(VISUAL) |
//DISPLAY *display,struct canvas *can,int x,int y,char *str,int color){ |
|
#if defined(VISUAL) || defined(__MINGW32__) |
HDC dc; |
HDC dc; |
COLORREF oldcolor; |
COLORREF oldcolor; |
|
|
Line 490 void pline(DISPLAY *display,struct canvas *can,DRAWABL |
|
Line 565 void pline(DISPLAY *display,struct canvas *can,DRAWABL |
|
double adjust_scale(); |
double adjust_scale(); |
|
|
/* XXX : should be cleaned up */ |
/* XXX : should be cleaned up */ |
if ( can->noaxis || (can->mode == MODE_PLOT && !can->pa) ) |
if ( can->noaxis || (can->mode==modeNO(PLOT)&& !can->pa) ) |
return; |
return; |
if ( can->mode == MODE_INTERACTIVE ) |
if ( can->mode==modeNO(INTERACTIVE)) |
return; |
return; |
|
|
xadj = yadj = 0; |
xadj = yadj = 0; |
Line 531 void pline(DISPLAY *display,struct canvas *can,DRAWABL |
|
Line 606 void pline(DISPLAY *display,struct canvas *can,DRAWABL |
|
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) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
xadj = TEXTWIDTH(sffs,buf,strlen(buf)); |
xadj = TEXTWIDTH(sffs,buf,strlen(buf)); |
#else |
#else |
SIZE size; |
SIZE size; |
Line 559 double adjust_scale(double e,double w){ |
|
Line 634 double adjust_scale(double e,double w){ |
|
} |
} |
|
|
void initmarker(struct canvas *can,char *message){ |
void initmarker(struct canvas *can,char *message){ |
#if defined(VISUAL) |
#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 |
Line 570 void initmarker(struct canvas *can,char *message){ |
|
Line 645 void initmarker(struct canvas *can,char *message){ |
|
} |
} |
|
|
void marker(struct canvas *can,int dir,int p){ |
void marker(struct canvas *can,int dir,int p){ |
#if defined(VISUAL) |
#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 ) |
Line 592 void marker(struct canvas *can,int dir,int p){ |
|
Line 667 void marker(struct canvas *can,int dir,int p){ |
|
} |
} |
|
|
void define_cursor(WINDOW w,CURSOR cur){ |
void define_cursor(WINDOW w,CURSOR cur){ |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
XDefineCursor(display,w,cur); flush(); |
XDefineCursor(display,w,cur); flush(); |
#endif |
#endif |
} |
} |
Line 605 static int flush_count; |
|
Line 680 static int flush_count; |
|
#endif |
#endif |
|
|
void count_and_flush(){ |
void count_and_flush(){ |
#if !defined(VISUAL) |
#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) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
flush_count = 0; |
flush_count = 0; |
XFlush(display); |
XFlush(display); |
#endif |
#endif |