summaryrefslogtreecommitdiff
path: root/js/Misc/BOUNCEXY.js
blob: fd4b12229ddb9c078fa99679ff69c67166d0d52c (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
/* autogenerated from "macros/Misc/BOUNCEXY.sci" */
function BOUNCEXY() {
    BOUNCEXY.prototype.define = function BOUNCEXY() {
        this.win = -1;
        this.imode = 1;
        this.clrs = [[1],[2]];
        this.siz = [[1],[1]];
        this.xmin = -5;
        this.xmax = 5;
        this.ymin = 0;
        this.ymax = 15;
        this.model = scicos_model();
        this.model.sim = list(new ScilabString(["bouncexy"]), new ScilabDouble([4]));
        this.model.in1 = new ScilabDouble([-1],[-1]);
        this.model.in2 = new ScilabDouble([1],[1]);
        this.model.intyp = new ScilabDouble([1],[1]);
        this.model.evtin = new ScilabDouble([1]);
        var z = [];
        for (i=1;i<=size(this.clrs,"*");i+=1) {
            z[6*(i-1)+1-1] = 0;
            z[6*(i-1)+2-1] = 0;
            z[6*(i-1)+3-1] = 2*this.siz[i-1];
            z[6*(i-1)+4-1] = 2*this.siz[i-1];
            z[6*(i-1)+5-1] = 0.000;
            z[6*(i-1)+6-1] = 64.0*360.000;
        }
        this.model.dstate = new ScilabDouble(z);
        this.model.rpar = new ScilabDouble([this.xmin],[this.xmax],[this.ymin],[this.ymax]);
        this.model.ipar = new ScilabDouble([this.win],[this.imode],[this.clrs.slice()]);
        this.model.blocktype = new ScilabString(["d"]);
        this.model.firing = new ScilabDouble([]);
        this.model.dep_ut = new ScilabDouble([false,false]);
        var exprs = [[strcat(sci2exp(this.clrs))],[strcat(sci2exp(this.siz))],[strcat(sci2exp(this.win))],[strcat(sci2exp(1))],[strcat(sci2exp(this.xmin))],[strcat(sci2exp(this.xmax))],[strcat(sci2exp(this.ymin))],[strcat(sci2exp(this.ymax))]];
        var gr_i = new ScilabString(["xstringb(orig(1),orig(2),\"BOUNCEXY\",sz(1),sz(2));"]);
        this.x = standard_define([2,2],this.model,exprs,gr_i);
        return new BasicBlock(this.x);
    }
    BOUNCEXY.prototype.details = function BOUNCEXY() {
        return this.x;
    }
    BOUNCEXY.prototype.get = function BOUNCEXY() {
        var options = {
            clrs:["colors",this.clrs.toString().replace(/,/g," ")],
            siz:["radii",this.siz.toString().replace(/,/g," ")],
            win:["window number (-1 for automatic)",this.win],
            imode:["animation mode (0,1)",this.imode],
            xmin:["Xmin",this.xmin],
            xmax:["Xmax",this.xmax],
            ymin:["Ymin",this.ymin],
            ymax:["Ymax",this.ymax],
        }
        return options;
    }
    BOUNCEXY.prototype.set = function BOUNCEXY() {
        this.clrs = inverse(arguments[0]["clrs"])
        this.siz = inverse(arguments[0]["siz"])
        this.win = parseFloat(arguments[0]["win"])
        this.imode = parseFloat(arguments[0]["imode"])
        this.xmin = parseFloat(arguments[0]["xmin"])
        this.xmax = parseFloat(arguments[0]["xmax"])
        this.ymin = parseFloat(arguments[0]["ymin"])
        this.ymax = parseFloat(arguments[0]["ymax"])
        this.x = arg1;
        this.graphics = arg1.graphics;
        var exprs = this.graphics.exprs;
        this.model = arg1.model;
        var dstate = this.model.dstate;
        while (true) {
            [ok,this.clrs,this.siz,this.win,this.imode,this.xmin,this.xmax,this.ymin,this.ymax,exprs] = scicos_getvalue("Set Scope parameters",["colors","radii","window number (-1 for automatic)","animation mode (0,1)","Xmin","Xmax","Ymin","Ymax"],list("vec",-1,"vec",-1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1),exprs);
            if (!ok) {
                break;
            }
            var mess = [];
            if (size(this.clrs,"*")!=size(this.siz,"*")) {
                var mess = [[mess],["colors and radii must have equal size (number of balls)"],[" "]];
                var ok = false;
            }
            if (this.win<-1) {
                var mess = [[mess],["Window number cannot be inferior than -1"],[" "]];
                var ok = false;
            }
            if (this.ymin>=this.ymax) {
                var mess = [[mess],["Ymax must be greater than Ymin"],[" "]];
                var ok = false;
            }
            if (this.xmin>=this.xmax) {
                var mess = [[mess],["Xmax must be greater than Xmin"],[" "]];
                var ok = false;
            }
            if (!ok) {
                message(mess);
            } else {
                var rpar = [[this.xmin],[this.xmax],[this.ymin],[this.ymax]];
                var ipar = [[this.win],[this.imode],[this.clrs.slice()]];
                var z = [];
                for (i=1;i<=size(this.clrs,"*");i+=1) {
                    z[6*(i-1)+1-1] = 0;
                    z[6*(i-1)+2-1] = 0;
                    z[6*(i-1)+3-1] = 2*this.siz[i-1];
                    z[6*(i-1)+4-1] = 2*this.siz[i-1];
                    z[6*(i-1)+5-1] = 0.000;
                    z[6*(i-1)+6-1] = 64.0*360.000;
                }
                this.model.dstate = new ScilabDouble(z);
                this.model.rpar = new ScilabDouble(rpar);
                this.model.ipar = new ScilabDouble(ipar);
                this.graphics.exprs = new ScilabDouble([exprs]);
                this.x.graphics = this.graphics;
                this.x.model = this.model;
                break;
            }
        }
        return new BasicBlock(this.x);
    }
}