1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr>
4 // This file must be used under the terms of the CeCILL.
5 // This source file is licensed as described in the file COPYING, which
6 // you should have received as part of this distribution. The terms
7 // are also available at;
8 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 function datatipSetDisplay(curve_handle,fun)
12 //Changes the datatips visualisation function for a given curve
14 error(msprintf(_("%s: Wrong number of input argument(s): At least %d expected.\n"),"datatipSetDisplay",1))
17 ud=datatipGetStruct(curve_handle)
18 if typeof(ud)<>'datatips' then;
19 if ~datatipInitStruct(curve_handle) then return,end
20 ud=datatipGetStruct(curve_handle)
23 // function definition is queried
24 txt=fun2string(ud.formatfunction,'fun')
26 txt=x_dialog('Function Editor',txt)
27 if txt==[] then ok=%f,break,end
28 ierr=execstr(txt,'errcatch')
29 if ierr==0 then ok=%t,break,end
30 messagebox(lasterror(),'','error')
32 if ~ok then return,end
34 if ~datatipCheckFunction(fun) then return,end
36 datatipSetStruct(curve_handle,ud)
37 for k=1:size(ud.tips,'*')
39 point_handle=tip_handle.children(1)
40 string_handle=tip_handle.children(2)
41 tip_index=point_handle.user_data(2)
42 string_handle.text=fun(curve_handle,point_handle.data)
46 function ok=datatipCheckFunction(fun)
48 [out,in,c]=string(fun)
49 if size(in,'*')<>3 then
50 messagebox(_("The selected function must have 3 input parameters (curve,pt,index)"))
53 if size(out,'*')<>1 then
54 messagebox(_("The selected function must have 1 output parameter (str)"))