* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Sinks / CANIMXY.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]=CANIMXY(job,arg1,arg2)
23     //Scicos 2D animated visualization block
24     x=[];
25     y=[];
26     typ=[];
27     select job
28     case "set" then
29         x=arg1;
30         graphics=arg1.graphics;
31         exprs=graphics.exprs
32         model=arg1.model;
33         //dstate=model.dstate
34
35         while %t do
36             [ok,nbr_curves,clrs,siz,win,wpos,wdim,xmin,xmax,ymin,ymax,N,exprs]=scicos_getvalue(..
37             msprintf(_("Set %s block parameters"), "CANIMXY Scope"),..
38             [_("Number of Curves");
39             _("Curves styles: Colors>0 | marks<0");
40             _("Curves thicknesses | marks sizes");
41             _("Output window number (-1 for automatic)");
42             _("Output window position");
43             _("Output window sizes");
44             "Xmin";
45             "Xmax";
46             "Ymin";
47             "Ymax";
48             _("Buffer size")],..
49             list("vec",1,"vec",1,"vec",1,"vec",1,"vec",-1,"vec",-1,"vec",1,..
50             "vec",1,"vec",1,"vec",1,"vec",1),exprs)
51             if ~ok then
52                 break,
53             end //user cancel modification
54
55             mess = []
56             if size(wpos,"*")<>0 &size(wpos,"*")<>2 then
57                 mess=[mess ; _("''Window position'' must be [] or a 2 vector") ; " "]
58             end
59             if size(wdim,"*")<>0 &size(wdim,"*")<>2 then
60                 mess=[mess ; _("''Window sizes'' must be [] or a 2 vector") ; " "]
61             end
62             if win<-1 then
63                 mess=[mess ; _("The Window number must be >= -1") ; " "]
64             end
65             if nbr_curves<=0 then
66                 mess=[mess ; _("The Number of curves must be >= 1") ; " "]
67             end
68             if N<1 then
69                 mess=[mess ; _("The Buffer size must be >= 1") ; " "]
70             end
71             if N==1 & clrs>0 then
72                 mess=[mess ; _("The Buffer size must be >= 2") ; " "]
73             end
74             if ymin>=ymax then
75                 mess=[mess ; _("Ymax > Ymin is required") ; " "]
76             end
77             if xmin>=xmax then
78                 mess=[mess ; _("Xmax > Xmin is required.") ; " "]
79             end
80             if mess <> [] then
81                 message(mess)
82             else
83                 in = nbr_curves*ones(2,1);
84                 in2 = ones(2,1);
85                 [model,graphics,ok]=set_io(model,graphics,list([in in2],ones(2,1)),list(),ones(1,1),[]);
86                 if wpos==[] then
87                     wpos=[-1;-1];
88                 end
89                 if wdim==[] then
90                     wdim=[-1;-1];
91                 end
92                 rpar=[xmin;xmax;ymin;ymax]
93                 ipar=[win;1;N;clrs;siz;0;wpos(:);wdim(:);nbr_curves]
94                 //if prod(size(dstate))<>2*N+1 then dstate=zeros(2*N+1,1),end
95                 //model.dstate=dstate;
96                 model.rpar=rpar;
97                 model.ipar=ipar
98                 graphics.exprs=exprs;
99                 x.graphics=graphics;
100                 x.model=model
101                 break
102             end
103         end
104
105     case "define" then
106         win=-1;
107         clrs=-4;
108         N=2;
109         siz=1;
110         wpos=[-1;-1];
111         wdim=[-1;-1];
112         xmin=-15;
113         xmax=15;
114         ymin=-15;
115         ymax=+15
116         nbr_curves = 1;
117
118         model=scicos_model()
119         model.sim=list("canimxy",4)
120         model.in=[1;1]
121         model.in2=[1;1]
122         model.intyp=[1;1]
123         model.evtin=1
124         model.rpar=[xmin;xmax;ymin;ymax]
125         model.ipar=[win;1;N;clrs;siz;0;wpos(:);wdim(:);nbr_curves]
126         model.blocktype="d"
127         model.firing=[]
128         model.dep_ut=[%f %f]
129
130         exprs=[string(nbr_curves);
131         string(clrs);
132         string(siz);
133         string(win);
134         "[]";
135         "[]";
136         string(xmin);
137         string(xmax);
138         string(ymin);
139         string(ymax);
140         string(N)]
141         gr_i=[]
142         x=standard_define([2 2],model,exprs,gr_i)
143     end
144 endfunction