* Bug 15813 fixed: polarplot datatips shew cartesian coordinates 68/20568/6
Samuel GOUGEON [Fri, 19 Oct 2018 21:10:59 +0000 (23:10 +0200)]
  http://bugzilla.scilab.org/15813

  Test:
  clf
  polarplot()
  datatipManagerMode on
  // Click on a curve to add a datatip
  // Check that the label shows R (as generic radial coordinates)
  // and theta

Change-Id: I90eb477ce20e7bcbf79cee78307b7aa80fbaaefa

scilab/CHANGES.md
scilab/modules/graphics/help/en_US/polygon/polyline_properties.xml
scilab/modules/graphics/help/ja_JP/polygon/polyline_properties.xml
scilab/modules/graphics/macros/polarplot.sci
scilab/modules/graphics/macros/polarplot_datatip_display.sci [new file with mode: 0644]

index 70ec670..eee5db8 100644 (file)
@@ -644,6 +644,7 @@ Known issues
 * [#15796](http://bugzilla.scilab.org/show_bug.cgi?id=15796): Display after `mprintf("")` crashed Scilab (regression)
 * [#15808](http://bugzilla.scilab.org/show_bug.cgi?id=15808): `[5i]` was parsed as `[5,i]`
 * [#15809](http://bugzilla.scilab.org/show_bug.cgi?id=15809): HDF5 load/save was super slow for nested lists.
+* [#15813](http://bugzilla.scilab.org/show_bug.cgi?id=15813): In polarplot mode, datatips displayed irrelevant cartesian coordinates instead of polar ones.
 * [#15814](http://bugzilla.scilab.org/show_bug.cgi?id=15814): Selecting graphic children with booleans yielded an error.
 * [#15815](http://bugzilla.scilab.org/show_bug.cgi?id=15815): After `polarplot()`, reversing axes or switching `gca().rotation_angles` shifted all angular and radial labels.
 * [#15816](http://bugzilla.scilab.org/show_bug.cgi?id=15816): `polarplot()`, `pie()`, `mesh()` and  `contourf()` ignored / canceled any upstream `drawlater`.
index 250191a..1d69353 100644 (file)
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>datatip_display_mode: </term>
+                <term>datatip_display_mode:</term>
                 <listitem>
                     <para>
                         The value can be one of the following:
                 <term>display_function: </term>
                 <listitem>
                     <para>
-                        A character string that contains a function name. This function syntax must be <literal>str=fun(datatipHandle)</literal> where <literal>datatipHandle</literal> is the handle of the datatip to be displayed. This function must return a string or a vector of strings in str.
+                        A character string that contains a function name. This function syntax must
+                        be <literal>str=fun(datatipHandle)</literal> where
+                        <literal>datatipHandle</literal> is the handle of the datatip to be displayed.
+                        This function must return a string or a vector of strings in str.
                     </para>
                     <para>
                         This function can be overloaded by setting the similar property on a datatip itself.
                     </para>
+                    <para>
+                        Some datatips formatting functions are predefined:
+                        <table border="1">
+                          <tr valign="top">
+                            <th align="left">polar_datatip_display()</th>
+                            <td>: set by polarplot()</td>
+                          </tr>
+                          <tr valign="top">
+                            <th align="left">formatBodePhaseTip()</th>
+                            <td>: set by bode()</td>
+                          </tr>
+                        </table>
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
index 5b0134f..4bca8df 100644 (file)
                         この関数は, datatip本体に類似のプロパティを設定することで,
                         オーバーロードできます.
                     </para>
+                   <para>
+                        Some datatips formatting functions are predefined:
+                        <table border="1">
+                          <tr valign="top">
+                            <th align="left">polar_datatip_display()</th>
+                            <td>: set by polarplot()</td>
+                          </tr>
+                          <tr valign="top">
+                            <th align="left">formatBodePhaseTip()</th>
+                            <td>: set by bode()</td>
+                          </tr>
+                        </table>
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
index 9c076cf..19ed338 100644 (file)
@@ -194,6 +194,12 @@ function polarplot(theta,rho,style,strf,leg,rect)
     fcolor = color("grey60");
     txtColor = color("grey30");
 
+    // Default Datatip function for curves
+    a = gca();
+    curves = a.children(1).children;
+    curves.display_function = "polarplot_datatip_display";
+    curves.display_function_data = Amin;    // for theta on [0,360] | [-90,90]
+
     // CIRCULAR FRAME AT SET OF RADII:
     // ------------------------------
     // Radial values for the frame:
diff --git a/scilab/modules/graphics/macros/polarplot_datatip_display.sci b/scilab/modules/graphics/macros/polarplot_datatip_display.sci
new file mode 100644 (file)
index 0000000..d74eb40
--- /dev/null
@@ -0,0 +1,37 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2018 - 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 Default function formating datatips for curves in polar frames
+function Label = polarplot_datatip_display(dtip)
+    xy = dtip.data(1:2)
+    r = sqrt(xy(1)^2+xy(2)^2);
+    a = atan(xy(2), xy(1)) / %pi * 180;
+    if dtip.parent.display_function_data>=0 & a<0 then
+        a = a+360;
+    end
+
+    if r<1000 & r>=0.1 then // 123.4  12.34  1.234  0.1234
+       nm = 1 + int(log10(r));
+       nd = 1 + (3-nm);
+       f = msprintf("%%%d.%df",nm,nd);
+       f = strsubst("R = %s\n$\\large\\theta = %6.1f°$\n", "%s", f);
+       Label = msprintf(f, r, a);
+    elseif r>=1000
+        nm = int(log10(r));
+        m = r/10^nm;
+        Label = msprintf("$\\large R = %5.2f\\ 10^{%d}$\n"+..
+                         "$\\large \\theta = %6.1f\\ °$\n", m, nm, a);
+    else  // r < 0.1
+        nm = int(log10(r));
+        m = r/10^(nm-1);
+        Label = msprintf("$\\large R = %5.2f\\ 10^{%d}$\n"+..
+                         "$\\large \\theta = %6.1f\\ °$\n", m, nm-1, a);
+    end
+endfunction