From: Samuel GOUGEON Date: Sun, 31 Jan 2021 01:06:44 +0000 (+0100) Subject: * Bug 16638 fixed: getcolor() rendering debugged X-Git-Tag: 6.1.1~97 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=c3bfb2899804b4f229f30e35670f8c43285c9a43;hp=e2d0fd91c0fed29d65cc67500b7d719b6a7b7dd6 * Bug 16638 fixed: getcolor() rendering debugged http://bugzilla.scilab.org/16638 Page illustrated: http://bugzilla.scilab.org/attachment.cgi?id=5226 Change-Id: I4235ec23407d3df5b87ac61f35e32f3d345c4fc7 --- diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 08399fc..960105c 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -201,7 +201,6 @@ Feature changes and additions on 6.1.1 - It can now sort any sparse 2D matrix, in all `g, r, c, lr, lc` methods, including sparse booleans and in multi-level mode. It was formerly limited to sparse real or complex vectors and only to the `g` mode. - Any hypermatrix can be sorted along a dimension > 2. * `unique` is enabled for any 2D sparse arrays, in simple, 'c' and 'r' modes. -<<<<<<< HEAD * `%chars` constant added, to easily access to some selected sets of unicode symbols. * Lists are displayed in a more compact and comprehensive way. * `interp1` is upgraded: @@ -226,11 +225,8 @@ Feature changes and additions on 6.1.1 * `close` is extended to close the help browser, xcos, or the variables browser or editor GUIs. * `polyint` is introduced to compute polynomial antiderivatives. * Listbox uicontrol callback is now triggered by item click in single selection mode. For example, it allows successive execution of a demo in the demonstrations gui. - -======= -* %chars constant added, to easily access to some selected sets of unicode symbols. * `det` is now actually extended to sparse matrices. ->>>>>>> 608020c6bbd (* Bug 16636 fixed: det(sparse) now actually implemented) + Help pages: ----------- @@ -434,6 +430,7 @@ Bug Fixes * [#16631](https://bugzilla.scilab.org/16631): read-only handle properties were reported as unknown when trying to set them. * [#16632](https://bugzilla.scilab.org/16632): Scilab did not start with unsupported locale on macOS. * [#16636](https://bugzilla.scilab.org/16636): `det(sparse)` most often yielded `Nan`. `[e,m]=det(sparse)` was not actually implemented. +* [#16638](https://bugzilla.scilab.org/16638): `getcolor` shew a bunch of issues. * [#16644](https://bugzilla.scilab.org/16644): `input("message:")` yielded a wrong error message about `mprintf` in case of non-interpretable input. * [#16654](https://bugzilla.scilab.org/16654): `interp` was leaking memory. diff --git a/scilab/modules/graphics/help/en_US/color_management/getcolor.xml b/scilab/modules/graphics/help/en_US/color_management/getcolor.xml index e36aaf6..023ab48 100644 --- a/scilab/modules/graphics/help/en_US/color_management/getcolor.xml +++ b/scilab/modules/graphics/help/en_US/color_management/getcolor.xml @@ -2,8 +2,8 @@ - + getcolor - opens a dialog to show colors in the current colormap + opens a dialog to show colors of the current or default colormap Syntax - c=getcolor(title,[cini]) - c=getcolor() + + c = getcolor() + c = getcolor(title) + c = getcolor(title, cini) @@ -36,13 +41,13 @@ cini - initial selected color id. Default value is 1. + initial selected color index. Default value is 1. c - selected color id or [] if the selection is cancelled. + index of the selected color, or [] if the selection is canceled. @@ -50,26 +55,47 @@ Description - getcolor opens a window displaying the palette of the current colormap. - The user can click on a color to show its id and RGB values. - getcolor returns the id of the selected color or [] if the "Cancel" button has been clicked or the window closed. + getcolor opens a window displaying the palette of the current + colormap, or of the default one if no graphical figure exists. + The user can click on a color to show its index and its RGB values + in the bottom bar. + getcolor returns the index of the selected color, or [] if the "Cancel" + button has been clicked or the window has been closed. Examples +c = getcolor("Please choose a color"); + ]]> + + + + + + + + c = getcolor("Please choose a color") + c = + 28. +]]> See also + uigetcolor + + + color_list + + color diff --git a/scilab/modules/graphics/help/images/getcolor.png b/scilab/modules/graphics/help/images/getcolor.png new file mode 100644 index 0000000..51b82ef Binary files /dev/null and b/scilab/modules/graphics/help/images/getcolor.png differ diff --git a/scilab/modules/graphics/help/ja_JP/color_management/getcolor.xml b/scilab/modules/graphics/help/ja_JP/color_management/getcolor.xml index 79b03ae..4187203 100644 --- a/scilab/modules/graphics/help/ja_JP/color_management/getcolor.xml +++ b/scilab/modules/graphics/help/ja_JP/color_management/getcolor.xml @@ -1,15 +1,9 @@ - - - - + - getcolor - カレントのカラーマップの色を示すダイアログをオープンする - - - 呼び出し手順 - - c=getcolor(title,[cini]) - - c=getcolor() - + + c = getcolor() + c = getcolor(title) + c = getcolor(title, cini) - - - 引数 - - - title - - 文字列, ダイアログのタイトル. - - - - cini - - 選択された初期値の色ID.デフォルト値はs 1. - - - - c - - 選択された色IDまたは - 選択がキャンセルされた場合に []. - - - - - - - 説明 - - getcolor はカレントのカラーマップのパレットを表示する - ウインドウをオープンします. - ユーザはそのIDとRGB値を表示するために色をクリックすることができます. - getcolor は選択された色のID,または - "Cancel"ボタンがクリックされたかウインドウがクローズされた場合に []を返します. - - - - 例 - - +c = getcolor(); +c = getcolor("Title foo", color("red")); // 赤を選択 +c = getcolor("Please choose a color"); + ]]> + + + + + + + + c = getcolor("Please choose a color") + c = + 28. +]]> - - - - 参照 - - - + uigetcolor + + + color_list + + color - - - colormap - - - - - - + \ No newline at end of file diff --git a/scilab/modules/graphics/help/pt_BR/color_management/getcolor.xml b/scilab/modules/graphics/help/pt_BR/color_management/getcolor.xml index c9da43a..317005a 100644 --- a/scilab/modules/graphics/help/pt_BR/color_management/getcolor.xml +++ b/scilab/modules/graphics/help/pt_BR/color_management/getcolor.xml @@ -2,8 +2,8 @@ - + getcolor - abre um diálogo que exibe as cores no mapa de cores + abre um diálogo que exibe as cores no mapa de cores atual ou padrão corrente Seqüência de Chamamento - c=getcolor(title,[cini]) - c=getcolor() + + c = getcolor() + c = getcolor(title) + c = getcolor(title, cini) @@ -38,15 +43,14 @@ cini - identificador da cor selecionada inicial. O valor padrão é - 1. + número da cor selecionada inicial. O valor padrão é 1. c - identificador da cor selecionada ou [] se o usuário tiver + número da cor selecionada, ou [] se o usuário tiver clicado no botão "Cancel" (cancelar). @@ -56,17 +60,44 @@ Descrição - getcolor abre uma janela que exibe o palete do - mapa de cores corrente. O usuário pode clicar numa cor para exibir seu - identificador e valores RGB. getcolor retorna o - identificador da cor selecionada ou [] se o usuário clicar no botão - "Cancel". + getcolor abre uma janela que exibe o palete do mapa + de cores corrente o padrão. O usuário pode clicar numa cor para exibir seu + número e valores RGB. getcolor retorna o + número da cor selecionada, ou [] se o usuário clicar no botão "Cancel". + + Exemplos + + + + + + + + + c = getcolor("Please choose a color") + c = + 28. +]]> + Ver Também + uigetcolor + + + color_list + + color diff --git a/scilab/modules/graphics/help/ru_RU/color_management/getcolor.xml b/scilab/modules/graphics/help/ru_RU/color_management/getcolor.xml new file mode 100644 index 0000000..18319c6 --- /dev/null +++ b/scilab/modules/graphics/help/ru_RU/color_management/getcolor.xml @@ -0,0 +1,114 @@ + + + + + getcolor + + открывает диалог для показа цветов текущей цветовой карты или цветовой + карты по умолчанию + + + + Синтаксис + + c = getcolor() + c = getcolor(title) + c = getcolor(title, cini) + + + + Аргументы + + + title + + строка, название диалога. + + + + cini + + + индекс исходного выбранного цвета. Значению по умолчанию 1. + + + + + c + + + индекс выбранного цвета или [], если + выбор отменён. + + + + + + Описание + + getcolor открывает окно, отображающее палитру текущей + цветовой карты, либо цветовой карты по умолчанию, если не существует + графического окна. Пользователь может щёлкнуть по цвету чтобы показать + его индекс и его RGB-значения на панели снизу. + getcolor возвращает индекс выбранного цвета, либо + [], если выбор нажата кнопка "Отмена", либо окно + было закрыто. + + + + Примеры + + + + + + + + + c = getcolor("Please choose a color") + c = + 28. +]]> + + + + Смотрите также + + + uigetcolor + + + color_list + + + color + + + colormap + + + + diff --git a/scilab/modules/graphics/macros/getcolor.sci b/scilab/modules/graphics/macros/getcolor.sci index 19a4282..133780b 100644 --- a/scilab/modules/graphics/macros/getcolor.sci +++ b/scilab/modules/graphics/macros/getcolor.sci @@ -1,8 +1,7 @@ // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) INRIA -// Copyright (C) 2017 - Samuel GOUGEON -// // Copyright (C) 2012 - 2016 - Scilab Enterprises +// Copyright (C) 2017, 2021 - Samuel GOUGEON // // This file is hereby licensed under the terms of the GNU GPL v2.0, // pursuant to article 5.3.4 of the CeCILL v.2.1. @@ -57,32 +56,33 @@ function [c] = getcolor(Title,cini) else cmap = [] curwin = [] - end; + end // create the window for getcolor - fig = scf(); - fig.visible = "off"; + fig = figure("visible","off","background",-2); //scf(); win = fig.figure_id; sdf; // quite agressive. Not sure it is actually useful sda; // same remark if cmap~=[] then fig.color_map = cmap; + fig.figure_name = gettext("Current colormap") else cmap = fig.color_map; + fig.figure_name = gettext("Default colormap") end; N = size(cmap,1); wdim = [1,1]; - r = wdim(1)/wdim(2); - n = round(sqrt(N/r)); - m = int(n*r); - H = m*45; // These numbers set the size of the getcolor window - W = n*45; - fig.figure_size = [H,W]; + m = ceil(sqrt(N)); + n = ceil(N/m); + [W, H] = (max(m*35,320), n*40) // minW=320 for infos in status bar + fig.axes_size = [W,H]; + // position = center of screen: + c = get(0,"screensize_px") + fig.figure_position = [c(3)-W, c(4)-fig.figure_size(2)]/2 toolbar(win, "off") - delmenu(win, gettext("&File")) delmenu(win, gettext("&Tools")) delmenu(win, gettext("&Edit")) @@ -101,32 +101,31 @@ function [c] = getcolor(Title,cini) end; rects = [rects,R+[x;y;0;0]]; y = y-dy; - end; + end if Title~="" then xsetech([-1/8,0,1+1/6,1+1/6-1/8],[0,0,wdim(1),wdim(2)]); else xsetech([-1/8,-1/8,1+1/6,1+1/6],[0,0,wdim(1),wdim(2)]); - end; + end // rectangles with the colors xrects(rects,1:N); + // frame around the colors r = m*n-N; ddx = 0.05*dx; ddy = 0.05*dy; - if r==0 then + if abs(r)<0.1 then xpoly([-ddx,1,1,-ddx],[0,0,1+ddy,1+ddy],"lines",1); else - xpoly([-ddx,1-1/n,1-1/n,1,1,-ddx],[0,0,r/m,r/m,1+ddy,1+ddy],"lines",1); - end; + xpoly([-ddx, 1-dx, 1-dx, 1 , 1 ,-ddx],.. + [ 0 , 0 , r*dy, r*dy, 1+ddy,1+ddy], "lines",1); + end // title if Title~="" then - xtitle(Title); - t = gce(); - t.font_size = 4; - t.font_style = 6; - end; + title(Title, "fontsize",3, "font_style",6) + end k1 = min(max(cini,1),N); xrects(rects(eye(),k1),-k1); @@ -142,6 +141,7 @@ function [c] = getcolor(Title,cini) addmenu(win, gettext("Ok")); addmenu(win, gettext("Cancel")); + set(gca(),"tight_limits","on","axes_bounds",[0 0 1 1],"margins",[.05 .05 .15 .05]); fig.visible = "on"; c_i = 0; @@ -158,7 +158,7 @@ function [c] = getcolor(Title,cini) elseif (c_i== -2) then if str==Ok then k = k1; c = k; break;end; if str==Cancel then k = []; c = []; break;end; - end; + end mc = int(cx/dx)+1; nc = n-int(cy/dy); @@ -184,8 +184,6 @@ function [c] = getcolor(Title,cini) if curwin~=[] then scf(curwin); - end; - - + end endfunction diff --git a/scilab/modules/helptools/images/getcolor.png b/scilab/modules/helptools/images/getcolor.png new file mode 100644 index 0000000..51b82ef Binary files /dev/null and b/scilab/modules/helptools/images/getcolor.png differ