* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Sinks / CEVENTSCOPE.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]=CEVENTSCOPE(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         model=arg1.model;
32         while %t do
33             [ok,nclock,clrs,win,wpos,wdim,per,exprs]=scicos_getvalue(..
34             msprintf(_("Set %s block parameters"), "CEVENT SCOPE"), ..
35              _(["Number of event inputs";
36                 "Curves styles: Colors>0 | marks<0";
37                 "Output window number (-1 for automatic)";
38                 "Output window position";
39                 "Output window sizes";
40                 "Refresh period"]),..
41             list("vec",1,"vec",-1,"vec",1,"vec",-1,"vec",-1,"vec",1),exprs);
42             nclock=int(nclock)
43             clrs=int(clrs)
44             win=int(win)
45
46             if ~ok then
47                 break,
48             end //user cancel modification
49             mess=[]
50             if size(wpos,"*")<>0 &size(wpos,"*")<>2 then
51                 mess=[mess ; _("The Window position must be [] or a 2 vector") ; " "]
52                 ok=%f
53             end
54             if size(wdim,"*")<>0 &size(wdim,"*")<>2 then
55                 mess=[mess ; _("''Window sizes'' must be [] or a 2 vector") ; " "]
56                 ok=%f
57             end
58             if nclock<=0 then
59                 mess=[mess ; _("The block must have at least one input event") ; " "]
60                 ok=%f
61             end
62             if size(clrs,"*")<>nclock then
63                 mess=[mess ;
64                       _("The number of curves styles must match the Number of inputs");
65                       " "]
66                 ok=%f
67             end
68             if win<-1 then
69                 mess=[mess ; _("The Window number must be >= -1") ; " "]
70                 ok=%f
71             end
72             if per<=0 then
73                 mess=[mess ; _("The Refresh period must be > 0") ; " "]
74                 ok=%f
75             end
76             if ok then
77                 [model,graphics,ok] = set_io(model,graphics,list(),list(),ones(nclock,1),[])
78             else
79                 message([_("Some specified values are inconsistent:") ;
80                          " " ; mess])
81             end
82             if ok then
83                 if wpos==[] then
84                     wpos=[-1;-1];
85                 end
86                 if wdim==[] then
87                     wdim=[-1;-1];
88                 end
89                 rpar=per
90                 ipar=[win;1;clrs(:);wpos(:);wdim(:)]
91                 model.rpar=rpar;
92                 model.ipar=ipar
93                 graphics.exprs=exprs;
94                 x.graphics=graphics;
95                 x.model=model
96                 break
97             end
98         end
99
100     case "define" then
101         nclock=1
102         win=-1;
103         clrs=[1;3;5;7;9;11;13;15];
104         wdim=[600;400]
105         wpos=[-1;-1]
106         per=30;
107
108         model=scicos_model()
109         model.sim=list("cevscpe",4)
110         model.evtin=1
111         model.rpar=per
112         model.ipar=[win;1;clrs(nclock);wpos(:);wdim(:)]
113         model.blocktype="d"
114         model.dep_ut=[%f %f]
115
116         exprs=[sci2exp(nclock);
117         strcat(sci2exp(clrs(nclock))," ");
118         string(win);
119         sci2exp([]);
120         sci2exp(wdim);
121         string(per)]
122         gr_i=[]
123         x=standard_define([2 2],model,exprs,gr_i)
124     end
125 endfunction