version 1.23, 2004/03/01 01:23:37 |
version 1.30, 2013/11/05 02:55:03 |
|
|
* 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/ox_plot_xevent.c,v 1.22 2002/08/02 08:59:47 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/plot/ox_plot_xevent.c,v 1.29 2007/01/30 03:25:52 saito Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#include <X11/Xaw/MenuButton.h> |
#include <X11/Xaw/MenuButton.h> |
#include <X11/Xaw/Paned.h> |
#include <X11/Xaw/Paned.h> |
|
|
|
static void Quit(); |
|
static void print_canvas(Widget w, struct canvas *can, XtPointer calldata); |
|
static void output_to_printer(Widget w, struct canvas *can, XtPointer calldata); |
|
static void print_canvas_to_file(Widget w, struct canvas *can, XtPointer calldata); |
|
static void printing_method(Widget w, struct canvas *can, XtPointer calldata); |
|
void clear_pixmap(struct canvas *); |
|
void create_gc(); |
|
void create_font(); |
|
void create_cursors(); |
|
void copy_to_canvas(struct canvas *can); |
|
void draw_level(struct canvas *can,int index,GC gc); |
|
void draw_frame(Window window,POINT spos,POINT opos,POINT epos); |
|
void draw_frame0( Window window,POINT spos,POINT epos); |
|
void draw_coord(struct canvas *can,POINT pos); |
|
void draw_wideframe(struct canvas *can); |
|
void redraw_canvas(struct canvas *can); |
|
void reset_busy(struct canvas *can); |
|
int search_canvas(); |
|
int search_active_canvas(); |
|
void PSFromImage(FILE *fp,XImage *image,struct canvas *can); |
|
|
|
|
|
|
static Atom wm_delete_window; |
static Atom wm_delete_window; |
|
|
|
void SetWM_Proto(Widget w) |
|
{ |
|
XtOverrideTranslations(w, |
|
XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()")); |
|
XSetWMProtocols(display,XtWindow(w),&wm_delete_window,1); |
|
} |
|
|
|
#if 0 |
static void quit(Widget w, XEvent *ev, String *params,Cardinal *nparams) |
static void quit(Widget w, XEvent *ev, String *params,Cardinal *nparams) |
{ |
{ |
XBell(display,0); |
XBell(display,0); |
} |
} |
|
#endif |
|
|
/* XXX : these lines are in plotg.c, but ld says they are not defined */ |
/* XXX : these lines are in plotg.c, but ld says they are not defined */ |
#if __DARWIN__ |
#if __DARWIN__ |
Line 113 static struct PlotResources { |
|
Line 145 static struct PlotResources { |
|
#define reverse PlotResources.Reverse |
#define reverse PlotResources.Reverse |
#define upsidedown PlotResources.UpsideDown |
#define upsidedown PlotResources.UpsideDown |
|
|
|
Pixel BackPixel; |
|
|
Cursor create_cursor(); |
Cursor create_cursor(); |
|
|
#define blackPixel BlackPixel(display,scrn) |
#define blackPixel BlackPixel(display,scrn) |
Line 120 Cursor create_cursor(); |
|
Line 154 Cursor create_cursor(); |
|
|
|
#define LABELWIDTH 150 |
#define LABELWIDTH 150 |
|
|
process_xevent() { |
void process_xevent() { |
XEvent ev; |
XEvent ev; |
|
|
while ( XPending(display) ) { |
while ( XPending(display) ) { |
Line 133 process_xevent() { |
|
Line 167 process_xevent() { |
|
|
|
static POINT spos,cpos; |
static POINT spos,cpos; |
|
|
void press(w,can,ev) |
void press(Widget w,struct canvas *can,XButtonEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XButtonEvent *ev; |
|
{ |
{ |
POINT p; |
POINT p; |
|
|
Line 144 XButtonEvent *ev; |
|
Line 175 XButtonEvent *ev; |
|
case Button1: |
case Button1: |
XC(spos) = ev->x; YC(spos) = ev->y; cpos = spos; break; |
XC(spos) = ev->x; YC(spos) = ev->y; cpos = spos; break; |
case Button3: |
case Button3: |
XC(p) = ev->x; YC(p) = ev->y; draw_coord(can,&p); break; |
XC(p) = ev->x; YC(p) = ev->y; draw_coord(can,p); break; |
default: |
default: |
break; |
break; |
} |
} |
} |
} |
|
|
void motion(w,can,ev) |
void motion(Widget w,struct canvas *can,XMotionEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XMotionEvent *ev; |
|
{ |
{ |
|
|
POINT o,p; |
POINT o,p; |
Line 167 XMotionEvent *ev; |
|
Line 195 XMotionEvent *ev; |
|
} |
} |
} |
} |
|
|
void release(w,can,ev) |
void release(Widget w,struct canvas *can,XButtonEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XButtonEvent *ev; |
|
{ |
{ |
POINT e; |
POINT e; |
|
|
Line 192 XButtonEvent *ev; |
|
Line 217 XButtonEvent *ev; |
|
} |
} |
} |
} |
|
|
void structure(w,can,ev) |
void structure(Widget w,struct canvas *can,XEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XEvent *ev; |
|
{ |
{ |
switch ( ev->xany.type ) { |
switch ( ev->xany.type ) { |
case Expose: |
case Expose: |
|
|
|
|
static int lindex; |
static int lindex; |
|
|
void lpress(w,can,ev) |
void lpress(Widget w,struct canvas *can,XButtonEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XButtonEvent *ev; |
|
{ |
{ |
lindex = (can->height-ev->y)/(can->height/can->nzstep); |
lindex = (can->height-ev->y)/(can->height/can->nzstep); |
draw_level(can,lindex,hlGC); |
draw_level(can,lindex,hlGC); |
} |
} |
|
|
void jumpproc(w,can,percent) |
void jumpproc(Widget w,struct canvas *can,float *percent) |
Widget w; |
|
struct canvas *can; |
|
float *percent; |
|
{ |
{ |
int index; |
int index; |
|
|
|
|
draw_level(can,lindex,hlGC); |
draw_level(can,lindex,hlGC); |
} |
} |
|
|
void jumpproc_m(w,can,percent) |
void jumpproc_m(Widget w,struct canvas *can,float *percent) |
Widget w; |
|
struct canvas *can; |
|
float *percent; |
|
{ |
{ |
int index; |
int index; |
|
|
|
|
} |
} |
} |
} |
|
|
void lrelease(w,can,ev) |
void lrelease(Widget w,struct canvas *can,XButtonEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XButtonEvent *ev; |
|
{ |
{ |
draw_level(can,lindex,drawGC); lindex = -1; |
draw_level(can,lindex,drawGC); lindex = -1; |
} |
} |
|
|
void lrelease_m(w,can,ev) |
void lrelease_m(Widget w,struct canvas *can,XButtonEvent *ev) |
Widget w; |
|
struct canvas *can; |
|
XButtonEvent *ev; |
|
{ |
{ |
lindex = -1; |
lindex = -1; |
} |
} |
|
|
draw_level(can,index,gc) |
void draw_level(struct canvas *can,int index,GC gc) |
struct canvas *can; |
|
int index; |
|
GC gc; |
|
{ |
{ |
Pixmap pix; |
Pixmap pix; |
struct pa *pa; |
struct pa *pa; |
|
|
copy_to_canvas(can); |
copy_to_canvas(can); |
} |
} |
|
|
draw_frame(window,spos,opos,epos) |
void draw_frame(Window window,POINT spos,POINT opos,POINT epos) |
Window window; |
|
POINT spos,opos,epos; |
|
{ |
{ |
if ( XC(opos) != XC(epos) || YC(opos) != YC(epos) ) |
if ( XC(opos) != XC(epos) || YC(opos) != YC(epos) ) |
draw_frame0(window,spos,opos); |
draw_frame0(window,spos,opos); |
draw_frame0(window,spos,epos); |
draw_frame0(window,spos,epos); |
} |
} |
|
|
draw_frame0(window,spos,epos) |
void draw_frame0(Window window,POINT spos,POINT epos) |
Window window; |
|
POINT spos,epos; |
|
{ |
{ |
int ulx,uly,w,h; |
int ulx,uly,w,h; |
|
|
Line 312 POINT spos,epos; |
|
Line 312 POINT spos,epos; |
|
XFlush(display); |
XFlush(display); |
} |
} |
|
|
draw_coord(can,pos) |
void draw_coord(struct canvas *can,POINT pos) |
struct canvas *can; |
|
POINT pos; |
|
{ |
{ |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
Arg arg[2]; |
Arg arg[2]; |
|
|
XtSetValues(can->ycoord,arg,2); |
XtSetValues(can->ycoord,arg,2); |
} |
} |
|
|
redraw_canvas(can) |
void redraw_canvas(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
if ( can->wide ) |
if ( can->wide ) |
draw_wideframe(can); |
draw_wideframe(can); |
Line 347 struct canvas *can; |
|
Line 344 struct canvas *can; |
|
copy_to_canvas(can); |
copy_to_canvas(can); |
} |
} |
|
|
search_canvas() |
int search_canvas() |
{ |
{ |
int i; |
int i; |
|
|
|
|
canvas[i] = (struct canvas *)MALLOC(sizeof(struct canvas)); |
canvas[i] = (struct canvas *)MALLOC(sizeof(struct canvas)); |
canvas[i]->index = i; return i; |
canvas[i]->index = i; return i; |
} |
} |
|
return -1; |
} |
} |
|
|
search_active_canvas() |
int search_active_canvas() |
{ |
{ |
int i; |
int i; |
|
|
Line 368 search_active_canvas() |
|
Line 366 search_active_canvas() |
|
return -1; |
return -1; |
} |
} |
|
|
void popup_canvas(index) |
void popup_canvas(int index) |
{ |
{ |
clear_pixmap(canvas[index]); |
clear_pixmap(canvas[index]); |
XtPopup(canvas[index]->shell,XtGrabNone); |
XtPopup(canvas[index]->shell,XtGrabNone); |
copy_to_canvas(canvas[index]); |
copy_to_canvas(canvas[index]); |
} |
} |
|
|
void destroy_canvas(w,can,calldata) |
void destroy_canvas(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
XtPopdown(can->shell); |
XtPopdown(can->shell); |
/* XtDestroyWidget(can->shell); */ |
/* XtDestroyWidget(can->shell); */ |
Line 392 XtPointer calldata; |
|
Line 387 XtPointer calldata; |
|
canvas[can->index] = 0; |
canvas[can->index] = 0; |
} |
} |
|
|
void precise_canvas(w,can,calldata) |
void precise_canvas(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
if ( can->precise ) |
if ( can->precise ) |
can->precise = 0; |
can->precise = 0; |
Line 403 XtPointer calldata; |
|
Line 395 XtPointer calldata; |
|
can->precise = 1; |
can->precise = 1; |
} |
} |
|
|
void wide_canvas(w,can,calldata) |
void wide_canvas(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
if ( can->wide ) { |
if ( can->wide ) { |
can->wide = 0; copy_to_canvas(can); |
can->wide = 0; copy_to_canvas(can); |
Line 415 XtPointer calldata; |
|
Line 404 XtPointer calldata; |
|
} |
} |
} |
} |
|
|
void noaxis_canvas(w,can,calldata) |
void noaxis_canvas(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
if ( can->noaxis ) |
if ( can->noaxis ) |
can->noaxis = 0; |
can->noaxis = 0; |
Line 430 XtPointer calldata; |
|
Line 416 XtPointer calldata; |
|
copy_to_canvas(can); |
copy_to_canvas(can); |
} |
} |
|
|
toggle_button(w,flag) |
void toggle_button(Widget w,int flag) |
Widget w; |
|
int flag; |
|
{ |
{ |
Arg arg[2]; |
Arg arg[2]; |
|
|
|
|
XtSetValues(w,arg,2); XFlush(display); |
XtSetValues(w,arg,2); XFlush(display); |
} |
} |
|
|
draw_wideframe(can) |
void draw_wideframe(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
struct canvas fakecan; |
struct canvas fakecan; |
double xmin,xmax,ymin,ymax,xmid,ymid,dx,dy; |
double xmid,ymid,dx,dy; |
POINT s,e; |
POINT s,e; |
|
|
fakecan = *can; |
fakecan = *can; |
Line 468 struct canvas *can; |
|
Line 451 struct canvas *can; |
|
draw_frame0(can->window,s,e); |
draw_frame0(can->window,s,e); |
} |
} |
|
|
create_popup(parent,name,str,shell,dialog) |
void create_popup(Widget parent,char *name,char *str,Widget *shell,Widget *dialog) |
Widget parent; |
|
char *name,*str; |
|
Widget *shell,*dialog; |
|
{ |
{ |
Arg arg[3]; |
Arg arg[3]; |
Position x,y; |
Position x,y; |
Line 483 Widget *shell,*dialog; |
|
Line 463 Widget *shell,*dialog; |
|
*dialog = XtCreateManagedWidget("dialog",dialogWidgetClass,*shell,arg,1); |
*dialog = XtCreateManagedWidget("dialog",dialogWidgetClass,*shell,arg,1); |
} |
} |
|
|
warning(can,s) |
void warning(struct canvas *can,char *s) |
struct canvas *can; |
|
char *s; |
|
{ |
{ |
void popdown_warning(); |
void popdown_warning(); |
Widget warnshell,warndialog; |
Widget warnshell,warndialog; |
Position x,y; |
|
Arg arg[3]; |
|
|
|
if ( !can->shell ) |
if ( !can->shell ) |
return; |
return; |
create_popup(can->shell,"warning",s,&warnshell,&warndialog); |
create_popup(can->shell,"warning",s,&warnshell,&warndialog); |
XawDialogAddButton(warndialog,"dismiss",popdown_warning,warnshell); |
XawDialogAddButton(warndialog,"dismiss",popdown_warning,warnshell); |
XtPopup(warnshell,XtGrabNone); |
XtPopup(warnshell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(warnshell),&wm_delete_window,1); |
SetWM_Proto(warnshell); |
} |
} |
|
|
void popdown_warning(w,client,call) |
void popdown_warning(Widget w,XtPointer client,XtPointer call) |
Widget w; |
|
XtPointer client,call; |
|
{ |
{ |
XtPopdown(client); XtDestroyWidget(client); |
XtPopdown(client); XtDestroyWidget(client); |
} |
} |
|
|
void show_formula(w,can,calldata) |
void show_formula(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
void popdown_formula(); |
void popdown_formula(); |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
Line 520 XtPointer calldata; |
|
Line 491 XtPointer calldata; |
|
create_popup(can->shell,"formula",buf,&fshell,&fdialog); |
create_popup(can->shell,"formula",buf,&fshell,&fdialog); |
XawDialogAddButton(fdialog,"dismiss",popdown_formula,w); |
XawDialogAddButton(fdialog,"dismiss",popdown_formula,w); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(fshell),&wm_delete_window,1); |
SetWM_Proto(fshell); |
} |
} |
|
|
void popdown_formula(w,fbutton,call) |
void popdown_formula(Widget w,Widget fbutton,XtPointer call) |
Widget w,fbutton; |
|
XtPointer call; |
|
{ |
{ |
Widget shell = XtParent(XtParent(w)); |
Widget shell = XtParent(XtParent(w)); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtPopdown(shell); XtDestroyWidget(shell); |
|
|
|
|
#define NormalSelection ButtonPressMask|ButtonReleaseMask|Button1MotionMask|Button3MotionMask|StructureNotifyMask| ExposureMask |
#define NormalSelection ButtonPressMask|ButtonReleaseMask|Button1MotionMask|Button3MotionMask|StructureNotifyMask| ExposureMask |
|
|
create_canvas(can) |
void create_canvas(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
XEvent event; |
|
Widget box,frame,commands, |
Widget box,frame,commands, |
coords,quit,print,wide,precise,canvas,formula; |
coords,quit,print,wide,precise,canvas,formula; |
Window window; |
Window window; |
Pixmap pix; |
Pixmap pix; |
int i,width,height; |
int width,height; |
Arg arg[6]; |
Arg arg[6]; |
char buf[BUFSIZ]; |
char buf[BUFSIZ]; |
static void print_canvas(); |
|
|
|
|
XImage *image; |
|
|
width = can->width; height = can->height; |
width = can->width; height = can->height; |
|
|
sprintf(buf,"%s : %d", can->wname?can->wname:"Plot",can->index); |
sprintf(buf,"%s : %d", can->wname?can->wname:"Plot",can->index); |
Line 566 struct canvas *can; |
|
Line 534 struct canvas *can; |
|
commands = XtCreateManagedWidget("commands",boxWidgetClass,frame,arg,2); |
commands = XtCreateManagedWidget("commands",boxWidgetClass,frame,arg,2); |
|
|
quit = XtCreateManagedWidget("quit",commandWidgetClass,commands,NULL,0); |
quit = XtCreateManagedWidget("quit",commandWidgetClass,commands,NULL,0); |
XtAddCallback(quit,XtNcallback,destroy_canvas,can); |
XtAddCallback(quit,XtNcallback,(XtCallbackProc)destroy_canvas,can); |
print = XtCreateManagedWidget("print",commandWidgetClass,commands,NULL,0); |
print = XtCreateManagedWidget("print",commandWidgetClass,commands,NULL,0); |
XtAddCallback(print,XtNcallback,print_canvas,can); |
XtAddCallback(print,XtNcallback,(XtCallbackProc)print_canvas,can); |
can->wideb = wide = |
can->wideb = wide = |
XtCreateManagedWidget("wide",toggleWidgetClass,commands,NULL,0); |
XtCreateManagedWidget("wide",toggleWidgetClass,commands,NULL,0); |
XtAddCallback(wide,XtNcallback,wide_canvas,can); |
XtAddCallback(wide,XtNcallback,(XtCallbackProc)wide_canvas,can); |
can->preciseb = precise = |
can->preciseb = precise = |
XtCreateManagedWidget("precise",toggleWidgetClass,commands,NULL,0); |
XtCreateManagedWidget("precise",toggleWidgetClass,commands,NULL,0); |
XtAddCallback(precise,XtNcallback,precise_canvas,can); |
XtAddCallback(precise,XtNcallback,(XtCallbackProc)precise_canvas,can); |
formula = |
formula = |
XtCreateManagedWidget("formula",commandWidgetClass,commands,NULL,0); |
XtCreateManagedWidget("formula",commandWidgetClass,commands,NULL,0); |
XtAddCallback(formula,XtNcallback,show_formula,can); |
XtAddCallback(formula,XtNcallback,(XtCallbackProc)show_formula,can); |
can->noaxisb = |
can->noaxisb = |
XtCreateManagedWidget("noaxis",toggleWidgetClass,commands,NULL,0); |
XtCreateManagedWidget("noaxis",toggleWidgetClass,commands,NULL,0); |
XtAddCallback(can->noaxisb,XtNcallback,noaxis_canvas,can); |
XtAddCallback(can->noaxisb,XtNcallback,(XtCallbackProc)noaxis_canvas,can); |
|
|
XtSetArg(arg[0],XtNfromVert,commands); |
XtSetArg(arg[0],XtNfromVert,commands); |
XtSetArg(arg[1],XtNwidth,width); |
XtSetArg(arg[1],XtNwidth,width); |
Line 614 struct canvas *can; |
|
Line 582 struct canvas *can; |
|
XtSetArg(arg[0],XtNwidth,LABELWIDTH); |
XtSetArg(arg[0],XtNwidth,LABELWIDTH); |
can->ycoord = XtCreateManagedWidget("ycoord",labelWidgetClass,coords,arg,1); |
can->ycoord = XtCreateManagedWidget("ycoord",labelWidgetClass,coords,arg,1); |
|
|
XtAddEventHandler(canvas,ButtonPressMask,False,press,can); |
XtAddEventHandler(canvas,ButtonPressMask,False,(XtEventHandler)press,can); |
XtAddEventHandler(canvas,ButtonReleaseMask,False,release,can); |
XtAddEventHandler(canvas,ButtonReleaseMask,False,(XtEventHandler)release,can); |
XtAddEventHandler(canvas,Button1MotionMask,False,motion,can); |
XtAddEventHandler(canvas,Button1MotionMask,False,(XtEventHandler)motion,can); |
XtAddEventHandler(canvas,Button3MotionMask,False,motion,can); |
XtAddEventHandler(canvas,Button3MotionMask,False,(XtEventHandler)motion,can); |
XtAddEventHandler(canvas,StructureNotifyMask,False,structure,can); |
XtAddEventHandler(canvas,StructureNotifyMask,False,(XtEventHandler)structure,can); |
XtAddEventHandler(canvas,ExposureMask,False,structure,can); |
XtAddEventHandler(canvas,ExposureMask,False,(XtEventHandler)structure,can); |
|
|
if ( can->mode == MODE_CONPLOT ) { |
if ( can->mode == MODE_CONPLOT ) { |
Widget scale; |
|
|
|
XtSetArg(arg[0],XtNwidth,LABELWIDTH); |
XtSetArg(arg[0],XtNwidth,LABELWIDTH); |
can->level = XtCreateManagedWidget("level",labelWidgetClass, |
can->level = XtCreateManagedWidget("level",labelWidgetClass, |
commands,arg,1); |
commands,arg,1); |
Line 631 struct canvas *can; |
|
Line 597 struct canvas *can; |
|
XtSetArg(arg[0],XtNsensitive,True); |
XtSetArg(arg[0],XtNsensitive,True); |
XtSetValues(can->ydone,arg,1); |
XtSetValues(can->ydone,arg,1); |
if ( depth >= 2 ) { |
if ( depth >= 2 ) { |
XtAddCallback(can->ydone,XtNjumpProc,jumpproc,can); |
XtAddCallback(can->ydone,XtNjumpProc,(XtCallbackProc)jumpproc,can); |
XtAddEventHandler(can->ydone,ButtonReleaseMask,False,lrelease,can); |
XtAddEventHandler(can->ydone,ButtonReleaseMask,False,(XtEventHandler)lrelease,can); |
} else { |
} else { |
XtAddCallback(can->ydone,XtNjumpProc,jumpproc_m,can); |
XtAddCallback(can->ydone,XtNjumpProc,(XtCallbackProc)jumpproc_m,can); |
XtAddEventHandler(can->ydone,ButtonReleaseMask,False,lrelease_m,can); |
XtAddEventHandler(can->ydone,ButtonReleaseMask,False,(XtEventHandler)lrelease_m,can); |
} |
} |
} |
} |
if ( can->mode != MODE_IFPLOT || !qpcheck((Obj)can->formula) ) |
if ( can->mode != MODE_IFPLOT || !qpcheck((Obj)can->formula) ) |
XtSetSensitive(precise,False); |
XtSetSensitive(precise,False); |
XtPopup(can->shell,XtGrabNone); |
XtPopup(can->shell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(can->shell),&wm_delete_window,1); |
SetWM_Proto(can->shell); |
window = can->window = XtWindow(canvas); |
window = can->window = XtWindow(canvas); |
pix = can->pix = XCreatePixmap(display,window,width,height,depth); |
pix = can->pix = XCreatePixmap(display,window,width,height,depth); |
XFillRectangle(display,pix,clearGC,0,0,width,height); |
XFillRectangle(display,pix,clearGC,0,0,width,height); |
|
image = XGetImage(display, can->pix, 0, 0, can->width, can->height, |
|
-1, ZPixmap); |
|
BackPixel = XGetPixel(image,0,0); |
XDefineCursor(display,window,normalcur); |
XDefineCursor(display,window,normalcur); |
XFlush(display); |
XFlush(display); |
current_can = can; |
current_can = can; |
} |
} |
|
|
alloc_pixmap(can) |
void alloc_pixmap(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
can->pix = XCreatePixmap(display,can->window, |
can->pix = XCreatePixmap(display,can->window, |
can->width,can->height,depth); |
can->width,can->height,depth); |
Line 686 static XtResource resources[] = { |
|
Line 654 static XtResource resources[] = { |
|
offset(DashPixel),XtRPixel,(XtPointer)&dashPixel}, |
offset(DashPixel),XtRPixel,(XtPointer)&dashPixel}, |
}; |
}; |
|
|
int init_plot_display(argc,argv) |
static XtActionsRec actions_table[] = { |
int argc; |
{"quit",Quit}, |
char **argv; |
}; |
|
|
|
static void Quit(Widget w, XEvent *ev, String *params,Cardinal *nparams) |
{ |
{ |
|
XBell(XtDisplay(w),0); |
|
} |
|
|
|
int init_plot_display(int argc,char **argv) |
|
{ |
int ac; |
int ac; |
char **av; |
char **av; |
unsigned int tmp; |
unsigned int tmp; |
|
|
dname = *av; |
dname = *av; |
XtToolkitInitialize(); |
XtToolkitInitialize(); |
app_con = XtCreateApplicationContext(); |
app_con = XtCreateApplicationContext(); |
|
XtAppAddActions(app_con,actions_table, XtNumber(actions_table)); |
display = XtOpenDisplay(app_con,dname,"plot","Plot", |
display = XtOpenDisplay(app_con,dname,"plot","Plot", |
options,XtNumber(options),&argc,argv); |
options,XtNumber(options),&argc,argv); |
if ( !display ) { |
if ( !display ) { |
|
|
|
|
static char *scalefont = "*-8-80-*"; |
static char *scalefont = "*-8-80-*"; |
|
|
create_font() { |
void create_font() { |
Font sfid; |
Font sfid; |
|
|
sfid = XLoadFont(display,scalefont); |
sfid = XLoadFont(display,scalefont); |
|
|
XSetFont(display,scaleGC,sfid); |
XSetFont(display,scaleGC,sfid); |
} |
} |
|
|
create_gc() { |
void create_gc() { |
static XColor color = {0,0x0,0x0,0x0,DoRed|DoGreen|DoBlue,0}; |
static XColor color = {0,0x0,0x0,0x0,DoRed|DoGreen|DoBlue,0}; |
int i,b,step; |
|
|
|
drawGC = XCreateGC(display,rootwin,0,NULL); |
drawGC = XCreateGC(display,rootwin,0,NULL); |
dashGC = XCreateGC(display,rootwin,0,NULL); |
dashGC = XCreateGC(display,rootwin,0,NULL); |
|
|
XSetForeground(display,colorGC,color.pixel); |
XSetForeground(display,colorGC,color.pixel); |
} |
} |
|
|
set_drawcolor(c) |
void set_drawcolor(unsigned int c) |
unsigned int c; |
|
{ |
{ |
XColor color = {0,0x0,0x0,0x0,DoRed|DoGreen|DoBlue,0}; |
XColor color = {0,0x0,0x0,0x0,DoRed|DoGreen|DoBlue,0}; |
|
|
|
|
XSetForeground(display,cdrawGC,color.pixel); |
XSetForeground(display,cdrawGC,color.pixel); |
} |
} |
|
|
create_cursors() { |
void create_cursors() { |
static XColor fg = {0, 0x0, 0x0, 0x0,DoRed|DoGreen|DoBlue,0}; |
static XColor fg = {0, 0x0, 0x0, 0x0,DoRed|DoGreen|DoBlue,0}; |
static XColor bg = {0, 0xffff, 0xffff, 0xffff,DoRed|DoGreen|DoBlue,0}; |
static XColor bg = {0, 0xffff, 0xffff, 0xffff,DoRed|DoGreen|DoBlue,0}; |
|
|
Line 805 create_cursors() { |
|
Line 779 create_cursors() { |
|
m_width/2,m_height/2,&fg,&bg); |
m_width/2,m_height/2,&fg,&bg); |
} |
} |
|
|
Cursor create_cursor(image,mask,width,height,xhot,yhot,fg,bg) |
Cursor create_cursor(char *image,char *mask,int width,int height,int xhot,int yhot,XColor *fg,XColor *bg) |
char *image,*mask; |
|
int width,height,xhot,yhot; |
|
XColor *fg,*bg; |
|
{ |
{ |
Pixmap ipix,mpix; |
Pixmap ipix,mpix; |
|
|
|
|
return XCreatePixmapCursor(display,ipix,mpix,fg,bg,xhot,yhot); |
return XCreatePixmapCursor(display,ipix,mpix,fg,bg,xhot,yhot); |
} |
} |
|
|
copy_to_canvas(can) |
void copy_to_canvas(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
if ( display ) { |
if ( display ) { |
XCopyArea(display,can->pix,can->window, |
if ( can->color ) { |
drawGC,0,0,can->width,can->height,0,0); |
set_drawcolor(can->color); |
|
XCopyArea(display,can->pix,can->window, |
|
cdrawGC,0,0,can->width,can->height,0,0); |
|
} else |
|
XCopyArea(display,can->pix,can->window, |
|
drawGC,0,0,can->width,can->height,0,0); |
pline(display,can,can->window); |
pline(display,can,can->window); |
XFlush(display); |
XFlush(display); |
} |
} |
} |
} |
|
|
copy_subimage(subcan,can,pos) |
void copy_subimage(struct canvas *subcan,struct canvas *can,XPoint pos) |
struct canvas *subcan,*can; |
|
XPoint pos; |
|
{ |
{ |
if ( display ) { |
if ( display ) { |
XCopyArea(display,subcan->pix,can->pix, |
XCopyArea(display,subcan->pix,can->pix, |
|
|
#include <signal.h> |
#include <signal.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
|
set_selection() { |
void set_selection() { |
if ( current_can ) { |
if ( current_can ) { |
XSelectInput(display,current_can->window,0); |
XSelectInput(display,current_can->window,0); |
XFlush(display); |
XFlush(display); |
} |
} |
} |
} |
|
|
reset_selection() { |
void reset_selection() { |
if ( current_can ) { |
if ( current_can ) { |
XSelectInput(display,current_can->window,NormalSelection); |
XSelectInput(display,current_can->window,NormalSelection); |
XFlush(display); |
XFlush(display); |
} |
} |
} |
} |
|
|
set_busy(can) |
void set_busy(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
busy = 1; |
busy = 1; |
XtSetSensitive(can->wideb,False); |
XtSetSensitive(can->wideb,False); |
Line 866 struct canvas *can; |
|
Line 838 struct canvas *can; |
|
XFlush(display); |
XFlush(display); |
} |
} |
|
|
reset_busy(can) |
void reset_busy(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
busy = 0; |
busy = 0; |
if ( can->window ) { |
if ( can->window ) { |
Line 879 struct canvas *can; |
|
Line 850 struct canvas *can; |
|
} |
} |
} |
} |
|
|
reset_current_computation() |
void reset_current_computation() |
{ |
{ |
if ( current_can ) { |
if ( current_can ) { |
reset_selection(); reset_busy(current_can); |
reset_selection(); reset_busy(current_can); |
Line 926 static Widget create_printing_method_bar(Widget parent |
|
Line 897 static Widget create_printing_method_bar(Widget parent |
|
*/ |
*/ |
|
|
|
|
static void print_canvas(w,can,calldata) |
static void print_canvas(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget W; |
extern Widget W; |
Widget entry; |
|
int i; |
|
Arg arg[1]; |
|
static void output_to_printer(); |
|
static void print_canvas_to_file(); |
|
static void printing_method(); |
|
|
|
W = w; |
W = w; |
Can = can; |
Can = can; |
create_popup(can->shell,"Print/Output PS file","",&fshell,&fdialog); |
create_popup(can->shell,"Print/Output PS file","",&fshell,&fdialog); |
XawDialogAddButton(fdialog,"print",output_to_printer,w); |
XawDialogAddButton(fdialog,"print",(XtCallbackProc)output_to_printer,w); |
XawDialogAddButton(fdialog,"output PS file",print_canvas_to_file,w); |
XawDialogAddButton(fdialog,"output PS file",(XtCallbackProc)print_canvas_to_file,w); |
XawDialogAddButton(fdialog,"method",printing_method,w); |
XawDialogAddButton(fdialog,"method",(XtCallbackProc)printing_method,w); |
XawDialogAddButton(fdialog,"dismiss",cancel_output_to_file,w); |
XawDialogAddButton(fdialog,"dismiss",(XtCallbackProc)cancel_output_to_file,w); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(fshell),&wm_delete_window,1); |
SetWM_Proto(fshell); |
} |
} |
|
|
static void set_printing_method(Widget w,XtPointer number,XtPointer call_data) { |
static void set_printing_method(Widget w,XtPointer number,XtPointer call_data) |
Widget shell; |
{ |
extern int PrintingMethod; |
Widget shell; |
PrintingMethod = (int) number; |
extern int PrintingMethod; |
fprintf(stderr,"PrintingMethod=%d\n",number); |
PrintingMethod = (int) number; |
shell = XtParent(XtParent(w)); |
fprintf(stderr,"PrintingMethod=%d\n",(int)number); |
XtPopdown(shell); XtDestroyWidget(shell); |
shell = XtParent(XtParent(w)); |
|
XtPopdown(shell); XtDestroyWidget(shell); |
} |
} |
|
|
static void printing_method(w,can,calldata) |
static void printing_method(Widget w,struct canvas *can,XtPointer calldata) |
Widget w; |
|
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
Arg arg[10]; |
Arg arg[10]; |
int i,n; |
int i,n; |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern int PrintingMethod; |
extern int PrintingMethod; |
|
|
w = W; |
w = W; |
can = Can; |
can = Can; |
create_popup(can->shell,"Printing method",Printing_methods[PrintingMethod], |
create_popup(can->shell,"Printing method",Printing_methods[PrintingMethod], |
&fshell,&fdialog); |
&fshell,&fdialog); |
n = 0; |
n = 0; |
XtSetArg(arg[n], XtNlabel, "Method: "); n++; |
XtSetArg(arg[n], XtNlabel, "Method: "); n++; |
XtSetArg(arg[n], XtNvalue, Printing_methods[PrintingMethod]); n++; |
XtSetArg(arg[n], XtNvalue, Printing_methods[PrintingMethod]); n++; |
XtSetValues(fdialog,arg,n); |
XtSetValues(fdialog,arg,n); |
for (i=0; i<N_printing_methods; i++) { |
for (i=0; i<N_printing_methods; i++) { |
XawDialogAddButton(fdialog,Printing_methods[i],set_printing_method,(XtPointer) i); |
XawDialogAddButton( |
} |
fdialog,Printing_methods[i],set_printing_method,(XtPointer) i); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
} |
XSetWMProtocols(display,XtWindow(fshell),&wm_delete_window,1); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
|
SetWM_Proto(fshell); |
} |
} |
static void print_canvas_to_file(w,can,calldata) |
|
Widget w; |
static void print_canvas_to_file(Widget w,struct canvas *can,XtPointer calldata) |
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
FILE *fp; |
Arg arg[10]; |
Arg arg[10]; |
int n; |
int n; |
static char *psfile = NULL; |
static char *psfile = NULL; |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget PrintDialog; |
extern Widget PrintDialog; |
extern char *Fname; |
extern char *Fname; |
|
|
|
w = W; |
w = W; |
can = Can; |
can = Can; |
if (psfile == NULL || Fname == NULL) psfile = "ox_plot.eps"; |
if (psfile == NULL || Fname == NULL) psfile = "ox_plot.eps"; |
else psfile = Fname; |
else psfile = Fname; |
create_popup(can->shell,"Output as PS file",psfile,&fshell,&fdialog); |
create_popup(can->shell,"Output as PS file",psfile,&fshell,&fdialog); |
n = 0; |
n = 0; |
XtSetArg(arg[n], XtNlabel, "File : "); n++; |
XtSetArg(arg[n], XtNlabel, "File : "); n++; |
XtSetArg(arg[n], XtNvalue, psfile); n++; |
XtSetArg(arg[n], XtNvalue, psfile); n++; |
XtSetValues(fdialog,arg,n); |
XtSetValues(fdialog,arg,n); |
XawDialogAddButton(fdialog,"output to file",output_to_file,w); |
XawDialogAddButton(fdialog,"output to file",output_to_file,w); |
XawDialogAddButton(fdialog,"cancel",cancel_output_to_file,w); |
XawDialogAddButton(fdialog,"cancel",cancel_output_to_file,w); |
PrintDialog = fdialog; |
PrintDialog = fdialog; |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(fshell),&wm_delete_window,1); |
SetWM_Proto(fshell); |
} |
} |
static void output_to_printer(w,can,calldata) |
|
Widget w; |
static void output_to_printer(Widget w,struct canvas *can,XtPointer calldata) |
struct canvas *can; |
|
XtPointer calldata; |
|
{ |
{ |
FILE *fp; |
Arg arg[10]; |
Arg arg[10]; |
int n; |
int n; |
static char *psfile = NULL; |
static char *psfile = NULL; |
Widget fshell,fdialog; |
Widget fshell,fdialog; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget PrintDialog_lp; |
extern Widget PrintDialog_lp; |
extern char *PrinterName; |
extern char *PrinterName; |
|
|
|
w = W; |
w = W; |
can = Can; |
can = Can; |
if (psfile == NULL || PrinterName == NULL) psfile = "lp"; |
if (psfile == NULL || PrinterName == NULL) psfile = "lp"; |
else psfile = PrinterName; |
else psfile = PrinterName; |
create_popup(can->shell,"Output PS file to printer",psfile,&fshell,&fdialog); |
create_popup(can->shell,"Output PS file to printer",psfile,&fshell,&fdialog); |
n = 0; |
n = 0; |
XtSetArg(arg[n], XtNlabel, "PS Printer Name : "); n++; |
XtSetArg(arg[n], XtNlabel, "PS Printer Name : "); n++; |
XtSetArg(arg[n], XtNvalue, psfile); n++; |
XtSetArg(arg[n], XtNvalue, psfile); n++; |
XtSetValues(fdialog,arg,n); |
XtSetValues(fdialog,arg,n); |
XawDialogAddButton(fdialog,"output to PS printer",output_to_ps_printer,w); |
XawDialogAddButton(fdialog,"output to PS printer",output_to_ps_printer,w); |
XawDialogAddButton(fdialog,"cancel",cancel_output_to_file,w); |
XawDialogAddButton(fdialog,"cancel",cancel_output_to_file,w); |
PrintDialog_lp = fdialog; |
PrintDialog_lp = fdialog; |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XtSetSensitive(w,False); XtPopup(fshell,XtGrabNone); |
XSetWMProtocols(display,XtWindow(fshell),&wm_delete_window,1); |
SetWM_Proto(fshell); |
} |
} |
|
|
static void cancel_output_to_file(w,fbutton,call) |
static void cancel_output_to_file(Widget w,XtPointer fbutton,XtPointer call) |
Widget w; |
|
XtPointer fbutton, call; |
|
{ |
{ |
Widget shell = XtParent(XtParent(w)); |
Widget shell = XtParent(XtParent(w)); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtSetSensitive(fbutton,True); |
XtSetSensitive(fbutton,True); |
} |
} |
|
|
static void output_to_file(w,fbutton,call) |
static void output_to_file(Widget w,XtPointer fbutton,XtPointer call) |
Widget w; |
|
XtPointer fbutton, call; |
|
{ |
{ |
char *fname; |
char *fname; |
FILE *fp; |
FILE *fp; |
int i; |
int i; |
char *m; |
|
extern struct canvas *Can; |
|
extern Widget PrintDialog; |
|
extern int PrintingMethod; |
|
Widget shell = XtParent(XtParent(w)); |
|
|
|
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
extern struct canvas *Can; |
}else{ |
extern Widget PrintDialog; |
method_is_not_available(); |
extern int PrintingMethod; |
XtPopdown(shell); XtDestroyWidget(shell); |
Widget shell = XtParent(XtParent(w)); |
XtSetSensitive(fbutton,True); |
|
return; |
|
} |
|
|
|
fname = XawDialogGetValueString(PrintDialog); |
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
Fname = (char *)malloc(sizeof(char)*strlen(fname)+1); |
TODO; |
strcpy(Fname,fname); |
}else{ |
for (i=0; i<strlen(Fname); i++) { |
method_is_not_available(); |
if (Fname[i] == 0xd || Fname[i] == 0xa) { |
XtPopdown(shell); XtDestroyWidget(shell); |
Fname[i] = 0; break; |
XtSetSensitive(fbutton,True); |
|
return; |
} |
} |
} |
|
fprintf(stderr,"fname=%s\n",Fname); fflush(NULL); |
|
fp = fopen(Fname,"w"); |
|
if (fp == NULL) { |
|
warning(Can,"Could not open the output file."); |
|
}else{ |
|
generate_psfile(Can,fp); |
|
fclose(fp); |
|
} |
|
|
|
XtPopdown(shell); XtDestroyWidget(shell); |
fname = XawDialogGetValueString(PrintDialog); |
XtSetSensitive(fbutton,True); |
Fname = (char *)malloc(sizeof(char)*strlen(fname)+1); |
|
strcpy(Fname,fname); |
|
for (i=0; i<strlen(Fname); i++) { |
|
if (Fname[i] == 0xd || Fname[i] == 0xa) { |
|
Fname[i] = 0; break; |
|
} |
|
} |
|
fprintf(stderr,"fname=%s\n",Fname); fflush(NULL); |
|
fp = fopen(Fname,"w"); |
|
if (fp == NULL) { |
|
warning(Can,"Could not open the output file."); |
|
}else{ |
|
generate_psfile(Can,fp); |
|
fclose(fp); |
|
} |
|
|
|
XtPopdown(shell); XtDestroyWidget(shell); |
|
XtSetSensitive(fbutton,True); |
} |
} |
|
|
static void output_to_ps_printer(w,fbutton,call) |
static void output_to_ps_printer(Widget w, XtPointer fbutton, XtPointer call) |
Widget w; |
|
XtPointer fbutton, call; |
|
{ |
{ |
char *printerName; |
char *printerName; |
FILE *fp; |
FILE *fp; |
extern struct canvas *Can; |
extern struct canvas *Can; |
extern Widget PrintDialog_lp; |
extern Widget PrintDialog_lp; |
char fname[256]; |
char fname[256]; |
char cmd[512]; |
char cmd[512]; |
static int id = 0; |
static int id = 0; |
int i; |
int i; |
Widget shell = XtParent(XtParent(w)); |
Widget shell = XtParent(XtParent(w)); |
|
|
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
}else{ |
}else{ |
method_is_not_available(); |
method_is_not_available(); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtSetSensitive(fbutton,True); |
XtSetSensitive(fbutton,True); |
return; |
return; |
} |
} |
|
|
sprintf(fname,"/tmp/ox_plot_%d.eps",(int) getpid(),id++); |
sprintf(fname,"/tmp/ox_plot_%d_%d.eps",(int) getpid(),id++); |
|
|
printerName = XawDialogGetValueString(PrintDialog_lp); |
printerName = XawDialogGetValueString(PrintDialog_lp); |
PrinterName = (char *)malloc(sizeof(char)*strlen(printerName)+1); |
PrinterName = (char *)malloc(sizeof(char)*strlen(printerName)+1); |
strcpy(PrinterName,printerName); |
strcpy(PrinterName,printerName); |
for (i=0; i<strlen(PrinterName); i++) { |
for (i=0; i<strlen(PrinterName); i++) { |
if (PrinterName[i] == 0xd || PrinterName[i] == 0xa) { |
if (PrinterName[i] == 0xd || PrinterName[i] == 0xa) { |
PrinterName[i] = 0; break; |
PrinterName[i] = 0; break; |
|
} |
} |
} |
} |
fprintf(stderr,"printerName=%s\n",PrinterName); fflush(NULL); |
fprintf(stderr,"printerName=%s\n",PrinterName); fflush(NULL); |
fp = fopen(fname,"w"); |
fp = fopen(fname,"w"); |
if (fp == NULL) { |
if (fp == NULL) { |
warning(Can,"Could not open the output file."); |
warning(Can,"Could not open the output file."); |
}else{ |
}else{ |
generate_psfile(Can,fp); |
generate_psfile(Can,fp); |
fclose(fp); |
fclose(fp); |
} |
} |
|
|
|
sprintf(cmd,"lpr -P%s %s",PrinterName,fname); |
sprintf(cmd,"lpr -P%s %s",PrinterName,fname); |
if (system(cmd)) { |
if (system(cmd)) { |
warning(Can,"Unknown printer?"); |
warning(Can,"Unknown printer?"); |
} |
} |
sprintf(cmd,"rm -f %s",fname); |
sprintf(cmd,"rm -f %s",fname); |
system(cmd); |
system(cmd); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtPopdown(shell); XtDestroyWidget(shell); |
XtSetSensitive(fbutton,True); |
XtSetSensitive(fbutton,True); |
} |
} |
|
|
|
|
/* test sequence |
/* test sequence |
ox_launch(0,"ox_plot"); |
ox_launch(0,"ox_plot"); |
ifplot(x^2-y^3); |
ifplot(x^2-y^3); |
drawcircle(0,0,100,0,0); |
drawcircle(0,0,100,0xff000,0); |
*/ |
*/ |
static int getColorSizeOfImageForPS(int xsize,int ysize,XImage *image, |
static void generate_psfile(struct canvas *can, FILE *fp) |
struct xcolorForPS **tableOfxcolorForPS); |
|
|
|
static void generate_psfile(can,fp) |
|
struct canvas *can; |
|
FILE *fp; |
|
{ |
{ |
int x,y; |
XImage *image; |
XImage *image; |
int color[1]; |
int color[1]; |
extern int PrintingMethod; |
int colorSize = 1; |
|
char *m; |
fprintf(stderr,"generate_psfile\n"); |
struct xcolorForPS *tableOfxcolorForPS; |
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
extern int PrintingMethod; |
if ( display ) { |
fprintf(stderr,"generate_psfile\n"); |
fprintf(stderr,"generate_psfile: output to a file.\n"); |
if (PrintingMethod == PRINTING_METHOD_BITMAP) { |
image = XGetImage(display,can->pix, |
if ( display ) { |
|
fprintf(stderr,"generate_psfile: output to a file.\n"); |
|
image = XGetImage(display,can->pix, |
|
0,0,can->width,can->height,-1,ZPixmap); |
0,0,can->width,can->height,-1,ZPixmap); |
colorSize = |
color[0] = 0; /* black line */ |
getColorSizeOfImageForPS(can->width,can->height,image,&tableOfxcolorForPS); |
PSFromImage(fp,image,can); |
color[0] = 0; /* black line */ |
}else{ |
generatePS_from_image(fp,image,can->width,can->height,color,colorSize,can,tableOfxcolorForPS,upsidedown); |
fprintf(stderr,"Cannot print on this system\n"); |
|
} |
}else{ |
}else{ |
fprintf(stderr,"Cannot print on this system\n"); |
method_is_not_available(); |
} |
} |
}else{ |
fflush(NULL); |
method_is_not_available(); |
|
} |
|
fflush(NULL); |
|
} |
} |
|
|
static void method_is_not_available() { |
static void method_is_not_available() { |
Line 1197 static void method_is_not_available() { |
|
Line 1136 static void method_is_not_available() { |
|
warning(Can,m); |
warning(Can,m); |
} |
} |
|
|
clear_pixmap(can) |
void clear_pixmap(struct canvas *can) |
struct canvas *can; |
|
{ |
{ |
XFillRectangle(display,can->pix,clearGC,0,0,can->width,can->height); |
XFillRectangle(display,can->pix,clearGC,0,0,can->width,can->height); |
XFlush(display); |
XFlush(display); |
} |
} |
|
|
|
#if 0 |
/* |
/* |
The following functions are used to generate color postscript file. |
The following functions are used to generate color postscript file. |
*/ |
*/ |
/* In order to count colorSize, binary tree (sm_btree) is used. */ |
/* In order to count colorSize, binary tree (sm_btree) is used. */ |
static struct sm_btree *sm_newNode(unsigned long v); |
static struct sm_btree *sm_newNode(unsigned long v); |
static int sm_insert(struct sm_btree *node,unsigned long v); |
static void sm_insert(struct sm_btree *node,unsigned long v); |
static int sm_count(struct sm_btree *rootp); |
static int sm_count(struct sm_btree *rootp); |
|
static int getColorSizeOfImageForPS(int xsize,int ysize,XImage *image, |
|
struct xcolorForPS **tableOfxcolorForPS); |
|
|
struct sm_btree { |
struct sm_btree { |
unsigned long p; |
unsigned long p; |
struct sm_btree * left; |
struct sm_btree * left; |
struct sm_btree * right; |
struct sm_btree * right; |
}; |
}; |
|
|
static struct sm_btree *sm_newNode(unsigned long v) { |
static struct sm_btree *sm_newNode(unsigned long v) { |
struct sm_btree * n; |
struct sm_btree * n; |
n = (struct sm_btree *)MALLOC(sizeof(struct sm_btree)); |
n = (struct sm_btree *)MALLOC(sizeof(struct sm_btree)); |
Line 1226 static struct sm_btree *sm_newNode(unsigned long v) { |
|
Line 1168 static struct sm_btree *sm_newNode(unsigned long v) { |
|
n->right = NULL; |
n->right = NULL; |
return n; |
return n; |
} |
} |
static int sm_insert(struct sm_btree *node,unsigned long v) |
|
|
static void sm_insert(struct sm_btree *node,unsigned long v) |
{ |
{ |
if (node->p == v) return; |
if (node->p == v) return; |
if (node->p > v) { |
if (node->p > v) { |
Line 1244 static int sm_insert(struct sm_btree *node,unsigned lo |
|
Line 1187 static int sm_insert(struct sm_btree *node,unsigned lo |
|
sm_insert(node->right,v); |
sm_insert(node->right,v); |
} |
} |
} |
} |
|
|
|
|
static int sm_count(struct sm_btree *rootp) |
static int sm_count(struct sm_btree *rootp) |
{ |
{ |
if (rootp == NULL) return 0; |
if (rootp == NULL) return 0; |
Line 1255 static int setTableOfxcolorForPS(struct sm_btree *root |
|
Line 1200 static int setTableOfxcolorForPS(struct sm_btree *root |
|
{ |
{ |
int m; |
int m; |
m = k; |
m = k; |
if (rootp == NULL) return; |
if (rootp == NULL) return 0; |
if (k >= size) { |
if (k >= size) { |
warning(Can,"internal error of setTableOfxcolorForPS"); |
warning(Can,"internal error of setTableOfxcolorForPS"); |
} |
} |
Line 1271 static int setTableOfxcolorForPS(struct sm_btree *root |
|
Line 1216 static int setTableOfxcolorForPS(struct sm_btree *root |
|
return m; |
return m; |
} |
} |
|
|
|
|
static int getColorSizeOfImageForPS(int xsize,int ysize,XImage *image, |
static int getColorSizeOfImageForPS(int xsize,int ysize,XImage *image, |
struct xcolorForPS **tableOfxcolorForPS) |
struct xcolorForPS **tableOfxcolorForPS) |
{ |
{ |
Line 1304 static int getColorSizeOfImageForPS(int xsize,int ysiz |
|
Line 1248 static int getColorSizeOfImageForPS(int xsize,int ysiz |
|
*/ |
*/ |
if (setTableOfxcolorForPS(&root,table,0,size) != size) { |
if (setTableOfxcolorForPS(&root,table,0,size) != size) { |
warning(Can,"internal error."); |
warning(Can,"internal error."); |
return ; |
return 0; |
} |
} |
|
|
screen = DefaultScreen(display); |
screen = DefaultScreen(display); |
Line 1349 static int getColorSizeOfImageForPS(int xsize,int ysiz |
|
Line 1293 static int getColorSizeOfImageForPS(int xsize,int ysiz |
|
*tableOfxcolorForPS = table; |
*tableOfxcolorForPS = table; |
return size; |
return size; |
} |
} |
|
#endif |
|
|