From 07dffc43cdfbf52b957307da35584d1ebe653c9d Mon Sep 17 00:00:00 2001 From: Samuel GOUGEON Date: Sun, 8 Oct 2017 19:49:49 +0200 Subject: [PATCH] * Bug 11483 fixed: demo Graphics => Misc improved, renamed, unduplicated http://bugzilla.scilab.org/11483 Graphics => Misc: * There were some holes in the top left grayplot (reported) * The bottom and top left plots were the same (reported) * There was no colorbar * The list of selectable colormaps was very wide * The figure's title was always "grayplot" instead of the name of the current colormap * The code was very redundant (e.g. to create buttons). The .groupname property was not used. * Rendering of both 3D axes improved. The knot spanned only on the first 60 colors over 128. * The Graphics => Colormap demo was a weak duplicate of this one, but with the right title. Change-Id: I615b9297bcda246b8d6858223dde6421d934421d --- scilab/CHANGES.md | 1 + .../graphics/demos/colormap/colormap.dem.sce | 437 ------------------ .../graphics/demos/colormap/colormaps.dem.sce | 225 +++++++++ .../graphics/demos/graphics.dem.gateway.sce | 3 +- scilab/modules/graphics/demos/misc/misc.dem.sce | 486 -------------------- 5 files changed, 227 insertions(+), 925 deletions(-) delete mode 100644 scilab/modules/graphics/demos/colormap/colormap.dem.sce create mode 100644 scilab/modules/graphics/demos/colormap/colormaps.dem.sce delete mode 100644 scilab/modules/graphics/demos/misc/misc.dem.sce diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index b9d33d3..c4e40b9 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -405,6 +405,7 @@ the [development mailing list](dev@lists.scilab.org) for a particular toolbox. * [#10467](http://bugzilla.scilab.org/show_bug.cgi?id=10467): `execstr` inside a `try/end` with a `catch` killed the stack. * [#11196](http://bugzilla.scilab.org/show_bug.cgi?id=11196): Some recursive extractions from a mlist failed. * [#11251](http://bugzilla.scilab.org/show_bug.cgi?id=11251): `execstr` could kill the variables stack. +* [#11483](http://bugzilla.scilab.org/show_bug.cgi?id=11483): The `Graphics => Misc` demo had a hole, 2 duplicates, and other bugs. * [#11530](http://bugzilla.scilab.org/show_bug.cgi?id=11530): Raise (help, scinotes, ...) windows when iconified ( recall or startup ) * [#11693](http://bugzilla.scilab.org/show_bug.cgi?id=11693): uicontrol edit fields needed after the input to actually record it. * [#11756](http://bugzilla.scilab.org/show_bug.cgi?id=11756): In the categories of the ATOMS GUI, actually available modules might be not listed. diff --git a/scilab/modules/graphics/demos/colormap/colormap.dem.sce b/scilab/modules/graphics/demos/colormap/colormap.dem.sce deleted file mode 100644 index 63628f3..0000000 --- a/scilab/modules/graphics/demos/colormap/colormap.dem.sce +++ /dev/null @@ -1,437 +0,0 @@ -// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab -// Copyright (C) 2008 - INRIA - Pierre MARECHAL -// Copyright (C) 2010 - DIGITEO - Allan CORNET -// Copyright (C) 2016 - Scilab Enterprises - Paul Bignier -// -// This file is released under the 3-clause BSD license. See COPYING-BSD. - -prot = funcprot(); -funcprot(0); - -function demo_colormap() - - // Parameters - // ========================================================================= - - frame_w = 200; // Frame width - frame_h = 330; // Frame height - - plot_w = 600; // Plot width - plot_h = 550; // Plot height - - margin_x = 15; // Horizontal margin between each elements - margin_y = 15; // Vertical margin between each elements - - defaultfont = "arial"; // Default Font - text_font_size = 12; // Text font size - - // Figure creation - // ========================================================================= - - axes_w = 3*margin_x + frame_w + plot_w; // axes width - axes_h = 2*margin_y + max(frame_h,plot_h); // axes height - - fig_handle = figure( ... - "infobar_visible", "off", ... - "toolbar_visible", "off", ... - "toolbar", "none", ... - "default_axes", "on", ... - "layout", "gridbag", ... - "visible", "off", ... - "background", -2, ... - "figure_position", [0 0], ... - "axes_size", [axes_w axes_h], ... - "figure_name", "Colormap"); - - c = createConstraints("gridbag", [2 1 1 1], [1 1], "vertical", "right"); - // Create an empty panel on the right to occupy the 3/4 of the screen (figure plot) - empty_frame = uicontrol(fig_handle, "style", "frame","constraints", c); - - c = createConstraints("gridbag", [1 1 1 5], [0.05 1], "both", "left", [0 0], [150 0]); - u = uicontrol(fig_handle, ... - "style", "frame", ... - "backgroundcolor", [1 1 1], ... - "layout", "border", ... - "constraints", c); - - // Add top and bottom empty panels to pad the upcoming colormap panel - c = createConstraints("border", "top", [0 80]); - top = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); - c = createConstraints("border", "bottom", [0 80]); - bottom = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); - - // Border for the colormap frame - b_f_colormap = createBorderFont("", 18); - b_l_colormap = createBorder("line", "navy", 2); - b_colormap = createBorder("titled", b_l_colormap, "Colormap", "center", "top", b_f_colormap, "navy"); - - colormap_frame = uicontrol(u, ... - "style", "frame", ... - "backgroundcolor", [1 1 1], ... - "border", b_colormap, ... - "layout", "gridbag", ... - "tag", "colormap_frame"); - - demo_viewCode("colormap.dem.sce"); - - fig_handle.color_map = jetcolormap(128); - - // Radio buttons - // ========================================================================= - - // Radio buttons : Jet - - c = createConstraints("gridbag", [1 1 1 1], [1 1], "both", "upper"); - square_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Jet", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 1, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "jetcolormap_radio"); - - // Radio buttons : Parula - - c = createConstraints("gridbag", [1 2 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Parula", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "parulacolormap_radio"); - - // Radio buttons : HSV - - c = createConstraints("gridbag", [1 3 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "HSV", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "HSVcolormap_radio"); - - // Radio buttons : Hot - - c = createConstraints("gridbag", [1 4 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Hot", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "hotcolormap_radio"); - - // Radio buttons : Gray - - c = createConstraints("gridbag", [1 5 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Gray", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "graycolormap_radio"); - - // Radio buttons : Winter - - c = createConstraints("gridbag", [1 6 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Winter", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "wintercolormap_radio"); - - // Radio buttons : Spring - - c = createConstraints("gridbag", [1 7 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Spring", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "springcolormap_radio"); - - // Radio buttons : Summer - - c = createConstraints("gridbag", [1 8 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Summer", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "summercolormap_radio"); - - // Radio buttons : Autumn - - c = createConstraints("gridbag", [1 9 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Autumn", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "autumncolormap_radio"); - - // Radio buttons : Bone - - c = createConstraints("gridbag", [1 10 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Bone", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "bonecolormap_radio"); - - // Radio buttons : Copper - - c = createConstraints("gridbag", [1 11 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Copper", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "coppercolormap_radio"); - - // Radio buttons : Pink - - c = createConstraints("gridbag", [1 12 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Pink", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "pinkcolormap_radio"); - - // Radio buttons : Rainbow - - c = createConstraints("gridbag", [1 13 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Rainbow", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "rainbowcolormap_radio"); - - // Radio buttons : Ocean - - c = createConstraints("gridbag", [1 14 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Ocean", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "oceancolormap_radio"); - - // Radio buttons : White - - c = createConstraints("gridbag", [1 15 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "White", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_colormap", ... - "constraints" , c, ... - "tag" , "whitecolormap_radio"); - - // Plot3d creation - // ========================================================================= - - my_plot_axes = gca(); - - my_plot_axes.x_label.text = ""; - my_plot_axes.y_label.text = ""; - my_plot_axes.z_label.text = ""; - my_plot_axes.title.text = ""; - my_plot_axes.title.font_size = 5; - my_plot_axes.rotation_angles(1) = 80; - my_plot_axes.axes_bounds = [ ((2*margin_x+frame_w)/axes_w) 0 1-((2*margin_x+frame_w)/axes_w) 1]; - - // define colormap - colormapSize = 128; - f = gcf(); - f.color_map = jetcolormap(128); - - // generate facet coordinates - x = %pi * [-1:0.05:1]';z = sin(x)*cos(x)'; - [x,y,z] = genfac3d(x,x,z); - - // generate colors - // colors depending on z, between 1 and colormap size - facetsColors = (z + 1) * (colormapSize - 1) / 2 + 1; - - // plot - plot3d(x,y,list(z, facetsColors)); - - // Colorbar - z_min = min(z); - z_max = max(z); - colorbar(z_min,z_max); - - // Background - my_plot_axes.background = color(240,240,240); - - my_plot3d = gce(); - - my_plot_axes.rotation_angles(1) = 80; - - fig_handle.visible = "on"; - -endfunction - - -function demo_update_colormap() - - my_figure = gcf(); - my_plot_axes = gca(); - - my_figure.immediate_drawing = "off"; - - set(findobj("tag", "jetcolormap_radio") , "value", 0); - set(findobj("tag", "parulacolormap_radio") , "value", 0); - set(findobj("tag", "hotcolormap_radio") , "value", 0); - set(findobj("tag", "graycolormap_radio") , "value", 0); - set(findobj("tag", "wintercolormap_radio") , "value", 0); - set(findobj("tag", "springcolormap_radio") , "value", 0); - set(findobj("tag", "summercolormap_radio") , "value", 0); - set(findobj("tag", "autumncolormap_radio") , "value", 0); - set(findobj("tag", "bonecolormap_radio") , "value", 0); - set(findobj("tag", "coppercolormap_radio") , "value", 0); - set(findobj("tag", "pinkcolormap_radio") , "value", 0); - set(findobj("tag", "HSVcolormap_radio") , "value", 0); - set(findobj("tag", "rainbowcolormap_radio") , "value", 0); - set(findobj("tag", "oceancolormap_radio") , "value", 0); - set(findobj("tag", "whitecolormap_radio") , "value", 0); - - set(gcbo, "value", 1); - - my_wanted_colormap = get(gcbo,"tag"); - - if get(gcbo, "tag") == "jetcolormap_radio" then - my_figure.color_map = jetcolormap(128); - elseif get(gcbo, "tag") == "parulacolormap_radio" then - my_figure.color_map = parulacolormap(128); - elseif get(gcbo, "tag") == "hotcolormap_radio" then - my_figure.color_map = hotcolormap(128); - elseif get(gcbo, "tag") == "graycolormap_radio" then - my_figure.color_map = graycolormap(128); - elseif get(gcbo, "tag") == "wintercolormap_radio" then - my_figure.color_map = wintercolormap(128); - elseif get(gcbo, "tag") == "springcolormap_radio" then - my_figure.color_map = springcolormap(128); - elseif get(gcbo, "tag") == "summercolormap_radio" then - my_figure.color_map = summercolormap(128); - elseif get(gcbo, "tag") == "autumncolormap_radio" then - my_figure.color_map = autumncolormap(128); - elseif get(gcbo, "tag") == "bonecolormap_radio" then - my_figure.color_map = bonecolormap(128); - elseif get(gcbo, "tag") == "coppercolormap_radio" then - my_figure.color_map = coppercolormap(128); - elseif get(gcbo, "tag") == "pinkcolormap_radio" then - my_figure.color_map = pinkcolormap(128); - elseif get(gcbo, "tag") == "HSVcolormap_radio" then - my_figure.color_map = hsvcolormap(128); - elseif get(gcbo, "tag") == "rainbowcolormap_radio" then - my_figure.color_map = rainbowcolormap(128); - elseif get(gcbo, "tag") == "oceancolormap_radio" then - my_figure.color_map = oceancolormap(128); - elseif get(gcbo, "tag") == "whitecolormap_radio" then - my_figure.color_map = whitecolormap(128); - end - - // Background - my_plot_axes.background = color(240,240,240); - - my_figure.immediate_drawing = "on"; - -endfunction - -funcprot(prot); - -demo_colormap(); -clear demo_colormap; diff --git a/scilab/modules/graphics/demos/colormap/colormaps.dem.sce b/scilab/modules/graphics/demos/colormap/colormaps.dem.sce new file mode 100644 index 0000000..69b5f75 --- /dev/null +++ b/scilab/modules/graphics/demos/colormap/colormaps.dem.sce @@ -0,0 +1,225 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Pierre MARECHAL +// Copyright (C) 2016 - Scilab Enterprises - Paul Bignier +// Copyright (C) 2017 - Samuel GOUGEON +// +// This file is released under the 3-clause BSD license. See COPYING-BSD. + +prot = funcprot(); +funcprot(0); + +function demo_colormaps() + + // Parameters + // ========================================================================= + + frame_w = 150; // Frame width + frame_h = 330; // Frame height + + plot_w = 600; // Plot width + plot_h = 550; // Plot height + + margin_x = 15; // Horizontal margin between each elements + margin_y = 15; // Vertical margin between each elements + + defaultfont = "arial"; // Default Font + text_font_size = 12; // Text font size + + // Figure creation + // ========================================================================= + + axes_w = 3*margin_x + frame_w + plot_w; // axes width + axes_h = 2*margin_y + max(frame_h,plot_h); // axes height + + fig_handle = figure( ... + "infobar_visible", "off", ... + "toolbar_visible", "off", ... + "toolbar", "none", ... + "default_axes", "on", ... + "layout", "gridbag", ... + "visible", "off", ... + "background", -2, ... + "figure_position", [0 0], ... + "axes_size", [axes_w axes_h], ... + "figure_name", _("Misc")); + + c = createConstraints("gridbag", [2 1 1 1], [1 1], "vertical", "right"); + // Create an empty panel on the right to occupy the 3/4 of the screen (figure plot) + empty_frame = uicontrol(fig_handle, "style", "frame","constraints", c); + + c = createConstraints("gridbag", [1 1 1 5], [0 1], "both", "left", [0 0], [90 0]); + u = uicontrol(fig_handle, ... + "style", "frame", ... + "backgroundcolor", [1 1 1], ... + "layout", "border", ... + "constraints", c); + + // Add top and bottom empty panels to pad the upcoming colormap panel + c = createConstraints("border", "top", [0 80]); + top = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); + c = createConstraints("border", "bottom", [0 80]); + bottom = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); + + // Border for the colormap frame + b_f_colormap = createBorderFont("", 15); + b_l_colormap = createBorder("line", "navy", 2); + b_colormap = createBorder("titled", b_l_colormap, "Colormap", "center", "top", b_f_colormap, "navy"); + + colormap_frame = uicontrol(u, ... + "style", "frame", ... + "backgroundcolor", [1 1 1], ... + "border", b_colormap, ... + "layout", "gridbag", ... + "tag", "colormap_frame"); + + demo_viewCode("colormaps.dem.sce"); + + fig_handle.color_map = jetcolormap(128); + + // Radio buttons + // ========================================================================= + colormaps = ["Jet" "Parula" "HSV" "Hot" "Gray" .. + "Winter" "Spring" "Summer" "Autumn" .. + "Bone" "Copper" "Pink" "Rainbow" "Ocean" "White"]; + for i = 1:size(colormaps,"*") + mapname = colormaps(i); + c = createConstraints("gridbag", [1 i 1 1], [1 1], "both", "upper"); + disk_radio = uicontrol( ... + "parent" , colormap_frame, ... + "style" , "radiobutton", ... + "string" , mapname, ... + "fontname" , defaultfont, ... + "fontunits" , "points", ... + "fontsize" , text_font_size, ... + "value" , 1*(i==1), ... + "background" , [1 1 1], ... + "callback" , "demo_update_misc", ... + "groupname" , "colormap_demo", .. + "constraints" , c, ... + "tag" , mapname+"colormap_radio"); + end + + // Plots creation + // ========================================================================= + + drawlater(); + + my_plot_region_pos_x = ((2*margin_x+frame_w)/axes_w); + my_plot_region_pos_y = 0; + my_plot_region_w = 1-my_plot_region_pos_x; + my_plot_region_h = 1; + + // First plot : grayplot(); top - left + + my_plot_1_axes = newaxes(); + my_plot_1_pos_x = ((2*margin_x+frame_w)/axes_w); + my_plot_1_pos_y = 0.05; + my_plot_1_w = (1-my_plot_region_pos_x)/2.3; + my_plot_1_h = 1/2.3; + my_plot_1_axes.axes_bounds = [ my_plot_1_pos_x my_plot_1_pos_y my_plot_1_w my_plot_1_h ]; + grayplot(); + my_plot_1_axes.tight_limits = "on"; + e = my_plot_1_axes.children(1); + z = e.data.z + e.data.z(1,1) = min(z)+(max(z)-min(z))/127*128; + + // Second plot : plot3d1(); top right + + my_plot_2_axes = newaxes(); + // my_plot_2_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2; + my_plot_2_pos_x = my_plot_1_pos_x + my_plot_1_w; + my_plot_2_pos_y = 0; + my_plot_2_w = (1-my_plot_region_pos_x)/2 + 0.03; + my_plot_2_h = 1/2; + my_plot_2_axes.axes_bounds = [ my_plot_2_pos_x my_plot_2_pos_y my_plot_2_w my_plot_2_h ]; + plot3d1(); + my_plot_2_axes.rotation_angles = [80 45]; + + // Third plot : grayplot(); bottom - left + + my_plot_3_axes = newaxes(); + my_plot_3_pos_x = ((2*margin_x+frame_w)/axes_w); + my_plot_3_pos_y = 1/2; + my_plot_3_w = (1-my_plot_region_pos_x)/2; + my_plot_3_h = 1/2; + my_plot_3_axes.axes_bounds = [ my_plot_3_pos_x my_plot_3_pos_y my_plot_3_w my_plot_3_h ]; + Matplot() + isoview + my_plot_3_axes.axes_bounds(3:4) = [0.33 0.45]; + xtitle("Matplot","","") + + // Fourth plot : knot(); bottom - right + + my_plot_4_axes = newaxes(); + // my_plot_4_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2; + my_plot_4_pos_x = my_plot_3_pos_x + my_plot_3_w - 0.05; + my_plot_4_pos_y = 1/2; + my_plot_4_w = 0.5; + my_plot_4_h = 1/2; + my_plot_4_axes.axes_bounds = [ my_plot_4_pos_x my_plot_4_pos_y my_plot_4_w my_plot_4_h ]; + + deff("[x,y,z] = knot(u,v)",.. + ["vv = ones(v)"; + "uu = ones(u);"; + "x = (5.*cos(u)+cos(u).*cos(v))"; + "y = (5.*sin(u)+sin(u).*cos(v))"; + "z = (uu.*sin(v))";]) + + nx=60; + Nx=(0:nx)/nx; + ny=20; + Ny=(0:ny)/ny; + + [xx,yy,zz]=eval3dp(knot,2*%pi*Nx,2*%pi*Ny); + XXX=[-xx xx]; + YYY=[-yy zz]; + ZZZ=[-zz yy]; + kk1=[1:size(zz,2)]; + + kk1=modulo(kk1,60)*2; + kk2=kk1; + KKK=list(ZZZ,[kk1 kk2]); + plot3d(XXX,YYY,KKK,35,70," @ @ ",[2,1,4],[-6,6,-6,6,-6,6]); + + // define colormap + f = gcf(); + f.color_map = jetcolormap(128); + + my_plot_2_axes.background = color(240,240,240); + my_plot_4_axes.background = color(240,240,240); + + // Color bar + colorbar(0,128, [0 128], "%d"); + gcf().children(1).axes_bounds = [0.14 0.1 0.1 0.8]; + gcf().figure_name = "Jetcolormap"; + drawnow(); + + fig_handle.visible = "on"; +endfunction + + +function demo_update_misc() + my_figure = gcf(); + my_figure.immediate_drawing = "off"; + set(gcbo, "value", 1); + colormap_name = strtok(get(gcbo,"tag"),"_"); + execstr(["my_figure.color_map = "+convstr(colormap_name,'l')+"(128);" + "my_figure.figure_name = """+colormap_name+""""]); + + // Gray background for 3d axes + for i = 1:size(my_figure.children,"*"), + child = my_figure.children(i); + if child.type=="Axes" then + if child.view=="3d" then + child.background = color(240,240,240); + end + end + end + + // Plot + my_figure.immediate_drawing = "on"; +endfunction + +funcprot(prot); +demo_colormaps(); +clear demo_colormaps; diff --git a/scilab/modules/graphics/demos/graphics.dem.gateway.sce b/scilab/modules/graphics/demos/graphics.dem.gateway.sce index 94cdfe0..348b60d 100644 --- a/scilab/modules/graphics/demos/graphics.dem.gateway.sce +++ b/scilab/modules/graphics/demos/graphics.dem.gateway.sce @@ -22,8 +22,7 @@ function subdemolist = demo_gateway() _("Datatips") ,"datatips/datatips.dem.gateway.sce" ; .. _("LaTeX/MathML") ,"textrendering/textrendering.dem.gateway.sce" ; .. _("Lighting") ,"lighting/lighting.dem.gateway.sce" ; .. - _("Misc") ,"misc/misc.dem.sce" ; .. - _("Colormap") ,"colormap/colormap.dem.sce" ; .. + _("Colormap") ,"colormap/colormaps.dem.sce" ; .. _("Matplot") ,"matplot/matplot.dem.gateway.sce"]; subdemolist(:,2) = demopath + subdemolist(:,2); diff --git a/scilab/modules/graphics/demos/misc/misc.dem.sce b/scilab/modules/graphics/demos/misc/misc.dem.sce deleted file mode 100644 index 93d3e42..0000000 --- a/scilab/modules/graphics/demos/misc/misc.dem.sce +++ /dev/null @@ -1,486 +0,0 @@ -// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab -// Copyright (C) 2008 - INRIA - Pierre MARECHAL -// Copyright (C) 2016 - Scilab Enterprises - Paul Bignier -// -// This file is released under the 3-clause BSD license. See COPYING-BSD. - -prot = funcprot(); -funcprot(0); - -function demo_misc() - - // Parameters - // ========================================================================= - - frame_w = 200; // Frame width - frame_h = 330; // Frame height - - plot_w = 600; // Plot width - plot_h = 550; // Plot height - - margin_x = 15; // Horizontal margin between each elements - margin_y = 15; // Vertical margin between each elements - - defaultfont = "arial"; // Default Font - text_font_size = 12; // Text font size - - // Figure creation - // ========================================================================= - - axes_w = 3*margin_x + frame_w + plot_w; // axes width - axes_h = 2*margin_y + max(frame_h,plot_h); // axes height - - fig_handle = figure( ... - "infobar_visible", "off", ... - "toolbar_visible", "off", ... - "toolbar", "none", ... - "default_axes", "on", ... - "layout", "gridbag", ... - "visible", "off", ... - "background", -2, ... - "figure_position", [0 0], ... - "axes_size", [axes_w axes_h], ... - "figure_name", _("Misc")); - - c = createConstraints("gridbag", [2 1 1 1], [1 1], "vertical", "right"); - // Create an empty panel on the right to occupy the 3/4 of the screen (figure plot) - empty_frame = uicontrol(fig_handle, "style", "frame","constraints", c); - - c = createConstraints("gridbag", [1 1 1 5], [0.05 1], "both", "left", [0 0], [150 0]); - u = uicontrol(fig_handle, ... - "style", "frame", ... - "backgroundcolor", [1 1 1], ... - "layout", "border", ... - "constraints", c); - - // Add top and bottom empty panels to pad the upcoming colormap panel - c = createConstraints("border", "top", [0 80]); - top = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); - c = createConstraints("border", "bottom", [0 80]); - bottom = uicontrol(u, "style", "frame", "backgroundcolor", [1 1 1], "constraints", c); - - // Border for the colormap frame - b_f_colormap = createBorderFont("", 18); - b_l_colormap = createBorder("line", "navy", 2); - b_colormap = createBorder("titled", b_l_colormap, "Colormap", "center", "top", b_f_colormap, "navy"); - - colormap_frame = uicontrol(u, ... - "style", "frame", ... - "backgroundcolor", [1 1 1], ... - "border", b_colormap, ... - "layout", "gridbag", ... - "tag", "colormap_frame"); - - demo_viewCode("misc.dem.sce"); - - fig_handle.color_map = jetcolormap(128); - - // Radio buttons - // ========================================================================= - - // Radio buttons : Jet - - c = createConstraints("gridbag", [1 1 1 1], [1 1], "both", "upper"); - square_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Jet", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 1, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "jetcolormap_radio"); - - // Radio buttons : Parula - - c = createConstraints("gridbag", [1 2 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Parula", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "parulacolormap_radio"); - - // Radio buttons : HSV - - c = createConstraints("gridbag", [1 3 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "HSV", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "HSVcolormap_radio"); - - // Radio buttons : Hot - - c = createConstraints("gridbag", [1 4 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Hot", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "hotcolormap_radio"); - - // Radio buttons : Gray - - c = createConstraints("gridbag", [1 5 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Gray", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "graycolormap_radio"); - - // Radio buttons : Winter - - c = createConstraints("gridbag", [1 6 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Winter", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "wintercolormap_radio"); - - // Radio buttons : Spring - - c = createConstraints("gridbag", [1 7 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Spring", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "springcolormap_radio"); - - // Radio buttons : Summer - - c = createConstraints("gridbag", [1 8 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Summer", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "summercolormap_radio"); - - // Radio buttons : Autumn - - c = createConstraints("gridbag", [1 9 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Autumn", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "autumncolormap_radio"); - - // Radio buttons : Bone - - c = createConstraints("gridbag", [1 10 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Bone", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "bonecolormap_radio"); - - // Radio buttons : Copper - - c = createConstraints("gridbag", [1 11 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Copper", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "coppercolormap_radio"); - - // Radio buttons : Pink - - c = createConstraints("gridbag", [1 12 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Pink", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "pinkcolormap_radio"); - - // Radio buttons : Rainbow - - c = createConstraints("gridbag", [1 13 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Rainbow", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "rainbowcolormap_radio"); - - // Radio buttons : Ocean - - c = createConstraints("gridbag", [1 14 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "Ocean", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "oceancolormap_radio"); - - // Radio buttons : White - - c = createConstraints("gridbag", [1 15 1 1], [1 1], "both", "upper"); - disk_radio = uicontrol( ... - "parent" , colormap_frame, ... - "style" , "radiobutton", ... - "string" , "White", ... - "fontname" , defaultfont, ... - "fontunits" , "points", ... - "fontsize" , text_font_size, ... - "value" , 0, ... - "background" , [1 1 1], ... - "callback" , "demo_update_misc", ... - "constraints" , c, ... - "tag" , "whitecolormap_radio"); - - // Plots creation - // ========================================================================= - - drawlater(); - - my_plot_region_pos_x = ((2*margin_x+frame_w)/axes_w); - my_plot_region_pos_y = 0; - my_plot_region_w = 1-my_plot_region_pos_x; - my_plot_region_h = 1; - - // First plot : grayplot(); top - left - - my_plot_1_axes = newaxes(); - my_plot_1_pos_x = ((2*margin_x+frame_w)/axes_w); - my_plot_1_pos_y = 0; - my_plot_1_w = (1-my_plot_region_pos_x)/2; - my_plot_1_h = 1/2; - my_plot_1_axes.axes_bounds = [ my_plot_1_pos_x my_plot_1_pos_y my_plot_1_w my_plot_1_h ]; - grayplot(); - - // Second plot : plot3d1(); top right - - my_plot_2_axes = newaxes(); - my_plot_2_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2; - my_plot_2_pos_y = 0; - my_plot_2_w = (1-my_plot_region_pos_x)/2; - my_plot_2_h = 1/2; - my_plot_2_axes.axes_bounds = [ my_plot_2_pos_x my_plot_2_pos_y my_plot_2_w my_plot_2_h ]; - plot3d1(); - - // Third plot : grayplot(); bottom - left - - my_plot_3_axes = newaxes(); - my_plot_3_pos_x = ((2*margin_x+frame_w)/axes_w); - my_plot_3_pos_y = 1/2; - my_plot_3_w = (1-my_plot_region_pos_x)/2; - my_plot_3_h = 1/2; - my_plot_3_axes.axes_bounds = [ my_plot_3_pos_x my_plot_3_pos_y my_plot_3_w my_plot_3_h ]; - grayplot(); - - // Fourth plot : knot(); bottom - right - - my_plot_4_axes = newaxes(); - my_plot_4_pos_x = ((2*margin_x+frame_w)/axes_w) + my_plot_region_w/2; - my_plot_4_pos_y = 1/2; - my_plot_4_w = (1-my_plot_region_pos_x)/2; - my_plot_4_h = 1/2; - my_plot_4_axes.axes_bounds = [ my_plot_4_pos_x my_plot_4_pos_y my_plot_4_w my_plot_4_h ]; - - deff("[x,y,z]=knot(u,v)",["vv=ones(v)";"uu=ones(u);"; - "x=(5.*cos(u)+cos(u).*cos(v))"; - "y=(5.*sin(u)+sin(u).*cos(v))"; - "z=(uu.*sin(v))";]) - - nx=60; - Nx=(0:nx)/nx; - ny=20; - Ny=(0:ny)/ny; - - [xx,yy,zz]=eval3dp(knot,2*%pi*Nx,2*%pi*Ny); - XXX=[-xx xx]; - YYY=[-yy zz]; - ZZZ=[-zz yy]; - kk1=[1:size(zz,2)]; - - kk1=modulo(kk1,60); - kk2=kk1; - KKK=list(ZZZ,[kk1 kk2]); - plot3d(XXX,YYY,KKK,35,70," @ @ ",[2,1,4],[-6,6,-6,6,-6,6]); - - // define colormap - colormapSize = 128; - f = gcf(); - f.color_map = jetcolormap(128); - - my_plot_2_axes.background = color(240,240,240); - my_plot_4_axes.background = color(240,240,240); - - drawnow(); - - fig_handle.visible = "on"; - -endfunction - - -function demo_update_misc() - - my_figure = gcf(); - - my_figure.immediate_drawing = "off"; - - set(findobj("tag", "jetcolormap_radio") , "value", 0); - set(findobj("tag", "parulacolormap_radio") , "value", 0); - set(findobj("tag", "HSVcolormap_radio") , "value", 0); - set(findobj("tag", "hotcolormap_radio") , "value", 0); - set(findobj("tag", "graycolormap_radio") , "value", 0); - set(findobj("tag", "wintercolormap_radio") , "value", 0); - set(findobj("tag", "springcolormap_radio") , "value", 0); - set(findobj("tag", "summercolormap_radio") , "value", 0); - set(findobj("tag", "autumncolormap_radio") , "value", 0); - set(findobj("tag", "bonecolormap_radio") , "value", 0); - set(findobj("tag", "coppercolormap_radio") , "value", 0); - set(findobj("tag", "pinkcolormap_radio") , "value", 0); - set(findobj("tag", "rainbowcolormap_radio") , "value", 0); - set(findobj("tag", "oceancolormap_radio") , "value", 0); - set(findobj("tag", "whitecolormap_radio") , "value", 0); - - set(gcbo, "value", 1); - - my_wanted_colormap = get(gcbo,"tag"); - - if get(gcbo, "tag") == "jetcolormap_radio" then - my_figure.color_map = jetcolormap(128); - elseif get(gcbo, "tag") == "parulacolormap_radio" then - my_figure.color_map = parulacolormap(128); - elseif get(gcbo, "tag") == "hotcolormap_radio" then - my_figure.color_map = hotcolormap(128); - elseif get(gcbo, "tag") == "graycolormap_radio" then - my_figure.color_map = graycolormap(128); - elseif get(gcbo, "tag") == "wintercolormap_radio" then - my_figure.color_map = wintercolormap(128); - elseif get(gcbo, "tag") == "springcolormap_radio" then - my_figure.color_map = springcolormap(128); - elseif get(gcbo, "tag") == "summercolormap_radio" then - my_figure.color_map = summercolormap(128); - elseif get(gcbo, "tag") == "autumncolormap_radio" then - my_figure.color_map = autumncolormap(128); - elseif get(gcbo, "tag") == "bonecolormap_radio" then - my_figure.color_map = bonecolormap(128); - elseif get(gcbo, "tag") == "coppercolormap_radio" then - my_figure.color_map = coppercolormap(128); - elseif get(gcbo, "tag") == "pinkcolormap_radio" then - my_figure.color_map = pinkcolormap(128); - elseif get(gcbo, "tag") == "HSVcolormap_radio" then - my_figure.color_map = hsvcolormap(128); - elseif get(gcbo, "tag") == "rainbowcolormap_radio" then - my_figure.color_map = rainbowcolormap(128); - elseif get(gcbo, "tag") == "oceancolormap_radio" then - my_figure.color_map = oceancolormap(128); - elseif get(gcbo, "tag") == "whitecolormap_radio" then - my_figure.color_map = whitecolormap(128); - end - - // Gray background for 3d axes - - for i = 1:size(my_figure.children,"*"), - child = my_figure.children(i); - if child.type=="Axes" then - if child.view=="3d" then - child.background = color(240,240,240); - end - end - end - - // Plot - - my_figure.immediate_drawing = "on"; - - - -endfunction - -funcprot(prot); - -demo_misc(); -clear demo_misc; -- 1.7.9.5