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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
function [scs_m,newparameters,needcompile,edited]=scicos(scs_m,menus)
// scicos - block diagram graphic editor
//%SYNTAX
// scs_m=scicos(scs_m,job)
//%PARAMETERS
// scs_m : scilab list, scicos main data structure
// scs_m(1) contains system name and other infos
// scs_m(i+1) contains description of ith block diagram element
// menus : vector of character strings,optional parameter giving usable menus
//!
// Copyright INRIA
[lhs,rhs]=argn(0)
//check if superblock editing mode
[%ljunk,%mac]=where()
slevel=prod(size(find(%mac=='scicos')))
super_block=slevel>1
if ~super_block then
// define scicos libraries
if exists('scicos_pal')==0 | exists('%scicos_menu')==0 | exists('%scicos_short')==0 then
x_message(['scicos_pal,%scicos_menu or %scicos_short not defined';
'using default values'])
[scicos_pal,%scicos_menu,%scicos_short]=initial_scicos_tables()
end
if exists('scicoslib')==0 then load('SCI/macros/scicos/lib'),end
if exists('blockslib')==0 then load('SCI/macros/scicos_blocks/lib'),end
end
scicos_ver='scicos2.5.1' // set current version of scicos
Main_Scicos_window=1000
//Initialisation
newparameters=list()
enable_undo=%f
edited=%f
needreplay=%f
%path='./'
%exp_dir=PWD
global %tableau //a remettre qd le bug de global est corrige
if ~super_block then // global variables
%zoom=1.8
pal_mode=%f // Palette edition mode
newblocks=[] // table of added functions in pal_mode
super_path=[] // path to the currently opened superblock
errcatch(-1,'continue','nomessage')
scicos_paltmp=scicos_pal;
load('.scicos_pal')
errcatch(-1)
if iserror(-1) then
errclear(-1)
else
scicos_pal=[scicos_paltmp;scicos_pal]
[%junk,%palce]=gunique(scicos_pal(:,2))
%palce=-sort(-%palce);
scicos_pal=scicos_pal(%palce,:);
end
errcatch(-1,'continue','nomessage')
load('.scicos_short') //keyboard shortcuts
errcatch(-1)
if iserror(-1) then
errclear(-1)
end
end
//
if rhs>=1 then
if type(scs_m)==10 then //diagram is given by its filename
%fil=scs_m
alreadyran=%f
[ok,scs_m,%cpr,edited]=do_load(%fil,'diagram')
if ~ok then return,end
if size(%cpr)==0 then
needcompile=4
%state0=list()
else
%state0=%cpr(1);
needcompile=0
end
else //diagram is given by its data structure
if ~super_block then
%cpr=list();needcompile=4;alreadyran=%f,%state0=list()
end
end
else
xset('window',Main_Scicos_window);
scs_m=empty_diagram()
%cpr=list();needcompile=4;alreadyran=%f;%state0=list()
end
//
if type(scs_m)<>15 then error('first argument must be a scicos list'),end
%cor_item_exec=[];
for %Y=1:length(%scicos_menu)
for %R=2:size(%scicos_menu(%Y),2)
%kaka=%scicos_menu(%Y)(%R)
%koko=stripblanks(%kaka)+'_'
%koko=strsubst(%koko,'/','')
%koko=strsubst(%koko,' ','')
%koko=strsubst(%koko,'.','')
%koko=strsubst(%koko,'-','')
%cor_item_exec=[%cor_item_exec;[%kaka,%koko]];
end
end
menus=tlist('xxx')
for %Y=1:length(%scicos_menu)
menus(1)=[menus(1),%scicos_menu(%Y)(1)];
execstr(%scicos_menu(%Y)(1)+'_t=[]');
for %R=2:size(%scicos_menu(%Y),2)
execstr(%scicos_menu(%Y)(1)+'_t=['+%scicos_menu(%Y)(1)+'_t '''+%scicos_menu(%Y)(%R)+''']')
end
menus($+1)=evstr(%scicos_menu(%Y)(1)+'_t');
end
%rpar=')'
for %Y=1:length(%scicos_menu)
%w='menus('''+%scicos_menu(%Y)(1)+''')(';
menu_e=%scicos_menu(%Y)(1)+'_t'
execstr(%scicos_menu(%Y)(1)+'=%w(ones('+%scicos_menu(%Y)(1)+'_t))+string(1:size('+%scicos_menu(%Y)(1)+'_t,''*''))+%rpar(ones('+%scicos_menu(%Y)(1)+'_t))')
end
//keyboard definiton
%tableau=emptystr([1:100]);
for %Y=1:size(%scicos_short,1)
%tableau(-31+ascii(%scicos_short(%Y,1)))=%scicos_short(%Y,2);
end
//viewport
%wpar=scs_m(1)
options=%wpar(7)
if ~super_block then
xset('window',Main_Scicos_window);
curwin=xget('window');
palettes=list();
noldwin=0
windows=[1 curwin]
pixmap=%scicos_display_mode
//
else
noldwin=size(windows,1)
windows=[windows;slevel curwin]
palettes=palettes;
end
//initialize graphics
xdel(curwin)
xset('window',curwin);
xset('default')
xbasc();
if pixmap then xset('pixmap',1); end
xset('pattern',1)
xset('dashes',1)
if ~set_cmap(options('Cmap')) then // add colors if required
options('3D')(1)=%f //disable 3D block shape
end
if pixmap then xset('wwpc');end
xbasc();xselect()
%dr=driver();driver('Rec');
set_background()
rect=dig_bound(scs_m);
if rect<>[] then
%wsiz=[rect(3)-rect(1),rect(4)-rect(2)];
else
%wsiz=[600/%zoom,400/%zoom]
end
// 1.3 to correct for X version
xset('wpdim',min(1000,%zoom*%wsiz(1)),min(800,%zoom*%wsiz(2)*1.5))
window_set_size()
xset('alufunction',6)
for %Y=1:length(%scicos_menu)
execstr(%scicos_menu(%Y)(1)+'_'+string(curwin)+'='+%scicos_menu(%Y)(1))
end
menu_stuff()
if ~super_block then
delmenu(curwin,'stop')
addmenu(curwin,'stop',list(1,'haltscicos'))
unsetmenu(curwin,'stop')
else
unsetmenu(curwin,'Simulate')
end
//set context (variable definition...)
if size(scs_m(1))>4 then
if type(scs_m(1)(5))==10 then
errcatch(-1,'continue','nomessage')
execstr(scs_m(1)(5))
errcatch(-1)
if iserror(-1) then
message('Cannot evaluate context')
errclear(-1)
end
else
scs_m(1)(5)=' '
end
end
drawobjs(scs_m)
if pixmap then xset('wshow'),end
%pt=[];%win=0;
Cmenu='Open/Set'
while %t
while %t do
if Cmenu==[]&%pt==[] then
[btn,%xc,%yc,%win_1,Cmenu]=cosclick()
if Cmenu<> [] then
%pt=[];
break
elseif btn>31 then
%pt=[%xc;%yc];%win=%win_1;Cmenu=%tableau(min(100,btn-31));
if Cmenu==emptystr() then Cmenu=[];%pt=[];end
break
end
else
break
end
end
if Cmenu=='Quit' then do_exit();break;end
%koko=find(Cmenu==%cor_item_exec(:,1));
if size(%koko,'*')==1 then
execstr('exec('+%cor_item_exec(%koko,2)+',-1)')
else
Cmenu=[];%pt=[]
end
if pixmap then xset('wshow'),end
end
function [x,k]=gunique(x)
[x,k]=gsort(x);
keq=find(x(2:$)==x(1:$-1))
x(keq)=[]
k(keq)=[]
|