// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2002-2004 - INRIA - Vincent COUVERT
-//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
+// Copyright (C) 2020 - Samuel GOUGEON
//
// This file is hereby licensed under the terms of the GNU GPL v2.0,
// pursuant to article 5.3.4 of the CeCILL v.2.1.
// For more information, see the COPYING file which you should have received
// along with this program.
-function tree=sci_axis(tree)
+function tree = sci_axis(tree)
// M2SCI function
// Conversion function for Matlab axis()
// Input: tree = Matlab funcall tree
// Ouput: tree = Scilab equivalent for tree
- // Insert %v0=gca()
- a=Funcall("gca",1,list(),list())
-
- if rhs>0 then
- for krhs=1:rhs
- if tree.rhs(krhs).vtype==Double then
-
- // axis([xmin xmax ymin ymax])
- // axis([xmin xmax ymin ymax zmin zmax])
- if or(tree.rhs(krhs).dims(2)==[4,6]) then
- mat=Funcall("matrix",1,list(tree.rhs(krhs),Cste(2),Cste(-1)),list())
- tree=Funcall("set",1,Rhs_tlist(a,"data_bounds",mat),tree.lhs)
-
- // axis([xmin xmax ymin ymax zmin zmax cmin cmax])
- elseif tree.rhs(krhs).dims(2)==8 then
- no_equiv(expression2code(tree))
-
- // Unknown column number for tree.rhs(krhs)
- else
- tree.name="mtlb_axis"
- end
- elseif tree.rhs(krhs).vtype==String then
+ ax = Funcall("gca",1,list(),list())
- // Option is a character string
- if typeof(tree.rhs(krhs))=="cste" then
+ i = 1
+ if rhs > 0 then
+ if tree.rhs(1).vtype==Handle // The first argin is the target
+ ax = tree.rhs(1)
+ if typeof(ax) <> "variable"
+ ax = gettempvar()
+ m2sci_insert(Equal(list(ax), tree.rhs(1)))
+ end
+ i = 2
+ end
+ end
+ if rhs==(i-1) then
+ // v = axis
+ tree = Funcall("get",1,Rhs_tlist(ax,"data_bounds"),tree.lhs)
+ tree.lhs(1).dims = list(2,Unknown)
+ tree.lhs(1).type = Type(Double,Real)
+ return
+ end
- // axis auto
- if tree.rhs(krhs).value=="auto" then
- tree=Funcall("set",1,Rhs_tlist(a,"auto_scale","on"),tree.lhs)
+ keepInputSyntax = %f
+ for krhs = i:rhs
+ if tree.rhs(krhs).vtype==Double then
- // axis manual
- elseif tree.rhs(krhs).value=="manual" then
- tree=Funcall("set",1,Rhs_tlist(a,"auto_scale","off"),tree.lhs)
+ // axis([xmin xmax ymin ymax])
+ // axis([xmin xmax ymin ymax zmin zmax])
+ if or(tree.rhs(krhs).dims(2)==[4,6]) then
+ mat = Funcall("matrix",1,list(tree.rhs(krhs),Cste(2),Cste(-1)),list())
+ LHS = Operation("ins", list(ax,Cste("data_bounds")), list())
+ m2sci_insert(Equal(list(LHS), tree.rhs(krhs)))
- // axis tight
- elseif tree.rhs(krhs).value=="tight" then
- tree=Funcall("set",1,Rhs_tlist(a,"tight_limits","on"),tree.lhs)
+ // axis([xmin xmax ymin ymax zmin zmax cmin cmax])
+ elseif tree.rhs(krhs).dims(2)==8 then
+ no_equiv(expression2code(tree))
+ keepInputSyntax = %t
- // axis fill
- elseif tree.rhs(krhs).value=="fill" then
- no_equiv(expression2code(tree))
+ // Unknown column number for tree.rhs(krhs)
+ else
+ tree.name = "mtlb_axis"
+ keepInputSyntax = %t
+ end
+ elseif tree.rhs(krhs).vtype==String then
- // axis ij
- elseif tree.rhs(krhs).value=="ij" then
- mat=Operation("cc",list(Cste(180),Cste(270)),list())
- tree=Funcall("set",1,Rhs_tlist(a,"rotation_angles",mat),tree.lhs)
+ // Option is a character string
+ if typeof(tree.rhs(krhs))=="cste" then
- // axis xy
- elseif tree.rhs(krhs).value=="xy" then
- mat=Operation("cc",list(Cste(0),Cste(270)),list())
- tree=Funcall("set",1,Rhs_tlist(a,"rotation_angles",mat),tree.lhs)
+ // axis auto
+ if tree.rhs(krhs).value=="auto" then
+ LHS = Operation("ins", list(ax,Cste("auto_scale")), list())
+ m2sci_insert(Equal(list(LHS), Cste("on")))
- // axis equal
- elseif tree.rhs(krhs).value=="equal" then
- tree=Funcall("set",1,Rhs_tlist(a,"isoview","on"),tree.lhs)
+ // axis manual
+ elseif tree.rhs(krhs).value=="manual" then
+ LHS = Operation("ins", list(ax,Cste("auto_scale")), list())
+ m2sci_insert(Equal(list(LHS), Cste("off")))
- // axis image
- elseif tree.rhs(krhs).value=="image" then
- no_equiv(expression2code(tree))
+ // axis tight
+ elseif tree.rhs(krhs).value=="tight" then
+ LHS = Operation("ins", list(ax,Cste("tight_limits")), list())
+ m2sci_insert(Equal(list(LHS), Cste("on")))
- // axis square
- elseif tree.rhs(krhs).value=="square" then
- set_infos(gettext("cube_scaling only used in 3d mode."),2);
- tree=Funcall("set",1,Rhs_tlist(a,"cube_scaling","on"),tree.lhs)
+ // axis fill
+ elseif tree.rhs(krhs).value=="fill" then
+ no_equiv(expression2code(tree))
+ keepInputSyntax = %t
- // axis vis3d
- elseif tree.rhs(krhs).value=="vis3d" then
- tree=Funcall("set",1,Rhs_tlist(a,"view","3d"),tree.lhs)
+ // axis ij
+ elseif tree.rhs(krhs).value=="ij" then
+ axis_ij_xy(ax, Cste("on")) // sets .axes_reverse(2)="on"
- // axis normal
- elseif tree.rhs(krhs).value=="normal" then
- no_equiv(expression2code(tree))
+ // axis xy
+ elseif tree.rhs(krhs).value=="xy" then
+ axis_ij_xy(ax, Cste("off")) // sets .axes_reverse(2)="off"
- // axis on
- elseif tree.rhs(krhs).value=="on" then
- tree=Funcall("set",1,Rhs_tlist(a,"axes_visible","on"),tree.lhs)
+ // axis equal
+ elseif tree.rhs(krhs).value=="equal" then
+ LHS = Operation("ins", list(ax,Cste("isoview")), list())
+ m2sci_insert(Equal(list(LHS), Cste("on")))
- // axis off
- elseif tree.rhs(krhs).value=="off" then
- tree=Funcall("set",1,Rhs_tlist(a,"axes_visible","off"),tree.lhs)
+ // axis image
+ elseif tree.rhs(krhs).value=="image" then
+ no_equiv(expression2code(tree))
+ keepInputSyntax = %t
- // [mode,visibility,direction] = axis('state')
- elseif tree.rhs(krhs).value=="state" then
- tree.name="mtlb_axis"
+ // axis square
+ elseif tree.rhs(krhs).value=="square" then
+ set_infos(gettext("cube_scaling only used in 3d mode."),2);
+ LHS = Operation("ins", list(ax,Cste("cube_scaling")), list())
+ m2sci_insert(Equal(list(LHS), Cste("on")))
- // Unknown character string
- else
- tree.name="mtlb_axis"
- end
+ // axis vis3d
+ elseif tree.rhs(krhs).value=="vis3d" then
+ LHS = Operation("ins", list(ax,Cste("view")), list())
+ m2sci_insert(Equal(list(LHS), Cste("3d")))
- // Option is a variable
+ // axis normal
+ elseif tree.rhs(krhs).value=="normal" then
+ no_equiv(expression2code(tree))
+ keepInputSyntax = %t
+
+ // axis on
+ elseif tree.rhs(krhs).value=="on" then
+ LHS = Operation("ins", list(ax,Cste("axes_visible")), list())
+ m2sci_insert(Equal(list(LHS), Cste("on")))
+
+ // axis off
+ elseif tree.rhs(krhs).value=="off" then
+ LHS = Operation("ins", list(ax,Cste("axes_visible")), list())
+ m2sci_insert(Equal(list(LHS), Cste("off")))
+
+ // [mode,visibility,direction] = axis('state')
+ elseif tree.rhs(krhs).value=="state" then
+ tree.name = "mtlb_axis"
+ keepInputSyntax = %t
+ // Unknown character string
else
- tree.name="mtlb_axis"
+ tree.name = "mtlb_axis"
+ keepInputSyntax = %t
end
- // axis(axes_handles,...)
- elseif tree.rhs(krhs).vtype==Handle then
- no_equiv(expression2code(tree))
-
- // Unknown type for tree.rhs(krhs)
+ // Option is a variable
else
- tree.name="mtlb_axis"
+ tree.name = "mtlb_axis"
+ keepInputSyntax = %t
end
+
+ // axis(axes_handles,...)
+ elseif tree.rhs(krhs).vtype==Handle then
+ no_equiv(expression2code(tree))
+ keepInputSyntax = %t
+
+ // Unknown type for tree.rhs(krhs)
+ else
+ tree.name = "mtlb_axis"
+ keepInputSyntax = %t
end
- // v = axis
+ end
+ if ~keepInputSyntax then
+ tree = list()
+ end
+endfunction
+
+function axis_ij_xy(ax, value)
+ if typeof(ax) <> "variable" | is_a_scalar(ax) // gca()
+ LHS = Operation("ins", list(ax,Cste("axes_reverse")), list())
+ LHS = Operation("ins", list(LHS,Cste(2)), list())
+ m2sci_insert(Equal(list(LHS), value))
else
- tree=Funcall("set",1,Rhs_tlist(a,"data_bounds"),tree.lhs)
- tree.lhs(1).dims=list(2,Unknown)
- tree.lhs(1).type=Type(Double,Real)
+ // handles(:) : (because .axes_reverse is a row)
+ LHS = Operation("ins", list(ax,Colon), list())
+ // handles(:).axes_reverse :
+ LHS = Operation("ins", list(LHS,Cste("axes_reverse")), list())
+ // handles(:).axes_reverse(:,2) :
+ LHS = Operation("ins", list(LHS,Colon,Cste(2)), list())
+ m2sci_insert(Equal(list(LHS), value))
end
endfunction
Syntax modification: Done
Macro to tree conversion...
Conversion of M-tree...
- !! L.11: No Scilab equivalent for: axis([xmin,xmax,ymin,ymax,zmin,zmax,cmin,cmax])
- L.12: Unknown variable axis is a M-file.
- L.14: Unknown variable axis is a M-file.
- L.15: Unknown variable axis is a M-file.
- L.16: Unknown variable axis is a M-file.
- L.17: Unknown variable axis is a M-file.
- !! L.17: No Scilab equivalent for: axis("fill")
- L.19: Unknown variable axis is a M-file.
- L.20: Unknown variable axis is a M-file.
- L.22: Unknown variable axis is a M-file.
- L.23: Unknown variable axis is a M-file.
- !! L.23: No Scilab equivalent for: axis("image")
- L.24: Unknown variable axis is a M-file.
- !! L.24: cube_scaling only used in 3d mode.
- L.25: Unknown variable axis is a M-file.
- L.26: Unknown variable axis is a M-file.
- !! L.26: No Scilab equivalent for: axis("normal")
- L.28: Unknown variable axis is a M-file.
- L.29: Unknown variable axis is a M-file.
- L.34: Unknown variable axis is a M-file.
- !! L.34: No Scilab equivalent for: axis([h1,h2],"auto")
- L.35: Unknown variable axis is a M-file.
- L.37: Unknown variable axis is a M-file.
+ !! L.12: No Scilab equivalent for: axis([xmin,xmax,ymin,ymax,zmin,zmax,cmin,cmax])
+ L.13: Unknown variable axis is a M-file.
+ !! L.18: No Scilab equivalent for: axis("fill")
+ !! L.24: No Scilab equivalent for: axis("image")
+ !! L.25: cube_scaling only used in 3d mode.
+ !! L.27: No Scilab equivalent for: axis("normal")
+ !! L.42: cube_scaling only used in 3d mode.
Conversion of M-tree: Done
TESTING M2SCI: creating varslist file...
Macro to tree conversion: Done
Translation may be wrong (see the //!! comments).
****** End of mfile2sci() session ******
-
// Test file for function axis()
// Copyright INRIA
// Matlab version: 6.5.1.199709 (R13) Service Pack 1
// V.C.
-
+// Copyright 2020 - Samuel GOUGEON
xmin = 1;
ymin = 1;
zmin = 1;
ymax = 10;
zmax = 10;
cmax = 10;
-
-set(gca(),"data_bounds",matrix([xmin,xmax,ymin,ymax],2,-1))
-set(gca(),"data_bounds",matrix([xmin,xmax,ymin,ymax,zmin,zmax],2,-1))
+gca().data_bounds = [xmin,xmax,ymin,ymax];
+gca().data_bounds = [xmin,xmax,ymin,ymax,zmin,zmax];
axis([xmin,xmax,ymin,ymax,zmin,zmax,cmin,cmax])
-v = set(gca(),"data_bounds")
-
-set(gca(),"auto_scale","on")
-set(gca(),"auto_scale","off")
-set(gca(),"tight_limits","on")
+v = get(gca(),"data_bounds");
+gca().auto_scale = "on";
+gca().auto_scale = "off";
+gca().tight_limits = "on";
axis("fill")
-
-set(gca(),"rotation_angles",[180;270])
-set(gca(),"rotation_angles",[0;270])
-
-set(gca(),"isoview","on")
+gca().axes_reverse(2) = "on";
+gca().axes_reverse(2) = "off";
+gca().isoview = "on";
axis("image")
-set(gca(),"cube_scaling","on")
-set(gca(),"view","3d")
+gca().cube_scaling = "on";
+gca().view = "3d";
axis("normal")
-
-set(gca(),"axes_visible","off")
-set(gca(),"axes_visible","on")
-
-
-set(gca(),"auto_scale","on")
+gca().axes_visible = "off";
+gca().axes_visible = "on";
+h1.isoview = "on";
+h1.axes_reverse(2) = "on";
+h1.axes_reverse(2) = "off";
+%v0 = [h1,h2];
+%v0.auto_scale = "on";
+%v0 = [h1,h2];
+%v0(:).axes_reverse(:,2) = "on";
+%v0(:).axes_reverse(:,2) = "off";
[mode,visibility,direction] = mtlb_axis("state")
-
-set(gca(),"axes_visible","on")
+gca().auto_scale = "on";
+gca().cube_scaling = "on";
+gca().tight_limits = "on";
+h2.auto_scale = "off";
+h2.data_bounds = [xmin,xmax,ymin,ymax];