summaryrefslogtreecommitdiff
path: root/js/Sinks/AFFICH_m.js
blob: e0c9e793c9c4870aee95ca04787901ad1fe0bf80 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* autogenerated from "macros/Sinks/AFFICH_m.sci" */
function AFFICH_m() {
    AFFICH_m.prototype.define = function AFFICH_m() {
        this.font = 1;
        this.fontsize = 1;
        this.colr = 1;
        this.nt = 5;
        this.nd = 1;
        this.in = [1,1];
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["affich2"]), new ScilabDouble([4]));
        this.model.in = new ScilabDouble([this.in[1-1][1-1]]);
        this.model.in2 = new ScilabDouble([this.in[1-1][2-1]]);
        this.model.evtin = new ScilabDouble([1]);
        this.model.dstate = new ScilabDouble([-1],[0],[0],[1],[1],[0],[zeros(this.in[1-1][1-1]*this.in[1-1][2-1],1)]);
        this.model.ipar = new ScilabDouble([this.font],[this.fontsize],[this.colr],[1000],[this.nt],[this.nd],[this.in[1-1][1-1]]);
        this.model.blocktype = new ScilabString(["c"]);
        this.model.firing = new ScilabDouble([]);
        this.model.dep_ut = new ScilabBoolean([true,false]);
        this.model.label = new ScilabString([""]);
        var exprs = [[sci2exp([this.model.in,this.model.in2])],[string(this.font)],[string(this.fontsize)],[string(this.colr)],[string(this.nt)],[string(this.nd)],[string(0)]];
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"AFFICH_m\",sz(1),sz(2));"]);
        this.x = new standard_define(new ScilabDouble([3,2]),this.model,new ScilabDouble(exprs),gr_i);
        return new AfficheBlock(this.x);
    }
    AFFICH_m.prototype.details = function AFFICH_m() {
        return this.x;
    }
    AFFICH_m.prototype.get = function AFFICH_m() {
        var exprs = this.graphics.exprs;
        this.set_param_popup_title = "Set  parameters";
        var options = {
            in:["Input Size",this.in],
            font:["Font number",this.font],
            fontsize:["Font size",this.fontsize],
            colr:["Color",this.colr],
            nt:["Total number of digits",this.nt],
            nd:["Number of rational part digits",this.nd],
            herit:["Block inherits (1) or not (0)",this.herit],
        }
        return options;
    }
    AFFICH_m.prototype.set = function AFFICH_m() {
        var exprs = this.graphics.exprs;
        while (true) {
            var ok = true;
            this.in = inverse(arguments[0]["in"]);
            this.font = parseFloat(arguments[0]["font"]);
            this.fontsize = parseFloat(arguments[0]["fontsize"]);
            this.colr = parseFloat(arguments[0]["colr"]);
            this.nt = parseFloat(arguments[0]["nt"]);
            this.nd = parseFloat(arguments[0]["nd"]);
            this.herit = arguments[0]["herit"];
            var exprs = [arguments[0]["in"], arguments[0]["font"], arguments[0]["fontsize"], arguments[0]["colr"], arguments[0]["nt"], arguments[0]["nd"], arguments[0]["herit"]];
            if (!ok) {
                break;
            }
            var mess = [];
            if (this.font<=0) {
                var mess = [[mess],["Font number must be positive"],[" "]];
                var ok = false;
            }
            if (this.fontsize<=0) {
                var mess = [[mess],["Font size must be positive"],[" "]];
                var ok = false;
            }
            if (this.nt<=3) {
                var mess = [[mess],["Total number of digits must be greater than 3"],[" "]];
                var ok = false;
            }
            if (this.nd<0) {
                var mess = [[mess],["Number of rational part digits must be ","greater or equal 0"],[" "]];
                var ok = false;
            }
            if (!ok) {
                message([["Some specified values are inconsistent:"],[" "],[mess]]);
                throw "user error";
            }
            if (!or(this.herit==[0,1])) {
                var mess = [[mess],["Accept inherited values are 0 and 1"],[" "]];
                var ok = false;
            }
            if (!ok) {
                message([["Some specified values are inconsistent:"],[" "],[mess]]);
                throw "user error";
            }
            if (ok) {
                var tmpvar0 = set_io(this.model,this.graphics,list(this.in,1),list(),ones(1-this.herit,1),[]);
                this.model = tmpvar0[0];
                this.graphics = tmpvar0[1];
                var ok = tmpvar0[2];
            }
            if (ok) {
                this.model.ipar = new ScilabDouble([this.font],[this.fontsize],[this.colr],[this.nt],[this.nd],[this.in[1-1][1-1]]);
                this.model.dstate = new ScilabDouble([-1],[0],[0],[1],[1],[0],[zeros(this.in[1-1][1-1]*this.in[1-1][2-1],1)]);
                this.model.evtin = new ScilabDouble([ones(1-this.herit,1)]);
                this.graphics.exprs = new ScilabDouble([exprs]);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new AfficheBlock(this.x);
    }
    AFFICH_m.prototype.get_popup_title = function AFFICH_m() {
        return this.set_param_popup_title;
    }
    AFFICH_m.prototype.importset = function AFFICH_m() {
        var graphics = this.x.graphics;
        var ary = getData(graphics.exprs);
        this.in = ary[0];
        this.font = ary[1];
        this.fontsize = ary[2];
        this.colr = ary[3];
        this.nt = ary[4];
        this.nd = ary[5];
        this.herit = ary[6];
    }
    AFFICH_m.prototype.getContainer = function AFFICH_m() { return new AfficheBlock(this.x); }
}