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
|
//
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) DIGITEO - 2009-2009 - Vincent COUVERT
// Copyright (C) DIGITEO - 2010-2010 - Clément DAVID
//
// 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.1-en.txt
//
//
// Generate xcos palette block icons and graph images from scicos pal files.
//
// @param palFiles set of string of palette files
// @param iconsOutPath output path of the palette icons (GIF files).
// The default is the common `palFiles' dir.
// @param imagesOutPath output path of the graph images (SVG files).
// The default is the common `palFiles' dir.
// @param[opt] traceEnable %T if a trace output must be printed, %F if not (default=%F).
function generateBlockImages(palFiles, iconsOutPath, imagesOutPath, traceEnable)
[lhs, rhs] = argn(0);
if rhs < 3 then
error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"), "generateBlockImages", 3));
end
if typeof(iconsOutPath) <> "string" | ~isdir(iconsOutPath) then
error(msprintf(gettext("%s: Wrong type for input argument ""%s"": directory path string expected.\n"), "generateBlockImages", "iconsOutPath"));
end
if typeof(imagesOutPath) <> "string" | ~isdir(imagesOutPath) then
error(msprintf(gettext("%s: Wrong type for input argument ""%s"": directory path string expected.\n"), "generateBlockImages", "imagesOutPath"));
end
if exists("traceEnable", "l") == 0 then
traceEnable = %f;
else
if typeof(traceEnable) <> "boolean" then
error(msprintf(gettext("%s: Wrong type for input argument ""%s"": boolean expected.\n"), "generateBlockImage", "traceEnable"));
end
end
// call loadXcosLibs if not loaded
if exists("scicos_diagram", "a") == 0 then loadXcosLibs(); end
if traceEnable then
ncl = lines(), lines(0);
end
// iterator on all blocks
for fIndex = 1:size(palFiles, "*")
if ~isfile(palFiles(fIndex)) then
if traceEnable then
mprintf(gettext("%s: File ''%s'' does not exist.\n"), "generateBlockImages", palFiles(fIndex));
end
continue;
end
exec(palFiles(fIndex), -1);
if isempty("scs_m") then
if traceEnable then
mprintf(gettext("%s: File ''%s'' is not a valid palette file.\n"), "generateBlockImages", palFiles(fIndex));
end
continue;
end
for iBlock = 1:size(scs_m.objs)
block = scs_m.objs(iBlock);
if typeof(block)=="Block" & block.gui == "PAL_f" then
// Add PAL_f children blocks
children = block.model.rpar.objs;
for jBlock = 1:size(children)
varsToLoad($+1) = children(jBlock).gui;
end
elseif typeof(block)=="Block" then
// old scicos palettes doesn't have a PAL_f block but directly
// the reference instances instead.
varsToLoad($+1) = block.gui
else
if traceEnable then
mprintf(gettext("%s: Found ''%s'' instead of a block.\n"), "generateBlockImages", typeof(block));
end
continue;
end
end
clear scs_m;
end
varsToLoad = gsort(varsToLoad, "r", "i");
for kBlock = 1 : size(varsToLoad, "*")
ierr = execstr("scs_m = " + varsToLoad(kBlock) + "(""define"")", "errcatch");
if traceEnable then
mprintf("%d: %s", kBlock, varsToLoad(kBlock));
end
if ierr == 0 then
status = generateBlockImage(scs_m, imagesOutPath, imageType=imageType, %f);
if status & traceEnable then
mprintf(" SUCCEED\n");
elseif traceEnable then
mprintf(" FAILED\n");
end
elseif traceEnable then
mprintf(" FAILED\n");
end
end
if traceEnable then
lines(ncl);
end
endfunction
function c=scs_color(c)
endfunction
|