diff options
3 files changed, 208 insertions, 155 deletions
diff --git a/scilab/modules/scicos/macros/scicos_scicos/ExportAll_.sci b/scilab/modules/scicos/macros/scicos_scicos/ExportAll_.sci index d76e5ad..076381f 100644 --- a/scilab/modules/scicos/macros/scicos_scicos/ExportAll_.sci +++ b/scilab/modules/scicos/macros/scicos_scicos/ExportAll_.sci | |||
@@ -21,138 +21,137 @@ | |||
21 | 21 | ||
22 | function ExportAll_() | 22 | function ExportAll_() |
23 | 23 | ||
24 | Cmenu = [] | 24 | Cmenu = [] |
25 | 25 | ||
26 | %exp_dir = tk_getdirectory() | 26 | // Select output directory |
27 | %exp_dir = tk_getdirectory() | ||
27 | 28 | ||
28 | if %exp_dir<>[] then | 29 | if ~isempty(%exp_dir) then |
29 | systexport(scs_m,%exp_dir), | ||
30 | if MSDOS then | ||
31 | fname=%exp_dir+'\'+'navigator' | ||
32 | else | ||
33 | fname=%exp_dir+'/'+'navigator' | ||
34 | end | ||
35 | 30 | ||
36 | if 0 then | 31 | systexport(scs_m, %exp_dir) |
37 | driv=driver(); | ||
38 | driver('Pos'); | ||
39 | set_posfig_dim(400,600) | ||
40 | xinit(fname); | ||
41 | else | ||
42 | win_nag=max(winsid())+1 | ||
43 | scf(win_nag) | ||
44 | end | ||
45 | |||
46 | gh_axes=gca(); | ||
47 | |||
48 | |||
49 | gh_navig = gcf() | ||
50 | |||
51 | y0 = 0 ; | ||
52 | x0 = 0 ; | ||
53 | path = [] ; | ||
54 | larg = 0 ; | ||
55 | [xx, yy, lp] = build_scs_tree(scs_m); | ||
56 | |||
57 | |||
58 | n_node = size(lp) ; | ||
59 | mnx = min(xx)-0.1 ; | ||
60 | mxx = max(xx)+0.1 ; | ||
61 | |||
62 | if n_node<=20 then | ||
63 | dx = (mxx-mnx) | ||
64 | mnx = mnx-dx/5 | ||
65 | x0 = [mnx,mnx+dx/5] | ||
66 | else | ||
67 | dx = (mxx-mnx) ; | ||
68 | mnx = mnx-dx/2 ; | ||
69 | x0 = [mnx,mnx+dx/4,mnx+dx/2] ; | ||
70 | end | ||
71 | |||
72 | //** axes settings | ||
73 | gh_navig_axes = gh_navig.children ; //** axes handle | ||
74 | gh_navig_axes.tight_limits = "on" ; //** set the limit "gh_axes.data_bounds" in "hard mode" | ||
75 | |||
76 | arect =[ 0.125 0.125 0.125 0.125 ]; //** margins (default normalized values) | ||
77 | gh_navig_axes.margins = arect ; //** | ||
78 | |||
79 | wrect = [-1/6 -1/6 8/6 8/6] ; | ||
80 | gh_navig_axes.axes_bounds = wrect ; //** default : axes_bounds = [0,0 , 1,1] = [xmin ymin with height] | ||
81 | |||
82 | //** map the diagram size on the window size | ||
83 | //** (1,1) (1,2) (2,1) (2,2) | ||
84 | bnds = [mnx, min(yy)-0.2 ; mxx, max(yy)+0.2]; | ||
85 | gh_navig_axes.data_bounds = bnds ; //** default : data_bounds = [0,0 ; 1,1] = [xmin ymin ; xmax ymax ] | ||
86 | |||
87 | // draw tree | ||
88 | xsegs(xx,yy,1) ; //** draw unconnected segments | ||
89 | |||
90 | xx = [xx(1,1);xx(2,:)'] ; | ||
91 | yy = [yy(1,1);yy(2,:)'] ; | ||
92 | |||
93 | plot2d(xx,yy,-9,'000') ; | ||
94 | |||
95 | xtitle('Navigator window') ; | ||
96 | |||
97 | for k=1 : size(xx,1) | ||
98 | xstring( xx(k), yy(k), string(k) ) ; | ||
99 | end | ||
100 | |||
101 | r = xstringl(x0(1),y0,'X') ; | ||
102 | h = r(4) ; | ||
103 | y0 = bnds(2,2)-h ; | ||
104 | kx = 1 ; | ||
105 | |||
106 | xrect(x0(kx), bnds(2,2), x0(kx+1)-x0(kx), bnds(2,2)-bnds(1,2)); | ||
107 | |||
108 | for k=1:size(xx,1) | ||
109 | |||
110 | if k==1 then path=[]; else path=lp(k-1);end | ||
111 | Path=list(); | ||
112 | 32 | ||
113 | for pk=path | 33 | fname = fullfile(%exp_dir, 'navigator') |
114 | Path=lstcat(Path,'objs',pk,'model','rpar'); | 34 | |
35 | // SC5: win_nag = scf() | ||
36 | if 0 then | ||
37 | driv = driver() | ||
38 | driver('Pos') | ||
39 | set_posfig_dim(400, 600) | ||
40 | xinit(fname) | ||
41 | else | ||
42 | win_nag = max(winsid()) + 1 | ||
43 | scf(win_nag) | ||
115 | end | 44 | end |
116 | 45 | ||
117 | Path = lstcat(Path,'props','title',1); | 46 | win_nag = scf() |
118 | 47 | ||
119 | xstring(x0(kx),y0,string(k)+': '+scs_m(Path)) ; | 48 | gh_axes = gca() |
120 | 49 | gh_navig = gcf() | |
121 | y0=y0-h; | 50 | |
122 | 51 | y0 = 0 | |
123 | if k==20 then | 52 | x0 = 0 |
124 | y0 = bnds(2,2)-h; | 53 | path = [] |
125 | kx = kx+1 | 54 | larg = 0 |
126 | xrect(x0(kx),bnds(2,2),x0(kx+1)-x0(kx),bnds(2,2)-bnds(1,2)) | 55 | [xx, yy, lp] = build_scs_tree(scs_m) |
56 | |||
57 | n_node = size(lp) | ||
58 | mnx = min(xx)-0.1 | ||
59 | mxx = max(xx)+0.1 | ||
60 | |||
61 | if n_node <= 20 then | ||
62 | dx = (mxx - mnx) | ||
63 | mnx = mnx - dx/5 | ||
64 | x0 = [mnx, mnx + dx/5] | ||
65 | else | ||
66 | dx = (mxx - mnx) | ||
67 | mnx = mnx - dx/2 | ||
68 | x0 = [mnx, mnx + dx/4, mnx + dx/2] | ||
127 | end | 69 | end |
128 | |||
129 | end | ||
130 | drawnow() | ||
131 | 70 | ||
71 | //** axes settings | ||
72 | gh_navig_axes = gh_navig.children //** axes handle | ||
73 | gh_navig_axes.tight_limits = "on" //** set the limit "gh_axes.data_bounds" in "hard mode" | ||
132 | 74 | ||
133 | if 0 then | 75 | arect = [ 0.125 0.125 0.125 0.125 ] //** margins (default normalized values) |
134 | xend(); | 76 | gh_navig_axes.margins = arect |
135 | set_posfig_dim(0,0) | 77 | |
136 | driver(driv); | 78 | wrect = [ -1/6 -1/6 8/6 8/6 ] |
137 | fname=pathconvert(fname,%f,%t,'w') | 79 | gh_navig_axes.axes_bounds = wrect //** default : axes_bounds = [0 0 1 1] = [xmin ymin with height] |
138 | else | 80 | |
139 | if MSDOS then | 81 | //** map the diagram size on the window size |
140 | fname=pathconvert(fname,%f,%t,'w') | 82 | //** (1,1) (1,2) (2,1) (2,2) |
141 | end | 83 | bnds = [mnx, min(yy)-0.2 ; mxx, max(yy)+0.2] |
142 | xs2ps(win_nag,fname) | 84 | gh_navig_axes.data_bounds = bnds //** default : data_bounds = [0 0 ; 1 1] = [xmin ymin ; xmax ymax] |
143 | xdel(win_nag) | 85 | |
144 | end | 86 | // draw tree |
145 | 87 | xsegs(xx, yy, 1) //** draw unconnected segments | |
146 | opt=' ';//' -landscape ' | 88 | |
147 | if MSDOS then | 89 | xx = [xx(1,1) ; xx(2,:)'] |
148 | comm=pathconvert(SCI+'\bin\BEpsf',%f,%f,'w') | 90 | yy = [yy(1,1) ; yy(2,:)'] |
149 | rep=unix_g(comm+' '+opt+'""'+fname+'""') | 91 | |
150 | else | 92 | plot2d(xx, yy, -9, '000') |
151 | rep=unix_g(SCI+'/bin/BEpsf '+opt+fname) | 93 | |
152 | end | 94 | xtitle('Navigator window') |
153 | 95 | ||
154 | if rep<>[] then | 96 | for k = 1:size(xx,1) |
155 | message(['Problem generating ps file.';'perhaps directory not writable'] ) | 97 | xstring(xx(k), yy(k), string(k)) |
98 | end | ||
99 | |||
100 | r = xstringl(x0(1), y0, 'X') | ||
101 | h = r(4) | ||
102 | y0 = bnds(2,2) - h | ||
103 | kx = 1 | ||
104 | |||
105 | xrect(x0(kx), bnds(2,2), x0(kx+1) - x0(kx), bnds(2,2) - bnds(1,2)) | ||
106 | |||
107 | for k = 1:size(xx,1) | ||
108 | |||
109 | if k == 1 then | ||
110 | path = [] | ||
111 | else | ||
112 | path = lp(k-1) | ||
113 | end | ||
114 | |||
115 | Path = list() | ||
116 | |||
117 | for pk = path | ||
118 | Path = lstcat(Path,'objs',pk,'model','rpar') | ||
119 | end | ||
120 | |||
121 | Path = lstcat(Path,'props','title',1) | ||
122 | |||
123 | xstring(x0(kx), y0, string(k) + ': ' + scs_m(Path)) | ||
124 | |||
125 | y0 = y0 - h | ||
126 | |||
127 | if k == 20 then | ||
128 | y0 = bnds(2,2) - h | ||
129 | kx = kx + 1 | ||
130 | xrect(x0(kx), bnds(2,2), x0(kx+1) - x0(kx), bnds(2,2) - bnds(1,2)) | ||
131 | end | ||
132 | |||
133 | end | ||
134 | |||
135 | drawnow() | ||
136 | |||
137 | if 0 then | ||
138 | xend() | ||
139 | set_posfig_dim(0,0) | ||
140 | driver(driv) | ||
141 | fname = pathconvert(fname, %f, %t, 'w') | ||
142 | else | ||
143 | if MSDOS then | ||
144 | fname = pathconvert(fname, %f, %t, 'w') | ||
145 | end | ||
146 | // Capture in landscape mode | ||
147 | try | ||
148 | xs2eps(win_nag.figure_id, fname, 'landscape') | ||
149 | catch | ||
150 | disp(lasterror()) | ||
151 | end | ||
152 | delete(win_nag) | ||
153 | end | ||
156 | end | 154 | end |
157 | end | 155 | |
158 | endfunction | 156 | endfunction |
157 | |||
diff --git a/scilab/modules/scicos/macros/scicos_scicos/do_export.sci b/scilab/modules/scicos/macros/scicos_scicos/do_export.sci index 4001380..ed0c65e 100644 --- a/scilab/modules/scicos/macros/scicos_scicos/do_export.sci +++ b/scilab/modules/scicos/macros/scicos_scicos/do_export.sci | |||
@@ -19,57 +19,94 @@ | |||
19 | // See the file ../license.txt | 19 | // See the file ../license.txt |
20 | // | 20 | // |
21 | 21 | ||
22 | function [wa,ha] = do_export(scs_m, fname, titleflag) | 22 | function [wa,ha] = do_export(scs_m, fname, titleflag) |
23 | //** default call inside Export_.sci | 23 | //** default call inside Export_.sci |
24 | //** | 24 | //** |
25 | //** do_export(scs_m) ; | 25 | //** do_export(scs_m) ; |
26 | //** | 26 | //** |
27 | //** rhs := 1 | 27 | //** rhs := 1 |
28 | // titleflag:0 or 1 (place or not place title in eps file) | 28 | // titleflag:0 or 1 (place or not place title in eps file) |
29 | // used only with fname | 29 | // used only with fname |
30 | 30 | ||
31 | |||
32 | |||
31 | [lhs, rhs] = argn(0) ; //** verify the presence of tha arguments | 33 | [lhs, rhs] = argn(0) ; //** verify the presence of tha arguments |
32 | 34 | ||
33 | if rhs<3 then //** if no "titleflag" is specified | 35 | if rhs<3 then //** if no "titleflag" is specified |
34 | titleflag = 0 | 36 | titleflag = 0 |
35 | end | 37 | end |
36 | 38 | ||
37 | rect = dig_bound(scs_m); | 39 | rect = dig_bound(scs_m); |
38 | if rect==[] then | 40 | if rect==[] then |
39 | return //** empty diagram | 41 | return //** empty diagram |
40 | end | 42 | end |
41 | |||
42 | wa = (rect(3)-rect(1)) | 43 | wa = (rect(3)-rect(1)) |
43 | ha = (rect(4)-rect(2)) | 44 | ha = (rect(4)-rect(2)) |
44 | 45 | ||
45 | if ~exists('%scicos_lr_margin') then %scicos_lr_margin=.1;end | 46 | if ~exists('%scicos_lr_margin') then %scicos_lr_margin=.1;end |
46 | if ~exists('%scicos_ud_margin') then %scicos_ud_margin=.1;end | 47 | if ~exists('%scicos_ud_margin') then %scicos_ud_margin=.1;end |
47 | 48 | ||
48 | rect(1)=rect(1)-wa*%scicos_lr_margin | 49 | rect(1)=rect(1)-wa*%scicos_lr_margin |
49 | rect(3)=rect(3)+wa*%scicos_lr_margin | 50 | rect(3)=rect(3)+wa*%scicos_lr_margin |
50 | rect(2)=rect(2)-ha*%scicos_ud_margin | 51 | rect(2)=rect(2)-ha*%scicos_ud_margin |
51 | rect(4)=rect(4)+ha*%scicos_ud_margin | 52 | rect(4)=rect(4)+ha*%scicos_ud_margin |
52 | 53 | ||
53 | wa = (rect(3)-rect(1)) ; //** geometrical correction | 54 | wa = (rect(3)-rect(1)) ; //** geometrical correction |
54 | ha = (rect(4)-rect(2)) ; | 55 | ha = (rect(4)-rect(2)) ; |
55 | 56 | ||
56 | //**Graphics window -> 2 | 57 | |
58 | |||
59 | |||
60 | |||
61 | |||
62 | num = 1 ; //** the default is Postscript file output | ||
63 | |||
64 | //**------------------------------------------------------------------ | ||
65 | if rhs==1 then //** the default "scs_m only" case | ||
66 | |||
67 | num = choose(['Postscript file';.. | ||
68 | 'Graphics window'],'How do you want to export?') | ||
69 | |||
70 | //** Postscript file -> 1 | ||
71 | //** Graphics window -> 2 | ||
72 | //** [Cancel] -> 0 | ||
73 | |||
74 | if num==1 then fname= savefile('*');end | ||
75 | end | ||
76 | |||
77 | if num==0 then | ||
78 | return ; //** EXIT point | ||
79 | elseif num==1 then //** Postscript file | ||
80 | |||
81 | if ~MSDOS then // remove blanks | ||
82 | fname = stripblanks(fname) | ||
83 | ff = str2code(fname); ff(find(ff==40|ff==53))=36; fname=code2str(ff) | ||
84 | if fname==emptystr() then return;end | ||
85 | end | ||
86 | driv=driver(); | ||
87 | driver('Pos'); | ||
88 | set_posfig_dim(wa*%zoom/1.8, ha*%zoom/1.8) | ||
89 | xinit(fname); | ||
90 | gh_axes=gca(); | ||
91 | gh_winc =gcf(); | ||
92 | else //**Graphics window -> 2 | ||
57 | gh_winc = scf( max(winsid()) + 1 ) ; //** create a brand new window and get the handle | 93 | gh_winc = scf( max(winsid()) + 1 ) ; //** create a brand new window and get the handle |
58 | drawlater() | 94 | drawlater() |
59 | winc = gh_winc.figure_id ; | 95 | winc = gh_winc.figure_id ; |
60 | gh_axes = gh_winc.children ; //** axes handle | 96 | gh_axes = gh_winc.children ; //** axes handle |
97 | end | ||
61 | 98 | ||
62 | //** Geometrical correction | 99 | //** Geometrical correction |
63 | gh_axes.axes_bounds = [0 0 1 1] ; // use whole graphic window | 100 | gh_axes.axes_bounds = [0 0 1 1] ; // use whole graphic window |
64 | gh_axes.tight_limits = "on" ; //** set the limit "gh_axes.data_bounds" in "hard mode" | 101 | gh_axes.tight_limits = "on" ; //** set the limit "gh_axes.data_bounds" in "hard mode" |
65 | mrect = [rect(1) rect(2) ; rect(3) rect(4)] ; //** vector to matrix conversion | 102 | mrect = [rect(1) rect(2) ; rect(3) rect(4)] ; //** vector to matrix conversion |
66 | gh_axes.data_bounds = mrect ; //** default : data_bounds = [xmin ymin ; xmax ymax ] | 103 | gh_axes.data_bounds = mrect ; //** default : data_bounds = [xmin ymin ; xmax ymax ] |
67 | gh_axes.margins = [0,0,0,0] ; //** no margins | 104 | gh_axes.margins = [0,0,0,0] ; //** no margins |
68 | gh_winc.axes_size= [wa ha] //figure_size = [wa ha] ; | 105 | gh_winc.axes_size= [wa ha] //figure_size = [wa ha] ; |
69 | 106 | ||
70 | // set options | 107 | // set options |
71 | options = scs_m.props.options | 108 | options = scs_m.props.options |
72 | 109 | ||
73 | // **----------- set colormap ----------------------------------------- | 110 | // **----------- set colormap ----------------------------------------- |
74 | // RN: this is not satisfactory. It uses the exact algorithm that in | 111 | // RN: this is not satisfactory. It uses the exact algorithm that in |
75 | // set_cmap to make sure the same numbering is used. A common | 112 | // set_cmap to make sure the same numbering is used. A common |
@@ -84,12 +121,12 @@ function [wa,ha] = do_export(scs_m, fname, titleflag) | |||
84 | end | 121 | end |
85 | ierr = execstr('set(gh_winc,'"color_map'",d)','errcatch') | 122 | ierr = execstr('set(gh_winc,'"color_map'",d)','errcatch') |
86 | if ierr<>0 then | 123 | if ierr<>0 then |
87 | warning("Cannot allocate colormap.") | 124 | warning("%s: Cannot allocate colormap", "do_export") |
88 | end | 125 | end |
89 | 126 | ||
90 | //**----------- Background handling ----------------------------------------- | 127 | //**----------- Background handling ----------------------------------------- |
91 | if ~exists('%scicos_with_background') then %scicos_with_background = 1;end | 128 | if ~exists('%scicos_with_background') then %scicos_with_background = 1;end |
92 | if ~%scicos_with_background then | 129 | if ~%scicos_with_background then |
93 | gh_axes.background=-2; | 130 | gh_axes.background=-2; |
94 | gh_winc.background=-2; | 131 | gh_winc.background=-2; |
95 | else | 132 | else |
@@ -102,21 +139,38 @@ function [wa,ha] = do_export(scs_m, fname, titleflag) | |||
102 | end | 139 | end |
103 | //**------------------------------------------------------------------------ | 140 | //**------------------------------------------------------------------------ |
104 | 141 | ||
142 | //** --------------------- Output ------------------------------------------ | ||
143 | |||
144 | if num == 1 then //** Postscript file | ||
145 | |||
146 | %draw_title() | ||
147 | drawobjs(scs_m,gcf()) | ||
148 | drawnow() | ||
149 | |||
150 | // Capture to EPS and delete figure | ||
151 | xs2eps(gh_winc.figure_id, fname, 'landscape') | ||
152 | delete(gh_winc) | ||
153 | |||
154 | //** reset the postscript export coordinates transformation | ||
155 | set_posfig_dim(0,0) ; | ||
156 | |||
157 | else | ||
105 | //** Graphics Window | 158 | //** Graphics Window |
106 | %draw_title() | 159 | %draw_title() |
107 | scf(gh_winc); //** put the focus in the graphics window | 160 | scf(gh_winc); //** put the focus in the graphics window |
108 | drawobjs(scs_m, gcf()) | 161 | drawobjs(scs_m, gcf()) |
109 | drawnow(); | 162 | drawnow(); |
110 | 163 | ||
164 | end | ||
165 | |||
166 | |||
111 | endfunction | 167 | endfunction |
112 | 168 | ||
113 | function %draw_title() | 169 | function %draw_title() |
114 | //** Put the title in the ouput window/file | 170 | //** Put the title in the ouput window/file |
115 | if ~(rhs==3 & titleflag==0) then | 171 | if ~(rhs==3 & titleflag==0) then |
116 | width = (rect(3)-rect(1))/3; | 172 | width = (rect(3)-rect(1))/3; |
117 | height = (rect(4)-rect(2))/6; | 173 | height = (rect(4)-rect(2))/6; |
118 | xstringb(rect(1)+width,rect(4)-height*(1+%scicos_ud_margin),scs_m.props.title(1),width,height,'fill') | 174 | xstringb(rect(1)+width,rect(4)-height*(1+%scicos_ud_margin),scs_m.props.title(1),width,height,'fill') |
119 | end | 175 | end |
120 | endfunction | 176 | endfunction |
121 | |||
122 | |||
diff --git a/scilab/modules/scicos/macros/scicos_scicos/systexport.sci b/scilab/modules/scicos/macros/scicos_scicos/systexport.sci index 3ce65ed..552bd99 100644 --- a/scilab/modules/scicos/macros/scicos_scicos/systexport.sci +++ b/scilab/modules/scicos/macros/scicos_scicos/systexport.sci | |||
@@ -31,7 +31,7 @@ function systexport(scs_m,exp_dir) | |||
31 | if typeof(o)=='Block' then | 31 | if typeof(o)=='Block' then |
32 | model=o.model | 32 | model=o.model |
33 | if model.sim=='super' then | 33 | if model.sim=='super' then |
34 | systexport(model.rpar,exp_dir) | 34 | systexport(model.rpar,exp_dir) |
35 | end | 35 | end |
36 | end | 36 | end |
37 | end | 37 | end |