f1f1052e070b3032ab3a66fed1d9aaea6afad85a
[scilab.git] / scilab / modules / m2sci / macros / sci_files / sci_axis.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13 function tree=sci_axis(tree)
14     // M2SCI function
15     // Conversion function for Matlab axis()
16     // Input: tree = Matlab funcall tree
17     // Ouput: tree = Scilab equivalent for tree
18
19     // Insert %v0=gca()
20     a=Funcall("gca",1,list(),list())
21
22     if rhs>0 then
23         for krhs=1:rhs
24             if tree.rhs(krhs).vtype==Double then
25
26                 // axis([xmin xmax ymin ymax])
27                 // axis([xmin xmax ymin ymax zmin zmax])
28                 if or(tree.rhs(krhs).dims(2)==[4,6]) then
29                     mat=Funcall("matrix",1,list(tree.rhs(krhs),Cste(2),Cste(-1)),list())
30                     tree=Funcall("set",1,Rhs_tlist(a,"data_bounds",mat),tree.lhs)
31
32                     // axis([xmin xmax ymin ymax zmin zmax cmin cmax])
33                 elseif tree.rhs(krhs).dims(2)==8 then
34                     no_equiv(expression2code(tree))
35
36                     // Unknown column number for tree.rhs(krhs)
37                 else
38                     tree.name="mtlb_axis"
39                 end
40             elseif tree.rhs(krhs).vtype==String then
41
42                 // Option is a character string
43                 if typeof(tree.rhs(krhs))=="cste" then
44
45                     // axis auto
46                     if tree.rhs(krhs).value=="auto" then
47                         tree=Funcall("set",1,Rhs_tlist(a,"auto_scale","on"),tree.lhs)
48
49                         // axis manual
50                     elseif tree.rhs(krhs).value=="manual" then
51                         tree=Funcall("set",1,Rhs_tlist(a,"auto_scale","off"),tree.lhs)
52
53                         // axis tight
54                     elseif tree.rhs(krhs).value=="tight" then
55                         tree=Funcall("set",1,Rhs_tlist(a,"tight_limits","on"),tree.lhs)
56
57                         // axis fill
58                     elseif tree.rhs(krhs).value=="fill" then
59                         no_equiv(expression2code(tree))
60
61                         // axis ij
62                     elseif tree.rhs(krhs).value=="ij" then
63                         mat=Operation("cc",list(Cste(180),Cste(270)),list())
64                         tree=Funcall("set",1,Rhs_tlist(a,"rotation_angles",mat),tree.lhs)
65
66                         // axis xy
67                     elseif tree.rhs(krhs).value=="xy" then
68                         mat=Operation("cc",list(Cste(0),Cste(270)),list())
69                         tree=Funcall("set",1,Rhs_tlist(a,"rotation_angles",mat),tree.lhs)
70
71                         // axis equal
72                     elseif tree.rhs(krhs).value=="equal" then
73                         tree=Funcall("set",1,Rhs_tlist(a,"isoview","on"),tree.lhs)
74
75                         // axis image
76                     elseif tree.rhs(krhs).value=="image" then
77                         no_equiv(expression2code(tree))
78
79                         // axis square
80                     elseif tree.rhs(krhs).value=="square" then
81                         set_infos(gettext("cube_scaling only used in 3d mode."),2);
82                         tree=Funcall("set",1,Rhs_tlist(a,"cube_scaling","on"),tree.lhs)
83
84                         // axis vis3d
85                     elseif tree.rhs(krhs).value=="vis3d" then
86                         tree=Funcall("set",1,Rhs_tlist(a,"view","3d"),tree.lhs)
87
88                         // axis normal
89                     elseif tree.rhs(krhs).value=="normal" then
90                         no_equiv(expression2code(tree))
91
92                         // axis on
93                     elseif tree.rhs(krhs).value=="on" then
94                         tree=Funcall("set",1,Rhs_tlist(a,"axes_visible","on"),tree.lhs)
95
96                         // axis off
97                     elseif tree.rhs(krhs).value=="off" then
98                         tree=Funcall("set",1,Rhs_tlist(a,"axes_visible","off"),tree.lhs)
99
100                         // [mode,visibility,direction] = axis('state')
101                     elseif tree.rhs(krhs).value=="state" then
102                         tree.name="mtlb_axis"
103
104                         // Unknown character string
105                     else
106                         tree.name="mtlb_axis"
107                     end
108
109                     // Option is a variable
110                 else
111                     tree.name="mtlb_axis"
112                 end
113
114                 // axis(axes_handles,...)
115             elseif tree.rhs(krhs).vtype==Handle then
116                 no_equiv(expression2code(tree))
117
118                 // Unknown type for tree.rhs(krhs)
119             else
120                 tree.name="mtlb_axis"
121             end
122         end
123         // v = axis
124     else
125         tree=Funcall("set",1,Rhs_tlist(a,"data_bounds"),tree.lhs)
126         tree.lhs(1).dims=list(2,Unknown)
127         tree.lhs(1).type=Type(Double,Real)
128     end
129 endfunction