version 1.1, 1999/12/03 07:39:13 |
version 1.37, 2018/03/29 01:32:55 |
|
|
/* $OpenXM: OpenXM/src/asir99/plot/if.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */ |
/* |
|
* Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED |
|
* All rights reserved. |
|
* |
|
* FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited, |
|
* non-exclusive and royalty-free license to use, copy, modify and |
|
* redistribute, solely for non-commercial and non-profit purposes, the |
|
* computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and |
|
* conditions of this Agreement. For the avoidance of doubt, you acquire |
|
* only a limited right to use the SOFTWARE hereunder, and FLL or any |
|
* third party developer retains all rights, including but not limited to |
|
* copyrights, in and to the SOFTWARE. |
|
* |
|
* (1) FLL does not grant you a license in any way for commercial |
|
* purposes. You may use the SOFTWARE only for non-commercial and |
|
* non-profit purposes only, such as academic, research and internal |
|
* business use. |
|
* (2) The SOFTWARE is protected by the Copyright Law of Japan and |
|
* international copyright treaties. If you make copies of the SOFTWARE, |
|
* with or without modification, as permitted hereunder, you shall affix |
|
* to all such copies of the SOFTWARE the above copyright notice. |
|
* (3) An explicit reference to this SOFTWARE and its copyright owner |
|
* shall be made on your publication or presentation in any form of the |
|
* results obtained by use of the SOFTWARE. |
|
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
|
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
|
* for such modification or the source code of the modified part of the |
|
* SOFTWARE. |
|
* |
|
* THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL |
|
* MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND |
|
* EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS |
|
* FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES' |
|
* RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY |
|
* MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY. |
|
* UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT, |
|
* OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY |
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL |
|
* DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES |
|
* ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES |
|
* FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY |
|
* DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF |
|
* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART |
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
|
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
|
* |
|
* $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" |
#include "ox.h" |
#include "ox.h" |
#include "ifplot.h" |
#include "ifplot.h" |
|
|
extern jmp_buf ox_env; |
#if defined(INTERVAL) |
|
// Time message and func |
|
#include <sys/types.h> |
|
#include <sys/resource.h> |
|
#include <sys/time.h> |
|
|
int plot(NODE arg) |
static struct oEGT ltime; |
|
static double r0; |
|
double get_rtime(); |
|
void MSGdraw(char *); |
|
char msg[128]; |
|
#if defined(ITV_TIME_CHECK) |
|
void tstart() |
{ |
{ |
int id; |
get_eg(<ime); |
NODE n; |
r0=get_rtime(); |
struct canvas *can; |
} |
P formula; |
|
LIST xrange,yrange,zrange,wsize; |
|
STRING wname; |
|
|
|
formula = (P)ARG0(arg); |
void tstop(struct canvas *can) |
xrange = (LIST)ARG1(arg); |
{ |
yrange = (LIST)ARG2(arg); |
struct oEGT egt1; |
zrange = (LIST)ARG3(arg); |
double e, g, r; |
wsize = (LIST)ARG4(arg); |
char ts[100]; |
wname = (STRING)ARG5(arg); |
void popdown_warning(); |
|
Widget warnshell,warndialog; |
|
|
can = canvas[id = search_canvas()]; |
get_eg(&egt1); |
n = BDY(xrange); can->vx = VR((P)BDY(n)); n = NEXT(n); |
e=egt1.exectime - ltime.exectime; |
can->qxmin = (Q)BDY(n); n = NEXT(n); can->qxmax = (Q)BDY(n); |
g=egt1.gctime - ltime.gctime; |
can->xmin = ToReal(can->qxmin); can->xmax = ToReal(can->qxmax); |
r=get_rtime() - r0; |
if ( yrange ) { |
sprintf(ts,"(%8.6f + gc %8.6f) total %8.6f \n",e,g,r); |
n = BDY(yrange); can->vy = VR((P)BDY(n)); n = NEXT(n); |
create_popup(can->shell,"Message",&ts,&warnshell,&warndialog); |
can->qymin = (Q)BDY(n); n = NEXT(n); can->qymax = (Q)BDY(n); |
XawDialogAddButton(warndialog,"OK",popdown_warning,warnshell); |
can->ymin = ToReal(can->qymin); can->ymax = ToReal(can->qymax); |
XtPopup(warnshell,XtGrabNone); |
if ( zrange ) { |
SetWM_Proto(warnshell); |
n = NEXT(BDY(zrange)); |
|
can->zmin = ToReal(BDY(n)); n = NEXT(n); can->zmax = ToReal(BDY(n)); |
|
if ( n = NEXT(n) ) |
|
can->nzstep = QTOS((Q)BDY(n)); |
|
else |
|
can->nzstep = MAXGC; |
|
can->mode = MODE_CONPLOT; |
|
} else |
|
can->mode = MODE_IFPLOT; |
|
} else |
|
can->mode = MODE_PLOT; |
|
if ( !wsize ) { |
|
can->width = DEFAULTWIDTH; can->height = DEFAULTHEIGHT; |
|
} else { |
|
can->width = QTOS((Q)BDY(BDY(wsize))); |
|
can->height = QTOS((Q)BDY(NEXT(BDY(wsize)))); |
|
} |
|
if ( wname ) |
|
can->wname = BDY(wname); |
|
else |
|
can->wname = ""; |
|
can->formula = formula; |
|
create_canvas(can); |
|
if ( can->mode == MODE_PLOT ) { |
|
plotcalc(can); |
|
plot_print(display,can); |
|
} else |
|
ifplotmain(can); |
|
copy_to_canvas(can); |
|
return id; |
|
} |
} |
|
#else |
|
#define tstart() |
|
#define tstop(a) |
|
#endif |
|
#endif |
|
|
int plotover(NODE arg) |
extern JMP_BUF ox_env; |
{ |
|
int index; |
|
P formula; |
|
struct canvas *can; |
|
struct canvas fakecan; |
|
VL vl,vl0; |
|
|
|
index = QTOS((Q)ARG0(arg)); |
int open_canvas(NODE arg){ |
formula = (P)ARG1(arg); |
int id; |
can = canvas[index]; |
struct canvas *can; |
if ( !can->window ) |
LIST wsize; |
return -1; |
STRING wname; |
get_vars_recursive(formula,&vl); |
|
for ( vl0 = vl; vl0; vl0 = NEXT(vl0) ) |
wsize=(LIST)ARG0(arg); |
if ( vl0->v->attr == V_IND ) |
wname=(STRING)ARG1(arg); |
if ( vl->v != can->vx && vl->v != can->vy ) |
id=search_canvas(); |
return -1; |
can=canvas[id]; |
current_can = can; |
can->mode=modeNO(INTERACTIVE); |
fakecan = *can; fakecan.formula = formula; |
if(!wsize){ |
if ( can->mode == MODE_PLOT ) { |
can->width=DEFAULTWIDTH; |
plotcalc(&fakecan); |
can->height=DEFAULTHEIGHT; |
plot_print(display,&fakecan); |
} else { |
} else |
can->width=QTOS((Q)BDY(BDY(wsize))); |
ifplotmain(&fakecan); |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
copy_to_canvas(&fakecan); |
} |
return index; |
if(wname)can->wname=BDY(wname); |
|
else can->wname=""; |
|
create_canvas(can); |
|
return id; |
} |
} |
|
|
int drawcircle(NODE arg) |
int plot(NODE arg,int fn){ |
{ |
int id; |
int id; |
NODE n; |
int index; |
struct canvas *can; |
pointer ptr; |
P formula; |
Q ret; |
LIST xrange,yrange,zrange,wsize; |
LIST xyr; |
STRING wname; |
Obj x,y,r; |
V v; |
int wx,wy,wr; |
Real r; |
struct canvas *can; |
double rr; |
struct canvas fakecan; |
|
|
|
index = QTOS((Q)ARG0(arg)); |
formula=(P)ARG0(arg); |
xyr = (LIST)ARG1(arg); |
xrange=(LIST)ARG1(arg); |
x = (Obj)ARG0(BDY(xyr)); y = (Obj)ARG1(BDY(xyr)); r = (Obj)ARG2(BDY(xyr)); |
yrange=(LIST)ARG2(arg); |
can = canvas[index]; |
zrange=(LIST)ARG3(arg); |
if ( !can->window ) |
wsize=(LIST)ARG4(arg); |
return -1; |
wname=(STRING)ARG5(arg); |
else { |
can=canvas[id=search_canvas()]; |
current_can = can; |
if(xrange){ |
wx = (ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin); |
n=BDY(xrange);can->vx=VR((P)BDY(n));n=NEXT(n); |
wy = (can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin); |
can->qxmin=(Q)BDY(n);n=NEXT(n);can->qxmax=(Q)BDY(n); |
wr = ToReal(r); |
can->xmin=ToReal(can->qxmin);can->xmax=ToReal(can->qxmax); |
XFillArc(display,can->pix,colorGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64); |
} |
copy_to_canvas(can); |
if(yrange){ |
return index; |
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->ymin=ToReal(can->qymin);can->ymax=ToReal(can->qymax); |
|
} else if ( !formula || NUM(formula) ) { |
|
devalr(CO,(Obj)formula,(Obj *)&r); rr = ToReal(r); |
|
can->ymin=rr-1; can->ymax=rr+1; |
|
} |
|
can->mode=fn; |
|
if(zrange){ |
|
n=NEXT(BDY(zrange)); |
|
can->zmin=ToReal(BDY(n)); |
|
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
|
n=NEXT(n); |
|
if(can->mode==modeNO(CONPLOT))can->nzstep=n?QTOS((Q)BDY(n)):MAXGC; |
|
else { |
|
can->vx=VR((P)BDY(BDY(zrange))); |
|
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
|
} |
|
} |
|
if(!wsize){ |
|
can->width=DEFAULTWIDTH; |
|
can->height=DEFAULTHEIGHT; |
|
} else { |
|
can->width=QTOS((Q)BDY(BDY(wsize))); |
|
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
|
} |
|
if(wname) can->wname=BDY(wname); |
|
else can->wname=""; |
|
can->formula=formula; |
|
if(can->mode==modeNO(PLOT)){ |
|
//plot |
|
can->prec=argc(arg)==7 ? QTOS((Q)ARG6(arg)) : 0; |
|
plotcalc(can); |
|
create_canvas(can); |
|
plot_print(display,can); |
|
} else if(can->mode==modeNO(POLARPLOT)){ |
|
polarcalc(can); |
|
create_canvas(can); |
|
plot_print(display,can); |
|
} else { |
|
create_canvas(can); |
|
ifplotmain(can); |
|
} |
|
copy_to_canvas(can); |
|
return id; |
} |
} |
|
|
|
void ifplotmain(struct canvas *can){ |
|
int i,width,height; |
|
double ** tabe; |
|
|
|
width=can->width;height=can->height; |
|
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
|
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
|
define_cursor(can->window,runningcur); |
|
set_busy(can); set_selection(); |
|
calc(tabe,can,0); |
|
if_print(display,tabe,can); |
|
reset_selection(); reset_busy(can); |
|
define_cursor(can->window,normalcur); |
|
} |
|
|
|
int memory_plot(NODE arg,LIST *bytes){ |
|
NODE n; |
|
struct canvas tmp_can; |
|
struct canvas *can; |
|
P formula; |
|
LIST xrange,yrange,zrange,wsize; |
|
int width,height; |
|
double **tabe; |
|
int i; |
|
BYTEARRAY barray; |
|
Q qw,qh,prec; |
|
|
|
formula=(P)ARG0(arg); |
|
xrange=(LIST)ARG1(arg); |
|
yrange=(LIST)ARG2(arg); |
|
zrange=(LIST)ARG3(arg); |
|
wsize=(LIST)ARG4(arg); |
|
|
|
bzero((char *)&tmp_can,sizeof(tmp_can)); |
|
can=&tmp_can; |
|
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->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
|
if( yrange ){ |
|
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->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
|
if( zrange ){ |
|
n=NEXT(BDY(zrange)); |
|
can->zmin=ToReal(BDY(n)); n=NEXT(n); can->zmax=ToReal(BDY(n)); |
|
n=NEXT(n); |
|
if(n) can->nzstep=QTOS((Q)BDY(n)); |
|
else can->nzstep=MAXGC; |
|
can->mode=modeNO(CONPLOT); |
|
} else |
|
can->mode=modeNO(IFPLOT); |
|
} else |
|
can->mode=modeNO(PLOT); |
|
if( !wsize ){ |
|
can->width=DEFAULTWIDTH; can->height=DEFAULTHEIGHT; |
|
} else { |
|
can->width=QTOS((Q)BDY(BDY(wsize))); |
|
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
|
} |
|
can->wname=""; |
|
can->formula=formula; |
|
if( can->mode==modeNO(PLOT)){ |
|
can->prec = argc(arg)==6 ? QTOS((Q)ARG5(arg)) : 0; |
|
plotcalc(can); |
|
memory_print(can,&barray); |
|
STOQ(can->width,qw); STOQ(can->height,qh); |
|
n=mknode(3,qw,qh,barray); |
|
MKLIST(*bytes,n); |
|
} else { |
|
width=can->width; height=can->height; |
|
tabe=(double **)ALLOCA(width*sizeof(double *)); |
|
for( i=0; i<width; i++ ) |
|
tabe[i]=(double *)ALLOCA(height*sizeof(double)); |
|
calc(tabe,can,1); |
|
memory_if_print(tabe,can,&barray); |
|
STOQ(width,qw); STOQ(height,qh); |
|
n=mknode(3,qw,qh,barray); |
|
MKLIST(*bytes,n); |
|
} |
|
return 0; |
|
} |
|
|
|
int plotover(NODE arg){ |
|
int id; |
|
unsigned int orgcolor; |
|
P formula; |
|
struct canvas *can; |
|
VL vl,vl0; |
|
|
|
id=QTOS((Q)ARG0(arg)); |
|
formula=(P)ARG1(arg); |
|
can=canvas[id]; |
|
orgcolor=can->color; |
|
if(argc(arg)==3) can->color=QTOS((Q)ARG2(arg)); |
|
else can->color=0; |
|
get_vars_recursive((Obj)formula,&vl); |
|
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
|
if(vl0->v->attr==(pointer)V_IND) |
|
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
current_can=can; |
|
can->formula=formula; |
|
if(can->mode==modeNO(PLOT)){ |
|
can->prec = argc(arg)==3 ? QTOS((Q)ARG2(arg)) : 0; |
|
plotcalc(can); |
|
plot_print(display,can); |
|
} else ifplotmain(can); |
|
copy_to_canvas(can); |
|
can->color=orgcolor; |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
return id; |
|
} |
|
|
|
int drawcircle(NODE arg){ |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
int id,index,wx,wy,wr; |
|
unsigned int c; |
|
pointer ptr; |
|
Q ret; |
|
LIST xyr; |
|
Obj x,y,r; |
|
struct canvas *can; |
|
|
|
index=QTOS((Q)ARG0(arg)); |
|
xyr=(LIST)ARG1(arg); |
|
x=(Obj)ARG0(BDY(xyr)); y=(Obj)ARG1(BDY(xyr)); r=(Obj)ARG2(BDY(xyr)); |
|
c=QTOS((Q)ARG2(arg)); |
|
can=canvas[index]; |
|
if(!can->window)return -1; |
|
else { |
|
current_can=can; |
|
set_drawcolor(c); |
|
wx=(ToReal(x)-can->xmin)*can->width/(can->xmax-can->xmin); |
|
wy=(can->ymax-ToReal(y))*can->height/(can->ymax-can->ymin); |
|
wr=ToReal(r); |
|
XFillArc(display,can->pix,cdrawGC,wx-wr/2,wy-wr/2,wr,wr,0,360*64); |
|
copy_to_canvas(can); |
|
set_drawcolor(can->color); |
|
return index; |
|
} |
|
#endif |
|
} |
|
|
|
int draw_obj(NODE arg){ |
|
int index,x,y,u,v,len,r; |
|
unsigned int color; |
|
NODE obj,n; |
|
RealVect *vect; |
|
struct canvas *can; |
|
|
|
index=QTOS((Q)ARG0(arg)); |
|
can=canvas[index]; |
|
if(!can && closed_canvas[index]){ |
|
canvas[index]=closed_canvas[index]; |
|
closed_canvas[index]=0; |
|
can=canvas[index]; |
|
popup_canvas(index); |
|
current_can=can; |
|
} else if(!can||(can && !can->window)){ |
|
set_lasterror("draw_obj : canvas does not exist"); |
|
return -1; |
|
} |
|
|
|
obj=BDY((LIST)ARG1(arg)); |
|
if(argc(arg)== 3) color=QTOS((Q)ARG2(arg)); |
|
else color=0; // black |
|
switch(len=length(obj)){ |
|
case 2: // point |
|
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
|
draw_point(display,can,x,y,color); |
|
MKRVECT3(vect,x,y,color); MKNODE(n,vect,can->history); |
|
can->history=n; |
|
break; |
|
case 3: // circle |
|
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
|
r=(int)ToReal((Q)ARG2(obj)); |
|
MKRVECT4(vect,x,y,r,color); MKNODE(n,vect,can->history); |
|
can->history=n; |
|
break; |
|
case 4: // line |
|
x=(int)ToReal((Q)ARG0(obj)); y=(int)ToReal((Q)ARG1(obj)); |
|
u=(int)ToReal((Q)ARG2(obj)); v=(int)ToReal((Q)ARG3(obj)); |
|
draw_line(display,can,x,y,u,v,color); |
|
MKRVECT5(vect,x,y,u,v,color); MKNODE(n,vect,can->history); |
|
can->history=n; |
|
break; |
|
default: |
|
set_lasterror("draw_obj : invalid request"); |
|
return -1; |
|
} |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
return 0; |
|
} |
|
|
|
int draw_string(NODE arg){ |
|
int index,x,y; |
|
unsigned int color; |
|
char *str; |
|
NODE pos; |
|
struct canvas *can; |
|
|
|
index=QTOS((Q)ARG0(arg)); |
|
can=canvas[index]; |
|
if(!can && closed_canvas[index]){ |
|
canvas[index]=closed_canvas[index]; |
|
closed_canvas[index]=0; |
|
can=canvas[index]; |
|
popup_canvas(index); |
|
current_can=can; |
|
} else if(!can||(can && !can->window)){ |
|
set_lasterror("draw_obj : canvas does not exist"); |
|
return -1; |
|
} |
|
|
|
pos=BDY((LIST)ARG1(arg)); |
|
str=BDY((STRING)ARG2(arg)); |
|
if(argc(arg)==4)color=QTOS((Q)ARG3(arg)); |
|
else color=0; // black |
|
x=(int)ToReal((Q)ARG0(pos)); |
|
y=(int)ToReal((Q)ARG1(pos)); |
|
draw_character_string(display,can,x,y,str,color); |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
return 0; |
|
} |
|
|
|
int clear_canvas(NODE arg){ |
|
int index; |
|
struct canvas *can; |
|
|
|
index=QTOS((Q)ARG0(arg)); |
|
can=canvas[index]; |
|
if(!can||!can->window) return -1; |
|
clear_pixmap(can); |
|
copy_to_canvas(can); |
|
// clear the history |
|
can->history=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; |
Q ret; |
Real *tab; |
double ymax,ymin,dy,xstep; |
struct canvas *can; |
Real *tab; |
POINT *pa; |
struct canvas *can; |
|
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->height = DEFAULTHEIGHT; |
can->width=DEFAULTWIDTH; |
} else { |
can->height=DEFAULTHEIGHT; |
can->width = QTOS((Q)BDY(BDY(wsize))); |
} else { |
can->height = QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->width=QTOS((Q)BDY(BDY(wsize))); |
} |
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
can->wname = wname; can->formula = 0; can->mode = MODE_PLOT; |
} |
create_canvas(can); |
can->wname=wname; can->formula=0; can->mode=modeNO(PLOT); |
w = array->len; |
create_canvas(can); |
h = can->height; |
w=array->len; |
tab = (Real *)BDY(array); |
h=can->height; |
if ( can->ymax == can->ymin ) { |
tab=(Real *)BDY(array); |
for ( ymax = ymin = RealtoDbl(tab[0]), ix = 1; ix < w; ix++ ) { |
if(can->ymax==can->ymin){ |
if ( RealtoDbl(tab[ix]) > ymax ) |
for(ymax=ymin=RealtoDbl(tab[0]),ix=1; ix<w; ix++){ |
ymax = RealtoDbl(tab[ix]); |
if(RealtoDbl(tab[ix])>ymax)ymax=RealtoDbl(tab[ix]); |
if ( RealtoDbl(tab[ix]) < ymin ) |
if(RealtoDbl(tab[ix])<ymin)ymin=RealtoDbl(tab[ix]); |
ymin = RealtoDbl(tab[ix]); |
} |
} |
can->ymax=ymax; |
can->ymax = ymax; can->ymin = ymin; |
can->ymin=ymin; |
} else { |
} else { |
ymax = can->ymax; ymin = can->ymin; |
ymax=can->ymax; |
} |
ymin=can->ymin; |
dy = ymax-ymin; |
} |
can->pa = (struct pa *)MALLOC(sizeof(struct pa)); |
dy=ymax-ymin; |
can->pa[0].length = w; |
can->pa=(struct pa *)MALLOC(sizeof(struct pa)); |
can->pa[0].pos = pa = (POINT *)MALLOC(w*sizeof(POINT)); |
can->pa[0].length=w; |
xstep = (double)can->width/(double)(w-1); |
can->pa[0].pos=pa=(POINT *)MALLOC(w*sizeof(POINT)); |
for ( ix = 0; ix < w; ix++ ) { |
xstep=(double)can->width/(double)(w-1); |
|
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 ) |
if(t>MAXSHORT)pa[ix].y=MAXSHORT; |
pa[ix].y = MAXSHORT; |
else if(t<-MAXSHORT)pa[ix].y=-MAXSHORT; |
else if ( t < -MAXSHORT ) |
else pa[ix].y=(long)t; |
pa[ix].y = -MAXSHORT; |
} |
else |
plot_print(display,can); |
pa[ix].y = t; |
copy_to_canvas(can); |
} |
return id; |
plot_print(display,can); |
|
copy_to_canvas(can); |
|
return id; |
|
} |
} |
|
/* |
|
void ifplot_resize(struct canvas *can,POINT spos,POINT epos){ |
|
struct canvas *ncan; |
|
struct canvas fakecan; |
|
Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid; |
|
Q sx,sy,ex,ey,cw,ch,ten,two; |
|
Q s,t; |
|
int new; |
|
int w,h,m; |
|
if(XC(spos)<XC(epos) && YC(spos)<YC(epos)){ |
|
if(can->precise && !can->wide){ |
|
fakecan=*can; |
|
ncan=&fakecan; |
|
} else { |
|
new=search_canvas(); |
|
ncan=canvas[new]; |
|
} |
|
ncan->mode=can->mode; |
|
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
|
ncan->nzstep=can->nzstep; |
|
ncan->wname=can->wname; |
|
ncan->vx=can->vx; ncan->vy=can->vy; |
|
ncan->formula=can->formula; |
|
w=XC(epos)-XC(spos); |
|
h=YC(epos)-YC(spos); |
|
m=MAX(can->width,can->height); |
|
if(can->precise){ |
|
ncan->width=w; |
|
ncan->height=h; |
|
} else if(w>h){ |
|
ncan->width=m; |
|
ncan->height=m*h/w; |
|
} else { |
|
ncan->width=m*w/h; |
|
ncan->height=m; |
|
} |
|
if(can->wide){ |
|
STOQ(10,ten); |
|
STOQ(2,two); |
|
subq(can->qxmax,can->qxmin,&t); |
|
mulq(t,ten,&dx); |
|
subq(can->qymax,can->qymin,&t); |
|
mulq(t,ten,&dy); |
|
addq(can->qxmax,can->qxmin,&t); |
|
divq(t,two,&xmid); |
|
addq(can->qymax,can->qymin,&t); |
|
divq(t,two,&ymid); |
|
divq(dx,two,&dx2); |
|
divq(dy,two,&dy2); |
|
subq(xmid,dx2,&xmin); |
|
addq(xmid,dx2,&xmax); |
|
subq(ymid,dy2,&ymin); |
|
addq(ymid,dy2,&ymax); |
|
} else { |
|
subq(can->qxmax,can->qxmin,&dx); |
|
subq(can->qymax,can->qymin,&dy); |
|
xmin=can->qxmin; |
|
xmax=can->qxmax; |
|
ymin=can->qymin; |
|
ymax=can->qymax; |
|
} |
|
STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey); |
|
STOQ(can->width,cw); STOQ(can->height,ch); |
|
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(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); |
|
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
|
ncan->ymin=ToReal(ncan->qymin); ncan->ymax=ToReal(ncan->qymax); |
|
if(can->precise && !can->wide){ |
|
current_can=can; |
|
alloc_pixmap(ncan); |
|
#if defined(VISUAL) || defined(__MINGW32__) |
|
ncan->real_can=can; |
|
#endif |
|
qifplotmain(ncan); |
|
copy_subimage(ncan,can,spos); |
|
copy_to_canvas(can); |
|
} else { |
|
create_canvas(ncan); |
|
if( can->precise ) qifplotmain(ncan); |
|
else ifplotmain(ncan); |
|
copy_to_canvas(ncan); |
|
} |
|
} |
|
} |
|
*/ |
|
|
ifplot_resize(can,spos,epos) |
void plot_resize(struct canvas *can,POINT spos,POINT epos){ |
struct canvas *can; |
struct canvas *ncan; |
POINT spos,epos; |
Q dx,dx2,xmin,xmax,xmid,sx,ex,cw,ten,two,s,t; |
{ |
double dy,ymin,ymax,ymid; |
struct canvas *ncan; |
int new,w,h,m; |
struct canvas fakecan; |
|
Q dx,dy,dx2,dy2,xmin,xmax,ymin,ymax,xmid,ymid; |
|
Q sx,sy,ex,ey,cw,ch,ten,two; |
|
Q s,t; |
|
int new; |
|
int w,h,m; |
|
Q ret; |
|
|
|
if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) { |
if( XC(spos)<XC(epos) && YC(spos)<YC(epos) ){ |
if ( can->precise && !can->wide ) { |
new=search_canvas(); ncan=canvas[new]; |
fakecan = *can; ncan = &fakecan; |
ncan->mode=can->mode; |
} else { |
ncan->zmin=can->zmin; ncan->zmax=can->zmax; |
new = search_canvas(); ncan = canvas[new]; |
ncan->nzstep=can->nzstep; |
} |
ncan->wname=can->wname; |
ncan->mode = can->mode; |
ncan->vx=can->vx; ncan->vy=can->vy; |
ncan->zmin = can->zmin; ncan->zmax = can->zmax; |
ncan->formula=can->formula; |
ncan->nzstep = can->nzstep; |
ncan->color=can->color; |
ncan->wname = can->wname; |
w=XC(epos)-XC(spos); |
ncan->vx = can->vx; ncan->vy = can->vy; |
h=YC(epos)-YC(spos); |
ncan->formula = can->formula; |
m=MAX(can->width,can->height); |
w = XC(epos)-XC(spos); |
if( w>h ){ |
h = YC(epos)-YC(spos); |
ncan->width=m; |
m = MAX(can->width,can->height); |
ncan->height=m * h/w; |
if ( can->precise ) { |
} else { |
ncan->width = w; ncan->height = h; |
ncan->width=m * w/h; |
} else if ( w > h ) { |
ncan->height=m; |
ncan->width = m; ncan->height = m * h/w; |
} |
} else { |
if( can->wide ){ |
ncan->width = m * w/h; ncan->height = m; |
STOQ(10,ten); STOQ(2,two); |
} |
subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx); |
if ( can->wide ) { |
addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid); |
STOQ(10,ten); STOQ(2,two); |
divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax); |
subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx); |
dy=(can->ymax-can->ymin)*10; |
subq(can->qymax,can->qymin,&t); mulq(t,ten,&dy); |
ymid=(can->ymax+can->ymin)/2; |
addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid); |
ymin=ymid-dy/2; ymax=ymid+dy/2; |
addq(can->qymax,can->qymin,&t); divq(t,two,&ymid); |
} else { |
divq(dx,two,&dx2); divq(dy,two,&dy2); |
subq(can->qxmax,can->qxmin,&dx); |
subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax); |
xmin=can->qxmin; |
subq(ymid,dy2,&ymin); addq(ymid,dy2,&ymax); |
xmax=can->qxmax; |
} else { |
dy=can->ymax-can->ymin; |
subq(can->qxmax,can->qxmin,&dx); subq(can->qymax,can->qymin,&dy); |
ymin=can->ymin; |
xmin = can->qxmin; xmax = can->qxmax; |
ymax=can->ymax; |
ymin = can->qymin; ymax = can->qymax; |
} |
} |
STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw); |
STOQ(XC(spos),sx); STOQ(YC(spos),sy); STOQ(XC(epos),ex); STOQ(YC(epos),ey); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
STOQ(can->width,cw); STOQ(can->height,ch); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
ncan->xmin=ToReal(ncan->qxmin); ncan->xmax=ToReal(ncan->qxmax); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
ncan->ymin=ymax-YC(epos)*dy/can->height; |
mulq(ey,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymin); |
ncan->ymax=ymax-YC(spos)*dy/can->height; |
mulq(sy,dy,&t); divq(t,ch,&s); subq(ymax,s,&ncan->qymax); |
ncan->prec = can->prec; |
ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax); |
create_canvas(ncan); |
ncan->ymin = ToReal(ncan->qymin); ncan->ymax = ToReal(ncan->qymax); |
|
if ( can->precise && !can->wide ) { |
switch (ncan->mode){ |
current_can = can; |
case 0://IFPLOT |
alloc_pixmap(ncan); |
case 1://CONPLOT |
qifplotmain(ncan); |
ifplotmain(ncan); |
copy_subimage(ncan,can,spos); |
break; |
copy_to_canvas(can); |
case 2://PLOT |
} else { |
plotcalc(ncan); |
create_canvas(ncan); |
plot_print(display,ncan); |
if ( can->precise ) |
break; |
qifplotmain(ncan); |
case 4://POLARPLOT |
else |
polarcalc(ncan); |
ifplotmain(ncan); |
plot_print(display,ncan); |
copy_to_canvas(ncan); |
break; |
} |
case 30://MEMORY_PLOT |
} |
break; |
|
case 31://ARRAYPLOT |
|
break; |
|
case 33://DRAWCIRCLE |
|
break; |
|
case 34://DRAW_OBJ |
|
break; |
|
case 35://DRAW_STRING |
|
break; |
|
case 36://OBJ_CP |
|
break; |
|
case 6://IFPLOTD |
|
case 7://IFPLOTQ |
|
case 8://IFPLOTB |
|
case 9://INEQND |
|
case 10://INEQNQ |
|
case 11://INEQNB |
|
case 21://CONPLOTD |
|
case 22://CONPLOTQ |
|
case 23://CONPLOTB |
|
case 24://ITVIFPLOT |
|
//ifplotNG |
|
ifplotmainNG(ncan); |
|
break; |
|
case 12://INEQNDAND |
|
case 13://INEQNQAND |
|
case 14://INEQNBAND |
|
case 15://INEQNDOR |
|
case 16://INEQNQOR |
|
case 17://INEQNBOR |
|
case 18://INEQNDXOR |
|
case 19://INEQNQXOR |
|
case 20://INEQNBXOR |
|
case 25://PLOTOVERD |
|
case 26://PLOTOVERQ |
|
case 27://PLOTOVERB |
|
//ifplotOP |
|
ifplotmainNG(ncan); |
|
break; |
|
case 38://POLARPLOTD |
|
//polarplotNG |
|
polarcalcNG(ncan); |
|
polar_print(display,ncan); |
|
break; |
|
} |
|
copy_to_canvas(ncan); |
|
} |
} |
} |
|
|
plot_resize(can,spos,epos) |
void qifplotmain(struct canvas *can) |
struct canvas *can; |
|
POINT spos,epos; |
|
{ |
{ |
struct canvas *ncan; |
int width,height; |
Q dx,dx2,xmin,xmax,xmid; |
char **tabe,*tabeb; |
double dy,dy2,ymin,ymax,ymid; |
int i; |
Q sx,ex,cw,ten,two; |
|
double sy,ey; |
|
Q s,t; |
|
int new; |
|
int w,h,m; |
|
|
|
if ( XC(spos) < XC(epos) && YC(spos) < YC(epos) ) { |
width=can->width; height=can->height; |
new = search_canvas(); ncan = canvas[new]; |
tabe=(char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char)); |
ncan->mode = can->mode; |
bzero((void *)tabe,width*sizeof(char *)+width*height*sizeof(char)); |
ncan->zmin = can->zmin; ncan->zmax = can->zmax; |
for( i=0, tabeb=(char *)(tabe+width); i<width; i++ ) |
ncan->nzstep = can->nzstep; |
tabe[i]=tabeb + height*i; |
ncan->wname = can->wname; |
define_cursor(can->window,runningcur); |
ncan->vx = can->vx; ncan->vy = can->vy; |
set_busy(can); set_selection(); |
ncan->formula = can->formula; |
qcalc(tabe,can); qif_print(display,tabe,can); |
w = XC(epos)-XC(spos); |
reset_selection(); reset_busy(can); |
h = YC(epos)-YC(spos); |
define_cursor(can->window,normalcur); |
m = MAX(can->width,can->height); |
} |
if ( w > h ) { |
|
ncan->width = m; ncan->height = m * h/w; |
|
} else { |
|
ncan->width = m * w/h; ncan->height = m; |
|
} |
|
if ( can->wide ) { |
|
STOQ(10,ten); STOQ(2,two); |
|
subq(can->qxmax,can->qxmin,&t); mulq(t,ten,&dx); |
|
addq(can->qxmax,can->qxmin,&t); divq(t,two,&xmid); |
|
divq(dx,two,&dx2); subq(xmid,dx2,&xmin); addq(xmid,dx2,&xmax); |
|
|
|
dy = (can->ymax-can->ymin)*10; |
//*******************ifplotNG |
ymid = (can->ymax+can->ymin)/2; |
int ifplotNG(NODE arg,int func){ |
ymin = ymid-dy/2; ymax = ymid+dy/2; |
int id,op_code; |
} else { |
unsigned int color; |
subq(can->qxmax,can->qxmin,&dx); |
NODE n; |
xmin = can->qxmin; xmax = can->qxmax; |
struct canvas *can; |
|
P formula; |
|
LIST xrange,yrange,zrange,wsize; |
|
STRING wname; |
|
|
dy = can->ymax-can->ymin; |
can=canvas[id=search_canvas()]; |
ymin = can->ymin; ymax = can->ymax; |
formula=(P)ARG0(arg); |
} |
can->color=QTOS((Q)ARG1(arg)); |
STOQ(XC(spos),sx); STOQ(XC(epos),ex); STOQ(can->width,cw); |
xrange=(LIST)ARG2(arg); |
mulq(sx,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmin); |
yrange=(LIST)ARG3(arg); |
mulq(ex,dx,&t); divq(t,cw,&s); addq(xmin,s,&ncan->qxmax); |
zrange=(LIST)ARG4(arg); |
ncan->xmin = ToReal(ncan->qxmin); ncan->xmax = ToReal(ncan->qxmax); |
wsize=(LIST)ARG5(arg); |
|
wname=(STRING)ARG6(arg); |
|
can->division=0; |
|
// set canvas data |
|
if(xrange){ |
|
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->xmin=ToReal(can->qxmin); can->xmax=ToReal(can->qxmax); |
|
} |
|
if(yrange){ |
|
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->ymin=ToReal(can->qymin); can->ymax=ToReal(can->qymax); |
|
} |
|
if(zrange){ |
|
n=BDY(zrange); can->zmin=ToReal(BDY(n)); |
|
n=NEXT(n); can->zmax=ToReal(BDY(n)); |
|
n=NEXT(n); can->nzstep=QTOS((Q)BDY(n)); |
|
} |
|
if(!wsize){ |
|
can->width=DEFAULTWIDTH; |
|
can->height=DEFAULTHEIGHT; |
|
} else { |
|
can->width=QTOS((Q)BDY(BDY(wsize))); |
|
can->height=QTOS((Q)BDY(NEXT(BDY(wsize)))); |
|
} |
|
if(wname) can->wname=BDY(wname); |
|
else can->wname=""; |
|
can->formula=formula; |
|
set_drawcolor(can->color); |
|
can->mode=func; |
|
create_canvas(can); |
|
ifplotmainNG(can); |
|
copy_to_canvas(can); |
|
return id; |
|
} |
|
|
ncan->ymin = ymax-YC(epos)*dy/can->height; |
int ifplotOP(NODE arg,int func){ |
ncan->ymax = ymax-YC(spos)*dy/can->height; |
//ineqnor[D,Q,B],ineqnand[D,Q,B],ineqnxor[D,Q,b],plotover[D,Q,B] |
|
int index,op_code; |
|
unsigned int orgcolor,color; |
|
P formula; |
|
struct canvas *can; |
|
VL vl,vl0; |
|
NODE n; |
|
|
create_canvas(ncan); |
index=QTOS((Q)ARG0(arg)); |
plotcalc(ncan); |
formula=(P)ARG1(arg); |
plot_print(display,ncan); |
color=QTOS((Q)ARG2(arg)); |
copy_to_canvas(ncan); |
// set canvas data |
} |
can=canvas[index]; |
|
orgcolor=can->color; |
|
can->color=color; |
|
can->formula=formula; |
|
current_can=can; |
|
get_vars_recursive((Obj)formula,&vl); |
|
for(vl0=vl;vl0;vl0=NEXT(vl0)) |
|
if(vl0->v->attr==(pointer)V_IND) |
|
if(vl->v!=can->vx && vl->v!=can->vy)return -1; |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
can->mode=func; |
|
set_drawcolor(color); |
|
ifplotmainNG(can); |
|
set_drawcolor(orgcolor); |
|
copy_to_canvas(can); |
|
can->color=orgcolor; |
|
#if !defined(VISUAL) && !defined(__MINGW32__) |
|
set_drawcolor(can->color); |
|
#endif |
|
return index; |
} |
} |
|
|
ifplotmain(can) |
void ifplotmainNG(struct canvas *can){ |
struct canvas *can; |
int width,height,i,j,ix,iy,**mask; |
{ |
double **tabe; |
int width,height; |
|
double **tabe,*tabeb; |
|
int i; |
|
|
|
width = can->width; height = can->height; |
width=can->width; height=can->height; |
tabe = (double **)ALLOCA(width*sizeof(double *)); |
tabe=(double **)ALLOCA((width+1)*sizeof(double *)); |
for ( i = 0; i < width; i++ ) |
for(i=0;i<width;i++)tabe[i]=(double *)ALLOCA((height+1)*sizeof(double)); |
tabe[i] = (double *)ALLOCA(height*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); |
calc(tabe,can); if_print(display,tabe,can); |
switch(can->mode){ |
reset_selection(); reset_busy(can); |
case 6://IFPLOTD |
define_cursor(can->window,normalcur); |
calc(tabe,can,0); |
|
if_printNG(display,tabe,can,1); |
|
break; |
|
case 7://IFPLOTQ |
|
calcq(tabe,can,0); |
|
if_printNG(display,tabe,can,1); |
|
break; |
|
case 8://IFPLOTB |
|
calcb(tabe,can,0); |
|
if_printNG(display,tabe,can,0); |
|
break; |
|
case 9://INEQND |
|
calc(tabe,can,0); |
|
area_print(display,tabe,can,0); |
|
break; |
|
case 10://INEQNQ |
|
calcq(tabe,can,0); |
|
area_print(display,tabe,can,0); |
|
break; |
|
case 11://INEQNB |
|
calcb(tabe,can,0); |
|
area_print(display,tabe,can,0); |
|
break; |
|
case 12://INEQNFAND |
|
calc(tabe,can,0); |
|
area_print(display,tabe,can,2); |
|
break; |
|
case 13://INEQNQAND |
|
calcq(tabe,can,0); |
|
area_print(display,tabe,can,2); |
|
break; |
|
case 14://INEQNBAND |
|
calcb(tabe,can,0); |
|
area_print(display,tabe,can,2); |
|
break; |
|
case 15://INEQNDOR |
|
calc(tabe,can,0); |
|
area_print(display,tabe,can,3); |
|
break; |
|
case 16://INEQNQOR |
|
calcq(tabe,can,0); |
|
area_print(display,tabe,can,3); |
|
break; |
|
case 17://INEQNBOR |
|
calcb(tabe,can,0); |
|
area_print(display,tabe,can,3); |
|
break; |
|
case 18://INEQNDXOR |
|
calc(tabe,can,0); |
|
area_print(display,tabe,can,4); |
|
break; |
|
case 19://INEQNQXOR |
|
calcq(tabe,can,0); |
|
area_print(display,tabe,can,4); |
|
break; |
|
case 20://INEQNBXOR |
|
calcb(tabe,can,0); |
|
area_print(display,tabe,can,4); |
|
break; |
|
case 21://CONPLOTD |
|
calc(tabe,can,0); |
|
con_print(display,tabe,can); |
|
break; |
|
case 22://CONPLOTQ |
|
calcq(tabe,can,0); |
|
con_print(display,tabe,can); |
|
break; |
|
case 23://CONPLOTB |
|
calcb(tabe,can,0); |
|
con_print(display,tabe,can); |
|
break; |
|
#if defined(INTERVAL) |
|
case 24://ITVIFPLOT: |
|
itvcalc(tabe,can,1); |
|
if_printNG(display,tabe,can,1); |
|
break; |
|
#endif |
|
case 25://PLOTOVERD |
|
calc(tabe,can,0); |
|
over_print(display,tabe,can,0); |
|
break; |
|
case 26://PLOTOVERQ: |
|
calcq(tabe,can,0); |
|
over_print(display,tabe,can,0); |
|
break; |
|
case 27://PLOTOVERB: |
|
calcb(tabe,can,0); |
|
over_print(display,tabe,can,0); |
|
break; |
|
} |
|
set_drawcolor(can->color); |
|
reset_selection(); reset_busy(can); |
|
define_cursor(can->window,normalcur); |
} |
} |
|
|
qifplotmain(can) |
#if !defined(VISUAL) && !defined(__MINGW32__) |
struct canvas *can; |
int objcp(NODE arg){ |
{ |
int idsrc, idtrg, op_code; |
int width,height; |
struct canvas *cansrc, *cantrg; |
char **tabe,*tabeb; |
|
int i; |
|
|
|
width = can->width; height = can->height; |
idsrc=QTOS((Q)ARG0(arg)); |
tabe = (char **)ALLOCA(width*sizeof(char *)+width*height*sizeof(char)); |
idtrg=QTOS((Q)ARG1(arg)); |
bzero(tabe,width*sizeof(char *)+width*height*sizeof(char)); |
op_code=QTOS((Q)ARG2(arg)); |
for ( i = 0, tabeb = (char *)(tabe+width); i < width; i++ ) |
cansrc=canvas[idsrc]; |
tabe[i] = tabeb + height*i; |
cantrg=canvas[idtrg]; |
define_cursor(can->window,runningcur); |
obj_op(cansrc, cantrg, op_code); |
set_busy(can); set_selection(); |
return idsrc; |
qcalc(tabe,can); qif_print(display,tabe,can); |
|
reset_selection(); reset_busy(can); |
|
define_cursor(can->window,normalcur); |
|
} |
} |
|
|
|
void obj_op(struct canvas *cansrc, struct canvas *cantrg, int op){ |
|
XImage *imgsrc, *imgtrg; |
|
int width, height, i, j; |
|
unsigned long src, trg, black, white; |
|
|
|
width=cansrc->width; height=cansrc->height; |
|
imgsrc=XGetImage(display, cansrc->pix, 0, 0, width, height, -1, ZPixmap); |
|
imgtrg=XGetImage(display, cantrg->pix, 0, 0, width, height, -1, ZPixmap); |
|
black=GetColor(display, "black"); |
|
white=GetColor(display, "white"); |
|
flush(); |
|
define_cursor(cantrg->window,runningcur); |
|
set_busy(cantrg); set_selection(); |
|
cantrg->precise=cansrc->precise; |
|
cantrg->noaxis=cansrc->noaxis; |
|
cantrg->noaxisb=cansrc->noaxisb; |
|
cantrg->vx=cansrc->vx; |
|
cantrg->vy=cansrc->vy; |
|
cantrg->formula=cansrc->formula; |
|
cantrg->width=cansrc->width; |
|
cantrg->height=cansrc->height; |
|
cantrg->xmin=cansrc->xmin; |
|
cantrg->xmax=cansrc->xmax; |
|
cantrg->ymin=cansrc->ymin; |
|
cantrg->ymax=cansrc->ymax; |
|
cantrg->zmin=cansrc->zmin; |
|
cantrg->zmax=cansrc->zmax; |
|
cantrg->nzstep=cansrc->nzstep; |
|
cantrg->qxmin=cansrc->qxmin; |
|
cantrg->qxmax=cansrc->qxmax; |
|
cantrg->qymin=cansrc->qymin; |
|
cantrg->qymax=cansrc->qymax; |
|
cantrg->pa=cansrc->pa; |
|
switch(op){ |
|
case 1:/* and case */ |
|
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
|
src=XGetPixel(imgsrc,i,j); |
|
trg=XGetPixel(imgtrg,i,j); |
|
if( (src == black) || (trg == black) ) |
|
XPutPixel(imgtrg,i,j,black); |
|
else if( (src == white) || (trg == white) ) |
|
XPutPixel(imgtrg,i,j,white); |
|
else XPutPixel(imgtrg,i,j,(src & trg)); |
|
} |
|
break; |
|
case 3:/* copy case */ |
|
imgtrg->data=imgsrc->data; |
|
break; |
|
case 6:/* xor case */ |
|
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
|
src=XGetPixel(imgsrc,i,j); |
|
trg=XGetPixel(imgtrg,i,j); |
|
if( (src == black) || (trg == black) ) |
|
XPutPixel(imgtrg,i,j,black); |
|
else if( (src == white) && (trg == white) ) |
|
XPutPixel(imgtrg,i,j,trg|src); |
|
else if( (src != white) && (trg != white) ) |
|
XPutPixel(imgtrg,i,j,white); |
|
else if( src == white ) |
|
XPutPixel(imgtrg,i,j,src); |
|
} |
|
break; |
|
case 7:/* or case */ |
|
for(i=0;i<width;i++)for(j=0;j<height;j++){ |
|
src=XGetPixel(imgsrc,i,j); |
|
trg=XGetPixel(imgtrg,i,j); |
|
if( (src == black) || (trg == black) ) |
|
XPutPixel(imgtrg,i,j,black); |
|
else if(src == white) |
|
XPutPixel(imgtrg,i,j,trg); |
|
else if(trg == white) |
|
XPutPixel(imgtrg,i,j,src); |
|
} |
|
break; |
|
default: |
|
break; |
|
} |
|
XPutImage(display, cantrg->pix, drawGC, imgtrg, 0, 0, 0, 0, width, height); |
|
reset_selection(); reset_busy(cantrg); |
|
define_cursor(cantrg->window,normalcur); |
|
copy_to_canvas(cantrg); |
|
count_and_flush(); |
|
flush(); |
|
} |
|
#endif |
|
|
|
int polarplotNG(NODE arg){ |
|
int i,id,width,height; |
|
NODE n; |
|
struct canvas *can; |
|
LIST range,geom; |
|
STRING wname; |
|
V v; |
|
|
|
id=search_canvas(); |
|
can=canvas[id]; |
|
can->mode=modeNO(POLARPLOTD); |
|
can->formula=(P)ARG0(arg); |
|
can->color=QTOS((Q)ARG1(arg)); |
|
range=(LIST)ARG2(arg); |
|
geom=(LIST)ARG3(arg); |
|
wname=(STRING)ARG4(arg); |
|
|
|
if(range){ |
|
n=NEXT(BDY(range)); |
|
can->zmin=ToReal(BDY(n)); |
|
n=NEXT(n);can->zmax=ToReal(BDY(n)); |
|
n=NEXT(n); |
|
can->vx=VR((P)BDY(BDY(range))); |
|
can->nzstep=n?QTOS((Q)BDY(n)):DEFAULTPOLARSTEP; |
|
} |
|
if(geom){ |
|
can->width=width=QTOS((Q)BDY(BDY(geom))); |
|
can->height=height=QTOS((Q)BDY(NEXT(BDY(geom)))); |
|
} |
|
if(wname)can->wname=BDY(wname); |
|
else can->wname=""; |
|
polarcalcNG(can); |
|
create_canvas(can); |
|
set_drawcolor(can->color); |
|
polar_print(display,can); |
|
reset_selection(); |
|
reset_busy(can); |
|
define_cursor(can->window,normalcur); |
|
return id; |
|
} |
|
|
|
void MSGdraw(char *str){ |
|
int id,x,y; |
|
struct canvas *can; |
|
|
|
id=search_canvas(); |
|
can=canvas[id]; |
|
can->mode=modeNO(INTERACTIVE); |
|
can->width=300; |
|
can->height=300; |
|
can->wname="MSG"; |
|
x=100; |
|
y=100; |
|
create_canvas(can); |
|
draw_character_string(display,can,x,y,str,0xff0000); |
|
} |
|
|