clf('reset') must not reset .figure_id 16/19116/3
Samuel GOUGEON [Tue, 14 Feb 2017 17:49:25 +0000 (18:49 +0100)]
Change-Id: If2a852839d2ab6aa6567d5c12a3ca78c0bf43d44

scilab/CHANGES.md
scilab/modules/graphics/help/en_US/figure_operations/clf.xml
scilab/modules/graphics/macros/clf.sci
scilab/modules/graphics/tests/unit_tests/clf.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/unit_tests/clf.tst [new file with mode: 0644]

index c4f5887..96e75b8 100644 (file)
@@ -345,7 +345,7 @@ the [development mailing list](dev@lists.scilab.org) for a particular toolbox.
 * [#14636](http://bugzilla.scilab.org/show_bug.cgi?id=14636): Xcos model with modelica electrical blocks (created in 5.5.2) crashed Scilab 6.
 * [#14978](http://bugzilla.scilab.org/show_bug.cgi?id=15006): ode help page still contained 'root' which has been replaced by 'roots'.
 * [#15010](http://bugzilla.scilab.org/show_bug.cgi?id=15010): Coselica did not simulate on Scilab 6.
-
+* [#15023](http://bugzilla.scilab.org/show_bug.cgi?id=15023): `clf()` wrongly reset `figure_id`.
 
 ### Bugs fixed in 6.0.0:
 * [#592](http://bugzilla.scilab.org/show_bug.cgi?id=592): `linspace(a, b, n<=0)` returned `b` instead of `[]`
index 025b1be..4de9da3 100644 (file)
@@ -39,7 +39,8 @@
                 <term>numFig</term>
                 <listitem>
                     <para>
-                        Vector of indices of figures to clear or reset (<literal>.figure_id</literal> values). By default, the current figure is targeted.
+                        Vector of indices of figures to clear or reset (<literal>.figure_id</literal>
+                        values). By default, the current figure is targeted.
                     </para>
                 </listitem>
             </varlistentry>
                 <term>figFrameHandle</term>
                 <listitem>
                     <para>
-                        Vector of handles of figures or frame uicontrol to clear or reset. Mixing figures and frames is possible. By default, the current figure is targeted.
+                        Vector of handles of figures or frame uicontrol to clear or reset. Mixing
+                        figures and frames is possible. By default, the current figure is targeted.
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>"reset"</term>
                 <listitem>
-                    Provide this option keyword to reset properties of chosen figures to their default values, in addition to deleting the figures contents.
+                    Provide this option keyword to reset properties of chosen figures to their
+                    default values, in addition to deleting the figures contents.
                 </listitem>
             </varlistentry>
         </variablelist>
@@ -62,8 +65,9 @@
     <refsection>
         <title>Description</title>
         <para>
-            The <literal>clf</literal> command can be used to delete all children of a given graphic window, hence clearing it.
-            If the <literal>"reset"</literal> keyword is used, in addition most of the figure properties are reset to their default values.
+            The <literal>clf</literal> command can be used to delete all children of a given
+            graphic window, hence clearing it. If the <literal>"reset"</literal> keyword is used,
+            in addition most of the figure properties are reset to their default values.
             The detailled changes are now described:
         </para>
         <para>
                     <para>
                     <itemizedlist>
                         <listitem>
-                                All visible and invisible axes of each targeted figure or frame are deleted.
+                            All visible and invisible axes of each targeted figure or frame are
+                            deleted.
                         </listitem>
                         <listitem>
-                                All menus whose figure.children handles are not hidden are deleted. It is possible to protect them with <literal>set(get(0), "ShowHiddenHandles", "off")</literal>. This then applies to all opened figures and forthcoming ones. See <link linkend="console_properties">ShowHiddenHandles</link>.
+                            All menus whose figure.children handles are not hidden are deleted.
+                            It is possible to protect them with
+                            <literal>set(get(0), "ShowHiddenHandles", "off")</literal>.
+                            This then applies to all opened figures and forthcoming ones.
+                            See <link linkend="console_properties">ShowHiddenHandles</link>.
                         </listitem>
                         <listitem>
-                                The message in the status bar of each figure is cleared.
+                            The message in the status bar of each figure is cleared.
                         </listitem>
                         <listitem>
-                                The event handler of each figure is disabled, but their references are kept .
+                            The event handler of each figure is disabled, but their references are kept .
                         </listitem>
                     </itemizedlist>
                     </para>
                     <para>
-                        Values of all <link linkend="figure_properties">figures properties</link> are unchanged, except <literal>.info_message=""</literal> and <literal>.event_handler_enable="off"</literal> that are forced.
+                        Values of all <link linkend="figure_properties">figures properties</link>
+                        are unchanged, except <literal>.info_message=""</literal> and
+                        <literal>.event_handler_enable="off"</literal> that are forced.
                     </para>
                 </listitem>
                 <listitem>
                     <para>
-                        <literal>"reset"</literal>: in addition to default actions, <literal>"reset"</literal> resets most of figures properties to their default values, as specified by <function>gdf()</function>. This applies only to figures.
+                        <literal>"reset"</literal>: in addition to default actions,
+                        <literal>"reset"</literal> resets most of figures properties to their
+                        default values, as specified by <function>gdf()</function>.
+                        This applies only to figures.
                     </para>
                     <warning>
                         <itemizedlist>
                             <listitem>
-                                <emphasis role="italic">Some properties are never reset</emphasis>: <literal>.toolbar</literal>,  <literal>.menubar</literal>, <literal>.layout</literal>,  <literal>.layout_options</literal>, and <literal>.dockable</literal> can be set only once and so are never resettable.
+                                <emphasis role="italic">Some properties are never reset</emphasis>:
+                                The figure's number <literal>.figure_id</literal> is kept as is.
+                                <literal>.toolbar</literal>,  <literal>.menubar</literal>,
+                                <literal>.layout</literal>,  <literal>.layout_options</literal>,
+                                and <literal>.dockable</literal> can be set only once and so are
+                                never resettable.
                             </listitem>
                             <listitem>
-                                <emphasis role="italic">For docked figures</emphasis>: <literal>.figure_position</literal>, <literal>.figure_size</literal>, and <literal>.axes_size</literal> are unchanged if the parent figure is docked to the Scilab's desktop or to another Scilab interface. Changing their value would change the position or size of the whole block of docked interfaces, not only the targeted figure.
+                                <emphasis role="italic">For docked figures</emphasis>:
+                                <literal>.figure_position</literal>, <literal>.figure_size</literal>,
+                                and <literal>.axes_size</literal> are unchanged if the parent figure
+                                is docked to the Scilab's desktop or to another Scilab interface.
+                                Changing their value would change the position or size of the whole
+                                block of docked interfaces, not only the targeted figure.
                             </listitem>
                         </itemizedlist>
                     </warning>
             <title>Clearing specific parts of a figure</title>
             <itemizedlist>
                 <listitem>
-                    <literal>xname("")</literal> or <literal>gcf().name = ""</literal> clears the name of the window, displayed at its very top left corner.
+                    <literal>xname("")</literal> or <literal>gcf().name = ""</literal> clears the
+                    name of the window, displayed at its very top left corner.
                 </listitem>
                 <listitem>
-                    <literal>xinfo("")</literal> or <literal>gcf().info_message = ""</literal> clears the message displayed in the status bar of the current figure.
+                    <literal>xinfo("")</literal> or <literal>gcf().info_message = ""</literal>
+                    clears the message displayed in the status bar of the current figure.
                 </listitem>
                 <listitem>
-                    <literal>delete(gca())</literal> deletes the current axes in the current window. All other components of the window are kept: other axes (if any), menus, interactive components, figure properties, etc.
+                    <literal>delete(gca())</literal> deletes the current axes in the current window.
+                    All other components of the window are kept: other axes (if any), menus,
+                    interactive components, figure properties, etc.
                 </listitem>
                 <listitem>
-                    Deleting only all axes of a figure may be done with <literal>c=gcf().children; delete(c(c.type=="Axes"))</literal>. This keeps all its other components: menus, interactive components, etc.
+                    Deleting only all axes of a figure may be done with
+                    <literal>c=gcf().children; delete(c(c.type=="Axes"))</literal>. This keeps all
+                    its other components: menus, interactive components, etc.
                 </listitem>
                 <listitem>
-                    Deleting only menus: <literal>c=gcf().children; delete(c(c.type=="uimenu"))</literal>. This assumes that <literal>get(get(0), "ShowHiddenHandles")</literal> is <literal>"on"</literal>.
+                    Deleting only menus: <literal>c=gcf().children; delete(c(c.type=="uimenu"))</literal>.
+                    This assumes that <literal>get(get(0), "ShowHiddenHandles")</literal> is
+                    <literal>"on"</literal>.
                 </listitem>
             </itemizedlist>
         </refsect2>
                     <literal>clf</literal> now clears frames as well.
                 </revremark>
             </revision>
+            <revision>
+                <revnumber>6.0.0</revnumber>
+                <revremark>
+                    <literal>clf('reset')</literal> no longer resizes nor moves docked figures.
+                </revremark>
+            </revision>
         </revhistory>
     </refsection>
 </refentry>
index 7747abf..233e71a 100644 (file)
@@ -135,7 +135,7 @@ function clf(varargin)
         "icon"
         "tag"
         ];
-        excluded0 = ["children" "dockable" "menubar" "toolbar" "immediate_drawing"]
+        excluded0 = ["children" "figure_id" "dockable" "menubar" "toolbar" "immediate_drawing"]
         excluded0 = [excluded0 "layout" "layout_options"] // http://bugzilla.scilab.org/14955
         for k = 1: nbHandles
             curFig = h(k);
diff --git a/scilab/modules/graphics/tests/unit_tests/clf.dia.ref b/scilab/modules/graphics/tests/unit_tests/clf.dia.ref
new file mode 100644 (file)
index 0000000..3f67b61
--- /dev/null
@@ -0,0 +1,38 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2017 - Scilab Enterprises - Adeline CARNIS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// test clf()
+f = scf(100);
+f.figure_name = "Test number 1 with clf";
+f.figure_size = [300 200];
+plot(1:10)
+clf()
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Test number 1 with clf");
+assert_checkequal(f.figure_size, [300 200]);
+assert_checkequal(f.children.children, []);
+plot(1:10)
+clf("clear")
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Test number 1 with clf");
+assert_checkequal(f.figure_size, [300 200]);
+assert_checkequal(f.children.children, []);
+clf("reset")
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Figure n°%d");
+assert_checkequal(f.figure_size, [620 590]);
+assert_checkequal(f.children.children, []);
+delete(f);
+// clf must not reset figure_id
+f0 = scf(0);
+plot(1:10);
+f1 = scf(1);
+plot(1:20)
+clf("reset")
+assert_checkequal(f1.figure_id, 1);
+delete(f0);
+delete(f1);
diff --git a/scilab/modules/graphics/tests/unit_tests/clf.tst b/scilab/modules/graphics/tests/unit_tests/clf.tst
new file mode 100644 (file)
index 0000000..93853c0
--- /dev/null
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2017 - Scilab Enterprises - Adeline CARNIS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// test clf()
+
+f = scf(100);
+f.figure_name = "Test number 1 with clf";
+f.figure_size = [300 200];
+plot(1:10)
+clf()
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Test number 1 with clf");
+assert_checkequal(f.figure_size, [300 200]);
+assert_checkequal(f.children.children, []);
+plot(1:10)
+clf("clear")
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Test number 1 with clf");
+assert_checkequal(f.figure_size, [300 200]);
+assert_checkequal(f.children.children, []);
+clf("reset")
+assert_checkequal(f.figure_id, 100);
+assert_checkequal(f.figure_name, "Figure n°%d");
+assert_checkequal(f.figure_size, [620 590]);
+assert_checkequal(f.children.children, []);
+delete(f);
+
+// clf must not reset figure_id
+f0 = scf(0);
+plot(1:10);
+f1 = scf(1);
+plot(1:20)
+clf("reset")
+assert_checkequal(f1.figure_id, 1);
+delete(f0);
+delete(f1);
+