version 1.30, 2014/06/27 07:58:29 |
version 1.37, 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/if.c,v 1.29 2014/05/25 03:07:04 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/if.c,v 1.36 2017/09/04 01:57:53 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#if defined(ITV_TIME_CHECK) |
#if defined(ITV_TIME_CHECK) |
void tstart() |
void tstart() |
{ |
{ |
get_eg(<ime); |
get_eg(<ime); |
r0=get_rtime(); |
r0=get_rtime(); |
} |
} |
|
|
void tstop(struct canvas *can) |
void tstop(struct canvas *can) |
{ |
{ |
struct oEGT egt1; |
struct oEGT egt1; |
double e, g, r; |
double e, g, r; |
char ts[100]; |
char ts[100]; |
void popdown_warning(); |
void popdown_warning(); |
Widget warnshell,warndialog; |
Widget warnshell,warndialog; |
|
|
get_eg(&egt1); |
get_eg(&egt1); |
e=egt1.exectime - ltime.exectime; |
e=egt1.exectime - ltime.exectime; |
g=egt1.gctime - ltime.gctime; |
g=egt1.gctime - ltime.gctime; |
r=get_rtime() - r0; |
r=get_rtime() - r0; |
sprintf(ts,"(%8.6f + gc %8.6f) total %8.6f \n",e,g,r); |
sprintf(ts,"(%8.6f + gc %8.6f) total %8.6f \n",e,g,r); |
create_popup(can->shell,"Message",&ts,&warnshell,&warndialog); |
create_popup(can->shell,"Message",&ts,&warnshell,&warndialog); |
XawDialogAddButton(warndialog,"OK",popdown_warning,warnshell); |
XawDialogAddButton(warndialog,"OK",popdown_warning,warnshell); |
XtPopup(warnshell,XtGrabNone); |
XtPopup(warnshell,XtGrabNone); |
SetWM_Proto(warnshell); |
SetWM_Proto(warnshell); |
} |
} |
#else |
#else |
#define tstart() |
#define tstart() |
Line 97 void tstop(struct canvas *can) |
|
Line 97 void tstop(struct canvas *can) |
|
extern JMP_BUF ox_env; |
extern JMP_BUF ox_env; |
|
|
int open_canvas(NODE arg){ |
int open_canvas(NODE arg){ |
int id; |
int id; |
struct canvas *can; |
struct canvas *can; |
LIST wsize; |
LIST wsize; |
STRING wname; |
STRING wname; |
|
|
wsize=(LIST)ARG0(arg); |
wsize=(LIST)ARG0(arg); |
wname=(STRING)ARG1(arg); |
wname=(STRING)ARG1(arg); |
id=search_canvas(); |
id=search_canvas(); |
can=canvas[id]; |
can=canvas[id]; |
can->mode=modeNO(INTERACTIVE); |
can->mode=modeNO(INTERACTIVE); |
if(!wsize){ |
if(!wsize){ |
can->width=DEFAULTWIDTH; |
can->width=DEFAULTWIDTH; |
can->height=DEFAULTHEIGHT; |
can->height=DEFAULTHEIGHT; |
} else { |
} else { |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
} |
} |
if(wname)can->wname=BDY(wname); |
if(wname)can->wname=BDY(wname); |
else can->wname=""; |
else can->wname=""; |
create_canvas(can); |
create_canvas(can); |
return id; |
return id; |
} |
} |
|
|
int plot(NODE arg,int fn){ |
int plot(NODE arg,int fn){ |
int id; |
int id; |
NODE n; |
NODE n; |
struct canvas *can; |
struct canvas *can; |
P formula; |
P formula; |
LIST xrange,yrange,zrange,wsize; |
LIST xrange,yrange,zrange,wsize; |
STRING wname; |
STRING wname; |
V v; |
V v; |
|
Real r; |
|
double rr; |
|
|
formula=(P)ARG0(arg); |
formula=(P)ARG0(arg); |
xrange=(LIST)ARG1(arg); |
xrange=(LIST)ARG1(arg); |
yrange=(LIST)ARG2(arg); |
yrange=(LIST)ARG2(arg); |
zrange=(LIST)ARG3(arg); |
zrange=(LIST)ARG3(arg); |
wsize=(LIST)ARG4(arg); |
wsize=(LIST)ARG4(arg); |
wname=(STRING)ARG5(arg); |
wname=(STRING)ARG5(arg); |
can=canvas[id=search_canvas()]; |
can=canvas[id=search_canvas()]; |
if(xrange){ |
if(xrange){ |
n=BDY(xrange);can->vx=VR((P)BDY(n));n=NEXT(n); |
n=BDY(xrange);can->vx=VR((P)BDY(n));n=NEXT(n); |
can->qxmin=(Q)BDY(n);n=NEXT(n);can->qxmax=(Q)BDY(n); |
can->qxmin=(Q)BDY(n);n=NEXT(n);can->qxmax=(Q)BDY(n); |
can->xmin=ToReal(can->qxmin);can->xmax=ToReal(can->qxmax); |
can->xmin=ToReal(can->qxmin);can->xmax=ToReal(can->qxmax); |
} |
} |
if(yrange){ |
if(yrange){ |
n=BDY(yrange);can->vy=VR((P)BDY(n));n=NEXT(n); |
n=BDY(yrange);can->vy=VR((P)BDY(n));n=NEXT(n); |
can->qymin=(Q)BDY(n);n=NEXT(n);can->qymax=(Q)BDY(n); |
can->qymin=(Q)BDY(n);n=NEXT(n);can->qymax=(Q)BDY(n); |
can->ymin=ToReal(can->qymin);can->ymax=ToReal(can->qymax); |
can->ymin=ToReal(can->qymin);can->ymax=ToReal(can->qymax); |
} |
} else if ( !formula || NUM(formula) ) { |
can->mode=fn; |
devalr(CO,(Obj)formula,(Obj *)&r); rr = ToReal(r); |
if(zrange){ |
can->ymin=rr-1; can->ymax=rr+1; |
n=NEXT(BDY(zrange)); |
} |
can->zmin=ToReal(BDY(n)); |
can->mode=fn; |
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
if(zrange){ |
n=NEXT(n); |
n=NEXT(BDY(zrange)); |
if(can->mode==modeNO(CONPLOT))can->nzstep=n?QTOS((Q)BDY(n)):MAXGC; |
can->zmin=ToReal(BDY(n)); |
else { |
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
can->vx=VR((P)BDY(BDY(zrange))); |
n=NEXT(n); |
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
if(can->mode==modeNO(CONPLOT))can->nzstep=n?QTOS((Q)BDY(n)):MAXGC; |
} |
else { |
} |
can->vx=VR((P)BDY(BDY(zrange))); |
if(!wsize){ |
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
can->width=DEFAULTWIDTH; |
} |
can->height=DEFAULTHEIGHT; |
} |
} else { |
if(!wsize){ |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->width=DEFAULTWIDTH; |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->height=DEFAULTHEIGHT; |
} |
} else { |
if(wname) can->wname=BDY(wname); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
else can->wname=""; |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->formula=formula; |
} |
if(can->mode==modeNO(PLOT)){ |
if(wname) can->wname=BDY(wname); |
//plot |
else can->wname=""; |
plotcalc(can); |
can->formula=formula; |
create_canvas(can); |
if(can->mode==modeNO(PLOT)){ |
plot_print(display,can); |
//plot |
} else if(can->mode==modeNO(POLARPLOT)){ |
can->prec=argc(arg)==7 ? QTOS((Q)ARG6(arg)) : 0; |
polarcalc(can); |
plotcalc(can); |
create_canvas(can); |
create_canvas(can); |
plot_print(display,can); |
plot_print(display,can); |
} else { |
} else if(can->mode==modeNO(POLARPLOT)){ |
create_canvas(can); |
polarcalc(can); |
ifplotmain(can); |
create_canvas(can); |
} |
plot_print(display,can); |
copy_to_canvas(can); |
} else { |
return id; |
create_canvas(can); |
|
ifplotmain(can); |
|
} |
|
copy_to_canvas(can); |
|
return id; |
} |
} |
|
|
void ifplotmain(struct canvas *can){ |
void ifplotmain(struct canvas *can){ |
int i,width,height; |
int i,width,height; |
double ** tabe; |
double ** tabe; |
|
|
width=can->width;height=can->height; |
width=can->width;height=can->height; |
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
define_cursor(can->window,runningcur); |
define_cursor(can->window,runningcur); |
set_busy(can); set_selection(); |
set_busy(can); set_selection(); |
calc(tabe,can,0); |
calc(tabe,can,0); |
if_print(display,tabe,can); |
if_print(display,tabe,can); |
reset_selection(); reset_busy(can); |
reset_selection(); reset_busy(can); |
define_cursor(can->window,normalcur); |
define_cursor(can->window,normalcur); |
} |
} |
|
|
int memory_plot(NODE arg,LIST *bytes){ |
int memory_plot(NODE arg,LIST *bytes){ |
NODE n; |
NODE n; |
struct canvas tmp_can; |
struct canvas tmp_can; |
struct canvas *can; |
struct canvas *can; |
P formula; |
P formula; |
LIST xrange,yrange,zrange,wsize; |
LIST xrange,yrange,zrange,wsize; |
int width,height; |
int width,height; |
double **tabe; |
double **tabe; |
int i; |
int i; |
BYTEARRAY barray; |
BYTEARRAY barray; |
Q qw,qh; |
Q qw,qh,prec; |
|
|
formula=(P)ARG0(arg); |
formula=(P)ARG0(arg); |
xrange=(LIST)ARG1(arg); |
xrange=(LIST)ARG1(arg); |
yrange=(LIST)ARG2(arg); |
yrange=(LIST)ARG2(arg); |
zrange=(LIST)ARG3(arg); |
zrange=(LIST)ARG3(arg); |
wsize=(LIST)ARG4(arg); |
wsize=(LIST)ARG4(arg); |
|
|
bzero((char *)&tmp_can,sizeof(tmp_can)); |
bzero((char *)&tmp_can,sizeof(tmp_can)); |
can=&tmp_can; |
can=&tmp_can; |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
if( yrange ){ |
if( yrange ){ |
n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n); |
n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n); |
can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n); |
can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n); |
can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
if( zrange ){ |
if( zrange ){ |
n=NEXT(BDY(zrange)); |
n=NEXT(BDY(zrange)); |
can->zmin=ToReal(BDY(n)); n=NEXT(n); can->zmax=ToReal(BDY(n)); |
can->zmin=ToReal(BDY(n)); n=NEXT(n); can->zmax=ToReal(BDY(n)); |
n=NEXT(n); |
n=NEXT(n); |
if(n) can->nzstep=QTOS((Q)BDY(n)); |
if(n) can->nzstep=QTOS((Q)BDY(n)); |
else can->nzstep=MAXGC; |
else can->nzstep=MAXGC; |
can->mode=modeNO(CONPLOT); |
can->mode=modeNO(CONPLOT); |
} else |
} else |
can->mode=modeNO(IFPLOT); |
can->mode=modeNO(IFPLOT); |
} else |
} else |
can->mode=modeNO(PLOT); |
can->mode=modeNO(PLOT); |
if( !wsize ){ |
if( !wsize ){ |
can->width=DEFAULTWIDTH; can->height=DEFAULTHEIGHT; |
can->width=DEFAULTWIDTH; can->height=DEFAULTHEIGHT; |
} else { |
} else { |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
} |
} |
can->wname=""; |
can->wname=""; |
can->formula=formula; |
can->formula=formula; |
if( can->mode==modeNO(PLOT)){ |
if( can->mode==modeNO(PLOT)){ |
plotcalc(can); |
can->prec = argc(arg)==6 ? QTOS((Q)ARG5(arg)) : 0; |
memory_print(can,&barray); |
plotcalc(can); |
STOQ(can->width,qw); STOQ(can->height,qh); |
memory_print(can,&barray); |
n=mknode(3,qw,qh,barray); |
STOQ(can->width,qw); STOQ(can->height,qh); |
MKLIST(*bytes,n); |
n=mknode(3,qw,qh,barray); |
} else { |
MKLIST(*bytes,n); |
width=can->width; height=can->height; |
} else { |
tabe=(double **)ALLOCA(width*sizeof(double *)); |
width=can->width; height=can->height; |
for( i=0; i<width; i++ ) |
tabe=(double **)ALLOCA(width*sizeof(double *)); |
tabe[i]=(double *)ALLOCA(height*sizeof(double)); |
for( i=0; i<width; i++ ) |
calc(tabe,can,1); |
tabe[i]=(double *)ALLOCA(height*sizeof(double)); |
memory_if_print(tabe,can,&barray); |
calc(tabe,can,1); |
STOQ(width,qw); STOQ(height,qh); |
memory_if_print(tabe,can,&barray); |
n=mknode(3,qw,qh,barray); |
STOQ(width,qw); STOQ(height,qh); |
MKLIST(*bytes,n); |
n=mknode(3,qw,qh,barray); |
} |
MKLIST(*bytes,n); |
return 0; |
} |
|
return 0; |
} |
} |
|
|
int plotover(NODE arg){ |
int plotover(NODE arg){ |
int id; |
int id; |
unsigned int orgcolor; |
unsigned int orgcolor; |
P formula; |
P formula; |
struct canvas *can; |
struct canvas *can; |
VL vl,vl0; |
VL vl,vl0; |
|
|
id=QTOS((Q)ARG0(arg)); |
id=QTOS((Q)ARG0(arg)); |
formula=(P)ARG1(arg); |
formula=(P)ARG1(arg); |
can=canvas[id]; |
can=canvas[id]; |
orgcolor=can->color; |
orgcolor=can->color; |
if(argc(arg)==3) can->color=QTOS((Q)ARG2(arg)); |
if(argc(arg)==3) can->color=QTOS((Q)ARG2(arg)); |
else can->color=0; |
else can->color=0; |
get_vars_recursive((Obj)formula,&vl); |
get_vars_recursive((Obj)formula,&vl); |
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
if(vl0->v->attr==(pointer)V_IND) |
if(vl0->v->attr==(pointer)V_IND) |
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
#endif |
#endif |
current_can=can; |
current_can=can; |
can->formula=formula; |
can->formula=formula; |
if(can->mode==modeNO(PLOT)){ |
if(can->mode==modeNO(PLOT)){ |
plotcalc(can); |
can->prec = argc(arg)==3 ? QTOS((Q)ARG2(arg)) : 0; |
plot_print(display,can); |
plotcalc(can); |
} else ifplotmain(can); |
plot_print(display,can); |
copy_to_canvas(can); |
} else ifplotmain(can); |
can->color=orgcolor; |
copy_to_canvas(can); |
#if !defined(VISUAL) |
can->color=orgcolor; |
set_drawcolor(can->color); |
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
#endif |
#endif |
return id; |
return id; |
} |
} |
|
|
int drawcircle(NODE arg){ |
int drawcircle(NODE arg){ |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
int id,index,wx,wy,wr; |
int id,index,wx,wy,wr; |
unsigned int c; |
unsigned int c; |
pointer ptr; |
pointer ptr; |
Q ret; |
Q ret; |
LIST xyr; |
LIST xyr; |
Obj x,y,r; |
Obj x,y,r; |
struct canvas *can; |
struct canvas *can; |
|
|
index=QTOS((Q)ARG0(arg)); |
index=QTOS((Q)ARG0(arg)); |
xyr=(LIST)ARG1(arg); |
xyr=(LIST)ARG1(arg); |
x=(Obj)ARG0(BDY(xyr)); y=(Obj)ARG1(BDY(xyr)); r=(Obj)ARG2(BDY(xyr)); |
x=(Obj)ARG0(BDY(xyr)); y=(Obj)ARG1(BDY(xyr)); r=(Obj)ARG2(BDY(xyr)); |
c=QTOS((Q)ARG2(arg)); |
c=QTOS((Q)ARG2(arg)); |
can=canvas[index]; |
can=canvas[index]; |
if(!can->window)return -1; |
if(!can->window)return -1; |
else { |
else { |
current_can=can; |
current_can=can; |
set_drawcolor(c); |
set_drawcolor(c); |
wx=(ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin); |
wx=(ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin); |
wy=(can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin); |
wy=(can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin); |
wr=ToReal(r); |
wr=ToReal(r); |
XFillArc(display,can->pix,cdrawGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64); |
XFillArc(display,can->pix,cdrawGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64); |
copy_to_canvas(can); |
copy_to_canvas(can); |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
return index; |
return index; |
} |
} |
#endif |
#endif |
} |
} |
|
|
int draw_obj(NODE arg){ |
int draw_obj(NODE arg){ |
int index,x,y,u,v,len,r; |
int index,x,y,u,v,len,r; |
unsigned int color; |
unsigned int color; |
NODE obj,n; |
NODE obj,n; |
RealVect *vect; |
RealVect *vect; |
struct canvas *can; |
struct canvas *can; |
|
|
index=QTOS((Q)ARG0(arg)); |
index=QTOS((Q)ARG0(arg)); |
can=canvas[index]; |
can=canvas[index]; |
if(!can && closed_canvas[index]){ |
if(!can && closed_canvas[index]){ |
canvas[index]=closed_canvas[index]; |
canvas[index]=closed_canvas[index]; |
closed_canvas[index]=0; |
closed_canvas[index]=0; |
can=canvas[index]; |
can=canvas[index]; |
popup_canvas(index); |
popup_canvas(index); |
current_can=can; |
current_can=can; |
} else if(!can||(can && !can->window)){ |
} else if(!can||(can && !can->window)){ |
set_lasterror("draw_obj : canvas does not exist"); |
set_lasterror("draw_obj : canvas does not exist"); |
return -1; |
return -1; |
} |
} |
|
|
obj=BDY((LIST)ARG1(arg)); |
obj=BDY((LIST)ARG1(arg)); |
if(argc(arg)== 3) color=QTOS((Q)ARG2(arg)); |
if(argc(arg)== 3) color=QTOS((Q)ARG2(arg)); |
else color=0; // black |
else color=0; // black |
switch(len=length(obj)){ |
switch(len=length(obj)){ |
case 2: // point |
case 2: // point |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
draw_point(display,can,x,y,color); |
draw_point(display,can,x,y,color); |
MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history); |
MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history); |
can->history=n; |
can->history=n; |
break; |
break; |
case 3: // circle |
case 3: // circle |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
r=(int)ToReal((Q)ARG2(obj)); |
r=(int)ToReal((Q)ARG2(obj)); |
MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history); |
MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history); |
can->history=n; |
can->history=n; |
break; |
break; |
case 4: // line |
case 4: // line |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
u=(int)ToReal((Q)ARG2(obj)); v=(int)ToReal((Q)ARG3(obj)); |
u=(int)ToReal((Q)ARG2(obj)); v=(int)ToReal((Q)ARG3(obj)); |
draw_line(display,can,x,y,u,v,color); |
draw_line(display,can,x,y,u,v,color); |
MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history); |
MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history); |
can->history=n; |
can->history=n; |
break; |
break; |
default: |
default: |
set_lasterror("draw_obj : invalid request"); |
set_lasterror("draw_obj : invalid request"); |
return -1; |
return -1; |
} |
} |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
#endif |
#endif |
return 0; |
return 0; |
} |
} |
|
|
int draw_string(NODE arg){ |
int draw_string(NODE arg){ |
int index,x,y; |
int index,x,y; |
unsigned int color; |
unsigned int color; |
char *str; |
char *str; |
NODE pos; |
NODE pos; |
struct canvas *can; |
struct canvas *can; |
|
|
index=QTOS((Q)ARG0(arg)); |
index=QTOS((Q)ARG0(arg)); |
can=canvas[index]; |
can=canvas[index]; |
if(!can && closed_canvas[index]){ |
if(!can && closed_canvas[index]){ |
canvas[index]=closed_canvas[index]; |
canvas[index]=closed_canvas[index]; |
closed_canvas[index]=0; |
closed_canvas[index]=0; |
can=canvas[index]; |
can=canvas[index]; |
popup_canvas(index); |
popup_canvas(index); |
current_can=can; |
current_can=can; |
} else if(!can||(can && !can->window)){ |
} else if(!can||(can && !can->window)){ |
set_lasterror("draw_obj : canvas does not exist"); |
set_lasterror("draw_obj : canvas does not exist"); |
return -1; |
return -1; |
} |
} |
|
|
pos=BDY((LIST)ARG1(arg)); |
pos=BDY((LIST)ARG1(arg)); |
str=BDY((STRING)ARG2(arg)); |
str=BDY((STRING)ARG2(arg)); |
if(argc(arg)==4)color=QTOS((Q)ARG3(arg)); |
if(argc(arg)==4)color=QTOS((Q)ARG3(arg)); |
else color=0; // black |
else color=0; // black |
x=(int)ToReal((Q)ARG0(pos)); |
x=(int)ToReal((Q)ARG0(pos)); |
y=(int)ToReal((Q)ARG1(pos)); |
y=(int)ToReal((Q)ARG1(pos)); |
draw_character_string(display,can,x,y,str,color); |
draw_character_string(display,can,x,y,str,color); |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
#endif |
#endif |
return 0; |
return 0; |
} |
} |
|
|
int clear_canvas(NODE arg){ |
int clear_canvas(NODE arg){ |
int index; |
int index; |
struct canvas *can; |
struct canvas *can; |
|
|
index=QTOS((Q)ARG0(arg)); |
index=QTOS((Q)ARG0(arg)); |
can=canvas[index]; |
can=canvas[index]; |
if(!can||!can->window) return -1; |
if(!can||!can->window) return -1; |
clear_pixmap(can); |
clear_pixmap(can); |
copy_to_canvas(can); |
copy_to_canvas(can); |
// clear the history |
// clear the history |
can->history=0; |
can->history=0; |
return 0; |
return 0; |
} |
} |
|
|
#define RealtoDbl(r) ((r)?BDY(r):0.0) |
#define RealtoDbl(r) ((r)?BDY(r):0.0) |
|
|
int arrayplot(NODE arg){ |
int arrayplot(NODE arg){ |
int id,ix,w,h; |
int id,ix,w,h; |
VECT array; |
VECT array; |
LIST xrange,wsize; |
LIST xrange,wsize; |
char *wname; |
char *wname; |
NODE n; |
NODE n; |
double ymax,ymin,dy,xstep; |
double ymax,ymin,dy,xstep; |
Real *tab; |
Real *tab; |
struct canvas *can; |
struct canvas *can; |
POINT *pa; |
POINT *pa; |
|
|
array=(VECT)ARG0(arg); |
array=(VECT)ARG0(arg); |
xrange=(LIST)ARG1(arg); |
xrange=(LIST)ARG1(arg); |
can=canvas[id=search_canvas()]; |
can=canvas[id=search_canvas()]; |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
if(!wsize){ |
if(!wsize){ |
can->width=DEFAULTWIDTH; |
can->width=DEFAULTWIDTH; |
can->height=DEFAULTHEIGHT; |
can->height=DEFAULTHEIGHT; |
} else { |
} else { |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
} |
} |
can->wname=wname; can->formula=0; can->mode=modeNO(PLOT); |
can->wname=wname; can->formula=0; can->mode=modeNO(PLOT); |
create_canvas(can); |
create_canvas(can); |
w=array->len; |
w=array->len; |
h=can->height; |
h=can->height; |
tab=(Real *)BDY(array); |
tab=(Real *)BDY(array); |
if(can->ymax==can->ymin){ |
if(can->ymax==can->ymin){ |
for(ymax=ymin=RealtoDbl(tab[0]),ix=1; ix<w; ix++){ |
for(ymax=ymin=RealtoDbl(tab[0]),ix=1; ix<w; ix++){ |
if(RealtoDbl(tab[ix])>ymax)ymax=RealtoDbl(tab[ix]); |
if(RealtoDbl(tab[ix])>ymax)ymax=RealtoDbl(tab[ix]); |
if(RealtoDbl(tab[ix])<ymin)ymin=RealtoDbl(tab[ix]); |
if(RealtoDbl(tab[ix])<ymin)ymin=RealtoDbl(tab[ix]); |
} |
} |
can->ymax=ymax; |
can->ymax=ymax; |
can->ymin=ymin; |
can->ymin=ymin; |
} else { |
} else { |
ymax=can->ymax; |
ymax=can->ymax; |
ymin=can->ymin; |
ymin=can->ymin; |
} |
} |
dy=ymax-ymin; |
dy=ymax-ymin; |
can->pa=(struct pa *)MALLOC(sizeof(struct pa)); |
can->pa=(struct pa *)MALLOC(sizeof(struct pa)); |
can->pa[0].length=w; |
can->pa[0].length=w; |
can->pa[0].pos=pa=(POINT *)MALLOC(w*sizeof(POINT)); |
can->pa[0].pos=pa=(POINT *)MALLOC(w*sizeof(POINT)); |
xstep=(double)can->width/(double)(w-1); |
xstep=(double)can->width/(double)(w-1); |
for(ix=0;ix<w;ix++){ |
for(ix=0;ix<w;ix++){ |
#ifndef MAXSHORT |
#ifndef MAXSHORT |
#define MAXSHORT ((short)0x7fff) |
#define MAXSHORT ((short)0x7fff) |
#endif |
#endif |
double t; |
double t; |
|
|
pa[ix].x=(int)(ix*xstep); |
pa[ix].x=(int)(ix*xstep); |
t=(h - 1)*(ymax - RealtoDbl(tab[ix]))/dy; |
t=(h - 1)*(ymax - RealtoDbl(tab[ix]))/dy; |
if(t>MAXSHORT)pa[ix].y=MAXSHORT; |
if(t>MAXSHORT)pa[ix].y=MAXSHORT; |
else if(t<-MAXSHORT)pa[ix].y=-MAXSHORT; |
else if(t<-MAXSHORT)pa[ix].y=-MAXSHORT; |
else pa[ix].y=(long)t; |
else pa[ix].y=(long)t; |
} |
} |
plot_print(display,can); |
plot_print(display,can); |
copy_to_canvas(can); |
copy_to_canvas(can); |
return id; |
return id; |
} |
} |
/* |
/* |
void ifplot_resize(struct canvas *can,POINT spos,POINT epos){ |
void ifplot_resize(struct canvas *can,POINT spos,POINT epos){ |
struct canvas *ncan; |
struct canvas *ncan; |
struct canvas fakecan; |
struct canvas fakecan; |
Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid; |
Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid; |
Q sx,sy,ex,ey,cw,ch,ten,two; |
Q sx,sy,ex,ey,cw,ch,ten,two; |
Q s,t; |
Q s,t; |
int new; |
int new; |
int w,h,m; |
int w,h,m; |
if(XC(spos)<XC(epos) && YC(spos)<YC(epos)){ |
if(XC(spos)<XC(epos) && YC(spos)<YC(epos)){ |
if(can->precise && !can->wide){ |
if(can->precise && !can->wide){ |
fakecan=*can; |
fakecan=*can; |
ncan=&fakecan; |
ncan=&fakecan; |
} else { |
} else { |
new=search_canvas(); |
new=search_canvas(); |
ncan=canvas[new]; |
ncan=canvas[new]; |
} |
} |
ncan->mode=can->mode; |
ncan->mode=can->mode; |
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
ncan->nzstep=can->nzstep; |
ncan->nzstep=can->nzstep; |
ncan->wname=can->wname; |
ncan->wname=can->wname; |
ncan->vx=can->vx; ncan->vy=can->vy; |
ncan->vx=can->vx; ncan->vy=can->vy; |
ncan->formula=can->formula; |
ncan->formula=can->formula; |
w=XC(epos)-XC(spos); |
w=XC(epos)-XC(spos); |
h=YC(epos)-YC(spos); |
h=YC(epos)-YC(spos); |
m=MAX(can->width,can->height); |
m=MAX(can->width,can->height); |
if(can->precise){ |
if(can->precise){ |
ncan->width=w; |
ncan->width=w; |
ncan->height=h; |
ncan->height=h; |
} else if(w>h){ |
} else if(w>h){ |
ncan->width=m; |
ncan->width=m; |
ncan->height=m*h/w; |
ncan->height=m*h/w; |
} else { |
} else { |
ncan->width=m*w/h; |
ncan->width=m*w/h; |
ncan->height=m; |
ncan->height=m; |
} |
} |
if(can->wide){ |
if(can->wide){ |
STOQ(10,ten); |
STOQ(10,ten); |
STOQ(2,two); |
STOQ(2,two); |
subq(can->qxmax,can->qxmin,&t); |
subq(can->qxmax,can->qxmin,&t); |
mulq(t,ten,&dx); |
mulq(t,ten,&dx); |
subq(can->qymax,can->qymin,&t); |
subq(can->qymax,can->qymin,&t); |
mulq(t,ten,&dy); |
mulq(t,ten,&dy); |
addq(can->qxmax,can->qxmin,&t); |
addq(can->qxmax,can->qxmin,&t); |
divq(t,two,&xmid); |
divq(t,two,&xmid); |
addq(can->qymax,can->qymin,&t); |
addq(can->qymax,can->qymin,&t); |
divq(t,two,&ymid); |
divq(t,two,&ymid); |
divq(dx,two,&dx2); |
divq(dx,two,&dx2); |
divq(dy,two,&dy2); |
divq(dy,two,&dy2); |
subq(xmid,dx2,&xmin); |
subq(xmid,dx2,&xmin); |
addq(xmid,dx2,&xmax); |
addq(xmid,dx2,&xmax); |
subq(ymid,dy2,&ymin); |
subq(ymid,dy2,&ymin); |
addq(ymid,dy2,&ymax); |
addq(ymid,dy2,&ymax); |
} else { |
} else { |
subq(can->qxmax,can->qxmin,&dx); |
subq(can->qxmax,can->qxmin,&dx); |
subq(can->qymax,can->qymin,&dy); |
subq(can->qymax,can->qymin,&dy); |
xmin=can->qxmin; |
xmin=can->qxmin; |
xmax=can->qxmax; |
xmax=can->qxmax; |
ymin=can->qymin; |
ymin=can->qymin; |
ymax=can->qymax; |
ymax=can->qymax; |
} |
} |
STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey); |
STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey); |
STOQ(can->width,cw); STOQ(can->height,ch); |
STOQ(can->width,cw); STOQ(can->height,ch); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin); |
mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin); |
mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax); |
mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax); |
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
ncan->ymin=ToReal(ncan->qymin); ncan->ymax=ToReal(ncan->qymax); |
ncan->ymin=ToReal(ncan->qymin); ncan->ymax=ToReal(ncan->qymax); |
if(can->precise && !can->wide){ |
if(can->precise && !can->wide){ |
current_can=can; |
current_can=can; |
alloc_pixmap(ncan); |
alloc_pixmap(ncan); |
#if defined(VISUAL) |
#if defined(VISUAL) || defined(__MINGW32__) |
ncan->real_can=can; |
ncan->real_can=can; |
#endif |
#endif |
qifplotmain(ncan); |
qifplotmain(ncan); |
copy_subimage(ncan,can,spos); |
copy_subimage(ncan,can,spos); |
copy_to_canvas(can); |
copy_to_canvas(can); |
} else { |
} else { |
create_canvas(ncan); |
create_canvas(ncan); |
if( can->precise ) qifplotmain(ncan); |
if( can->precise ) qifplotmain(ncan); |
else ifplotmainNG(ncan); |
else ifplotmain(ncan); |
copy_to_canvas(ncan); |
copy_to_canvas(ncan); |
} |
} |
} |
} |
} |
} |
*/ |
*/ |
|
|
void plot_resize(struct canvas *can,POINT spos,POINT epos){ |
void plot_resize(struct canvas *can,POINT spos,POINT epos){ |
struct canvas *ncan; |
struct canvas *ncan; |
Q dx,dx2,xmin,xmax,xmid,sx,ex,cw,ten,two,s,t; |
Q dx,dx2,xmin,xmax,xmid,sx,ex,cw,ten,two,s,t; |
double dy,ymin,ymax,ymid; |
double dy,ymin,ymax,ymid; |
int new,w,h,m; |
int new,w,h,m; |
|
|
if( XC(spos)<XC(epos) && YC(spos)<YC(epos) ){ |
if( XC(spos)<XC(epos) && YC(spos)<YC(epos) ){ |
new=search_canvas(); ncan=canvas[new]; |
new=search_canvas(); ncan=canvas[new]; |
ncan->mode=can->mode; |
ncan->mode=can->mode; |
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
ncan->nzstep=can->nzstep; |
ncan->nzstep=can->nzstep; |
ncan->wname=can->wname; |
ncan->wname=can->wname; |
ncan->vx=can->vx; ncan->vy=can->vy; |
ncan->vx=can->vx; ncan->vy=can->vy; |
ncan->formula=can->formula; |
ncan->formula=can->formula; |
ncan->color=can->color; |
ncan->color=can->color; |
w=XC(epos)-XC(spos); |
w=XC(epos)-XC(spos); |
h=YC(epos)-YC(spos); |
h=YC(epos)-YC(spos); |
m=MAX(can->width,can->height); |
m=MAX(can->width,can->height); |
if( w>h ){ |
if( w>h ){ |
ncan->width=m; |
ncan->width=m; |
ncan->height=m * h/w; |
ncan->height=m * h/w; |
} else { |
} else { |
ncan->width=m * w/h; |
ncan->width=m * w/h; |
ncan->height=m; |
ncan->height=m; |
} |
} |
if( can->wide ){ |
if( can->wide ){ |
STOQ(10,ten); STOQ(2,two); |
STOQ(10,ten); STOQ(2,two); |
subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx); |
subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx); |
addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid); |
addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid); |
divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax); |
divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax); |
dy=(can->ymax-can->ymin)*10; |
dy=(can->ymax-can->ymin)*10; |
ymid=(can->ymax+can->ymin)/2; |
ymid=(can->ymax+can->ymin)/2; |
ymin=ymid-dy/2; ymax=ymid+dy/2; |
ymin=ymid-dy/2; ymax=ymid+dy/2; |
} else { |
} else { |
subq(can->qxmax,can->qxmin,&dx); |
subq(can->qxmax,can->qxmin,&dx); |
xmin=can->qxmin; |
xmin=can->qxmin; |
xmax=can->qxmax; |
xmax=can->qxmax; |
dy=can->ymax-can->ymin; |
dy=can->ymax-can->ymin; |
ymin=can->ymin; |
ymin=can->ymin; |
ymax=can->ymax; |
ymax=can->ymax; |
} |
} |
STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw); |
STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
ncan->ymin=ymax-YC(epos)*dy/can->height; |
ncan->ymin=ymax-YC(epos)*dy/can->height; |
ncan->ymax=ymax-YC(spos)*dy/can->height; |
ncan->ymax=ymax-YC(spos)*dy/can->height; |
create_canvas(ncan); |
ncan->prec = can->prec; |
|
create_canvas(ncan); |
|
|
switch (ncan->mode){ |
switch (ncan->mode){ |
case 0://IFPLOT |
case 0://IFPLOT |
case 1://CONPLOT |
case 1://CONPLOT |
ifplotmain(ncan); |
ifplotmain(ncan); |
break; |
break; |
case 2://PLOT |
case 2://PLOT |
plotcalc(ncan); |
plotcalc(ncan); |
plot_print(display,ncan); |
plot_print(display,ncan); |
break; |
break; |
case 4://POLARPLOT |
case 4://POLARPLOT |
polarcalc(ncan); |
polarcalc(ncan); |
plot_print(display,ncan); |
plot_print(display,ncan); |
break; |
break; |
case 30://MEMORY_PLOT |
case 30://MEMORY_PLOT |
break; |
break; |
case 31://ARRAYPLOT |
case 31://ARRAYPLOT |
break; |
break; |
case 33://DRAWCIRCLE |
case 33://DRAWCIRCLE |
break; |
break; |
case 34://DRAW_OBJ |
case 34://DRAW_OBJ |
break; |
break; |
case 35://DRAW_STRING |
case 35://DRAW_STRING |
break; |
break; |
case 36://OBJ_CP |
case 36://OBJ_CP |
break; |
break; |
case 6://IFPLOTD |
case 6://IFPLOTD |
case 7://IFPLOTQ |
case 7://IFPLOTQ |
case 8://IFPLOTB |
case 8://IFPLOTB |
case 9://INEQND |
case 9://INEQND |
case 10://INEQNQ |
case 10://INEQNQ |
case 11://INEQNB |
case 11://INEQNB |
case 21://CONPLOTD |
case 21://CONPLOTD |
case 22://CONPLOTQ |
case 22://CONPLOTQ |
case 23://CONPLOTB |
case 23://CONPLOTB |
case 24://ITVIFPLOT |
case 24://ITVIFPLOT |
//ifplotNG |
//ifplotNG |
ifplotmainNG(ncan); |
ifplotmainNG(ncan); |
break; |
break; |
case 12://INEQNDAND |
case 12://INEQNDAND |
case 13://INEQNQAND |
case 13://INEQNQAND |
case 14://INEQNBAND |
case 14://INEQNBAND |
case 15://INEQNDOR |
case 15://INEQNDOR |
case 16://INEQNQOR |
case 16://INEQNQOR |
case 17://INEQNBOR |
case 17://INEQNBOR |
case 18://INEQNDXOR |
case 18://INEQNDXOR |
case 19://INEQNQXOR |
case 19://INEQNQXOR |
case 20://INEQNBXOR |
case 20://INEQNBXOR |
case 25://PLOTOVERD |
case 25://PLOTOVERD |
case 26://PLOTOVERQ |
case 26://PLOTOVERQ |
case 27://PLOTOVERB |
case 27://PLOTOVERB |
//ifplotOP |
//ifplotOP |
ifplotmainNG(ncan); |
ifplotmainNG(ncan); |
break; |
break; |
case 38://POLARPLOTD |
case 38://POLARPLOTD |
//polarplotNG |
//polarplotNG |
polarcalcNG(ncan); |
polarcalcNG(ncan); |
polar_print(display,ncan); |
polar_print(display,ncan); |
break; |
break; |
} |
} |
copy_to_canvas(ncan); |
copy_to_canvas(ncan); |
} |
} |
} |
} |
|
|
void qifplotmain(struct canvas *can) |
void qifplotmain(struct canvas *can) |
{ |
{ |
int width,height; |
int width,height; |
char **tabe,*tabeb; |
char **tabe,*tabeb; |
int i; |
int i; |
|
|
width=can->width; height=can->height; |
width=can->width; height=can->height; |
tabe=(char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char)); |
tabe=(char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char)); |
bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char)); |
bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char)); |
for( i=0, tabeb=(char *)(tabe+width); i<width; i++ ) |
for( i=0, tabeb=(char *)(tabe+width); i<width; i++ ) |
tabe[i]=tabeb + height*i; |
tabe[i]=tabeb + height*i; |
define_cursor(can->window,runningcur); |
define_cursor(can->window,runningcur); |
set_busy(can); set_selection(); |
set_busy(can); set_selection(); |
qcalc(tabe,can); qif_print(display,tabe,can); |
qcalc(tabe,can); qif_print(display,tabe,can); |
reset_selection(); reset_busy(can); |
reset_selection(); reset_busy(can); |
define_cursor(can->window,normalcur); |
define_cursor(can->window,normalcur); |
} |
} |
|
|
//*******************ifplotNG |
//*******************ifplotNG |
int ifplotNG(NODE arg,int func){ |
int ifplotNG(NODE arg,int func){ |
int id,op_code; |
int id,op_code; |
unsigned int color; |
unsigned int color; |
NODE n; |
NODE n; |
struct canvas *can; |
struct canvas *can; |
P formula; |
P formula; |
LIST xrange,yrange,zrange,wsize; |
LIST xrange,yrange,zrange,wsize; |
STRING wname; |
STRING wname; |
|
|
can=canvas[id=search_canvas()]; |
can=canvas[id=search_canvas()]; |
formula=(P)ARG0(arg); |
formula=(P)ARG0(arg); |
can->color=QTOS((Q)ARG1(arg)); |
can->color=QTOS((Q)ARG1(arg)); |
xrange=(LIST)ARG2(arg); |
xrange=(LIST)ARG2(arg); |
yrange=(LIST)ARG3(arg); |
yrange=(LIST)ARG3(arg); |
zrange=(LIST)ARG4(arg); |
zrange=(LIST)ARG4(arg); |
wsize=(LIST)ARG5(arg); |
wsize=(LIST)ARG5(arg); |
wname=(STRING)ARG6(arg); |
wname=(STRING)ARG6(arg); |
can->division=0; |
can->division=0; |
// set canvas data |
// set canvas data |
if(xrange){ |
if(xrange){ |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
n=BDY(xrange); can->vx=VR((P)BDY(n)); n=NEXT(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->qxmin=(Q)BDY(n); n=NEXT(n); can->qxmax=(Q)BDY(n); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
can->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
} |
} |
if(yrange){ |
if(yrange){ |
n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n); |
n=BDY(yrange); can->vy=VR((P)BDY(n)); n=NEXT(n); |
can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n); |
can->qymin=(Q)BDY(n); n=NEXT(n); can->qymax=(Q)BDY(n); |
can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
can->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
} |
} |
if(zrange){ |
if(zrange){ |
n=BDY(zrange); can->zmin=ToReal(BDY(n)); |
n=BDY(zrange); can->zmin=ToReal(BDY(n)); |
n=NEXT(n); can->zmax=ToReal(BDY(n)); |
n=NEXT(n); can->zmax=ToReal(BDY(n)); |
n=NEXT(n); can->nzstep=QTOS((Q)BDY(n)); |
n=NEXT(n); can->nzstep=QTOS((Q)BDY(n)); |
} |
} |
if(!wsize){ |
if(!wsize){ |
can->width=DEFAULTWIDTH; |
can->width=DEFAULTWIDTH; |
can->height=DEFAULTHEIGHT; |
can->height=DEFAULTHEIGHT; |
} else { |
} else { |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
} |
} |
if(wname) can->wname=BDY(wname); |
if(wname) can->wname=BDY(wname); |
else can->wname=""; |
else can->wname=""; |
can->formula=formula; |
can->formula=formula; |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
can->mode=func; |
can->mode=func; |
create_canvas(can); |
create_canvas(can); |
ifplotmainNG(can); |
ifplotmainNG(can); |
copy_to_canvas(can); |
copy_to_canvas(can); |
return id; |
return id; |
} |
} |
|
|
int ifplotOP(NODE arg,int func){ |
int ifplotOP(NODE arg,int func){ |
//ineqnor[D,Q,B],ineqnand[D,Q,B],ineqnxor[D,Q,b],plotover[D,Q,B] |
//ineqnor[D,Q,B],ineqnand[D,Q,B],ineqnxor[D,Q,b],plotover[D,Q,B] |
int index,op_code; |
int index,op_code; |
unsigned int orgcolor,color; |
unsigned int orgcolor,color; |
P formula; |
P formula; |
struct canvas *can; |
struct canvas *can; |
VL vl,vl0; |
VL vl,vl0; |
NODE n; |
NODE n; |
|
|
index=QTOS((Q)ARG0(arg)); |
index=QTOS((Q)ARG0(arg)); |
formula=(P)ARG1(arg); |
formula=(P)ARG1(arg); |
color=QTOS((Q)ARG2(arg)); |
color=QTOS((Q)ARG2(arg)); |
// set canvas data |
// set canvas data |
can=canvas[index]; |
can=canvas[index]; |
orgcolor=can->color; |
orgcolor=can->color; |
can->color=color; |
can->color=color; |
can->formula=formula; |
can->formula=formula; |
current_can=can; |
current_can=can; |
get_vars_recursive((Obj)formula,&vl); |
get_vars_recursive((Obj)formula,&vl); |
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
if(vl0->v->attr==(pointer)V_IND) |
if(vl0->v->attr==(pointer)V_IND) |
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
#endif |
#endif |
can->mode=func; |
can->mode=func; |
set_drawcolor(color); |
set_drawcolor(color); |
ifplotmainNG(can); |
ifplotmainNG(can); |
set_drawcolor(orgcolor); |
set_drawcolor(orgcolor); |
copy_to_canvas(can); |
copy_to_canvas(can); |
can->color=orgcolor; |
can->color=orgcolor; |
#if !defined(VISUAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
#endif |
#endif |
return index; |
return index; |
} |
} |
|
|
void ifplotmainNG(struct canvas *can){ |
void ifplotmainNG(struct canvas *can){ |
int width,height,i,j,ix,iy,**mask; |
int width,height,i,j,ix,iy,**mask; |
double **tabe; |
double **tabe; |
|
|
width=can->width; height=can->height; |
width=can->width; height=can->height; |
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
define_cursor(can->window,runningcur); |
define_cursor(can->window,runningcur); |
set_busy(can); set_selection(); |
set_busy(can); set_selection(); |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
switch(can->mode){ |
switch(can->mode){ |
case 6://IFPLOTD |
case 6://IFPLOTD |
calc(tabe,can,0); |
calc(tabe,can,0); |
if_printNG(display,tabe,can,1); |
if_printNG(display,tabe,can,1); |
break; |
break; |
case 7://IFPLOTQ |
case 7://IFPLOTQ |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
if_printNG(display,tabe,can,1); |
if_printNG(display,tabe,can,1); |
break; |
break; |
case 8://IFPLOTB |
case 8://IFPLOTB |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
if_printNG(display,tabe,can,0); |
if_printNG(display,tabe,can,0); |
break; |
break; |
case 9://INEQND |
case 9://INEQND |
calc(tabe,can,0); |
calc(tabe,can,0); |
area_print(display,tabe,can,0); |
area_print(display,tabe,can,0); |
break; |
break; |
case 10://INEQNQ |
case 10://INEQNQ |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
area_print(display,tabe,can,0); |
area_print(display,tabe,can,0); |
break; |
break; |
case 11://INEQNB |
case 11://INEQNB |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
area_print(display,tabe,can,0); |
area_print(display,tabe,can,0); |
break; |
break; |
case 12://INEQNFAND |
case 12://INEQNFAND |
calc(tabe,can,0); |
calc(tabe,can,0); |
area_print(display,tabe,can,2); |
area_print(display,tabe,can,2); |
break; |
break; |
case 13://INEQNQAND |
case 13://INEQNQAND |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
area_print(display,tabe,can,2); |
area_print(display,tabe,can,2); |
break; |
break; |
case 14://INEQNBAND |
case 14://INEQNBAND |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
area_print(display,tabe,can,2); |
area_print(display,tabe,can,2); |
break; |
break; |
case 15://INEQNDOR |
case 15://INEQNDOR |
calc(tabe,can,0); |
calc(tabe,can,0); |
area_print(display,tabe,can,3); |
area_print(display,tabe,can,3); |
break; |
break; |
case 16://INEQNQOR |
case 16://INEQNQOR |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
area_print(display,tabe,can,3); |
area_print(display,tabe,can,3); |
break; |
break; |
case 17://INEQNBOR |
case 17://INEQNBOR |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
area_print(display,tabe,can,3); |
area_print(display,tabe,can,3); |
break; |
break; |
case 18://INEQNDXOR |
case 18://INEQNDXOR |
calc(tabe,can,0); |
calc(tabe,can,0); |
area_print(display,tabe,can,4); |
area_print(display,tabe,can,4); |
break; |
break; |
case 19://INEQNQXOR |
case 19://INEQNQXOR |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
area_print(display,tabe,can,4); |
area_print(display,tabe,can,4); |
break; |
break; |
case 20://INEQNBXOR |
case 20://INEQNBXOR |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
area_print(display,tabe,can,4); |
area_print(display,tabe,can,4); |
break; |
break; |
case 21://CONPLOTD |
case 21://CONPLOTD |
calc(tabe,can,0); |
calc(tabe,can,0); |
con_print(display,tabe,can); |
con_print(display,tabe,can); |
break; |
break; |
case 22://CONPLOTQ |
case 22://CONPLOTQ |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
con_print(display,tabe,can); |
con_print(display,tabe,can); |
break; |
break; |
case 23://CONPLOTB |
case 23://CONPLOTB |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
con_print(display,tabe,can); |
con_print(display,tabe,can); |
break; |
break; |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
case 24://ITVIFPLOT: |
case 24://ITVIFPLOT: |
itvcalc(tabe,can,1); |
itvcalc(tabe,can,1); |
if_printNG(display,tabe,can,1); |
if_printNG(display,tabe,can,1); |
break; |
break; |
#endif |
#endif |
case 25://PLOTOVERD |
case 25://PLOTOVERD |
calc(tabe,can,0); |
calc(tabe,can,0); |
over_print(display,tabe,can,0); |
over_print(display,tabe,can,0); |
break; |
break; |
case 26://PLOTOVERQ: |
case 26://PLOTOVERQ: |
calcq(tabe,can,0); |
calcq(tabe,can,0); |
over_print(display,tabe,can,0); |
over_print(display,tabe,can,0); |
break; |
break; |
case 27://PLOTOVERB: |
case 27://PLOTOVERB: |
calcb(tabe,can,0); |
calcb(tabe,can,0); |
over_print(display,tabe,can,0); |
over_print(display,tabe,can,0); |
break; |
break; |
} |
} |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
reset_selection(); reset_busy(can); |
reset_selection(); reset_busy(can); |
define_cursor(can->window,normalcur); |
define_cursor(can->window,normalcur); |
} |
} |
|
|
#if defined(INTERVAL) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
int objcp(NODE arg){ |
int objcp(NODE arg){ |
int idsrc, idtrg, op_code; |
int idsrc, idtrg, op_code; |
struct canvas *cansrc, *cantrg; |
struct canvas *cansrc, *cantrg; |
|
|
idsrc=QTOS((Q)ARG0(arg)); |
idsrc=QTOS((Q)ARG0(arg)); |
idtrg=QTOS((Q)ARG1(arg)); |
idtrg=QTOS((Q)ARG1(arg)); |
op_code=QTOS((Q)ARG2(arg)); |
op_code=QTOS((Q)ARG2(arg)); |
cansrc=canvas[idsrc]; |
cansrc=canvas[idsrc]; |
cantrg=canvas[idtrg]; |
cantrg=canvas[idtrg]; |
obj_op(cansrc, cantrg, op_code); |
obj_op(cansrc, cantrg, op_code); |
return idsrc; |
return idsrc; |
} |
} |
|
|
void obj_op(struct canvas *cansrc, struct canvas *cantrg, int op){ |
void obj_op(struct canvas *cansrc, struct canvas *cantrg, int op){ |
XImage *imgsrc, *imgtrg; |
XImage *imgsrc, *imgtrg; |
int width, height, i, j; |
int width, height, i, j; |
unsigned long src, trg, black, white; |
unsigned long src, trg, black, white; |
|
|
width=cansrc->width; height=cansrc->height; |
width=cansrc->width; height=cansrc->height; |
imgsrc=XGetImage(display, cansrc->pix, 0, 0, width, height, -1, ZPixmap); |
imgsrc=XGetImage(display, cansrc->pix, 0, 0, width, height, -1, ZPixmap); |
imgtrg=XGetImage(display, cantrg->pix, 0, 0, width, height, -1, ZPixmap); |
imgtrg=XGetImage(display, cantrg->pix, 0, 0, width, height, -1, ZPixmap); |
black=GetColor(display, "black"); |
black=GetColor(display, "black"); |
white=GetColor(display, "white"); |
white=GetColor(display, "white"); |
flush(); |
flush(); |
define_cursor(cantrg->window,runningcur); |
define_cursor(cantrg->window,runningcur); |
set_busy(cantrg); set_selection(); |
set_busy(cantrg); set_selection(); |
cantrg->precise=cansrc->precise; |
cantrg->precise=cansrc->precise; |
cantrg->noaxis=cansrc->noaxis; |
cantrg->noaxis=cansrc->noaxis; |
cantrg->noaxisb=cansrc->noaxisb; |
cantrg->noaxisb=cansrc->noaxisb; |
cantrg->vx=cansrc->vx; |
cantrg->vx=cansrc->vx; |
cantrg->vy=cansrc->vy; |
cantrg->vy=cansrc->vy; |
cantrg->formula=cansrc->formula; |
cantrg->formula=cansrc->formula; |
cantrg->width=cansrc->width; |
cantrg->width=cansrc->width; |
cantrg->height=cansrc->height; |
cantrg->height=cansrc->height; |
cantrg->xmin=cansrc->xmin; |
cantrg->xmin=cansrc->xmin; |
cantrg->xmax=cansrc->xmax; |
cantrg->xmax=cansrc->xmax; |
cantrg->ymin=cansrc->ymin; |
cantrg->ymin=cansrc->ymin; |
cantrg->ymax=cansrc->ymax; |
cantrg->ymax=cansrc->ymax; |
cantrg->zmin=cansrc->zmin; |
cantrg->zmin=cansrc->zmin; |
cantrg->zmax=cansrc->zmax; |
cantrg->zmax=cansrc->zmax; |
cantrg->nzstep=cansrc->nzstep; |
cantrg->nzstep=cansrc->nzstep; |
cantrg->qxmin=cansrc->qxmin; |
cantrg->qxmin=cansrc->qxmin; |
cantrg->qxmax=cansrc->qxmax; |
cantrg->qxmax=cansrc->qxmax; |
cantrg->qymin=cansrc->qymin; |
cantrg->qymin=cansrc->qymin; |
cantrg->qymax=cansrc->qymax; |
cantrg->qymax=cansrc->qymax; |
cantrg->pa=cansrc->pa; |
cantrg->pa=cansrc->pa; |
switch(op){ |
switch(op){ |
case 1:/* and case */ |
case 1:/* and case */ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
src=XGetPixel(imgsrc,i,j); |
src=XGetPixel(imgsrc,i,j); |
trg=XGetPixel(imgtrg,i,j); |
trg=XGetPixel(imgtrg,i,j); |
if( (src == black) || (trg == black) ) |
if( (src == black) || (trg == black) ) |
XPutPixel(imgtrg,i,j,black); |
XPutPixel(imgtrg,i,j,black); |
else if( (src == white) || (trg == white) ) |
else if( (src == white) || (trg == white) ) |
XPutPixel(imgtrg,i,j,white); |
XPutPixel(imgtrg,i,j,white); |
else XPutPixel(imgtrg,i,j,(src & trg)); |
else XPutPixel(imgtrg,i,j,(src & trg)); |
} |
} |
break; |
break; |
case 3:/* copy case */ |
case 3:/* copy case */ |
imgtrg->data=imgsrc->data; |
imgtrg->data=imgsrc->data; |
break; |
break; |
case 6:/* xor case */ |
case 6:/* xor case */ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
src=XGetPixel(imgsrc,i,j); |
src=XGetPixel(imgsrc,i,j); |
trg=XGetPixel(imgtrg,i,j); |
trg=XGetPixel(imgtrg,i,j); |
if( (src == black) || (trg == black) ) |
if( (src == black) || (trg == black) ) |
XPutPixel(imgtrg,i,j,black); |
XPutPixel(imgtrg,i,j,black); |
else if( (src == white) && (trg == white) ) |
else if( (src == white) && (trg == white) ) |
XPutPixel(imgtrg,i,j,trg|src); |
XPutPixel(imgtrg,i,j,trg|src); |
else if( (src != white) && (trg != white) ) |
else if( (src != white) && (trg != white) ) |
XPutPixel(imgtrg,i,j,white); |
XPutPixel(imgtrg,i,j,white); |
else if( src == white ) |
else if( src == white ) |
XPutPixel(imgtrg,i,j,src); |
XPutPixel(imgtrg,i,j,src); |
} |
} |
break; |
break; |
case 7:/* or case */ |
case 7:/* or case */ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
src=XGetPixel(imgsrc,i,j); |
src=XGetPixel(imgsrc,i,j); |
trg=XGetPixel(imgtrg,i,j); |
trg=XGetPixel(imgtrg,i,j); |
if( (src == black) || (trg == black) ) |
if( (src == black) || (trg == black) ) |
XPutPixel(imgtrg,i,j,black); |
XPutPixel(imgtrg,i,j,black); |
else if(src == white) |
else if(src == white) |
XPutPixel(imgtrg,i,j,trg); |
XPutPixel(imgtrg,i,j,trg); |
else if(trg == white) |
else if(trg == white) |
XPutPixel(imgtrg,i,j,src); |
XPutPixel(imgtrg,i,j,src); |
} |
} |
break; |
break; |
default: |
default: |
break; |
break; |
} |
} |
XPutImage(display, cantrg->pix, drawGC, imgtrg, 0, 0, 0, 0, width, height); |
XPutImage(display, cantrg->pix, drawGC, imgtrg, 0, 0, 0, 0, width, height); |
reset_selection(); reset_busy(cantrg); |
reset_selection(); reset_busy(cantrg); |
define_cursor(cantrg->window,normalcur); |
define_cursor(cantrg->window,normalcur); |
copy_to_canvas(cantrg); |
copy_to_canvas(cantrg); |
count_and_flush(); |
count_and_flush(); |
flush(); |
flush(); |
} |
} |
#endif |
#endif |
|
|
int polarplotNG(NODE arg){ |
int polarplotNG(NODE arg){ |
int i,id,width,height; |
int i,id,width,height; |
NODE n; |
NODE n; |
struct canvas *can; |
struct canvas *can; |
LIST range,geom; |
LIST range,geom; |
STRING wname; |
STRING wname; |
V v; |
V v; |
|
|
id=search_canvas(); |
id=search_canvas(); |
can=canvas[id]; |
can=canvas[id]; |
can->mode=modeNO(POLARPLOTD); |
can->mode=modeNO(POLARPLOTD); |
can->formula=(P)ARG0(arg); |
can->formula=(P)ARG0(arg); |
can->color=QTOS((Q)ARG1(arg)); |
can->color=QTOS((Q)ARG1(arg)); |
range=(LIST)ARG2(arg); |
range=(LIST)ARG2(arg); |
geom=(LIST)ARG3(arg); |
geom=(LIST)ARG3(arg); |
wname=(STRING)ARG4(arg); |
wname=(STRING)ARG4(arg); |
|
|
if(range){ |
if(range){ |
n=NEXT(BDY(range)); |
n=NEXT(BDY(range)); |
can->zmin=ToReal(BDY(n)); |
can->zmin=ToReal(BDY(n)); |
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
n=NEXT(n); |
n=NEXT(n); |
can->vx=VR((P)BDY(BDY(range))); |
can->vx=VR((P)BDY(BDY(range))); |
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
} |
} |
if(geom){ |
if(geom){ |
can->width=width=QTOS((Q)BDY(BDY(geom))); |
can->width=width=QTOS((Q)BDY(BDY(geom))); |
can->height=height=QTOS((Q)BDY(NEXT(BDY(geom)))); |
can->height=height=QTOS((Q)BDY(NEXT(BDY(geom)))); |
} |
} |
if(wname)can->wname=BDY(wname); |
if(wname)can->wname=BDY(wname); |
else can->wname=""; |
else can->wname=""; |
polarcalcNG(can); |
polarcalcNG(can); |
create_canvas(can); |
create_canvas(can); |
set_drawcolor(can->color); |
set_drawcolor(can->color); |
polar_print(display,can); |
polar_print(display,can); |
reset_selection(); |
reset_selection(); |
reset_busy(can); |
reset_busy(can); |
define_cursor(can->window,normalcur); |
define_cursor(can->window,normalcur); |
return id; |
return id; |
} |
} |
|
|
void MSGdraw(char *str){ |
void MSGdraw(char *str){ |
int id,x,y; |
int id,x,y; |
struct canvas *can; |
struct canvas *can; |
|
|
id=search_canvas(); |
id=search_canvas(); |
can=canvas[id]; |
can=canvas[id]; |
can->mode=modeNO(INTERACTIVE); |
can->mode=modeNO(INTERACTIVE); |
can->width=300; |
can->width=300; |
can->height=300; |
can->height=300; |
can->wname="MSG"; |
can->wname="MSG"; |
x=100; |
x=100; |
y=100; |
y=100; |
create_canvas(can); |
create_canvas(can); |
draw_character_string(display,can,x,y,str,0xff0000); |
draw_character_string(display,can,x,y,str,0xff0000); |
} |
} |
|
|