summaryrefslogtreecommitdiff
path: root/modules/graphics/demos/datatips
diff options
context:
space:
mode:
Diffstat (limited to 'modules/graphics/demos/datatips')
-rwxr-xr-xmodules/graphics/demos/datatips/curvature.sci23
-rwxr-xr-xmodules/graphics/demos/datatips/datatip1.sce45
-rwxr-xr-xmodules/graphics/demos/datatips/datatip2.sce56
-rwxr-xr-xmodules/graphics/demos/datatips/datatips.dem.gateway.sce17
4 files changed, 141 insertions, 0 deletions
diff --git a/modules/graphics/demos/datatips/curvature.sci b/modules/graphics/demos/datatips/curvature.sci
new file mode 100755
index 000000000..4adf908f5
--- /dev/null
+++ b/modules/graphics/demos/datatips/curvature.sci
@@ -0,0 +1,23 @@
+// 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 c=curvature(data)
+ d1=diff(data,1,1);
+ d2=diff(data,2,1);
+ if size(data,2)==3 then
+ c=sqrt(...
+ (d2(:,3).*d1(2:$,2)-d2(:,2).*d1(2:$,3)).^2 +...
+ (d2(:,1).*d1(2:$,3)-d2(:,3).*d1(2:$,1)).^2 +...
+ (d2(:,2).*d1(2:$,1)-d2(:,1).*d1(2:$,2)).^2)/...
+ ((d1(2:$,1)^2+d1(2:$,2)^2+d1(2:$,3)^2)^1.5)
+ else
+ c=(d1(2:$,1).*d2(:,2)-d1(2:$,2).*d2(:,1))./((d1(2:$,1)^2+d1(2:$,2)^2)^1.5)
+ end
+endfunction
+
diff --git a/modules/graphics/demos/datatips/datatip1.sce b/modules/graphics/demos/datatips/datatip1.sce
new file mode 100755
index 000000000..62cf9da2a
--- /dev/null
+++ b/modules/graphics/demos/datatips/datatip1.sce
@@ -0,0 +1,45 @@
+// 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 datatip1
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ fig=gcf();fig.axes_size=[760 460];
+
+ title(_("datatips on 2D curves"),"fontsize",3);
+
+ x1=linspace(-1,1,300)';
+ plot(x1,x1.^3,x1,sinc(10*x1));
+ e=gce();
+ p1=e.children(1);//the handle on the sinc(10*x1) curve
+ p2=e.children(2); //the handle on the x1^3 curve
+
+ //Create 2 datatips on the sinc curve
+ datatipCreate(p1,50); //by index
+ datatipCreate(p1,[0.8 0.5]);//by nearest mesh point
+
+ //Create 2 datatips on the x^3 curve
+ //datatipSetStyle(p2,2,%f) //directional arrow no box
+ //function s=mydisp(curve,pt,index),s=msprintf("%.2g",pt(1)),endfunction
+ //pause;
+ //datatipSetDisplay(p2,mydisp) // Change the default datatip label
+ datatipCreate(p2,[0.1,0]);
+ datatipCreate(p2,[0.8 0.4]);
+ datatipSetStyle(p2,2,%f) //directional arrow no box
+
+ datatipManagerMode(fig,"on") //activate the interactive editor
+
+
+ demo_viewCode("datatip1.sce");
+
+endfunction
+
+datatip1();
+clear datatip1;
diff --git a/modules/graphics/demos/datatips/datatip2.sce b/modules/graphics/demos/datatips/datatip2.sce
new file mode 100755
index 000000000..b25c48a24
--- /dev/null
+++ b/modules/graphics/demos/datatips/datatip2.sce
@@ -0,0 +1,56 @@
+// 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 datatip2
+
+ my_handle = scf(100001);
+ clf(my_handle,"reset");
+ fig=gcf();
+
+ title(_("datatips on 3D curves"),"fontsize",3);
+
+
+ r=1;
+ k=tan(%pi/27);
+ t=linspace(-40,40,1000);
+ x=r*cos(t)./cosh(k*t);
+ y=r*sin(t)./cosh(k*t);
+ z=r*tanh(k*t);
+ param3d(x,y,z);c=gce();c.thickness=2;C.foreground=color("blue")
+
+ ax=gca();ax.rotation_angles=[70 50];ax.axes_visible="off";
+ drawnow()
+
+ c.display_function_data = t;
+ datatipSetStyle(c,2,%f) //directional arrow no box
+
+ function s=mydisp(curve,pt,index),
+ ud=datatipGetStruct(curve);
+ if index<>[] then
+ t=ud.t(index);
+ else //interpolated
+ [d,ptp,i,c]=orthProj(curve.data,pt);
+ t=ud.t(i)+(ud.t(i+1)-ud.t(i))*c;
+ end
+ s=msprintf("%.2g", t);
+ endfunction
+
+ for k=[350 400 450 500 520 550 600]
+ dt=datatipCreate(c,k);
+ end
+ //datatipSetDisplay(c,mydisp) // Change the default datatip label
+
+ datatipManagerMode(fig,"on") //activate the interactive editor
+
+ demo_viewCode("datatip2.sce");
+
+endfunction
+
+datatip2();
+clear datatip2;
diff --git a/modules/graphics/demos/datatips/datatips.dem.gateway.sce b/modules/graphics/demos/datatips/datatips.dem.gateway.sce
new file mode 100755
index 000000000..fc2144698
--- /dev/null
+++ b/modules/graphics/demos/datatips/datatips.dem.gateway.sce
@@ -0,0 +1,17 @@
+// 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
+demopath = get_absolute_file_path("datatips.dem.gateway.sce");
+
+subdemolist=[
+_("2D curves") , "datatip1.sce";
+_("3D curve") , "datatip2.sce"];
+
+
+subdemolist(:,2) = demopath + subdemolist(:,2);
+clear demopath;