xcos_debug_gui function added for a simple use of the Debug block
[scilab.git] / scilab / modules / scicos_blocks / macros / Misc / DEBUG_SCICOS.sci
1 //  Scicos
2 //
3 //  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 //
19 // See the file ../license.txt
20 //
21
22 function [x,y,typ]=DEBUG_SCICOS(job,arg1,arg2)
23     x=[];y=[];typ=[]
24     select job
25     case "plot" then
26         standard_draw(arg1)
27     case "getinputs" then
28         [x,y,typ]=standard_inputs(arg1)
29     case "getoutputs" then
30         x=[];y=[];typ=[];
31     case "getorigin" then
32         [x,y]=standard_origin(arg1)
33     case "set" then
34         x=arg1;
35         graphics=arg1.graphics;exprs=graphics.exprs
36         textmp=exprs(2)
37         ok=%t
38         while 1==1
39             [txt]=dialog(["Enter scilab instructions for debugging.";
40             " Inputs are block and flag, output is block"],..
41             textmp);
42
43             if txt<>[] then
44                 tt=["block=debug_scicos(block,flag)"]
45
46                 if execstr("deff(tt,txt)","errcatch")==0 then
47                     warnMode = warning("query");
48                     warning("off");
49                     save(TMPDIR+"/debug_scicos", debug_scicos)
50                     warning(warnMode);
51                     exprs(2)=txt
52                     if (scicos_debug()<>2 & scicos_debug()<>3) then
53                         scicos_debug(2)
54                     end
55                     break
56                 else
57                     message(["Error in the instructions";lasterror()])
58                 end
59             else
60                 ok=%f;break;
61             end
62         end
63         if ok then
64             graphics.exprs=exprs;
65             x.graphics=graphics;
66         end
67
68     case "define" then
69         model=scicos_model()
70         model.sim=list("%debug_scicos",99)
71         model.blocktype="d"
72
73         exprs=list("","xcos_debug_gui(flag,block);")
74         gr_i=["xstringb(orig(1),orig(2),''Debug'',sz(1),sz(2),''fill'')"]
75         x=standard_define([8 2],model,exprs,gr_i)
76     end
77 endfunction