1 /*------------------------------------------------------------------------
3 * Copyright (C) 1998-2001 Enpc/Jean-Philippe Chancelier
5 --------------------------------------------------------------------------*/
10 #include "math_graphics.h"
11 #include "GetProperty.h"
12 #include "SetProperty.h"
13 #include "DrawObjects.h"
15 #include "WindowList.h"
20 extern int xinitxend_flag;
22 /********************************************************
23 * the functions in this file are called from
24 * callback ( see jpc_SGraph.c ) for the XWindow version
25 * Nov 1998 : we must be sure that during the evaluation of
26 * scig_xxx an other function scig_yyy won't be
27 * run. This is possible since during the execution of
28 * one scig_xxx function a sciprint can be performed
29 * and it will lead to an event check which can
30 * produce a call to an other scig_yyy function
31 * flag scig_buzy is used to check for that
33 ********************************************************/
34 extern int sciSwitchWindow __PARAMS((int *winnum));/* NG */
35 extern void sciGetIdFigure __PARAMS((int *vect, int *id, int *iflag));/* NG */
36 extern int C2F(syncexec)(char *str, int *ns, int *ierr, int *seq, long int str_len) ;
37 #if !defined(_MSC_VER)
38 extern int WithBackingStore();
40 static int scig_buzy = 0;
42 int I3dRotation(void) ;
44 typedef int (*Scig_handler) __PARAMS((int));
46 void reset_scig_handler(void);
47 int scig_handler_none(int win_num);
49 /********************************************************
50 * A handler which can be dynamically set to custiomize
51 * action of scig_xxx functions
52 ********************************************************/
54 int scig_handler_none(int win_num) {
58 Scig_handler scig_handler = scig_handler_none;
61 /********************************************************
62 * Basic Replay : redraw recorded graphics
63 ********************************************************/
65 void scig_replay(integer win_num)
67 /* Modification Allan CORNET Mai 2004 */
68 integer verb=0,cur,pix,na,backing;
70 if ( scig_buzy == 1 ) return ;
72 GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
73 C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
74 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
75 C2F(dr)("xget","pixmap",&verb,&pix,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
80 backing = WithBackingStore();
84 C2F(dr)("xset","wshow",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
90 if ( (GetDriver()) != 'R') C2F(SetDriver)("Rec",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
91 C2F(dr)("xclear","v",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
93 C2F(dr)("xset","wshow",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
97 C2F(dr)("xset","wshow",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
101 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
102 C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
107 void scig_erase(integer win_num)
109 integer verb=0,cur,na;
111 if ( scig_buzy == 1 ) return ;
113 GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
114 if ( (GetDriver()) !='R')
115 C2F(SetDriver)("Rec",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
116 C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
117 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
119 C2F(dr)("xclear","v",PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
120 C2F(dr)("xstart","v",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
121 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
122 C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
128 int scig_2dzoom(integer win_num)
132 integer verb=0,cur,na;
134 if ( scig_buzy == 1 ) return 0; ;
136 GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
138 C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
139 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
142 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
143 C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
149 void scig_unzoom(integer win_num)
151 integer verb=0,cur,na;
153 if ( scig_buzy == 1 ) return ;
155 GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
156 C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
157 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
160 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
161 C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
165 int scig_3drot(integer win_num)
167 integer verb=0,cur,na,ret;
169 if ( scig_buzy == 1 ) return 0;
171 GetDriver1(name,PI0,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0);
173 C2F(dr)("xget","window",&verb,&cur,&na,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
174 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
177 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
178 C2F(dr)("xsetdr",name, PI0, PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
183 void scig_sel(integer win_num)
187 if ((c=GetDriver())=='R' || c == 'X' || c == 'W')
189 C2F(dr)("xset","window",&win_num,&v,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
190 sciSwitchWindow(&win_num) ;
194 void scig_loadsg(int win_num, char *filename)
201 char * macroCall = NULL ;
202 /* the sting is "xload('(1)')" where (1) is filemame */
203 /* Consequently we have 9 fixed character and two variable strings. */
204 int macroCallLength = 9 + strlen(filename) ;
206 if ( scig_buzy == 1 ) { return ; }
209 C2F(dr)("xget","window",&verb,&cur,&narg,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
210 C2F(dr)("xset","window",&win_num,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
212 macroCall = MALLOC( (macroCallLength+1) * sizeof(char) ) ; /* +1 for the \0 terminating character */
213 sprintf(macroCall,"xload('%s')",filename);
215 C2F(syncexec)(macroCall,¯oCallLength,&ierr,&seq, macroCallLength );
218 if(ierr != 0) { sciprint("Wrong plot file : %s\r\n",filename) ; }
220 C2F(dr)("xset","window",&cur,PI0,PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
224 void scig_savesg( int win_num, char * filename )
228 char * macroCall = NULL ;
230 /* the sting is "xsave('(1)',(2))" where (1) is filemame and (2) the string */
231 /* corresponding of win_num. Consequently we have 10 fixed character and two variable strings. */
232 int macroCallLength = 10 + strlen(filename) + GET_NB_DIGITS(win_num) ;
234 macroCall = MALLOC( (macroCallLength+1) * sizeof(char) ) ; /* +1 for the \0 terminating character */
236 sprintf( macroCall, "xsave('%s',%d)", filename, win_num ) ; /* call xsave macro */
237 C2F(syncexec)(macroCall,¯oCallLength,&ierr,&seq, macroCallLength );