cfbf07702f25f452512386a3895abd89d6a0a6f2
[scilab.git] / scilab / modules / scicos_blocks / macros / NonLinear / PROD_f.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]=PROD_f(job,arg1,arg2)
23     x=[];y=[];typ=[];
24     p=1 //pixel sizes ratio
25     select job
26         //**-----------------------------------------------------------------------
27     case "plot" then
28         wd = xget("wdim")
29         graphics = arg1.graphics;
30         orig = graphics.orig,
31         sz = graphics.sz
32         orient = graphics.flip
33         thick = xget("thickness");xset("thickness",2)
34         //** patt=xget('dashes');xset('dashes',default_color(1))
35         rx = sz(1)*p/2
36         ry = sz(2)/2
37         xarc(orig(1),orig(2)+sz(2),sz(1)*p,sz(2),0,23040) // (23040=360*64)
38         gh_temp = gce();
39         gh_temp.foreground = default_color(1);
40
41         t=%pi/4
42         xx=(orig(1)+rx)+..
43         [sin(5*t) , sin(-t);
44         sin(t) ,   sin(3*t)]*diag([rx;rx]/1.7)
45         yy=(orig(2)+ry)+..
46         [cos(5*t) , cos(-t);
47         cos(t) ,   cos(3*t)]*diag([ry;ry]/1.7)
48         xsegs(xx,yy,0)
49         gh_temp = gce();
50         gh_temp.segs_color = [default_color(1), default_color(1)] ;
51
52         xset("thickness",1)
53         if orient then  //standard orientation (port)
54             out= [0  -1/14
55             1/7    0
56             0   1/14]*3
57             xfpoly(sz(1)*out(:,1)+ones(3,1)*(orig(1)+sz(1)*p),sz(2)*out(:,2)+ones(3,1)*(orig(2)+sz(2)/2),1);
58             gh_temp = gce();
59             gh_temp.foreground = default_color(1);
60             gh_temp.background = default_color(1);
61         else //tilded orientation
62             out= [0   -1/14
63             -1/7    0
64             0   1/14]*3
65             xfpoly(sz(1)*out(:,1)+ones(3,1)*orig(1),sz(2)*out(:,2)+ones(3,1)*(orig(2)+sz(2)/2),1);
66             gh_temp = gce();
67             gh_temp.foreground = default_color(1);
68             gh_temp.background = default_color(1);
69         end
70         //** xset('dashes',patt)
71         //**-------------------------------------------------------------------------------------------
72     case "getinputs" then
73         graphics=arg1.graphics
74         orig=graphics.orig
75         sz=graphics.sz
76         orient=graphics.flip
77
78         wd=xget("wdim");
79         if orient then
80             t=[%pi -%pi/2]
81         else
82             t=[%pi %pi/2]
83         end
84         r=sz(2)/2
85         rx=r*p
86         x=(rx*sin(t)+(orig(1)+rx)*ones(t))
87         y=r*cos(t)+(orig(2)+r)*ones(t)
88         typ=ones(x)
89     case "getoutputs" then
90         graphics=arg1.graphics;
91         orig=graphics.orig,
92         sz=graphics.sz
93         orient=graphics.flip
94         wd=xget("wdim");
95         if orient then
96             t=%pi/2
97             dx=sz(1)/7
98         else
99             t=-%pi/2
100             dx=-sz(1)/7
101         end
102         r=sz(2)/2
103         rx=r*p
104         x=(rx*sin(t)+(orig(1)+rx)*ones(t))+dx
105         y=r*cos(t)+(orig(2)+r)*ones(t)
106         typ=ones(x)
107     case "getorigin" then
108         [x,y]=standard_origin(arg1)
109     case "set" then
110         x=arg1;
111     case "define" then
112         model=scicos_model()
113         model.sim=list("prod",2)
114         model.in=[-1;-1]
115         model.out=-1
116         model.blocktype="c"
117         model.dep_ut=[%t %f]
118
119         x=standard_define([1 1],model,[],[])
120     end
121 endfunction