* Bug 16320 fixed: typos in blocks interfaces + a few files
[scilab.git] / scilab / modules / scicos_blocks / macros / Sinks / CSCOPE.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]=CSCOPE(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,heritance,nom,exprs]=scicos_getvalue(..
36             msprintf(_("Set %s block parameters"), "CSCOPE"),..
37             [_("Curve style: Color>0 | mark<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             _("Accept herited events 0/1");
46             _("Name of Scope (label&Id)")],..
47             list("vec",8,"vec",1,"vec",-1,"vec",-1,"vec",1,..
48             "vec",1,"vec",1,"vec",1,"vec",1,"str",1),..
49             exprs)
50             if ~ok then
51                 break,
52             end //user cancel modification
53             mess=[]
54             if size(wpos,"*")<>0 &size(wpos,"*")<>2 then
55                 mess=[mess ; _("''Window position'' must be [] or a 2 vector") ; " "]
56             end
57             if size(wdim,"*")<>0 &size(wdim,"*")<>2 then
58                 mess=[mess ; _("''Window sizes'' must be [] or a 2 vector") ; " "]
59             end
60             if win<-1 then
61                 mess=[mess ; _("The Window number must be >= -1") ; " "]
62             end
63             if per<=0 then
64                 mess=[mess ; _("The Refresh period must be > 0") ; " "]
65             end
66             if N<2 then
67                 mess=[mess ; _("The Buffer size must be >= 2") ; " "]
68             end
69             if ymin>=ymax then
70                 mess=[mess ; _("Ymax > Ymin is required") ; " "]
71             end
72             if ~or(heritance==[0 1]) then
73                 mess=[mess ; _("''Accept herited events'' must be 0 or 1") ; " "]
74             end
75             if mess<>[] then
76                 message([_("Some specified values are inconsistent:") ;
77                          " " ; mess])
78             else
79                 [model,graphics,ok]=set_io(model,graphics,list([-1 1],1),list(),ones(1-heritance,1),[])
80                 if wpos==[] then
81                     wpos=[-1;-1];
82                 end
83                 if wdim==[] then
84                     wdim=[-1;-1];
85                 end
86                 rpar=[0;ymin;ymax;per]
87                 ipar=[win;1;N;clrs(:);wpos(:);wdim(:)]
88                 //if prod(size(dstate))<>(8+1)*N+1 then dstate=-eye((8+1)*N+1,1),end
89                 //model.dstate=[];
90                 model.rpar=rpar;
91                 model.ipar=ipar
92                 model.evtin=ones(1-heritance,1)
93                 model.label=nom;
94                 graphics.id=nom
95                 graphics.exprs=exprs;
96                 x.graphics=graphics;
97                 x.model=model
98                 break
99             end
100         end
101
102     case "define" then
103         win=-1;
104         wdim=[600;400]
105         wpos=[-1;-1]
106         clrs=[1;3;5;7;9;11;13;15];
107         N=20;
108         ymin=-15;
109         ymax=+15;
110         per=30;
111
112         model=scicos_model()
113         model.sim=list("cscope",4)
114         model.in=-1
115         model.in2=1
116         model.evtin=1
117         model.rpar=[0;ymin;ymax;per]
118         model.ipar=[win;1;N;clrs;wpos;wdim]
119         model.blocktype="c"
120         model.dep_ut=[%t %f]
121
122         exprs=[strcat(string(clrs)," ");
123         string(win);
124         sci2exp([]);
125         sci2exp(wdim);
126         string(ymin);
127         string(ymax);
128         string(per);
129         string(N);
130         string(0)';
131         emptystr()]; //label-id
132         gr_i=[]
133         x=standard_define([2 2],model,exprs,gr_i)
134     end
135 endfunction