Scicos_blocks: clean NonLinear blocks interfaces
[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=[];
24     y=[];
25     typ=[];
26     select job
27     case "set" then
28         x=arg1;
29         graphics=arg1.graphics;
30         exprs=graphics.exprs
31         model=arg1.model;
32         while %t then
33             [ok,pas,meth,exprs]=scicos_getvalue("Set parameters",..
34             ["Step";"Quantization Type (1-4)"],..
35             list("vec",1,"vec",1),exprs)
36             if ~ok then
37                 break,
38             end
39             if meth<1|meth>4 then
40                 message("Quantization Type must be from 1 to 4")
41             else
42                 rpar=pas
43                 model.rpar=rpar
44                 model.ipar=meth
45                 select meth
46                 case 1 then
47                     model.sim="qzrnd"
48                 case 2 then
49                     model.sim="qztrn"
50                 case 3 then
51                     model.sim="qzflr"
52                 case 4  then
53                     model.sim="qzcel"
54                 end
55                 graphics.exprs=exprs
56                 x.graphics=graphics;
57                 x.model=model
58                 break
59             end
60         end
61     case "define" then
62         pas=0.1;
63         meth=1
64         model=scicos_model()
65         model.sim="qzrnd"
66         model.in=-1
67         model.out=-1
68         model.rpar=pas
69         model.ipar=meth
70         model.blocktype="c"
71         model.dep_ut=[%t %f]
72
73         exprs=[string(pas);string(meth)]
74         gr_i=[]
75         x=standard_define([2 2],model,exprs,gr_i)
76     end
77 endfunction