- Returned indices can now be formatted with the new option `indType`.
- There were no unit tests. More than 100 tests are added.
* `datafit` is now able to fit weighted data. It now supports any gap function vectorized for Data points, and so is much faster. It now accepts any matrix of parameters (not necessarily a colum). It now returns the average Mode-to-data distance, and the termination status for the quasi-Newton algo.
+* `tree_show()` is upgraded:
+ - New `rootTitle` and `styles` optional inputs.
+ - New `arrayByFields` option, to allow displaying each array component as an object in its whole.
+ - Improved layout: detailled indices for 2D arrays, simplified symbols, etc.
+ - The content of implicitlist objects, and information for Scilab functions and libraries of functions are now displayed.
+
Help pages:
-----------
* [#16104](https://bugzilla.scilab.org/16104): `assert_checkequal` did not support properly or at all Nan and void in lists, Nan in sparse, implicit lists, macros, libraries, built-in functions, graphical handles. For input arrays or lists of matching typeof and sizes, the failure message did not display neither the index nor the values of the first mismatching elements.
* [#16111](https://bugzilla.scilab.org/16111): `isglobal` was not supporting non-scalar array of strings as input.
* [#16118](https://bugzilla.scilab.org/16118): `%s <> (1+%s)` returned %F.
+* [#16120](https://bugzilla.scilab.org/16120): `tree_show` was broken cells within containers.
+* [#16121](https://bugzilla.scilab.org/16121): `tree_show` void components were displayed as non-empty.
* [#16124](https://bugzilla.scilab.org/16124): `sci2exp({})` result could not be executed.
+* [#16128](https://bugzilla.scilab.org/16128): `tree_show` need improvements.
* [#16129](https://bugzilla.scilab.org/16129): `uiDumpTree()` interpreted "\n" "\r" "\t" sequences in contents as special ones.
* [#16135](https://bugzilla.scilab.org/16135): base2dec did not detect invalid numbers.
* [#16137](https://bugzilla.scilab.org/16137): After running `playsnd` on Windows for a long sound, it was not possible to stop it.
<?xml version="1.0" encoding="UTF-8"?>
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="tree_show">
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2019 - 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.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+ xml:lang="en" xml:id="tree_show">
<refnamediv>
<refname>tree_show</refname>
- <refpurpose>Display a tree view of a list</refpurpose>
+ <refpurpose>Displays a tree view of a list, tlist, mlist, cell or structure array</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Syntax</title>
<synopsis>
tree_show(x)
+ tree_show(x, rootTitle)
+ tree_show(x, rootTitle, styles)
+ tree_show(x, rootTitle, styles, arrayByFields)
</synopsis>
</refsynopsisdiv>
<refsection>
<varlistentry>
<term>x</term>
<listitem>
- <para>list or mlist or tlist to display.</para>
+ <para>
+ Container to display. Supported containers: list, mlist, tlist, array of cells,
+ array of structures. Other containers may be nested in <varname>x</varname>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>rootTitle</term>
+ <listitem>
+ <para>
+ Single string: explicit label of the tree's root, for instance the name of
+ the <varname>x</varname> variable in the calling environment. Default = "".
+ </para>
+ <note>
+ HTML.4 styling tags can be used to change the style of the root's title.
+ Example: "<literal><html><font color="red"><b>The title</b></literal>"
+ will display <emphasis>The title</emphasis> in bold red.
+ </note>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>styles</term>
+ <listitem>
+ <para>
+ Single string = HTML.4 styling tag, including the "$" character that will
+ be replaced with the address (fields names, lists indices..) of each data.
+ </para>
+ <para>
+ The <varname>styles</varname> option can be used to customize the style
+ either of addresses, or of related contents, or both. Examples:
+ <itemizedlist>
+ <listitem>
+ <literal>"<b>$</b>"</literal> : address in bold, content in
+ normal black.
+ </listitem>
+ <listitem>
+ <literal>"$<i>"</literal> : address in normal black, content
+ in italic.
+ </listitem>
+ <listitem>
+ <literal>"<i>$"</literal> : both address and content in italic.
+ </listitem>
+ <listitem>
+ <literal>"<font color=''grey''>$</font><i>"</literal> :
+ address in grey, content in italic.
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Default =
+ <literal>"<font color=""blue"">$</font>"</literal>
+ (address in blue, content in black).
+ </para>
+ <para>
+ Setting <literal>""</literal> removes styling.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>arrayByFields</term>
+ <listitem>
+ <para>
+ Single boolean, used only for arrays of structures:
+ <table>
+ <tr><th>%T :</th>
+ <td>For each field of the struct, the array of its values is displayed.
+ </td>
+ </tr>
+ <tr><th>%F :</th>
+ <td>
+ For each structure of the array, its fields and their values
+ are displayed.
+ </td>
+ </tr>
+ </table>
+ </para>
+ <para>
+ The chosen display mode is used as well for every nested array of structures,
+ at any depths.
+ </para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
- <para>Creates a window and displays a tree view of the given list.</para>
+ <para>
+ Creates a window and displays a tree view of the given container.
+ </para>
+ <warning>
+ The window has no handle.
+ </warning>
</refsection>
<refsection>
<title>Examples</title>
+ <para>
+ <emphasis role="bold">list(), including a cells array</emphasis> :
+ </para>
+ <table>
+ <tr>
+ <td>
+ <programlisting role="example"><![CDATA[
+ films = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+ L = list([%t %f %f], ..
+ $:-1:3, ..
+ int8([1 2 3 ; 4 5 6]), ..
+ [-%inf, -1, 0, %i, 7.1, 3.3e20, %inf, %nan], ..
+ sparse([0 1 2; 3 0 4]), ..
+ ["This" "is" "some" "text"], ..
+ , ..
+ sin, ..
+ logspace, ..
+ iolib, ..
+ {%pi, "abcd" ;
+ list(,)(1),(%i-%s)^3}, ..
+ {}, ..
+ films);
+ tree_show(L)
+ ]]></programlisting>
+ </td>
+ <td>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_list.png"/>
+ </imageobject>
+ </inlinemediaobject>
+ </td>
+ </tr>
+ </table>
+
+ <para>
+ <emphasis role="bold">Using the <emphasis>rootTitle</emphasis> and <emphasis>styles</emphasis>
+ options
+ </emphasis> :
+ </para>
<programlisting role="example"><![CDATA[
-// Simple example
-a=list(1,2,3);
-tree_show(a);
-
-// Another example with mlist
-str=['a','b','c','d','e','f','g','h'];
-n=matrix(str, [2,2,2]);
-v=matrix(1:8, [2,2,2]);
-Mm=mlist(['V','name','value'],n,v);
+// Data to display:
+clear films
+films(1) = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+films(2,2) = struct("Title", "I, robot", ..
+ "Year", 2004, ..
+ "Director", "Alex Proyas", ..
+ "Duration", 120);
+
+// Styling both the addresses and the contents:
+mainTitle = "<html><b>Films (A)</b>";
+tree_show(films, mainTitle , "<font color=""red"">$</font><i>");
+
+// Styling only the contents:
+mainTitle = "<html><b>Films (B)</b>";
+tree_show(films([1 4]), mainTitle, "$<font color=""green"">", %t);
+ ]]></programlisting>
+ <para/>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_styling.png"/>
+ </imageobject>
+ </inlinemediaobject>
+
+ <para>
+ <emphasis role="bold">Array of structures</emphasis> :
+ </para>
+ <programlisting role="example"><![CDATA[
+clear films
+films(1) = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+films(2) = struct("Title", "I, robot", ..
+ "Year", 2004, ..
+ "Director", "Alex Proyas", ..
+ "Duration", 120);
+films(1,2) = struct("Title", "Gravity", ..
+ "Year", 2013, ..
+ "Director", "Alfonso Cuarón", ..
+ "Duration", 100);
+films(2,2) = struct("Title", "2001: A space odyssey", ..
+ "Year", 1968, ..
+ "Director", "Stanley Kubrick", ..
+ "Duration", 141);
+
+tree_show(films(:),"Films (I)");
+tree_show(films ,"Films (II)");
+tree_show(films(:),"Films (III)", , %t);
+tree_show(films ,"Films (IV)" , , %t);
+ ]]></programlisting>
+ <screen><![CDATA[
+2x2 struct array with fields:
+ Title
+ Director
+ Year
+ Duration
+]]></screen>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_2x2.png"/>
+ </imageobject>
+ </inlinemediaobject>
+ <para/>
+
+ <para>
+ <emphasis role="bold">With a custom tlist or mlist</emphasis> :
+ </para>
+ <programlisting role="example"><![CDATA[
+// For a mlist:
+str = ['a','b','c','d','e','f','g','h'];
+n = matrix(str, [2,2,2]);
+v = matrix(1:8, [2,2,2]);
+Mm = mlist(['V','name','value'],n,v);
tree_show(Mm);
-// Another example with tlist
-Mt=tlist(['V','name','value'],['a','b','c'],[1 2 3]);
+// For a tlist:
+Mt = tlist(['V','name','value'],['a','b','c'],[1 2 3]);
tree_show(Mt);
]]></programlisting>
+ <para/>
+ </refsection>
+
+ <refsection role="see also">
+ <title>See Also</title>
+ <simplelist type="inline">
+ <member>
+ <link linkend="uiDisplayTree">uiDisplayTree</link>
+ </member>
+ <member>
+ <link linkend="uiDumpTree">uiDumpTree</link>
+ </member>
+ <member>
+ <link linkend="prettyprint">prettyprint</link>
+ </member>
+ <member>
+ <link linkend="editvar">editvar</link>
+ </member>
+ <member>
+ <link linkend="browsevar">browsevar</link>
+ </member>
+ </simplelist>
+ </refsection>
+
+ <refsection role="history">
+ <title>History</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <itemizedlist>
+ <listitem>
+ rootTitle, styles, and arrayByFields input options added.
+ </listitem>
+ <listitem>
+ Input containers including void elements are now supported.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
</refsection>
</refentry>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="tree_show">
- <refnamediv>
- <refname>tree_show</refname>
- <refpurpose>リストのツリービューを表示する</refpurpose>
- </refnamediv>
- <refsynopsisdiv>
- <title>呼び出し手順</title>
- <synopsis>
- tree_show(x)
- </synopsis>
- </refsynopsisdiv>
- <refsection>
- <title>引数</title>
- <variablelist>
- <varlistentry>
- <term>x</term>
- <listitem>
- <para>表示するリスト,mlistまたはtlist.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsection>
- <refsection>
- <title>説明</title>
- <para>
- ウインドウを作成し,指定するリストのツリービューを表示します.
- </para>
- </refsection>
- <refsection>
- <title>例</title>
- <programlisting role="example"><![CDATA[
-// 簡単な例
-a=list(1,2,3);
-tree_show(a);
-// mlistを指定した他の例
-str=['a','b','c','d','e','f','g','h'];
-n=matrix(str, [2,2,2]);
-v=matrix(1:8, [2,2,2]);
-Mm=mlist(['V','name','value'],n,v);
-tree_show(Mm);
-// tlistを指定した別の例
-Mt=tlist(['V','name','value'],['a','b','c'],[1 2 3]);
-tree_show(Mt);
- ]]></programlisting>
- </refsection>
-</refentry>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2019 - 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.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+ xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
+ xml:lang="ru" xml:id="tree_show">
+ <refnamediv>
+ <refname>tree_show</refname>
+ <refpurpose>
+ Отображает в виде дерева содержимое list, tlist, mlist, cell-массивы или массивы структур
+ </refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <title>Синтаксис</title>
+ <synopsis>
+ tree_show(x)
+ tree_show(x, rootTitle)
+ tree_show(x, rootTitle, styles)
+ tree_show(x, rootTitle, styles, arrayByFields)
+ </synopsis>
+ </refsynopsisdiv>
+ <refsection>
+ <title>Аргументы</title>
+ <variablelist>
+ <varlistentry>
+ <term>x</term>
+ <listitem>
+ <para>
+ Контейнер для отображения. Поддерживаемые контейнеры list, mlist, tlist,
+ cell-массивы или массивы структур. Другие контейнеры могут быть вложены
+ в <varname>x</varname>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>rootTitle</term>
+ <listitem>
+ <para>
+ Отдельная строка: напрямую указанная метка корня дерева, например, имя
+ переменной <varname>x</varname> в вызываюжщем окружении. По умолчанию
+ <literal>""</literal>.
+ </para>
+ <note>
+ Для изменения стиля названия корня могут использоваться теги стилей
+ HTML.4.
+ Например: "<literal><html><font color="red"><b>Название</b></literal>"
+ отобразит <emphasis>Название</emphasis> жирным красным шрифтом.
+ </note>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>styles</term>
+ <listitem>
+ <para>
+ Отдельная строка: тег стиля HTML.4, включающий символ
+ <literal>"$"</literal>, который будет заменяться адресом данных (имена
+ полей, индексы списков...).
+ </para>
+ <para>
+ Опция <varname>styles</varname> может исползоваться для настройки стилей
+ либо адресов, либо соответствующее содержимое или и то и другое. Примеры:
+ <itemizedlist>
+ <listitem>
+ <literal>"<b>$</b>"</literal> : адрес жирным, содержимое нормальным чёрным шрифтом.
+ </listitem>
+ <listitem>
+ <literal>"$<i>"</literal> : адрес нормальным, содержимое курсивным шрифтом.
+ </listitem>
+ <listitem>
+ <literal>"<i>$"</literal> : и адрес и содержимое курсивным шрифтом.
+ </listitem>
+ <listitem>
+ <literal>"<font color=''grey''>$</font><i>"</literal> :
+ адрес серым, содержимое курсивным шрифтом.
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ По умолчанию =
+ <literal>"<font color=""blue"">$</font>"</literal>
+ (адрес синим, содержимое чёрным шрифтом).
+ </para>
+ <para>
+ Установка <literal>""</literal> удаляет стилевое оформление.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>arrayByFields</term>
+ <listitem>
+ <para>
+ Отдельное логическое значение, используемое только для массивов структур:
+ <table>
+ <tr><th>%T :</th>
+ <td>
+ Для каждого поля структуры отображается массив его значений.
+ </td>
+ </tr>
+ <tr><th>%F :</th>
+ <td>
+ Для каждой структуры массива отображаются её поля и их значения.
+ </td>
+ </tr>
+ </table>
+ </para>
+ <para>
+ Выбранный режим отображения используется также для каждого вложенного
+ массива структур на любой глубине.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsection>
+ <refsection>
+ <title>Описание</title>
+ <para>
+ Создаёт окно и отображает указанный контейнер в виде дерева.
+ </para>
+ <warning>
+ Это окно не имеет дескриптора.
+ </warning>
+ </refsection>
+ <refsection>
+ <title>Примеры</title>
+ <para>
+ <emphasis role="bold">list(), включая cell-массив</emphasis> :
+ </para>
+ <table>
+ <tr>
+ <td>
+ <programlisting role="example"><![CDATA[
+ films = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+ L = list([%t %f %f], ..
+ $:-1:3, ..
+ int8([1 2 3 ; 4 5 6]), ..
+ [-%inf, -1, 0, %i, 7.1, 3.3e20, %inf, %nan], ..
+ sparse([0 1 2; 3 0 4]), ..
+ ["This" "is" "some" "text"], ..
+ , ..
+ sin, ..
+ logspace, ..
+ iolib, ..
+ {%pi, "abcd" ;
+ list(,)(1),(%i-%s)^3}, ..
+ {}, ..
+ films);
+ tree_show(L)
+ ]]></programlisting>
+ </td>
+ <td>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_list.png"/>
+ </imageobject>
+ </inlinemediaobject>
+ </td>
+ </tr>
+ </table>
+
+ <para>
+ <emphasis role="bold">Использование опций <emphasis>rootTitle</emphasis> и <emphasis>styles</emphasis>
+ </emphasis> :
+ </para>
+ <programlisting role="example"><![CDATA[
+// Данные для отображения:
+clear films
+films(1) = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+films(2,2) = struct("Title", "I, robot", ..
+ "Year", 2004, ..
+ "Director", "Alex Proyas", ..
+ "Duration", 120);
+
+// Стилевое оформление как адресов, так и содержимого:
+mainTitle = "<html><b>Films (A)</b>";
+tree_show(films, mainTitle , "<font color=""red"">$</font><i>");
+
+// Стилевое оформление только содержимого:
+mainTitle = "<html><b>Films (B)</b>";
+tree_show(films([1 4]), mainTitle, "$<font color=""green"">", %t);
+ ]]></programlisting>
+ <para/>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_styling.png"/>
+ </imageobject>
+ </inlinemediaobject>
+
+ <para>
+ <emphasis role="bold">Массив структур</emphasis> :
+ </para>
+ <programlisting role="example"><![CDATA[
+clear films
+films(1) = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+films(2) = struct("Title", "I, robot", ..
+ "Year", 2004, ..
+ "Director", "Alex Proyas", ..
+ "Duration", 120);
+films(1,2) = struct("Title", "Gravity", ..
+ "Year", 2013, ..
+ "Director", "Alfonso Cuarón", ..
+ "Duration", 100);
+films(2,2) = struct("Title", "2001: A space odyssey", ..
+ "Year", 1968, ..
+ "Director", "Stanley Kubrick", ..
+ "Duration", 141);
+
+tree_show(films(:),"Films (I)");
+tree_show(films ,"Films (II)");
+tree_show(films(:),"Films (III)", , %t);
+tree_show(films ,"Films (IV)" , , %t);
+ ]]></programlisting>
+ <screen><![CDATA[
+2x2 struct array with fields:
+ Title
+ Director
+ Year
+ Duration
+]]></screen>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/tree_show_2x2.png"/>
+ </imageobject>
+ </inlinemediaobject>
+ <para/>
+
+ <para>
+ <emphasis role="bold">С пользовательским tlist или mlist</emphasis> :
+ </para>
+ <programlisting role="example"><![CDATA[
+// Для mlist:
+str = ['a','b','c','d','e','f','g','h'];
+n = matrix(str, [2,2,2]);
+v = matrix(1:8, [2,2,2]);
+Mm = mlist(['V','name','value'],n,v);
+tree_show(Mm);
+
+// Для tlist:
+Mt = tlist(['V','name','value'],['a','b','c'],[1 2 3]);
+tree_show(Mt);
+ ]]></programlisting>
+ <para/>
+ </refsection>
+
+ <refsection role="see also">
+ <title>Смотрите также</title>
+ <simplelist type="inline">
+ <member>
+ <link linkend="uiDisplayTree">uiDisplayTree</link>
+ </member>
+ <member>
+ <link linkend="uiDumpTree">uiDumpTree</link>
+ </member>
+ <member>
+ <link linkend="prettyprint">prettyprint</link>
+ </member>
+ <member>
+ <link linkend="editvar">editvar</link>
+ </member>
+ <member>
+ <link linkend="browsevar">browsevar</link>
+ </member>
+ </simplelist>
+ </refsection>
+
+ <refsection role="history">
+ <title>История</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.1.0</revnumber>
+ <revdescription>
+ <itemizedlist>
+ <listitem>
+ Добавлены входные опции rootTitle, styles и arrayByFields.
+ </listitem>
+ <listitem>
+ Теперь поддерживаются входные контейнеры, включающие пустые элементы.
+ </listitem>
+ </itemizedlist>
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
+</refentry>
--- /dev/null
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - 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.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+
+// Internal function (for the time being..)
+
+function tree = list2tree(x, titleRoot, styles, arrayByFields)
+ // x : list, cells or structs array, tlist, mlist, Xcos block
+ // titleRoot: single string: label of the tree root, for instance
+ // the name of x in the calling environment
+ // styles: single string = HTML.4 tag embedding the address
+ // of each data (fields names, lists indices..).
+ // Example: "<b>$</b>" where $ will be replaced with the address.
+ // arrayByFields: single boolean (when x is an array of structs).
+ // %T => For each field: the array of its values is displayed.
+ // %F => For each array component, all its fields are displayed.
+
+ // CHECKING INPUT ARGUMENTS
+ // ------------------------
+ if argn(2) < 1 then
+ msg = _("%s: Wrong number of input argument(s): %d to %d expected.\n")
+ error(msprintf(msg, "list2tree", 1, 4));
+ end
+
+ if and(type(x)<>[15 16 17 128]) then
+ msg = _("%s: Argument #%d: Container or Xcos object expected.\n")
+ error(msprintf(msg, "list2tree", 1))
+ end
+
+ if ~isdef("titleRoot","l")
+ titleRoot = "";
+ end
+
+ if ~isdef("arrayByFields","l") then
+ arrayByFields = %f
+ elseif type(arrayByFields) <> 4
+ msg = _("%s: Argument #%d: Boolean(s) expected.\n")
+ error(msprintf(msg, "tree_show", 3))
+ else
+ arrayByFields = arrayByFields(1)
+ end
+
+ if ~isdef("styles","l") then
+ styles = ""
+ elseif type(styles) <> 10
+ msg = _("%s: Argument #%d: Text(s) expected.\n")
+ error(msprintf(msg, "tree_show", 4))
+ else
+ styles = styles(1)
+ end
+
+ // BUILDING THE TREE
+ // -----------------
+ tree = uiCreateNode(titleRoot);
+ tree = list2tree_inc(x, "root", tree, styles, arrayByFields);
+endfunction
+
+// ===========================================================================
+
+function tree = list2tree_inc(x, Path, tree, styles, arrayByFields)
+
+ if type(x) <> 15 then
+ list_field_content = %f
+ end
+ if type(x)==15 then
+ if length(x)==0 then
+ tree($).label = tree($).label + " list()"
+ return
+ end
+ II = 1:size(x);
+ if isdef("list_field_content") & list_field_content
+ if sum(list_field_content>1)>1
+ // Generating all "(i,j,..)" headers
+ v = container_get_ijk_labels(list_field_content)
+ else
+ v = msprintf("%d\n",II')';
+ if prod(list_field_content)==1 // parent struct is scalar
+ tree($).label = tree($).label + " [list]"
+ end
+ end
+ else
+ tree($).label = tree($).label + " [list]"
+ v = msprintf("%d\n",II')';
+ end
+
+ elseif typeof(x)=="ce"
+ nb = length(x)
+ if nb==0
+ tree($).label = tree($).label + " { }"
+ return
+ else
+ if nb==1 then
+ tmp = " [cell]"
+ else
+ tmp = msprintf(" [%s cell]", ..
+ strcat(msprintf("%d\n",size(x)'),"x"));
+ end
+ tree($).label = tree($).label + tmp
+ II = 1:nb
+ // Generating all "(i,j,..)" headers
+ v = container_get_ijk_labels(size(x))
+ end
+
+ elseif type(x)==17 & typeof(x)=="st" then
+ // Structures are displayed first by k indices, then
+ // for each x(k), by field. In this way, each x(k) is
+ // displayed as a whole object/record, instead of being split.
+ if length(x)==0 then
+ tree($).label = tree($).label + " struct()"
+ return
+ else
+ if arrayByFields | length(x)==1 then
+ if length(x)==1 then
+ if isdef("struct_array") & struct_array then
+ tmp = "↴"
+ else
+ tmp = " [struct]"
+ end
+ else
+ tmp = msprintf(" [%s struct]", ..
+ strcat(msprintf("%d\n",size(x)'),"x"));
+ end
+ struct_array = %f
+ v = ["" ; fieldnames(x)]
+ II = 2:size(v,"*") // fields indices
+ list_field_content = size(x)
+ else
+ tmp = msprintf(" [%s struct]", ..
+ strcat(msprintf("%d\n",size(x)'),"x"));
+ II = 1:size(x,"*")
+ v = container_get_ijk_labels(size(x))
+ struct_array = %t
+ end
+ tree($).label = tree($).label + tmp
+ end
+
+ elseif typeof(x)=="rational"
+ v = getfield(1,x);
+ II = 2:4
+ if x.dt == []
+ II = 2:3 // dt field skipped
+ end
+ if size(x,"*")<=1 then
+ tmp = " [rational]"
+ else
+ tmp = msprintf(" [%s rational]", ..
+ strcat(msprintf("%d\n",size(x)'),"x"));
+ end
+ tree($).label = tree($).label + tmp
+
+ else // or(type(x)==[16 17])
+ v = getfield(1,x);
+ II = 2:size(v,"*")
+ if II==[] // No field
+ tree($).label = tree($).label + " " + sci2exp(x)
+ return
+ end
+ // Header:
+ tpof = typeof(x)
+ sz = []
+ if or(tpof==["st" "ce"]) | isdef("%"+tpof+"_size") then
+ sz = size(x)
+ end
+ tmp = "tlist"
+ if type(x)==17
+ tmp = "mlist"
+ end
+ if sz == [] | prod(sz)<2
+ tmp = "[" + tpof + " " + tmp + "]"
+ else
+ tmp = msprintf(" [%s %s %s]", ..
+ strcat(msprintf("%d\n",size(x)'),"x"), tpof, tmp);
+ end
+ tree($).label = tree($).label + tmp
+ end
+
+ // Loop over container components or fields
+ // ----------------------------------------
+ for i = II
+ path = Path+"," + msprintf("%d",i)
+ titre = v(i) + ": ";
+ if styles <> ""
+ titre = strsubst("<html>"+styles, "$", titre)
+ end
+
+ // Reads the object
+ clear o
+ if typeof(x)=="st" then
+ if ~struct_array
+ o = x(v(i))
+ else
+ o = x(i)
+ end
+ elseif typeof(x)=="ce"
+ o = x{i}
+ elseif or(type(x)==[15 16 17])
+ try // there may be more field names than data
+ o = getfield(i,x);
+ catch
+ o = list(,2)(1)
+ end
+ else
+ o = x
+ end
+ //
+ if ~isdef("o","l") // void element in lists
+ currentNode = uiCreateNode(titre);
+ tree = uiConcatTree(tree, currentNode);
+
+ elseif or(type(o)==[15 16 17 128])
+ // Recursive call:
+ currentNode = uiCreateNode(titre);
+ currentNode = list2tree_inc(o, path, currentNode, styles, arrayByFields)
+ tree = uiConcatTree(tree, currentNode);
+
+ elseif typeof(o)=="implicitlist"
+ tree = uiConcatTree(tree, uiCreateNode(titre + sci2exp(o)));
+
+ elseif type(o)== 13 // function
+ p = macr2tree(o)
+ tmp = msprintf(_("%s() (%d lines)"), p.name, p.nblines)
+ tree = uiConcatTree(tree, uiCreateNode(titre + tmp));
+
+ elseif type(o)== 14 // library
+ tmp = string(o)
+ p = strsubst(tmp(1), "\", "/"); // not escaped chars for mprintf()
+ libname = xmlGetValues("/scilablib","name",p + "lib")
+ tmp = msprintf("%s library of %d functions @ %s", ..
+ libname, size(tmp,1)-1, p)
+ tree = uiConcatTree(tree, uiCreateNode(titre + tmp));
+
+ else
+ tp = typeof(o)
+ try
+ if size(o, "*") > 40 then
+ tts = tp + " of size " + sci2exp(size(o))
+ else
+ tts = sci2exp(o)
+ if or(type(o)==(1:8))
+ tts = strsubst(tts, ",", ", ");
+ tts = strsubst(tts, ";", " ; ");
+ elseif type(o)==10
+ tts = strsubst(tts, """,""", """, """);
+ tts = strsubst(tts, """;""", """ ; """);
+ end
+ if type(o)==2 | typeof(o)=="rational"
+ vn = varn(o)
+ if or(vn==["s" "z"])
+ tts = strsubst(tts, "%"+vn, vn)
+ tts = strsubst(tts, "*", "")
+ end
+ end
+ if (or(type(o)==[1 2 5]) | typeof(o)=="rational")
+ tts = strsubst(tts, "%inf","Inf")
+ tts = strsubst(tts, "%nan","Nan")
+ tts = strsubst(tts, "%i","i")
+ end
+ if or(type(o)==[4 6])
+ tts = strsubst(tts, "%t", "T")
+ tts = strsubst(tts, "%f", "F")
+ tts = strsubst(tts, "],", "]]")
+ tts = strsubst(tts, ",", "")
+ tts = strsubst(tts, "]]", "],")
+ end
+ end
+ catch
+ tts = tp;
+ end
+ titre2 = titre + tts ;
+ tree = uiConcatTree(tree, uiCreateNode(titre2));
+ end
+ end
+
+endfunction
+
+// -------------------------------------------------------------------
+
+function v = container_get_ijk_labels(sz)
+ if sum(sz>1) < 2 then
+ // if it's a vector, we display linearized indices
+ v = msprintf("%d\n", (1:prod(sz))')
+ else
+ // Otherwise we display (i,j,.) indices
+ L = list()
+ nd = length(sz);
+ in = "=ndgrid(" + strcat(msprintf("1:%d\n",sz'),",") + ")";
+ out = "[" + strcat(msprintf("L(%d)\n",(1:nd)'),",") + "]";
+ execstr(out + in);
+ v = []
+ for i = 1:nd
+ v = [v, msprintf("%d\n",L(i)(:))];
+ end
+ v = "(" + strcat(v,",","c") + ") ";
+ end
+endfunction
// Scicos
//
// Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
+// Copyright (C) 2019 - Samuel GOUGEON
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See the file ../license.txt
-//
-function tree_show(x,titletop)
+function tree_show(x, titleRoot, styles, arrayByFields)
+ // x : list, cells or structs array, tlist, mlist, Xcos block
+ // titleRoot: single string: label of the tree root, for instance
+ // the name of x in the calling environment
+ // styles: single string = HTML 4 tag styling either the address of
+ // each data (fields names, lists indices..), or their content, or both.
+ // In the string, "$" is replaced with the address.
+ // Example: "<b>$</b>" where $ will be replaced with the address.
+ // arrayByFields: single boolean (when x is an array of structs).
+ // %T => For each field: the array of its values is displayed.
+ // %F => For each array component, all its fields are displayed.
+ // CHECKING INPUT ARGUMENTS
+ // ------------------------
if argn(2) < 1 then
- error(sprintf(_("%s: Wrong number of input argument(s): %d to %d expected.\n"), "tree_show", 1, 2));
+ msg = _("%s: Wrong number of input argument(s): %d to %d expected.\n")
+ error(sprintf(msg, "tree_show", 1, 4));
end
- if type(x)<>16 & type(x)<>17 & type(x)<>15 & type(x)<>128 then
- error("Wrong type; input must be a list or an Xcos object.")
+ if and(type(x)<>[15 16 17 128]) then
+ msg = _("%s: Argument #%d: Container or Xcos object expected.\n")
+ error(msprintf(msg, "tree_show", 1))
end
- //-- tt = ["set BWpath [file dirname '"$env(SCIPATH)/modules/tclsci/tcl/BWidget-1.8.0'"] "
- //-- "if {[lsearch $auto_path $BWpath]==-1} { set auto_path [linsert $auto_path 0 $BWpath] }"
- //-- "package require BWidget 1.8.0"
- //-- // 'proc ppx {label} {global xmind; set xmind $label;ScilabEval '"%tcl_par=''1'''"}'
- //-- // 'proc qqx {label} {global xmind; set xmind $label;ScilabEval '"%tcl_par=''3'''"}'
- //-- 'catch {destroy .ss}'
- //-- 'toplevel .ss'
- //-- 'scrollbar .ss.ysb -command {.ss.t yview}'
- //-- 'scrollbar .ss.xsb -command {.ss.t xview} -orient horizontal'
- //-- 'Tree .ss.t -xscrollcommand '".ss.xsb set'" -yscrollcommand '".ss.ysb set'" "+...
- //-- " -width 30'
- //-- 'grid .ss.t .ss.ysb -sticky nsew'
- //-- ' grid .ss.xsb -sticky ew'
- //-- ' grid rowconfig .ss 0 -weight 1'
- //-- ' grid columnconfig .ss 0 -weight 1'
- //-- ];
-
- //-- for i=1:size(tt,1)
- //-- TCL_EvalStr(tt(i))
- //-- end
-
-
- //-- if argn(2)>1 then
- //-- tt = 'wm title .ss {'+titletop+'}';
- //-- elseif type(x)<>15 then
- //-- v = getfield(1,x);
- //-- tt = 'wm title .ss '+v(1);
- //-- else
- //-- tt = 'wm title .ss list';
- //-- end
-
- //-- TCL_EvalStr(tt)
- Path = "root"
- tree = uiCreateNode("Root");
- tree = crlist3(x,Path, tree);
- uiDisplayTree(tree);
-
- //-- TCL_EvalStr(' .ss.t bindText <Double-1> {ppx}')
- //-- TCL_EvalStr(' .ss.t bindText <3> {qqx}')
-endfunction
-
+ if ~isdef("titleRoot","l") then
+ titleRoot = ""
+ end
-function java = crlist3(x,Path, java)
- if type(x)==15 then
- II=1:size(x);v=string(II);
+ if ~isdef("arrayByFields","l") then
+ arrayByFields = %f
+ elseif type(arrayByFields) <> 4
+ msg = _("%s: Argument #%d: Boolean(s) expected.\n")
+ error(msprintf(msg, "tree_show", 3))
else
- v=getfield(1,x);
- if type(x)==17 & v(1)=="st" then
- II=3:size(v,"*");
- else
- II=2:size(v,"*");
- end
+ arrayByFields = arrayByFields(1)
end
- for i=II
- path=Path+","+string(i)
- titre=v(i);
- o=getfield(i,x);
- if type(o)==16 | type(o)==17 | type(o)==128 then
- w=getfield(1,o);
- titre2=titre+" ("+w(1)+")";
- //-- TCL_EvalStr('.ss.t insert end '+Path+' '+path+' -image [Bitmap::get folder] -text {'+titre2+'}')
- currentNode = uiCreateNode(titre2);
- currentNode = crlist3(o,path,currentNode); //* recursive
- java = uiConcatTree(java, currentNode);
- elseif type(o)==15 then
- titre2=titre;
- //-- TCL_EvalStr('.ss.t insert end '+Path+' '+path+' -image [Bitmap::get folder] -text {'+titre2+'}')
- currentNode = uiCreateNode(titre2);
- currentNode = crlist3(o,path,currentNode); //* recursive
- java = uiConcatTree(java, currentNode);
- else
- try
- if size(o, "*") > 40 then
- tts = typeof(o) + " of size " + sci2exp(size(o))
- else
- tts = sprintf("%s", sci2exp(o))
- end,
- catch
- tts = typeof(o);
- end
- titre2=titre+": "+tts ;
- //-- TCL_EvalStr('set yy {'+titre2+'}')
- //-- TCL_EvalStr('.ss.t insert end '+Path+' '+path+' -text $yy')
- java = uiConcatTree(java, uiCreateNode(titre2));
- end
+ if ~isdef("styles","l") then
+ styles = "<font color=""blue"">$</font>"
+ elseif type(styles) <> 10
+ msg = _("%s: Argument #%d: Text(s) expected.\n")
+ error(msprintf(msg, "tree_show", 4))
+ else
+ styles = styles(1)
end
-endfunction
+ // BUILDING THE TREE
+ // -----------------
+ tree = list2tree(x, titleRoot, styles, arrayByFields)
+ // Displaying it:
+ uiDisplayTree(tree);
+endfunction
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 16120 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/16120
+//
+// <-- Short Description -->
+// tree_show() was broken for containers including some cells
+
+clear c s
+c = makecell([1 2],"abc",%t);
+assert_checkequal(execstr("tree_show(c)", "errcatch"), 0);
+assert_checkequal(execstr("tree_show({})", "errcatch"), 0);
+s.c = c;
+assert_checkequal(execstr("tree_show(s)", "errcatch"), 0);
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - 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.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+// =============================================================================
+
+// <-- INTERACTIVE TEST -->
+
+// unitary tests of tree_show()
+// =============================================================================
+
+// INPUT STRUCTURE
+// ===============
+clear f
+films(1) = struct("Title", "A.I. Artificial Intelligence",..
+ "Year", 2001, ..
+ "Director", "Steven Spielberg", ..
+ "Duration", 140);
+films(2) = struct("Title", "I, robot", ..
+ "Year", 2004, ..
+ "Director", "Alex Proyas", ..
+ "Duration", 120);
+films(1,2) = struct("Title", "Gravity", ..
+ "Year", 2013, ..
+ "Director", "Alfonso Cuarón", ..
+ "Duration", 100);
+films(2,2) = struct("Title", "2001: A space odyssey", ..
+ "Year", 1968, ..
+ "Director", "Stanley Kubrick", ..
+ "Duration", 141);
+// 1)
+tree_show(films(:), "films(:) (by indices)");
+// Checking
+// --------
+// * films(:) is a vector => displayed indices are simple.
+// * Root title = films(:) (by indices) [4x1 struct]
+// * Main items : 1: ↴ 2: ↴ 3: ↴ 4:↴ (in blue and folded)
+// 1: Subitems: Title: "A.I. Artificial Intelligence"
+// Year: 2001
+// Director: "Steven Spielberg"
+// Duration: 140
+// Title:, Year:, Director: and Duration: are in blue
+// Their values are in black
+// Same thing for 2:, 3:, and 4:.
+
+// 2)
+tree_show(films, "films (by indices)");
+// Checking
+// --------
+// * films is a matrix => displayed indices are detailled: (i,j,..)
+// * Root title = films (by indices) [2x2 struct]
+// * Same as in test 1), except that 1: ↴ is now (1,1): ↴
+// 2: ↴ is now (2,1): ↴
+// 3: ↴ is now (1,2): ↴
+// 4: ↴ is now (2,2): ↴
+// ArrayByFields option
+// --------------------
+// 3)
+tree_show(films(:), "films(:) (by fields)",, %t);
+// Checking
+// --------
+// films(:) is a vector => displayed indices are simple.
+// Root title = films(:) (by fields) [4x1 struct]
+// Main items = Title:, Year:, Director: and Duration: (in blue and folded)
+// Unfold "Title": Subitems:
+// 1: "A.I. Artificial Intelligence"
+// 2: "I, robot"
+// 3: "Gravity"
+// 4: "2001: A space odyssey"
+// 1: 2: 3: and 4: are in blue. Titles are in black.
+// Same thing for Year:, Director: and Duration:
+
+
+// 4)
+tree_show(films, "films (by fields)",, %t);
+// Checking
+// --------
+// Same as 3), except:
+// * films is a matrix => displayed indices are detailled: (i,j,..)
+// * Root title = films (by fields) [2x2 struct]
+
+
+// 5) EMPTY | VOID COMPONENTS (& list)
+// ===================================
+L = list([], ..
+ list(), ..
+ list(,%pi), .. // first element is void
+ struct(), ..
+ sparse([],[]), ..
+ {}, ..
+ mlist(""), ..
+ tlist(""));
+tree_show(L, "Empty or void components");
+// Checking
+// --------
+// The following tree must be displayed (all indices in blue, contents in black):
+// Empty or void components [list]
+// 1: []
+// 2: list()
+// 3: [list]
+// 1:
+// 2: 3.1415927
+// 4: struct()
+// 5: sparse([],[],[0,0])
+// 6: { }
+// 7: mlist("")
+// 8: tlist("")
+
+
+// 6) STYLING THE MAIN TITLE WITH HTML
+// ===================================
+rootTitle = "<html><font color=""red"" size=""4""><b>Films</b> (Science fiction)</font>";
+tree_show(films, rootTitle, ,%t)
+// Checking
+// --------
+// In the main title:
+// "Films" must be in bold red and slightly bigger
+// "(Science fiction)" must be in red normal size
+// "[2x2 struct]" must be in black normal size
+
+
+// 7) STYLING ADDRESSES OR/AND CONTENTS
+// ====================================
+// 7.a) Removing default addresses style => in black
+tree_show(films, , "", %t)
+// Check that fields names and indices are in black
+
+// 7.b) Setting fields names and indices in small bold
+tree_show(films, , "<font size=""2""><b>$</b></font>", %t)
+// Check that fields names and indices are in small bold black
+
+// 7.c) Setting contents in italic
+tree_show(films, , "$<i>", %t)
+// Check that fields names and indices are in normal black,
+// and contents in italic black
+
+// 7.d) Setting addresses in small red, and contents in italic
+tree_show(films, , "<font color=""red""><small>$</small></font><i>", %t)
+// Check that fields names and indices are in small red,
+// and contents is in italic black
+
+
+// 8) INPUT CELLS ARRAY
+// ====================
+c = {
+ [%t %f %f], list(,)(1), ["This" "is" "some" "text"]
+ int8([1 2 3 ; 4 5 6]), sin, list(%pi,"abcd",,(%i-%s)^3)
+ [-%inf, -1, 0, %i, 7.1, 3.3e20, %inf, %nan], logspace, {}
+ sparse([0 1 2; 3 0 4]), iolib, films(1,:)
+ };
+// Expected display (with blue indices and fields names):
+//
+// [4x3 cell]
+// (1,1) : [T F F]
+// (2,1) : int8([1, 2, 3 ; 4, 5, 6])
+// (3,1) : [-Inf, -1, 0, i, 7.1, 3.300D+20, Inf, Nan]
+// (4,1) : sparse([1, 2 ; 1, 3 ; 2, 1 ; 2, 3], [1 ; 2 ; 3 ; 4], [2, 3])
+// (1,2) : $:-1:3
+// (2,2) : fptr
+// (3,2) : logspace() (42 lines)
+// (4,2) : iolib library of 6 functions @ SCI\modules\io\macros\
+// (1,3) : ["This", "is", "some", "text"]
+// (2,3) : [list]
+// 1: 3.1415927
+// 2: "abcd"
+// 3:
+// 4: -i+3s+(i3)s^2-s^3
+// (3,3) : { }
+// (4,3) : [struct]
+// Title: "A.I. Artificial Intelligence"
+// Year: 2001
+// Director: "Steven Spielberg"
+// Duration: 140
+