de8d57fe15dbcb29c8832d05456eff206df21932
[scilab.git] / scilab / modules / scicos_blocks / macros / NonLinear / QUANT_f.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]=QUANT_f(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]=standard_outputs(arg1)
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         model=arg1.model;
37         while %t then
38             [ok,pas,meth,exprs]=scicos_getvalue("Set parameters",..
39             ["Step";"Quantization Type (1-4)"],..
40             list("vec",1,"vec",1),exprs)
41             if ~ok then break,end
42             if meth<1|meth>4 then
43                 message("Quantization Type must be from 1 to 4")
44             else
45                 rpar=pas
46                 model.rpar=rpar
47                 model.ipar=meth
48                 select meth
49                 case 1 then
50                     model.sim="qzrnd"
51                 case 2 then
52                     model.sim="qztrn"
53                 case 3 then
54                     model.sim="qzflr"
55                 case 4  then
56                     model.sim="qzcel"
57                 end
58                 graphics.exprs=exprs
59                 x.graphics=graphics;x.model=model
60                 break
61             end
62         end
63     case "define" then
64         pas=0.1;
65         meth=1
66         model=scicos_model()
67         model.sim="qzrnd"
68         model.in=-1
69         model.out=-1
70         model.rpar=pas
71         model.ipar=meth
72         model.blocktype="c"
73         model.dep_ut=[%t %f]
74
75         exprs=[string(pas);string(meth)]
76         gr_i=["thick=xget(''thickness'');xset(''thickness'',2);";
77         "xx=orig(1)+[1;2;2;3;3;4;4]/5*sz(1);";
78         "yy= orig(2)+[1;1;2;2;3;3;4]/5*sz(2);";
79         "xpoly(xx,yy,''lines'');";
80         "xset(''thickness'',thick);"]
81         x=standard_define([2 2],model,exprs,gr_i)
82     end
83 endfunction