* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Sinks / CFSCOPE.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]=CFSCOPE(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
32         model=arg1.model;
33         //dstate=model.in
34         while %t do
35             [ok,clrs,win,wpos,wdim,ymin,ymax,per,N,wu,exprs]=scicos_getvalue(..
36             msprintf(_("Set %s block parameters"), "Floating SCOPE"),..
37              _(["Curves styles: Colors>0 | marks<0";
38                 "Output window number (-1 for automatic)";
39                 "Output window position";
40                 "Output window sizes";
41                 "Ymin";
42                 "Ymax";
43                 "Refresh period";
44                 "Buffer size";
45                 "Links to view"]),..
46             list("vec",8,"vec",1,"vec",-1,"vec",-1,"vec",1,..
47             "vec",1,"vec",1,"vec",1,"vec",-1),..
48             exprs)
49             if ~ok then
50                 break,
51             end //user cancel modification
52             mess=[]
53             if size(wpos,"*")<>0 &size(wpos,"*")<>2 then
54                 mess=[mess ; _("''Window position'' must be [] or a 2 vector");" "]
55                 ok=%f
56             end
57             if size(wdim,"*")<>0 &size(wdim,"*")<>2 then
58                 mess=[mess ; _("''Window sizes'' must be [] or a 2 vector");" "]
59                 ok=%f
60             end
61             if win<-1 then
62                 mess=[mess ; _("''Window number'' must be >= -1") ; " "]
63                 ok=%f
64             end
65             if per<=0 then
66                 mess=[mess ; _("The Refresh period must be > 0") ; " "]
67                 ok=%f
68             end
69             if N<2 then
70                 mess=[mess ; _("The Buffer size must be >= 2") ; " "]
71                 ok=%f
72             end
73             if ymin>=ymax then
74                 mess=[mess ; _("Ymax > Ymin is required.") ; " "]
75                 ok=%f
76             end
77             if wu<0 then
78                 mess=[mess ; _("Link to view must be positive") ; " "]
79                 ok=%f
80             end
81             if ~ok then
82                 message([_("Some specified values are inconsistent:");
83                         " " ; mess])
84             end
85             if ok then
86                 if wpos==[] then
87                     wpos=[-1;-1];
88                 end
89                 if wdim==[] then
90                     wdim=[-1;-1];
91                 end
92                 rpar=[0;ymin;ymax;per]
93                 if size(clrs,"*")>8 then
94                     clrs=clrs(1:8);
95                 end
96                 if size(clrs,"*")<8 then
97                     clrs(8)=0;
98                 end
99                 ipar=[win;1;N;clrs(:);wpos(:);wdim(:);size(wu,"*");wu(:)]
100                 //if prod(size(dstate))<>(8+1)*N+1 then dstate=-eye((8+1)*N+1,1),end
101                 //model.dstate=dstate;
102                 model.rpar=rpar;
103                 model.ipar=ipar
104                 model.firing=[] //compatibility
105                 model.dep_ut=[%t %f] //compatibility
106                 graphics.exprs=exprs;
107                 x.graphics=graphics;
108                 x.model=model
109                 break
110             end
111         end
112     case "define" then
113         win=-1;
114         wdim=[600;400]
115         wpos=[-1;-1]
116         clrs=[1;3;5;7;9;11;13;15];
117         N=2;
118         ymin=-15;
119         ymax=+15;
120         per=30;
121         model=scicos_model()
122         model.sim=list("cfscope",4)
123         model.evtin=1
124         model.rpar=[0;ymin;ymax;per]
125         model.ipar=[win;1;N;clrs;wpos;wdim;1;1]
126         model.blocktype="c"
127         model.dep_ut=[%t %f]
128
129         exprs=[strcat(string(clrs)," ");
130         string(win);
131         sci2exp([]);
132         sci2exp(wdim);
133         string(ymin);
134         string(ymax);
135         string(per);
136         string(N);
137         string([1])];
138         gr_i=[]
139         x=standard_define([2 2],model,exprs,gr_i)
140     end
141 endfunction