~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/Sinks/CMSCOPE.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [x,y,typ]=CMSCOPE(job,arg1,arg2)
 
2
// Copyright INRIA
 
3
x=[];y=[];typ=[]
 
4
select job
 
5
case 'plot' then
 
6
  standard_draw(arg1)
 
7
case 'getinputs' then
 
8
  [x,y,typ]=standard_inputs(o)
 
9
case 'getoutputs' then
 
10
  x=[];y=[];typ=[];
 
11
case 'getorigin' then
 
12
  [x,y]=standard_origin(arg1)
 
13
case 'set' then
 
14
  x=arg1;
 
15
  graphics=arg1.graphics;exprs=graphics.exprs
 
16
  if size(exprs)<11 then exprs(11)=emptystr(),end // compatibility
 
17
  model=arg1.model;
 
18
  dstate=model.in
 
19
  while %t do
 
20
    [ok,in,clrs,win,wpos,wdim,ymin,ymax,per,N,heritance,nom,exprs]=getvalue(..
 
21
        'Set Scope parameters',..
 
22
        ['Input ports sizes';
 
23
        'Drawing colors (>0) or mark (<0)';
 
24
        'Output window number';
 
25
        'Output window position';
 
26
        'Output window sizes';
 
27
        'Ymin vector';
 
28
        'Ymax vector';
 
29
        'Refresh period';
 
30
        'Buffer size';
 
31
        'Accept herited events 0/1'
 
32
        'Name of Scope (label&Id)'],..
 
33
         list('vec',-1,'vec',-1,'vec',1,'vec',-1,'vec',-1,..
 
34
         'vec','size(%1,''*'')','vec','size(%1,''*'')','vec',1,..
 
35
         'vec',1,'vec',1,'str',1),exprs)
 
36
    if ~ok then break,end //user cancel modification
 
37
    mess=[]
 
38
    if size(in,'*')<=0 then
 
39
      mess=[mess;'Block must have at least one input port';' ']
 
40
      ok=%f
 
41
    end
 
42
    if mini(in)<=0 then
 
43
      mess=[mess;'Port sizes must be positive';' ']
 
44
      ok=%f
 
45
    end
 
46
    if size(clrs,'*')<sum(in) then 
 
47
      mess=[mess;'Not enough colors defined (at least '+string(sum(in))+')';' ']
 
48
      ok=%f
 
49
    end
 
50
    if size(wpos,'*')<>0 &size(wpos,'*')<>2 then
 
51
      mess=[mess;'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 dim must be [] or a 2 vector';' ']
 
56
      ok=%f
 
57
    end
 
58
    if win<-1 then
 
59
      mess=[mess;'Window number can''t be  < -1';' ']
 
60
      ok=%f
 
61
    end
 
62
    if per<=0 then
 
63
      mess=[mess;'Refresh period must be positive';' ']
 
64
      ok=%f
 
65
    end
 
66
    if N<2 then
 
67
      mess=[mess;'Buffer size must be at least 2';' ']
 
68
      ok=%f
 
69
    end
 
70
    if or(ymin>=ymax) then
 
71
      mess=[mess;'Ymax must be greater than Ymin';' ']
 
72
      ok=%f
 
73
    end
 
74
    if ~or(heritance==[0 1]) then
 
75
      mess=[mess;'Accept herited events must be 0 or 1';' ']
 
76
      ok=%f
 
77
    end
 
78
    if ~ok then
 
79
      message(['Some specified values are inconsistent:';
 
80
                 ' ';mess])
 
81
    end
 
82
    if ok then
 
83
      [model,graphics,ok]=check_io(model,graphics,in,[],ones(1-heritance,1),[])
 
84
    end
 
85
    if ok then
 
86
      if wpos==[] then wpos=[-1;-1];end
 
87
      if wdim==[] then wdim=[-1;-1];end
 
88
      if ok then
 
89
        yy=[ymin(:)';ymax(:)']
 
90
        rpar=[0;per;yy(:)]
 
91
        clrs=clrs(1:sum(in))
 
92
        ipar=[win;size(in,'*');N;wpos(:);wdim(:);in(:);clrs(:);heritance]
 
93
        if prod(size(dstate))<>(sum(in)+1)*N+1 then 
 
94
          dstate=-eye((sum(in)+1)*N+1,1),
 
95
        end
 
96
        model.evtin=ones(1-heritance,1)
 
97
        model.dstate=dstate;model.rpar=rpar;model.ipar=ipar
 
98
        model.label=nom;
 
99
        graphics.id=nom;
 
100
        graphics.exprs=exprs;
 
101
        x.graphics=graphics;x.model=model
 
102
        break
 
103
      end
 
104
    end
 
105
  end
 
106
case 'define' then
 
107
  win=1;
 
108
  in=[1;1]
 
109
  wdim=[-1;-1]
 
110
  wpos=[-1;-1]
 
111
  clrs=[1;3;5;7;9;11;13;15];
 
112
  N=2;
 
113
 
 
114
  ymin=[-1;-5];ymax=[1;5];per=30;
 
115
  yy=[ymin(:)';ymax(:)']
 
116
 
 
117
  model=scicos_model()
 
118
  model.sim=list('cmscope',4)
 
119
  model.in=in
 
120
  model.evtin=1
 
121
  model.rpar=[0;per;yy(:)]
 
122
  model.ipar=[win;size(in,'*');N;wpos(:);wdim(:);in(:);clrs(1:sum(in))]
 
123
  model.blocktype='c'
 
124
  model.dep_ut=[%t %f]
 
125
  
 
126
  exprs=[strcat(string(in),' ');
 
127
         strcat(string(clrs),' ');
 
128
         string(win);
 
129
         sci2exp([]);
 
130
         sci2exp([]);
 
131
         strcat(string(ymin),' ');
 
132
         strcat(string(ymax),' ');
 
133
         string(per);
 
134
         string(N);
 
135
         string(0);
 
136
         emptystr()];
 
137
   gr_i='xstringb(orig(1),orig(2),''MScope'',sz(1),sz(2),''fill'')'
 
138
   x=standard_define([2 2],model,exprs,gr_i)
 
139
end
 
140
endfunction