summaryrefslogtreecommitdiff
path: root/macros/Misc/DSUPER.sci
blob: c0a522b6c361a19ac28310c72989411302528b28 (plain)
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
//  Scicos
//
//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
//  Copyright (C) DIGITEO - Clément DAVID <clement.david@scilab.org>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See the file ../license.txt
//

function [x,y,typ] = DSUPER(job,arg1,arg2)
    x=[];
    y=[];
    typ=[];

    select job
    case "set" then
        y=needcompile // in case leaving with Exit x=arg1
        typ=list()
        graphics=arg1.graphics;
        if (length(graphics.exprs) == 0) then
            warnBlockByUID(arg1.model.label, gettext("Invalid masked block."));
            x=arg1,
            return;
        end

        exprs=graphics.exprs(1)
        exprs0=graphics.exprs(2)(1)
        btitre=graphics.exprs(2)(2)(1)
        bitems=graphics.exprs(2)(2)(2:$)
        if exprs0==[] then
            x=arg1,
            return,
        end

        // First evaluate the diagram context
        context = [arg1.model.rpar.props.context];
        [%scicos_context,ierr] = script2var(context,%scicos_context);

        if ierr <> 0 then
            x=arg1,
            return;
        end

        // then update the context with the mask parameters
        tt="scicos_context."+exprs0(1);
        for i=2:size(exprs0,1)
            tt=tt+",scicos_context."+exprs0(i),
        end

        ss=graphics.exprs(2)(3);
        scicos_context = %scicos_context;
        execstr("[ok,"+tt+",exprs]=scicos_getvalue(btitre,bitems,ss,exprs)")
        if ok then
            x=arg1;
            %scicos_context = scicos_context;
            sblock=x.model.rpar;
            [sblock,%w,needcompile2,ok]=do_eval(sblock,list(),scicos_context);
            y=max(2,needcompile,needcompile2)
            x.graphics.exprs(1)=exprs;
            x.model.rpar=sblock;
        else
            x = arg1;
        end

    case "define" then
        // never used
    end
endfunction