Scicos_blocks: clean NonLinear blocks interfaces
[scilab.git] / scilab / modules / scicos_blocks / macros / NonLinear / INTRP2BLK_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]=INTRP2BLK_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 do
33             [ok,a,b,c,exprs]=scicos_getvalue("Set Interpolation block parameters",..
34             ["X coord.";"Y coord.";"Z values"],list("vec",-1,"vec",-1,"mat",[-1,-1]),exprs)
35             if ~ok then
36                 break,
37             end
38             if size(a,"*") <> size(c,"c") | size(b,"*") <> size(c,"r") then
39                 message("incompatible dimension")
40             elseif min(a(2:$)-a(1:$-1)) <=0 | min(b(2:$)-b(1:$-1)) <=0 then
41                 message("X and Y must be strictly increasing")
42             else
43                 if ok then
44                     graphics.exprs=exprs
45                     model.rpar=[a(:);b(:);c(:)]
46                     model.ipar=[size(a,"*");size(b,"*")]
47                     x.graphics=graphics;
48                     x.model=model
49                     break
50                 end
51             end
52         end
53     case "define" then
54         a=[0;1];
55         b=[0;1];
56         c=[0 1;1 2]
57         model=scicos_model()
58         model.sim=list("intrp2",1)
59         model.in=[1;1]
60         model.out=1
61         model.rpar=[a;b;c(:)]
62         model.ipar=[2;2]
63         model.blocktype="c"
64         model.dep_ut=[%t %f]
65         exprs=[strcat(sci2exp(a));strcat(sci2exp(b));strcat(sci2exp(c,0))]
66         gr_i=[]
67         x=standard_define([3 2],model,exprs,gr_i)
68     end
69 endfunction