Revert "Xcos: Bug #9995 fixed - The RELATION_OP box drawn."
[scilab.git] / scilab / modules / scicos_blocks / macros / Misc / RELATIONALOP.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] = RELATIONALOP(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         if size(exprs,1)==2 then
33             exprs=[exprs;sci2exp(1)];
34         end
35         while %t do
36             [ok,rule,zcr,Datatype,exprs]=scicos_getvalue("Set parameters",..
37             ["Operator: == (0), ~= (1), < (2), <= (3), > (4), >= (5)";..
38             "Use zero crossing (no: 0), (yes: 1)"
39             "Datatype (1=double 3=int32 ...)"],..
40             list("vec",1,"vec",1,"vec",1),exprs)
41             if ~ok then
42                 break,
43             end
44             rule=int(rule);
45             if zcr<>0 then
46                 zcr=1,
47             end
48             if (rule<0)|(rule>5) then
49                 message("Incorrect operator "+string(rule)+" ; must be 0 to 5.")
50             end
51             if (Datatype==1) then
52                 model.sim=list("relational_op",4)
53             elseif (Datatype==3|Datatype==9) then
54                 model.sim=list("relational_op_i32",4)
55             elseif(Datatype==4) then
56                 model.sim=list("relational_op_i16",4)
57             elseif(Datatype==5) then
58                 model.sim=list("relational_op_i8",4)
59             elseif(Datatype==6) then
60                 model.sim=list("relational_op_ui32",4)
61             elseif(Datatype==7) then
62                 model.sim=list("relational_op_ui16",4)
63             elseif(Datatype==8) then
64                 model.sim=list("relational_op_ui8",4)
65             else
66                 message("Datatype is not supported");
67                 ok=%f;
68             end
69             if ok then
70                 it=Datatype*ones(1,2)
71                 ot=Datatype
72                 in=[-1 -2;-1 -2]
73                 out=[-1 -2]
74                 [model,graphics,ok]=set_io(model,graphics,list(in,it),list(out,ot),[],[])
75             end
76             if ok then
77                 graphics.exprs=exprs;
78                 model.ipar=[rule],
79                 model.nzcross=zcr,
80                 model.nmode=zcr,
81                 x.graphics=graphics;
82                 x.model=model
83                 break
84             end
85         end
86     case "define" then
87         ipar=[2]
88         model=scicos_model()
89         model.sim=list("relationalop",4)
90         model.in=[1;1]
91         model.out=1
92         model.ipar=ipar
93         model.blocktype="c"
94         model.dep_ut=[%t %f]
95
96         exprs=[string(ipar);string(0)]
97         gr_i=[]
98         x=standard_define([3 2],model,exprs,gr_i)
99     end
100 endfunction