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
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2004-2006 - INRIA - Fabrice Leray
// 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
function [Color,Line,LineStyle,Marker,MarkerStyle,MarkerSize,fail]=getLineSpec(str,current_figure,cur_draw_mode)
LineStyle=1;
Color=[];
MarkerStyle=[];
MarkerSize=1;
LineStyle=1;
fail=0;
//conversion to lower format
str = convstr(str);
// 1) LINE STYLE
// Line type modifiers
if strindex(str,"--")
str=strsubst(str,"--","");
LineStyle=2;
Line = %T;
elseif strindex(str,"-.")
str=strsubst(str,"-.","");
LineStyle=4;
Line = %T;
elseif strindex(str,":")
str=strsubst(str,":","");
LineStyle=5;
Line = %T;
elseif strindex(str,"-")
str=strsubst(str,"-","");
LineStyle=1;
Line = %T;
end
//
//disp("str vaut:::::::: 1/2")
//disp(str)
// 2) COLORS + MARKS STYLE
opt1=[];
//Marks
Table = [ "+" "o" "*" "." "x" "square" "diamond" "^" "v" ">" "<" "pentagram"];
MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14];
//MarksSizeVal =[4 3 7 1 3 3 4 3 3 3 3 3];
//MarksSizeVal =[6 6 6 6 6 6 6 6 6 6 6 6]; // size is given in points now (25.02.05)
//Colors
Table= [Table "red" "green" "blue" "cyan" "magenta" "yellow" "black" "k" "white"]
ColorVal = ["red" "green" "blue" "cyan" "magenta" "yellow" "black" "black" "white"]
//color management
//difficulty here since we have to allow every kind of writings:
//i.e:
//magenta can be set by: 'm' 'ma' 'mag' 'mage' 'magen' 'magent' or at least 'magenta'
//
str = str+"@";
while length(str) > 1
c1 = part(str,1); // We get the first character
k=find(part(Table,1)==c1);
if (k == [] | (size(k,"*") > 1 & c1 <> "b"))
ResetFigureDDM(current_figure, cur_draw_mode);
error(msprintf(gettext("%s: Wrong type for input argument.\n"), "getLineSpec"));
end
if c1=="b" // special case here : we have to distinguish between black and blue colors
c2 = part(str,2);
if (c2 == "l")
c3 = part(str,3);
if (c3 == "a")
k=19; // k is set to black color
else
k=15; // k is set to blue color
end
else
k=15; // k is set to blue color
end
end
opt = Table(k);
for i=1:length(str)
if part(opt,i) <> part(str,i)
break;
end
end
opt1 = [opt1 k];
str = part(str,i:length(str));
end
// LineSpec is parsed now
//Marker = %F;
//Line = %T;
for i=1:size(opt1,"*")
if (opt1(i) <= 12)
Marker = %T;
MarkerStyle = MarksStyleVal(opt1(i));
MarkerSize = 6;
//MarkerSize = MarksSizeVal (opt1(i));
// disp("MarkerSize =");
// disp(MarkerSize);
else
Color = color(ColorVal(opt1(i)-12));
end
end
endfunction
// end of getLineSpec
|