1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 - INRIA - Pierre MARECHAL
3 // Copyright (C) 2016 - Scilab Enterprises - Paul Bignier
5 // This file is released under the 3-clause BSD license. See COPYING-BSD.
13 // =========================================================================
15 frame_w = 200; // Frame width
16 frame_h = 330; // Frame height
18 plot_w = 600; // Plot width
19 plot_h = 550; // Plot height
21 margin_x = 15; // Horizontal margin between each elements
22 margin_y = 15; // Vertical margin between each elements
24 defaultfont = "arial"; // Default Font
25 text_font_size = 12; // Text font size
28 // =========================================================================
30 axes_w = 3*margin_x + frame_w + plot_w; // axes width
31 axes_h = 2*margin_y + max(frame_h,plot_h); // axes height
33 fig_handle = figure( ...
34 "infobar_visible", "off", ...
35 "toolbar_visible", "off", ...
36 "toolbar", "none", ...
37 "default_axes", "on", ...
38 "layout", "gridbag", ...
41 "figure_position", [0 0], ...
42 "axes_size", [axes_w axes_h], ...
43 "figure_name", _("Misc"));
45 c = createConstraints("gridbag", [2 1 1 1], [1 1], "vertical", "right");
46 // Create an empty panel on the right to occupy the 3/4 of the screen (figure plot)
47 empty_frame = uicontrol(fig_handle, "style", "frame","constraints", c);
49 c = createConstraints("gridbag", [1 1 1 5], [0.05 1], "both", "left", [0 0], [150 0]);
50 u = uicontrol(fig_handle, ...
52 "backgroundcolor", [1 1 1], ...
53 "layout", "border", ...
56 // Add top and bottom empty panels to pad the upcoming colormap panel
57 c = createConstraints("border", "top", [0 80]);
58 top = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c);
59 c = createConstraints("border", "bottom", [0 80]);
60 bottom = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c);
62 // Border for the colormap frame
63 b_f_colormap = createBorderFont("", 18);
64 b_l_colormap = createBorder("line", "navy", 2);
65 b_colormap = createBorder("titled", b_l_colormap, "Colormap", "center", "top", b_f_colormap, "navy");
67 colormap_frame = uicontrol(u, ...
69 "backgroundcolor", [1 1 1], ...
70 "border", b_colormap, ...
71 "layout", "gridbag", ...
72 "tag", "colormap_frame");
74 demo_viewCode("misc.dem.sce");
76 fig_handle.color_map = jetcolormap(128);
79 // =========================================================================
81 // Radio buttons : Jet
83 c = createConstraints("gridbag", [1 1 1 1], [1 1], "both", "upper");
84 square_radio = uicontrol( ...
85 "parent" , colormap_frame, ...
86 "style" , "radiobutton", ...
88 "fontname" , defaultfont, ...
89 "fontunits" , "points", ...
90 "fontsize" , text_font_size, ...
92 "background" , [1 1 1], ...
93 "callback" , "demo_update_misc", ...
94 "constraints" , c, ...
95 "tag" , "jetcolormap_radio");
97 // Radio buttons : Parula
99 c = createConstraints("gridbag", [1 2 1 1], [1 1], "both", "upper");
100 disk_radio = uicontrol( ...
101 "parent" , colormap_frame, ...
102 "style" , "radiobutton", ...
103 "string" , "Parula", ...
104 "fontname" , defaultfont, ...
105 "fontunits" , "points", ...
106 "fontsize" , text_font_size, ...
108 "background" , [1 1 1], ...
109 "callback" , "demo_update_misc", ...
110 "constraints" , c, ...
111 "tag" , "parulacolormap_radio");
113 // Radio buttons : HSV
115 c = createConstraints("gridbag", [1 3 1 1], [1 1], "both", "upper");
116 disk_radio = uicontrol( ...
117 "parent" , colormap_frame, ...
118 "style" , "radiobutton", ...
119 "string" , "HSV", ...
120 "fontname" , defaultfont, ...
121 "fontunits" , "points", ...
122 "fontsize" , text_font_size, ...
124 "background" , [1 1 1], ...
125 "callback" , "demo_update_misc", ...
126 "constraints" , c, ...
127 "tag" , "HSVcolormap_radio");
129 // Radio buttons : Hot
131 c = createConstraints("gridbag", [1 4 1 1], [1 1], "both", "upper");
132 disk_radio = uicontrol( ...
133 "parent" , colormap_frame, ...
134 "style" , "radiobutton", ...
135 "string" , "Hot", ...
136 "fontname" , defaultfont, ...
137 "fontunits" , "points", ...
138 "fontsize" , text_font_size, ...
140 "background" , [1 1 1], ...
141 "callback" , "demo_update_misc", ...
142 "constraints" , c, ...
143 "tag" , "hotcolormap_radio");
145 // Radio buttons : Gray
147 c = createConstraints("gridbag", [1 5 1 1], [1 1], "both", "upper");
148 disk_radio = uicontrol( ...
149 "parent" , colormap_frame, ...
150 "style" , "radiobutton", ...
151 "string" , "Gray", ...
152 "fontname" , defaultfont, ...
153 "fontunits" , "points", ...
154 "fontsize" , text_font_size, ...
156 "background" , [1 1 1], ...
157 "callback" , "demo_update_misc", ...
158 "constraints" , c, ...
159 "tag" , "graycolormap_radio");
161 // Radio buttons : Winter
163 c = createConstraints("gridbag", [1 6 1 1], [1 1], "both", "upper");
164 disk_radio = uicontrol( ...
165 "parent" , colormap_frame, ...
166 "style" , "radiobutton", ...
167 "string" , "Winter", ...
168 "fontname" , defaultfont, ...
169 "fontunits" , "points", ...
170 "fontsize" , text_font_size, ...
172 "background" , [1 1 1], ...
173 "callback" , "demo_update_misc", ...
174 "constraints" , c, ...
175 "tag" , "wintercolormap_radio");
177 // Radio buttons : Spring
179 c = createConstraints("gridbag", [1 7 1 1], [1 1], "both", "upper");
180 disk_radio = uicontrol( ...
181 "parent" , colormap_frame, ...
182 "style" , "radiobutton", ...
183 "string" , "Spring", ...
184 "fontname" , defaultfont, ...
185 "fontunits" , "points", ...
186 "fontsize" , text_font_size, ...
188 "background" , [1 1 1], ...
189 "callback" , "demo_update_misc", ...
190 "constraints" , c, ...
191 "tag" , "springcolormap_radio");
193 // Radio buttons : Summer
195 c = createConstraints("gridbag", [1 8 1 1], [1 1], "both", "upper");
196 disk_radio = uicontrol( ...
197 "parent" , colormap_frame, ...
198 "style" , "radiobutton", ...
199 "string" , "Summer", ...
200 "fontname" , defaultfont, ...
201 "fontunits" , "points", ...
202 "fontsize" , text_font_size, ...
204 "background" , [1 1 1], ...
205 "callback" , "demo_update_misc", ...
206 "constraints" , c, ...
207 "tag" , "summercolormap_radio");
209 // Radio buttons : Autumn
211 c = createConstraints("gridbag", [1 9 1 1], [1 1], "both", "upper");
212 disk_radio = uicontrol( ...
213 "parent" , colormap_frame, ...
214 "style" , "radiobutton", ...
215 "string" , "Autumn", ...
216 "fontname" , defaultfont, ...
217 "fontunits" , "points", ...
218 "fontsize" , text_font_size, ...
220 "background" , [1 1 1], ...
221 "callback" , "demo_update_misc", ...
222 "constraints" , c, ...
223 "tag" , "autumncolormap_radio");
225 // Radio buttons : Bone
227 c = createConstraints("gridbag", [1 10 1 1], [1 1], "both", "upper");
228 disk_radio = uicontrol( ...
229 "parent" , colormap_frame, ...
230 "style" , "radiobutton", ...
231 "string" , "Bone", ...
232 "fontname" , defaultfont, ...
233 "fontunits" , "points", ...
234 "fontsize" , text_font_size, ...
236 "background" , [1 1 1], ...
237 "callback" , "demo_update_misc", ...
238 "constraints" , c, ...
239 "tag" , "bonecolormap_radio");
241 // Radio buttons : Copper
243 c = createConstraints("gridbag", [1 11 1 1], [1 1], "both", "upper");
244 disk_radio = uicontrol( ...
245 "parent" , colormap_frame, ...
246 "style" , "radiobutton", ...
247 "string" , "Copper", ...
248 "fontname" , defaultfont, ...
249 "fontunits" , "points", ...
250 "fontsize" , text_font_size, ...
252 "background" , [1 1 1], ...
253 "callback" , "demo_update_misc", ...
254 "constraints" , c, ...
255 "tag" , "coppercolormap_radio");
257 // Radio buttons : Pink
259 c = createConstraints("gridbag", [1 12 1 1], [1 1], "both", "upper");
260 disk_radio = uicontrol( ...
261 "parent" , colormap_frame, ...
262 "style" , "radiobutton", ...
263 "string" , "Pink", ...
264 "fontname" , defaultfont, ...
265 "fontunits" , "points", ...
266 "fontsize" , text_font_size, ...
268 "background" , [1 1 1], ...
269 "callback" , "demo_update_misc", ...
270 "constraints" , c, ...
271 "tag" , "pinkcolormap_radio");
273 // Radio buttons : Rainbow
275 c = createConstraints("gridbag", [1 13 1 1], [1 1], "both", "upper");
276 disk_radio = uicontrol( ...
277 "parent" , colormap_frame, ...
278 "style" , "radiobutton", ...
279 "string" , "Rainbow", ...
280 "fontname" , defaultfont, ...
281 "fontunits" , "points", ...
282 "fontsize" , text_font_size, ...
284 "background" , [1 1 1], ...
285 "callback" , "demo_update_misc", ...
286 "constraints" , c, ...
287 "tag" , "rainbowcolormap_radio");
289 // Radio buttons : Ocean
291 c = createConstraints("gridbag", [1 14 1 1], [1 1], "both", "upper");
292 disk_radio = uicontrol( ...
293 "parent" , colormap_frame, ...
294 "style" , "radiobutton", ...
295 "string" , "Ocean", ...
296 "fontname" , defaultfont, ...
297 "fontunits" , "points", ...
298 "fontsize" , text_font_size, ...
300 "background" , [1 1 1], ...
301 "callback" , "demo_update_misc", ...
302 "constraints" , c, ...
303 "tag" , "oceancolormap_radio");
305 // Radio buttons : White
307 c = createConstraints("gridbag", [1 15 1 1], [1 1], "both", "upper");
308 disk_radio = uicontrol( ...
309 "parent" , colormap_frame, ...
310 "style" , "radiobutton", ...
311 "string" , "White", ...
312 "fontname" , defaultfont, ...
313 "fontunits" , "points", ...
314 "fontsize" , text_font_size, ...
316 "background" , [1 1 1], ...
317 "callback" , "demo_update_misc", ...
318 "constraints" , c, ...
319 "tag" , "whitecolormap_radio");
322 // =========================================================================
326 my_plot_region_pos_x = ((2*margin_x+frame_w)/axes_w);
327 my_plot_region_pos_y = 0;
328 my_plot_region_w = 1-my_plot_region_pos_x;
329 my_plot_region_h = 1;
331 // First plot : grayplot(); top - left
333 my_plot_1_axes = newaxes();
334 my_plot_1_pos_x = ((2*margin_x+frame_w)/axes_w);
336 my_plot_1_w = (1-my_plot_region_pos_x)/2;
338 my_plot_1_axes.axes_bounds = [ my_plot_1_pos_x my_plot_1_pos_y my_plot_1_w my_plot_1_h ];
341 // Second plot : plot3d1(); top right
343 my_plot_2_axes = newaxes();
344 my_plot_2_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2;
346 my_plot_2_w = (1-my_plot_region_pos_x)/2;
348 my_plot_2_axes.axes_bounds = [ my_plot_2_pos_x my_plot_2_pos_y my_plot_2_w my_plot_2_h ];
351 // Third plot : grayplot(); bottom - left
353 my_plot_3_axes = newaxes();
354 my_plot_3_pos_x = ((2*margin_x+frame_w)/axes_w);
355 my_plot_3_pos_y = 1/2;
356 my_plot_3_w = (1-my_plot_region_pos_x)/2;
358 my_plot_3_axes.axes_bounds = [ my_plot_3_pos_x my_plot_3_pos_y my_plot_3_w my_plot_3_h ];
361 // Fourth plot : knot(); bottom - right
363 my_plot_4_axes = newaxes();
364 my_plot_4_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2;
365 my_plot_4_pos_y = 1/2;
366 my_plot_4_w = (1-my_plot_region_pos_x)/2;
368 my_plot_4_axes.axes_bounds = [ my_plot_4_pos_x my_plot_4_pos_y my_plot_4_w my_plot_4_h ];
370 deff("[x,y,z]=knot(u,v)",["vv=ones(v)";"uu=ones(u);";
371 "x=(5.*cos(u)+cos(u).*cos(v))";
372 "y=(5.*sin(u)+sin(u).*cos(v))";
380 [xx,yy,zz]=eval3dp(knot,2*%pi*Nx,2*%pi*Ny);
388 KKK=list(ZZZ,[kk1 kk2]);
389 plot3d(XXX,YYY,KKK,35,70," @ @ ",[2,1,4],[-6,6,-6,6,-6,6]);
394 f.color_map = jetcolormap(128);
396 my_plot_2_axes.background = color(240,240,240);
397 my_plot_4_axes.background = color(240,240,240);
401 fig_handle.visible = "on";
406 function demo_update_misc()
410 my_figure.immediate_drawing = "off";
412 set(findobj("tag", "jetcolormap_radio") , "value", 0);
413 set(findobj("tag", "parulacolormap_radio") , "value", 0);
414 set(findobj("tag", "HSVcolormap_radio") , "value", 0);
415 set(findobj("tag", "hotcolormap_radio") , "value", 0);
416 set(findobj("tag", "graycolormap_radio") , "value", 0);
417 set(findobj("tag", "wintercolormap_radio") , "value", 0);
418 set(findobj("tag", "springcolormap_radio") , "value", 0);
419 set(findobj("tag", "summercolormap_radio") , "value", 0);
420 set(findobj("tag", "autumncolormap_radio") , "value", 0);
421 set(findobj("tag", "bonecolormap_radio") , "value", 0);
422 set(findobj("tag", "coppercolormap_radio") , "value", 0);
423 set(findobj("tag", "pinkcolormap_radio") , "value", 0);
424 set(findobj("tag", "rainbowcolormap_radio") , "value", 0);
425 set(findobj("tag", "oceancolormap_radio") , "value", 0);
426 set(findobj("tag", "whitecolormap_radio") , "value", 0);
428 set(gcbo, "value", 1);
430 my_wanted_colormap = get(gcbo,"tag");
432 if get(gcbo, "tag") == "jetcolormap_radio" then
433 my_figure.color_map = jetcolormap(128);
434 elseif get(gcbo, "tag") == "parulacolormap_radio" then
435 my_figure.color_map = parulacolormap(128);
436 elseif get(gcbo, "tag") == "hotcolormap_radio" then
437 my_figure.color_map = hotcolormap(128);
438 elseif get(gcbo, "tag") == "graycolormap_radio" then
439 my_figure.color_map = graycolormap(128);
440 elseif get(gcbo, "tag") == "wintercolormap_radio" then
441 my_figure.color_map = wintercolormap(128);
442 elseif get(gcbo, "tag") == "springcolormap_radio" then
443 my_figure.color_map = springcolormap(128);
444 elseif get(gcbo, "tag") == "summercolormap_radio" then
445 my_figure.color_map = summercolormap(128);
446 elseif get(gcbo, "tag") == "autumncolormap_radio" then
447 my_figure.color_map = autumncolormap(128);
448 elseif get(gcbo, "tag") == "bonecolormap_radio" then
449 my_figure.color_map = bonecolormap(128);
450 elseif get(gcbo, "tag") == "coppercolormap_radio" then
451 my_figure.color_map = coppercolormap(128);
452 elseif get(gcbo, "tag") == "pinkcolormap_radio" then
453 my_figure.color_map = pinkcolormap(128);
454 elseif get(gcbo, "tag") == "HSVcolormap_radio" then
455 my_figure.color_map = hsvcolormap(128);
456 elseif get(gcbo, "tag") == "rainbowcolormap_radio" then
457 my_figure.color_map = rainbowcolormap(128);
458 elseif get(gcbo, "tag") == "oceancolormap_radio" then
459 my_figure.color_map = oceancolormap(128);
460 elseif get(gcbo, "tag") == "whitecolormap_radio" then
461 my_figure.color_map = whitecolormap(128);
464 // Gray background for 3d axes
466 for i = 1:size(my_figure.children,"*"),
467 child = my_figure.children(i);
468 if child.type=="Axes" then
469 if child.view=="3d" then
470 child.background = color(240,240,240);
477 my_figure.immediate_drawing = "on";