1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
function [sd]=gr_menu(sd,flag,noframe)
// Copyright INRIA
getf('SCI/macros/xdess/gr_macros.sci','c');
deff('[modek]=clearmode()',['modek=xget(''alufunction'')';
'xset(''alufunction'',6);']);
deff('[]=modeback(x)','xset(''alufunction'',x);');
dash=['0 continue';
'1 {2,5,2,5}';
'2 {5,2,5,2}';
'3 {5,3,2,3}';
'4 {8,3,2,3}';
'5 {11,3,2,3}';
'6 {11,3,5,3}}'];
[lhs,rhs]=argn(0);
if rhs<=1,flag=0;end;
if rhs<=2,noframe=0;end;
if rhs <=0 then
cdef=[0 0 100 100];init=1
else
select type(sd)
case 1 then cdef=sd;init=1
case 15 then
if sd(1)<>'sd' then
error('l''entree n''est pas une liste de type sd'),
end
cdef=sd(2);init=0
else error('incorrect input:'+...
'[xmin,ymin,xmax,ymax] ou list(''sd'',,,)')
end
end
if noframe==1;s_t="010";else s_t="012";end
plot2d(0,0,[1],s_t,' ',cdef);
curwin=xget('window')
xclip('clipgrf')
menu_o=['rectangle','frectangle','circle','fcircle','polyline',...
'fpolyline','spline','arrow','points','caption']
menu_s=['dash style','pattern','thickness','mark','clip off','clip on']
menu_e=['redraw','pause','delete','move','group','Exit']
menus=list(['Objects','Settings','Edit'],menu_o,menu_s,menu_e)
w='menus(2)(';rpar=')'
Objects=w(ones(menu_o))+string(1:size(menu_o,'*'))+rpar(ones(menu_o))
w='menus(3)(';rpar=')'
Settings=w(ones(menu_s))+string(1:size(menu_s,'*'))+rpar(ones(menu_s))
w='menus(4)(';rpar=')'
Edit=w(ones(menu_e))+string(1:size(menu_e,'*'))+rpar(ones(menu_e))
execstr('Edit_'+string(curwin)+'=Edit')
execstr('Settings_'+string(curwin)+'=Settings')
execstr('Objects_'+string(curwin)+'=Objects')
menubar(curwin,menus)
if init==0 then redraw(sd,s_t); else sd=list('sd',cdef); end,
//
if flag==1; xclip();return ;end
// boucle principale
Cmenu1=[]
while %t then
ksd=prod(size(sd))
[btn,xc,yc,win,Cmenu]=getclick()
c1=[xc,yc]
select Cmenu
case 'Exit' then
fin='ok'
break
case 'rectangle' then
xinfo('rectangle ');
new=rect();
if new<>list() then
sd(ksd+1)=new
end
case 'frectangle' then
xinfo('filled rectangle ');
new=frect();
if new<>list() then
sd(ksd+1)=new
end
case 'circle' then
xinfo(['circle : center point,';...
' point on the circle']);
new=cerc();
if new<>list() then
sd(ksd+1)=new
end
case 'fcircle' then
xinfo(['filles circle : center point,';...
' point on the circle']);
new=fcerc();
if new<>list() then
sd(ksd+1)=new
end
case 'polyline' then
xinfo(['line : left-click to stop,';...
' right or middle to add a point']);
new=ligne();
if new<>list() then
sd(ksd+1)=new
end
case 'fpolyline' then
xinfo(['fline : left-click to stop,';...
' right or middle to add a point']);
new=fligne();
if new<>list() then
sd(ksd+1)=new
end
case 'spline' then
xinfo(['splin [xi increasing]:left-click to stop,';...
' right or middle to add a point ']);
new=curve();
if new<>list() then
sd(ksd+1)=new
end
case 'arrow' then
xinfo('arrow : begining point, ending point');
new=fleche();
if new<>list() then
sd(ksd+1)=new
end
case 'points' then
xinfo(['points: left-click to stop,';
' right or middle to add a point']);
new=points();
if new<>list() then
sd(ksd+1)=new
end
case 'caption' then
xinfo('leg');
new=comment();
if new<>list() then
sd(ksd+1)=new
end
case 'dash style' then
xinfo('dash');
new=dashs()
if new<>list() then
sd(ksd+1)=new
end
case 'pattern' then
xinfo('pattern');
new=patts();
if new<>list() then
sd(ksd+1)=new
end
case 'thickness' then
xinfo('thickness');
new=Thick();
if new<>list() then
sd(ksd+1)=new
end
case 'mark' then
xinfo('symbols');
new=symbs();
if new<>list() then
sd(ksd+1)=new
end
case 'redraw' then
xset("default");
redraw(sd,s_t);
case 'pause' then
pause;
case 'delete' then
delete(sd);
case 'move' then
sd=move(sd);
case 'clip off' then
new=grclipoff();
if new<>list() then
sd(ksd+1)=new
end
case 'clip on' then
new=grclipon();
if new<>list() then
sd(ksd+1)=new
end
case 'group' then
sd=group(sd)
end // fin select
end, // fin while
xset("default");
|