File: sd2sci.sci

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (156 lines) | stat: -rw-r--r-- 4,701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at    
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

function txt=sd2sci(sd,zoom,orig)
[lhs,rhs]=argn(0);
if rhs<1 then
   error(msprintf(gettext("%s: Wrong number of input argument(s): At least %d expected.\n"), "sd2sci", 1));
end
[l,mac]=where()
scsmode=find(mac=='scicos')<>[]
[lhs,rhs]=argn(0)
pat=33
thick=1
fnt=[2 1]
dash=33
symb=[0 0]
if sd(1)<>'sd' then
   error(msprintf(gettext("%s: Wrong type for input argument #%d.\n"), "sd2sci", 1));
end
if rhs<3 then orig=['0';'0'],end
if type(orig)==1 then orig=string(orig),end
if rhs<2 then zoom=['1';'1'],end
if type(zoom)==1 then zoom=string(zoom),end
if size(zoom,'*')==1 then zoom(2)=zoom(1),end
rect=sd(2)
xmx=rect(3);ymx=rect(4)
dx=abs(rect(3)-rect(1));dx=10^(-log(dx/100)/log(10))*10
dy=abs(rect(4)-rect(2));dy=10^(-log(dy/100)/log(10))*10
dxy=maxi(dx,dy)
txt=[]
txt='xsetech([0 0 1 1],'+sci2exp(sd(2))+')'
for k=3:size(sd)
  o=sd(k)
  if type(o)==15 then
    select o(1)
    case 'rect' then
      [x1,x2,y1,y2]=o(2:5)
      x1=round(dx*x1)/dx
      x2=round(dx*x2)/dx
      y1=round(dy*y1)/dy
      y2=round(dy*y2)/dy
      xi=string(mini(x1,x2));
      w=string(abs(x1-x2));
      yi=string(max(y1,y2));
      h=string(abs(y1-y2));
      txt=[txt;'xrect('+strcat([zsx(xi),zsy(yi),zx(w),zy(h)],',')+');']
    case 'frect' then
      [x1,x2,y1,y2]=o(2:5)
      x1=round(dx*x1)/dx
      x2=round(dx*x2)/dx
      y1=round(dy*y1)/dy
      y2=round(dy*y2)/dy
      xi=string(mini(x1,x2));
      w=string(abs(x1-x2));
      yi=string(max(y1,y2));
      h=string(abs(y1-y2));
      Color=string(pat)
      if scsmode then Color='scs_color('+Color+')',end
      txt=[txt;'xrects(['+strcat([zsx(xi),zsy(yi),zx(w),zy(h)],';')+'],'+Color+');']  
    case 'fleche' then
      x=round(dx*o(2))/dx;y=round(dy*o(3))/dy
      txt=[txt;'xarrows('+zsx(sci2exp(x))+','+zsy(sci2exp(y))+',-1,-1);']
    case 'ligne' then
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;'xpoly('+x+','+y+',""lines"");']
    case 'cercle' then
      c=o(2);r=round(dxy*o(3))/dxy
      c1=round(dx*c(1))/dx
      c2=round(dy*c(2))/dy
      xx=zsx(string(c1-r))
      yy=zsy(string(c2+r))
      rx=zx(string(2*r))
      ry=zy(string(2*r))
      txt=[txt;'xarc('+strcat([xx,yy,rx,ry,'0','64*360'],',')+');']
    case 'fcercle' then
      c=o(2);r=round(dxy*o(3))/dxy
      c1=round(dx*c(1))/dx
      c2=round(dy*c(2))/dy
      xx=zsx(string(c1-r))
      yy=zsy(string(c2+r))
      rx=zx(string(2*r))
      ry=zy(string(2*r))
      txt=[txt;'xfarc('+strcat([xx,yy,rx,ry,'0','64*360'],',')+');']      
    case 'comm' then
      z=o(2)
      com=sci2exp(o(3))
      x=zsx(string(round(dx*z(1))/dx))
      y=zsy(string(round(dy*z(2))/dy))
      txt=[txt;'xstring('+strcat([x,y,com,'0,0'],',')+');']
    case 'patts' then
      Color=string(o(2))
      if scsmode then Color='scs_color('+Color+')',end
      txt=[txt;'xset(''pattern'','+Color+')']
      pat=o(2)
    case 'thick' then
      txt=[txt;'xset(''thickness'','+string(o(2))+')']  
      thick=o(2)
    case 'symbs' then
      txt=[txt;'xset(''mark'','+string(o(2))+','+string(o(3))+')']
      symb=[o(2),o(3)]
    case 'dashs' then
      Color=string(o(2))
      if scsmode then Color='scs_color('+Color+')',end
      txt=[txt;'xset(''dashes'','+Color+')']
      dash=o(2)
    case 'fligne' then
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;
	  'xpoly('+x+','+y+',''lines'')';
	  'xfpoly('+x+','+y+',1)'];
    case 'points' then 
      z=o(2)';
      x=zsx(strcat(sci2exp(round(dx*z(:,1))/dx)))
      y=zsy(strcat(sci2exp(round(dy*z(:,2))/dy)))
      txt=[txt;
	  'xpoly('+x+','+y+',""marks"")'];
    case "clipon" then
      txt=[txt;"axes = gca()"; "axes.clip_state = ''clipgrf''"]
    case "clipoff" then
      txt=[txt;"axes = gca()"; "axes.clip_state = ''off''"]     
    else

    end
  end
  
end
endfunction
function t=zx(t)
if zoom(1)<>'1' then t($)=mulf(t($),zoom(1)),end



endfunction
function t=zy(t)
if zoom(2)<>'1' then t($)=mulf(t($),zoom(2)),end


endfunction
function t=zsx(t)
if zoom(1)<>'1' then t($)=mulf(t($),zoom(1)),end
if orig(1)<>'0' then t(1)=addf(orig(1),t(1)),end

endfunction
function t=zsy(t)
if zoom(2)<>'1' then t($)=mulf(t($),zoom(2)),end
if orig(2)<>'0' then t(1)=addf(orig(2),t(1)),end
endfunction