summaryrefslogtreecommitdiff
path: root/modules/graphics/macros/datatips
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/graphics/macros/datatips
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/graphics/macros/datatips')
-rwxr-xr-xmodules/graphics/macros/datatips/%datatips_p.binbin0 -> 4656 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/%datatips_p.sci38
-rwxr-xr-xmodules/graphics/macros/datatips/datatipCreatePopupMenu.binbin0 -> 3248 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipCreatePopupMenu.sci44
-rwxr-xr-xmodules/graphics/macros/datatips/datatipDefaultDisplay.binbin0 -> 1132 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipDefaultDisplay.sci16
-rwxr-xr-xmodules/graphics/macros/datatips/datatipDeleteSelected.binbin0 -> 764 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipDeleteSelected.sci19
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGUIEventHandler.binbin0 -> 592 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGUIEventHandler.sci13
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetEntities.binbin0 -> 5216 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetEntities.sci57
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetSelected.binbin0 -> 1344 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetSelected.sci22
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetStruct.binbin0 -> 1416 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipGetStruct.sci19
-rwxr-xr-xmodules/graphics/macros/datatips/datatipHilite.binbin0 -> 1824 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipHilite.sci29
-rwxr-xr-xmodules/graphics/macros/datatips/datatipManagerMode.binbin0 -> 11464 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipManagerMode.sci90
-rwxr-xr-xmodules/graphics/macros/datatips/datatipMove.binbin0 -> 9824 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipMove.sci60
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRadioCallback.binbin0 -> 4784 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRadioCallback.sci50
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRemoveAll.binbin0 -> 6628 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRemoveAll.sci53
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRemoveNearest.binbin0 -> 2168 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipRemoveNearest.sci27
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetGUI.binbin0 -> 4896 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetGUI.sci56
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetOrientation.binbin0 -> 3220 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetOrientation.sci30
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetSelected.binbin0 -> 3100 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetSelected.sci38
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetStruct.binbin0 -> 4200 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetStruct.sci39
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetStyle.binbin0 -> 11776 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetStyle.sci81
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetTipPosition.binbin0 -> 3356 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetTipPosition.sci35
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetTipStyle.binbin0 -> 7392 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipSetTipStyle.sci76
-rwxr-xr-xmodules/graphics/macros/datatips/datatipsGUI.binbin0 -> 44220 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/datatipsGUI.sci413
-rwxr-xr-xmodules/graphics/macros/datatips/libbin0 -> 904 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/names25
-rwxr-xr-xmodules/graphics/macros/datatips/orthProj.binbin0 -> 9272 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/orthProj.sci49
-rwxr-xr-xmodules/graphics/macros/datatips/pixDist.binbin0 -> 1248 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/pixDist.sci14
-rwxr-xr-xmodules/graphics/macros/datatips/setStringPosition.binbin0 -> 18936 bytes
-rwxr-xr-xmodules/graphics/macros/datatips/setStringPosition.sci138
52 files changed, 1531 insertions, 0 deletions
diff --git a/modules/graphics/macros/datatips/%datatips_p.bin b/modules/graphics/macros/datatips/%datatips_p.bin
new file mode 100755
index 000000000..d737eaf86
--- /dev/null
+++ b/modules/graphics/macros/datatips/%datatips_p.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/%datatips_p.sci b/modules/graphics/macros/datatips/%datatips_p.sci
new file mode 100755
index 000000000..9b5094bc9
--- /dev/null
+++ b/modules/graphics/macros/datatips/%datatips_p.sci
@@ -0,0 +1,38 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function %datatips_p(d)
+ fun=fun2string(d.formatfunction)
+
+ F=getfield(1,d);
+ txt=[];
+ L=max(length(F(2:$)))
+ for k=2:size(F,"*")
+ f=F(k)
+ if f=="interpolate" then
+ txt=[txt;
+ part(f,1:L+1)+"= "+sci2exp(d.interpolate)]
+ elseif f=="replace" then
+ txt=[txt;
+ part(f,1:L+1)+"= "+sci2exp(d.replace)]
+ elseif f=="formatfunction" then
+ txt=[txt;
+ part(f,1:L+1)+": "
+ " "+fun2string(d.formatfunction)]
+ elseif f=="tips" then
+ txt=[txt;
+ part(f,1:L+1)+": "+string(size(d.tips,"*"))+ " tip handles" ]
+ else
+ txt=[txt
+ part(f,1:L+1)+": "+"["+strcat(string(size(d(f))),"x")+" "+typeof(d(f))+"]"]
+ end
+ end
+ mprintf(" %s\n",txt)
+endfunction
+
diff --git a/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin b/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin
new file mode 100755
index 000000000..fa38575b0
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipCreatePopupMenu.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci b/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci
new file mode 100755
index 000000000..d8181c805
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipCreatePopupMenu.sci
@@ -0,0 +1,44 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+// Create a popupmenu and waits for a user input
+function h = datatipCreatePopupMenu(listOfMenus)
+ //datatip utility function
+ // Create a contextmenu
+ h = uicontextmenu();
+
+ // Create its items
+ createPopupItems(h, listOfMenus);
+
+ // Display and wait for a user answer
+ Cmenu = uiwait(h);
+
+endfunction
+
+function createPopupItems(parent, listOfMenus)
+
+ for menu=listOfMenus
+ if type(menu) == 10 then
+ if size(menu,"*")==1 then
+ h1 = uimenu("Parent", parent, "label", menu);
+ else
+ h1 = uimenu("Parent", parent, "label", menu(1), "callback", ...
+ menu(2));
+ end
+ else
+ if length(menu) >= 2
+ h1 = uimenu("Parent", parent, "label", menu(1));
+ menu(1)=null();
+ createPopupItems(h1, menu);
+ else
+ error(gettext("createPopupItems: found an empty cascading menu."));
+ end
+ end
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipDefaultDisplay.bin b/modules/graphics/macros/datatips/datatipDefaultDisplay.bin
new file mode 100755
index 000000000..91329e4ae
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipDefaultDisplay.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipDefaultDisplay.sci b/modules/graphics/macros/datatips/datatipDefaultDisplay.sci
new file mode 100755
index 000000000..2c7c90440
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipDefaultDisplay.sci
@@ -0,0 +1,16 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function str=datatipDefaultDisplay(curve,pt,index)
+ if size(pt,"c")==2 then
+ str=msprintf("X: %.2g\nY: %.2g", pt(1,1),pt(1,2))
+ else
+ str=msprintf("X: %.2g\nY: %.2g\nZ: %.2g", pt(1,1),pt(1,2),pt(1,3))
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipDeleteSelected.bin b/modules/graphics/macros/datatips/datatipDeleteSelected.bin
new file mode 100755
index 000000000..5fd2dd7a8
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipDeleteSelected.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipDeleteSelected.sci b/modules/graphics/macros/datatips/datatipDeleteSelected.sci
new file mode 100755
index 000000000..79e45dc9f
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipDeleteSelected.sci
@@ -0,0 +1,19 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipDeleteSelected(curve_handles)
+ //datatip utility function
+ //set the selected datatip(s)
+
+ [curve,ind]=datatipGetSelected(curve_handles)
+ if ind<>[] then
+ datatipRemove(curve,ind)
+ end
+endfunction
+
diff --git a/modules/graphics/macros/datatips/datatipGUIEventHandler.bin b/modules/graphics/macros/datatips/datatipGUIEventHandler.bin
new file mode 100755
index 000000000..154b73cf7
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGUIEventHandler.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipGUIEventHandler.sci b/modules/graphics/macros/datatips/datatipGUIEventHandler.sci
new file mode 100755
index 000000000..dc9bca377
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGUIEventHandler.sci
@@ -0,0 +1,13 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function datatipGUIEventHandler(win,x,y,ibut)
+ if ibut==-1000 then
+ clearglobal datatipGUIHandles datatipGUICurve datatipGUIwin
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipGetEntities.bin b/modules/graphics/macros/datatips/datatipGetEntities.bin
new file mode 100755
index 000000000..cd68a4b71
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetEntities.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipGetEntities.sci b/modules/graphics/macros/datatips/datatipGetEntities.sci
new file mode 100755
index 000000000..8f2b7473c
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetEntities.sci
@@ -0,0 +1,57 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Gustavo Barbosa Libotte <gustavolibotte@gmail.com>
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function curve_handles=datatipGetEntities(ax)
+ curve_handles=[];
+ if argn(2)<1 then
+ ax=gca()
+ fig = ax.parent;
+ for k=1:size(fig.children,"*")
+ fc=fig.children(k);
+ select fc.type
+ case "Axes" then
+ axes=fc;
+ for j=1:size(axes.children,"*")
+ ac=axes.children(j);
+ select ac.type
+ case "Compound" then
+ compound=ac;
+ for i=1:size(compound.children,"*")
+ cc=compound.children(i);
+ select cc.type
+ case "Polyline" then
+ curve_handles=[curve_handles cc];
+ end
+ end
+ end
+ end
+ end
+ end
+ else
+ if type(ax)<>9|size(ax,"*")<>1|and(ax.type<>["Axes" "Compound"]) then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipGetEntities",1,"Axes"))
+ else
+ for j=1:size(ax.children,"*")
+ ac=ax.children(j);
+ select ac.type
+ case "Compound" then
+ compound=ac;
+ for i=1:size(compound.children,"*")
+ cc=compound.children(i);
+ select cc.type
+ case "Polyline" then
+ curve_handles=[curve_handles cc];
+ end
+ end
+ end
+ end
+ end
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipGetSelected.bin b/modules/graphics/macros/datatips/datatipGetSelected.bin
new file mode 100755
index 000000000..6e1cd2b87
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetSelected.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipGetSelected.sci b/modules/graphics/macros/datatips/datatipGetSelected.sci
new file mode 100755
index 000000000..df91e3215
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetSelected.sci
@@ -0,0 +1,22 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [curve,ind]=datatipGetSelected(curve_handles)
+ //datatip utility function
+ //get the selected datatip(s)
+ ind=[]
+ for kc=1:size(curve_handles,"*")
+ curve=curve_handles(kc);
+ ud=datatipGetStruct(curve);
+ sel=ud.selected
+ if sel>0 then ind=sel,break,end
+ end
+ if ind==[] then curve=[],end
+endfunction
+
diff --git a/modules/graphics/macros/datatips/datatipGetStruct.bin b/modules/graphics/macros/datatips/datatipGetStruct.bin
new file mode 100755
index 000000000..b5a0c40ce
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetStruct.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipGetStruct.sci b/modules/graphics/macros/datatips/datatipGetStruct.sci
new file mode 100755
index 000000000..b0f947368
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipGetStruct.sci
@@ -0,0 +1,19 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function t=datatipGetStruct(curve)
+
+ warnobsolete(_("''datatips'' property"), "5.5.1")
+
+ if type(curve)<>9|size(curve,"*")<>1 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: Graphic handle expected.\n"),"datatipGetStruct",1))
+ end
+
+ t = curve.datatips;
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipHilite.bin b/modules/graphics/macros/datatips/datatipHilite.bin
new file mode 100755
index 000000000..6aa3e8b12
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipHilite.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipHilite.sci b/modules/graphics/macros/datatips/datatipHilite.sci
new file mode 100755
index 000000000..01451747b
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipHilite.sci
@@ -0,0 +1,29 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipHilite(datatip_handle)
+ //datatip utility function
+ point_handle=datatip_handle.children(1)
+ string_handle=datatip_handle.children(2)
+ style=string_handle.user_data(2);
+ if style(1)==1 then
+ if point_handle.mark_background==point_handle.mark_foreground then
+ point_handle.mark_background=addcolor([255 255 238]/255);
+ else
+ point_handle.mark_background=point_handle.mark_foreground;
+ end
+ else
+ if point_handle.mark_mode=="on" then
+ point_handle.mark_mode="off"
+ else
+ point_handle.mark_mode="on"
+ end
+
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipManagerMode.bin b/modules/graphics/macros/datatips/datatipManagerMode.bin
new file mode 100755
index 000000000..8ebcdba2d
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipManagerMode.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipManagerMode.sci b/modules/graphics/macros/datatips/datatipManagerMode.sci
new file mode 100755
index 000000000..cb2af5635
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipManagerMode.sci
@@ -0,0 +1,90 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipManagerMode(varargin)
+ //Toggle or sets the interactive mode for datatips edition.;
+ // This function is called by the datatips menu callbacks.;
+ global datatipAngles; //to be able to detect that a rotation occurred
+ old=[] //to preserve current figure
+ if winsid()<>[] then old=gcf();end
+ select size(varargin)
+ case 0 then //toggle mode
+ fig=gcf()
+ action="toggle"
+ case 1 then
+ if type(varargin(1))==10 then
+ action=varargin(1)
+ fig=gcf()
+ elseif type(varargin(1))==9 then
+ fig=varargin(1)
+ action="toggle"
+ elseif type(varargin(1))==1 then
+ fig=scf(varargin(1))
+ if old<>[] then scf(old),end
+ action="toggle"
+ end
+ case 2 then
+ if type(varargin(1))==10 then
+ action=varargin(1)
+ fig=varargin(2)
+ elseif type(varargin(1))==9 then
+ fig=varargin(1)
+ action=varargin(2)
+ elseif type(varargin(1))==1 then
+ fig=scf(varargin(1))
+ if old<>[] then scf(old),end
+ action=varargin(2)
+ end
+ else
+ error(msprintf(_("%s: too many input arguments"),"datatipManagerMode"))
+ end
+ fig_ud=get(fig,"user_data")
+ if action =="toggle" then
+ if fig.event_handler <> "datatipEventhandler" then
+ action="on"
+ elseif fig.event_handler_enable == "on"
+ action="off"
+ else
+ action="on"
+ end
+ end
+ select action
+ case "on"
+ if fig.event_handler<>""& fig.event_handler<>"datatipEventhandler" then
+ //push current event handler in fig user data if possible
+ if fig_ud==[] then fig_ud=struct();end
+ if typeof(fig_ud)=="st" then
+ if ~isfield(fig_ud,"handlers") then fig_ud.handlers=[],end
+ fig_ud.handlers=[fig_ud.handlers;
+ fig.event_handler fig.event_handler_enable]
+ set(fig,"user_data",fig_ud)
+ else
+ warning(_("Datatip manager cannot be enabled, user data figure field is already used" ))
+ return
+ end
+ end
+ fig.event_handler_enable = "off" //to prevent against bug 7855
+ fig.event_handler = "datatipEventhandler"
+ fig.event_handler_enable = "on"
+ xinfo(_("Left click on a curve to create a datatip, right opens contextual menu"))
+ show_window(fig)
+ case "off"
+ fig.event_handler_enable = "off"
+ if typeof(fig_ud)=="st"&isfield(fig_ud,"handlers")&fig_ud.handlers<>[] then
+ fig.event_handler=fig_ud.handlers($,1)
+ fig.event_handler_enable=fig_ud.handlers($,2)
+ fig_ud.handlers= fig_ud.handlers(1:$-1,:)
+ set(fig,"user_data",fig_ud)
+ else
+ fig.event_handler_enable = "off"
+ end
+ clearglobal datatipAngles
+ xinfo("")
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipMove.bin b/modules/graphics/macros/datatips/datatipMove.bin
new file mode 100755
index 000000000..9f7e73d37
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipMove.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipMove.sci b/modules/graphics/macros/datatips/datatipMove.sci
new file mode 100755
index 000000000..b3cd116ad
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipMove.sci
@@ -0,0 +1,60 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipMove(tip_handle,ax)
+ //moves a datatip along the associated curve
+ // tip_handle : handle on the given datatip compound;
+ if argn(2)<1 then
+ error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"),"datatipMove",1))
+ end
+
+ if type(tip_handle)<>9|size(tip_handle,"*")<>1|or(tip_handle.type<>"Compound") then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipMove",1,"datatip"))
+ end
+
+ if argn(2)==1 then
+ ax=tip_handle.parent
+ while ax.type<>"Axes" then ax=ax.parent,end
+ else
+ if type(ax)<>9|size(ax,"*")<>1|or(ax.type<>"Axes") then
+ error(msprintf(_( "%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),"datatipMove",2,"Axes"))
+ end
+ end
+ curve_handle=tip_handle.children(1).user_data(1)
+ data=curve_handle.data //the curve data points
+ ud=datatipGetStruct(curve_handle);
+
+ if ax.view=="3d"&curve_handle.type=="Polyline" then
+ [xx,yy]=geom3d(data(:,1),data(:,2),data(:,3))
+ data=[xx,yy]
+ end
+
+ rep=[0 0 -1];
+ if ~ud.interpolate then //position restricted to knots
+ np=size(data,1)
+ while rep(3)==-1
+ rep=xgetmouse([%t %t])
+ //find data point which is at minimum distance to the pointer
+ [m,k]=min(sum((data-ones(np,1).*.rep(1:2)).^2,2))
+ datatipSetTipPosition(ud,tip_handle,curve_handle.data(k,:),k)
+ end
+ else //interpolated position
+ while rep(3)==-1
+ rep=xgetmouse([%t %t])
+ //find data point which is at minimum distance to the pointer
+ [d,pt,k,c]=orthProj(data,rep(1:2))
+ if pt<>[] then
+ if ax.view=="3d"&curve_handle.type=="Polyline" then
+ pt=curve_handle.data(k,:)+c*(curve_handle.data(k+1,:)-curve_handle.data(k,:))
+ end
+ datatipSetTipPosition(ud,tip_handle,pt,k)
+ end
+ end
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipRadioCallback.bin b/modules/graphics/macros/datatips/datatipRadioCallback.bin
new file mode 100755
index 000000000..4f014c3c5
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRadioCallback.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipRadioCallback.sci b/modules/graphics/macros/datatips/datatipRadioCallback.sci
new file mode 100755
index 000000000..7d8653842
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRadioCallback.sci
@@ -0,0 +1,50 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipRadioCallback(key,v)
+ global datatipGUIHandles datatipGUICurve
+ Keys=["sty" "lab" "box" "pos" "mul"]
+ i=find(key==Keys)
+ if v then
+ datatipGUIHandles(i,1).value=1
+ datatipGUIHandles(i,2).value=0
+ else
+ datatipGUIHandles(i,1).value=0
+ datatipGUIHandles(i,2).value=1
+ end
+ if i<=3 then
+ ud=datatipGetStruct(datatipGUICurve)
+ style=ud.style
+ end
+ select key
+ case "sty"
+ style(1)=bool2s(~v)+1
+ case "lab"
+ style(3)=bool2s(v)
+ case "box"
+ style(2)=bool2s(v)
+ case "pos"
+ datatipSetInterp(datatipGUICurve,~v);
+ case "mul"
+ datatipSetReplaceMode(datatipGUICurve,~v);
+ end
+
+ if i<=3 then
+ ud.style=style
+ datatipSetStruct(datatipGUICurve,ud)
+ fig=datatipGUICurve.parent
+ while fig.type<>"Figure" then fig=fig.parent,end
+ id=fig.immediate_drawing;
+ fig.immediate_drawing="off"
+ for i=1:size(ud.tips.children,"*")
+ datatipSetTipStyle(ud.tips.children(i),style)
+ end
+ fig.immediate_drawing=id
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipRemoveAll.bin b/modules/graphics/macros/datatips/datatipRemoveAll.bin
new file mode 100755
index 000000000..3bec233f6
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRemoveAll.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipRemoveAll.sci b/modules/graphics/macros/datatips/datatipRemoveAll.sci
new file mode 100755
index 000000000..eb98cf5ea
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRemoveAll.sci
@@ -0,0 +1,53 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipRemoveAll(curve_handles)
+ //remove all the datatips for the given curves
+ if argn(2)<>1 then //search for curves in the current axes
+ ax=gca()
+ curve_handles=datatipGetEntities(ax)
+ elseif type(curve_handles)<>9 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: an array of graphic handle expected.\n"),"datatipRemoveAll",1))
+ elseif size(curve_handles,"*")==1&curve_handles.type=="Axes" then
+ //the argument is a handle on an axes, search for curves in it
+ ax=curve_handles
+ curve_handles=datatipGetEntities(ax)
+ elseif and(curve_handles<>"Figure") then
+ //check for a common axes entity for parent
+ ax=[]
+ for k=1:size(curve_handles,"*")
+ a=curve_handles(k)
+ while a.type<>"Axes" then a=a.parent,end
+ if ax<>[]&a<>ax then
+ error(msprintf(_("%s: Wrong value for input argument #%d: the handles must have the same parent.\n"),"datatipRemoveAll",1))
+ end
+ ax=a
+ end
+ else
+ error(msprintf(_("%s: Wrong type for input argument #%d: handle on axes or axes children expected.\n"),"datatipRemoveAll",1))
+ end
+
+ fig=ax.parent
+ id=fig.immediate_drawing;
+ fig.immediate_drawing="off"
+ for k=1:size(curve_handles,"*")
+ ck=curve_handles(k);
+
+ num = 1;
+ for t=1:size(ck.children,"*")
+ tip = ck.children(num);
+ if tip.type == "Datatip" then
+ datatipRemove(tip);
+ else
+ num = num + 1;
+ end
+ end
+ end
+ fig.immediate_drawing=id
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipRemoveNearest.bin b/modules/graphics/macros/datatips/datatipRemoveNearest.bin
new file mode 100755
index 000000000..b38978644
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRemoveNearest.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipRemoveNearest.sci b/modules/graphics/macros/datatips/datatipRemoveNearest.sci
new file mode 100755
index 000000000..9a042679f
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipRemoveNearest.sci
@@ -0,0 +1,27 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipRemoveNearest(curve,pt)
+ //datatip utility function
+ ud=datatipGetStruct(curve)
+ if typeof(ud)=="datatips" then
+ tips=ud.tips.children
+ dmin=%inf;l=[];
+ pt=pt(:);
+ for tip_index=1:size(tips,"*")
+ d=norm(tips(tip_index).children(1).data(1:2)-pt(1:2))
+ if d<dmin then
+ l=tip_index;dmin=d;
+ end
+ end
+ if l<>[] then
+ datatipRemove(curve,l);
+ end
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipSetGUI.bin b/modules/graphics/macros/datatips/datatipSetGUI.bin
new file mode 100755
index 000000000..9f625692e
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetGUI.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetGUI.sci b/modules/graphics/macros/datatips/datatipSetGUI.sci
new file mode 100755
index 000000000..4a936f53e
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetGUI.sci
@@ -0,0 +1,56 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+function datatipSetGUI()
+ global datatipGUIwin
+ if datatipGUIwin==[] then return,end
+ global datatipGUIHandles datatipGUICurve
+ ud=datatipGetStruct(datatipGUICurve)
+ if typeof(ud)<>"datatips" then
+ //no datatips structure yet, initialize it
+ ud=datatipGetStruct(curve)
+ end
+ style=ud.style
+ if style(1)==1 then
+ datatipGUIHandles(1,1).value=1
+ datatipGUIHandles(1,2).value=0
+ else
+ datatipGUIHandles(1,1).value=0
+ datatipGUIHandles(1,2).value=1
+ end
+ if style(3)==1 then
+ datatipGUIHandles(2,1).value=1
+ datatipGUIHandles(2,2).value=0
+ else
+ datatipGUIHandles(2,1).value=0
+ datatipGUIHandles(2,2).value=1
+ end
+ if style(2)==1 then
+ datatipGUIHandles(3,1).value=1
+ datatipGUIHandles(3,2).value=0
+ else
+ datatipGUIHandles(3,1).value=0
+ datatipGUIHandles(3,2).value=1
+ end
+ if ~ud.interpolate then
+ datatipGUIHandles(4,1).value=1
+ datatipGUIHandles(4,2).value=0
+ else
+ datatipGUIHandles(4,1).value=0
+ datatipGUIHandles(4,2).value=1
+ end
+ if ~ud.replace then
+ datatipGUIHandles(5,1).value=1
+ datatipGUIHandles(5,2).value=0
+ else
+ datatipGUIHandles(5,1).value=0
+ datatipGUIHandles(5,2).value=1
+ end
+endfunction
+
+
diff --git a/modules/graphics/macros/datatips/datatipSetOrientation.bin b/modules/graphics/macros/datatips/datatipSetOrientation.bin
new file mode 100755
index 000000000..7c550c379
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetOrientation.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetOrientation.sci b/modules/graphics/macros/datatips/datatipSetOrientation.sci
new file mode 100755
index 000000000..241089d1d
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetOrientation.sci
@@ -0,0 +1,30 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipSetOrientation(tip_handle,o)
+ if argn(2)<>2 then
+ error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),...
+ "datatipSetOrientation",2))
+ end
+ orientations=["automatic" "upper left" "upper right", "lower left","lower right"]
+ if type(tip_handle)<>9|size(tip_handle,"*")<>1|or(tip_handle.type<>"Compound") then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),...
+ "datatipSetOrientation",1,"datatip"))
+ end
+
+ if o == "upper left" then
+ tip_handle.orientation = 0;
+ elseif o == "upper right" then
+ tip_handle.orientation = 1;
+ elseif o == "lower left" then
+ tip_handle.orientation = 2;
+ elseif o == "lower right" then
+ tip_handle.orientation = 3;
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipSetSelected.bin b/modules/graphics/macros/datatips/datatipSetSelected.bin
new file mode 100755
index 000000000..9a33d22b7
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetSelected.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetSelected.sci b/modules/graphics/macros/datatips/datatipSetSelected.sci
new file mode 100755
index 000000000..2fbccc256
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetSelected.sci
@@ -0,0 +1,38 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipSetSelected(curve_handles,tip_indices)
+ //datatip utility function
+ //set the selected datatip(s)
+
+ [curve,ind]=datatipGetSelected(curve_handles)
+ //unselect the current datatip if any
+ if ind<>[] then
+ ud=datatipGetStruct(curve);
+ tips=ud.tips.children
+ tip_handle=tips(ind);
+ datatipHilite(tip_handle) //unhilite
+ ud.selected=0
+ datatipSetStruct(curve,ud);
+ end
+
+ //select the new one
+ if tip_indices<>[] then
+ k=tip_indices(1);
+ l=tip_indices(2);
+ curve=curve_handles(k);
+ ud=datatipGetStruct(curve);
+ tips=ud.tips.children
+ tip_handle=tips(l);
+ datatipHilite(tip_handle) //hilite
+ ud.selected=l
+ datatipSetStruct(curve,ud);
+ end
+endfunction
+
diff --git a/modules/graphics/macros/datatips/datatipSetStruct.bin b/modules/graphics/macros/datatips/datatipSetStruct.bin
new file mode 100755
index 000000000..5af97655d
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetStruct.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetStruct.sci b/modules/graphics/macros/datatips/datatipSetStruct.sci
new file mode 100755
index 000000000..7e2cab2dc
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetStruct.sci
@@ -0,0 +1,39 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function ok=datatipSetStruct(curve,t)
+ if argn(2)<>2 then
+ error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),...
+ "datatipSetStruct",2))
+ end
+ if type(curve)<>9|size(curve,"*")<>1|or(curve.type<>"Polyline") then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),...
+ "datatipSetType",1,"Polyline"))
+ end
+
+ ok=%t
+ %datatips_i_s=generic_i_s
+ %datatips_i_st=generic_i_st
+ u_d=get(curve,"user_data")
+ if u_d==[] then
+ u_d.datatips=t
+ else
+ if typeof(u_d)=="st" then
+ u_d.datatips=t
+ elseif typeof(u_d)=="datatips" //for compatibilty
+ u.datatips=u_d
+ u_d=u
+ else
+ ok=%f
+ warning(msprintf(_("%s: Wrong type for curve user_data field: a struct expected.\n"),...
+ "datatipSetStruct"))
+ end
+ end
+ set(curve,"user_data",u_d)
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipSetStyle.bin b/modules/graphics/macros/datatips/datatipSetStyle.bin
new file mode 100755
index 000000000..91338cdd0
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetStyle.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetStyle.sci b/modules/graphics/macros/datatips/datatipSetStyle.sci
new file mode 100755
index 000000000..eb9eda2fa
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetStyle.sci
@@ -0,0 +1,81 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipSetStyle(curve_handle,t,boxed,labeled)
+ //changes the tips interpolation modes for a given curve
+ // curve_handle : a handle on a polyline
+ // t : 1 "square mark" or 2 "Directional arrow"
+ // boxed : a boolean
+ // labeled : a boolean
+ if argn(2)<1 then
+ error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"),...
+ "datatipSetType",1))
+ end
+ if argn(2)<4 then labeled=%t,end
+ if argn(2)<3 then boxed=%t,end
+
+ if type(curve_handle)<>9|size(curve_handle,"*")<>1|or(curve_handle.type<>"Polyline") then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A ''%s'' handle expected.\n"),...
+ "datatipSetType",1,"Polyline"))
+ end
+
+ if argn(2)==1 then
+ items=[_("Square mark, boxed label")
+ _("Square mark, simple label")
+ _("Square mark, no label")
+ _("Directional arrow, boxed label")
+ _("Directional arrow, simple label")
+ _("Directional arrow, no label")
+ ];
+ sel=x_choose(items,_("Select tip style"))
+ if sel==0 then return,end
+ t=floor(sel/3)+1
+ boxed=(modulo(sel,3)==1)
+ labeled=~(modulo(sel,3)==0)
+ else
+ if type(t)<>1|size(t,"*")<>1 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A scalar expected.\n"),...
+ "datatipSetType",2))
+ end
+ if and(t<>[1 2]) then
+ error(msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),...
+ "datatipSetType",2,"1,2"))
+ end
+ if type(boxed)<>4 |size(t,"*")<>1 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A boolean scalar expected.\n"),...
+ "datatipSetType",3))
+ end
+ if type(labeled)<>4 |size(labeled,"*")<>1 then
+ error(msprintf(_("%s: Wrong type for input argument #%d: A boolean scalar expected.\n"),...
+ "datatipSetType",4))
+ end
+
+ end
+ style=[t bool2s(boxed) bool2s(labeled)]
+
+ ud=datatipGetStruct(curve_handle)
+ if typeof(ud)<>"datatips" then;
+ ud=datatipGetStruct(curve_handle)
+ end
+ if or(ud.style<>style) then
+
+ fig=curve_handle.parent
+ while fig.type<>"Figure" then fig=fig.parent,end
+ id=fig.immediate_drawing;
+ fig.immediate_drawing="off"
+ tips=ud.tips.children
+ for i=1:size(tips,"*")
+ datatipSetTipStyle(tips(i),style)
+ end
+ fig.immediate_drawing=id
+ ud.style=style
+ datatipSetStruct(curve_handle,ud)
+ end
+
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipSetTipPosition.bin b/modules/graphics/macros/datatips/datatipSetTipPosition.bin
new file mode 100755
index 000000000..2bfe02ae7
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetTipPosition.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetTipPosition.sci b/modules/graphics/macros/datatips/datatipSetTipPosition.sci
new file mode 100755
index 000000000..4c0924e42
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetTipPosition.sci
@@ -0,0 +1,35 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipSetTipPosition(ud,tip_handle,pt,k)
+ //datatip utility function
+ point_handle=tip_handle.children(1)
+ string_handle=tip_handle.children(2)
+
+ tip_refs=point_handle.user_data
+ [curve_handle,point_index]=tip_refs(:)
+ formatfunction=ud.formatfunction
+
+ if ud.style==0 | size(curve_handle.data,1) == 1 then
+ point_handle.data=pt
+ else
+ if k<size(curve_handle.data,1)
+ dxy=curve_handle.data(k+1,:)-pt;
+ else
+ dxy=pt-curve_handle.data(k-1,:);
+ end
+ dxy=dxy/norm(dxy)/10000;
+ point_handle.data=[pt;pt+dxy]
+ end
+ tip_refs(2)=k;
+ point_handle.user_data=tip_refs
+ string_handle.text=formatfunction(curve_handle,pt,k)
+ setStringPosition(tip_handle,pt)
+
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipSetTipStyle.bin b/modules/graphics/macros/datatips/datatipSetTipStyle.bin
new file mode 100755
index 000000000..a725f4447
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetTipStyle.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipSetTipStyle.sci b/modules/graphics/macros/datatips/datatipSetTipStyle.sci
new file mode 100755
index 000000000..0d0b08051
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipSetTipStyle.sci
@@ -0,0 +1,76 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipSetTipStyle(tip_handle,style)
+ //datatip utility function
+ point_handle=tip_handle.children(1)
+ string_handle=tip_handle.children(2)
+ bg=addcolor([255 255 238]/255);
+ tip_refs=point_handle.user_data
+ [curve_handle,k]=tip_refs(1:2)
+
+ pt=point_handle.data(1,:)
+
+ //label
+ if style(3)==0 then //no label
+ string_handle.visible="off"
+ else
+ string_handle.visible="on"
+ end
+ if style(2)==1 then //boxed
+ string_handle.background=bg;
+ string_handle.box="on";
+ string_handle.fill_mode="on";
+ string_handle.font_foreground=curve_handle.foreground;
+ else
+ string_handle.box="off"
+ string_handle.foreground=color("gray");
+ string_handle.fill_mode="off";
+ string_handle.font_foreground=curve_handle.foreground;
+ end
+ string_handle.clip_state="off";
+ if string_handle.user_data<>[] then //preserve orientation if any
+ orient=string_handle.user_data(1)
+ else
+ orient=0;
+ end
+ string_handle.user_data=[orient style(2)]
+
+ //marker
+ point_handle.mark_style=11;
+ point_handle.mark_size_unit="point";
+ point_handle.mark_size=6;
+ select style(1)
+ case 1 then //square marker
+ point_handle.data= pt
+ point_handle.mark_mode="on";
+ point_handle.mark_background=bg;
+ point_handle.mark_foreground=curve_handle.foreground;
+ point_handle.arrow_size_factor = 0;
+ case 2 then //directional arrow marker
+
+ //compute tangeant
+ tip_refs=point_handle.user_data
+ [curve_handle,k]=tip_refs(1:2)
+ if k<size(curve_handle.data,1)
+ dxy=(curve_handle.data(k+1,:)-pt)/100000;
+ else
+ dxy=(pt-curve_handle.data(k-1,:))/100000;
+ end
+ point_handle.data=[pt;pt+dxy]
+ //set properties
+ point_handle.mark_background=curve_handle.foreground;
+ point_handle.mark_foreground=curve_handle.foreground;
+ point_handle.mark_mode="off";
+ point_handle.arrow_size_factor = 1.5;
+ point_handle.polyline_style = 4;
+ point_handle.foreground=curve_handle.foreground;
+ end
+ if style(3)<>0 then setStringPosition(tip_handle,pt),end
+endfunction
diff --git a/modules/graphics/macros/datatips/datatipsGUI.bin b/modules/graphics/macros/datatips/datatipsGUI.bin
new file mode 100755
index 000000000..37365c4d0
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipsGUI.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/datatipsGUI.sci b/modules/graphics/macros/datatips/datatipsGUI.sci
new file mode 100755
index 000000000..ca45db052
--- /dev/null
+++ b/modules/graphics/macros/datatips/datatipsGUI.sci
@@ -0,0 +1,413 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function datatipsGUI(curve_handle)
+ global datatipGUIwin
+ if datatipGUIwin<>[]&or(datatipGUIwin==winsid()) then //the gui window is already opened
+ global datatipGUICurve
+ datatipGUICurve= curve_handle
+ datatipSetGUI()
+ return
+ end
+
+
+ global datatipGUIHandles datatipGUICurve datatipGUIwin
+ margin_x = 5; // Horizontal margin between each elements
+ margin_y = 5; // Vertical margin between each elements
+ button_w = 150;
+ button_h = 25;
+ label_h = 20;
+ label_w = 160;
+ slabel_w = 80;
+ editor_h = 120;
+ axes_w = 3*margin_x+label_w+2*(slabel_w+4*margin_x+label_h);
+ editor_w = axes_w-2*margin_x;
+ axes_h = 4*margin_y+6*(label_h+margin_y)+ button_h;
+ defaultfont = "arial"; // Default Font
+ datatipGUICurve= curve_handle
+ ud=datatipGetStruct(datatipGUICurve)
+ if typeof(ud)<>"datatips" then
+ //no datatips structure yet, initialize it
+ ud=datatipGetStruct(curve)
+ end
+ style=ud.style
+
+ datatipGUIwin=max(winsid())+1
+
+ fig_id=datatipGUIwin
+ fig = scf(fig_id)
+ fig.event_handler="datatipGUIEventHandler"
+ fig.event_handler_enable="on"
+
+ // Remove Scilab graphics menus & toolbar
+ // drawlater (bug)
+ delmenu(fig.figure_id, gettext("&File"));
+ delmenu(fig.figure_id, gettext("&Tools"));
+ delmenu(fig.figure_id, gettext("&Edit"));
+ delmenu(fig.figure_id, gettext("&?"));
+ toolbar(fig.figure_id, "off");
+ fig.axes_size = [axes_w axes_h];
+
+
+ fig.background = addcolor([0.8 0.8 0.8]);
+ fig.figure_name = _("Datatips style");
+ ax=fig.children;
+ ax.background= fig.background ;
+ gui=uicontrol( ...
+ "parent" , fig,...
+ "style" , "frame",...
+ "units" , "pixels",...
+ "position" , [0 0 axes_w axes_h],...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ yo=axes_h-margin_y-label_h;
+ xo=margin_x;
+ H=[]
+ //Datatips positionning
+ x=xo;
+ y=yo;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Marker style:"),...
+ "units" , "pixels",...
+ "position" , [x y label_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "fontweight" , "bold", ...
+ "horizontalalignment" , "left", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+label_w+margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Square"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],...
+ "HorizontalAlignment" , "right",...
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+slabel_w+margin_x
+ r1= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 1,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""sty"",%t)",...
+ "visible" , "on");
+ x=x+label_h+4*margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Arrow"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "HorizontalAlignment" , "right",...
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ x=x+slabel_w+margin_x;
+ r2= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 0,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""sty"",%f)",...
+ "visible" , "on");
+ H=[H;r1 r2]
+ //Datatips Label
+ x=xo;
+ y=y-margin_y-label_h;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Labeled?"),...
+ "units" , "pixels",...
+ "position" , [x y label_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "fontweight" , "bold", ...
+ "horizontalalignment" , "left", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+label_w+margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Yes"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+slabel_w+margin_x
+ r1= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 1,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""lab"",%t)",...
+ "visible" , "on");
+ x=x+label_h+4*margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("No"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ x=x+slabel_w+margin_x;
+ r2= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 0,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""lab"",%f)",...
+ "visible" , "on");
+ H=[H;r1 r2]
+
+ //Datatips box
+ x=xo;
+ y=y-margin_y-label_h;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Boxed?"),...
+ "units" , "pixels",...
+ "position" , [x y label_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "fontweight" , "bold", ...
+ "horizontalalignment" , "left", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+label_w+margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Yes"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+slabel_w+margin_x;
+ r1= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 1,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""box"",%t)",...
+ "visible" , "on");
+ x=x+label_h+4*margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("No"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ x=x+slabel_w+margin_x;
+ r2= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 0,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""box"",%f)",...
+ "visible" , "on");
+ H=[H;r1 r2]
+ //marker position
+ x=xo;
+ y=y-margin_y-label_h;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Positionning?"),...
+ "units" , "pixels",...
+ "position" , [x y label_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "fontweight" , "bold", ...
+ "horizontalalignment" , "left", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+label_w+margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Knots"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+slabel_w+margin_x;
+ r1= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 1,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""pos"",%t)",...
+ "visible" , "on");
+ x=x+label_h+4*margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Interpolated"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ x=x+slabel_w+margin_x;
+ r2= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 0,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""pos"",%f)",...
+ "visible" , "on");
+ H=[H;r1 r2]
+ //Multiple datatips
+ x=xo;
+ y=y-margin_y-label_h;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Allow multiple datatips?"),...
+ "units" , "pixels",...
+ "position" , [x y label_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "fontweight" , "bold", ...
+ "horizontalalignment" , "left", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+label_w+margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("Yes"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+ x=x+slabel_w+margin_x;
+ r1= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 1,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""mul"",%t)",...
+ "visible" , "on");
+ x=x+label_h+4*margin_x;
+ uicontrol( ...
+ "parent" , gui,...
+ "style" , "text",...
+ "string" , _("No"),...
+ "units" , "pixels",...
+ "position" , [x y slabel_w label_h],....
+ "fontname" , defaultfont,...
+ "fontunits" , "points",...
+ "fontsize" , 12,...
+ "horizontalalignment" , "right", ...
+ "background" , [1 1 1]*0.8, ...
+ "visible" , "on");
+
+ x=x+slabel_w+margin_x;
+ r2= uicontrol( ...
+ "parent" , gui,...
+ "style" , "radiobutton",...
+ "value" , 0,...
+ "units" , "pixels",...
+ "position" , [x y label_h label_h],....
+ "background" , [1 1 1]*0.8, ...
+ "callback" , "datatipRadioCallback(""mul"",%f)",...
+ "visible" , "on");
+ H=[H;r1 r2]
+ //label edition function
+ x=xo;
+ y=y-2*margin_y-button_h;
+
+ E= uicontrol( ...
+ "parent" , gui, ...
+ "style" , "pushbutton", ...
+ "string" , _("Edit label generator"), ...
+ "units" , "pixels",...
+ "position" , [x y button_w button_h], ...
+ "fontname" , defaultfont, ...
+ "fontunits" , "points", ...
+ "fontsize" , 12, ...
+ "callback" , "global datatipGUICurve;datatipSetDisplay(datatipGUICurve)", ...
+ "visible" , "on");
+
+
+ datatipGUIHandles=H
+ datatipSetGUI()
+endfunction
diff --git a/modules/graphics/macros/datatips/lib b/modules/graphics/macros/datatips/lib
new file mode 100755
index 000000000..883e2c827
--- /dev/null
+++ b/modules/graphics/macros/datatips/lib
Binary files differ
diff --git a/modules/graphics/macros/datatips/names b/modules/graphics/macros/datatips/names
new file mode 100755
index 000000000..105d30093
--- /dev/null
+++ b/modules/graphics/macros/datatips/names
@@ -0,0 +1,25 @@
+%datatips_p
+datatipCreatePopupMenu
+datatipDefaultDisplay
+datatipDeleteSelected
+datatipGUIEventHandler
+datatipGetEntities
+datatipGetSelected
+datatipGetStruct
+datatipHilite
+datatipManagerMode
+datatipMove
+datatipRadioCallback
+datatipRemoveAll
+datatipRemoveNearest
+datatipSetGUI
+datatipSetOrientation
+datatipSetSelected
+datatipSetStruct
+datatipSetStyle
+datatipSetTipPosition
+datatipSetTipStyle
+datatipsGUI
+orthProj
+pixDist
+setStringPosition
diff --git a/modules/graphics/macros/datatips/orthProj.bin b/modules/graphics/macros/datatips/orthProj.bin
new file mode 100755
index 000000000..305eb662a
--- /dev/null
+++ b/modules/graphics/macros/datatips/orthProj.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/orthProj.sci b/modules/graphics/macros/datatips/orthProj.sci
new file mode 100755
index 000000000..d51816988
--- /dev/null
+++ b/modules/graphics/macros/datatips/orthProj.sci
@@ -0,0 +1,49 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function [d,ptp,ind,c]=orthProj(data,pt)
+ // computes minimum distance from a point to a polyline
+ //d minimum distance of the point to the nearest polyline data point
+ //ptp projected point coordiantes
+ //ind projection lies on segment [ind ind+1]
+ //c orthogonal projection coefficient
+ if argn(2)<>2 then
+ error(msprintf(_("%s: Wrong number of input argument(s): %d expected.\n"),"orthProj",2))
+ end
+
+
+ d = [];ptp = [];ind = [],c = []
+ [n,m] = size(data)
+ pt = matrix(pt,1,-1) //make pt a row vector
+ if n<2 then return,end
+ //the orthogonal projection coefficient of the vector y on the vector x;
+ //is given by <x,y>/||x||^2
+ //shift origin to (0,0) for each segment defined by data
+ X = (data(2:$,:)-data(1:$-1,:))
+ //apply similar origin transformation to the given point
+ Y = ones(n-1,1)*pt-data(1:$-1,:) ;
+ //compute the orthogonal projection coefficients relative to each segments
+ //first remove zero length segements;
+ L = sum(X.*X,2); //segment lengths
+ nz = find(L>0)
+ X = X(nz,:); Y = Y(nz,:);
+ P = sum(X.*Y,2)./L(nz);
+ //the projected point lies in the segment nz(i) if 0 <= P(i)<1
+ i_in = find(P >= 0 & P<1); //find segments the projected point falls in
+
+ if i_in<>[] then
+ //find the segment that realizes the min distance
+ [d,k] = min(sum((X(i_in,:).*(P(i_in)*ones(1,m))-Y(i_in,:)).^2,2))
+ d = sqrt(d) //the mini distance between the given point and the curve
+ i_in = i_in(k) //index of the first bound of the segment in data
+ c = P(i_in) // the orthogonal projection coefficient
+ ind = nz(i_in) //make i_in relative to the initial data
+ ptp = data(ind,:)+(data(ind+1,:)-data(ind,:))*c //the projected point
+ end
+endfunction
diff --git a/modules/graphics/macros/datatips/pixDist.bin b/modules/graphics/macros/datatips/pixDist.bin
new file mode 100755
index 000000000..6a68e299d
--- /dev/null
+++ b/modules/graphics/macros/datatips/pixDist.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/pixDist.sci b/modules/graphics/macros/datatips/pixDist.sci
new file mode 100755
index 000000000..c735d2e30
--- /dev/null
+++ b/modules/graphics/macros/datatips/pixDist.sci
@@ -0,0 +1,14 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function d=pixDist(p1,p2)
+ //computes the distance in pixels of two points
+ [x1,y1]=xchange([p1(1) p2(1)],[p1(2) p2(2)],"f2i")
+ d=max(abs([x1(2)-x1(1),y1(2)-y1(1)]))
+endfunction
diff --git a/modules/graphics/macros/datatips/setStringPosition.bin b/modules/graphics/macros/datatips/setStringPosition.bin
new file mode 100755
index 000000000..e73c82ab6
--- /dev/null
+++ b/modules/graphics/macros/datatips/setStringPosition.bin
Binary files differ
diff --git a/modules/graphics/macros/datatips/setStringPosition.sci b/modules/graphics/macros/datatips/setStringPosition.sci
new file mode 100755
index 000000000..7d544d416
--- /dev/null
+++ b/modules/graphics/macros/datatips/setStringPosition.sci
@@ -0,0 +1,138 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010-2011 - INRIA - Serge Steer <serge.steer@inria.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at;
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function setStringPosition(tip_handle,pt)
+ //Computes the position of the lower left corner of the string box.
+ //
+ //These coordinates must be expressed in user coordinates units but their
+ //computation takes into account the pixel dimensions of the text boxes
+ //when they are not located in the upper right position
+ ax=tip_handle.parent
+ while ax.type<>"Axes" then ax=ax.parent,end
+ string_handle=tip_handle.children(2);
+ point_handle=tip_handle.children(1);
+
+
+ params=string_handle.user_data
+ orient=params(1);
+ if size(params,"*")>1 then //for compatibility
+ style=params(2)
+ else
+ style=1
+ end
+ pt=pt(1,:)
+
+ r=xstringl(0,0,string_handle.text);r=r(3:4)';
+ if style==1 then
+ d=mark_usersize(point_handle);
+ else
+ d=[0 0]
+ end
+ orient=string_handle.user_data(1);
+ if orient==0 then //automatic
+
+ //compute the slope and curvature at the tip point
+ curve_handle=point_handle.user_data(1)
+ k=point_handle.user_data(2)
+ np=size(curve_handle.data,1)
+ T=curve_handle.data([max(k-1,1) k min(np,k+1)],:)
+
+
+ if size(T,2)==3 then
+ [Tx,Ty]=geom3d(T(:,1),T(:,2),T(:,3))
+ T=[Tx Ty];
+ end
+ d1=sum(diff(T,1,1),1)/2;
+ d2=diff(T,2,1);
+ c=(d1(1)*d2(2)-d1(2)*d2(1))
+
+ //set position according to the slope and curvature sign
+ if d1(1)>0 then
+ if d1(2)>0 then
+ if c<0 then//upper left
+ orient=1
+ else //lower right
+ orient=4
+ end
+ else
+ if c<0 then//upper right
+ orient=2
+ else //lower left
+ orient=3
+ end
+ end
+ else
+ if d1(2)>0 then
+ if c>0 then //upper right
+ orient=2
+ else //lower left
+ orient=3
+ end
+ else
+ if c>0 then//upper left
+ orient=1
+ else //lower right
+ orient=4
+ end
+
+ end
+ end
+ // mprintf("d1=[%f %f], c=%f, orient=%d\n",d1(1),d1(2),c,orient)
+ if ax.zoom_box==[]
+ box=ax.data_bounds
+ else
+ box=[ax.zoom_box(1:2);ax.zoom_box(3:4)];
+ end
+ //take care of the plot boundaries
+ // mprintf("Y:%f< [%f %f]<%f\n",box(1,2),pt(2)-r(2),pt(2)+r(2),box(2,2))
+ // mprintf("X:%f< [%f %f]<%f\n",box(1,1),pt(1)-r(1),pt(1)+r(1),box(2,1))
+ if or(orient==[1 2])&pt(2)+r(2)>box(2,2) then//upper bound on Y
+ orient=5-orient
+ end
+ if or(orient==[3 4])&pt(2)-r(2)<box(1,2) then//lower bound on Y
+ orient=5-orient
+ end
+ if or(orient==[2 4])&pt(1)+r(1)>box(2,1) then//right bound on X
+ orient=orient-1
+ end
+ if or(orient==[1 3])&pt(1)-r(1)<box(1,1) then//left bound on X
+ orient=orient+1
+ end
+ end
+ select orient
+ case 1 then //upper left
+ dx=-d(1)-r(1);dy=d(2);
+ case 2 then //upper right
+ dx=d(1);dy=d(2)
+ case 3 then //lower left
+ dx=-d(1)-r(1);dy=-d(2)-r(2)
+ case 4 then //lower right
+ dx=d(1);dy=-d(2)-r(2)
+ end
+
+ if ax.view=="3d" then
+ angles=ax.rotation_angles*%pi/180;
+ t=angles(2);a=angles(1);
+ st=sin(t);ct=cos(t);sa=sin(a);ca=cos(a)
+ c=sum(ax.data_bounds,1)/2
+ x=pt(1)-c(1)
+ y=pt(2)-c(2)
+ z=pt(3)-c(3)
+ pos=c+[(st*x-ct*y-dx)/st,0,(st*dy+st*sa*z-ca*y-ct*ca*dx)/(sa*st)]
+ else
+ pos=pt+[dx dy]
+
+ end
+ string_handle.data=pos
+endfunction
+function usize=mark_usersize(m)
+ pix_size=10*(m.mark_size+1)
+ [x1,y1]=xchange([0 pix_size],[0 pix_size],"i2f");
+ usize=abs([x1(2)-x1(1) y1(2)-y1(1)])/20;
+endfunction