1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2004-2006 - INRIA - Fabrice Leray
3 // Copyright (C) 2012 - 2016 - Scilab Enterprises
4 // Copyright (C) 2018, 2019 - Samuel GOUGEON
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
13 function [fail]=setPlotProperty(PropertyName,PropertyValue,Curves,current_figure,cur_draw_mode)
17 //conversion to lower format
18 str = convstr(PropertyName);
22 //Property = ['foreground' 'clipping'];
24 [PName] = getPlotPropertyName(str,current_figure,cur_draw_mode)
28 ResetFigureDDM(current_figure, cur_draw_mode);
34 /////////////////////////
35 case "foreground" // <=> Color
36 /////////////////////////
37 c = iscolor(PropertyValue);
39 msg = _("%s: Argument #%d: Wrong color specification.\n")
40 warning(msprintf(msg, "setPlotProperty", 2));
41 ResetFigureDDM(current_figure, cur_draw_mode);
44 if size(c,"r")<length(Curves)
45 msg = _("%s: Arguments #%d and #%d: Incompatible sizes.\n")
46 warning(msprintf(msg, "setPlotProperty", 2, 3));
47 ResetFigureDDM(current_figure, cur_draw_mode);
50 Curves.line_mode = "on";
51 if size(c,2) > 1 // c is RGB
52 ind = addcolor(c(1:length(Curves),:));
57 Curves($-i+1).foreground = ind(i);
58 Curves($-i+1).mark_foreground = ind(i);
61 /////////////////////////
62 case "clipping" // Clipping
63 /////////////////////////
64 if (type(PropertyValue)==10 & (PropertyValue=="on" | PropertyValue=="off"))
65 Curves.clip_state=PropertyValue;
67 warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setPlotProperty",2,"on","off"));
68 ResetFigureDDM(current_figure, cur_draw_mode);
73 /////////////////////////
74 case "linestyle" // LineStyle
75 /////////////////////////
76 if (type(PropertyValue)==10)
77 if (PropertyValue=="--")
79 Curves.line_mode = "on";
80 elseif (PropertyValue=="-.")
82 Curves.line_mode = "on";
83 elseif (PropertyValue==":")
85 Curves.line_mode = "on";
86 elseif (PropertyValue=="-")
88 Curves.line_mode = "on";
89 elseif (PropertyValue=="none")
90 Curves.line_mode = "off";
93 warning(msprintf(gettext("%s: Wrong type for input argument #%d: string expected.\n"),"setPlotProperty",2));
94 ResetFigureDDM(current_figure, cur_draw_mode);
98 /////////////////////////
99 case "thickness" // <=> LineWidth
100 /////////////////////////
101 if (type(PropertyValue)==1)
102 Curves.thickness=PropertyValue;
104 warning(msprintf(gettext("%s: Wrong type for input argument #%d: A scalar expected.\n"),"setPlotProperty",2));
105 ResetFigureDDM(current_figure, cur_draw_mode);
109 /////////////////////////
110 case "markstyle" // <=> Marker
111 /////////////////////////
112 if (type(PropertyValue)==10)
114 str = convstr(PropertyValue);
116 Table = [ "+" "o" "*" "." "x" "square" "diamond" "^" "v" ">" "<" "pentagram" "none"];
117 MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14 -99];
118 // MarksSizeVal =[4 3 7 1 3 3 4 3 3 3 3 3 -99];
122 k=find(part(Table,1:length(str))==str);
125 warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotProperty", 2));
127 ResetFigureDDM(current_figure, cur_draw_mode);
129 elseif ( size(k,"*") > 1)
130 warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotProperty", 2)); //unreachable case normally
132 ResetFigureDDM(current_figure, cur_draw_mode);
138 if part(opt,i) <> part(str,i)
145 str = part(str,i:length(str));
147 if (size(opt1,"*") > 1)
148 warning(msprintf(gettext("%s: Wrong value for input argument #%d: A marker style expected.\n"),"setPlotproperty",2));
149 ResetFigureDDM(current_figure, cur_draw_mode);
154 Curves.mark_style = MarksStyleVal(opt1);
155 Curves.mark_size = 6;
156 //MarksSizeVal(opt1);
158 // 'none' is selected
159 Curves.mark_mode="off"
163 warning(msprintf(gettext("%s: Wrong type for input argument #%d: string expected.\n"),"setPlotProperty"));
164 ResetFigureDDM(current_figure, cur_draw_mode);
169 /////////////////////////
170 case "markforeground" // <=> MarkerEdgeColor
171 /////////////////////////
173 markmodeON = find(Curves.mark_mode=="on");
174 tmp = "/^"+PropertyValue+"/"
175 if type(PropertyValue)==10 & size(PropertyValue,"*")==1 & ..
176 grep(["none" "auto"], tmp, "r") <> []
177 if grep("none", tmp, "r") <> []
179 Curves(markmodeON).mark_foreground = gca().background;
181 else // 'auto' specified
183 Curves(markmodeON).mark_foreground = Curves.foreground;
187 co = iscolor(PropertyValue)
188 if or(isnan(co(:,1)))
189 msg = gettext("%s: Argument #%d: Wrong color specification.\n")
190 warning(msprintf(msg, "setPlotProperty", 2))
191 ResetFigureDDM(current_figure, cur_draw_mode)
196 Curves(markmodeON).mark_foreground = co;
198 Curves(markmodeON).mark_foreground = addcolor(co);
203 /////////////////////////
204 case "markbackground" // <=> MarkerFaceColor
205 /////////////////////////
207 markmodeON = find(Curves.mark_mode=="on");
208 tmp = "/^"+PropertyValue+"/"
209 if type(PropertyValue)==10 & size(PropertyValue,"*")==1 & ..
210 grep(["none" "auto"], tmp, "r") <> []
212 Curves(markmodeON).mark_background = gca().background;
215 co = iscolor(PropertyValue)
216 if or(isnan(co(:,1)))
217 msg = gettext("%s: Argument #%d: Wrong color specification.\n")
218 warning(msprintf(msg, "setPlotProperty", 2))
219 ResetFigureDDM(current_figure, cur_draw_mode)
224 Curves(markmodeON).mark_background = co;
226 Curves(markmodeON).mark_background = addcolor(co);
231 /////////////////////////
232 case "marksize" // <=> MarkerSize
233 /////////////////////////
234 if (type(PropertyValue)==1 & size(PropertyValue,"*")==1)
236 markmodeON = find(Curves.mark_mode=="on");
239 Curves(markmodeON).mark_size = PropertyValue;
242 warning(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"setPlotProperty",2));
243 ResetFigureDDM(current_figure, cur_draw_mode);
247 /////////////////////////
248 case "visible" // <=> Visible
249 /////////////////////////
250 if (type(PropertyValue)==10 & (PropertyValue=="on" | PropertyValue=="off"))
251 Curves.visible = PropertyValue;
253 warning(msprintf(gettext("%s: Wrong value for input argument #%d: %s or %s expected.\n"),"setPlotProperty",2,"on","off"));
254 ResetFigureDDM(current_figure, cur_draw_mode);
259 /////////////////////////
261 /////////////////////////
263 // Already done at the beginning of plot execution.
265 /////////////////////////
267 /////////////////////////
269 // Already done at the beginning of plot execution.
271 /////////////////////////
272 case "zdata" // <=> Zdata is treated after the curve was created
273 /////////////////////////
275 if (type(PropertyValue)<>1 | and(size(PropertyValue)<>1))
276 warning(msprintf(gettext("%s: Wrong size or type for input argument #%d: A column or row vector expected.\n"),"setPlotProperty",2));
277 ResetFigureDDM(current_figure, cur_draw_mode);
280 PropertyValue = PropertyValue(:); // force
282 for j=1:size(Curves,"*")
283 if size(Curves(i).data,1) <> size(PropertyValue,"*")
284 str="plot : incompatible dimensions in input arguments";
286 ResetFigureDDM(current_figure, cur_draw_mode);
289 for jj=1:size(PropertyValue,"*")
290 Curves(j).data(jj,3) = PropertyValue(jj);
294 a.data_bounds=[a.data_bounds(1,1) a.data_bounds(1,2) min(PropertyValue) ; a.data_bounds(2,1) a.data_bounds(2,2) max(PropertyValue)];