Scilab Reorganisation. Add macros in the graphics module.
Jean-baptiste Silvy [Wed, 26 Jul 2006 09:09:35 +0000 (09:09 +0000)]
138 files changed:
scilab/modules/graphics/etc/graphics.quit [new file with mode: 0644]
scilab/modules/graphics/etc/graphics.start [new file with mode: 0644]
scilab/modules/graphics/macros/%h_copy.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_delete.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_draw.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_e.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_get.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_load.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_matrix.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_p.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_save.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%h_set.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%xload.sci [new file with mode: 0644]
scilab/modules/graphics/macros/%xsave.sci [new file with mode: 0644]
scilab/modules/graphics/macros/Sfgrayplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/Sgrayplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/TitleLabel.sci [new file with mode: 0644]
scilab/modules/graphics/macros/addcolor.sci [new file with mode: 0644]
scilab/modules/graphics/macros/bar.sci [new file with mode: 0644]
scilab/modules/graphics/macros/barh.sci [new file with mode: 0644]
scilab/modules/graphics/macros/barhomogenize.sci [new file with mode: 0644]
scilab/modules/graphics/macros/black.sci [new file with mode: 0644]
scilab/modules/graphics/macros/bode.sci [new file with mode: 0644]
scilab/modules/graphics/macros/buildmacros.sce [new file with mode: 0644]
scilab/modules/graphics/macros/chart.sci [new file with mode: 0644]
scilab/modules/graphics/macros/check2dFun.sci [new file with mode: 0644]
scilab/modules/graphics/macros/checkXYPair.sci [new file with mode: 0644]
scilab/modules/graphics/macros/clear_pixmap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/clf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/color.sci [new file with mode: 0644]
scilab/modules/graphics/macros/colorbar.sci [new file with mode: 0644]
scilab/modules/graphics/macros/colordef.sci [new file with mode: 0644]
scilab/modules/graphics/macros/contour.sci [new file with mode: 0644]
scilab/modules/graphics/macros/contour2d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/contourf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/dragrect.sci [new file with mode: 0644]
scilab/modules/graphics/macros/edit_curv.sci [new file with mode: 0644]
scilab/modules/graphics/macros/errbar.sci [new file with mode: 0644]
scilab/modules/graphics/macros/eval3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/eval3dp.sci [new file with mode: 0644]
scilab/modules/graphics/macros/evans.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fac3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fac3d1.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fchamp.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fcontour.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fcontour2d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fgrayplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fplot2d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fplot3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/fplot3d1.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gainplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gca.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gce.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gcf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gda.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gdf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/ged.sci [new file with mode: 0644]
scilab/modules/graphics/macros/ged_insert.sci [new file with mode: 0644]
scilab/modules/graphics/macros/genfac3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getColorIndex.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getLineSpec.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getPlotPropertyName.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getSurfPropertyName.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getTitleLabelPropertyNam.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getcolor.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getfont.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getlinestyle.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getmark.sci [new file with mode: 0644]
scilab/modules/graphics/macros/getsymbol.sci [new file with mode: 0644]
scilab/modules/graphics/macros/ghdl2tree.sci [new file with mode: 0644]
scilab/modules/graphics/macros/ghdl_fields.sci [new file with mode: 0644]
scilab/modules/graphics/macros/gr_macros.sce [new file with mode: 0644]
scilab/modules/graphics/macros/gr_menu.sci [new file with mode: 0644]
scilab/modules/graphics/macros/graduate.sci [new file with mode: 0644]
scilab/modules/graphics/macros/graycolormap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/graypolarplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/hist3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/histplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/hotcolormap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/hsv2rgb.sci [new file with mode: 0644]
scilab/modules/graphics/macros/hsvcolormap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/isoview.sci [new file with mode: 0644]
scilab/modules/graphics/macros/jetcolormap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/legend.sci [new file with mode: 0644]
scilab/modules/graphics/macros/legends.sci [new file with mode: 0644]
scilab/modules/graphics/macros/loadplots.sci [new file with mode: 0644]
scilab/modules/graphics/macros/locate.sci [new file with mode: 0644]
scilab/modules/graphics/macros/m_circle.sci [new file with mode: 0644]
scilab/modules/graphics/macros/mesh.sci [new file with mode: 0644]
scilab/modules/graphics/macros/milk_drop.sci [new file with mode: 0644]
scilab/modules/graphics/macros/name2rgb.sci [new file with mode: 0644]
scilab/modules/graphics/macros/nf3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/nyquist.sci [new file with mode: 0644]
scilab/modules/graphics/macros/oldplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/paramfplot2d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/pie.sci [new file with mode: 0644]
scilab/modules/graphics/macros/plot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/plot3d2.sci [new file with mode: 0644]
scilab/modules/graphics/macros/plot3d3.sci [new file with mode: 0644]
scilab/modules/graphics/macros/plotframe.sci [new file with mode: 0644]
scilab/modules/graphics/macros/plzr.sci [new file with mode: 0644]
scilab/modules/graphics/macros/polarplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/replot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/rgb2name.sci [new file with mode: 0644]
scilab/modules/graphics/macros/rotate.sci [new file with mode: 0644]
scilab/modules/graphics/macros/rubberbox.sci [new file with mode: 0644]
scilab/modules/graphics/macros/sca.sci [new file with mode: 0644]
scilab/modules/graphics/macros/scaling.sci [new file with mode: 0644]
scilab/modules/graphics/macros/scf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/sd2sci.sci [new file with mode: 0644]
scilab/modules/graphics/macros/sda.sci [new file with mode: 0644]
scilab/modules/graphics/macros/sdf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/secto3d.sci [new file with mode: 0644]
scilab/modules/graphics/macros/setDefaultColor.sci [new file with mode: 0644]
scilab/modules/graphics/macros/setPlotProperty.sci [new file with mode: 0644]
scilab/modules/graphics/macros/setSurfProperty.sci [new file with mode: 0644]
scilab/modules/graphics/macros/setTitleLabelProperty.sci [new file with mode: 0644]
scilab/modules/graphics/macros/sgrid.sci [new file with mode: 0644]
scilab/modules/graphics/macros/show_pixmap.sci [new file with mode: 0644]
scilab/modules/graphics/macros/square.sci [new file with mode: 0644]
scilab/modules/graphics/macros/stringbox.sci [new file with mode: 0644]
scilab/modules/graphics/macros/subplot.sci [new file with mode: 0644]
scilab/modules/graphics/macros/surf.sci [new file with mode: 0644]
scilab/modules/graphics/macros/title.sci [new file with mode: 0644]
scilab/modules/graphics/macros/titlepage.sci [new file with mode: 0644]
scilab/modules/graphics/macros/twinkle.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xbasc.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xbasimp.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xbasr.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xclear.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xclip.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xlabel.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xnumb.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xrpoly.sci [new file with mode: 0644]
scilab/modules/graphics/macros/xsetm.sci [new file with mode: 0644]
scilab/modules/graphics/macros/ylabel.sci [new file with mode: 0644]
scilab/modules/graphics/macros/zgrid.sci [new file with mode: 0644]
scilab/modules/graphics/macros/zlabel.sci [new file with mode: 0644]

diff --git a/scilab/modules/graphics/etc/graphics.quit b/scilab/modules/graphics/etc/graphics.quit
new file mode 100644 (file)
index 0000000..e4937aa
--- /dev/null
@@ -0,0 +1,6 @@
+// ====================================================================\r
+// This file contains command to be executed at the end \r
+// of a scilab session for graphics module\r
+// Copyright INRIA 2006\r
+// ====================================================================\r
+\r
diff --git a/scilab/modules/graphics/etc/graphics.start b/scilab/modules/graphics/etc/graphics.start
new file mode 100644 (file)
index 0000000..3efbc75
--- /dev/null
@@ -0,0 +1,23 @@
+// ====================================================================\r
+// graphics module initialisation file \r
+// Copyright INRIA 2006\r
+// ====================================================================\r
+//Load  functions librarie\r
+load('SCI/modules/graphics/macros/lib')\r
+// ====================================================================\r
+//add help chapter\r
+global LANGUAGE\r
+path=get_absolute_file_path('graphics.start');\r
+path=getshortpathname(path);\r
+path=strsubst(path,'\','/');\r
+if (LANGUAGE=='fr') then\r
+  path=strsubst(path,'/etc/','/help/fr');\r
+  add_help_chapter("Manipulation de fichiers sons",path);\r
+end\r
+\r
+if (LANGUAGE=='eng') then\r
+  path=strsubst(path,'/etc/','/help/eng');\r
+  add_help_chapter("Sound file handling",path)\r
+end\r
+clear path get_absolute_file_path add_help_chapter LANGUAGE;\r
+// ====================================================================\r
diff --git a/scilab/modules/graphics/macros/%h_copy.sci b/scilab/modules/graphics/macros/%h_copy.sci
new file mode 100644 (file)
index 0000000..977859b
--- /dev/null
@@ -0,0 +1,11 @@
+function h=%h_copy(h,ax)
+  save(TMPDIR+'/ghdlcopy',h)
+  if argn(2)<2 then 
+    load(TMPDIR+'/ghdlcopy')
+  else
+    a=get('current_axes')
+    set('current_axes', ax)
+    load(TMPDIR+'/ghdlcopy')
+    set('current_axes', a)
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_delete.sci b/scilab/modules/graphics/macros/%h_delete.sci
new file mode 100644 (file)
index 0000000..326fe99
--- /dev/null
@@ -0,0 +1,10 @@
+function %h_delete(varargin)
+
+  if (length(varargin) == 1)
+    hdl = varargin(1)
+    for i=1:size(hdl,'*')
+      delete(hdl(i))
+    end,
+  end,
+
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_draw.sci b/scilab/modules/graphics/macros/%h_draw.sci
new file mode 100644 (file)
index 0000000..8dc00e8
--- /dev/null
@@ -0,0 +1,5 @@
+function %h_draw(hdl)
+  for i=1:size(hdl,'*')
+    draw(hdl(i));
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_e.sci b/scilab/modules/graphics/macros/%h_e.sci
new file mode 100644 (file)
index 0000000..9890c72
--- /dev/null
@@ -0,0 +1,31 @@
+function r=%h_e(i,h)
+h=h
+  if type(i)==10 then
+    r=get(h,i)
+  elseif type(i)==15 then
+    n=lstsize(i)
+    
+    for k=1:n
+      p=i(k)
+      if type(p)==10 then
+       if type(h)==9 then
+         h=get(h,p),
+       else
+         h=h(p)
+       end
+      elseif or(type(p)==[1 2 4 8 129]) then
+       h=h(p)
+      elseif type(p)==15 then
+       h=h(p(:))
+      else
+       error('Invalid path')
+      end
+    end
+    r=h
+  elseif type(i)==1 then
+    r=h(i)
+  else
+    error('Invalid path')
+  end
+  if type(r)==10 then r=stripblanks(r),end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_get.sci b/scilab/modules/graphics/macros/%h_get.sci
new file mode 100644 (file)
index 0000000..ccf600f
--- /dev/null
@@ -0,0 +1,13 @@
+function out_vect = %h_get(varargin)\r
+  if (lstsize(varargin) == 2)\r
+    hdl = varargin(1)\r
+    str = varargin(2)\r
+    for i=1:size(hdl,'*')\r
+      out_vect(i) = get(hdl(i),str)\r
+    end,\r
+\r
+  elseif (lstsize(varargin) == 1)\r
+    str = varargin(1)\r
+    out_vect = get(str)\r
+  end,\r
+endfunction\r
diff --git a/scilab/modules/graphics/macros/%h_load.sci b/scilab/modules/graphics/macros/%h_load.sci
new file mode 100644 (file)
index 0000000..e8c0fd0
--- /dev/null
@@ -0,0 +1,1099 @@
+function h=%h_load(fd)
+//Author S. Steer Sept 2004, Copyright INRIA
+  global init_immediate_drawing
+  init_immediate_drawing = 0;
+  
+  if exists('xload_mode')==0 then xload_mode=%f,end
+  version=mget(4,'c',fd)
+  immediate_drawing="";
+  
+  h=[];
+  
+  if is_higher_than([3 1 0 1]) then // case 3 1 0 2 and after
+    hsize = mget(2,'c',fd)
+    for i=1:hsize(1)
+      for j=1:hsize(2)
+       [htmp,immediate_drawing] = load_graphichandle(fd)
+       h = [h htmp];
+      end
+    end
+  else
+    [h,immediate_drawing] = load_graphichandle(fd) // a single handle only can be loaded before 3 1 0 2
+  end
+  f=gcf();
+  f.immediate_drawing = immediate_drawing;
+  clearglobal init_immediate_drawing
+  clear init_immediate_drawing
+endfunction
+
+function [h,immediate_drawing] = load_graphichandle(fd)
+//Author S. Steer Sept 2004, Copyright INRIA
+  global init_immediate_drawing
+  typ=ascii(mget(mget(1,'c',fd),'c',fd))
+  if typ<>'Figure'
+    f=gcf();
+    if init_immediate_drawing == 0
+      immediate_drawing = f.immediate_drawing;
+      f.immediate_drawing ='off';
+      init_immediate_drawing = 1;
+    end
+  end
+  select typ
+  case "Figure"
+    
+    if xload_mode then
+      h=gcf()
+      visible=toggle(mget(1,'c',fd)); // visible
+      figure_position=mget(2,'sl',fd); // figure_position
+      figure_size=mget(2,'sl',fd); // figure_size
+      axes_size=mget(2,'sl',fd); //axes_size
+      auto_resize=toggle(mget(1,'c',fd)); // auto_resize
+      figure_name=ascii(mget(mget(1,'c',fd),'c',fd)) // figure_name
+      figure_id=mget(1,'sl',fd); // figure_id
+      h.color_map=matrix(mget(mget(1,'il',fd),"dl",fd),-1,3) // color_map
+      pixmap=toggle(mget(1,'c',fd)); // pixmap
+      pixel_drawing_mode=ascii(mget(mget(1,'c',fd),'c',fd)) // pixel_drawing_mode
+      immediate_drawing=toggle(mget(1,'c',fd));// immediate drawing // init. global variable immediate_drawing
+      h.immediate_drawing = 'off';  // set it to 'off' to pass useless redraw due to several 'set' calls
+      h.background=mget(1,'il',fd) // background
+      rotation_style=ascii(mget(mget(1,'c',fd),'c',fd)) // rotation_style
+    else
+      visible=toggle(mget(1,'c',fd)); // visible
+      figure_position=mget(2,'sl',fd); // figure_position
+      figure_size=mget(2,'sl',fd); // figure_size
+      axes_size=mget(2,'sl',fd); // axes_size
+      auto_resize=toggle(mget(1,'c',fd)); // auto_resize
+      figure_name=ascii(mget(mget(1,'c',fd),'c',fd)) // figure_name
+      figure_id=mget(1,'sl',fd); // figure_id
+      
+      // create the figure
+      h=scf(figure_id)
+       h.visible=visible;  // can be set now as we act on immediate_drawing everywhere else F.Leray 18.02.05
+      h.figure_position=figure_position
+      h.figure_size=figure_size
+      h.axes_size=axes_size
+      h.auto_resize=auto_resize
+      h.figure_name=figure_name
+      h.color_map=matrix(mget(mget(1,'il',fd),"dl",fd),-1,3) // color_map
+      h.pixmap=toggle(mget(1,'c',fd)); // pixmap
+      h.pixel_drawing_mode=ascii(mget(mget(1,'c',fd),'c',fd)) // pixel_drawing_mode
+      immediate_drawing=toggle(mget(1,'c',fd)); // immediate_drawing  // init. global variable immediate_drawing
+      h.immediate_drawing = 'off'; // set it to 'off' to pass useless redraw due to several 'set' calls
+      h.background=mget(1,'il',fd); // background
+      h.rotation_style=ascii(mget(mget(1,'c',fd),'c',fd)) // rotation_style
+      
+    end
+    
+    // children
+    n_axes=mget(1,'il',fd);
+    if n_axes==1 then
+      load_graphichandle(fd)
+    else
+      load_graphichandle(fd);
+      for k=2:n_axes
+       xsetech(wrect=[0 0 .1 .1])
+       load_graphichandle(fd)
+      end
+    end
+    
+    load_user_data(fd); // user_data
+    
+  case "Axes"
+    
+    a=gca() ;
+    titl=a.title ;
+    x_label=a.x_label ;
+    y_label=a.y_label ;
+    set(a,"visible"              , toggle(mget(1,'c',fd))) // visible
+    if and(version==[3 0 0 0]) then // axes_visible
+      axes_visible= toggle(mget(1,'c',fd));
+      axes_visible=emptystr(1,3)+axes_visible
+    else
+      axes_visible= toggle(mget(mget(1,'c',fd),'c',fd)) ;
+    end
+    
+    if is_higher_than( [3 1 0 1] ) then // axes_reverse
+      axes_reverse = toggle(mget(mget(1,'c',fd),'c',fd)) ;
+    end
+    
+    set(a,"axes_visible", axes_visible)
+    set(a,"axes_reverse", axes_reverse)
+    set(a,"grid"        , mget(mget(1,'c',fd),'il',fd)) //grid
+    set(a,"x_location"  , ascii(mget(mget(1,'c',fd),'c',fd))) // x_location
+    set(a,"y_location"  , ascii(mget(mget(1,'c',fd),'c',fd))) // y_location
+    view            =  ascii(mget(2,'c',fd)); // view
+
+    // title
+    set(titl,"visible"   , toggle(mget(1,'c',fd))) // title.visible
+    if is_higher_than( [4 0 0 0] ) then
+      set(titl, "text", load_text_matrix( fd ) ) ;
+    else
+      set(titl,"text"      , ascii(mget(mget(1,'c',fd),'c',fd))) // title.text
+    end
+    if is_higher_than([3 1 0 2]) then
+      set(titl,"font_foreground", mget(1,'il',fd)); // title.font_foreground
+    end
+    set(titl,"foreground", mget(1,'il',fd)); // title.foreground
+    if is_higher_than([3 1 0 0]) then
+      set(titl,"background"       , mget(1,'il',fd)); // title.background
+      set(titl,"fill_mode"        , toggle(mget(1,'c',fd))); //title.fill_mode
+    end
+    
+    set(titl,"font_style"       , mget(1,'c',fd)); // title.font_style
+    set(titl,"font_size"        , mget(1,'c',fd)); // title.font_size
+
+    if is_higher_than([3 1 0 0]) then
+      set(titl,"auto_rotation", toggle(mget(1,'c',fd))) // title.auto_rotation
+      set(titl,"font_angle"   , mget(1,'dl',fd)); // title.font_angle
+      set(titl,"auto_position", toggle(mget(1,'c',fd))) // title.auto_position
+      set(titl,"position"     , mget(2,'dl',fd)); // title.position
+    end
+    
+    // x_label
+    set(x_label,"visible"   , toggle(mget(1,'c',fd))) // x_label.visible
+    if is_higher_than( [4 0 0 0] ) then
+      set(x_label, "text", load_text_matrix( fd ) ) ;
+    else
+      set(x_label,"text"      , ascii(mget(mget(1,'c',fd),'c',fd))) // title.text
+    end
+    if is_higher_than([3 1 0 2]) then
+      set(x_label,"font_foreground", mget(1,'il',fd)); // x_label.font_foreground
+    end
+    set(x_label,"foreground", mget(1,'il',fd)); // x_label.foreground
+    if is_higher_than([3 0 0 0]) then
+      set(x_label,"background"       , mget(1,'il',fd)); // x_label.background
+      set(x_label,"fill_mode"        , toggle(mget(1,'c',fd))); // x_label.fill_mode
+    end
+    set(x_label,"font_style"     , mget(1,'c',fd)); // x_label.font_style
+    set(x_label,"font_size"      , mget(1,'c',fd)); // x_label.font_size
+    
+    if is_higher_than([3 0 0 0]) then
+      set(x_label,"auto_rotation"         , toggle(mget(1,'c',fd))) // x_label.auto_rotation
+      set(x_label,"font_angle"            , mget(1,'dl',fd)); // x_label.font_angle
+      set(x_label,"auto_position"         , toggle(mget(1,'c',fd))) // x_label.auto_position
+      set(x_label,"position"              , mget(2,'dl',fd)); // x_label.position
+    end
+    
+    // y_label
+    set(y_label,"visible"        , toggle(mget(1,'c',fd)))
+    if is_higher_than( [4 0 0 0] ) then
+      set(y_label, "text", load_text_matrix( fd ) ) ;
+    else
+      set(y_label,"text"      , ascii(mget(mget(1,'c',fd),'c',fd))) // title.text
+    end
+    if is_higher_than([3 1 0 2]) then
+      set(y_label,"font_foreground", mget(1,'il',fd)); // y_label.font_foreground
+    end
+    set(y_label,"foreground"     , mget(1,'il',fd));
+    if is_higher_than([3 0 0 0]) then
+      set(y_label,"background"       , mget(1,'il',fd));
+      set(y_label,"fill_mode"        , toggle(mget(1,'c',fd)));
+    end
+    set(y_label,"font_style"     , mget(1,'c',fd));
+    set(y_label,"font_size"      , mget(1,'c',fd));
+    
+    if is_higher_than([3 0 0 0]) then
+      set(y_label,"auto_rotation"         , toggle(mget(1,'c',fd)))
+      set(y_label,"font_angle"            , mget(1,'dl',fd));
+      set(y_label,"auto_position"         , toggle(mget(1,'c',fd)))
+      set(y_label,"position"              , mget(2,'dl',fd));
+    end
+    
+    if view=='3d' then
+      // z_label
+      z_label=a.z_label
+      set(z_label,"visible"        , toggle(mget(1,'c',fd)))
+      if is_higher_than( [4 0 0 0] ) then
+       set(z_label, "text", load_text_matrix( fd ) ) ;
+      else
+       set(z_label,"text"      , ascii(mget(mget(1,'c',fd),'c',fd))) // title.text
+      end
+      if is_higher_than([3 1 0 2]) then
+       set(z_label,"font_foreground", mget(1,'il',fd)); // z_label.font_foreground
+      end
+      set(z_label,"foreground"     , mget(1,'il',fd));
+      if is_higher_than([3 0 0 0]) then
+       set(z_label,"background"       , mget(1,'il',fd));
+       set(z_label,"fill_mode"        , toggle(mget(1,'c',fd)));
+      end
+      set(z_label,"font_style"     , mget(1,'c',fd));
+      set(z_label,"font_size"      , mget(1,'c',fd));
+      
+      if is_higher_than([3 0 0 0]) then
+       set(z_label,"auto_rotation"         , toggle(mget(1,'c',fd)))
+       set(z_label,"font_angle"            , mget(1,'dl',fd));
+       set(z_label,"auto_position"         , toggle(mget(1,'c',fd)))
+       set(z_label,"position"              , mget(2,'dl',fd));
+      end
+    end
+    
+    
+    
+    if is_higher_than([3 0 0 0]) then
+      auto_ticks=toggle(mget(mget(1,'c',fd),'c',fd)); // auto_ticks
+      
+      ticks=['ticks','locations','labels']
+      sz=mget(1,'sl',fd) // x_ticks.locations
+      x_ticks_locations=mget(sz,'dl',fd)'
+      lz=mget(sz,'c',fd) // x_ticks.label
+      x_ticks_labels=[];for ks=1:sz,x_ticks_labels(ks)=ascii(mget(lz(ks),'c',fd));end
+      set(a,'x_ticks',tlist(ticks,x_ticks_locations,x_ticks_labels))
+      
+      sz=mget(1,'sl',fd) // y_ticks.locations
+      y_ticks_locations=mget(sz,'dl',fd)'
+      lz=mget(sz,'c',fd) // y_ticks.label
+      y_ticks_labels=[];for ks=1:sz,y_ticks_labels(ks)=ascii(mget(lz(ks),'c',fd));end
+      set(a,'y_ticks',tlist(ticks,y_ticks_locations,y_ticks_labels))
+
+      sz=mget(1,'sl',fd) // z_ticks.locations
+      z_ticks_locations=mget(sz,'dl',fd)'
+      lz=mget(sz,'c',fd) // z_ticks.labels
+      z_ticks_labels=[];for ks=1:sz,z_ticks_labels(ks)=ascii(mget(lz(ks),'c',fd));end
+      set(a,'z_ticks',tlist(ticks,z_ticks_locations,z_ticks_labels))
+
+      set(a,"auto_ticks"           , auto_ticks)
+    end
+    
+    if is_higher_than([3 1 0 2]) then
+      // migth be now 'off','hidden_axis','back_half' or 'on'
+      boxtype = ascii(mget(mget(1,'c',fd),'c',fd)) ;
+      set( a, "box", boxtype  ) // box
+    else
+      set(a, "box", toggle(mget(1,'c',fd) ) ) // box
+    end
+    
+    set(a,"sub_tics"             , mget(mget(1,'c',fd),'c',fd)) // sub_tics
+    if ~(is_higher_than([3 1 0 1]) ) then 
+      mget(1,'il',fd); // tics_color is removed F.Leray 15.03.05
+    end
+    set(a,"font_style"           , mget(1,'c',fd));  // font_style
+    set(a,"font_size"            , mget(1,'c',fd));  // font_size
+    set(a,"font_color"           , mget(1,'il',fd)); // font_color
+    set(a,"isoview"              , toggle(mget(1,'c',fd))) // isoview
+    cube_scaling    = toggle(mget(1,'c',fd)) // cube_scaling
+    rotation_angles = mget(2,'dl',fd); // rotation_angles
+    
+    if a.view=='2d' then
+      set(a,"view"               , view);
+    end
+    if a.view=='3d' then
+      set(a,"cube_scaling"      , cube_scaling)
+      if view=='3d' then
+       set(a,"rotation_angles"   , rotation_angles)
+      end
+    end
+    if is_higher_than([3 0 0 0]) then // log_flags
+      set(a,"log_flags"            , ascii(mget(3,'c',fd)));
+    else
+      set(a,"log_flags"            , ascii(mget(2,'c',fd)));
+    end
+    
+    set(a,"tight_limits"         , toggle(mget(1,'c',fd))) // tight_limits
+    data_bounds = matrix(mget(mget(1,'c',fd),'dl',fd),2,-1) // data_bounds
+    
+    
+    if view=='2d'& a.view=='3d' then
+      data_bounds(2,3)=0;
+    end
+    if xload_mode
+      // check if a had at least a child previously
+      // if not the axes is considered unused
+      // and we don't merge the data_bounds.
+      if a.children <> []  then
+       old_bounds=a.data_bounds;
+       for k=1:size(old_bounds,2)
+         data_bounds(1,k)=min(data_bounds(1,k),old_bounds(1,k));
+         data_bounds(2,k)=max(data_bounds(2,k),old_bounds(2,k));
+       end
+      end
+    end
+    if is_higher_than([3 0 0 0]) then
+      if mget(1,'c',fd)<>0 then
+       set(a,"zoom_box"          , mget(4,'dl',fd))  // zoom_box
+      end
+    end
+    if is_higher_than([3 1 0 1]) then
+      set(a,"margins"              , mget(4,'dl',fd))  // margins
+    end
+    
+    set(a,"axes_bounds"          , mget(4,'dl',fd))  // axes_bounds
+    set(a,"auto_clear"           , toggle(mget(1,'c',fd))) // auto_clear
+    set(a,"auto_scale"           , toggle(mget(1,'c',fd))) // auto_scale
+
+    if is_higher_than([3 1 0 2] ) then // 4 0 0 0 and after
+      set(a,"hidden_axis_color", mget(1,'il',fd)) ; // hidden_axis_color
+    end
+    
+    set(a,"hiddencolor"          , mget(1,'il',fd)), // hidden_color
+    set(a,"line_mode"            , toggle(mget(1,'c',fd))), // line_mode
+    set(a,"line_style"           , mget(1,'c',fd)) // line_style
+    set(a,"thickness"            , mget(1,'sl',fd)), // thickness
+    set(a,"mark_mode"            , toggle(mget(1,'c',fd))), //mark_mode
+    set(a,"mark_style"           , mget(1,'c',fd)) // mark_style
+    set(a,"mark_size"            , mget(1,'c',fd)) // mark_size
+    if is_higher_than([3 0 0 0]) then  
+      
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit 
+       msu='tabulated' ;
+      else 
+       msu='point';
+      end
+      
+      set(a,"mark_size_unit"   , msu)
+      set(a,"mark_foreground"      , mget(1,'il',fd)) ; // mark_foreground
+      set(a,"mark_background"      , mget(1,'il',fd)) ; // mark_background
+    else
+      set(a,"mark_size_unit"     , 'tabulated')
+    end
+    set(a,"foreground"           , mget(1,'il',fd)), // foreground
+    set(a,"background"           , mget(1,'il',fd)), // background
+    clip_state                   = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then // clip_box
+      set(a,"clip_box",mget(4,'dl',fd)) ;
+    end
+    set(a,"clip_state"           ,clip_state);
+    
+    // children
+    nbChildren = mget(1,'il',fd) ;
+    for k = 1 : nbChildren
+       load_graphichandle(fd) ;
+    end
+    //next lines because tools used to rebuild children change the
+    //data_bounds an axes_visible properties
+    set(a,"data_bounds"          , data_bounds) ; 
+    set(a,"axes_visible"          , axes_visible) ;
+    if is_higher_than([3 1 0 2] ) then
+      set(a, "box", boxtype ) ;
+    end   
+
+    h=a;
+    load_user_data(fd) ; // user_data
+    
+  case "Polyline"
+    visible=toggle(mget(1,'c',fd)) // visible
+    sz=mget(2,'il',fd); // data
+    data=matrix(mget(prod(sz),'dl',fd),sz(1),-1); 
+    if is_higher_than([3 1 0 0]) then  
+      closed      = toggle(mget(1,'c',fd)) // closed
+    end
+    line_mode      = toggle(mget(1,'c',fd)) // line_mode
+    if is_higher_than([3 1 0 0]) then  
+      fill_mode      = toggle(mget(1,'c',fd)) // fill_mode
+    end
+    line_style     = mget(1,'c',fd); // line_style
+    thickness      = mget(1,'sl',fd); // thickness
+    if is_higher_than([3 1 0 1]) then  
+      arrow_size_factor = mget(1,'sl',fd); // arrow_size_factor
+    end
+    polyline_style = mget(1,'c',fd); // polyline_style
+    
+    if is_higher_than([3 1 0 1] ) then
+      size_interp_color = mget(1,'sl',fd) ; // interp_color_vector
+      interp_color_vector = mget( size_interp_color, 'dl', fd ) ;
+      interp_color_mode   = toggle( mget( 1, 'c', fd ) ) ; // interp_color_mode
+    end
+    
+    mark_mode      = toggle(mget(1,'c',fd)) // mark_mode
+    mark_style     = mget(1,'c',fd); // mark_style
+    mark_size      = mget(1,'c',fd); // mark_size
+    msu='tabulated'
+    if is_higher_than([3 0 0 0]) then
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit
+       msu='tabulated' ;
+      else 
+       msu='point';
+      end
+    end
+
+    foreground     = mget(1,'il',fd); // foreground
+    
+    if is_higher_than([3 1 0 0]) then  
+      background     = mget(1,'il',fd); // background
+    end
+  
+    if is_higher_than([3 0 0 0]) then  
+      mark_foreground=mget(1,'il',fd) // mark_foreground
+      mark_background=mget(1,'il',fd) // mark_background
+    end
+    
+    if is_higher_than([3 1 0 0]) then  
+      sz_x_shift=mget(1,'sl',fd) // x_shift
+      x_shift=mget(sz_x_shift,'dl',fd)'
+
+      sz_y_shift=mget(1,'sl',fd) // y_shift
+      y_shift=mget(sz_y_shift,'dl',fd)'
+      
+      sz_z_shift=mget(1,'sl',fd) // z_shift
+      z_shift=mget(sz_z_shift,'dl',fd)'
+    end
+    
+    if is_higher_than([3 1 0 1]) then
+      bar_width = mget( 1, 'dl', fd ) ; // bar_width
+    end
+    
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) ; // clip_box
+    else
+      clip_box = [] ;
+    end
+    
+    // draw the polyline and set properties
+    xpoly(data(:,1),data(:,2))
+    //plot2d( data(:,1),data(:,2));
+    h=get('hdl')
+    set(h,"data",data)
+    set(h,"visible",visible)
+    set(h,"line_mode",line_mode),
+    set(h,"line_style",line_style)
+    set(h,"thickness",thickness)
+    set(h,"arrow_size_factor",arrow_size_factor);
+    set(h,"polyline_style",max(1,polyline_style)),
+    set(h,"mark_style",mark_style),
+    set(h,"mark_size",mark_size),
+    set(h,"mark_mode",mark_mode),
+    set(h,"foreground",foreground),
+    if is_higher_than([3 0 0 0]) then
+      set(h,"mark_size_unit",msu)
+      set(h,"mark_foreground",mark_foreground),
+      set(h,"mark_background",mark_background)
+    end
+    if is_higher_than([3 1 0 0]) then
+      set(h,"background",background)
+      set(h,"fill_mode",fill_mode)
+      set(h,"closed",closed);
+      set(h,'x_shift',x_shift);
+      set(h,'y_shift',y_shift);
+      set(h,'z_shift',z_shift);
+    end
+    
+    if is_higher_than([3 1 0 1]) then
+      set(h,"interp_color_mode",interp_color_mode);
+      if interp_color_mode == 'on' then
+       set(h,"interp_color_vector",interp_color_vector);       
+      end
+      set(h,"bar_width",bar_width);
+    end
+    
+    if clip_state =='' then clip_state='clipgrf',end
+    if clip_state=='on' then set(h,"clip_box",clip_box),end
+    set(h,"clip_state",clip_state);
+    
+    load_user_data(fd) // user_data
+  
+  case "Plot3d" then
+    visible=toggle(mget(1,'c',fd)) // visible
+    surface_mode   = toggle(mget(1,'c',fd)) // surface_mode
+    foreground     = mget(1,'il',fd); // foreground
+    thickness      = mget(1,'sl',fd); // thickness
+    mark_mode      = toggle(mget(1,'c',fd)) // mark_mode
+    mark_style     = mget(1,'c',fd); // mark_style
+    mark_size      = mget(1,'c',fd); // mark_size
+    
+    if is_higher_than([3 0 0 0]) then
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit
+       msu='tabulated' ;
+      else 
+       msu='point';
+      end
+      mark_foreground=mget(1,'il',fd) // mark_foreground
+      mark_background=mget(1,'il',fd) // mark_background
+    else
+      msu='tabulated'  
+    end
+    
+    color_mode     = mget(1,'c',fd); // color_mode
+    color_flag     = mget(1,'c',fd); // color_flag
+
+    sz=mget(2,'il',fd); // data.x
+    x=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.y
+    y=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.z
+    z=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    
+    if or(color_flag==[2,5]) then
+         sz=mget(2,'il',fd); // data.color
+        clr=matrix(mget(prod(sz),'il',fd),sz(1),-1);
+    end
+    hiddencolor    = mget(1,'il',fd); // hidden_color
+    
+    // plot3d modify the given rotation angles
+    // trick to force keeping the good rotation angles F.Leray 18.02.05
+    a=gca();
+    rotation_angles = a.rotation_angles;
+    
+    if or(color_flag==[2 5]) then
+      plot3d1(x,y,list(z,clr))
+    else
+      plot3d(x,y,z)
+    end
+    
+    a.rotation_angles = rotation_angles;
+    
+    h=gce();
+    set(h,"visible",visible)
+    set(h,"surface_mode",surface_mode)
+    set(h,"thickness",thickness)
+    set(h,"foreground",foreground),
+    set(h,"color_mode",color_mode),
+    set(h,"mark_style",mark_style),
+    set(h,"mark_size",mark_size),
+    if is_higher_than([3 0 0 0]) then
+      set(h,"mark_size_unit",msu),
+      set(h,"mark_foreground",mark_foreground),
+      set(h,"mark_background",mark_background)
+    end
+    set(h,"mark_mode",mark_mode)
+    set(h,"color_flag",color_flag),
+    set(h,"hiddencolor",hiddencolor),
+    load_user_data(fd)
+    
+  case "Fac3d" then
+    
+    visible=toggle(mget(1,'c',fd)) // visible
+    surface_mode   = toggle(mget(1,'c',fd)) // surface_mode
+    foreground     = mget(1,'il',fd); // foreground
+    thickness      = mget(1,'sl',fd); // thickness
+    mark_mode      = toggle(mget(1,'c',fd)) // mark_mode
+    mark_style     = mget(1,'c',fd); // mark_style
+    mark_size      = mget(1,'c',fd); // mark_size
+    if is_higher_than([3 0 0 0]) then
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit
+       msu='tabulated';
+      else 
+         msu='point';
+      end
+      mark_foreground=mget(1,'il',fd) ; // mark_foreground
+      mark_background=mget(1,'il',fd) ; // mark_background
+    end
+    color_mode     = mget(1,'c',fd); // color_mode
+    color_flag     = mget(1,'c',fd); // color_flag
+    sz=mget(2,'il',fd); // data.x
+    x=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.y
+    y=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.z
+    z=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    
+    if is_higher_than([3 1 0 1]) & color_flag >= 2 then
+      sz=mget(2,'il',fd); // data.z
+      clr=matrix(mget(prod(sz),'il',fd),sz(1),-1);
+      
+      if ascii(mget(1,'c',fd)) == 's' then // cdata_mapping
+       cdata_mapping = 'scaled' ;
+      else
+       cdata_mapping = 'direct'  ;
+      end
+      
+    elseif or(color_flag==[2 5]) then
+      // compatibility with old version
+      sz=mget(2,'il',fd); // data.z
+      clr=matrix(mget(prod(sz),'il',fd),sz(1),-1);
+    end
+    hiddencolor    = mget(1,'il',fd); // hiddencolor
+    
+    // plot3d modify the given rotation angles
+    // trick to force keeping the good rotation angles F.Leray 18.02.05
+    a=gca();
+    rotation_angles = a.rotation_angles;
+    if is_higher_than([3 1 0 1]) & color_flag >= 2 then
+      plot3d1(x,y,list(z,clr))
+    elseif or(color_flag==[2 5]) then
+      plot3d1(x,y,list(z,clr))
+    else
+      plot3d(x,y,z)
+    end
+    
+    a.rotation_angles = rotation_angles;
+    
+    h=gce();
+    set(h,"visible",visible)
+    set(h,"surface_mode",surface_mode)
+    set(h,"thickness",thickness)
+    set(h,"foreground",foreground),
+    set(h,"color_mode",color_mode),
+    set(h,"color_flag",color_flag),
+    set(h,"hiddencolor",hiddencolor),
+    set(h,"mark_style",mark_style),
+    set(h,"mark_size",mark_size),
+    set(h,"mark_mode",mark_mode)
+    if is_higher_than([3 0 0 0]) then
+      set(h,"mark_size_unit",msu),
+      set(h,"mark_foreground",mark_foreground),
+      set(h,"mark_background",mark_background)
+    end
+    
+    if is_higher_than([3 1 0 1]) & color_flag >= 2 then
+      set(h,"cdata_mapping",cdata_mapping);
+    end
+    
+    load_user_data(fd) ; // user_data
+  
+  case "Compound"
+    // children
+    n=mget(1,'il',fd)        
+    H=[]
+    for k=1:n
+      htmp = load_graphichandle(fd)
+      H=[htmp H]
+    end
+    h=glue(H)
+    if is_higher_than([3 1 0 1]) then // visible
+     h.visible = toggle(mget(1,'c',fd)) ;
+    end
+    
+    load_user_data(fd) // user_data
+    
+  
+  case "Agregation" // for compatibility with old save
+       
+    // children
+    n=mget(1,'il',fd)
+    H=[]
+    for k=1:n
+      htmp = load_graphichandle(fd)
+      H=[htmp H]
+    end
+    h=glue(H)
+    
+    if is_higher_than([3 1 0 1]) then // visible
+      h.visible = toggle(mget(1,'c',fd)) ;
+    end
+    
+    load_user_data(fd) // user_data
+  
+  case "Rectangle"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    thickness      = mget(1,'sl',fd); // thickness
+    mark_mode      = toggle(mget(1,'c',fd)) // mark_mode
+    mark_style     = mget(1,'c',fd); // mark_style
+    mark_size      = mget(1,'c',fd); // mark_size
+    if is_higher_than([3 0 0 0]) then
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit
+       msu='tabulated' ;
+      else 
+       msu='point';
+      end
+      mark_foreground=mget(1,'il',fd) // mark_foreground
+      mark_background=mget(1,'il',fd) // mark_background
+    else
+      msu='tabulated'
+    end
+    
+    line_mode      = toggle(mget(1,'c',fd)) ; // line_mode
+    line_style     = mget(1,'c',fd); // line_style
+    fill_mode      = toggle(mget(1,'c',fd)) ; // fill_mode
+    foreground     = mget(1,'il',fd); // foreground
+    
+    if is_higher_than([3 1 0 1]) then
+      background = mget(1,'il',fd); // background
+    end
+    
+    data           = mget(4,'dl',fd); // data
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) ; // clip_stata
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) // clip_box
+    else
+      clip_box=[]
+    end
+    
+    // draw the rectangle
+    xrect(data);
+    h=get('hdl')
+    set(h,"visible",visible)
+    set(h,"thickness",thickness)
+    set(h,"mark_style",mark_style),
+    set(h,"mark_size",mark_size),
+    set(h,"mark_size_unit",msu),
+    if is_higher_than([3 0 0 0]) then
+      set(h,"mark_foreground",mark_foreground) ;
+      set(h,"mark_background",mark_background) ;
+    end
+    set(h,"mark_mode",mark_mode)
+    set(h,"line_style",line_style)
+    set(h,"fill_mode",fill_mode)
+    set(h,"foreground",foreground) ;
+    if is_higher_than([3 1 0 1]) then
+      set(h,"background",background) ;
+    end
+    set(h,"line_mode",line_mode)
+    if clip_state=='on' then set(h,"clip_box",clip_box),end
+    set(h,"clip_state",clip_state);
+    
+    load_user_data(fd) ; // user_data
+    
+  case "Arc"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    thickness      = mget(1,'sl',fd); // thickness
+    line_style     = mget(1,'c',fd);  // line_style
+    
+    if is_higher_than([3 1 0 1])
+      line_mode = toggle(mget(1,'c',fd)) ; // line_mode
+    end
+    
+    fill_mode      = toggle(mget(1,'c',fd)) // fill_mode
+    foreground     = mget(1,'il',fd); // foreground
+    
+    if is_higher_than([3 1 0 1]) then
+      background = mget(1,'il',fd) ; // background
+    end
+    
+    data           = mget(6,'dl',fd); // data
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) // clip_box
+    else
+      clip_box=[]
+    end
+    xarc(data(1),data(2),data(3),data(4),data(5),data(6));
+    h=get('hdl')
+    set(h,"visible",visible)
+    set(h,"thickness",thickness)
+    set(h,"line_style",line_style)
+    set(h,"line_mode",line_mode);
+    set(h,"fill_mode",fill_mode)
+    set(h,"foreground",foreground) ;
+    set(h,"background",background) ;
+    if clip_state=='on' then set(h,"clip_box",clip_box),end
+    set(h,"clip_state",clip_state);
+    
+    load_user_data(fd) // user_data
+    
+  case "Champ"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    sz=mget(2,'il',fd); // data.x
+    x=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.y
+    y=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.fx
+    fx=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    sz=mget(2,'il',fd); // data.fy
+    fy=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    
+    // draw the champ
+    champ(x,y,fx,fy);
+    h=gce();
+        
+    set(h,"visible",visible);
+    set(h,"line_style",mget(1,'c',fd)); // line_style
+    set(h,"thickness",mget(1,'sl',fd)) // thickness
+    set(h,"colored",toggle(mget(1,'c',fd))) // colored
+    set(h,"arrow_size",mget(1,'dl',fd)) // arrow_size
+    
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      set(h,"clip_box", mget(4,'dl',fd)) // clip_box
+    end
+    set(h,"clip_state",clip_state);  
+    load_user_data(fd) // user_data
+    
+  case "Segs"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    sz             = mget(2,'il',fd) // data
+    data           = matrix(mget(prod(sz),'dl',fd),sz(1),-1)
+    
+    // draw the segs
+    xsegs(data(:,1),data(:,2))
+    h=gce()
+    if size(data,2)==3 then
+      h.data=data
+    end
+    set(h,"visible",visible);
+    set(h,"line_mode" ,toggle(mget(1,'c',fd))) // line_mode
+    set(h,"line_style",mget(1,'c',fd)); // line_style
+    set(h,"thickness",mget(1,'sl',fd)) // thickness
+    set(h,"arrow_size",mget(1,'dl',fd)) // arrow_size
+    
+    n=mget(1,'il',fd) // segs_color
+    set(h,"segs_color",mget(n,'il',fd))
+    set(h,"mark_mode" ,toggle(mget(1,'c',fd))) // mark_mode
+    set(h,"mark_style"           , mget(1,'c',fd)) // mark_style
+    set(h,"mark_size"            , mget(1,'c',fd)) // mark_size
+    if is_higher_than([3 0 0 0]) then
+      if ascii(mget(1,'c',fd))=='t' then // mark_size_unit 
+       msu='tabulated'
+      else 
+       msu='point';
+      end
+      set(h,"mark_size_unit"     , msu) ;
+      set(h,"mark_foreground"    , mget(1,'il',fd)) ; // mark_foreground
+      set(h,"mark_background"    , mget(1,'il',fd)) ; // mark_background
+    else
+      set(h,"mark_size_unit"     , 'tabulated') ; // mark_size_unit
+    end
+    
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      set(h,"clip_box", mget(4,'dl',fd)) // clip_box
+    end
+    set(h,"clip_state",clip_state);
+    load_user_data(fd) // user_data
+    
+  case "Grayplot"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    if is_higher_than([3 0 0 0]) then
+      sz=mget(2,'il',fd); // data.x
+      x=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+      sz=mget(2,'il',fd); // data.y
+      y=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+      sz=mget(2,'il',fd); // data.z
+      z=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+    else
+      sz = mget(2,'il',fd) // data
+      data = matrix(mget(prod(sz),'dl',fd),sz(1),-1)
+    end
+    
+    data_mapping   = ascii(mget(mget(1,'c',fd),'c',fd)) // data_mapping
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) // clip_box
+    else
+      clip_box=[]
+    end
+    
+    // draw the grayplot
+    if is_higher_than([3 0 0 0]) then
+      grayplot(x,y,z)
+    else
+      grayplot(data(2:$,1),data(1,2:$),data(2:$,2:$))
+    end
+    
+    h=get('hdl')
+    set(h,"visible",visible)
+    set(h,"data_mapping",data_mapping)
+    if clip_state=='on' then
+      set(h,"clip_box",  clip_box)
+    end
+    set(h,"clip_state",clip_state);
+    
+    load_user_data(fd) // user_data
+    
+  case "Matplot"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    sz=mget(2,'il',fd); // data
+    data=matrix(mget(prod(sz),'dl',fd),sz(1),-1);
+//    data_mapping   = ascii(mget(mget(1,'c',fd),'c',fd))
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) // clip_box
+    else
+      clip_box=[]
+    end
+    
+    // draw the matplot
+    Matplot(data);
+
+    h=get('hdl')
+    set(h,"visible",visible)
+//    set(h,"data_mapping",data_mapping)
+    if clip_state=='on' then
+      set(h,"clip_box",  clip_box)
+    end
+    set(h,"clip_state",clip_state);
+    // user_data
+    load_user_data(fd)
+    
+  case "Fec"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    sz             = mget(2,'il',fd) // data
+    data           = matrix(mget(prod(sz),'dl',fd),sz(1),-1)
+    sz             = mget(2,'il',fd) // triangles
+    triangles      = matrix(mget(prod(sz),'dl',fd),sz(1),-1)
+    z_bounds       = mget(2,'dl',fd) // z_bounds
+    // draw the fec
+    fec(data(:,1),data(:,2),triangles,data(:,3))
+    h=unglue(get('hdl'))
+    set(h,"visible",visible)
+    set(h,"z_bounds",z_bounds)
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      set(h,"clip_box", mget(4,'dl',fd)) // clip_box
+    end
+    set(h,"clip_state",clip_state);
+    load_user_data(fd) // user_data
+    
+    // remove case because of bugs  
+  case "Legend"
+    visible        = toggle(mget(1,'c',fd)) // visible
+    line_mode       = toggle(mget(1,'c',fd)) // line_mode
+    mark_mode       = toggle(mget(1,'c',fd)) // mark_mode
+    mark_foreground = mget(1,'il',fd) ; // mark_foreground
+    mark_background = mget(1,'il',fd) ; // mark_background
+    //text=ascii(mget(mget(1,'c',fd),'c',fd)) // text
+    
+    text = load_text_vector(fd); // text
+    
+    //create the legend
+    //get the number of lines of the legend
+    lineFeedPosition = strindex(text,'@')
+    nbLines = size( lineFeedPosition ) ;
+    nbLines = nbLines(2) + 1
+    //create as many curves as lines in the text
+    nullVector = zeros(1,nbLines);
+    //draw the legend
+    plot2d(0,nullVector,leg=text) ;
+    H=unglue(get('hdl'));
+    h=H(1);
+    delete(H(2));
+  
+    set(h,"visible",visible)
+    set(h,"line_mode",line_mode);
+    set(h,"mark_mode",mark_mode);
+    set(h,"mark_foreground",mark_foreground) ;
+    set(h,"mark_background",mark_background) ;
+    set(h,"foreground", mget(1,'il',fd)); // foreground
+    
+    set(h,"font_style", mget(1,'c',fd)); // font_style
+    set(h,"font_size" , mget(1,'c',fd)); // font_size
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      set(h,"clip_box",mget(4,'dl',fd)); // clip_box
+    end
+    set(h,"clip_state",clip_state);
+    
+    
+  case "Text"
+    visible         = toggle(mget(1,'c',fd)) // visible
+    
+    if is_higher_than( [4 0 0 0] ) then
+      text            = load_text_matrix( fd ) ;
+    else
+      text            = load_text_vector(fd) // text
+    end
+    sz              = mget(2,'c',fd)
+    data            = matrix(mget(prod(sz),'dl',fd),sz(1),-1) // data
+    text_box        = mget(2,'dl',fd) // text_box
+    text_box_mode   = ascii(mget(mget(1,'c',fd),'c',fd)); // text_box_mode
+    
+    // draw the text
+    if text_box_mode == 'off' then
+      xstring(data(1),data(2),text)
+    else
+      xstringb(data(1),data(2),text,text_box(1),text_box(2))
+    end
+    
+    h=get('hdl');
+    set(h,"visible",visible) ;
+    set(h,"text_box_mode",text_box_mode)
+    set(h,"foreground"           , mget(1,'il',fd)); // foreground
+    set(h,"font_style"           , mget(1,'c',fd)); // font_style
+    
+    if text_box_mode == 'filled' then // font_size
+      mget(1,'c',fd) ;
+    else
+      set(h,"font_size", mget(1,'c',fd));
+    end
+    
+    set(h,"font_angle"           , mget(1,'dl',fd)); // font_angle
+    
+    //adding JB Silvy 28/11/05
+    // box drawing
+    if is_higher_than([3 1 0 1]) then
+      set( h, "box"      , toggle( mget( 1, 'c', fd ) ) ) ; // box
+      set( h, "line_mode", toggle( mget( 1, 'c', fd ) ) ) ; // line_mode
+      set( h, "fill_mode", toggle( mget( 1, 'c', fd ) ) ) ; // fill_mode
+      
+      set( h, "font_foreground", mget( 1, 'il', fd ) ) ; // font_foreground
+      set( h, "background"     , mget( 1, 'il', fd ) ) ; // background
+    end
+    
+    if is_higher_than( [4 0 0 0] ) then
+      set( h, "alignment", ascii(mget(mget(1,'c',fd),'c',fd)  ) ) ; // alignment
+    end
+    
+    clip_state     = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+    if clip_state=='on' then
+      clip_box     = mget(4,'dl',fd) // clip_box
+      set(h,"clip_box",clip_box) ; // clip_box
+    else
+      clip_box=[]
+    end
+    set(h,"clip_state",clip_state); 
+    load_user_data(fd) // user_data
+    
+  case 'Axis'
+    if is_higher_than([3 1 0 0]) then
+     
+      visible          = toggle(mget(1,'c',fd)) // visible
+      n                = mget(1,'il',fd) // tics_direction
+      tics_direction   = ascii(mget(n,'c',fd));
+      nx               = mget(1,'il',fd) // xtics_coord
+      xtics_coord      = mget(nx,'dl',fd)
+      ny               = mget(1,'il',fd) // ytics_coord
+      ytics_coord      = mget(ny,'dl',fd)
+      if nx>1 then dir='u',else dir='l',end
+      drawaxis(x=xtics_coord,y=ytics_coord,dir=dir);
+      h=gce()
+
+      h.tics_color       = mget(1,'il',fd) // tics_color
+      h.tics_segment     = toggle(mget(1,'c',fd)) // tics_segment
+      h.tics_style       = ascii(mget(1,'c',fd)) // tics_style
+      h.sub_tics         = mget(1,'il',fd) // sub_tics
+      h.tics_labels     = load_text_vector(fd) // tics_label
+      h.labels_font_size = mget(1,'il',fd); // label_font_size
+      h.labels_font_color= mget(1,'il',fd); // labels_font_color
+      // h.tics_style=tics_style // jb Silvy apparently strange
+
+      clip_state       = ascii(mget(mget(1,'c',fd),'c',fd)) // clip_state
+      if clip_state == 'on' then
+       set(h,"clip_box",clip_box)
+      end
+      set(h,"clip_state",clip_state);
+      load_user_data(fd) // user_data
+    end
+  else
+      warning("type " +typ+" unhandled");
+  end
+
+endfunction
+
+function r=toggle(k)
+//Author S. Steer Sept 2004, Copyright INRIA
+  r=emptystr(k)+'on'
+  r(k==0)='off'
+endfunction
+
+function load_user_data(fd)
+  if is_higher_than([3 1 0 0]) then
+    load(fd,'user_data')
+    if user_data<>[] then 
+      h.user_data=user_data;
+    end
+  end
+endfunction
+
+function r=is_higher_than(v)
+//check if current version is strictly higher than the given one
+  r=%f
+  for k=1:4
+    if version(k)>v(k) then r=%t,break,end
+    if version(k)<v(k) then r=%f,break,end
+  end
+endfunction
+
+function text=load_text_vector(fd)
+  T=mget(mget(1,'il',fd),'c',fd)
+  newline=[find(T==10) size(T,'*')+1]
+  text=[]
+  p=1
+  for k=1:size(newline,'*')
+    text=[text;ascii(T(p:newline(k)-1))]
+    p=newline(k)+1
+  end
+endfunction
+
+// retrieve a string matrix saved by save_text_matrix
+function strMat = load_text_matrix( fd )
+  nbRow = mget( 1, 'il', fd ) ;
+  nbCol = mget( 1, 'il', fd ) ;
+  for i = 1:nbRow
+    for j = 1:nbCol
+      strMat(i,j) = ascii(mget(mget(1,'c',fd),'c',fd)) ;
+    end
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_matrix.sci b/scilab/modules/graphics/macros/%h_matrix.sci
new file mode 100644 (file)
index 0000000..ab4eba2
--- /dev/null
@@ -0,0 +1,3 @@
+function y=%h_matrix(a,varargin)
+  y=%hm_matrix(a,varargin(:))
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_p.sci b/scilab/modules/graphics/macros/%h_p.sci
new file mode 100644 (file)
index 0000000..4f08eb0
--- /dev/null
@@ -0,0 +1,720 @@
+function %h_p(h)
+  if size(h,'*')>1 then
+    T=matrix(h.type,size(h))
+    t=''
+    for k=1:size(h,2)
+      t=t+part(T(:,k),1:max(length(T(:,k)))+1)
+    end
+    t1=string(size(h,1))+' by '+string(size(h,2))+' matrix of handles:'
+    t1=[t1;part('=',ones(1,length(t1)))]
+    t=[t1;t]
+  else
+    t='Handle of type ""'+h.type+'"" with properties:'
+    t=[t;part('=',ones(1,length(t)))]
+    select h.type
+    case "Polyline"
+      if size(h.data,'*') > 10 then 
+       d="matrix "+strcat(string(size(h.data)),'x')
+     else
+       d=sci2exp(h.data,0)
+       if length(d)>70 then d="matrix "+strcat(string(size(h.data)),'x'),end
+     end
+     
+     if size(h.x_shift,'*') > 10 then 
+       bxs="matrix "+strcat(string(size(h.x_shift)),'x')
+     else
+       bxs=sci2exp(h.x_shift,0)
+       if length(bxs)>70 then bxs="matrix "+strcat(string(size(h.x_shift)),'x'),end
+     end
+        
+     if size(h.y_shift,'*') > 10 then 
+       bys="matrix "+strcat(string(size(h.y_shift)),'x')
+     else
+       bys=sci2exp(h.y_shift,0)
+       if length(bys)>70 then bys="matrix "+strcat(string(size(h.y_shift)),'x'),end
+     end
+     
+     if size(h.z_shift,'*') > 10 then 
+       bzs="matrix "+strcat(string(size(h.z_shift)),'x')
+     else
+       bzs=sci2exp(h.z_shift,0)
+       if length(bzs)>70 then bzs="matrix "+strcat(string(size(h.z_shift)),'x'),end
+     end
+           
+     u=h.user_data;
+     t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible)
+        "data = "+d
+        "closed = "+sci2exp(h.closed)
+         "line_mode = "+sci2exp(h.line_mode)
+        "fill_mode = "+sci2exp(h.fill_mode)
+        "line_style = "+string(h.line_style)
+        "thickness = "+string(h.thickness)
+        "arrow_size_factor = "+string(h.arrow_size_factor)
+        "polyline_style = "+string(h.polyline_style)
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "interp_color_vector = "+sci2exp(h.interp_color_vector)
+        "interp_color_mode = "+sci2exp(h.interp_color_mode)
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_style = "+sci2exp(h.mark_style)
+        "mark_size_unit = "+sci2exp(h.mark_size_unit)
+        "mark_size = "+string(h.mark_size)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+        "x_shift = "+bxs
+        "y_shift = "+bys
+        "z_shift = "+bzs
+        "bar_width = "+sci2exp(h.bar_width)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box)
+        "user_data = "+fmtuser_data(u)]
+   case "Compound"
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible)
+        "user_data = "+fmtuser_data(u)]
+    case "Axes"
+
+      T=h.x_ticks
+      if size(T.locations,'*')>9 then
+       locx="matrix "+strcat(string(size(T.locations)),'x')
+       labx="matrix "+strcat(string(size(T.labels)),'x')
+      else
+       locx=sci2exp(T.locations,0)
+       labx=sci2exp(T.labels,0)
+       if length(locx)>70 then locx="matrix "+strcat(string(size(T.locations)),'x'), end
+       if length(labx)>70 then labx="matrix "+strcat(string(size(T.labels)),'x'), end
+      end
+     
+      T=h.y_ticks
+      if size(T.locations,'*')>9 then
+       locy="matrix "+strcat(string(size(T.locations)),'x')
+       laby="matrix "+strcat(string(size(T.labels)),'x')
+      else
+       locy=sci2exp(T.locations,0)
+       laby=sci2exp(T.labels,0)
+       if length(locy)>70 then locx="matrix "+strcat(string(size(T.locations)),'x'), end
+       if length(laby)>70 then labx="matrix "+strcat(string(size(T.labels)),'x'), end
+      end
+      
+      T=h.z_ticks
+      if size(T.locations,'*')>9 then
+       locz="matrix "+strcat(string(size(T.locations)),'x')
+       labz="matrix "+strcat(string(size(T.labels)),'x')
+      else
+       locz=sci2exp(T.locations,0)
+       labz=sci2exp(T.labels,0)
+       if length(locz)>70 then locx="matrix "+strcat(string(size(T.locations)),'x'), end
+       if length(labz)>70 then labx="matrix "+strcat(string(size(T.labels)),'x'), end
+      end
+      
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        " "
+        "visible = "+sci2exp(h.visible)
+        "axes_visible = "+sci2exp(h.axes_visible)
+        "axes_reverse = "+sci2exp(h.axes_reverse)
+        "grid = "+sci2exp(h.grid,0)
+        "x_location = "+sci2exp(h.x_location)
+        "y_location = "+sci2exp(h.y_location)
+        "title: "+fmtchildren(h.title)
+        "x_label: "+fmtchildren(h.x_label)
+        "y_label: "+fmtchildren(h.y_label)
+        "z_label: "+fmtchildren(h.z_label)
+        "auto_ticks = "+sci2exp(h.auto_ticks)
+        "x_ticks.locations = "+locx
+        "y_ticks.locations = "+locy
+        "z_ticks.locations = "+locz
+        "x_ticks.labels = "+labx
+        "y_ticks.labels = "+laby
+        "z_ticks.labels = "+labz
+        "box = "+sci2exp(h.box)
+        "sub_ticks = "+sci2exp(h.sub_ticks,0)
+         "font_style = "+string(h.font_style)
+        "font_size = "+string(h.font_size)
+        "font_color = "+string(h.font_color)
+        " "
+        "isoview = "+sci2exp(h.isoview)
+        "cube_scaling = "+sci2exp(h.cube_scaling)
+        "view = "+sci2exp(h.view)
+        "rotation_angles = "+sci2exp(h.rotation_angles,0)
+        "log_flags = "+sci2exp(h.log_flags)
+        "tight_limits = "+sci2exp(h.tight_limits)
+        "data_bounds = "+sci2exp(h.data_bounds,0)
+        "zoom_box = "+sci2exp(h.zoom_box,0)
+        "margins = "+sci2exp(h.margins,0)
+        "axes_bounds = "+sci2exp(h.axes_bounds,0)
+        " "
+        "auto_clear = "+sci2exp(h.auto_clear)
+        "auto_scale = "+sci2exp(h.auto_scale)
+        " "
+         "hidden_axis_color = " + string(h.hidden_axis_color);
+        "hiddencolor = "+string(h.hiddencolor)
+         "line_mode = "+sci2exp(h.line_mode)
+        "line_style = "+string(h.line_style)
+        "thickness = "+string(h.thickness)
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_style = "+sci2exp(h.mark_style,0)
+        "mark_size_unit = "+sci2exp(h.mark_size_unit)
+        "mark_size = "+sci2exp(h.mark_size,0)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)
+       ]
+
+    case "Legend"
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "line_mode = "+sci2exp(h.line_mode)
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+        "foreground = "+string(h.foreground)
+        "visible = "+sci2exp(h.visible)
+        "text = "+sci2exp(h.text)
+        "font_style = "+string(h.font_style)
+        "font_size = "+string(h.font_size)]
+    case "Rectangle"
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_style = "+string(h.mark_style)
+        "mark_size_unit = "+sci2exp(h.mark_size_unit)
+        "mark_size = "+string(h.mark_size)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+         "line_mode = "+sci2exp(h.line_mode)
+        "fill_mode = "+sci2exp(h.fill_mode)
+        "line_style = "+string(h.line_style)
+        "thickness = "+string(h.thickness)
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "data = "+sci2exp(h.data,0)
+        "visible = "+sci2exp(h.visible)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)]
+    case "Arc"
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "thickness = "+string(h.thickness)
+        "line_style = "+string(h.line_style)
+         "line_mode = "+sci2exp(h.line_mode)
+        "fill_mode = "+sci2exp(h.fill_mode)
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "data = "+sci2exp(h.data,0)
+        "visible = "+sci2exp(h.visible)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)]
+    case "Figure"
+      u=h.user_data
+      t=[t;
+        "children: "+fmtchildren(h.children)
+        
+        "figure_style = "+sci2exp(h.figure_style,0)
+        "figure_position = "+sci2exp(h.figure_position,0)
+        "figure_size = "+sci2exp(h.figure_size,0)
+        "axes_size = "+sci2exp(h.axes_size,0)
+        "auto_resize = "+sci2exp(h.auto_resize)
+        "figure_name = "+sci2exp(h.figure_name,0)
+        "figure_id = "+sci2exp(h.figure_id,0)
+         "color_map= matrix "+strcat(string(size(h.color_map)),'x')
+        "pixmap = "+sci2exp(h.pixmap)
+        "pixel_drawing_mode = "+sci2exp(h.pixel_drawing_mode,0)
+        "immediate_drawing = "+sci2exp(h.immediate_drawing)
+        "background =  "+string(h.background)
+        "visible = "+sci2exp(h.visible)
+        "rotation_style = "+sci2exp(h.rotation_style)
+        "user_data = "+fmtuser_data(u)
+       ]
+    case "Grayplot"
+      Data = h.data
+      if size(Data.x,'*') > 10 then 
+       dx="matrix "+strcat(string(size(Data.x)),'x')
+      else
+       dx=sci2exp(Data.x,0)
+       if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),'x'),end
+      end
+       
+      if size(Data.y,'*') > 10 then 
+       dy="matrix "+strcat(string(size(Data.y)),'x')
+      else
+       dy=sci2exp(Data.y,0)
+       if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),'x'),end
+      end
+      if size(Data.z,'*') > 10 then 
+       dz="matrix "+strcat(string(size(Data.z)),'x')
+      else
+       dz=sci2exp(Data.z,0)
+       if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),'x'),end
+      end
+      
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "data.x = "+dx
+        "data.y = "+dy
+        "data.z = "+dz
+        "data_mapping = "+sci2exp(h.data_mapping)
+        "user_data = "+fmtuser_data(u)
+       ]
+    case "Matplot"
+      if size(h.data,'*') > 10 then 
+       d="matrix "+strcat(string(size(h.data)),'x')
+      else     
+       d=sci2exp(h.data,0)
+       if length(d)>70 then d="matrix "+strcat(string(size(h.data)),'x'),end
+      end
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible)
+        "data = "+d
+        "user_data = "+fmtuser_data(u)]
+    case "Fec"
+      u=h.user_data
+      if size(h.data,'*') > 10 then 
+       d="matrix "+strcat(string(size(h.data)),'x')
+      else     
+       d=sci2exp(h.data,0)
+       if length(d)>70 then d="matrix "+strcat(string(size(h.data)),'x'),end
+      end
+
+      if size(h.triangles,'*') > 10 then 
+       f="matrix "+strcat(string(size(h.triangles)),'x')
+      else     
+       f=sci2exp(h.triangles,0)
+       if length(f)>70 then f="matrix "+strcat(string(size(h.triangles)),'x'),end
+      end
+      
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "data = "+d
+        "triangles = "+f
+        "z_bounds = "+sci2exp(h.z_bounds,0)
+        "user_data = "+fmtuser_data(u)
+       ]
+      
+    case "Segs"
+      if size(h.data,'*') > 10 then 
+       d="matrix "+strcat(string(size(h.data)),'x')
+      else
+       d=sci2exp(h.data,0)
+       if length(d)>70 then d="matrix "+strcat(string(size(h.data)),'x'),end
+      end     
+      
+     if size(h.segs_color,'*') > 10 then 
+       c="matrix "+strcat(string(size(h.segs_color)),'x')
+      else
+       c=sci2exp(h.segs_color,0)
+       if length(c)>70 then c="matrix "+strcat(string(size(h.segs_color)),'x'),end
+      end     
+
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "data = "+d
+        "line_mode = "+sci2exp(h.line_mode)
+        "line_style = "+string(h.line_style)
+        "thickness = "+string(h.thickness)
+        "arrow_size = "+string(h.arrow_size)
+        "segs_color = "+c
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_style = "+sci2exp(h.mark_style)
+        "mark_size_unit = "+sci2exp(h.mark_size_unit)
+        "mark_size = "+string(h.mark_size)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)]
+    case "Champ"
+      Data = h.data
+      if size(Data.x,'*') > 10 then 
+       dx="matrix "+strcat(string(size(Data.x)),'x')
+      else
+       dx=sci2exp(Data.x,0)
+       if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),'x'),end
+      end
+       
+      if size(Data.y,'*') > 10 then 
+       dy="matrix "+strcat(string(size(Data.y)),'x')
+      else
+       dy=sci2exp(Data.y,0)
+       if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),'x'),end
+      end
+
+      if size(Data.fx,'*') > 10 then 
+       dfx="matrix "+strcat(string(size(Data.fx)),'x')
+      else
+       dfx=sci2exp(Data.fx,0)
+       if length(dfx)>70 then d="matrix "+strcat(string(size(Data.fx)),'x'),end
+      end
+
+      if size(Data.fy,'*') > 10 then 
+       dfy="matrix "+strcat(string(size(Data.fy)),'x')
+      else
+       dfy=sci2exp(Data.fy,0)
+       if length(dfy)>70 then d="matrix "+strcat(string(size(Data.fy)),'x'),end
+      end
+      u=h.user_data
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "data.x = "+dx
+        "data.y = "+dy
+        "data.fx = "+dfx
+        "data.fy = "+dfy
+        "line_style = "+string(h.line_style)
+        "thickness = "+string(h.thickness)
+        "colored = "+sci2exp(h.colored)
+        "arrow_size = "+string(h.arrow_size)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)]
+    case "Text"
+      u=h.user_data
+      T=sci2exp(h.text,0)
+      if length(T)>70 then T="string array "+strcat(string(size(h.text)),'x'),end
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "text = "+T
+        "alignment = "+sci2exp(h.alignment) ;
+        "data = "+sci2exp(h.data,0)
+        "box = "+sci2exp(h.box) 
+        "line_mode = " + sci2exp(h.line_mode);
+        "fill_mode = " + sci2exp(h.fill_mode);
+        "text_box = "+sci2exp(h.text_box,0)
+        "text_box_mode = "+sci2exp(h.text_box_mode,0)
+        "font_foreground = "+string(h.font_foreground)
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "font_style = "+string(h.font_style)
+        "font_size = "+string(h.font_size)
+        "font_angle = "+string(h.font_angle)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)]
+    case "Title"
+      T=sci2exp(h.text,0)
+      if length(T)>70 then T="string array "+strcat(string(size(h.text)),'x'),end
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+        "text = "+T
+        "foreground = "+string(h.foreground)
+        "font_style = "+string(h.font_style)
+        "font_size = "+string(h.font_size)
+        "font_angle = "+string(h.font_angle)]
+    case "Label"
+      T=sci2exp(h.text,0)
+      if length(T)>70 then T="string array "+strcat(string(size(h.text)),'x'),end
+      t=[t;
+        "parent: "+h.parent.type
+        "visible = "+sci2exp(h.visible) 
+        "text = "+T;
+        "font_foreground = " + string(h.font_foreground) ;
+        "foreground = "+string(h.foreground)
+        "background = "+string(h.background)
+        "fill_mode = "+sci2exp(h.fill_mode)
+        "font_style = "+string(h.font_style)
+        "font_size = "+string(h.font_size)
+        "font_angle = "+string(h.font_angle)
+        "auto_position = "+sci2exp(h.auto_position)
+        "position = "+sci2exp(h.position,0)
+        "auto_rotation = "+sci2exp(h.auto_rotation)]
+    case "Plot3d"
+      Data = h.data
+      if size(Data.x,'*') > 10 then 
+       dx="matrix "+strcat(string(size(Data.x)),'x')
+      else
+       dx=sci2exp(Data.x,0)
+       if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),'x'),end
+      end
+       
+      if size(Data.y,'*') > 10 then 
+       dy="matrix "+strcat(string(size(Data.y)),'x')
+      else
+       dy=sci2exp(Data.y,0)
+       if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),'x'),end
+      end
+      if size(Data.z,'*') > 10 then 
+       dz="matrix "+strcat(string(size(Data.z)),'x')
+      else
+       dz=sci2exp(Data.z,0)
+       if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),'x'),end
+      end
+
+      u=h.user_data
+
+      if size(Data) == 5 then // There is a color
+       if size(Data.color,'*') > 10 then 
+        dcolor="matrix "+strcat(string(size(Data.color)),'x')
+        else
+        dcolor=sci2exp(Data.color,0)
+        if length(dcolor)>70 then dcolor="matrix "+strcat(string(size(Data.color)),'x'),end
+        end
+       
+       t=[t;
+          "parent: "+h.parent.type
+          "children: "+fmtchildren(h.children)
+          "visible = "+sci2exp(h.visible) 
+          "surface_mode = "+sci2exp(h.surface_mode)
+          "foreground = "+string(h.foreground)
+          "thickness = "+string(h.thickness)
+          "mark_mode = "+sci2exp(h.mark_mode)
+          "mark_style = "+sci2exp(h.mark_style)
+          "mark_size_unit = "+sci2exp(h.mark_size_unit)
+          "mark_size = "+string(h.mark_size)
+          "mark_foreground = "+string(h.mark_foreground)
+          "mark_background = "+string(h.mark_background)
+          "data.x = "+dx
+          "data.y = "+dy
+          "data.z "+dz  
+          "data.color (not used) = "+dcolor
+          "color_mode = "+string(h.color_mode)
+          "color_flag = "+sci2exp(h.color_flag,0)
+          "hiddencolor = "+string(h.hiddencolor)
+          "user_data = "+fmtuser_data(u)
+         ]
+      else
+       t=[t;
+          "parent: "+h.parent.type
+          "children: "+fmtchildren(h.children)
+          "visible = "+sci2exp(h.visible) 
+          "surface_mode = "+sci2exp(h.surface_mode)
+          "foreground = "+string(h.foreground)
+          "thickness = "+string(h.thickness)
+          "mark_mode = "+sci2exp(h.mark_mode)
+          "mark_style = "+sci2exp(h.mark_style)
+          "mark_size_unit = "+sci2exp(h.mark_size_unit)
+          "mark_size = "+string(h.mark_size)
+          "mark_foreground = "+string(h.mark_foreground)
+          "mark_background = "+string(h.mark_background)
+          "data.x = "+dx
+          "data.y = "+dy
+          "data.z = "+dz
+          "color_mode = "+string(h.color_mode)
+          "color_flag = "+sci2exp(h.color_flag,0)
+          "hiddencolor = "+string(h.hiddencolor)
+          "user_data = "+fmtuser_data(u)
+         ]
+      end
+
+    case "Fac3d" 
+      Data = h.data
+      if size(Data.x,'*') > 10 then 
+       dx="matrix "+strcat(string(size(Data.x)),'x')
+      else
+       dx=sci2exp(Data.x,0)
+       if length(dx)>70 then d="matrix "+strcat(string(size(Data.x)),'x'),end
+      end
+       
+      if size(Data.y,'*') > 10 then 
+       dy="matrix "+strcat(string(size(Data.y)),'x')
+      else
+       dy=sci2exp(Data.y,0)
+       if length(dy)>70 then d="matrix "+strcat(string(size(Data.y)),'x'),end
+      end
+      if size(Data.z,'*') > 10 then 
+       dz="matrix "+strcat(string(size(Data.z)),'x')
+      else
+       dz=sci2exp(Data.z,0)
+       if length(dz)>70 then d="matrix "+strcat(string(size(Data.z)),'x'),end
+      end
+
+      u=h.user_data;
+      if size(Data) == 5 then // There is a color
+       if size(Data.color,'*') > 10 then 
+        dcolor="matrix "+strcat(string(size(Data.color)),'x')
+        else
+        dcolor=sci2exp(Data.color,0)
+        if length(dcolor)>70 then dcolor="matrix "+strcat(string(size(Data.color)),'x'),end
+        end
+
+       t=[t;
+          "parent: "+h.parent.type
+          "children: "+fmtchildren(h.children)
+          "visible = "+sci2exp(h.visible) 
+          "surface_mode = "+sci2exp(h.surface_mode)
+          "foreground = "+string(h.foreground)
+          "thickness = "+string(h.thickness)
+          "mark_mode = "+sci2exp(h.mark_mode)
+          "mark_style = "+sci2exp(h.mark_style)
+          "mark_size_unit = "+sci2exp(h.mark_size_unit)
+          "mark_size = "+string(h.mark_size)
+          "mark_foreground = "+string(h.mark_foreground)
+          "mark_background = "+string(h.mark_background)
+          "data.x = "+dx
+          "data.y = "+dy
+          "data.z = "+dz  
+          "data.color = "+dcolor
+          "color_mode = "+string(h.color_mode)
+          "color_flag = "+sci2exp(h.color_flag,0)
+          "cdata_mapping = "+sci2exp(h.cdata_mapping)
+          "hiddencolor = "+string(h.hiddencolor)
+          "user_data = "+fmtuser_data(u)
+         ]
+      else
+       t=[t;
+          "parent: "+h.parent.type
+          "children: "+fmtchildren(h.children)
+          "visible = "+sci2exp(h.visible) 
+          "surface_mode = "+sci2exp(h.surface_mode)
+          "foreground = "+string(h.foreground)
+          "thickness = "+string(h.thickness)
+          "mark_mode = "+sci2exp(h.mark_mode)
+          "mark_style = "+sci2exp(h.mark_style)
+          "mark_size_unit = "+sci2exp(h.mark_size_unit)
+          "mark_size = "+string(h.mark_size)
+          "mark_foreground = "+string(h.mark_foreground)
+          "mark_background = "+string(h.mark_background)
+          "data.x = "+dx
+          "data.y = "+dy
+          "data.z = "+dz
+          "color_mode = "+string(h.color_mode)
+          "color_flag = "+sci2exp(h.color_flag,0)
+          "hiddencolor = "+string(h.hiddencolor)
+          "user_data = "+fmtuser_data(u)
+         ]
+      end
+      
+    case "Param3d" 
+      u=h.user_data;
+      if size(h.data,'*') > 10 then 
+       d="matrix "+strcat(string(size(h.data)),'x')
+      else
+       d=sci2exp(h.data,0)
+       if length(d)>70 then d="matrix "+strcat(string(size(h.data)),'x'),end
+      end
+      
+      if size(h.surface_color,'*') > 10 then 
+       c="matrix "+strcat(string(size(h.surface_color)),'x')
+      else
+       c=sci2exp(h.surface_color,0)
+       if length(c)>70 then c="matrix "+strcat(string(size(h.surface_color)),'x'),end
+      end
+  
+      t=[t;
+        "parent: "+h.parent.type
+        "children: "+fmtchildren(h.children)
+        "visible = "+sci2exp(h.visible) 
+         "line_mode = "+sci2exp(h.line_mode)
+        "foreground = "+string(h.foreground)
+        "thickness = "+string(h.thickness)
+        "mark_mode = "+sci2exp(h.mark_mode)
+        "mark_style = "+sci2exp(h.mark_style)
+        "mark_size_unit = "+sci2exp(h.mark_size_unit)
+        "mark_size = "+string(h.mark_size)
+        "mark_foreground = "+string(h.mark_foreground)
+        "mark_background = "+string(h.mark_background)
+        "data = "+d
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "color_mode = "+string(h.color_mode)
+        "surface_color = "+c
+        "user_data = "+fmtuser_data(u)
+       ]
+    case "Axis"
+      u=h.user_data;
+      T=sci2exp(h.tics_labels,0)
+      if length(T)>70 then T="string array 1x"+string(length(T)),end
+      t=[t;
+        "parent: "+h.parent.type
+        "visible = "+sci2exp(h.visible)
+        "tics_direction = "+sci2exp(h.tics_direction)
+        "xtics_coord = "+sci2exp(h.xtics_coord,0)
+        "ytics_coord = "+sci2exp(h.ytics_coord,0)
+        "tics_color = "+string(h.tics_color)
+        "tics_segment = "+sci2exp(h.tics_segment)
+        "tics_style = "+sci2exp(h.tics_style)
+        "sub_tics = "+string(h.sub_tics)
+        "tics_labels = "+T
+        "labels_font_size = "+string(h.labels_font_size)
+        "labels_font_color = "+string(h.labels_font_color)
+        "clip_state = "+sci2exp(h.clip_state)
+        "clip_box = "+sci2exp(h.clip_box,0)
+        "user_data = "+fmtuser_data(u)
+       ]
+  case "Uimenu"
+  t=[t;
+  "parent: "+h.parent.type
+  "children: "+fmtchildren(h.children)
+  "visible = "+sci2exp(h.visible)
+  "text = "+h.text 
+  "callback = "+h.callback
+  "callback type = "+h.callback_type
+  "handle_visible = "+sci2exp(h.handle_visible)
+  "position = "+sci2exp(h.position,0)
+  "menu_enable = "+sci2exp(h.menu_enable)
+    ]
+    end
+  end
+  write(%io(2),t)
+endfunction
+function t=fmtchildren(c)
+  if c==[] then 
+    t='[]'
+  else
+    if size(c,'*')<10 then
+      t=sci2exp(c.type,0)
+      if length(t)>70 then t="matrix "+strcat(string(size(c)),'x'),end 
+    else
+      t="matrix "+strcat(string(size(c)),'x')   
+    end
+  end
+endfunction
+function t=fmtuser_data(d)
+  td= type(d)
+  if or(td==[1 2 3 4 8 10 15]) then
+    t=sci2exp(d,0)
+    if length(t)>70 then t=typeof(d)+" "+strcat(string(size(d)),'x'),end 
+  elseif or(td==16) then
+    t=typeof(d)+" "+strcat(string(size(d)),'x'),
+  elseif or(td==17) then
+    if typeof(d)=="ce" then
+      t="cell "+strcat(string(size(d)),'x'),
+    elseif typeof(d)=="st" then
+      T=getfield(1,d)
+      t="struct with fields: "+strcat(d(2:$),' '),
+    else
+      t=typeof(d)
+    end
+  else
+    t=typeof(d)
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_save.sci b/scilab/modules/graphics/macros/%h_save.sci
new file mode 100644 (file)
index 0000000..09bfa11
--- /dev/null
@@ -0,0 +1,560 @@
+function %h_save(h,fd)
+  //Author S. Steer Sept 2004, Copyright INRIA
+  version=[4 0 0 1]
+  mput(version,'c',fd)
+  
+  hsize = size(h);
+  mput(hsize,'c',fd); 
+  // introduced in version 3 1 0 2 to handle 
+  // the case where we have a matrix of handles to save
+  
+  if or(hsize>1)
+    for i=1:hsize(1)
+      for j=1:hsize(2)
+       save_graphichandle(h(i,j),fd)
+      end
+    end
+  else
+    save_graphichandle(h,fd)
+  end
+endfunction
+
+function save_graphichandle(h,fd)
+//Author S. Steer Sept 2004, Copyright INRIA
+  typ=h.type
+  select h.type
+    
+  case "Figure"   
+    mput( length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    // handle => new style
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(h.figure_position,'sl',fd) // figure_position
+    mput(h.figure_size,'sl',fd) // figure size
+    mput(h.axes_size,'sl',fd) // axes_size
+    mput(bool2s(h.auto_resize=='on'),'c',fd) // auto_resize
+    mput(length(h.figure_name),'c',fd); // figure_name
+    mput(ascii(h.figure_name),'c',fd);
+    mput(h.figure_id,'sl',fd); // figure_id
+    
+    mput(size(h.color_map,'*'),'il',fd); // color_map
+    mput(h.color_map,'dl',fd) ;
+    mput(bool2s(h.pixmap=='on'),'c',fd) ; // pix_map
+    mput(length(h.pixel_drawing_mode),'c',fd); // pixel_drawing_mode
+    mput(ascii(h.pixel_drawing_mode),'c',fd);
+    mput(bool2s(h.immediate_drawing=='on'),'c',fd) // immediate_drawing
+    mput(h.background,'il',fd) // background
+    mput(length(h.rotation_style),'c',fd); // rotation style
+    mput(ascii(h.rotation_style),'c',fd);
+    
+    // children
+    c=h.children;
+    n=size(c,'*')
+    mput(n,'il',fd)
+    for k=n:-1:1
+      save_graphichandle(c(k),fd)
+    end
+    
+    user_data=h.user_data; // user_data
+    save(fd,user_data) ;
+    
+    
+  case "Axes" 
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(size(h.axes_visible,'*'),'c',fd); // axes_visible
+    mput(bool2s(h.axes_visible=='on'),'c',fd) ;
+    mput(size(h.axes_reverse,'*'),'c',fd); // axes_reverse
+    mput(bool2s(h.axes_reverse=='on'),'c',fd) ;
+    mput(size(h.grid,'*'),'c',fd); mput(h.grid,'il',fd); // grid
+    mput(length(h.x_location),'c',fd); // x_location
+    mput(ascii(h.x_location),'c',fd);
+    mput(length(h.y_location),'c',fd); // y_location
+    mput(ascii(h.y_location),'c',fd);
+    mput(ascii(h.view),'c',fd) ; // view
+    
+    // title
+    l=h.title;
+    mput(bool2s(l.visible=='on'),'c',fd) ; // title.visible
+    save_text_matrix( l.text, fd ) ;
+    mput(l.font_foreground,'il',fd); // title_label.font_foreground
+    mput(l.foreground,'il',fd) // title.foreground
+    mput(l.background,'il',fd) // title.background
+    mput(bool2s(l.fill_mode=='on'),'c',fd) // title.fill_mode
+    mput(l.font_style,'c',fd) ; // title.font_style
+    mput(l.font_size,'c',fd)  ; // title.font_size
+      
+    mput(bool2s(l.auto_rotation=='on'),'c',fd) // title.auto_rotation
+    mput(l.font_angle,'dl',fd) // title.font_angle
+    mput(bool2s(l.auto_position=='on'),'c',fd) // title.auto_position
+    mput(l.position,'dl',fd) // title.position
+    
+    // x_label
+    l=h.x_label
+    mput(bool2s(l.visible=='on'),'c',fd) // x_label.visible
+    save_text_matrix( l.text, fd ) ;
+    mput(l.font_foreground,'il',fd); // x_label.font_foreground
+    mput(l.foreground,'il',fd) // x_label.foreground
+    mput(l.background,'il',fd) // x_label.background
+    mput(bool2s(l.fill_mode=='on'),'c',fd) // x_label.fill_mode
+    mput(l.font_style,'c',fd) // x_label.font_style
+    mput(l.font_size,'c',fd)  // x_label.font_size
+  
+    mput(bool2s(l.auto_rotation=='on'),'c',fd) // x_label.auto_rotation
+    mput(l.font_angle,'dl',fd) // x_label.font_angle
+    mput(bool2s(l.auto_position=='on'),'c',fd) // x_label.auto_position
+    mput(l.position,'dl',fd) // x_label.position
+  
+    // y_label
+    l=h.y_label
+    mput(bool2s(l.visible=='on'),'c',fd) // y_label.visible
+    save_text_matrix( l.text, fd ) ;
+    mput(l.font_foreground,'il',fd); // y_label.font_foreground
+    mput(l.foreground,'il',fd) // y_label.foreground
+    mput(l.background,'il',fd) // y_label.background
+    mput(bool2s(l.fill_mode=='on'),'c',fd) // y_label.fill_mode
+    mput(l.font_style,'c',fd) // y_label.font_style
+    mput(l.font_size,'c',fd) // y_label.font_size
+    
+    mput(bool2s(l.auto_rotation=='on'),'c',fd) // y_label.auto_rotation
+    mput(l.font_angle,'dl',fd) // y_label.font_angle
+    mput(bool2s(l.auto_position=='on'),'c',fd) // y_label.auto_position
+    mput(l.position,'dl',fd) // y_label.position
+    
+    if h.view=='3d' then
+      // z_label
+      l=h.z_label
+      mput(bool2s(l.visible=='on'),'c',fd) // z_label.visible
+      save_text_matrix( l.text, fd ) ;
+      mput(l.font_foreground,'il',fd); // z_label.font_foreground
+      mput(l.foreground,'il',fd) // z_label.foreground
+      mput(l.background,'il',fd) // z_label.background
+      mput(bool2s(l.fill_mode=='on'),'c',fd) // z_label.fill_mode
+      mput(l.font_style,'c',fd) // z_label.font_style
+      mput(l.font_size,'c',fd) // z_label.font_size
+      mput(bool2s(l.auto_rotation=='on'),'c',fd) // z_label.auto_rotation
+      mput(l.font_angle,'dl',fd) // z_label.font_angle
+      mput(bool2s(l.auto_position=='on'),'c',fd) // z_label.auto_position
+      mput(l.position,'dl',fd) // z_label.position
+    end
+    
+    mput(size(h.auto_ticks,'*'),'c',fd); // auto_ticks
+    mput(bool2s(h.auto_ticks=='on'),'c',fd)
+    
+    mput(size(h.x_ticks.locations,'*'),'sl',fd); // x_ticks.locations
+    mput(h.x_ticks.locations,'dl',fd)
+    mput(length(h.x_ticks.labels),'c',fd); // x_ticks.labels
+    mput(ascii(strcat(h.x_ticks.labels)),'c',fd);
+  
+    mput(size(h.y_ticks.locations,'*'),'sl',fd); // y_ticks.locations
+    mput(h.y_ticks.locations,'dl',fd)
+    mput(length(h.y_ticks.labels),'c',fd); // y_ticks.labels
+    mput(ascii(strcat(h.y_ticks.labels)),'c',fd);
+
+    mput(size(h.z_ticks.locations,'*'),'sl',fd); // z_ticks.locations
+    mput(h.z_ticks.locations,'dl',fd)
+    mput(length(h.z_ticks.labels),'c',fd); // z_ticks.labels
+    mput(ascii(strcat(h.z_ticks.labels)),'c',fd);
+    
+    mput(length(h.box), 'c', fd ) ; // box
+    mput(ascii(h.box),  'c', fd ) ;
+    mput(size(h.sub_tics,'*'),'c',fd);mput(h.sub_tics,'c',fd); // sub_ticks
+    //mput(-1,'il',fd) // tics_color is removed F.Leray 15.03.05
+    mput(h.font_style,'c',fd) // font_style
+    mput(h.font_size,'c',fd) //font_size
+    mput(h.font_color,'il',fd) // font_color
+    mput(bool2s(h.isoview=='on'),'c',fd)    // isoview
+    mput(bool2s(h.cube_scaling=='on'),'c',fd) // cube_scaling
+    mput(h.rotation_angles,'dl',fd) // rotation_angles
+    mput(ascii(h.log_flags),'c',fd) // log_flags
+    mput(bool2s(h.tight_limits=='on'),'c',fd) // tight_limits
+    mput(size(h.data_bounds,'*'),'c',fd); // data_bounds
+    mput(h.data_bounds,'dl',fd);
+    mput(size(h.zoom_box,'*'),'c',fd);  // zoom_box
+    if size(h.zoom_box,'*')>0 then mput(h.zoom_box,'dl',fd);end
+    mput(h.margins,'dl',fd); // margins
+    mput(h.axes_bounds,'dl',fd); // axes_bounds
+    mput(bool2s(h.auto_clear=='on'),'c',fd) // auto_clear
+    mput(bool2s(h.auto_scale=='on'),'c',fd) // auto_scale
+    mput(h.hidden_axis_color,'il',fd); // hidden_axiis_color
+    mput(h.hiddencolor,'il',fd) // hidden_color
+    mput(bool2s(h.line_mode=='on'),'c',fd) // line_mode
+    mput(h.line_style,'c',fd) // line_style
+    mput(h.thickness,'sl',fd) // thickness
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.background,'il',fd) // background
+       
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    
+    // children
+    c=h.children;
+    n=size(c,'*')
+    mput(n,'il',fd)
+    for k=n:-1:1
+      save_graphichandle(c(k),fd)
+    end
+    
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Polyline"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    
+    mput(bool2s(h.visible=='on'),'c',fd) ; // visible
+    mput(size(h.data),'il',fd);mput(h.data,'dl',fd) // data
+    mput(bool2s(h.closed=='on'),'c',fd) // closed
+    mput(bool2s(h.line_mode=='on'),'c',fd) // line_mode
+    mput(bool2s(h.fill_mode=='on'),'c',fd) // fill_mode
+    mput(h.line_style,'c',fd) // line_style
+    mput(h.thickness,'sl',fd) // thickness
+    mput(h.arrow_size_factor,'sl',fd) // arrow_size_factor
+    mput(max(1,h.polyline_style),'c',fd) // ployline_style
+    
+    mput( size( h.interp_color_vector, '*' ), 'sl', fd ) ; // interp_color_vector
+    mput( h.interp_color_vector, 'dl', fd ) ;
+    mput( bool2s(h.interp_color_mode=='on'), 'c', fd ) ; // interp_color_mode
+    
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.background,'il',fd) // background
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+    
+    mput(size(h.x_shift,'*'),'sl',fd); mput(h.x_shift,'dl',fd); // x_shift
+    mput(size(h.y_shift,'*'),'sl',fd); mput(h.y_shift,'dl',fd); // y_shift
+    mput(size(h.z_shift,'*'),'sl',fd); mput(h.z_shift,'dl',fd); // z_shift
+    
+    mput( h.bar_width, 'dl', fd ) ; // bar_width
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+       mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Plot3d";
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(bool2s(h.surface_mode=='on'),'c',fd) // surface_mode
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.thickness,'sl',fd) // thickness
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+    mput(h.color_mode,'c',fd) // color_mode
+    mput(h.color_flag,'c',fd) // color_flag
+    x=h.data.x;sz=size(x)
+    mput(sz,'il',fd) // data.x
+    mput(x,'dl',fd)
+    y=h.data.y;sz=size(y)
+    mput(sz,'il',fd) // data.y
+    mput(y,'dl',fd)
+    z=h.data.z;sz=size(z)
+    mput(sz,'il',fd) // data.z
+    mput(z,'dl',fd)
+    if or(h.color_flag==[2 5]) then
+      clr=h.data.color;sz=size(clr)
+      mput(sz,'il',fd) // data.color
+      mput(clr,'il',fd)
+    end
+    mput(h.hiddencolor,'il',fd) // hidden_color
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Fac3d";
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd) ; // type
+    mput(bool2s(h.visible=='on'),'c',fd) ; // visible
+    mput(bool2s(h.surface_mode=='on'),'c',fd) // surface_mode
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.thickness,'sl',fd) // thickness
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+    mput(h.color_mode,'c',fd) // color_mode
+    mput(h.color_flag,'c',fd) // color_flag
+    x=h.data.x;sz=size(x)
+    mput(sz,'il',fd) // data.x
+    mput(x,'dl',fd)
+    y=h.data.y;sz=size(y)
+    mput(sz,'il',fd) // data.y
+    mput(y,'dl',fd)
+    z=h.data.z;sz=size(z)
+    mput(sz,'il',fd) // data.z
+    mput(z,'dl',fd)
+    if h.color_flag >=2 then
+      clr=h.data.color;sz=size(clr) // data.color
+      mput(sz,'il',fd)
+      mput(clr,'il',fd)
+      mput(ascii(part(h.cdata_mapping,1)),'c',fd) ; // cdata_mapping
+    end
+    mput(h.hiddencolor,'il',fd) // hidden_color
+    user_data=h.user_data;save(fd,user_data) // user_data
+  
+  case "Compound"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    
+    // children
+    children=h.children
+    n=size(children,'*')
+    mput(n,'il',fd)
+    for k=1:n
+      save_graphichandle(children(k),fd)
+    end
+    mput( bool2s( h.visible=='on'), 'c', fd ) ; // visible
+    //disp(mtell(fd));
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Rectangle"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(h.thickness,'sl',fd) // thickness
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+    mput(bool2s(h.line_mode=='on'),'c',fd) // line_mode
+    mput(h.line_style,'c',fd) // line_style
+    mput(bool2s(h.fill_mode=='on'),'c',fd) // fill_mode
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.background,'il',fd) // background
+    mput(h.data,'dl',fd) // data
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+       mput(h.clip_box,'dl',fd) // clip_box
+    end
+    
+    user_data=h.user_data;save(fd,user_data) ; // user_data
+    
+  case "Arc"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(h.thickness,'sl',fd) // thickness
+    mput(h.line_style,'c',fd) // line_style
+    mput(bool2s(h.line_mode=='on'),'c',fd) ;// line_mode
+    mput(bool2s(h.fill_mode=='on'),'c',fd) // fill_mode
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.background,'il',fd) ; // background
+    mput(h.data,'dl',fd) // data
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+  
+  case "Champ"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    x=h.data.x;sz=size(x)
+    mput(sz,'il',fd) // data.x
+    mput(x,'dl',fd)
+    y=h.data.y;sz=size(y)
+    mput(sz,'il',fd) // data.y
+    mput(y,'dl',fd)
+    fx=h.data.fx;sz=size(fx)
+    mput(sz,'il',fd) // data.fx
+    mput(fx,'dl',fd)
+    fy=h.data.fy;sz=size(fy)
+    mput(sz,'il',fd) // data.fz
+    mput(fy,'dl',fd)
+    mput(h.line_style,'c',fd) // line_style
+    mput(h.thickness,'sl',fd) // thickness
+    mput(bool2s(h.colored=='on'),'c',fd) // colored
+    mput(h.arrow_size,'dl',fd) // arrow_size
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+  
+  case "Segs"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(size(h.data),'il',fd);mput(h.data,'dl',fd) // data
+    mput(bool2s(h.line_mode=='on'),'c',fd) // line_mode
+    mput(h.line_style,'c',fd) // line_style
+    mput(h.thickness,'sl',fd) // thickness
+    mput(h.arrow_size,'dl',fd) // arrow_size
+    mput(size(h.segs_color,'*'),'il',fd); // segs_color
+    mput(h.segs_color,'il',fd)
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_style,'c',fd) // mark_style
+    mput(h.mark_size,'c',fd) // mark_size
+    mput(ascii(part(h.mark_size_unit,1)),'c',fd) // mark_size_unit
+    mput(h.mark_foreground,'il',fd) // mark_foreground
+    mput(h.mark_background,'il',fd) // mark_background
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd); // clip_state
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end  
+    user_data=h.user_data;save(fd,user_data) // user_data
+  
+  case "Grayplot"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    x=h.data.x;sz=size(x)
+    mput(sz,'il',fd) // data.x
+    mput(x,'dl',fd)
+    y=h.data.y;sz=size(y)
+    mput(sz,'il',fd) // data.y
+    mput(y,'dl',fd)
+    z=h.data.z;sz=size(z)
+    mput(sz,'il',fd) // data.z
+    mput(z,'dl',fd)
+    mput(length(h.data_mapping),'c',fd); // data_mapping
+    mput(ascii(h.data_mapping),'c',fd);
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+  
+  case "Matplot"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(size(h.data),'il',fd);mput(h.data,'dl',fd) // datat
+//    mput(length(h.data_mapping),'c',fd);mput(ascii(h.data_mapping),'c',fd);
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Fec"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(size(h.data),'il',fd);mput(h.data,'dl',fd) // data
+    mput(size(h.triangles),'il',fd);mput(h.triangles,'dl',fd) // triangles
+    mput(h.z_bounds,'dl',fd); // z_bounds
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Legend"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); //type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(bool2s(h.line_mode=='on'),'c',fd) // line_mode
+    mput(bool2s(h.mark_mode=='on'),'c',fd) // mark_mode
+    mput(h.mark_foreground,'il',fd); // mark_foreground
+    mput(h.mark_background,'il',fd); // mark_background
+    //mput(length(h.text),'c',fd);mput(ascii(h.text),'c',fd); // text
+    save_text_vector(h.text,fd); // text
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.font_style,'c',fd) // font_style
+    mput(h.font_size,'c',fd) // font_size
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    
+    
+  case "Text"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    //save_text_vector(h.text,fd) // text
+    save_text_matrix( h.text, fd ) ;
+    mput(size(h.data),'c',fd); // data // size could be 2 or 3
+    mput(h.data,'dl',fd); 
+    mput(h.text_box,'dl',fd); // text_box
+    mput(length(h.text_box_mode),'c',fd);
+    mput(ascii(h.text_box_mode),'c',fd); // text_box_mode
+    
+    mput(h.foreground,'il',fd) // foreground
+    mput(h.font_style,'c',fd) // font_style
+    mput(h.font_size,'c',fd) // font_size
+    mput(h.font_angle,'dl',fd) // font_angle
+    
+    //adding JB Silvy 28/11/05
+    // box drawing
+    mput( bool2s( h.box       == 'on' ), 'c', fd ) ; // box
+    mput( bool2s( h.line_mode == 'on' ), 'c', fd ) ; // line_mode
+    mput( bool2s( h.fill_mode == 'on' ), 'c', fd ) ; // fill_mode
+    
+    mput( h.font_foreground, 'il', fd ) ; // font_foreground
+    mput( h.background     , 'il', fd ) ; // background
+    
+    mput(length(h.alignment),'c',fd);
+    mput(ascii(h.alignment),'c',fd) ; // alignment
+    
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+    
+  case "Axis"
+    mput(length(h.type),'c',fd);mput(ascii(h.type),'c',fd); // type
+    mput(bool2s(h.visible=='on'),'c',fd) // visible
+    mput(length(h.tics_direction),'il',fd); // ticks_direction
+    mput(ascii(h.tics_direction),'c',fd);
+    mput(size(h.xtics_coord,'*'),'il',fd); // xtics_coord
+    mput(h.xtics_coord,'dl',fd) 
+    mput(size(h.ytics_coord,'*'),'il',fd); // ytics_coord
+    mput(h.ytics_coord,'dl',fd)
+    mput(h.tics_color,'il',fd) // tics_color
+    mput(bool2s(h.tics_segment=='on'),'c',fd) // tics_segment
+    mput(ascii(h.tics_style),'c',fd) // tics_style
+    mput(h.sub_tics,'il',fd) // sub_tics
+    save_text_vector(h.tics_labels,fd) // tics_labels
+    mput(h.labels_font_size,'il',fd) // label_font_size
+    mput(h.labels_font_color,'il',fd) // labels_font_color
+    mput(length(h.clip_state),'c',fd); // clip_state
+    mput(ascii(h.clip_state),'c',fd);
+    if h.clip_state=='on' then
+      mput(h.clip_box,'dl',fd) // clip_box
+    end
+    user_data=h.user_data;save(fd,user_data) // user_data
+  else
+    warning("handle of type "+h.type+" unhandled")
+  end
+
+endfunction
+
+function save_text_vector(t,fd)
+    t=strcat(t,ascii(10))
+    mput(length(t),'il',fd);mput(ascii(t),'c',fd);
+endfunction
+
+// save a text matrix
+function save_text_matrix(strMat,fd)
+  // put nbRow and nbCol
+  nbRow = size( strMat, 1 ) ;
+  nbCol = size( strMat, 2 ) ;
+  mput( nbRow, 'il', fd ) ;
+  mput( nbCol, 'il', fd ) ;
+  for i = 1:nbRow
+    for j = 1:nbCol
+      mput(length(strMat(i,j)),'c',fd) ;
+      mput(ascii(strMat(i,j)),'c',fd) ;
+    end
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/%h_set.sci b/scilab/modules/graphics/macros/%h_set.sci
new file mode 100644 (file)
index 0000000..8b8ebfb
--- /dev/null
@@ -0,0 +1,18 @@
+function hdl=%h_set(varargin)\r
+  if (lstsize(varargin) == 3)\r
+    hdl = varargin(1)\r
+    str = varargin(2)\r
+    val = varargin(3)\r
+    for i=1:size(hdl,'*')\r
+      set(hdl(i),str,val)\r
+    end,\r
+\r
+  elseif (lstsize(varargin) == 2)\r
+    str = varargin(1)\r
+    val = varargin(2)\r
+    hdl=[]\r
+    set(str,val)\r
+  end,\r
+endfunction\r
+\r
+\r
diff --git a/scilab/modules/graphics/macros/%xload.sci b/scilab/modules/graphics/macros/%xload.sci
new file mode 100644 (file)
index 0000000..6a18cea
--- /dev/null
@@ -0,0 +1,43 @@
+function %xload(fil,num)
+  if  argn(2)==2 then xset("window",num),end
+  if get('figure_style')=='old' then set('figure_style','new'),end
+  f=gcf()
+  xload_mode=%t
+  res = execstr('load(fil)','errcatch') ;
+  if res==0 then
+    f.visible='on'
+    f.immediate_drawing='on';
+  else 
+    //test if it is really an old style graphic save file
+    ufil=mopen(fil,'rb')
+    pos=mtell(ufil)
+    n1=mget(1,'uib',ufil)
+    if n1<>8 then 
+      mclose(ufil),error('Given file is not a graphic one');
+    end
+    mseek(pos,ufil,'set')
+    SciF_version=LoadVectC()
+    if part(SciF_version,1:4)<>"SciG" then 
+      mclose(ufil),error('Given file is not a graphic one'),
+    end
+    mclose(ufil),
+    set('figure_style','old')
+    xload(fil)
+  end
+//  draw(f)
+
+endfunction
+function str=LoadVectC()
+// Copyright INRIA
+// Author: Serge Steer
+
+// Emulate the C procedure in routines/graphics/RecLoad.c
+  
+  n1=mget(1,'uib',ufil)
+  //q=int(n1/4);r=n1-4*q
+  n=n1
+  if modulo(n1,4)<>0 then n=4*(int(n1/4)+1),end
+  c=mget(n,'uc',ufil)
+  if n1-1>size(c) then pause,end
+  str=ascii(c(1:n1-1))
+endfunction
diff --git a/scilab/modules/graphics/macros/%xsave.sci b/scilab/modules/graphics/macros/%xsave.sci
new file mode 100644 (file)
index 0000000..52c7135
--- /dev/null
@@ -0,0 +1,12 @@
+function %xsave(fil,num)
+  if argn(2)<2 then
+    f=gcf()
+    preservecur=%f
+  else
+    preservecur=winsid()<>[]
+    if preservecur then old=gcf();end
+    f=scf(num);
+  end
+  save(fil,f)
+  if preservecur then scf(old),end
+endfunction
diff --git a/scilab/modules/graphics/macros/Sfgrayplot.sci b/scilab/modules/graphics/macros/Sfgrayplot.sci
new file mode 100644 (file)
index 0000000..efcf772
--- /dev/null
@@ -0,0 +1,75 @@
+function []=Sfgrayplot(x, y, f, strf, rect, nax, zminmax, colminmax, mesh, colout)
+
+       // PURPOSE
+       //    Like fgrayplot but the function fec is used to smooth the 
+       //    result assuming that the underlying function is linear on 
+       //    a set of triangles built from the grid (here with n1=5, n2=3):
+       //             _____________
+       //             | /| /| /| /|
+       //             |/_|/_|/_|/_| 
+       //             | /| /| /| /| 
+       //             |/_|/_|/_|/_|
+       //
+       // Copyright INRIA
+       // rewritten by Bruno Pincon (17 april 05) (based of my modifs of Sgrayplot)
+
+       [lhs,rhs]=argn()
+       if rhs == 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of Sfgrayplot()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=x.^3+y'');';
+                       'xbasc()';
+                       'xset(""colormap"",jetcolormap(64))';
+                       'colorbar(-2,2)';
+                       'Sfgrayplot(-1:0.1:1,-1:0.1:1,Surf,strf=""031"",rect=[-1,-1,1,1]);';
+                       'xtitle(''Sfgrayplot demo: f(x,y)=x^3+y'')'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       elseif rhs < 3 then
+               error("bad number of input arguments");
+       end
+  
+       // some checks
+       if ~(type(x)==1 & isreal(x) & type(y)==1 & isreal(y)) then
+               error("two first arguments must be real");
+       end
+       if type(f)~=11 & type(f)~=13 then 
+               error("third argument must be a scilab function");
+       end
+       
+       p = length(x); q = length(y);
+       
+       // parsing the optional args
+       opt_arg_list = ["strf", "rect","nax","zminmax", "colminmax", "mesh", "colout"];
+       opt_arg_seq = [];
+       for opt_arg = opt_arg_list
+               if exists(opt_arg,"local") then
+                       opt_arg_seq = opt_arg_seq +","+ opt_arg + "=" + opt_arg;
+               end
+       end
+       
+       // build the datas for fec
+       z = feval(x,y,f);
+       [noe_x,noe_y] = ndgrid(x,y)
+       nbtri = 2*(p-1)*(q-1)
+       num = (1:p*(q-1))'; num(p*(1:q-1)) = []; num1 = num+1
+       connect =[(1:nbtri)' , [num   num1   num+p;...
+               num1  num1+p num+p]  ,  zeros(nbtri,1)]
+       
+       // then plot
+       if opt_arg_seq == [] then
+               fec(noe_x,noe_y,connect,z);
+       else
+               execstr("fec(noe_x,noe_y,connect,z"+opt_arg_seq+")");
+       end
+endfunction
diff --git a/scilab/modules/graphics/macros/Sgrayplot.sci b/scilab/modules/graphics/macros/Sgrayplot.sci
new file mode 100644 (file)
index 0000000..7dc453f
--- /dev/null
@@ -0,0 +1,75 @@
+function []=Sgrayplot(x,y,z, strf, rect, nax, zminmax, colminmax, mesh, colout)
+// 
+// PURPOSE
+//    Like grayplot but the function fec is used to smooth the 
+//    result assuming that the underlying function is linear on 
+//    a set of triangles built from the grid (here with n1=5, n2=3):
+//             _____________
+//             | /| /| /| /|
+//             |/_|/_|/_|/_| 
+//             | /| /| /| /| 
+//             |/_|/_|/_|/_|
+//
+// Copyright INRIA
+// Modified by Bruno Pincon (14 oct 04) to have named argument working
+// Some new modifs (Bruno Pincon, Feb 2005, demo + some checking + cleaning + add
+// mesh and colout optionnal args)
+
+       [lhs,rhs] = argn();
+        
+       if rhs == 0 then   // demo
+               title_demo = [
+                       '';
+                       'Demo of Sgrayplot()';
+                       '========================================';
+                       ''];
+               
+               s_mat = ["t=-%pi:0.1:%pi";
+                       "m=sin(t)''*cos(t)";
+                       "xbasc()";
+                       "xset(''colormap'',jetcolormap(64))";
+                       "colorbar(-1,1)"
+                       "Sgrayplot(t,t,m,strf=''041'',zminmax=[-1,1])";
+                       "xtitle(''Sgrayplot demo f(x,y)=sin(x)*cos(y) on [-pi,pi]x[-pi,pi]'')"]
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       elseif rhs < 3 then
+               error("bad number of input arguments")
+       end
+
+   // some checks
+   if ~(type(x)==1 & isreal(x) & type(y)==1 & isreal(y) & type(z)==1 & isreal(z)) then 
+      error("three first arguments must be real")
+   end
+   nx = length(x); ny = length(y); [p,q] = size(z)
+   if p ~= nx | q ~= ny then
+      error("third argument has incompatible dimensions with the two first")
+   end
+   
+   // parsing the optionnal args
+   opt_arg_list = ["strf", "rect","nax","zminmax", "colminmax", "mesh", "colout"]
+   opt_arg_seq = []
+   for opt_arg = opt_arg_list
+      if exists(opt_arg,"local") then
+        opt_arg_seq = opt_arg_seq +","+ opt_arg + "=" + opt_arg
+      end
+   end
+   
+   // build the datas for fec
+   [noe_x,noe_y] = ndgrid(x,y)
+   nbtri = 2*(p-1)*(q-1)
+   num = (1:p*(q-1))'; num(p*(1:q-1)) = []; num1 = num+1
+   connect =[(1:nbtri)' , [num   num1   num+p;...
+                          num1  num1+p num+p]  ,  zeros(nbtri,1)]
+   
+   // then plot
+   if opt_arg_seq == [] then
+      fec(noe_x,noe_y,connect,z)
+   else
+      execstr("fec(noe_x,noe_y,connect,z"+opt_arg_seq+")")
+   end
+endfunction
diff --git a/scilab/modules/graphics/macros/TitleLabel.sci b/scilab/modules/graphics/macros/TitleLabel.sci
new file mode 100644 (file)
index 0000000..a2f9167
--- /dev/null
@@ -0,0 +1,123 @@
+function TitleLabel(varargin)
+// Copyright INRIA
+// TITLELABEL function
+// is used by the functions title, xlabel, ylabel, zlabel
+// F.Belahcene
+
+[lhs,rhs]=argn(0);
+
+isold=get('figure_style')=='old'
+
+if isold
+  disp("Not supported under old graphic style");
+  return;
+end
+
+//CurColor = 0; // current color used if no color specified via LineSpec
+// nor PropertyName
+
+ListArg = varargin;
+titlelabel = ListArg(1);
+ListArg(1) = null();
+
+//detect and set the current axes now:
+if type(ListArg(1)) == 9
+  hdle = ListArg(1);
+  if (hdle.type == "Axes")
+    sca(ListArg(1));
+    ListArg(1) = null(); // remove this parameter from the list
+  else
+    disp("Handle should be an Axes handle")
+    return;
+  end
+end
+
+monaxe = gca();
+
+nv = size(ListArg);
+// detect and set the string now:
+if  type(ListArg(1))== 10 & modulo(nv,2) == 1 then
+  st = ListArg(1);
+  execstr("monaxe."+ titlelabel +".text"+"=st")
+  ListArg(1) = null();
+  nv=nv-1 
+else
+ error("wrong input argument")
+end
+
+T=[];
+
+//given_data = 2;
+
+for k=1:nv
+  T(k,1) = type(ListArg(k))
+end
+
+given_data = 0;
+P1 = 0;
+
+for i=1:nv
+  if T(i) == 1
+    given_data = given_data +1;
+  else
+    P1 = i;  // Position of the first PropertyName field
+    break;
+  end
+end
+
+
+// delay the drawing commands
+// smart drawlater
+current_figure=gcf();
+cur_draw_mode = current_figure.immediate_drawing;
+current_figure.immediate_drawing = 'off';
+
+
+// set some defaults here
+// current_figure=gcf(); // already init. before
+// current_figure.color_map=jetcolormap(64); // bad choice -> init must be done somewhere else.
+
+colormap_size = size(current_figure.color_map,1);
+
+///////////////////////////////////
+//Global Property treatment      //
+//PropertyName and PropertyValue //
+///////////////////////////////////
+
+// P1 is the position of the first PropertyName field.
+Property = P1;
+
+current_surface = gce(); // get the newly created fac3d
+
+current_titlelabel=get(monaxe,titlelabel)
+monaxe.axes_visible = ["on","on","on"]
+//current_surface.mark_size_unit='point';
+
+while ((Property <> 0) & (Property <= nv-1))
+  setTitleLabelProperty(ListArg(Property),ListArg(Property+1),current_titlelabel,current_figure,cur_draw_mode)
+  //setLabelProperty(ListArg(Property),ListArg(Property+1),monaxe.title,current_figure,cur_draw_mode)
+  Property = Property+2;
+end
+
+//postponed drawings are done now !
+// smart drawnow
+ResetFigureDDM(current_figure, cur_draw_mode);
+
+
+endfunction
+
+// Reset the Default Drawing Mode (DDM) of the figure
+// immediate_drawing is set to its input value.
+function ResetFigureDDM(cur_figure, cur_draw_mode)
+
+if type(cur_figure == 9)
+  if cur_figure.type == "Figure"
+    cur_figure.immediate_drawing = cur_draw_mode;
+  else
+    disp("Error in ResetFigureDDM : input argument must be a figure graphic handle");
+    return;
+  end
+end
+
+endfunction
+
diff --git a/scilab/modules/graphics/macros/addcolor.sci b/scilab/modules/graphics/macros/addcolor.sci
new file mode 100644 (file)
index 0000000..24081c8
--- /dev/null
@@ -0,0 +1,35 @@
+function new=addcolor(c)
+// add colors to the current colormap
+//!
+// Copyright INRIA
+
+//Modif. to accept 3x1 column vector
+c=c(:)';
+
+if size(c,'c')<>3 then
+  error('addcolor : argument is not a color table')
+end
+
+if maxi(c)>1|mini(c)<0 then
+  error('addcolor : argument is not a color table')
+end
+cmap=xget('colormap')
+ncol=size(cmap,'r')
+ncol0=ncol
+new=[]
+if xget('use color')==1 then 
+  for k=1:size(c,'r')
+    ck=c(k,:)
+    k2=find(abs(cmap-ones(ncol,1)*ck)*ones(3,1)<=1.d-5)
+    if k2==[] then 
+      cmap=[cmap;ck],
+      ncol=ncol+1
+      new=[new ncol]
+    else
+      new=[new k2(1)]
+    end
+
+  end
+end
+if ncol>ncol0 then xset('colormap',cmap),end
+endfunction
diff --git a/scilab/modules/graphics/macros/bar.sci b/scilab/modules/graphics/macros/bar.sci
new file mode 100644 (file)
index 0000000..d4fa1d0
--- /dev/null
@@ -0,0 +1,216 @@
+function  bar(varargin)
+// Copyright INRIA
+// bar(x,y,width,style,color)
+// This function  ...
+// 
+// Intput :
+// x : a real scalar or a vector
+// y : a real sclar, or a vector
+// width : a double, the bar width, it's the percentage (0<width<1) of the width max of one bar which is wanted (default: width=0.8)
+// style : a string 'grouped' or 'stacked' (default: style='grouped')
+// F.B
+
+
+styletab=["grouped","stacked"]
+COLORBOOL=%f
+STYLE="grouped"
+
+//Check RHS argument
+ListArg = varargin;
+
+//detect and set the current axes now:
+if type(ListArg(1)) == 9
+  hdle = ListArg(1);
+  if (hdle.type == "Axes")
+    sca(ListArg(1));
+    ListArg(1) = null(); // remove this parameter from the list
+  else
+    warning("Handle should be an Axes handle")
+    return;
+  end
+end
+
+nv = size(ListArg)
+
+T=[];
+
+// Number of inputs arguments < 6
+if  size(ListArg)>5 then 
+  error("wrong number of arguments RHS")
+end
+
+for k=1:nv
+  T(k) = type(ListArg(k))
+end
+
+argdb=find(T==1)
+argstr=find(T==10)
+
+if size(argdb,"*")<> argdb($) then
+  error("wrong argument type")
+end
+
+if size(argstr,"*") <> nv-argdb($) then
+  error("wrong argument type")
+end
+
+//set the double argument : x,y,width
+// bar(y,...)
+if size(argdb,"*")==1
+  Y=ListArg(1)
+  WIDTH=0.8
+  if or(size(Y)==1) then
+    Y=Y(:)
+  end 
+  X=1:size(Y,1)
+end
+
+if size(argdb,"*")==2
+  if size(ListArg(2),"*")==1 then
+    // bar(x,y,...)
+    if size(ListArg(1),"*")==1 then
+      WIDTH=0.8
+      X=ListArg(1)
+      Y=ListArg(2)
+    else
+      //bar(y,width,...)
+      WIDTH=ListArg(2)
+      Y=ListArg(1)
+      if or(size(Y)==1) then
+       Y=Y(:)
+      end
+      X=1:size(Y,1)
+    end
+  else
+    // bar(x,y,...) 
+    X=ListArg(1)
+    Y=ListArg(2)
+    if or(size(X)==1) then  
+      if size(X,"*")<>1 then // X is a vector  
+       if or(size(Y)==1) then // Y is a vector
+         Y=Y(:)
+       end  
+       if size(X,"*")<>size(Y,1)
+         error("x and y dims : no match")    
+       end
+      elseif size(Y,1)>1 then
+       error("x and y dims : no match") 
+      end 
+    else 
+      error("x must be a scalar or a vector")
+    end 
+    WIDTH=0.8
+  end    
+end
+
+// bar(x,y,width,...)      
+if size(argdb,"*")==3
+  X=ListArg(1)
+  Y=ListArg(2)
+  WIDTH=ListArg(3)
+  if size(WIDTH,"*")<>1 then
+    error("width must be a scalar")
+  elseif or(size(X)==1) then  
+    if size(X,"*")<>1 then // X is a vector  
+      if or(size(Y)==1) then // Y is a vector
+       Y=Y(:)
+      end  
+      if size(X,"*")<>size(Y,1)
+       error("x and y dims : no match")    
+      end
+    elseif size(Y,1)>1 then
+      error("x and y dims : no match") 
+    end 
+  else 
+    error("x must be a scalar or a vector")
+  end 
+end
+X=X(:)
+
+// set the string argument
+for i=1:size(argstr,"*") 
+  // bar(...,style)
+  if or(ListArg(argstr(i))==styletab) then
+    STYLE=ListArg(argstr(i))
+  else
+    COLOR=ListArg(argstr(i))
+    COLORBOOL=%t
+  end
+end
+
+drawlater();
+
+if COLORBOOL
+  plot(X,Y,COLOR)
+else 
+  plot(X,Y)
+end
+bar_number=size(Y,2)
+if size(X,"*")>1 then
+  Xtemp=gsort(X,'r','i')
+  inter=Xtemp(2)-Xtemp(1)
+  for i=2:size(Xtemp,"*")-1
+    inter=min(Xtemp(i+1)-Xtemp(i),inter)
+  end
+  if bar_number>1
+    inter=inter*0.9
+  end
+else
+  Xtemp=X
+  inter=1
+end
+
+wmax=inter/bar_number
+
+y_shift=zeros(size(X,"*"),1)
+
+bar_number= bar_number
+
+  e=gce()
+  a=gca()
+  
+  a.sub_ticks(1) = 0; // bar (barh => a.sub_ticks(2) = 0;)
+
+for i=bar_number:-1:1
+
+  ei = e.children(i);
+    
+  // Perform x_shift
+  if modulo(bar_number,2)==0 then  
+    x_shift=(-i+bar_number/2)*wmax+wmax/2
+  elseif modulo(bar_number,2)==1 then  
+    x_shift=(-i+1+floor(bar_number/2))*wmax
+  end
+  
+  // Perform y_shift 
+  if i==bar_number then
+    y_shift=zeros(size(X,"*"),1)
+  else
+    y_shift=Y(:,bar_number-i)+y_shift 
+  end
+  
+  // Udate the axes data bounds 
+  if STYLE=="grouped"
+    a.data_bounds=[min(a.data_bounds(1,1),min(X)+x_shift-wmax/2) min(a.data_bounds(1,2),0,min(y_shift+Y(:,bar_number-i+1))); max(a.data_bounds(2,1),max(X)+x_shift+wmax/2) max(a.data_bounds(2,2),0)]
+    ei.x_shift=x_shift*ones(size(X,"*"),1)
+  else
+    wmax=inter
+    a.data_bounds=[min(a.data_bounds(1,1),min(X)-wmax/2) min(a.data_bounds(1,2),0,min(y_shift+Y(:,bar_number-i+1))); max(a.data_bounds(2,1),max(X)+wmax/2) max(a.data_bounds(2,2),0,max(y_shift+Y(:,bar_number-i+1)))]
+    ei.y_shift=y_shift
+  end
+  
+  a.x_ticks=tlist("ticks",Xtemp,string(Xtemp))
+  
+  w=WIDTH*wmax
+  
+  ei.bar_width=w
+  ei.background=ei.foreground 
+  ei.polyline_style=6; // bar type
+  ei.background=ei.foreground  
+  ei.foreground = -1; // black by default
+  ei.line_mode='off';
+end
+
+drawnow();
+
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/barh.sci b/scilab/modules/graphics/macros/barh.sci
new file mode 100644 (file)
index 0000000..d9a3288
--- /dev/null
@@ -0,0 +1,237 @@
+function  barh(varargin)
+
+       // Copyright INRIA
+       // barh(x,y,width,style,color) 
+       // Intput :
+       // x : a scalar or a vector of reals
+       // y : a sclar, a vector or a matrix of reals
+       // width : a double, the bar width, it's the percentage (0<width<1) of the max width of one bar which is wanted (default: width=0.8)
+       // style : a string, 'grouped' or 'stacked' (default: style='grouped')
+       // F.B
+       
+       styletab=["grouped","stacked"]
+       COLORBOOL=%f
+       
+       // Default values
+       STYLE="grouped"
+       WIDTH=0.8
+       COLORBOOL=%f
+       
+       // Check RHS arguments
+       ListArg = varargin;
+       
+       // Detect and set the current axes now:
+       if type(ListArg(1)) == 9
+               hdle = ListArg(1);
+               if (hdle.type == "Axes")
+                       sca(ListArg(1));
+                       ListArg(1) = null(); // remove this parameter from the list
+               else
+                       warning("Handle should be an Axes handle")
+                       return;
+               end
+       end
+       
+       nv = size(ListArg)
+       
+       T=[];
+       
+       // Number of inputs arguments < 6
+       if  size(ListArg)>5 then 
+               error("wrong number of arguments RHS")
+       end
+       
+       for k=1:nv
+               T(k) = type(ListArg(k))
+       end
+       
+       argdb=find(T==1)
+       argstr=find(T==10)
+       
+       if size(argdb,"*")<> argdb($) then
+               error("wrong argument type")
+       end
+       
+       if size(argstr,"*") <> nv-argdb($) then
+               error("wrong argument type")
+       end
+       
+       // Set the double argument : x,y,width
+       // barh(y,...)
+       if size(argdb,"*")==1
+               Y=ListArg(1)
+               if or(size(Y)==1) then
+                       Y=Y(:)
+               end 
+               X=1:size(Y,1)
+       end
+       
+       if size(argdb,"*")==2
+               if size(ListArg(2),"*")==1 then
+                       // barh(x,y,...)
+                       if size(ListArg(1),"*")==1 then
+                               X=ListArg(1)
+                               Y=ListArg(2)
+                       else
+                               //barh(y,width,...)
+                               WIDTH=ListArg(2)
+                               Y=ListArg(1)
+                               if or(size(Y)==1) then
+                                       Y=Y(:)
+                               end
+                               X=1:size(Y,1)
+                       end
+               else
+                       // barh(x,y,...) 
+                       X=ListArg(1)
+                       Y=ListArg(2)
+                       if or(size(X)==1) then  
+                               if size(X,"*")<>1 then // X is a vector  
+                                       if or(size(Y)==1) then // Y is a vector
+                                               Y=Y(:)
+                                       end  
+                                       if size(X,"*")<>size(Y,1)
+                                               error("x and y dims : no match")    
+                                       end
+                               elseif size(Y,1)>1 then
+                                       error("x and y dims : no match") 
+                               end 
+                       else 
+                               error("x must be a scalar or a vector")
+                       end 
+               end    
+       end
+       
+       // barh(x,y,width,...)      
+       if size(argdb,"*")==3
+               X=ListArg(1)
+               Y=ListArg(2)
+               WIDTH=ListArg(3)
+               if size(WIDTH,"*")<>1 then
+                       error("width must be a scalar")
+               elseif or(size(X)==1) then  
+                       if size(X,"*")<>1 then // X is a vector  
+                               if or(size(Y)==1) then // Y is a vector
+                                       Y=Y(:)
+                               end  
+                               if size(X,"*")<>size(Y,1)
+                                       error("x and y dims : no match")    
+                               end
+                       elseif size(Y,1)>1 then
+                               error("x and y dims : no match") 
+                       end 
+               else 
+                       error("x must be a scalar or a vector")
+               end 
+       end
+       
+       X=X(:)
+       
+       // Set the string argument
+       for i=1:size(argstr,"*") 
+               // barh(...,style)
+               if or(ListArg(argstr(i))==styletab) then
+                       STYLE=ListArg(argstr(i))
+               else
+                       COLOR=ListArg(argstr(i))
+                       COLORBOOL=%t
+               end
+       end
+       
+       // Verify if there are data bounds which are defined before creation the horizontal bars creation, in order to merge the data bounds
+       a=gca()
+       if size(a.children)<>0 then
+               gca_children_empty=%t
+               a_data_bounds=a.data_bounds
+       else
+               gca_children_empty=%f
+       end
+       
+       drawlater();
+       
+       if COLORBOOL
+               plot(X,Y,COLOR)
+       else 
+               plot(X,Y)
+       end
+       
+       barh_number=size(Y,2)
+       
+       if size(X,"*")>1 then
+               Xtemp=gsort(X,'r','i')
+               inter=Xtemp(2)-Xtemp(1)
+               for i=2:size(Xtemp,"*")-1
+                       inter=min(Xtemp(i+1)-Xtemp(i),inter)
+               end
+               if barh_number>1
+                       inter=inter*0.9
+               end
+       else
+               inter=1
+       end
+       
+       wmax=inter/barh_number
+       y_shift=zeros(size(X,"*"),1)
+       bar_number= size(Y,2)
+       e=gce()
+       a=gca()
+       a.sub_ticks(2) = 0
+       
+       for i=bar_number:-1:1
+               
+               ei = e.children(i)
+               
+               // Perform x_shift
+               if modulo(bar_number,2)==0 then  
+                       x_shift=(-i+bar_number/2)*wmax+wmax/2
+               elseif modulo(bar_number,2)==1 then  
+                       x_shift=(-i+1+floor(bar_number/2))*wmax
+               end
+               
+               // Perform y_shift 
+               if i==bar_number then
+                       y_shift=zeros(size(X,"*"),1)
+               else
+                       y_shift=Y(:,bar_number-i)+y_shift 
+               end
+               
+               // Update axes data bounds 
+               // case 'grouped'
+               if STYLE=="grouped"
+                       if i <> bar_number then
+                               a.data_bounds=[min(a.data_bounds(1,1),min(Y(:,bar_number-i+1)),0) min(a.data_bounds(1,2),min(X)+x_shift-wmax/2); max(a.data_bounds(2,1),max(Y(:,bar_number-i+1)),0) max(a.data_bounds(2,2),max(X)+x_shift+wmax/2)]
+                       else
+                               if ~gca_children_empty
+                                       a.data_bounds=[min(min(Y(:,bar_number-i+1)),0) min(X)+x_shift-wmax/2; max(max(Y(:,bar_number-i+1)),0) max(X)+x_shift+wmax/2]
+                               else
+                                       a.data_bounds=[min(a_data_bounds(1,1),min(Y(:,bar_number-i+1)),0) min(a_data_bounds(1,2),min(X)+x_shift-wmax/2); max(a_data_bounds(2,1),max(Y(:,bar_number-i+1)),0) max(a_data_bounds(2,2),max(X)+x_shift+wmax/2)]
+                               end
+                       end
+                       ei.x_shift=x_shift*ones(size(X,"*"),1)
+               else  // case 'stacked'
+                       wmax=inter
+                       if i <> bar_number then
+                               a.data_bounds=[min(a.data_bounds(1,1),min(Y(:,bar_number-i+1)+y_shift)) min(a.data_bounds(1,2),0,min(X-wmax/2)); max(a.data_bounds(2,1),max(Y(:,bar_number-i+1)+y_shift)) max(a.data_bounds(2,2),0,max(X+wmax/2))]
+                       else
+                               if ~gca_children_empty
+                                       a.data_bounds=[min(Y(:,bar_number-i+1)+y_shift) min(0,min(X-wmax/2)); max(Y(:,bar_number-i+1)+y_shift) max(0,max(X+wmax/2))]
+                               else
+                                       a.data_bounds=[min(a_data_bounds(1,1),min(Y(:,bar_number-i+1)+y_shift)) min(a_data_bounds(1,2),0,min(X-wmax/2)); max(a_data_bounds(2,1),max(Y(:,bar_number-i+1)+y_shift)) max(a_data_bounds(2,2),0,max(X+wmax/2))]
+                               end
+                       end
+                       ei.y_shift=y_shift
+               end
+               
+               a.y_ticks=tlist("ticks",Xtemp,string(Xtemp))
+               w=WIDTH*wmax
+               ei.bar_width=w
+               ei.background=ei.foreground 
+               ei.polyline_style=7; // bar type
+               ei.background=ei.foreground  
+               ei.foreground = -1; // black by default
+               ei.line_mode='off';
+       end
+       
+       drawnow();
+
+endfunction
diff --git a/scilab/modules/graphics/macros/barhomogenize.sci b/scilab/modules/graphics/macros/barhomogenize.sci
new file mode 100644 (file)
index 0000000..5a966db
--- /dev/null
@@ -0,0 +1,183 @@
+function  barhomogenize(varargin)
+// Copyright INRIA
+// barhomogenize(a,style,width)
+// This function homogenizes the style and the widh of all the bars contained in the axes handle a (default is the handle of the current axes)  
+// 
+// Intput : 
+// a :  the handle of the axe containing the bares (default: a=gca())
+// style : a string, 'grouped' or 'stacked' (default: style='grouped')
+// width : a double, the bar width, it's the percentage (0<width<1) of the width max of one bar which is wanted (default: width=0.8).
+// F.B
+
+// Default values
+a=gca()
+STYLE="grouped"
+WIDTH=0.8
+varlist=varargin
+pos='v'
+
+if size(varargin)<>0 then
+if or(varlist($)==['h';'v']) then 
+  pos=varlist($)
+  varlist($)=null()
+end
+end
+// detect and set the handle axes, the style and the width
+if size(varlist) == 1 
+  if type(varlist(1))==9 
+    var1=varlist(1)
+    if var1.type == "Axes"
+      a=var1
+    else
+      error("Handle should be an Axes handle")
+    end
+    varlist(1).type == "Axes"
+    a=varlist(1)
+  elseif or(varlist(1) == ["grouped","stacked"])
+    STYLE=varlist(1)
+  elseif type(varlist(1)) == 1
+    WIDTH=varlist(1)
+  else 
+    error("wrong input argument(s)")
+  end
+elseif size(varlist) == 2 then  
+  if type(varlist(1))==9  then 
+    var1=varlist(1)
+    if (var1.type == "Axes") & or(varlist(2)==["grouped","stacked"]) then
+      a=var1
+      STYLE=varlist(2)
+    elseif var1.type == "Axes" & type(varlist(2)) == 1 then
+      a=var1
+      WIDTH=varlist(2)
+    else 
+      error("wrong input argument(s)")
+    end
+  elseif or(varlist(1) == ["grouped","stacked"]) & (type(varlist(2)) == 1)
+    STYLE=varlist(1)
+    WIDTH=varlist(2)  
+  else 
+    error("wrong input argument(s)")
+  end
+elseif size(varlist) == 3
+  if type(varlist(1))==9  then
+    var1 = varlist(1)
+    if var1.type == "Axes" & or(varlist(2)==["grouped","stacked"]) & (type(varlist(3)) == 1) 
+      a=var1
+      STYLE=varlist(2)
+      WIDTH=varlist(3) 
+    elseif  size(varlist) > 3 then
+      error("wrong number of input arguments")
+    end
+  end
+end
+
+if ~isreal(WIDTH)
+  error("The width must be real")
+end
+
+hbarlist=[];
+
+for i=1:size(a.children,"*")
+  hbarlist=searchbarhandle(a.children(i),hbarlist)
+end
+
+
+nbarhandle=size(hbarlist,'*')
+if hbarlist<>[] then
+  X=hbarlist(1).data(:,1)
+  for i=2:nbarhandle
+    if or(hbarlist(i).data(:,1) <> X)
+      error("The bars must have the same x data")
+    end
+  end
+end
+
+// Determinate the max width
+if size(X,"*")>1 then
+  Xtemp=gsort(X,'r','i')
+  inter=Xtemp(2)-Xtemp(1)
+  for i=2:size(Xtemp,"*")-1
+    inter=min(Xtemp(i+1)-Xtemp(i),inter)
+  end
+  if nbarhandle>1
+    inter=inter*0.9
+  end
+else
+  inter=1
+end
+
+// Perform the x_shift
+wmax=inter/nbarhandle
+
+
+for i=1:nbarhandle
+  if modulo(nbarhandle,2)==0 then  
+    x_shift=(i-1-nbarhandle/2)*wmax+wmax/2
+  elseif modulo(nbarhandle,2)==1 then  
+    x_shift=(i-1-floor(nbarhandle/2))*wmax
+  end
+  
+  // Perform the y_shift
+  if i==1 then
+    y_shift=zeros(size(X,"*"),1)
+  else
+    y_shift=hbarlist(i-1).data(:,2)+y_shift
+  end
+  
+  // Update axes data bounds 
+  if pos=='v'
+  if STYLE=="grouped"
+    a.data_bounds=[min(a.data_bounds(1,1),min(X)+x_shift-wmax/2) min(a.data_bounds(1,2),0,min(hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(X)+x_shift+wmax/2) max(a.data_bounds(2,2),0,max(hbarlist(i).data(:,2)))]
+    hbarlist(i).x_shift=x_shift*ones(size(X,"*"),1)
+    hbarlist(i).y_shift=zeros(size(X,"*"),1)
+  else
+    wmax=inter
+    a.data_bounds=[min(a.data_bounds(1,1),min(X)-wmax/2) min(a.data_bounds(1,2),0,min(y_shift+hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(X)+wmax/2) max(a.data_bounds(2,2),0,max(y_shift+hbarlist(i).data(:,2)))]
+    hbarlist(i).x_shift=zeros(size(X,"*"),1)
+    hbarlist(i).y_shift=y_shift
+  end
+  a.auto_ticks(2) = 'on';
+  a.x_ticks=tlist("ticks",Xtemp,string(Xtemp))
+  hbarlist(i).polyline_style=6;
+  elseif pos=='h' then
+  if STYLE=="grouped"
+    a.data_bounds=[min(a.data_bounds(1,2),min(X)+x_shift-wmax/2) min(a.data_bounds(1,1),0,min(hbarlist(i).data(:,2))); max(a.data_bounds(2,2),max(X)+x_shift+wmax/2) max(a.data_bounds(2,1),0,max(hbarlist(i).data(:,2)))]
+    hbarlist(i).x_shift=x_shift*ones(size(X,"*"),1)
+    hbarlist(i).y_shift=zeros(size(X,"*"),1)
+  else
+    wmax=inter
+    a.data_bounds=[min(a.data_bounds(1,2),min(X)-wmax/2) min(a.data_bounds(1,1),0,min(y_shift+hbarlist(i).data(:,2))); max(a.data_bounds(2,1),max(y_shift+hbarlist(i).data(:,2))) max(a.data_bounds(2,2),0,max(X+x_shift)+wmax/2)]
+    hbarlist(i).x_shift=zeros(size(X,"*"),1)
+    hbarlist(i).y_shift=y_shift
+  end
+  a.auto_ticks(1) = 'on';
+  a.sub_ticks(2) = 0;
+  a.y_ticks=tlist("ticks",Xtemp,string(Xtemp))
+  hbarlist(i).polyline_style=7; 
+  end
+  
+  w=WIDTH*wmax
+  if hbarlist(i).background == -2
+    hbarlist(i).background=hbarlist(i).foreground
+  end
+  hbarlist(i).bar_width=w
+  hbarlist(i).line_mode='off';
+end
+endfunction
+
+function  hbarlist=searchbarhandle(h,hbarlist)
+// This function searches all the bares contained in a axes handle 
+// output : 
+// hbarlist: a list which contains the bars handles 
+if h.type=="Compound" then
+  for j=1:size(h.children,"*")
+    hbarlist=searchbarhandle(h.children(j),hbarlist)
+  end
+elseif  h.type == "Polyline" then
+  if h.polyline_style == 6 | h.polyline_style == 7 then
+    hbarlist = [hbarlist h];
+  end
+end
+endfunction 
diff --git a/scilab/modules/graphics/macros/black.sci b/scilab/modules/graphics/macros/black.sci
new file mode 100644 (file)
index 0000000..8eb69db
--- /dev/null
@@ -0,0 +1,182 @@
+function []=black(sl,fmin,fmax,pas,comments)
+//Black's diagram (Nichols chart) for a linear system sl.
+//sl can be a continuous-time, discrete-time or sampled SIMO system
+//Syntax:
+//
+//           black( sl,fmin,fmax [,pas] [,comments] )
+//           black(frq,db,phi [,comments])
+//           black(frq, repf  [,comments])
+//  
+//  sl       : SIMO linear system (see syslin). In case of multi-output
+//             system the outputs are plotted with differents symbols.
+//            
+//  fmin     : minimal frequency (in Hz).
+//  fmax     : maximal frequency (in Hz).
+//  pas      : logarithmic discretization step. (see calfrq for the
+//             choice of default value).
+//  comments : character strings to comment the curves.
+//
+//  frq      : (row)-vector of frequencies (in Hz) or (SIMO case) matrix
+//             of frequencies.
+//  db       : matrix of modulus (in Db). One row for each response.
+//  phi      : matrix of phases (in degrees). One row for each response.
+//  repf     : matrix of complex numbers. One row for each response.
+
+// Copyright INRIA
+//To plot the grid of iso-gain and iso-phase of y/(1+y) use abaque()
+//%Example
+//  s=poly(0,'s')
+//  h=syslin('c',(s**2+2*0.9*10*s+100)/(s**2+2*0.3*10.1*s+102.01))
+//  abaque();
+//  black(h,0.01,100,'(s**2+2*0.9*10*s+100)/(s**2+2*0.3*10.1*s+102.01)')
+//  //
+//  h1=h*syslin('c',(s**2+2*0.1*15.1*s+228.01)/(s**2+2*0.9*15*s+225))
+//  black([h1;h],0.01,100,['h1';'h'])
+//See also:
+//  bode nyquist  abaque freq repfreq 
+//!
+[lhs,rhs]=argn(0);
+pas_def='auto' //
+//
+//
+ilf=0
+typ=type(sl)
+//-compat next line added for list/tlist compatibility
+if typ==15 then typ=16,end
+select typ
+case 16 then  // sl,fmin,fmax [,pas] [,comments]
+  typ=sl(1);typ=typ(1);
+  if typ<>'lss'&typ<>'r' then
+    error(97,1)
+  end
+  select rhs
+  case 1 then //sl
+   comments=' '
+   [frq,repf]=repfreq(sl);
+   [d,phi]=dbphi(repf);
+   sl=[] 
+  case 2 then // sl,frq
+   comments=' '
+   [frq,repf]=repfreq(sl,fmin);
+   [d,phi]=dbphi(repf);
+   fmin=[];sl=[]
+  case 3 ,
+   if type(fmax)==1 then
+      comments=' '
+      [frq,repf]=repfreq(sl,fmin,fmax,pas_def),
+      [d,phi]=dbphi(repf);
+      sl=[]
+   else
+      comments=fmax
+      [frq,repf]=repfreq(sl,fmin);
+      [d,phi]=dbphi(repf);
+      fmin=[];sl=[]
+   end
+  case 4 ,
+    if type(pas)==1 then 
+      comments=' ',
+    else 
+      comments=pas;pas=pas_def
+    end,
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  case 5 then,
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  else 
+    error('invalid call: sys,fmin,fmax [,pas] [,com]')
+  end;
+//bode(sl,fmin,fmax,pas,comments)
+case 1 then //frq,db,phi [,comments] or frq, repf [,comments]
+  select rhs
+  case 2 , //frq,repf
+    comments=' '
+    [phi,d]=phasemag(fmin),fmin=[]
+  case 3 then
+    if type(fmax)==1 then
+      comments=' '//frq db phi
+      d=fmin,fmin=[]
+      phi=fmax,fmax=[]
+    else
+      [phi,d]=phasemag(fmin);fmin=[]
+      comments=fmax
+     end;
+   case 4 then 
+     comments=pas;d=fmin;fmin=[];phi=fmax;fmax=[]
+   else 
+     error('invalid call :frq,db,phi,[com] ou frq,repf,[com]')
+   end;
+   frq=sl;sl=[];[mn,n]=size(frq);
+   if mn<>1 then
+      ilf=1;
+   else
+      ilf=0;
+   end;
+else 
+   error('invalid call to black')
+end;
+
+[mn,n]=size(phi);
+//
+if comments==' ' then
+   comments(mn)=' ';
+   mnc=0;
+   strf='051'
+else
+   mnc=mn;
+  strf='151'
+end;
+xmn=floor(min(phi)/90)*90
+xmx=ceil(max(phi)/90)*90
+ymn=min(d)
+ymx=max(d)
+rect=[ymn;xmn;ymx;xmx]
+//[xmn,xmx,npx]=graduate(-360,0)
+//[ymn,ymx,npy]=graduate(mini(d),maxi(d))
+rect=[xmn,ymn,xmx,ymx]
+leg=strcat(comments,'@')
+
+//plot2d(phi',d',(1:mn),strf,leg,rect,[10,npx,10,npy]);
+plot2d(phi',d',(1:mn),strf,leg,rect);
+kf=1
+phi1=phi+5*ones(phi);
+xgeti=xget("mark");
+xset("mark",2,xgeti(2));
+xset("clipgrf");
+
+
+
+kk=1;p0=[phi(:,kk) d(:,kk)];ks=1;dst=0;
+dx=rect(3)-rect(1)
+dy=rect(4)-rect(2)
+dx2=dx^2;dy2=dy^2
+
+while kk<n
+  kk=kk+1
+  dst=dst+mini(((phi(:,kk-1)-phi(:,kk))^2)/dx2+((d(:,kk-1)-d(:,kk))^2)/dy2)
+  if dst>0.001 then
+  if mini(abs(frq(:,ks(prod(size(ks))))-frq(:,kk))./frq(:,kk))>0.2 then
+   ks=[ks kk]
+   dst=0
+  end
+  end
+end
+kf=1
+for k=1:mn,
+    xnumb(phi(k,ks),d(k,ks),frq(kf,ks),0);
+    xpoly(phi(k,ks),d(k,ks),'marks',0);
+  kf=kf+ilf
+end;
+xclip();
+xtitle('h(2i.pi.f) ','phase','magnitude');
+//     contour 2.3 db
+mbf=2.3;
+lmda=exp(log(10)/20*mbf);
+r=lmda/(lmda**2-1);
+npts=100;
+crcl=exp(%i*(-%pi:(2*%pi/npts):%pi));
+lgmt=log(-r*crcl+r*lmda*ones(crcl));
+plot2d([180*(imag(lgmt)/%pi-ones(lgmt))]',[(20/log(10)*real(lgmt))]',...
+     [2,-(mnc+1)],"100",'2.3db curve'),
+xset("mark",xgeti(1),xgeti(2));
+endfunction
diff --git a/scilab/modules/graphics/macros/bode.sci b/scilab/modules/graphics/macros/bode.sci
new file mode 100644 (file)
index 0000000..2e6dff3
--- /dev/null
@@ -0,0 +1,196 @@
+function []=bode(sl,fmin,fmax,pas,comments)
+//!
+// Copyright INRIA
+[lhs,rhs]=argn(0);
+dom='c';
+//---------------------
+nyq_frq=[];l10=log(10);
+pas_def='auto' // default
+ilf=0
+typ=type(sl)
+//-compat next line added for list/tlist compatibility
+if typ==15 then typ=16,end
+select typ
+case 16 then  // sl,fmin,fmax [,pas] [,comments]
+  typ=sl(1);typ=typ(1);
+  if typ<>'lss'&typ<>'r' then
+    error(97,1)
+  end
+  if typ=='lss' then
+    if sl(7)==[] then error('Undefined time domain (sl(7))');end
+  end
+  if typ=='r' then
+    if sl(4)==[] then error('Undefined time domain (sl(4))');end
+  end
+  dom=sl('dt')
+  if dom==[]|dom==0 then error(96,1),end
+  if dom=='d' then dom=1;end
+  
+  select rhs
+  case 1 then //sl
+   comments=' '
+   fmin_default=1.d-3;
+   fmax_default=1.d3;
+
+   if dom=='c' then fmax_default=1.d3; else fmax_default=1/(2*dom),end
+   [frq,repf]=repfreq(sl,fmin_default,fmax_default);
+   [d,phi]=dbphi(repf);
+   sl=[] 
+  case 2 then // sl,frq
+   comments=' '
+   if min(fmin)<=0 then
+     error('bode: requires strictly positive frequency vector')
+   end
+   [frq,repf]=repfreq(sl,fmin);
+   [d,phi]=dbphi(repf);
+   fmin=[];sl=[]
+  case 3 , //sl,frq,comments ou sl,fmin,fmax
+   if type(fmax)==1 then
+      comments=' '
+      if fmin<=0 then
+         error('bode: requires strictly positive frequency range')
+       end
+      [frq,repf]=repfreq(sl,fmin,fmax,pas_def),sl=[]
+      [d,phi]=dbphi(repf);
+   else
+      comments=fmax
+      if min(fmin)<=0 then
+       error('bode: requires strictly positive frequency vector')
+      end      
+      if type(dom)==1 then nyq_frq=1/2/dom;end
+      if find(fmin>nyq_frq)~=[] then 
+       warning('There are frequencies beyond Nyquist f!');
+      end
+      [frq,repf]=repfreq(sl,fmin);fmin=[];sl=[]
+      [d,phi]=dbphi(repf);
+   end
+  case 4 ,
+    if type(pas)==1 then 
+      comments=' ',
+    else 
+      comments=pas;pas=pas_def;
+    end,
+    if min(fmin)<=0 then
+      error('bode: requires strictly positive frequency vector')
+    end
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  case 5 then,
+    if min(fmin)<=0 then
+      error('bode: requires strictly positive frequency vector')
+    end
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  else 
+    error('Invalid call: sys,fmin,fmax [,pas] [,com]')
+  end;
+
+case 1 then //frq,db,phi [,comments] ou frq, repf [,comments]
+  select rhs
+  case 2 , //frq,repf
+    comments=' '
+    [phi,d]=phasemag(fmin);fmin=[]
+  case 3 then
+    if type(fmax)==1 then
+      comments=' '//frq db phi
+      d=fmin,fmin=[]
+      phi=fmax,fmax=[]
+    else
+      [phi,d]=phasemag(fmin);fmin=[]
+      comments=fmax
+     end;
+   case 4 then 
+     comments=pas;d=fmin;fmin=[];phi=fmax;fmax=[]
+   else 
+     error('Invalid call: frq,db,phi,[com] or frq,repf,[com]')
+   end;
+   frq=sl;sl=[];[mn,n]=size(frq);
+   if min(frq)<=0 then
+     error('bode: requires strictly positive frequencies')
+   end
+   if mn<>1 then
+      ilf=1;//un vecteur de frequences par reponse
+   else
+      ilf=0;//un seul vecteur de frequence
+   end;
+else 
+   error('Bode: invalid call')
+end;
+[mn,n]=size(phi)
+//
+//Captions
+if comments==' ' then
+   comments(mn)=' ';
+   mnc=0
+   hx=0.48
+   else
+   mnc=mn
+   hx=0.43
+end;
+
+[wrect,frect]=xgetech();
+//magnitude
+xsetech(wrect=[wrect(1)+0,wrect(2)+0,wrect(3)*1.0,wrect(4)*hx*0.95]);
+rect=[mini(frq),mini(d),maxi(frq),maxi(d)]
+// just to fix the scales for xgrid
+plot2d1("oln",mini(frq),mini(d),0,"051"," ",rect);
+// xgrid first 
+xgrid(4);
+// now the curves 
+plot2d1("oln",frq',d',[1:mn],"000"," ",rect);
+if type(dom)==1 then
+  [xx1,xx2]=xgetech();
+  val= xx2([2;4])';
+  plot2d1("oln",max(frq)*[1;1],val,5,"000"," ",rect);
+end
+xtitle('Magnitude ',' Hz','db');
+//phase
+xsetech(wrect=[wrect(1)+0,wrect(2)+wrect(4)*hx,wrect(3)*1.0,wrect(4)*hx*0.95]);
+
+// get the axes of the phase
+if ( get("figure_style") == "new" ) then
+  sciCurAxes = get("current_axes") ;
+end
+
+rect=[mini(frq),mini(phi),maxi(frq),maxi(phi)]
+// just to fix the scales for xgrid
+plot2d1("oln",mini(frq),mini(phi),0,"051"," ",rect);
+xgrid(4);
+//  now the curves
+plot2d1("oln",frq',phi',[1:mn],"000");
+
+if type(dom)==1 then
+  [xx1,xx2]=xgetech();
+  val= xx2([2;4])';
+  plot2d1("oln",max(frq)*[1;1],val,5,"000");
+end
+xtitle('Phase ',' Hz','degrees');
+
+// create legend
+if mnc>0 then
+  xsetech([wrect(1)+0,wrect(2)+wrect(4)*2*hx,wrect(3)*1.0,wrect(4)*0.1],[0 0 1 1]);
+  dash=xget('color')
+  y0=0.7;dy=-1/2
+  x0=0;dx=1/2
+  count=0
+  for k=1:mnc
+    xset('color',k)
+    xsegs([x0;x0+0.08],[y0;y0])
+    rect=xstringl(x0+0.1,y0,comments(k))
+    xset('color',dash(1));
+    xstring(x0+0.1,y0-rect(4)/3,comments(k))
+    count=count+1
+    y0=y0+dy
+    if count==3 then x0=x0+dx;y0=0.7,end
+  end
+  xset('color',dash(1))
+end
+
+// return to the previous scale
+if ( get("figure_style") == "old" ) then
+  xsetech(wrect,frect);
+else
+  set( "current_axes", sciCurAxes ) ;
+end
+
+endfunction
diff --git a/scilab/modules/graphics/macros/buildmacros.sce b/scilab/modules/graphics/macros/buildmacros.sce
new file mode 100644 (file)
index 0000000..793e542
--- /dev/null
@@ -0,0 +1,9 @@
+//------------------------------------
+// Allan CORNET        INRIA 2005
+// Jean-Baptiste Silvy INRIA 2006
+//------------------------------------
+SCI=getenv('SCI'); 
+TMPDIR=getenv('TMPDIR');
+//------------------------------------
+genlib('graphics','SCI/modules/graphics/macros');
+//------------------------------------
diff --git a/scilab/modules/graphics/macros/chart.sci b/scilab/modules/graphics/macros/chart.sci
new file mode 100644 (file)
index 0000000..440ebb7
--- /dev/null
@@ -0,0 +1,116 @@
+function []=chart(attenu,angl,flags)
+       
+       // Copyright INRIA
+       titre='amplitude and phase contours of y/(1+y)'
+       l10=log(10);
+       ratio=%pi/180;
+       //
+       [lhs,rhs]=argn(0)
+       
+       select rhs
+       
+       case 3 then
+       
+       case 2 then,
+               if type(angl)==15 then
+                       flags=angl
+                       angl=-[1:10,20:10:160]*ratio;
+               else
+                       angl=-angl*ratio
+                       flags=[]
+               end
+       
+       case 1 then
+               
+               if type(attenu)==15 then
+                       flags=attenu
+                       attenu=[-12 -8 -6 -5 -4 -3 -2 -1.4 -1 -.5 ,..
+                               0.25 0.5 0.7 1 1.4 2 2.3 3 4 5 6 8 12];
+               else
+                       flags=list()
+               end
+               angl=-[1:10,20:10:160]*ratio;
+       
+       else
+               flags=list()
+               attenu=[-12 -8 -6 -5 -4 -3 -2 -1.4 -1 -.5 ,..
+                               0.25 0.5 0.7 1 1.4 2 2.3 3 4 5 6 8 12];
+               angl=-[1:10,20:10:160]*ratio
+       end
+       
+       select size(flags)
+               case 0 then
+                       flags=list(0,-1,1,2)
+               case 1 then
+                       flags=list(flags(1),-1,1, 2)
+               case 2 then
+                       flags=list(flags(1),flags(2), 1, 2)
+               case 3 then
+                       flags(4)=2
+       end
+       //
+       rect=[-360,-50,0,40];
+       strf='011'
+       if flags(1) then 
+               strf='000',
+       else
+               rect=[-360,-50,0,40];
+               plot2d(0,0,flags(3),strf," ",rect,[2,6,3,9]);
+       end
+       
+       [r1,r2]=xgetech();
+       //
+       if get('figure_style')<>'old' then drawlater(),end
+       if flags(2) then xtitle(titre,'phase(y) - degree','magnitude(y) - db'),end
+       llrect=xstringl(0,0,'1')
+       //contours de gain constant
+       lambda=exp(l10*attenu/20)
+       rayon=lambda./(lambda.*lambda-ones(lambda))
+       centre=-lambda.*rayon
+       //
+       for i = 1:prod(size(attenu)),
+               if attenu(i)<0 then 
+                       w=%eps:0.03:%pi;
+               else 
+                       w=-%pi:0.03:0;
+               end;
+               n=prod(size(w))
+               rf=centre(i)*ones(w)+rayon(i)*exp(%i*w);
+               phi=atan(imag(rf),real(rf))/ratio;
+               module=20*log(abs(rf))/l10;
+               plot2d([-360*ones(phi)-phi(n:-1:1) phi]',...
+               [module(n:-1:1) module]',[flags(3),flags(4)],"000");
+               att=attenu(i);
+               if att<0 then 
+                       xstring(phi(n)+llrect(3),module(n),string(att),0,0);
+               else 
+                       xstring(phi(1),module(1)+llrect(4)/4,string(att),0,0);
+               end
+               if flags(1)&r2(3)>0 then
+                       plot2d([-phi(n:-1:1) 360*ones(phi)+phi]',...
+                               [module(n:-1:1) module]',[flags(3),flags(4)],"000");
+               end
+       end;
+       
+       //phase
+       
+       eps=100*%eps;
+       for teta=angl,
+               if teta < -%pi/2 then
+                       last=teta-eps,
+               else
+                       last=teta+eps,
+               end;
+               w=[-170*ratio:0.03:last last]'
+               n=prod(size(w));
+               module=real(20*log((sin(w)*cos(teta)/sin(teta)-cos(w)))/l10)
+               w=w/ratio
+               plot2d([w,-360*ones(w)-w(n:-1:1)],[module,module(n:-1:1)],[flags(4),flags(4)],"000");
+               if flags(1)&r2(3)>0 then
+                       plot2d(360+[w,-360*ones(w)-w(n:-1:1)],[module,module(n:-1:1)],[flags(4),flags(4)],"000");
+               end
+       end;
+       if get('figure_style')<>'old' then
+               drawnow()
+       end
+endfunction
diff --git a/scilab/modules/graphics/macros/check2dFun.sci b/scilab/modules/graphics/macros/check2dFun.sci
new file mode 100644 (file)
index 0000000..e093e0b
--- /dev/null
@@ -0,0 +1,55 @@
+function [nArgOut,vectInput]=check2dFun(funName,func,X,current_figure,cur_draw_mode)
+
+// In this function we determine wether the function 'func'
+// has the syntax [y]=func(x) or [x,y]=func(t). 
+// We also test if the function accepts vector input
+// arguments.
+//
+// This allow to understand in a 2d plot function (plot)
+// if the user has requested a 2d plot of a parametric or
+// non-parametric curve. 
+
+// First We get the two strings in and out containing the
+// names of input and output arguments :
+
+[out,in,text]=string(func);
+
+nArgOut=max(size(out));
+nArgIn=max(size(in))
+
+if nArgIn~=1
+   warning(sprintf('%s : function must accept two input arguments',funName));
+   ResetFigureDDM(current_figure, cur_draw_mode)
+   return;
+end
+
+if nArgOut~=1 & nArgOut~=2
+   warning(sprintf('%s : function must have 1 or 2 output arguments',funName));
+   ResetFigureDDM(current_figure, cur_draw_mode)
+   return;
+end
+
+// Now we test if func accepts vector inputs (we test with the X,Y
+// pair provided by the user)
+
+if nArgOut==1;
+
+   ierr=execstr('yf=func(X)','errcatch');
+   if ierr==0
+      vectInput=(and(size(yf)==size(X)));
+   else
+      vectInput=%F;
+   end
+
+elseif nArgOut==2
+  
+  // now we test if func accepts vector inputs (as above)
+  
+  xf=[];yf=[];
+  ierr=execstr('[xf,yf]=func(X)','errcatch');
+  vectInput=(ierr==0 & and([size(xf)==size(yf) ... 
+                           size(yf)==size(X)]));
+end
+
+endfunction
diff --git a/scilab/modules/graphics/macros/checkXYPair.sci b/scilab/modules/graphics/macros/checkXYPair.sci
new file mode 100644 (file)
index 0000000..afc0efe
--- /dev/null
@@ -0,0 +1,140 @@
+function [X,Y]=checkXYPair(typeOfPlot,x,y,current_figure,cur_draw_mode)
+
+  ok=%F;
+
+  if type(y)==13 // If y is a function
+    f=y;
+    if and(size(x)~=1)  // then x *must* be a vector
+      warning(sprintf('%s : x must be a vector',typeOfPlot));
+      ResetFigureDDM(current_figure, cur_draw_mode);
+      return;
+    end
+
+    t=x(:); // to ensure that t is a column vector
+
+    [nArgOut,vectInput]=check2dFun(typeOfPlot,f,t,current_figure,cur_draw_mode);
+
+    if nArgOut==1
+      X=t;
+      if vectInput
+       Y=f(t);
+      else
+       Y=zeros(length(t),1);
+       for i=1:length(t)
+         Y(i)=f(t(i));
+       end
+      end
+    elseif nArgOut==2
+      if vectInput
+       [X,Y]=f(t);
+      else
+       X=zeros(length(t),1);
+       Y=zeros(length(t),1);
+       for i=1:length(t)
+
+         // CANNOT DO THE SAME WITH X(i) and Y(i)
+         // instead of xt and yt (scilab parser sees the stuff 
+         // as a comparison)
+
+         [xt,yt]=f(t(i));
+         X(i)=xt;Y(i)=yt;
+       end
+      end
+    end
+
+  else // "classical" case
+
+    X=x;
+    Y=y;
+
+    if size(X,1)==1, X=X', end;  // si l'un des vecteurs est une ligne
+    if size(Y,1)==1, Y=Y', end;  // on le transpose.
+    
+    if size(X)==[0 0] | size(Y)==[0 0]
+      ok=%F
+      str='plot error : empty input data';
+      warning(str);
+      ResetFigureDDM(current_figure, cur_draw_mode)
+      return;
+    end
+    
+    if and(size(X)==size(Y))  // si les tailles sont egales
+      ok=%T;
+      //    disp("I.)")
+      return
+    end
+
+    if (size(X,2)==1) & (size(Y,1)==size(X,1))
+      ok=%T;
+      //    pause;
+      //    disp("II.)")
+      return;
+    end
+
+    if (size(X,2)==1) & (size(Y,2)==size(X,1))
+      Y=Y';
+      ok=%T;
+      //    disp("III.)")
+      //    return;
+    end
+    
+
+    // new case : plot(MAT4x4,[1 2 3 4]) HERE Y is a vector and X a matrix
+    // extend y to be a 4x4 matrix defined as [1 1 1 1;2 2 2 2;3 3 3 3;4 4 4 4]
+    if or(size(Y) == 1)
+      if size(X,1) == size(Y,1)
+       //      disp("ENTRE 1!")
+       //      pause;
+       y=Y;
+       Y=[];
+       for i=1:size(X,2)
+         Y = [Y y]; 
+       end
+       //      disp("FINI")
+       //      pause;
+      elseif size(X,1) == size(Y,2)
+       //      disp("ENTRE 2!")
+       //      pause;
+       y=Y(:);
+       Y=[];
+       for i=1:size(X,2)
+         Y = [Y y]; 
+       end
+      elseif size(X,2) == size(Y,1)
+       //      disp("ENTRE 3!")
+       //      pause;
+       X=X';
+       y=Y(:);
+       Y=[];
+       for i=1:size(X,2)
+         Y = [Y y]; 
+       end
+       //      disp("FIN...!")
+       //      pause;
+      elseif size(X,2) == size(Y,2)
+       //      disp("ENTRE 4!")
+       //      pause;
+       y=Y;
+       Y=[];
+       for i=1:size(X,1)
+         Y = [Y y]; 
+       end
+      end
+      
+      //    disp("IV.)")
+      ok=%T;
+      return;
+    end
+    
+    
+    if ~ok
+      str='plot : incompatible dimensions of data arguments';
+      warning(str);
+      ResetFigureDDM(current_figure, cur_draw_mode)
+    end
+
+  end
+
+  // end of checkXYPair
+endfunction
+
diff --git a/scilab/modules/graphics/macros/clear_pixmap.sci b/scilab/modules/graphics/macros/clear_pixmap.sci
new file mode 100644 (file)
index 0000000..381e36b
--- /dev/null
@@ -0,0 +1,3 @@
+function clear_pixmap()
+  xset('wwpc')
+endfunction
diff --git a/scilab/modules/graphics/macros/clf.sci b/scilab/modules/graphics/macros/clf.sci
new file mode 100644 (file)
index 0000000..efe3149
--- /dev/null
@@ -0,0 +1,60 @@
+function clf(varargin)
+// This function is dedicated to the new graphics mode only
+// If called in old mode, it performs a basic 'xbasc' call.
+newstyle = get('figure_style')=='new'
+if ~newstyle
+  xbasc();
+  return;
+end
+
+if size(varargin)==0 then
+  h=gcf()
+  job='clear'
+elseif size(varargin)==1 then
+  if type(varargin(1))==1 then // win num given
+    num=varargin(1)
+    f=gcf();
+    h=[];for k=1:size(num,'*'),h=[h;scf(num(k))];end
+    scf(f);
+    job='clear'
+  elseif type(varargin(1))==9 then // handle given
+    h=varargin(1);job='clear'
+  elseif type(varargin(1))==10 then // job given
+    h=gcf()
+    job=varargin(1)
+  end
+elseif size(varargin)==2 then
+  if type(varargin(1))==1 then // win num given
+    num=varargin(1)
+    f=gcf();
+    h=[];for k=1:size(num,'*'),h=[h;scf(num(k))];end
+    scf(f);
+  elseif type(varargin(1))==9 then // handle given
+    h=varargin(1);
+  end
+  job=varargin(2);
+else
+  error('clf must be called with at most 2 arguments')
+end
+if and(job<>['clear','reset']) then 
+  error('clf: job argument possible values are '"clear"' or '"reset"'')
+end
+for k=1:size(h,'*') 
+  hk=h(k)
+  if stripblanks(hk.type)<>'Figure' then
+    error('handle should be of type '"Figure"'')
+  end
+  c=hk.children;
+  vis=hk.visible;hk.visible='off';
+  //delete(c)
+  for i=1:size(c,'*'),delete(c(i)),end
+  hk.visible=vis
+  if job=='reset' then
+    props=['axes_size','auto_resize','figure_name','color_map','pixmap','pixel_drawing_mode','background','visible','rotation_style']
+    df=gdf()
+    for p=props
+      hk(p)=df(p)
+    end
+  end
+end
+endfunction
diff --git a/scilab/modules/graphics/macros/color.sci b/scilab/modules/graphics/macros/color.sci
new file mode 100644 (file)
index 0000000..6091aca
--- /dev/null
@@ -0,0 +1,50 @@
+function id=color(c1,c2,c3)\r
+// get a color from the current colormap\r
+// or add it to current colormap if it does not exist\r
+// Copyright INRIA\r
+\r
+[lhs,rhs]=argn(0)\r
+if rhs==1 then \r
+  if (type(c1)<>10 | size(c1,"*")<>1) then\r
+    error("color: argument must be a string")\r
+  else\r
+    c=name2rgb(c1);\r
+    if c==[] then\r
+      error(""""+c1+""" is not a known color")\r
+    end\r
+    c=c/255;\r
+  end\r
+elseif rhs==3 then\r
+  if (type(c1)<>1 | type(c2)<>1 | type(c3)<>1 | size(c1,"*")<>1 | size(c2,"*")<>1 | size(c3,"*")<>1) then\r
+    error("color: arguments must be integers")\r
+  end\r
+  if (c1>255 | c1<0 | c2>255 | c2<0 | c3>255 | c3<0) then\r
+    error("color: arguments must be integers between 0 and 255")\r
+  end\r
+  c=[c1,c2,c3]/255;\r
+else\r
+  error("function ""color"" must have 1 or 3 arguments")\r
+end\r
+\r
+if get("figure_style")=="old" then\r
+  cmap=xget("colormap");\r
+else\r
+  f=gcf();\r
+  cmap=f.color_map;\r
+end\r
+ncol=max(size(cmap,"r"));\r
+k=find(abs(cmap-ones(ncol,1)*c)*ones(3,1)<=1.d-5);\r
+if k==[] then\r
+  // color does not exist, add it\r
+  cmap=[cmap;c];\r
+  id=ncol+1;\r
+  if get("figure_style")=="old" then\r
+    xset("colormap",cmap);\r
+  else\r
+    f.color_map=cmap;\r
+  end\r
+else\r
+  id=k(1);\r
+end\r
+\r
+endfunction\r
diff --git a/scilab/modules/graphics/macros/colorbar.sci b/scilab/modules/graphics/macros/colorbar.sci
new file mode 100644 (file)
index 0000000..f16c25e
--- /dev/null
@@ -0,0 +1,142 @@
+function colorbar(umin, umax, colminmax,fmt)
+
+//  PURPOSE
+//     Draw a colorbar for a plot3d, fec, Sgrayplot, etc...
+//
+//  PARAMETERS
+//     umin : min value of the plot
+//     umax : max value of the plot
+//     colminmax : (optional) a vector with 2 integer components
+//                 the first is the color number (of the current
+//                 colormap) associated with umin
+//                 the second the max color number ....
+//                 default : [1 nb_colors] where nb_colors is
+//                 the number of colors of the current colormap.
+//                 May be useful to deal with a part of the colormap
+//                 (for instance using fec or plot3d)
+//     fmt : optional, a C format to display colorbar graduations 
+//                 
+//  CAUTION
+//     this function may be used BEFORE a plot3d, fec, Sgrayplot, ...
+//     It is important because this function set and change the
+//     frame for the plot. This way the colorbar is not part of 
+//     the "associated" plot and so is not modified by a zoom or 
+//     a rotation of the plot.
+//
+//  AUTHORS
+//     Bruno Pincon
+//     Serge Steer (adaptation to new graphic system)
+//
+//  EXAMPLES
+//     see the help page
+  
+  nb_grad = 5
+  if ~exists("fmt","local") then 
+    fmt='%-5.2g'
+  else
+    if type(fmt)<>10|size(fmt,'*')<>1 then 
+      error("colorbar: the fmt argument should be a string containing a C format")
+    end
+  end
+  
+  if get('figure_style')=='old' then
+    if ~exists("colminmax","local") then 
+      nb_colors = xget("lastpattern") // modif for bug 1122 (bruno 7 december 2004)
+      colminmax = [1 nb_colors]
+    else
+      nb_colors = colminmax(2) - colminmax(1) + 1
+    end
+    
+    // go on... 
+    vec_ones = ones(1,nb_colors)
+
+    x1 = -0.3 ; x2 = 0.1 ; 
+    x_polys = [x1 ; x2 ; x2 ; x1] * vec_ones
+    y1 = 0.1 ; y2 = 0.9
+    y = linspace(y1,y2,nb_colors+1)
+    y_polys = [y(1:$-1) ; y(1:$-1) ; y(2:$) ; y(2:$)] 
+    
+    xtics = x2*ones(1,nb_grad) ; dx_tics = 0.05 ; 
+    ytics = linspace(y1, y2, nb_grad) ; dy_tics = 0
+
+    valeurs = linspace(umin,umax,nb_grad);
+    rect = xstringl(0, 0, string(umin))
+    dy_cor = -rect(4)*0.5
+    xmarks = xtics + 3*dx_tics ; ymarks = ytics + dy_cor; 
+
+    fg_color = xget("foreground")
+
+    wr = xgetech()
+    wrect_cb = [wr(1)+0.85*wr(3) , wr(2) , 0.15*wr(3) , wr(4)]
+    wrect_pl = [wr(1) , wr(2) , 0.85*wr(3) , wr(4)]
+    xsetech(wrect=wrect_cb,frect=[0 0 1 1], arect=0.125*[1 1 1 1])
+
+    
+    xfpolys(x_polys, y_polys, -(colminmax(1):colminmax(2)))
+    xset("color", fg_color) ;
+    xpoly([x1 x2 x2 x1],[y1 y1 y2 y2],"lines",1)
+    lab=msprintf(fmt+'\n',valeurs(:))
+    for k=1:size(xmarks,'*')
+      xstring(xmarks(k), ymarks(k) ,lab(k))
+    end
+    xsegs([xtics ; xtics+dx_tics ],[ytics ; ytics+dy_tics],fg_color)
+    
+    xsetech(wrect=wrect_pl)
+  else //new graphic mode
+    f=gcf();
+    if ~exists("colminmax","local") then 
+      nb_colors = size(f.color_map,1) 
+      colminmax = [1 nb_colors]
+    else
+      nb_colors = colminmax(2) - colminmax(1) + 1
+    end
+    
+    //defer the drawing to avoid binking
+    id=f.immediate_drawing=='on';
+    if id then f.immediate_drawing=='off',end
+
+    // get current axes and properties
+    a=gca(); 
+    fg_color=a.foreground
+    wr=a.axes_bounds; //get the rectangle of the current axes
+    
+    // modify the orginal axes to let space for the colorbar
+    a_pl=a;
+    a_pl.axes_bounds=[wr(1) , wr(2) , 0.85*wr(3) , wr(4)]
+
+    // create a new axes for the colorbar et set its properties
+    a_cb=newaxes(); 
+    a_cb.axes_bounds=[wr(1)+0.83*wr(3) , wr(2)+wr(4)*0.2 , 0.2*wr(3) , wr(4)*0.6];
+    a_cb.data_bounds=[0 umin;1 umax];
+    a_cb.foreground=a.foreground;
+    a_cb.background=f.background;
+    a_cb.axes_visible='on';
+    a_cb.y_location = "right";
+    a_cb.tight_limits ="on";
+    
+    //It is not possible to set no ticks for x (should be fixed)
+    a_cb.x_ticks=tlist(["ticks","locations","labels"],-1,'');
+    ytics = linspace(umin, umax, nb_grad);
+    a_cb.y_ticks=tlist(["ticks","locations","labels"],ytics', ' '+msprintf(fmt+'\n',ytics'));
+    a_cb.auto_ticks = ["off","off","on"];
+    a_cb.box = "on";
+    a_cb.margins=[0 0.75 0 0];
+
+    
+    //draw the colorbar
+    y = linspace(umin,umax,nb_colors+1)
+    col=[colminmax(1) colminmax(1):colminmax(2)]
+    Sgrayplot([0 1],y,[col;col],colminmax=colminmax)
+
+    //reset the initial values 
+    sca(a_pl) //current axes
+    if id then f.immediate_drawing='on',end //drawing mode
+
+  end
+endfunction
+
+
+
+
+
+
diff --git a/scilab/modules/graphics/macros/colordef.sci b/scilab/modules/graphics/macros/colordef.sci
new file mode 100644 (file)
index 0000000..00c78a1
--- /dev/null
@@ -0,0 +1,40 @@
+function colordef(a1,a2)
+  if type(a1)==9 then //a handle
+    f=gcf();a=gca();a1=a2
+    if f.type<>'Figure' then 
+      error('First argument shoud be a handle on a figure'),
+    end
+  elseif a1=='new' then
+    n=winsid();if n==[] then n=0;else n=max(n+1),end
+    f=scf(n)
+    a=gca();a1=a2
+  else
+    f=gdf();a=gda();
+  end
+  
+  if type(a1)<>10 then  error(44,1),  end
+
+  select convstr(a1)
+  case 'white'
+    f.color_map=[jetcolormap(64);[1 1 1]*0.8];
+    f.background=65;f.foreground=-1;
+    a.background=-2;a.foreground=-1;
+    a.font_color=a.foreground;
+    a.mark_foreground=a.foreground;
+  case 'black'
+    if MSDOS then c=0.2, else c=0.35,end
+    f.color_map=[jetcolormap(64);[1 1 1]*c];
+    f.background=65;f.foreground=-2;
+    a.background=-1;a.foreground=-2;
+    a.font_color=a.foreground;
+    a.mark_foreground=a.foreground;
+  case 'none'
+    f.color_map=[hsvcolormap(64)];
+    f.background=-1;f.foreground=-2;
+    a.background=-1;a.foreground=-2;
+    a.font_color=a.foreground;
+    a.mark_foreground=a.foreground;
+  else
+    error('Unknown color default option '+a1)
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/contour.sci b/scilab/modules/graphics/macros/contour.sci
new file mode 100644 (file)
index 0000000..38bd888
--- /dev/null
@@ -0,0 +1,115 @@
+function contour(x,y,z,nz,theta,alpha,leg,flag,ebox,zlev)
+  
+       rhs=argn(2);
+       if rhs == 0 then   // demo
+       
+               title_demo = [
+                       '';
+                       'Demo of contour()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf1(x,y)'',''z=x^2+y^3'');';
+                       'x=-1:0.1:1; y=x;'
+                       'subplot(211);contour(x,y,Surf1,10);'
+                       'deff(''[z]=Surf2(x,y)'',''z=x^2+y^2'');';
+                       'z=eval3d(Surf2,x,y)'
+                       'subplot(212);plot3d(x,y,z);contour(x,y,z+0.1,10,flag=[0 2 4]);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+  
+  if rhs<4, error('contour requires at least 4 arguments'),end;
+  levels=[]
+
+  opts=[]
+  if exists('theta','local')==1 then opts=[opts,'theta=theta'],end
+  if exists('alpha','local')==1 then opts=[opts,'alpha=alpha'],end
+  if exists('leg'  ,'local')==1 then opts=[opts,'leg=leg']    ,end
+  if exists('ebox' ,'local')==1 then opts=[opts,'ebox=ebox']  ,end
+  if exists('flag' ,'local')==0 then flag=[2 2 3], end
+  if exists('zlev' ,'local')==0 then zlev=0  ,end
+  
+  if or(type(z)==[11 13]) then 
+    fun=z;clear z //to avoid redfinition warning
+    if type(fun)==11 then comp(fun),end
+    z=feval(x,y,fun)
+  end
+  
+  job=flag(1)
+  if rhs==4|job==2 then  
+    contour2d(x,y,z,nz);
+    return,
+  end
+  
+  if  get('figure_style')=='old' then 
+    opts=strcat([opts,"flag=flag"],',')
+    execstr('oldcontour(x,y,z,nz,'+opts+')')
+    return,
+  end
+    
+  if size(nz,'*')==1 then
+    style=1:nz,
+  else
+    style=1:size(nz,'*')
+  end
+  
+  opts=strcat([opts,'flag=flag(2:3)'],',');
+
+  [xc,yc]=contour2di(x,y,z,nz);
+
+
+  fig=gcf();
+  autoc=fig.auto_clear;
+  if autoc=="on" then, xbasc(),end
+  a=gca();
+  fg=a.foreground
+  v=fig.immediate_drawing;
+  fig.immediate_drawing="off"
+  fig.auto_clear="off"
+  cnt=0
+
+  fpf=xget("fpf");if fpf=='' then fpf='%.2g',end
+  k=1;n=yc(k); c=0; level = %inf;
+  while k < length(xc)
+    n = yc(k)
+    if xc(k) ~= level then 
+      c = c+1; level = xc(k),levels=[level levels];
+      a.foreground=c;
+      if cnt>0 then glue(a.children(1:cnt)),cnt=0,end
+    end
+    
+    if job==1 then zz=zlev,else zz=level,end
+    execstr('param3d(xc(k+(1:n)),yc(k+(1:n)),zz*ones(1,n),'+opts+')')
+    
+    cnt = cnt+1
+    if stripblanks(fpf)<>'' then
+      xstring(xc(k+1+n/2),yc(k+1+n/2)," "+msprintf(fpf,level))
+      e=gce();e.data(3)=zz
+      cnt=cnt+1
+    end
+    k=k+n+1;
+  end
+  if cnt>0 then glue(a.children(1:cnt)),cnt=0,end
+  set('current_obj',a);
+  a.foreground=fg
+  if flag(3)<2 then
+    a.axes_visible='off';
+    a.box='off';
+  elseif flag(3)==3 then
+    a.axes_visible='off';
+    a.box='on';
+   elseif flag(3)>=4 then
+    a.axes_visible='on';
+    a.box='on';
+  end
+  fig.immediate_drawing=v;
+  fig.auto_clear=autoc;
+endfunction
+
diff --git a/scilab/modules/graphics/macros/contour2d.sci b/scilab/modules/graphics/macros/contour2d.sci
new file mode 100644 (file)
index 0000000..413d5be
--- /dev/null
@@ -0,0 +1,115 @@
+function levels=contour2d(x,y,z,nz,style,strf,leg,rect,nax,void)
+opts=[]
+levels=[]
+if ~exists('style','local')==1 then 
+  if size(nz,'*')==1 then
+    style=1:nz,
+  else
+    style=1:size(nz,'*')
+  end
+end
+if exists('strf','local')==1 then 
+  yflag=part(strf,2)
+  if or(yflag==['2' '4' '6' '8']) then
+    rect=[min(x),min(y),max(x),max(y)]
+    yflag=string(evstr(yflag)-1)
+    strf=part(strf,1)+yflag+part(strf,3)
+  end
+  opts=[opts,'strf=strf'],
+end
+if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
+rectSpecified = %f ;
+if exists('rect','local')==1 then 
+  opts=[opts,'rect=rect'];
+  rectSpecified = %t ;
+end
+if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
+if exists('logflag','local')==1 then opts=[opts,'logflag=logflag'],end
+//if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
+if exists('frameflag','local')==1 then 
+  opts=[opts,'frameflag=frameflag'],
+else 
+  frameflag=[]
+end
+if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
+opts=strcat([opts,"style=style(c)"],',')
+
+if or(type(z)==[11 13]) then 
+  fun=z;clear z //to avoid redfinition warning
+  if type(fun)==11 then comp(fun),end
+  z=feval(x,y,fun)
+end
+
+[xc,yc]=contour2di(x,y,z,nz);
+fpf=xget("fpf");if fpf=='' then fpf='%.3g',end
+
+newstyle = get('figure_style')=='new'
+if newstyle then
+  fig=gcf();
+  autoc=fig.auto_clear;
+  if autoc=="on" then, xbasc(),end
+  a=gca();
+  v=fig.immediate_drawing;
+  fig.immediate_drawing="off"
+  fig.auto_clear="off"
+  cnt=0
+end
+
+// we draw the contour with call to plot2d for each level line
+// however the data_bounds will be always reset after each plot
+// so we must compute before the bounding rectangle (xmin,ymin,xmax,ymax)
+// and give it to each plot2d. This is useful for frameflag = (2,4,6,8)
+// since the data_bounds are given by the extrema of x and y
+if ( frameflag == 2 | frameflag == 4 | frameflag == 6 | frameflag == 8 )
+  // get the bounding rectangle
+  rect = [min(x),min(y),max(x),max(y)];
+  // set the option accordingly
+  if ~rectSpecified then
+    opts=strcat([opts,'rect=rect'],',');
+  end
+  // the rect will be taken into account
+  frameflag = frameflag - 1 ;
+end
+
+k=1;n=yc(k); c=0; level = %inf;
+while k < length(xc)
+   n = yc(k)
+   if xc(k) ~= level then 
+     c = c+1; level = xc(k),levels=[level levels];
+     if newstyle then 
+       if cnt>0 then glue(a.children(1:cnt)),cnt=0,end
+     end
+   end
+   err = execstr('plot2d(xc(k+(1:n)),yc(k+(1:n)),'+opts+')','errcatch','m');
+   frameflag = 0 ;
+   
+   // add a test to see if plot2d call succeed
+   // and, if not, restore good figure property values before exiting
+   if err <> 0
+     mprintf("Error %d : in plot2d called by contour2d",err);
+     if newstyle then
+       fig.immediate_drawing=v;
+       fig.auto_clear=autoc;
+     end
+     return;
+   end
+   
+   if newstyle then 
+      unglue(a.children(1))
+      cnt = cnt+1
+   end
+   if stripblanks(fpf)<>'' then
+      xstring(xc(k+1+n/2),yc(k+1+n/2)," "+msprintf(fpf,level))
+      if newstyle then cnt=cnt+1,end
+   end
+   k=k+n+1;
+end
+
+if newstyle then 
+   if cnt>0 then glue(a.children(1:cnt)),cnt=0,end
+   set('current_obj',a);
+   fig.immediate_drawing=v;
+   fig.auto_clear=autoc;
+end
+
+endfunction
diff --git a/scilab/modules/graphics/macros/contourf.sci b/scilab/modules/graphics/macros/contourf.sci
new file mode 100644 (file)
index 0000000..8614c57
--- /dev/null
@@ -0,0 +1,139 @@
+function contourf(x,y,z,nv,style,strf,leg,rect,nax)
+       
+       [nout,nin]=argn(0);
+       
+       newstyle = get('figure_style')=='new'
+       
+       if nin == 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of contourf()';
+                       '========================================';
+                       ''];
+               
+               s_mat=['t=-%pi:0.1:%pi;m=sin(t)''*cos(t);contourf(t,t,m);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+if nin <= 8 then nax=[1,10,1,10];end 
+if nin <= 7 then rect=[0,0,1,1];end
+if nin <= 6 then leg=" ";end 
+if nin <= 5 then strf="121";end 
+if nin <= 3 then zmin=mini(z);zmax=maxi(z);nv = zmin + (1:10)*(zmax-zmin)/(11);end 
+if nin <= 2 then z=rand(size(x,'*'),size(y,'*'));end 
+if nin <= 1 then y=1:10;end 
+if nin <= 0 then x=1:10;end 
+if x==[] then x=1:size(z,'r');end 
+if y==[] then y=1:size(z,'c');end 
+
+nvs=size(nv,'*') ;
+if nvs==1 then nvs=nv;zmin=mini(z);zmax=maxi(z);nv = zmin + (1:nvs)*(zmax-zmin)/(nvs+1);end;
+if nin <= 4 then style = -1*ones(1,nvs);end
+if nin <= 7 then rect=[mini(x),mini(y),maxi(x),maxi(y)]; end 
+nv1=nv
+[mz,nz] = size(z);
+minz = min(z);
+maxz = max(z);
+// Surround the matrix by a very low region to get closed contours, and
+// replace any NaN with low numbers as well.
+zz=[ %nan*ones(1,nz+2); %nan*ones(mz,1),z,%nan*ones(mz,1);%nan*ones(1,nz+2)];
+kk=find(isnan(zz(:)));
+zz(kk)=minz-1e4*(maxz-minz)+zeros(kk);
+
+xx = [2*x(1)-x(2); x(:); 2*x(mz)-x(mz-1)];
+yy = [2*y(1)-y(2); y(:); 2*y(nz)-y(nz-1)];
+
+// Internal call to get the contours 
+[x1,y1]=contour2di(xx,yy,zz,nv);
+CS=[x1;y1];
+// Find the indices of the curves in the c matrix, and get the
+// area of closed curves in order to draw patches correctly. 
+ii = 1;
+ncurves = 0;
+I = [];
+Area=[];
+
+while (ii < size(CS,2)),
+  nl=CS(2,ii);
+  ncurves = ncurves + 1;
+  I(ncurves) = ii;
+  xp=CS(1,ii+(1:nl));  // First patch
+  yp=CS(2,ii+(1:nl));
+  Area(ncurves)=sum( mtlb_diff(xp).*(yp(1:nl-1)+yp(2:nl))/2 );
+  ii = ii + nl + 1;
+end
+
+lp=xget('lastpattern');
+
+if size(nv,'*') > 1 // case where nv is a vector defining the level curve values
+  if  size(nv,'*') > lp ; write(%io(2),'Colormap too small');return ;end 
+else
+  if nv > lp ; write(%io(2),'Colormap too small');return ;end 
+end
+
+min_nv=mini(nv);
+max_nv=maxi(nv);
+
+plot2d([mini(xx);maxi(xx)],[mini(yy);maxi(yy)],0,strf,leg,rect,nax);
+
+// Plot patches in order of decreasing size. This makes sure that
+// all the lev1es get drawn, not matter if we are going up a hill or
+// down into a hole. When going down we shift levels though, you can
+// tell whether we are going up or down by checking the sign of the
+// area (since curves are oriented so that the high side is always
+// the same side). Lowest curve is largest and encloses higher data
+// always.
+
+draw_min=1;
+H=[];
+[FA,IA]=sort(abs(Area));
+
+if newstyle then
+  drawlater(); // postpon the drawing here
+  a=gca();
+  old_foreground = a.foreground;
+  pat=xget('pattern');
+  for jj=IA',
+    nl=CS(2,I(jj));
+    lev1=CS(1,I(jj));
+    if (lev1 ~= minz | draw_min),
+      xp=CS(1,I(jj)+(1:nl));  
+      yp=CS(2,I(jj)+(1:nl)); 
+      pat=size(find( nv <= lev1),'*');
+      xset("pattern",pat);
+      xfpoly(xp,yp)
+    end;
+  end
+  
+  if style(1)<>-1 then 
+    contour2d(xx,yy,zz,nv,style,"000",leg,rect,nax);
+  end
+  a.foreground = old_foreground;
+  drawnow(); // draw all now!
+else
+  pat=xget('pattern');
+  for jj=IA',
+    nl=CS(2,I(jj));
+    lev1=CS(1,I(jj));
+    if (lev1 ~= minz | draw_min),
+      xp=CS(1,I(jj)+(1:nl));  
+      yp=CS(2,I(jj)+(1:nl)); 
+      pat=size(find( nv <= lev1),'*');
+      xset("pattern",pat);
+      xfpoly(xp,yp)
+    end;
+  end
+  
+  xset('pattern',pat);
+  if style(1)<>-1 then 
+    contour2d(xx,yy,zz,nv,style,"000",leg,rect,nax);
+  end
+end
+
+endfunction
diff --git a/scilab/modules/graphics/macros/dragrect.sci b/scilab/modules/graphics/macros/dragrect.sci
new file mode 100644 (file)
index 0000000..039c351
--- /dev/null
@@ -0,0 +1,46 @@
+function [rects,btn]=dragrect(rects)
+  if size(rects,1)==1 then rects=rects(:),end
+  n=size(rects,2)
+  if get('figure_style')=='old' then
+    d=driver()
+    if d=='Rec' then driver('X11'),end
+    alu=xget('alufunction') ;xset('alufunction',6) //Xor mode
+
+    rep=[rects(1),rects(2),-1]
+
+    while rep(3)==-1 then
+      xrects(rects) //draw
+      if xget('pixmap') then xset('wshow'),end
+      repn=xgetmouse()
+      if repn(3)==-100  then //window has been closed 
+       driver(d)
+       btn=repn(3)
+       return
+      end
+      xrects(rects) //erase
+      if xget('pixmap') then xset('wshow'),end
+      rects(1:2,:)=rects(1:2,:)+(repn(1:2)-rep(1:2))'*ones(1,n)
+      rep=repn
+    end
+    driver(d) ;xset('alufunction',alu) //set modes back
+  else
+    f=gcf();pix=f.pixmap;f.pixmap='on';
+    xrects(rects) 
+    R=gce(); //Compound of rectangles
+    rep=[rects(1),rects(2),-1]
+    while rep(3)==-1 then
+      show_pixmap()
+      repn=xgetmouse()
+      if repn(3)==-100  then //window has been closed 
+       btn=repn(3)
+       return
+      end
+      rects(1:2,:)=rects(1:2,:)+(repn(1:2)-rep(1:2))'*ones(1,n);
+      move(R,repn(1:2)-rep(1:2))
+      rep=repn
+    end
+    f.pixmap=stripblanks(pix)
+    delete(R)
+  end
+  btn=rep(3)
+endfunction
diff --git a/scilab/modules/graphics/macros/edit_curv.sci b/scilab/modules/graphics/macros/edit_curv.sci
new file mode 100644 (file)
index 0000000..e01233f
--- /dev/null
@@ -0,0 +1,414 @@
+function [x,y,ok,gc]=edit_curv(x,y,job,tit,gc)
+//   mod_curv  - Edition  de courbe interactive
+//%Syntaxe
+//  [x,y,ok]=mod_curv(xd,yd,job,tit)
+//%Parametres
+//  xd    :  vecteur des abscisses donnees (eventuellement [])
+//  yd    :  vecteur des ordonnees donnees (eventuellement [])
+//  job   :  chaine de 3 caracteres  specifiant les operations
+//           permises:
+//            - Si la chaine contient le caractere 'a', il est 
+//              possible d'ajouter des points aux donnees, sinon
+//              il est seulement possible de les deplacer
+//            - Si la chaine contient le caractere 'x', il est 
+//              possible de deplacer les points horizontalement
+//            - Si la chaine contient le caractere 'y', il est 
+//              possible de deplacer les points verticalement
+//  tit   : liste de trois chaines de caracteres
+//          tit(1) : titre de la courbe (peut etre un vecteur colonne)
+//          tit(2) : label de l'axe des abscisses
+//          tit(3) : label de l'axe des ordonnees
+//  x     : vecteur des abscisses resultat
+//  y     : vecteur des ordonnees resultat
+//  ok    : vaut %t si la sortie as ete demandee par le menu Ok
+//           et  %f si la sortie as ete demandee par le menu Abort
+//%menus
+//  Ok    : sortie de l'editeur et retour de la courbe editee
+//  Abort : sortie de l'editeur et retour au donnes initiales 
+//  Undo  : annulation de la derniere modification
+//  Size  : changement des bornes du graphique
+//  Grids : changement des graduations du graphique
+//  Clear : effacement de la courbe (x=[] et y=[]) (sans quitter l'editeur)
+//  Read  : lecture de la courbe a partir d'un fichier d'extension .xy
+//  Save  : sauvegarde binaire (sur un fichier d'extension .xy) de 
+//          la courbe
+//!
+//origine: serge Steer, Habib Jreij INRIA 1993
+// Copyright INRIA
+[lhs,rhs]=argn(0)
+xset('default')
+//in line definition of get_click
+deff('[btn,xc,yc,win,Cmenu]=get_click(flag)',[
+'if ~or(winsid() == curwin) then   Cmenu = ''Quit'';return,end,';
+'if argn(2) == 1 then';
+'  [btn, xc, yc, win, str] = xclick(flag);';
+'else';
+'  [btn, xc, yc, win, str] = xclick();';
+'end';
+'if btn == -100 then';
+'  if win == curwin then';
+'    Cmenu = ''Quit'';';
+'  else';
+'    Cmenu = ''Open/Set'';';
+'  end,';
+'  return,';
+'end';
+'if btn == -2 then';
+'  xc = 0;yc = 0;';
+'  execstr(''Cmenu='' + part(str, 9:length(str) - 1));';
+'  execstr(''Cmenu='' + Cmenu);';
+'  return,';
+'end';
+'Cmenu=[]'])
+
+
+ok=%t
+if rhs==0 then x=[];y=[],end;
+if rhs==1 then y=x;x=(1:size(y,'*'))',end
+if rhs<3  then job='axy',end
+if rhs<4 then tit=[' ',' ',' '],end
+if size(tit,'*')<3 then tit(3)=' ',end
+//
+[mx,nx]=size(x);x=x(:)
+[my,ny]=size(y);y=y(:)
+xsav=x;ysav=y;xs=x;ys=y;
+//
+lj=length(job)
+add=0;modx=0;mody=0
+for k=1:lj
+  jk=part(job,k)
+  select jk
+  case 'a' then add=1,
+  case 'x' then modx=1
+  case 'y' then mody=1
+  else error('parametre job incorrect')
+  end
+end
+eps=0.03
+symbsiz=0.2
+// bornes initiales du graphique
+if rhs<5 then
+  if mx<>0 then
+    xmx=maxi(x);xmn=mini(x)
+    ymx=maxi(y);ymn=mini(y)
+    dx=xmx-xmn;dy=ymx-ymn
+    if dx==0 then dx=maxi(xmx/2,1),end
+    xmn=xmn-dx/10;xmx=xmx+dx/10
+    if dy==0 then dy=maxi(ymx/2,1),end;
+    ymn=ymn-dy/10;ymx=ymx+dy/10;
+  else
+    xmn=0;ymn=0;xmx=1;ymx=1;dx=1;dy=1
+  end
+  rect=[xmn,ymn,xmx,ymx];
+  axisdata=[2 10 2 10]
+  gc=list(rect,axisdata)
+else
+  [rect,axisdata]=gc(1:2)
+  xmn=rect(1);ymn=rect(2);xmx=rect(3);ymx=rect(4)
+  dx=xmx-xmn;dy=ymx-ymn
+end
+xbasc()
+auto=%t
+
+// Set menus and callbacks
+menu_d=['Read','Save','Clear']
+menu_e=['Undo','Size','Grids','Replot','Ok','Abort']
+menus=list(['Edit','Data'],menu_e,menu_d)
+w='menus(2)(';rpar=')'
+Edit=w(ones(menu_e))+string(1:size(menu_e,'*'))+rpar(ones(menu_e))
+w='menus(3)(';rpar=')'
+Data=w(ones(menu_d))+string(1:size(menu_d,'*'))+rpar(ones(menu_d))
+
+xselect()
+curwin=xget('window')
+unsetmenu(curwin,'File',1) //clear
+unsetmenu(curwin,'File',2) //select
+unsetmenu(curwin,'File',6) //load
+unsetmenu(curwin,'File',7) //close
+unsetmenu(curwin,'3D Rot.')
+//
+execstr('Edit_'+string(curwin)+'=Edit')
+execstr('Data_'+string(curwin)+'=Data')
+menubar(curwin,menus)
+//
+xset('alufunction',3)
+xset('dashes',1)
+xset('pattern',1)
+// -- trace du cadre
+plot2d(rect(1),rect(2),-1,'011',' ',rect,axisdata);
+xgrid(4)
+xtitle(tit(1),tit(2),tit(3));
+xset('alufunction',6)
+if x<>[]&y<>[] then 
+  plot2d(x,y,1,'000',' ');plot2d(x,y,-1,'000',' ');
+end
+
+
+
+// -- boucle principale
+while %t then
+  [n1,n2]=size(x);npt=n1*n2
+  [btn,xc,yc,win,Cmenu]=get_click()
+  c1=[xc,yc]
+  if Cmenu=='Quit' then Cmenu='Abort',end
+  if Cmenu==[] then Cmenu='edit',end
+  if Cmenu=='Exit' then Cmenu='Ok',end
+  select Cmenu
+  case [] then 
+    //ce n est pas un menu
+    break
+  case 'Ok' then 
+    //    -- ok menu
+    xset('default')
+    gc=list(rect,axisdata)
+    xdel()
+    return
+  case 'Abort' then 
+    //    -- abort menu
+    x=xsav
+    y=ysav
+//    xset('default')
+    if or(curwin==winsid()) then xdel(curwin);end
+    ok=%f
+    return
+  case 'Undo' then
+    if x<>[]&y<>[] then plot2d(x,y,-1,'000',' ');plot2d(x,y,1,'000',' ');end
+    x=xs;y=ys
+    if x<>[]&y<>[] then plot2d(x,y,-1,'000',' ');plot2d(x,y,1,'000',' ');end
+    x=xs;y=ys
+  case 'Size' then
+    while %t
+      [ok,xmn,xmx,ymn,ymx]=getvalue('entrez les nouvelles bornes',..
+         ['xmin';'xmax';'ymin';'ymax'],..
+         list('vec',1,'vec',1,'vec',1,'vec',1),..
+         string([xmn;xmx;ymn;ymx]))
+      if ~ok then break,end
+      if xmn>xmx|ymn>ymx then
+       x_message('Les bornes sont incorrectes')
+      else
+       break
+      end
+    end
+    if ok then
+      xset('alufunction',3)
+      dx=xmx-xmn;dy=ymx-ymn
+      if dx==0 then dx=maxi(xmx/2,1),xmn=xmn-dx/10;xmx=xmx+dx/10;end
+      if dy==0 then dy=maxi(ymx/2,1),ymn=ymn-dy/5;ymx=ymx+dy/10;end
+      rect=[xmn,ymn,xmx,ymx];
+      xbasc()
+      auto=%f
+      xset('alufunction',3)
+      if x<>[]&y<>[] then 
+       plot2d(x,y,-1,'011',' ',rect,axisdata);
+       xset('alufunction',6)
+       plot2d(x,y,1,'000',' ')
+      else
+       plot2d(rect(1),rect(2),-1,'011',' ',rect,axisdata);
+       xset('alufunction',6)
+      end
+      xgrid(4)
+
+    end
+  case 'Grids' then 
+    rep=x_mdialog('entrez les nouveaux nombres d''intervalles',..
+       ['axe des x';'axe des y'],..
+       string([axisdata(2);axisdata(4)]))
+    if rep<>[] then
+      rep=evstr(rep)
+      axisdata(2)=rep(1);axisdata(4)=rep(2);
+      xset('alufunction',3)
+      rect=[xmn,ymn,xmx,ymx];
+      xbasc()
+      auto=%f
+      if x<>[]&y<>[] then 
+       plot2d(x,y,-1,'011',' ',rect,axisdata);
+       xset('alufunction',6)
+       plot2d(x,y,1,'000',' ')
+      else
+       plot2d(rect(1),rect(2),-1,'011',' ',rect,axisdata);
+       xset('alufunction',6)
+      end
+      xgrid(4)
+    end
+  case 'Clear' then
+    if x<>[]&y<>[] then 
+      plot2d(x,y,1,'000',' ');plot2d(x,y,-1,'000',' ')
+      x=[];y=[];
+    end
+  case 'Read' then
+    [x,y]=readxy()
+    mx=mini(prod(size(x)),prod(size(y)))
+    if mx<>0 then
+      xmx=maxi(x);xmn=mini(x)
+      ymx=maxi(y);ymn=mini(y)
+      dx=xmx-xmn;dy=ymx-ymn
+      if dx==0 then dx=maxi(xmx/2,1),xmn=xmn-dx/10;xmx=xmx+dx/10;end
+      if dy==0 then dy=maxi(ymx/2,1),ymn=ymn-dy/5;ymx=ymx+dy/10;end
+    else
+      xmn=0;ymn=0;xmx=1;ymx=1;dx=1;dy=1
+    end
+    rect=[xmn,ymn,xmx,ymx];
+    xbasc()
+    xset('alufunction',3)
+    if x<>[]&y<>[] then 
+      plot2d(x,y,-1,'011',' ',rect,axisdata);
+      xset('alufunction',6)
+      plot2d(x,y,1,'000',' ')
+    else
+      plot2d(rect(1),rect(2),-1,'011',' ',rect,axisdata);
+      xset('alufunction',6)
+    end
+    xgrid(4)
+  case 'Save' then
+    savexy(x,y)
+  case 'Replot' then
+    xbasc()
+    xset('alufunction',3)
+    plot2d(rect(1),rect(2),-1,'011',' ',rect,axisdata);
+    xgrid(4)
+    xset('alufunction',6)
+    if x<>[]&y<>[] then 
+      plot2d(x,y,1,'000',' ');plot2d(x,y,-1,'000',' ');
+    end
+  case 'edit' then
+    npt=prod(size(x))
+    if npt<>0 then
+      dist=((x-ones(npt,1)*c1(1))/dx)^2+((y-ones(npt,1)*c1(2))/dy)^2
+      [m,k]=mini(dist);m=sqrt(m)
+    else
+      m=3*eps
+    end
+    if m<eps then                 //on deplace le point
+      xs=x;ys=y
+      [x,y]=movept(x,y)         
+    else                          
+      if add==1 then 
+       xs=x;ys=y                  //on rajoute un point de cassure
+       [x,y]=addpt(c1,x,y)
+      end
+    end
+  end
+end
+
+
+endfunction
+
+function [x,y]=addpt(c1,x,y)
+//permet de rajouter un point de cassure
+  npt=prod(size(x))
+  c1=c1'
+  if npt==0 then
+    x=c1(1);y=c1(2)
+    plot2d(x,y,1,'000',' ')
+    return
+  end
+  //recherche des intervalles en x contenant l'abscisse designee
+  kk=[]
+  if npt>1 then
+    kk=find((x(1:npt-1)-c1(1)*ones(x(1:npt-1)))..
+           .*(x(2:npt)-c1(1)*ones(x(2:npt)))<=0)
+  end
+  if  kk<>[] then
+    //    recherche du segment sur le quel on a designe un point
+    pp=[];d=[];i=0
+    for k=kk
+      i=i+1
+      pr=projaff(x(k:k+1),y(k:k+1),c1)
+      if (x(k)-pr(1))*(x(k+1)-pr(1))<=0 then
+        pp=[pp pr]
+        d1=rect(3)-rect(1)
+        d2=rect(4)-rect(2)
+        d=[d norm([d1;d2].\(pr-c1))]
+      end
+    end
+    if d<>[] then
+      [m,i]=mini(d)
+      if m<eps
+        k=kk(i)
+        pp=pp(:,i)
+       //  -- trace du point designe
+        plot2d(pp(1),pp(2),-1,'000',' ')
+       //  acquisition du nouveau point
+       //        [btn,xc,yc]=xclick();c2=[xc;yc]
+       c2=pp
+       //  -- effacage de l'ancien segment
+        plot2d(pp(1),pp(2),-1,'000',' ')
+        plot2d(x(k:k+1),y(k:k+1),1,'000',' ')
+       //  -- mise a jour de x et y
+        x=x([1:k k:npt]);x(k+1)=c2(1);
+        y=y([1:k k:npt]);y(k+1)=c2(2);
+       //  -- dessin des 2 nouveaux segments
+       plot2d(x(k:k+2),y(k:k+2),1,'000',' ')
+       plot2d(x(k+1),y(k+1),-1,'000',' ')
+       return
+      end
+    end
+  end
+  d1=rect(3)-rect(1)
+  d2=rect(4)-rect(2)
+  if norm([d1;d2].\([x(1);y(1)]-c1))<norm([d1;d2].\([x(npt);y(npt)]-c1)) then
+    //  -- mise a jour de x et y
+    x(2:npt+1)=x;x(1)=c1(1)
+    y(2:npt+1)=y;y(1)=c1(2)
+    //  -- dessin du nouveau segment
+    plot2d(x(1),y(1),-1,'000',' ')
+    plot2d(x(1:2),y(1:2),1,'000',' ')
+  else
+    //  -- mise a jour de x et y
+    x(npt+1)=c1(1)
+    y(npt+1)=c1(2)
+    //  -- dessin du nouveau segment
+    plot2d(x(npt+1),y(npt+1),-1,'000',' ')
+    plot2d(x(npt:npt+1),y(npt:npt+1),1,'000',' ')
+  end
+endfunction
+
+function [x,y]=movept(x,y)
+//on bouge un point existant
+  rep(3)=-1
+  while rep(3)==-1 do
+    rep=xgetmouse()
+    xc=rep(1);yc=rep(2);c2=[xc;yc]
+    //[btn,xc,yc]=xclick();c2=[xc;yc]
+    if modx==0 then c2(1)=x(k);end
+    if mody==0 then c2(2)=y(k);end
+    pts=maxi(k-1,1):mini(k+1,npt)
+    // - effacage des deux segments   
+    plot2d(x(pts),y(pts),1,'000',' ')
+    plot2d(x(pts),y(pts),-1,'000',' ')
+    // - trace dans la nouvelle position
+    x(k)=c2(1);y(k)=c2(2)
+    plot2d(x(pts),y(pts),1,'000',' ')
+    plot2d(x(pts),y(pts),-1,'000',' ')
+  end
+
+endfunction
+function [x,y]=readxy()
+  fn=xgetfile('*.xy')
+  if fn<>emptystr() then 
+    if execstr('load(fn)','errcatch')<>0 then
+      xy=read(fn,-1,2)
+      x=xy(:,1);y=xy(:,2)
+    else
+      x=xy(:,1);y=xy(:,2)
+    end
+  else
+    x=x
+    y=y
+  end
+
+endfunction
+
+function savexy(x,y)
+  fn=xgetfile('*.xy')
+  if fn<>emptystr()  then 
+    xy=[x y];
+    fil=fn+'.xy'
+    if execstr('save(fil,xy)','errcatch')<>0 then
+      x_message(['Impossible to save in the selected file';
+                'Check file and directory access'])
+      return
+    end
+  end
+endfunction
diff --git a/scilab/modules/graphics/macros/errbar.sci b/scilab/modules/graphics/macros/errbar.sci
new file mode 100644 (file)
index 0000000..3849f5d
--- /dev/null
@@ -0,0 +1,46 @@
+function []=errbar(x,y,em,ep)
+// Rajoute des barres d'erreur sur un graphique 2D
+// x et y decrivent les courbes (voir plot2d)
+// em et ep sont deux matrices la barre d'erreur au point
+// <x(i,j),y(i,j)> va de <x(i,j),y(i,j)-em(i,j)> a <x(i,j),y(i,j)+em(i,j)>
+// x,y,em et ep sont donc des matrices (p,q), q courbes contenant chacunes
+// p points.
+// Exemple : taper errbar()
+//      x=0:0.1:2*%pi;
+//   y=<sin(x);cos(x)>';x=<x;x>';plot2d(x,y);
+//   errbar(x,y,0.05*ones(x),0.03*ones(x));
+//!
+// Copyright INRIA
+
+       [lhs,rhs]=argn(0)
+       
+       if rhs == 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of errbar()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'x=0:0.1:2*%pi;';
+                       'y=[sin(x);cos(x)]'';x=[x;x]''';
+                       'plot2d(x,y);';
+                       'errbar(x,y,0.05*ones(x),0.03*ones(x));'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+   
+xselect();
+[n1,n2]=size(x);
+y1=matrix(y-em,1,n1*n2);
+x1=matrix(x,1,n1*n2);
+y2=matrix(y+ep,1,n1*n2);
+xset("clipgrf");
+xsegs([x1;x1],[y1;y2]);
+xclip();
+endfunction
diff --git a/scilab/modules/graphics/macros/eval3d.sci b/scilab/modules/graphics/macros/eval3d.sci
new file mode 100644 (file)
index 0000000..3592e13
--- /dev/null
@@ -0,0 +1,19 @@
+function [z]=eval3d(fun,x,y)
+//Etant donnes une discretisation des abscisses (x) et des ordonnees (y)
+//  eval3d(fun,x [,y]) retourne la matrice [fun(x(i),y(j))] des valeurs de la
+//  fonction decrite par la macro fun aux points (x(i),y(j)).
+//Attention fun doit savoir gerer des arguments x et y vectoriels.
+//  Si fun ne sait pas gerer des arguments vectoriels, utiliser 
+//  feval(x,y,fun) 
+//Si y n'est pas fourni il est suppose identique a x
+//!
+// Copyright INRIA
+[lhs,rhs]=argn(0)
+if rhs==3 then
+  nx=prod(size(x));ny=prod(size(y))
+  z=matrix(fun(ones(1,ny).*.matrix(x,1,nx),matrix(y,1,ny).*.ones(1,nx)),nx,ny)
+else
+  nx=prod(size(x))
+  z=matrix(fun(ones(1,nx).*.matrix(x,1,nx),matrix(x,1,nx).*.ones(1,nx)),nx,nx)
+end
+endfunction
diff --git a/scilab/modules/graphics/macros/eval3dp.sci b/scilab/modules/graphics/macros/eval3dp.sci
new file mode 100644 (file)
index 0000000..ea7b84f
--- /dev/null
@@ -0,0 +1,50 @@
+function [x,y,z]=eval3dp(fun,p1,p2)
+// eval3d - retourne une representation par facettes d'une fonction z=f(u,v)
+//%Syntaxe
+//  [x,y,z]=eval3dp(fun,p1,p2)
+//%Parametres
+//  fun    : macro (de syntaxe : [x,y,z]=fun(p1,p2) ) definissant la 
+//           fonction f .
+//           Attention lors de l'appel de fun p1 et p2 sont des vecteurs
+//           et la macro doit retourner x,y,z tels que :
+//           [x(i),y(i),z(i)]=f(p1(i),p2(i))
+//
+//  p1     : vecteur reel donnant la discretisation des valeurs du 
+//           parametre u
+//  p2     : vecteur reel donnant la discretisation des valeurs du 
+//           parametre v
+//  x      : matrice 4xn dont chaque colonne contient les abscisses
+//           d'une facette
+//  y      : matrice 4xn dont chaque colonne contient les ordonnees
+//           d'une facette
+//  z      : matrice 4xn dont chaque colonne contient les cotes
+//           d'une facette
+//%Exemple
+//  deff('[x,y,z]=scp(p1,p2)',['x=p1.*sin(p1).*cos(p2)';
+//                             'y=p1.*cos(p1).*cos(p2)';
+//                             'z=p1.*sin(p2)'])
+//  [x,y,z]=eval3dp(scp,0:0.3:2*%pi,-%pi:0.3:%pi);
+//  fac3d(x,y,z,35,45,'x@y@z')
+//%Voir aussi
+// plot3d eval3d fac3d
+//!
+//origine S Steer INRIA 1990
+//
+// Copyright INRIA
+n1=prod(size(p1))
+n2=prod(size(p2))
+//on calcule la valeur de la fonction en tous le couples (p1(i),p2(j))
+[vx,vy,vz]=fun(ones(1,n2).*.matrix(p1,1,n1),matrix(p2,1,n2).*.ones(1,n1))
+p1=[];p2=[];
+//on genere les facettes
+ind=ones(1,n1-1).*.[0 1 n1+1 n1]+ (1:n1-1).*.[1 1 1 1];
+// ind=[1,2,n1+2,n1+1 , 2,3,n1+3,n1+2, ....  ,n1-1,n1,2n1,2n1-1
+
+ind2=ones(1,n2-1).*.ind+((0:n2-2)*n1).*.ones(ind);
+
+nx=prod(size(ind2))
+x=matrix(vx(ind2),4,nx/4);
+y=matrix(vy(ind2),4,nx/4);
+z=matrix(vz(ind2),4,nx/4);
+endfunction
diff --git a/scilab/modules/graphics/macros/evans.sci b/scilab/modules/graphics/macros/evans.sci
new file mode 100644 (file)
index 0000000..8acf805
--- /dev/null
@@ -0,0 +1,225 @@
+function []=evans(n,d,kmax)
+       // Seuil maxi et mini (relatifs) de discretisation en espace
+       // Copyright INRIA
+       
+       smax=0.002;smin=smax/3;
+       nptmax=2000 //nbre maxi de pt de discretisation en k
+       
+       //analyse de la liste d'appel
+       
+       [lhs,rhs]=argn(0)
+       
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of evans()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'xbasc();';
+                       'n=real(poly([0.1-%i 0.1+%i,-10],''s''));';
+                       'd=real(poly([-1 -2 -%i %i],''s''));';
+                       'evans(n,d,80);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+select type(n)
+  case 1  then
+    if rhs==2 then kmax=0,end
+  case 2  then
+    if rhs==2 then kmax=0,end
+  //-compat next case retained for list/tlist compatibility
+  case 15 then
+     if rhs==2 then kmax=d,else kmax=0,end
+     n1=n(1);
+     select n1(1)
+        case 'r' then [n,d]=n(2:3)
+        case 'lss' then n=ss2tf(n);[n,d]=n(2:3);n=clean(n);d=clean(d);
+        else error('transfer or state-space only')
+       end
+  case 16 then
+     if rhs==2 then kmax=d,else kmax=0,end
+     n1=n(1);
+     select n1(1)
+        case 'r' then [n,d]=n(2:3)
+        case 'lss' then n=ss2tf(n);[n,d]=n(2:3);n=clean(n);d=clean(d);
+        else error('transfer or state-space only')
+     end
+  else error('transfer or state-space only')
+end
+if prod(size(n))<>1 then
+    error('SISO system only'),
+end
+if kmax<=0 then
+     nm=mini([degree(n),degree(d)])
+     fact=norm(coeff(d),2)/norm(coeff(n),2)
+     kmax=round(500*fact),
+end
+//
+//calcul de la discretisation en k et racines associees
+nroots=roots(n);racines=roots(d);
+if nroots==[] then
+  nrm=maxi([norm(racines,1),norm(roots(d+kmax*n),1)])
+else
+  nrm=maxi([norm(racines,1),norm(nroots,1),norm(roots(d+kmax*n),1)])
+end
+md=degree(d)
+//
+ord=1:md;kk=0;nr=1;k=0;pas=0.99;fin='no';
+
+
+while fin=='no' then
+  k=k+pas
+  r=roots(d+k*n);r=r(ord)
+  dist=maxi(abs(racines(:,nr)-r))/nrm
+  //
+  point='nok'
+  if dist <smax then //pas correct
+    point='ok'
+  else //pas trop grand ou ordre incorrect
+    // on cherche l'ordre qui minimise la distance
+    ix=1:md
+    ord1=[]
+    for ky=1:md
+      yy=r(ky)
+      mn=10*dist*nrm
+      for kx=1:md
+       if ix(kx)>0 then
+         if  abs(yy-racines(kx,nr)) < mn then
+           mn=abs(yy-racines(kx,nr))
+           kmn=kx
+         end
+       end
+      end
+      ix(kmn)=0
+      ord1=[ord1 kmn]
+    end
+    r(ord1)=r
+    dist=maxi(abs(racines(:,nr)-r))/nrm
+    if dist <smax then
+      point='ok',
+      ord(ord1)=ord
+    else
+      k=k-pas,pas=pas/2.5
+    end
+  end
+  if dist<smin then
+    //pas trop petit
+    pas=2*pas;
+  end
+  if point=='ok' then
+    racines=[racines,r];kk=[kk,k];nr=nr+1
+    if k>kmax then fin='kmax',end
+    if nr>nptmax then fin='nptmax',end
+  end
+end
+//draw the axis
+x1 =[nroots;matrix(racines,md*nr,1)];
+xmin=mini(real(x1));xmax=maxi(real(x1))
+ymin=mini(imag(x1));ymax=maxi(imag(x1))
+dx=abs(xmax-xmin)*0.05
+dy=abs(ymax-ymin)*0.05
+if dx<1d-10, dx=0.01,end
+if dy<1d-10, dy=0.01,end
+legs=[],lstyle=[];
+rect=[xmin-dx;ymin-dy;xmax+dx;ymax+dy];
+gstyle=get('figure_style')
+if gstyle=='new' then 
+  f=gcf();
+  cur_im_dr= f.immediate_drawing;
+  f.immediate_drawing = 'off';
+  a=gca()
+  a.data_bounds=[rect(1) rect(2);rect(3) rect(4)]
+  if nroots<>[] then 
+    plot2d(real(nroots),imag(nroots),style=-5)
+    e=gce();e=e.children;e.mark_size_unit="point";e.mark_size=7;
+    legs=[legs 'open loop zeroes']
+  end
+  if racines<>[] then 
+    plot2d(real(racines(:,1)),imag(racines(:,1)),style=-2)
+    e=gce();e=e.children;e.mark_size_unit="point";e.mark_size=7;
+    legs=[legs,'open loop poles']
+  end
+else
+  plot2d([],[],rect=rect,frameflag=7)
+  xx=xget("mark")
+  xset("mark",xx(1),xx(1)+3);
+  if nroots<>[] then
+    plot2d(real(nroots),imag(nroots),style=-5,frameflag=0,axesflag=0)
+    legs=[legs 'open loop zeroes'],lstyle=[lstyle [-5;0]];
+  end
+  //plot the poles locations
+  if racines<>[] then
+    plot2d(real(racines(:,1)),imag(racines(:,1)),style=-2,frameflag=0, ...
+          axesflag=0)
+    legs=[legs,'open loop poles'],lstyle=[lstyle, [-2;0]];
+  end
+
+end
+dx=maxi(abs(xmax-xmin),abs(ymax-ymin));
+//plot the zeros locations
+
+
+//computes and draw the asymptotic lines
+m=degree(n);q=md-m
+if q>0 then
+  la=0:q-1;
+  so=(sum(racines(:,1))-sum(nroots))/q
+  i1=real(so);i2=imag(so);
+  if prod(size(la))<>1 then
+    ang1=%pi/q*(ones(la)+2*la)
+    x1=dx*cos(ang1),y1=dx*sin(ang1)
+  else
+    x1=0,y1=0,
+  end
+  if md==2,
+    if coeff(d,md)<0 then
+      x1=0*ones(2),y1=0*ones(2)
+    end,
+  end;
+  if maxi(k)>0 then
+    if gstyle=='new' then 
+      plot2d(i1,i2,style=1);
+      legs=[legs,'asymptotic directions']
+    else
+      plot2d(i1,i2,style=1,frameflag=0,axesflag=0);
+      legs=[legs,'asymptotic directions'],lstyle=[lstyle [1;1]];
+    end
+     xset("clipgrf");
+    for i=1:q,xsegs([i1,x1(i)+i1],[i2,y1(i)+i2]),end,
+    xclip();
+  end
+end;
+
+//lieu de evans
+[n1,n2]=size(racines);
+if gstyle=='new' then
+  plot2d(real(racines)',imag(racines)',style=2+(1:n2));
+  legend(legs,1);
+  xtitle('Evans root locus','Real axis','Imag. axis');
+  f=gcf();
+  if(cur_im_dr=="on") then f.immediate_drawing = 'on';end
+else
+  plot2d(real(racines)',imag(racines)',style=2+(1:n2),frameflag=0,axesflag=0);
+  legends(legs,lstyle,1);
+  xtitle('Evans root locus','Real axis','Imag. axis');
+  xset("mark",xx(1),xx(2));
+end
+
+
+if fin=='nptmax' then
+  write(%io(2),'evans : too many points required')
+end
+
+//   gain corresponding to a selected point of the locus
+//[l1,l2]=min(abs(racines(:)-selected));
+//col=int(l2/n1)+1;//row=modulo(l2,n1); racines(row,col) <-> seleceted
+//gain=kk(col);
+endfunction
diff --git a/scilab/modules/graphics/macros/fac3d.sci b/scilab/modules/graphics/macros/fac3d.sci
new file mode 100644 (file)
index 0000000..faa9853
--- /dev/null
@@ -0,0 +1,46 @@
+function fac3d(x,y,z,T,A,leg,flags,ebox)
+
+       // Copyright INRIA
+        
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fac3d()';
+                       '========================================';
+                       '';
+                       'WARNING : fac3d is obsolete see plot3d plot3d1 instead';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[x,y,z]=sph(alp,tet)'',[''x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)'';';
+                       '''y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)'';';
+                       '''z=r*sin(alp)+orig(3)*ones(tet)'']);';
+                       'r=1;orig=[0 0 0];';
+                       '[x1,y1,z1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));';
+                       '[n1,m1]=size(x1);';
+                       'r=1/2;orig=[-1 0 0];';
+                       '[x2,y2,z2]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));';
+                       '[n2,m2]=size(x2);';
+                       'x=[x1 x2];y=[y1 y2];z=[z1 z2];';
+                       'plot3d(x,y,z);';];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+       
+       write(%io(2),'WARNING : fac3d1 is obsolete see plot3d plot3d1 instead');
+       
+       select rhs 
+               case 3 then plot3d(x,y,z) 
+               case 4 then plot3d(x,y,z,T) 
+               case 5 then plot3d(x,y,z,T,A) 
+               case 6 then plot3d(x,y,z,T,A,leg) 
+               case 7 then plot3d(x,y,z,T,A,leg,flags) 
+               case 8 then plot3d(x,y,z,T,A,leg,flags,ebox) 
+       end
+endfunction
diff --git a/scilab/modules/graphics/macros/fac3d1.sci b/scilab/modules/graphics/macros/fac3d1.sci
new file mode 100644 (file)
index 0000000..9d7345f
--- /dev/null
@@ -0,0 +1,46 @@
+function fac3d1(x,y,z,T,A,leg,flags,ebox)
+       
+       // Copyright INRIA
+        
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fac3d1()';
+                       '========================================';
+                       '';
+                       'WARNING : fac3d1 is obsolete see plot3d plot3d1 instead';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[x,y,z]=sph(alp,tet)'',[''x=r*cos(alp).*cos(tet)+orig(1)*ones(tet)'';';
+                       '''y=r*cos(alp).*sin(tet)+orig(2)*ones(tet)'';';
+                       '''z=r*sin(alp)+orig(3)*ones(tet)'']);';
+                       'r=1;orig=[0 0 0];';
+                       '[x1,y1,z1]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));';
+                       '[n1,m1]=size(x1);';
+                       'r=1/2;orig=[-1 0 0];';
+                       '[x2,y2,z2]=eval3dp(sph,linspace(-%pi/2,%pi/2,40),linspace(0,%pi*2,20));';
+                       '[n2,m2]=size(x2);';
+                       'x=[x1 x2];y=[y1 y2];z=[z1 z2];';
+                       'plot3d1(x,y,z);';];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+       
+       write(%io(2),'WARNING : fac3d1 is obsolete see plot3d plot3d1 instead');
+       
+       select rhs 
+               case 3 then plot3d1(x,y,z) 
+               case 4 then plot3d1(x,y,z,T) 
+               case 5 then plot3d1(x,y,z,T,A) 
+               case 6 then plot3d1(x,y,z,T,A,leg) 
+               case 7 then plot3d1(x,y,z,T,A,leg,flags) 
+               case 8 then plot3d1(x,y,z,T,A,leg,flags,ebox) 
+       end
+endfunction
diff --git a/scilab/modules/graphics/macros/fchamp.sci b/scilab/modules/graphics/macros/fchamp.sci
new file mode 100644 (file)
index 0000000..6d743a9
--- /dev/null
@@ -0,0 +1,60 @@
+function []=fchamp(macr_f,fch_t,fch_xr,fch_yr,arfact,rect,strf)
+//   Draw vector field in R^2,
+//   Vector field defined by:
+//   y=f(x,t,[u]), for compatibility with ode function
+//    f : vector field. CAn be either :
+//      a function y=f(t,x,[u])
+//       a list such as  list(f1,u1) with f1 a function
+//       y=f1(t,x,u) and u1=current value of u
+//    t : instants vector
+//    xr,yr: two vectors defining the gridding
+//    arfact : optional arg to control size of arrow heads,
+//    strf : string ( same as  plot2d )
+//Example : enter fchamp()
+//!
+// Copyright INRIA
+       
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fchamp()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[xdot] = derpol(t,x)'',[''xd1 = x(2)'';';
+                       '''xd2 = -x(1) + (1 - x(1)**2)*x(2)'';';
+                       '''xdot = [ xd1 ; xd2 ]'']);';
+                       'fchamp(derpol,0,-1:0.1:1,-1:0.1:1,1);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+  
+  if rhs <= 2,fch_xr=-1:0.1:1;end
+  if rhs <= 3,fch_yr=-1:0.1:1;end
+
+  opts=[]
+  if exists('arfact','local')==1 then opts=[opts,'arfact=arfact'],end
+  if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
+  if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
+
+  if type(macr_f) <> 15,
+    if type(macr_f)==11 then comp(macr_f),end;
+    deff('[yy]=mmm(x1,x2)',['xx=macr_f(fch_t,[x1;x2])';'yy=xx(1)+%i*xx(2);']);
+  else
+    mmm1=macr_f(1)
+    if type(mmm1)==11 then comp(mmm1),end;
+    deff('[yy]=mmm(x1,x2)',['xx=mmm1(fch_t,[x1;x2],macr_f(2));';
+                   'yy=xx(1)+%i*xx(2);']);
+  end
+  fch_v=feval(fch_xr,fch_yr,mmm);
+
+
+  execstr('champ(fch_xr,fch_yr,real(fch_v),imag(fch_v),'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/fcontour.sci b/scilab/modules/graphics/macros/fcontour.sci
new file mode 100644 (file)
index 0000000..81337ef
--- /dev/null
@@ -0,0 +1,71 @@
+function fcontour(xr,yr,f,nz,teta,alpha,leg,flag,ebox,zlev)
+//fcontour(xr,yr,f,nz,[teta,alpha,leg,flag,ebox,zlev])
+// Trace des courbes de niveau de la surface
+// d\'efinie par un external f  ( ex macro [y]=f(x))
+// on calcule d'abord f sur la grille definie par xr.yr
+// xr et yr sont des vecteurs implicites donnant les
+// abscisses et les ordonn\'ees des points de la grille
+// - x est une matrice de taille (1,n1)
+// - y est une matrice de taille (1,n2)
+// nz : permet de specifier les niveaux cherches 
+//    si nz est un nombre c'est le nombre de courbes de niveau demandees
+//     regulierement espacees entre zmin et zmax 
+//    si est un vecteur, il specifie les valeurs de z pour lesquelles
+//      on veut les courbes de niveau
+//
+// Les arguments suivants sont optionnels et sont identiques a ceux de 
+//    plot3d (sauf zlev), il permettent de dessiner des courbes de niveau
+//    sur  un graphique 3d. 
+//    Seule la signification de flag(1) est differente :
+//     flag(1)=0, les courbes de niveaux sont dessinees 
+//         sur un graphique 3d, sur la surface definie par (x,y,z)
+//     flag(1)=1, les courbes de biveaux sont dessinees 
+//         sur un graphique 3d, sur le plan defini par z=zlev
+//     flag(1)=2, les courbes de biveaux sont dessinees 
+//         sur un graphique 2d.
+// Exemple : taper fcontour() pour voir un exemple .
+// deff('[z]=Surf(x,y)','z=x**2+y**2');
+// fcontour(Surf,-1:0.1:1,-1:0.1:1,10);
+//
+//!
+// Copyright INRIA
+
+       [lhs,rhs]=argn(0)
+       if rhs == 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fcontour()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=x**2+y**2'');';
+                       'fcontour(-1:0.1:1,-1:0.1:1,Surf,10);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+if rhs<3,
+  error(' I need at least 3 arguments')
+end
+opts=[]
+if rhs<4,
+  nz=10,
+else
+  if exists('theta','local')==1 then opts=[opts,'theta=theta'],end
+  if exists('alpha','local')==1 then opts=[opts,'alpha=alpha'],end
+  if exists('leg'  ,'local')==1 then opts=[opts,'leg=leg']    ,end
+  if exists('flag' ,'local')==1 then opts=[opts,'flag=flag']  ,end
+  if exists('ebox' ,'local')==1 then opts=[opts,'ebox=ebox']  ,end
+  if exists('zlev' ,'local')==1 then opts=[opts,'zlev=zlev']  ,end
+  if size(opts,2)<rhs-4 then  error('invalid named arguments'),end
+end;
+
+if type(f)==11 then comp(f),end;
+execstr('contour(xr,yr,feval(xr,yr,f),nz,'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/fcontour2d.sci b/scilab/modules/graphics/macros/fcontour2d.sci
new file mode 100644 (file)
index 0000000..9bb898d
--- /dev/null
@@ -0,0 +1,47 @@
+function fcontour2d(xr,yr,f,nz,style,strf,leg,rect,nax,void)
+       
+       // deff('[z]=Surf(x,y)','z=x**2+y**2');
+       // fcontour(Surf,-1:0.1:1,-1:0.1:1,10);
+       
+       // Copyright INRIA
+       
+       [lhs,rhs]=argn(0);
+       
+       if rhs == 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fcontour2d()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=x**3+y'');';
+                       'fcontour2d(-1:0.1:1,-1:0.1:1,Surf,10,style=1:10,rect=[-1,-1,1,1]*1.5,strf='"011"');'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+if rhs<3,
+  error(' I need at least 3 arguments or zero to have a demo');
+end
+
+opts=[]
+if exists('nz','local')==0 then nz=10,rhs=rhs+1,end
+if exists('style','local')==1 then opts=[opts,'style=style'],end
+if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
+if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
+if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
+if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
+if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
+if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
+
+if size(opts,2)<rhs-4 then  error('invalid named arguments'),end
+
+if type(f)==11 then comp(f),end;
+execstr('contour2d(xr,yr,feval(xr,yr,f),nz,'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/fgrayplot.sci b/scilab/modules/graphics/macros/fgrayplot.sci
new file mode 100644 (file)
index 0000000..69e939d
--- /dev/null
@@ -0,0 +1,48 @@
+function []=fgrayplot(x,y,f,strf,rect,nax,void)
+//[]=fgrayplot(x,y,f)
+// Trace en niveau de gris une surface
+// z=f(x,y) d\'efinie par un external f ( ex macro [y]=f(x)) 
+// on calcule d'abord f sur la grille definie par x.y
+// x et y sont des vecteurs implicites donnant les
+// abscisses et les ordonn\'ees des points de la grille
+// le niveau de gris choisi sur chaque maillage depend de la valeur
+//    moyenne de z dans le maillage.
+// Exemple : taper fgrayplot() pour voir un exemple .
+//    deff('[z]=Surf(x,y)','z=x**2+y**2');
+//    fgrayplot(-1:0.1:1,-1:0.1:1,Surf);
+//!
+// Copyright INRIA
+       
+       [lhs,rhs]=argn(0);
+       
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fgrayplot()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=x**2+y**2'');';
+                       'fgrayplot(-1:0.1:1,-1:0.1:1,Surf);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+opts=[]
+if exists('style','local')==1 then opts=[opts,'style=style'],end
+if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
+if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
+if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
+if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
+if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
+if size(opts,2)<rhs-3 then  error('invalid named arguments'),end
+
+if type(f)==11 then comp(f),end;
+execstr('grayplot(x,y,feval(x,y,f),'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/fplot2d.sci b/scilab/modules/graphics/macros/fplot2d.sci
new file mode 100644 (file)
index 0000000..5362ca1
--- /dev/null
@@ -0,0 +1,51 @@
+function []=fplot2d(xr,f,style,strf,leg,rect,nax,void)
+       // 2D plot of function f : a Scilab function or the name (as a string)
+       //  of a dynamically linked function.
+       // Enter fplot2d() for an example.
+       // deff('<y>=f(x)','y=sin(x)+cos(x)');
+       // fplot2d(f,0:0.1:%pi);
+       //!
+       // Copyright INRIA
+       
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fplot2d()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[y]=f(x)'',''y=sin(x)+cos(x)'');';
+                       'fplot2d(0:0.1:%pi,f);'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+       
+       if type(xr)=='10' then // logflag passed first
+               error('First argument must be the discretization of x')
+       elseif rhs < 2 then 
+               error('at least 2 input arguments required')
+       end
+       //handling optionnal arguments
+       
+       opts=[]
+       
+       if exists('style','local')==1 then opts=[opts,'style=style'],end
+       if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
+       if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
+       if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
+       if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
+       if exists('logflag','local')==1 then opts=[opts,'logflag=logflag'],end
+       if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
+       if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
+       if size(opts,2)<rhs-2 then  error('invalid named arguments'),end
+       
+       execstr('plot2d(xr,feval(xr,f),'+strcat(opts,',')+')')
+       
+endfunction
diff --git a/scilab/modules/graphics/macros/fplot3d.sci b/scilab/modules/graphics/macros/fplot3d.sci
new file mode 100644 (file)
index 0000000..61f88df
--- /dev/null
@@ -0,0 +1,47 @@
+function fplot3d(xr,yr,f,theta,alpha,leg,flag,ebox)
+// fplot3d(xr,yr,f,teta,alpha,leg,[flag,ebox])
+// Trace la surface d\'efinie par un external f ( ex macro [z]=f(x,y))
+// on calcule d'abord f sur la grille definie par xr.yr
+// xr et yr sont des vecteurs implicites donnant les
+// abscisses et les ordonn\'ees des points de la grille
+// -teta, alpha : sont les angles en coordonn\'ees spheriques du
+//      point d'observation
+// -flag et ebox (voir plot3d)
+// Exemple : taper fplot3d() pour voir un exemple
+//!
+// Copyright INRIA
+       
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fplot3d()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=sin(x)*cos(y)'');';
+                       't=-%pi:0.3:%pi;';
+                       'fplot3d(t,t,Surf,35,45,'"X@Y@Z'");'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+if rhs<3, error(' I need at least 3 arguments'),end;
+
+opts=[]
+if exists('theta','local')==1 then opts=[opts,'theta=theta'],end
+if exists('alpha','local')==1 then opts=[opts,'alpha=alpha'],end
+if exists('leg'  ,'local')==1 then opts=[opts,'leg=leg']    ,end
+if exists('flag' ,'local')==1 then opts=[opts,'flag=flag']  ,end
+if exists('ebox' ,'local')==1 then opts=[opts,'ebox=ebox']  ,end
+if size(opts,2)<rhs-3 then  error('invalid named arguments'),end
+if type(f)==11 then comp(f),end;
+
+execstr('plot3d(xr,yr,feval(xr,yr,f),'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/fplot3d1.sci b/scilab/modules/graphics/macros/fplot3d1.sci
new file mode 100644 (file)
index 0000000..e40be56
--- /dev/null
@@ -0,0 +1,48 @@
+function []=fplot3d1(xr,yr,f,theta,alpha,leg,flag,ebox)
+// Trace la surface d\'efinie par un external f ( ex macro [z]=f(x,y))
+// on calcule d'abord f sur la grille definie par xr.yr
+// xr et yr sont des vecteurs implicites donnant les
+// abscisses et les ordonn\'ees des points de la grille
+// -theta, alpha : sont les angles en coordonn\'ees spheriques du
+//      point d'observation
+// -flag et ebox (voir plot3d1)
+// Exemple : taper fplot3d1() pour voir un exemple
+// deff('<z>=Surf(x,y)','z=x**2+y**2');
+// res=fplot3d1(Surf,-1:0.1:1,-1:0.1:1,35,45,"X@Y@Z");
+//!
+// Copyright INRIA
+       
+       [lhs,rhs]=argn(0)
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of fplot3d1()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       'deff(''[z]=Surf(x,y)'',''z=sin(x)*cos(y)'');';
+                       't=-%pi:0.3:%pi;';
+                       'fplot3d1(t,t,Surf,35,45,'"X@Y@Z'");'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+if rhs<3, error(' I need at least 3 arguments'),end;
+
+opts=[]
+if exists('theta','local')==1 then opts=[opts,'theta=theta'],end
+if exists('alpha','local')==1 then opts=[opts,'alpha=alpha'],end
+if exists('leg'  ,'local')==1 then opts=[opts,'leg=leg']    ,end
+if exists('flag' ,'local')==1 then opts=[opts,'flag=flag']  ,end
+if exists('ebox' ,'local')==1 then opts=[opts,'ebox=ebox']  ,end
+if size(opts,2)<rhs-3 then  error('invalid named arguments'),end
+if type(f)==11 then comp(f),end;
+
+execstr('plot3d1(xr,yr,feval(xr,yr,f),'+strcat(opts,',')+')')
+endfunction
diff --git a/scilab/modules/graphics/macros/gainplot.sci b/scilab/modules/graphics/macros/gainplot.sci
new file mode 100644 (file)
index 0000000..5df60b5
--- /dev/null
@@ -0,0 +1,135 @@
+function []=gainplot(sl,fmin,fmax,pas,comments)
+//!
+// Copyright INRIA
+[lhs,rhs]=argn(0);
+dom='c';
+//---------------------
+pas_def='auto' // default
+//
+noxtitle=%f;
+ilf=0
+flag=type(sl);
+if flag==15 then flag=16;end
+select flag
+case 16 then  // sl,fmin,fmax [,pas] [,comments]
+  typ=sl(1);typ=typ(1);
+  if typ<>'lss'&typ<>'r' then
+    error(97,1)
+  end
+  sl1=sl(1);
+  if sl1(1)=='r' then dom=sl(4),else dom=sl(7),end
+  if dom==[] then error(96,1),end
+  if dom=='d' then dom=1;end
+  select rhs
+  case 1 then //sl
+   comments=' '
+   fmin_default=1.d-3;
+   fmax_default=1.d3;
+
+   if dom=='c' then fmax_default=1.d3; else fmax_default=1/(2*dom),end
+   [frq,repf]=repfreq(sl,fmin_default,fmax_default);sl=[] 
+   [d,phi]=dbphi(repf);
+  case 2 then // sl,frq
+   comments=' '
+   if min(fmin)<=0 then
+     error('bode: requires strictly positive frequency vector')
+   end   
+   [frq,repf]=repfreq(sl,fmin);fmin=[];sl=[]
+   [d,phi]=dbphi(repf);
+  case 3 , //sl,frq,comments ou sl,fmin,fmax
+   if type(fmax)==1 then
+      comments=' '
+      if fmin<=0 then
+         error('bode: requires strictly positive frequency range')
+       end      
+      [frq,repf]=repfreq(sl,fmin,fmax,pas_def),sl=[]
+      [d,phi]=dbphi(repf);
+   else
+      comments=fmax
+      if min(fmin)<=0 then
+       error('bode: requires strictly positive frequency vector')
+      end      
+      if type(dom)==1 then nyq_frq=1/2/dom;end
+      if find(fmin>nyq_frq)~=[] then 
+       warning('There are frequencies beyond Nyquist f!');
+      end      
+      [frq,repf]=repfreq(sl,fmin);fmin=[];sl=[]
+      [d,phi]=dbphi(repf);
+   end
+  case 4 ,
+    if type(pas)==1 then 
+      comments=' ',
+    else 
+      comments=pas;pas=pas_def
+    end,
+    if min(fmin)<=0 then
+      error('bode: requires strictly positive frequency vector')
+    end    
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  case 5 then,
+    if min(fmin)<=0 then
+      error('bode: requires strictly positive frequency vector')
+    end    
+    [frq,repf]=repfreq(sl,fmin,fmax,pas)
+    [d,phi]=dbphi(repf);
+  else 
+    error('Invalid call: sys,fmin,fmax [,pas] [,com]')
+  end;
+
+case 1 then //frq,db,phi [,comments] ou frq, repf [,comments]
+noxtitle=%t;
+  select rhs
+  case 2 , //frq,repf
+    comments=' '
+    [phi,d]=phasemag(fmin),fmin=[]
+  case 3 then
+    if type(fmax)==1 then
+      comments=' '//frq db phi
+      d=fmin,fmin=[]
+      phi=fmax,fmax=[]
+    else
+      [phi,d]=phasemag(fmin);fmin=[]
+      comments=fmax
+     end;
+   case 4 then 
+     comments=pas;d=fmin;fmin=[];phi=fmax;fmax=[]
+   else 
+     error('inputs:frq,db,phi,[com] or frq,repf,[com]')
+   end;
+   frq=sl;sl=[];[mn,n]=size(frq);
+   if min(frq)<=0 then
+     error('bode: requires strictly positive frequencies')
+   end   
+   if mn<>1 then
+      ilf=1;//un vecteur de frequences par reponse
+   else
+      ilf=0;//un seul vecteur de frequence
+   end;
+else 
+   error('gainplot: invalid plot')
+end;
+[mn,n]=size(phi)
+//
+//Captions
+if comments==' ' then
+   comments(mn)=' ';
+   mnc=0
+  strf='051'
+else
+   mnc=mn
+  strf='151'
+end;
+
+rect=[mini(frq),mini(d),maxi(frq),maxi(d)]
+plot2d1("oln",mini(frq),mini(d),0,'051',' ',rect);
+xgrid(4)
+if ilf==0 then
+       plot2d1("oln",frq',d',[1,3:mn+1],strf,strcat(comments,'@'),rect);
+else
+       plot2d1("gln",frq',d',[1,3:mn+1],strf,strcat(comments,'@'),rect);
+end
+if ~noxtitle then
+xtitle(' ','Hz','db');
+end
+endfunction
diff --git a/scilab/modules/graphics/macros/gca.sci b/scilab/modules/graphics/macros/gca.sci
new file mode 100644 (file)
index 0000000..8da795e
--- /dev/null
@@ -0,0 +1,3 @@
+function [a]=gca()
+  a=get("current_axes");
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/gce.sci b/scilab/modules/graphics/macros/gce.sci
new file mode 100644 (file)
index 0000000..77e0ed3
--- /dev/null
@@ -0,0 +1,3 @@
+function [a]=gce()
+  a=get("hdl");
+endfunction
diff --git a/scilab/modules/graphics/macros/gcf.sci b/scilab/modules/graphics/macros/gcf.sci
new file mode 100644 (file)
index 0000000..1b3ed92
--- /dev/null
@@ -0,0 +1,3 @@
+function [f]=gcf()
+  f=get("current_figure");
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/gda.sci b/scilab/modules/graphics/macros/gda.sci
new file mode 100644 (file)
index 0000000..48355e7
--- /dev/null
@@ -0,0 +1,3 @@
+function [a]=gda()
+  a=get("default_axes");
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/gdf.sci b/scilab/modules/graphics/macros/gdf.sci
new file mode 100644 (file)
index 0000000..d179b75
--- /dev/null
@@ -0,0 +1,3 @@
+function [a]=gdf()
+  a=get("default_figure");
+endfunction
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/ged.sci b/scilab/modules/graphics/macros/ged.sci
new file mode 100644 (file)
index 0000000..8a67806
--- /dev/null
@@ -0,0 +1,2443 @@
+function ged(k,win)
+  //xset, xget used because ged should handle both old and new style
+
+  global ged_current_figure
+  global ged_cur_fig_handle
+  
+  ged_current_figure=xget('window')
+  xset('window',win) 
+  isold=get('figure_style')=='old'
+  if isold&k>3 then 
+    message('this menu does not apply to old style graphics')
+    xset('window',ged_current_figure)
+    clearglobal ged_current_figure
+    clear ged_current_figure
+    return
+  end
+  
+  
+  scf(win);
+  ged_cur_fig_handle=gcf();
+  
+  if k>3 then
+    TCL_EvalStr("set isgedinterp [interp exists ged]")
+    if TCL_GetVar("isgedinterp")=='0' then    
+      TCL_EvalStr("interp create ged")
+      TCL_EvalStr("load {'+gettklib()+'} Tk ged")
+      TCL_EvalStr("ged eval {wm withdraw .}")
+    end
+  end
+
+  select k
+    case 1 then //Select (make it current)
+      return
+    case 2 then //redraw
+      if isold then xbasr(win),end
+    case 3 then //erase
+      xbasc()
+    case 4 then //copy
+      ged_copy_entity()
+    case 5 then //past
+      ged_paste_entity()
+    case 6 then //move
+      ged_move_entity()
+    case 7 then //Delete Entity
+      ged_delete_entity()
+      
+    case 8 then //edit current figure properties
+      
+      // hierarchical viewer
+    TK_send_handles_list(ged_cur_fig_handle)
+    TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(ged_cur_fig_handle)))
+    
+    //color_map array for color sample display
+    f=ged_cur_fig_handle;
+    for i=1:size(f.color_map,1)
+      redname= "RED("+string(i)+")";
+      TCL_EvalStr('set '+redname+" "+string(f.color_map(i,1)));
+      grename= "GREEN("+string(i)+")";
+      TCL_EvalStr('set '+grename+" "+string(f.color_map(i,2)));
+      bluname= "BLUE("+string(i)+")";
+      TCL_EvalStr('set '+bluname+" "+string(f.color_map(i,3)));
+    end
+    
+    TCL_SetVar("msdos",string(MSDOS)) // to know the OS
+    // get the number of the window associated with ged
+    TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ;
+    
+    //ged_fontarray = ["Courier" "Symbol" "Times" "Times Italic" "Times Bold" "Times Bold Italic"  "Helvetica"  "Helvetica Italic" "Helvetica Bold" "Helvetica Bold Italic"];
+    
+    ged_figure(ged_cur_fig_handle)
+    case 9 then //edit current axes
+      // hierarchical viewer
+    TK_send_handles_list(ged_cur_fig_handle)
+    TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(gca())))
+    
+    //color_map array for color sample display
+    f=ged_cur_fig_handle;
+    for i=1:size(f.color_map,1)
+      redname= "RED("+string(i)+")";
+      TCL_EvalStr('set '+redname+" "+string(f.color_map(i,1)));
+      grename= "GREEN("+string(i)+")";
+      TCL_EvalStr('set '+grename+" "+string(f.color_map(i,2)));
+      bluname= "BLUE("+string(i)+")";
+      TCL_EvalStr('set '+bluname+" "+string(f.color_map(i,3)));
+    end
+    
+    TCL_SetVar("msdos",string(MSDOS)) // to know the OS
+    // get the number of the window associated with ged
+    TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ;
+    
+    ged_axes(gca())
+    case 10 then //start Entity picker
+      seteventhandler("ged_eventhandler")
+    case 11 then //stop Entity picker
+      seteventhandler("")
+  end
+  xset('window',ged_current_figure)
+endfunction
+
+
+function curgedindex_ = Get_handle_pos_in_list(h)
+global ged_cur_fig_handle
+
+curgedindex_ = [];
+
+handles = Get_handles_list(ged_cur_fig_handle)
+for i=1:size(handles,1)
+  if (h==handles(i))
+    curgedindex_ = i;
+  end
+end
+
+// Other case :
+// a label has been selected (and for now they are included inside the Axes)
+if (curgedindex_==[])
+  if h.type == "Label"
+    h = h.parent;
+    for i=1:size(handles,1)
+      if (h==handles(i))
+       curgedindex_ = i;
+      end
+    end
+  end
+end
+  
+endfunction
+
+
+// Search the depth level for each handle
+// Usefull for new hierarchical graphic tree.
+function ged_levels = Get_levels(handles);
+
+ged_levels = 1; // for Figure, always 1
+
+f = handles(1);
+
+for i=2:size(handles,1)
+  ged_levels(i) = Get_Depth(f,handles(i));
+end
+
+//disp("les levels sont:")xb
+
+//disp(ged_levels);
+
+endfunction
+
+function depth = Get_Depth(f,h)
+
+depth = 2;
+
+while  h.parent <> f
+  h = h.parent;
+  depth = depth + 1;
+end
+
+endfunction
+
+
+
+function TK_send_handles_list(h)
+iFig = 0;
+iUim = 0;
+iAxe = 0; // <=> subwindow in C code
+iAgr = 0;
+iPol = 0;
+iPl3 = 0;
+iFac = 0;
+iRec = 0;
+iTex = 0;
+iLeg = 0;
+iArc = 0;
+iSeg = 0;
+iCha = 0; // Champ
+iFec = 0;
+iGra = 0;
+iMat = 0; // forgotten object F.Leray 22.10.04
+iAxi = 0; // axis : entity created when using drawaxis method for example
+iLab = 0;
+
+f=getparfig(h);
+handles = Get_handles_list(f)
+
+ged_levels = Get_levels(handles);
+
+TCL_SetVar("ged_handle_list_size",string(size(handles,1)));
+
+for i=1:size(handles,1)
+  SelObject="LEVELS("+string(i)+")";
+  TCL_EvalStr('set '+SelObject+" "+string(ged_levels(i)));
+end
+
+
+for i=1:size(handles,1)
+ SelObject="SELOBJECT("+string(i)+")";
+ hand = handles(i);
+ select  hand.type
+   case "Figure"
+    iFig = iFig+1;
+    figname= "Figure("+string(iFig)+")";
+    TCL_EvalStr('set '+SelObject+" "+figname);
+   case "Uimenu"
+    iUim = iUim+1;
+    uimname= "Uimenu("+string(iUim)+")";
+    TCL_EvalStr('set '+SelObject+" "+uimname);
+   
+   case "Axes"
+    iAxe = iAxe+1;
+    axename= "Axes("+string(iAxe)+")";
+    TCL_EvalStr('set '+SelObject+" "+axename);
+//   case "Label"  // to see later: have labels at the same level than Axes (to have a better visibility)
+//    iLab = iLab+1;
+//    labname= "Label("+string(iLab)+")";
+//    TCL_EvalStr('set '+SelObject+" "+labname);
+   case "Compound"
+    iAgr = iAgr+1;
+    agrname= "Compound("+string(iAgr)+")";
+    TCL_EvalStr('set '+SelObject+" "+agrname);
+   case "Polyline"
+    iPol = iPol+1;
+    polname= "Polyline("+string(iPol)+")";
+    TCL_EvalStr('set '+SelObject+" "+polname);
+   case "Plot3d"
+    iPl3 = iPl3+1;
+    pl3name= "Plot3d("+string(iPl3)+")";
+    TCL_EvalStr('set '+SelObject+" "+pl3name);
+   case "Fac3d"
+    iFac = iFac+1;
+    Facname= "Fac3d("+string(iFac)+")";
+    TCL_EvalStr('set '+SelObject+" "+Facname);
+   case "Rectangle"
+    iRec = iRec+1;
+    Recname= "Rectangle("+string(iRec)+")";
+    TCL_EvalStr('set '+SelObject+" "+Recname);
+   case "Text"
+    iTex = iTex+1;
+    Texname= "Text("+string(iTex)+")";
+    TCL_EvalStr('set '+SelObject+" "+Texname);
+   case "Legend"
+    iLeg = iLeg+1;
+    Legname= "Legend("+string(iLeg)+")";
+    TCL_EvalStr('set '+SelObject+" "+Legname);
+   case "Arc"
+    iArc = iArc+1;
+    Arcname= "Arc("+string(iArc)+")";
+    TCL_EvalStr('set '+SelObject+" "+Arcname);
+   case "Segs"
+    iSeg = iSeg+1;
+    Segname= "Segs("+string(iSeg)+")";
+    TCL_EvalStr('set '+SelObject+" "+Segname);
+   case "Champ"
+    iCha = iCha+1;
+    Chaname= "Champ("+string(iCha)+")";
+    TCL_EvalStr('set '+SelObject+" "+Chaname);
+   case "Fec"
+    iFec = iFec+1;
+    Fecname= "Fec("+string(iFec)+")";
+    TCL_EvalStr('set '+SelObject+" "+Fecname);
+   case "Grayplot"
+    iGra = iGra+1;
+    Graname= "Grayplot("+string(iGra)+")";
+    TCL_EvalStr('set '+SelObject+" "+Graname);
+   case "Matplot"
+    iMat = iMat+1;
+    Matname= "Matplot("+string(iMat)+")";
+    TCL_EvalStr('set '+SelObject+" "+Matname);
+   case "Axis"
+    iAxi = iAxi+1;
+    Axiname= "Axis("+string(iAxi)+")";
+    TCL_EvalStr('set '+SelObject+" "+Axiname);
+  end
+end
+endfunction
+
+
+//function h=Get_handle_from_index(index)
+function Get_handle_from_index(index)
+   global ged_handle;
+   global ged_cur_fig_handle
+
+   hl = Get_handles_list(ged_cur_fig_handle);
+
+   ged_handle = hl(index);
+//   h=ged_handle;
+   tkged();
+
+endfunction
+
+
+////////////////////////////////////////////
+function  hfig= getparfig( h )
+
+htmp = h;
+hfig= []
+
+while htmp.type<>'Figure' do
+  htmp=htmp.parent
+end
+
+hfig = htmp;
+endfunction
+
+
+function h_out_list=Get_handles_list(h);
+
+global ged_handle_out;
+
+f=getparfig(h);
+ged_handle_out=[f];
+
+List_handles(f);
+
+//disp(ged_handle_out);
+
+h_out_list=ged_handle_out;
+
+endfunction
+
+
+function List_handles(h)
+global ged_handle_out;
+
+i = 1;
+//if h.type=="Axes" then
+//   ged_handle_out = [ged_handle_out;h.x_label;h.y_label;h.z_label;h.title];
+//end
+psonstmp = h.children;
+if psonstmp <> [] then
+  psonstmp = h.children(1);
+end
+
+while ((psonstmp <>[]) & ((i) <=size(psonstmp.parent.children,1)))
+  i = i+1;
+  ged_handle_out = [ged_handle_out;  psonstmp];
+  List_handles(psonstmp);
+
+  if ((i) <=size(psonstmp.parent.children,1)) then
+    psonstmp = psonstmp.parent.children(i);
+  else
+    psonstmp=[];
+  end
+
+end
+
+endfunction
+
+
+
+function ged_Compound(h)
+  global ged_handle;ged_handle=h;
+  TCL_SetVar("curvis",h.visible)
+  TCL_EvalFile(SCI+'/tcl/ged/Compound.tcl')
+endfunction
+
+
+function ged_figure(h)
+  global ged_handle;ged_handle=h;
+  TCL_SetVar("background",string(h.background))
+  TCL_SetVar("rotation_style",h.rotation_style)
+  TCL_SetVar("figure_name",h.figure_name)
+  TCL_SetVar("figure_id",string(h.figure_id))
+  TCL_SetVar("figure_xposition",string(h.figure_position(1)))
+  TCL_SetVar("figure_yposition",string(h.figure_position(2)))
+  TCL_SetVar("figure_xsiz",string(h.figure_size(1)))
+  TCL_SetVar("figure_ysiz",string(h.figure_size(2)))
+  TCL_SetVar("figure_xaxesiz",string(h.axes_size(1)))
+  TCL_SetVar("figure_yaxesiz",string(h.axes_size(2)))
+  TCL_SetVar("bcolor",string(h.background))
+  TCL_SetVar("ncolors",string(size(h.color_map,1)))
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curpix",h.pixmap)
+  TCL_SetVar("curpdm",h.pixel_drawing_mode)
+  TCL_SetVar("curautoresize",h.auto_resize)
+  TCL_SetVar("currotation_style",h.rotation_style)
+  TCL_EvalFile(SCI+'/tcl/ged/Figure.tcl')
+endfunction
+
+
+function ged_axes(h)
+  global ged_handle;ged_handle=h;
+  
+  LoadTicks2TCL(h);
+  
+  TCL_SetVar("Xaxes_reverseToggle",h.axes_reverse(1))
+  TCL_SetVar("Yaxes_reverseToggle",h.axes_reverse(2))
+  TCL_SetVar("Zaxes_reverseToggle",h.axes_reverse(3))
+
+// forgotten axes bounds info.
+  TCL_SetVar("axes_boundsL",string(h.axes_bounds(1,1)))
+  TCL_SetVar("axes_boundsU",string(h.axes_bounds(1,2)))
+  TCL_SetVar("axes_boundsW",string(h.axes_bounds(1,3)))
+  TCL_SetVar("axes_boundsH",string(h.axes_bounds(1,4)))
+
+ // forgotten visibility info.
+  TCL_SetVar("xlabel_visibility",string(h.x_label.visible))
+  TCL_SetVar("ylabel_visibility",string(h.y_label.visible))
+  TCL_SetVar("zlabel_visibility",string(h.z_label.visible))
+  TCL_SetVar("titlelabel_visibility",string(h.title.visible))
+
+  TCL_SetVar("Lmargins",string(h.margins(1)));
+  TCL_SetVar("Rmargins",string(h.margins(2)));
+  TCL_SetVar("Tmargins",string(h.margins(3)));
+  TCL_SetVar("Bmargins",string(h.margins(4)));
+  ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"]; 
+  TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+  TCL_SetVar("curautoclear",h.auto_clear);
+  TCL_SetVar("curautoscale",h.auto_scale);
+  //TCL_SetVar("curfillmode",h.fill_mode);
+  TCL_SetVar("curalpharotation",string(h.rotation_angles(1)))
+  TCL_SetVar("curthetarotation",string(h.rotation_angles(2)))
+  ged_fontarray = ["Courier" "Symbol" "Times" "Times Italic"...
+        "Times Bold" "Times Bold Italic"  "Helvetica"  "Helvetica  Italic"...
+        "Helvetica Bold" "Helvetica Bold Italic"];
+  TCL_SetVar("Xlabelpos",h.x_location)
+  TCL_SetVar("Ylabelpos",h.y_location)
+  TCL_SetVar("Xlabelfontstyle",ged_fontarray(h.x_label.font_style+1))
+  TCL_SetVar("Ylabelfontstyle",ged_fontarray(h.y_label.font_style+1))
+  TCL_SetVar("Zlabelfontstyle",ged_fontarray(h.z_label.font_style+1))
+  TCL_SetVar("TITLEfontstyle",ged_fontarray(h.title.font_style+1))
+  TCL_SetVar("fontstyle",ged_fontarray(h.font_style+1))
+
+  // label texts
+  if size(h.x_label.text,'*') == 1 then
+    txt = """" + h.x_label.text + """" ;
+  else
+    // an array of strings
+    txt = "["+strcat(string(size(h.x_label.text)),'x')+" string array]" ;
+  end
+  TCL_SetVar("xlabel", txt );
+  
+  if size(h.y_label.text,'*') == 1 then
+    txt = """" + h.y_label.text + """" ;
+  else
+    // an array of strings
+    txt = "["+strcat(string(size(h.y_label.text)),'x')+" string array]" ;
+  end
+  TCL_SetVar("ylabel", txt );
+  
+  if size(h.z_label.text,'*') == 1 then
+    txt = """" + h.z_label.text + """" ;
+  else
+    // an array of strings
+    txt = "["+strcat(string(size(h.z_label.text)),'x')+" string array]" ;
+  end
+  TCL_SetVar("zlabel", txt );
+  
+  if size(h.title.text,'*') == 1 then
+    txt = """" + h.title.text + """" ;
+  else
+    // an array of strings
+    txt = "["+strcat(string(size(h.title.text)),'x')+" string array]" ;
+  end
+  TCL_SetVar("tlabel", txt );
+  
+  TCL_SetVar("xlabel_fontforeground",string(h.x_label.font_foreground))
+  TCL_SetVar("ylabel_fontforeground",string(h.y_label.font_foreground))
+  TCL_SetVar("zlabel_fontforeground",string(h.z_label.font_foreground))
+  TCL_SetVar("titlelabel_fontforeground",string(h.title.font_foreground))
+  TCL_SetVar("xlabel_foreground",string(h.x_label.foreground))
+  TCL_SetVar("ylabel_foreground",string(h.y_label.foreground))
+  TCL_SetVar("zlabel_foreground",string(h.z_label.foreground))
+  TCL_SetVar("titlelabel_foreground",string(h.title.foreground))
+  TCL_SetVar("xlabel_background",string(h.x_label.background))
+  TCL_SetVar("ylabel_background",string(h.y_label.background))
+  TCL_SetVar("zlabel_background",string(h.z_label.background))
+  TCL_SetVar("titlelabel_background",string(h.title.background))
+  TCL_SetVar("x_position",sci2exp(h.x_label.position,0))
+  TCL_SetVar("y_position",sci2exp(h.y_label.position,0))
+  TCL_SetVar("z_position",sci2exp(h.z_label.position,0))
+  TCL_SetVar("title_position",sci2exp(h.title.position,0))
+  TCL_SetVar("xauto_position",h.x_label.auto_position)
+  TCL_SetVar("yauto_position",h.y_label.auto_position)
+  TCL_SetVar("zauto_position",h.z_label.auto_position)
+  TCL_SetVar("titleauto_position",h.title.auto_position)
+  TCL_SetVar("xauto_rotation",h.x_label.auto_rotation)
+  TCL_SetVar("yauto_rotation",h.y_label.auto_rotation)
+  TCL_SetVar("zauto_rotation",h.z_label.auto_rotation)
+  TCL_SetVar("titleauto_rotation",h.title.auto_rotation)
+  TCL_SetVar("Xfillmode",h.x_label.fill_mode)
+  TCL_SetVar("Yfillmode",h.y_label.fill_mode)
+  TCL_SetVar("Zfillmode",h.z_label.fill_mode)
+  TCL_SetVar("Titlefillmode",h.title.fill_mode)
+  TCL_SetVar("xlabel_fontsize",string(h.x_label.font_size))
+  TCL_SetVar("ylabel_fontsize",string(h.y_label.font_size))
+  TCL_SetVar("zlabel_fontsize",string(h.z_label.font_size))
+  TCL_SetVar("titlelabel_fontsize",string(h.title.font_size))
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("fcolor",string(h.foreground))
+  TCL_SetVar("bcolor",string(h.background))
+  TCL_SetVar("curthick",string(h.thickness))
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curfontsize",string(h.font_size))
+  TCL_SetVar("curfontcolor",string(h.font_color))
+  TCL_SetVar("limToggle",h.tight_limits)
+  TCL_SetVar("isoToggle",h.isoview)
+  TCL_SetVar("cubToggle",h.cube_scaling)
+  TCL_SetVar("viewToggle",h.view)
+  TCL_SetVar("curBoxState",h.box)
+  TCL_SetVar("xToggle",part(h.log_flags,1))
+  TCL_SetVar("yToggle",part(h.log_flags,2))
+  TCL_SetVar("zToggle",part(h.log_flags,3))
+  TCL_SetVar("xGrid",string(h.grid(1)))
+  TCL_SetVar("yGrid",string(h.grid(2)))
+  
+  TCL_SetVar("hiddenAxisColor",h.hidden_axis_color)
+  TCL_SetVar("curfontangle_x",string(h.x_label.font_angle))
+  TCL_SetVar("curfontangle_y",string(h.y_label.font_angle))
+  TCL_SetVar("curfontangle_z",string(h.z_label.font_angle))
+  TCL_SetVar("curfontangle_title",string(h.title.font_angle))
+
+  
+  select h.view
+    case "2d" 
+    drawlater();
+    h.view='3d'
+    TCL_SetVar("old_curalpharotation",string(h.rotation_angles(1)))
+    TCL_SetVar("old_curthetarotation",string(h.rotation_angles(2)))
+    TCL_SetVar("zGrid",string(h.grid(3)))
+    TCL_SetVar("zGrid_initial",string(h.grid(3))) //to avoid useless redraw (see Axes.tcl)
+    TCL_SetVar("dbxmin",string(h.data_bounds(1,1)))
+    TCL_SetVar("dbymin",string(h.data_bounds(1,2)))
+    TCL_SetVar("dbzmin",string(h.data_bounds(1,3)))
+    TCL_SetVar("dbxmax",string(h.data_bounds(2,1)))
+    TCL_SetVar("dbymax",string(h.data_bounds(2,2)))
+    TCL_SetVar("dbzmax",string(h.data_bounds(2,3)))
+    h.view='2d'
+    drawnow();
+    case "3d"
+    TCL_SetVar("zGrid",string(h.grid(3)))
+    TCL_SetVar("zGrid_initial",string(h.grid(3))) //to avoid useless redraw (see Axes.tcl)
+    TCL_SetVar("dbxmin",string(h.data_bounds(1,1)))
+    TCL_SetVar("dbymin",string(h.data_bounds(1,2)))
+    TCL_SetVar("dbzmin",string(h.data_bounds(1,3)))
+    TCL_SetVar("dbxmax",string(h.data_bounds(2,1)))
+    TCL_SetVar("dbymax",string(h.data_bounds(2,2)))
+    TCL_SetVar("dbzmax",string(h.data_bounds(2,3)))
+  end
+  TCL_EvalFile(SCI+'/tcl/ged/Axes.tcl')
+endfunction
+
+function ged_rectangle(h)
+  global ged_handle; ged_handle=h
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+  f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end
+  ax=h;while stripblanks(ax.type)<>"Axes" then ax=ax.parent,end
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curcolor",string(h.foreground))
+  TCL_SetVar("curback",string(h.background))
+  TCL_SetVar("curthick",string(h.thickness))
+  TCL_SetVar("curvis",h.visible)
+  ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"]; 
+  TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+  ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" ..
+  "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+  "asterisk" "square" "triangle right" "triangle left" "pentagram"];
+  TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1))
+  TCL_SetVar("curmarkmode",h.mark_mode)
+  TCL_SetVar("curmarksize",string(h.mark_size))
+  TCL_SetVar("curmarksizeunit",h.mark_size_unit);
+  TCL_SetVar("curmarkforeground",string(h.mark_foreground))
+  TCL_SetVar("curmarkbackground",string(h.mark_background))
+
+  TCL_SetVar("curlinemode",h.line_mode)
+  TCL_SetVar("curfillmode",h.fill_mode)
+  // Rectangle data
+   select ax.view
+    case "2d" 
+    drawlater();
+    ax.view='3d'
+    TCL_SetVar("Xval",string(h.data(1)))
+    TCL_SetVar("Yval",string(h.data(2)))
+    TCL_SetVar("Zval",string(h.data(3)))
+    TCL_SetVar("Wval",string(h.data(4)))
+    TCL_SetVar("Hval",string(h.data(5)))
+    ax.view='2d'
+    drawnow();
+    case "3d"
+    TCL_SetVar("Xval",string(h.data(1)))
+    TCL_SetVar("Yval",string(h.data(2)))
+    TCL_SetVar("Zval",string(h.data(3)))
+    TCL_SetVar("Wval",string(h.data(4)))
+    TCL_SetVar("Hval",string(h.data(5)))
+  end
+  TCL_EvalFile(SCI+'/tcl/ged/Rectangle.tcl')
+endfunction
+
+function ged_polyline(h)
+    global ged_handle; ged_handle=h
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+    f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end
+    TCL_SetVar("ncolors",string(size(f.color_map,1)))
+    TCL_SetVar("curcolor",string(h.foreground))
+    TCL_SetVar("curback",string(h.background))
+    TCL_SetVar("curthick",string(h.thickness))
+    TCL_SetVar("curarrowsizefactor",string(h.arrow_size_factor))
+    TCL_SetVar("curvis",h.visible)
+
+    ged_polylinestylearray=["interpolated" "staircase" "barplot" "arrowed" "filled" "bar"];
+    TCL_SetVar("curpolylinestyle",ged_polylinestylearray(max(h.polyline_style,1)))
+    ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"];
+    TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+    ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" ..
+    "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+    "asterisk" "square" "triangle right" "triangle left" "pentagram"];
+
+    TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1))
+    TCL_SetVar("curmarkmode",h.mark_mode)
+    TCL_SetVar("curmarksize",string(h.mark_size))
+    TCL_SetVar("curmarksizeunit",h.mark_size_unit);
+    TCL_SetVar("curmarkforeground",string(h.mark_foreground))
+    TCL_SetVar("curmarkbackground",string(h.mark_background))
+
+    TCL_SetVar("curlinemode",h.line_mode)
+    TCL_SetVar("curclosedmode",h.closed)
+    TCL_SetVar("curfillmode",h.fill_mode)
+    TCL_SetVar("curinterpcolormode",h.interp_color_mode)
+    TCL_SetVar("curinterpcolorvector",sci2exp(h.interp_color_vector,0))
+        
+    d="["+strcat(string(size(h.data)),'x')+" double array]"
+    TCL_SetVar("curdata",d);
+
+    select get(getparaxe(h),'view')
+      case "2d"
+      TCL_SetVar("nbcol",string(2));
+      case "3d"
+      TCL_SetVar("nbcol",string(3));
+    end
+    TCL_EvalFile(SCI+'/tcl/ged/Polyline.tcl')
+endfunction
+
+
+function ged_plot3d(h)
+  global ged_handle; ged_handle=h
+
+  //  if (h.clip_box==[])
+//    TCL_SetVar("old_Xclipbox","")
+//    TCL_SetVar("old_Yclipbox","")
+//    TCL_SetVar("old_Wclipbox","")
+//    TCL_SetVar("old_Hclipbox","")
+//    TCL_SetVar("Xclipbox","")
+//    TCL_SetVar("Yclipbox","")
+//    TCL_SetVar("Wclipbox","")
+//    TCL_SetVar("Hclipbox","")
+//   else
+//    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+//    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+//  end
+//  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curcolormode",string(h.color_mode))
+  TCL_SetVar("colorflagToggle",string(h.color_flag))
+  TCL_SetVar("curforeground",string(h.foreground))
+  TCL_SetVar("curhiddencolor",string(h.hiddencolor))
+  TCL_SetVar("curthick",string(h.thickness))
+
+  ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" ..
+  "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+  "asterisk" "square" "triangle right" "triangle left" "pentagram"];
+
+  TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1))
+  TCL_SetVar("curmarkmode",h.mark_mode)
+  TCL_SetVar("curmarksize",string(h.mark_size))
+  TCL_SetVar("curmarksizeunit",h.mark_size_unit);
+  TCL_SetVar("curmarkforeground",string(h.mark_foreground))
+  TCL_SetVar("curmarkbackground",string(h.mark_background))
+  TCL_SetVar("curlinemode",h.surface_mode)
+
+
+  d="["+strcat(string(size(h.data.x)),'x')+" double array]"
+  TCL_SetVar("curdata_x",d);
+  d="["+strcat(string(size(h.data.y)),'x')+" double array]"
+  TCL_SetVar("curdata_y",d);
+  d="["+strcat(string(size(h.data.z)),'x')+" double array]"
+  TCL_SetVar("curdata_z",d);
+
+  TCL_EvalStr('set flagCOLOR 0')
+  if(h.data(1)==["3d" "x" "y" "z" "color"])
+  TCL_EvalStr('set flagCOLOR 1')
+    d="["+strcat(string(size(h.data.color)),'x')+" integer array]"
+    TCL_SetVar("curdata_color",d);
+  end
+  TCL_EvalFile(SCI+'/tcl/ged/Plot3d.tcl')
+endfunction
+
+
+function ged_fac3d(h)
+  global ged_handle; ged_handle=h
+
+  //  if (h.clip_box==[])
+//    TCL_SetVar("old_Xclipbox","")
+//    TCL_SetVar("old_Yclipbox","")
+//    TCL_SetVar("old_Wclipbox","")
+//    TCL_SetVar("old_Hclipbox","")
+//    TCL_SetVar("Xclipbox","")
+//    TCL_SetVar("Yclipbox","")
+//    TCL_SetVar("Wclipbox","")
+//    TCL_SetVar("Hclipbox","")
+//   else
+//    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+//    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+//  end
+//  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curcolormode",string(h.color_mode))
+  TCL_SetVar("colorflagToggle",string(h.color_flag))
+  TCL_SetVar("curforeground",string(h.foreground))
+  TCL_SetVar("curhiddencolor",string(h.hiddencolor))
+  TCL_SetVar("curthick",string(h.thickness))
+
+  ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" ..
+  "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+  "asterisk" "square" "triangle right" "triangle left" "pentagram"];
+
+  TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1))
+  TCL_SetVar("curmarkmode",h.mark_mode)
+  TCL_SetVar("curmarksize",string(h.mark_size))
+  TCL_SetVar("curmarksizeunit",h.mark_size_unit);
+  TCL_SetVar("curmarkforeground",string(h.mark_foreground))
+  TCL_SetVar("curmarkbackground",string(h.mark_background))
+  TCL_SetVar("curlinemode",h.surface_mode)
+
+
+  d="["+strcat(string(size(h.data.x)),'x')+" double array]"
+  TCL_SetVar("curdata_x",d);
+  d="["+strcat(string(size(h.data.y)),'x')+" double array]"
+  TCL_SetVar("curdata_y",d);
+   d="["+strcat(string(size(h.data.z)),'x')+" double array]"
+  TCL_SetVar("curdata_z",d);
+
+  TCL_EvalStr('set flagCOLOR 0')
+  if(h.data(1)==["3d" "x" "y" "z" "color"])
+  TCL_EvalStr('set flagCOLOR 1')
+    d="["+strcat(string(size(h.data.color)),'x')+" integer array]"
+    TCL_SetVar("curdata_color",d);
+  end
+
+
+  TCL_EvalFile(SCI+'/tcl/ged/Fac3d.tcl')
+endfunction
+
+
+function ged_text(h)
+  global ged_handle; ged_handle=h
+  f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curfontforeground",string(h.font_foreground))
+  ged_fontarray = ["Courier" "Symbol" "Times" "Times Italic"...
+        "Times Bold" "Times Bold Italic"  "Helvetica"  "Helvetica  Italic"...
+        "Helvetica Bold" "Helvetica Bold Italic"];
+  TCL_SetVar("curfontstyle",ged_fontarray(h.font_style+1))
+  TCL_SetVar("curfontsize",string(h.font_size))
+  TCL_SetVar("curfontangle",string(h.font_angle))
+  TCL_SetVar("curtextboxmode",h.text_box_mode)
+  TCL_SetVar("curtext",h.text)
+  TCL_SetVar("curforeground",string(h.foreground))
+  TCL_SetVar("curbackground",string(h.background))
+  TCL_SetVar("curboxmode",h.box)
+  TCL_SetVar("curlinemode",h.line_mode);
+  TCL_SetVar("curfillmode",h.fill_mode);
+  //TCL_SetVar("curPosition",h.data) ;
+
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+  if size(h.text,'*') == 1 then
+    txt =""""+ h.text +"""" ; // one double quote at each side
+  else
+    txt = "["+strcat(string(size(h.text)),'x')+" string array]"
+  end
+  TCL_SetVar("curtext", txt );
+  TCL_SetVar( "textBoxWidth", string( h.text_box(1) ) ) ;
+  TCL_SetVar("textBoxHeight", string( h.text_box(2) ) ) ;
+  TCL_SetVar("curAlignment",string(h.alignment) ) ;
+  
+  TCL_EvalFile(SCI+'/tcl/ged/Text.tcl')
+endfunction
+
+
+function ged_legend(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curforeground",string(h.foreground))
+  ged_fontarray = ["Courier" "Symbol" "Times" "Times Italic"...
+        "Times Bold" "Times Bold Italic"  "Helvetica"  "Helvetica  Italic"...
+        "Helvetica Bold" "Helvetica Bold Italic"];
+  TCL_SetVar("curfontstyle",ged_fontarray(h.font_style+1))
+  TCL_SetVar("curfontsize",string(h.font_size))
+  TCL_SetVar("curtext",h.text)
+
+  TCL_EvalFile(SCI+'/tcl/ged/Legend.tcl')
+endfunction
+
+
+function ged_arc(h)
+  global ged_handle; ged_handle=h
+
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+  ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"];
+  TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+  TCL_SetVar("nbcol",string(size(h.data,2)))
+  for i=1:size(h.data,2)
+    val= "arcVAL("+string(i)+")";
+      TCL_EvalStr('set '+val+" "+string(h.data(2)));
+  end
+  f=h;while stripblanks(f.type)<>"Figure" then f=f.parent,end
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curcolor",string(h.foreground))
+  TCL_SetVar("curback",string(h.background))
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curlinemode",h.line_mode)
+  TCL_SetVar("curfillmode",h.fill_mode)
+  TCL_SetVar("curthick",string(h.thickness))
+
+  ax=getparaxe(h);
+  // Arc data
+  select ax.view
+  case "2d" 
+    drawlater();
+    ax.view='3d'  //strange behavior in 3D... seems to be bugged!!
+    TCL_SetVar("Xval",string(h.data(1)))
+    TCL_SetVar("Yval",string(h.data(2)))
+    TCL_SetVar("Zval",string(h.data(3)))
+    TCL_SetVar("Wval",string(h.data(4)))
+    TCL_SetVar("Hval",string(h.data(5)))
+    TCL_SetVar("A1val",string(h.data(6)))
+    TCL_SetVar("A2val",string(h.data(7)))
+     ax.view='2d'
+     drawnow();
+    case "3d"
+    TCL_SetVar("Xval",string(h.data(1)))
+    TCL_SetVar("Yval",string(h.data(2)))
+    TCL_SetVar("Zval",string(h.data(3)))
+    TCL_SetVar("Wval",string(h.data(4)))
+    TCL_SetVar("Hval",string(h.data(5)))
+    TCL_SetVar("A1val",string(h.data(6)))
+    TCL_SetVar("A2val",string(h.data(7)))
+  end
+  TCL_EvalFile(SCI+'/tcl/ged/Arc.tcl')
+endfunction
+
+
+function ged_segs(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curarrowsize",string(h.arrow_size))
+  TCL_SetVar("curthick",string(h.thickness))
+  ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"]; 
+  TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+
+  ged_markstylearray=["dot" "plus" "cross" "star" "filled diamond" ..
+  "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+  "asterisk" "square" "triangle right" "triangle left" "pentagram"];
+
+  TCL_SetVar("curmarkstyle",ged_markstylearray(abs(h.mark_style)+1))
+  TCL_SetVar("curmarkmode",h.mark_mode)
+  TCL_SetVar("curmarksize",string(h.mark_size))
+  TCL_SetVar("curmarksizeunit",h.mark_size_unit);
+  TCL_SetVar("curmarkforeground",string(h.mark_foreground))
+  TCL_SetVar("curmarkbackground",string(h.mark_background))
+  TCL_SetVar("curlinemode",h.line_mode)
+    
+  TCL_SetVar("nbrow",string(size(h.data,1)))
+  
+   d="["+strcat(string(size(h.data)),'x')+" double array]"
+  TCL_SetVar("curdata",d);
+  
+  TCL_SetVar("nbcolsegscolor",string(size(h.segs_color,2)))
+  for i=1:size(h.segs_color,2)
+    val= "segscolorVAL("+string(i)+")";
+    TCL_EvalStr('set '+val+" "+string(h.segs_color(i)));
+  end
+
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Segs.tcl')
+endfunction
+
+
+function ged_champ(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curcolored",h.colored)
+  TCL_SetVar("ncolors",string(size(f.color_map,1)))
+  TCL_SetVar("curarrowsize",string(h.arrow_size))
+  TCL_SetVar("curthick",string(h.thickness))
+  ged_linestylearray=["solid" "dash" "dash dot" "longdash dot" "bigdash dot" "bigdash longdash"]; 
+  TCL_SetVar("curlinestyle",ged_linestylearray(max(h.line_style,1)))
+
+  d="["+strcat(string(size(h.data.x)),'x')+" double array]"
+  TCL_SetVar("curdata_x",d);
+  d="["+strcat(string(size(h.data.y)),'x')+" double array]"
+  TCL_SetVar("curdata_y",d);
+  d="["+strcat(string(size(h.data.fx)),'x')+" double array]"
+  TCL_SetVar("curdata_fx",d);
+  d="["+strcat(string(size(h.data.fy)),'x')+" double array]"
+  TCL_SetVar("curdata_fy",d);
+
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Champ.tcl')
+endfunction
+
+function ged_fec(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("zbmin",string(h.z_bounds(1)))
+  TCL_SetVar("zbmax",string(h.z_bounds(2)))
+//  TCL_SetVar("nbrow",string(size(h.data,1)))
+//  TCL_SetVar("nbcol",string(size(h.data,2)))
+//  TCL_SetVar("nbrowTri",string(size(h.triangles,1)))
+//  TCL_SetVar("nbcolTri",string(size(h.triangles,2)))
+
+  d="["+strcat(string(size(h.data)),'x')+" double array]"
+  TCL_SetVar("curdata_data",d);
+  d="["+strcat(string(size(h.triangles)),'x')+" double array]"
+  TCL_SetVar("curdata_triangles",d);
+
+//  if (h.clip_box==[])
+//    TCL_SetVar("old_Xclipbox","")
+//    TCL_SetVar("old_Yclipbox","")
+//    TCL_SetVar("old_Wclipbox","")
+//    TCL_SetVar("old_Hclipbox","")
+//    TCL_SetVar("Xclipbox","")
+//    TCL_SetVar("Yclipbox","")
+//    TCL_SetVar("Wclipbox","")
+//    TCL_SetVar("Hclipbox","")
+//   else
+//    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+//    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+//    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+//    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+//    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+//  end
+//  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Fec.tcl')
+endfunction
+
+
+function ged_grayplot(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curdatamapping",h.data_mapping)
+  
+  
+  d="["+strcat(string(size(h.data.x)),'x')+" double array]"
+  TCL_SetVar("curdata_x",d);
+  d="["+strcat(string(size(h.data.y)),'x')+" double array]"
+  TCL_SetVar("curdata_y",d);
+  d="["+strcat(string(size(h.data.z)),'x')+" double array]"
+  TCL_SetVar("curdata_z",d);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Grayplot.tcl')
+
+endfunction
+
+function ged_matplot(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+
+  d="["+strcat(string(size(h.data)),'x')+" double array]"
+  TCL_SetVar("curdata",d);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Matplot.tcl')
+
+endfunction
+
+
+function ged_axis(h)
+  global ged_handle; ged_handle=h
+  TCL_SetVar("curvis",h.visible)
+  TCL_SetVar("curseg",h.tics_segment)
+  TCL_SetVar("curcolor",string(h.tics_color))
+  TCL_SetVar("curticsstyle",h.tics_style)
+  TCL_SetVar("curfontcolor",string(h.labels_font_color))
+  TCL_SetVar("curfontsize",string(h.labels_font_size))
+  TCL_SetVar("nbcolX",string(size(h.xtics_coord,2)))
+  TCL_SetVar("nbcolY",string(size(h.ytics_coord,2)))
+  TCL_SetVar("xticscoord",sci2exp(h.xtics_coord,0))
+  TCL_SetVar("yticscoord",sci2exp(h.ytics_coord,0))
+  TCL_SetVar("cursubtics",string(h.sub_tics))
+  TCL_SetVar("curticslabel",sci2exp(h.tics_labels,0))
+  TCL_SetVar("curticsdir",string(h.tics_direction))
+
+  if (h.clip_box==[])
+    TCL_SetVar("old_Xclipbox","")
+    TCL_SetVar("old_Yclipbox","")
+    TCL_SetVar("old_Wclipbox","")
+    TCL_SetVar("old_Hclipbox","")
+    TCL_SetVar("Xclipbox","")
+    TCL_SetVar("Yclipbox","")
+    TCL_SetVar("Wclipbox","")
+    TCL_SetVar("Hclipbox","")
+   else
+    TCL_SetVar("old_Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("old_Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("old_Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("old_Hclipbox",string(h.clip_box(4)))
+    TCL_SetVar("Xclipbox",string(h.clip_box(1)))
+    TCL_SetVar("Yclipbox",string(h.clip_box(2)))
+    TCL_SetVar("Wclipbox",string(h.clip_box(3)))
+    TCL_SetVar("Hclipbox",string(h.clip_box(4)))
+  end
+  TCL_SetVar("curclipstate",h.clip_state);
+
+  TCL_EvalFile(SCI+'/tcl/ged/Axis.tcl')
+endfunction
+
+
+function [h,Axes]=ged_getobject(pt)
+  h=[];Axes=[];
+  f=get("current_figure");
+  aold=get("current_axes")
+  axes_array=f.children
+  // assume that the lastly created objects
+  // are at the beginning of the arrays of children
+  // We can then select the last object
+  // first in the loop.
+  for k=1:size(axes_array,'*')
+    Axes=axes_array(k)
+    set("current_axes",Axes)
+    h=ged_loop(Axes,pt)
+    if h<>[] then break,end
+  end
+  set("current_axes",aold)
+endfunction
+
+function h=ged_loop(a,pt)
+
+  h=[]
+  minDist    = 0.01 ;
+  minPixDist = 3    ;
+  
+  for ka=1:size(a,'*')
+    ck=a(ka) ;
+    select ck.type
+      
+      case "Polyline"
+       xy=ck.data;
+       d=Dist2polyline((xy(:,1)-Xmin)/Dx,(xy(:,2)-Ymin)/Dy,pts)
+       if d < minDist then h=ck,return,end
+       
+      case "Rectangle"
+       xy=ck.data;
+       x0=xy(1);y0=xy(2);W=xy(3);H=xy(4);
+       d=Dist2polyline((x0+[0,W,W,0]-Xmin)/Dx,(y0+[0,0,-H,-H]-Ymin)/Dy,pts)
+       if d < minDist then h=ck,return,end
+    
+      case "Arc" 
+       xy=ck.data;
+       [xp,yp]=xchange(pt(1),pt(2),'i2f')
+       //[dist, toto] = dist2Arc( [xp,yp] ./ [Dx,Dy], xy(1:2)./[Dx,Dy], xy(3)/Dx, xy(4)/Dy, xy(5) / 64., xy(6) / 64. ) ;
+       dist = pixDist2Arc( [xp,yp], xy(1:2), xy(3), xy(4), xy(5) / 64., xy(6) / 64. ) ;
+       if dist <= minPixDist then 
+         h=ck;
+         return;
+       end
+      
+      case "Segs"
+       xy=ck.data;
+       xv=matrix(xy(:,1),2,-1)
+       yv=matrix(xy(:,2),2,-1)
+       dx=(xv(1,:)-xv(2,:))
+       dy=(yv(1,:)-yv(2,:))
+       d_d=dx.^2+dy.^2
+       
+      case "Compound"
+       h=ged_loop(ck.children,pt)
+       if h<>[] then return,end
+       
+      case "Axes"
+       xy=ck.data_bounds;
+       [xp,yp]=xchange(pt(1),pt(2),'i2f')
+       Xmin=xy(1,1);Ymin=xy(1,2),Dx=xy(2,1)-xy(1,1);Dy=xy(2,2)-xy(1,2);
+       pts=[(xp-Xmin)/Dx (yp-Ymin)/Dy]
+       d=Dist2polyline([0,1,1,0],[0,0,1,1],pts)
+       if d < minDist then h=ck,return,end
+       h=ged_loop([a.children(:);ck.x_label;ck.y_label;ck.z_label;ck.title],pt)
+       if h<>[] then return,end
+       
+      case "Text"
+       if is_in_text(ck,[xp;yp]) then
+         h=ck,
+         return,
+       end
+       
+      case "Label"
+       if is_in_text(ck,[xp;yp]) then
+         h=ck
+         return,
+       end
+       
+      end
+    end
+endfunction
+  
+function r=is_in_text(h,xy)
+  r = stringbox(h);
+  r=[r r(:,1)];
+  r=and([xy(2) -xy(1)]*diff(r,1,2)+(r(1,1:$-1).*r(2,2:$)-r(1,2:$).*r(2,1:$-1))<0)
+endfunction
+
+// compute the square of distance between a point and the ellipse 
+// in 2D included in an axis aligned rectangle whose upper left 
+// corner is upperLeft and its wifth and heigth is defined.
+function [dist] = dist2Ellipse( point, upperLeft, width, heigth )
+  width2  = width  / 2. ;
+  heigth2 = heigth / 2. ;
+  centerC = [ upperLeft(1) + width2, upperLeft(2) - heigth2 ] ; // center of the ellipse
+  
+  // clicked point in the circle frame
+  pointC  = [ (point(1) - centerC(1)) / width2, (point(2) - centerC(2)) / heigth2 ] ;
+  
+  // get the vector between the point and the closest on the circle
+  diffclose = ( 1 - 1 / norm( pointC ) ) * pointC ;
+  //closest = pointC / sqrt( pointC(1) * pointC(1) + pointC(2) * pointC(2) ) ;
+  
+  // get the difference between the two
+  //ffclose = pointC - closest ;
+  
+  // bring it back to the current frame value
+  diffclose(1) = diffclose(1) * width2  ;
+  diffclose(2) = diffclose(2) * heigth2 ;
+  
+  // get the distance with the closest point
+  dist = norm( diffclose ) ;
+  
+endfunction
+
+// compute the distance between a point and the arc 
+// in 2D included in an axis aligned rectangle whose upper left 
+// corner is upperLeft and its wifth and heigth is defined.
+function [dist,diffClose] = dist2Arc( point, upperLeft, width, heigth, sector1, sector2 )
+
+
+  if ( width == 0 | heigth == 0 ) then
+    dist = %inf ;
+    diffClose = [%inf,%inf];
+    return ;
+  end
+  
+  // convert the sector into radiant angle
+  angle1 =  sector1            * %pi / 180. ;
+  angle2 = (sector1 + sector2) * %pi / 180. ;
+  
+  width2  = width  / 2. ;
+  heigth2 = heigth / 2. ;
+  centerC = [ upperLeft(1) + width2, upperLeft(2) - heigth2 ] ; // center of the ellipse
+  
+  // clicked point in the circle frame
+  pointC  = [ (point(1) - centerC(1)) / width2, (point(2) - centerC(2)) / heigth2 ] ;
+  
+  // get the projection of the clicked point on the circle
+  closest = pointC / norm( pointC ) ;
+  
+  // now a quite tricky part. The aim is to find
+  // if the closest point is in the drawing sector
+  // ie if it is between bound1 and bound2 on the circle
+  // maybe a eayer solution exists.
+  
+  // get the boundaries of the displayed angle
+  // the closest point is not on the arc it is one of the two
+  // boundaries
+  bound1 = [cos(angle1),sin(angle1)] ;
+  bound2 = [cos(angle2),sin(angle2)] ;
+  
+  // now get the vector of bissecting line between the two bounds
+  // with the orientation toward the arc
+  b2b1       = bound1 -  bound2 ;
+  bissect(1) = -b2b1(2)         ;
+  bissect(2) =  b2b1(1)         ;
+  
+  // get the position of the point along this axis
+  side = closest(1) * bissect(1) + closest(2) * bissect(2) ;
+  
+  // get the position of one of the bound (same value for both)
+  boundPos = bound1(1) * bissect(1) + bound1(2) * bissect(2) ;
+  
+  if side > boundPos  then
+    // the closest point is on the arc
+    diffClose = ( pointC - closest ) .* [width2,heigth2] ;
+    // bring it back to the current frame value
+    //diffclose = diffclose .* [width2,heigth2] ;
+  
+    // get the distance with the closest point
+    dist = norm( diffClose ) ;
+    
+  else
+    // the closest point is one of the bounds
+    // return back to the real coordinates
+    bound1 = centerC + bound1 .* [width2,heigth2];
+    bound2 = centerC + bound2 .* [width2,heigth2];
+    
+    // get the minimum distance
+    dist  = norm( bound1 - point ) ;
+    dist2 = norm( bound2 - point ) ;
+    if dist > dist2 then
+      diffClose = bound1 - point ;
+    else
+      dist = dist2 ;
+      diffClose = bound2 - point ;
+    end
+    //dist = min( norm( bound1 - point ), norm( bound2 - point ) ) ;
+  end  
+  
+endfunction
+
+// same as before but return the value in pixels
+function dist = pixDist2Arc( point, upperLeft, width, heigth, sector1, sector2 )
+  
+  [dist, difference] = dist2Arc( point, upperLeft, width, heigth, sector1, sector2 ) ;
+  // convert to pixels
+  // get the length of the difference vector
+  // we construct it by getting two points
+  [origin(1),origin(2)] = xchange(0,0,'f2i');
+  [extremity(1),extremity(2)] = xchange(difference(1),difference(2),'f2i');
+  dist = norm( extremity - origin ) ;
+
+endfunction
+
+function [d,pt,ind]=Dist2polyline(xp,yp,pt)
+// computes minimum distance from a point to a polyline
+//d    minimum distance to polyline
+//pt   coordinate of the polyline closest point
+//ind  
+//     if negative polyline closest point is a polyline corner:pt=[xp(-ind) yp(-ind)]
+//     if positive pt lies on segment [ind ind+1]
+
+// Copyright INRIA
+x=pt(1)
+y=pt(2)
+xp=xp(:);yp=yp(:)
+cr=4*sign((xp(1:$-1)-x).*(xp(1:$-1)-xp(2:$))+..
+          (yp(1:$-1)-y).*(yp(1:$-1)-yp(2:$)))+..
+    sign((xp(2:$)-x).*(xp(2:$)-xp(1:$-1))+..
+          (yp(2:$)-y).*(yp(2:$)-yp(1:$-1)))
+
+ki=find(cr==5) // index of segments for which projection fall inside
+np=size(xp,'*')
+if ki<>[] then
+  //projection on segments
+  x=[xp(ki) xp(ki+1)]
+  y=[yp(ki) yp(ki+1)]
+  dx=x(:,2)-x(:,1)
+  dy=y(:,2)-y(:,1)
+  d_d=dx.^2+dy.^2
+  d_x=( dy.*(-x(:,2).*y(:,1)+x(:,1).*y(:,2))+dx.*(dx*pt(1)+dy*pt(2)))./d_d
+  d_y=(-dx.*(-x(:,2).*y(:,1)+x(:,1).*y(:,2))+dy.*(dx*pt(1)+dy*pt(2)))./d_d
+  xp=[xp;d_x]
+  yp=[yp;d_y]
+end
+[d,k]=min(((xp-pt(1))).^2+((yp-pt(2))).^2) //distance with all points
+d=sqrt(d)
+pt(1)=xp(k)
+pt(2)=yp(k)
+if k>np then ind=ki(k-np),else ind=-k,end
+endfunction
+
+function ged_eventhandler(win,x,y,ibut)
+//Copyright INRIA
+//Author : Serge Steer 2002
+
+  if or(win==winsid()) then //does the windows still exists
+
+//    seteventhandler("")  
+  else //window has been deleted by an asynchronous xdel()
+    return
+  end
+
+  if ibut<0 then 
+    if ibut==-1000 then //the window has been closed by the window manager
+      return
+    end
+ //   seteventhandler("ged_eventhandler"),
+    return,
+  end
+//  seteventhandler("")  
+  if ibut==10 then
+      ax=ged_select_axes(x,y)
+      if ax<>[] then sca(ax),twinkle(ax,1),end
+      return
+  end 
+  global ged_handle;ged_handle=[]
+  cur=gcf();scf(win)
+  ged_handle=ged_getobject([x,y])
+    
+  scf(cur)
+
+  if ged_handle~=[] then
+    if ibut==0 | ibut==3  then
+      //Set(h)
+      tkged()
+    elseif ibut==2 | ibut==5 then
+      [x,y]=xchange(x,y,'i2f')
+      pos=[x,y]
+      while %t then
+       rep=xgetmouse(0,[%t %t])
+       if rep(3)>0 then break,end
+       
+       move(ged_handle,rep(1:2)-pos)
+       show_pixmap()
+       pos=rep(1:2)
+      end
+//    elseif ibut==3 then
+//      delete(ged_handle)
+    end
+  end
+//  seteventhandler("ged_eventhandler")  
+endfunction
+
+function [ini,typs]=build_args(labels)
+  n=size(labels,'*')
+  ini=[]
+  typs=list()
+  for k=1:n
+    typ=type(h(labels(k)))
+    execstr(['if typ==10 then'
+            '   w=h.'+labels(k)
+            'else'
+            '   w=sci2exp(h.'+labels(k)+',0)'
+            'end'])
+    ini=[ini;w]
+    if typ==10 then
+      typs($+1)="str";typs($+1)=-1
+    else
+      typs($+1)="vec";typs($+1)=1
+    end
+  end
+endfunction
+
+function GetSetValue(h)
+  n=size(labels,'*')
+  lhs='[ok,'+strcat('x'+string(1:n),',')+']'
+  execstr(lhs+'=getvalue(t,labels,typs,ini)')
+  if ok then
+    for k=1:n
+      execstr("if x'+string(k)+'<>h."+labels(k)+' then h.'+..
+             labels(k)+'=x'+string(k)+',end')
+    end
+  end
+endfunction
+
+
+
+function tkged()
+global ged_handle
+global ged_cur_fig_handle
+
+h=ged_handle
+
+// hierarchical viewer
+TK_send_handles_list(ged_cur_fig_handle)
+TCL_SetVar("curgedindex",string(Get_handle_pos_in_list(h)))
+
+//color_map array for color sample display
+f=getparfig(h);
+for i=1:size(f.color_map,1)
+  redname= "RED("+string(i)+")";
+  TCL_EvalStr('set '+redname+" "+string(f.color_map(i,1)));
+  grename= "GREEN("+string(i)+")";
+  TCL_EvalStr('set '+grename+" "+string(f.color_map(i,2)));
+  bluname= "BLUE("+string(i)+")";
+  TCL_EvalStr('set '+bluname+" "+string(f.color_map(i,3)));
+end
+
+TCL_SetVar("msdos",string(MSDOS)) // to know the OS
+// get the number of the window associated with ged
+TCL_SetVar("sciGedIsAlive",string(ged_cur_fig_handle.figure_id)) ;
+
+select h.type
+case "Polyline"
+  ged_polyline(h)
+case "Rectangle"
+  ged_rectangle(h)
+case "Axes"
+  ged_axes(h)
+case "Label" // for now the labels are inside the axes (F.Leray 06.12.05)
+  ged_axes(h.parent)
+  if (h == h.parent.x_label)
+    TCL_EvalStr("Notebook:raise $uf.n X");
+  elseif (h == h.parent.y_label)
+    TCL_EvalStr("Notebook:raise $uf.n Y");
+  elseif (h == h.parent.z_label)
+    TCL_EvalStr("Notebook:raise $uf.n Z");
+  elseif (h == h.parent.title)
+    TCL_EvalStr("Notebook:raise $uf.n Title");
+  end
+case "Figure"
+  ged_figure(h)
+case "Compound"
+  ged_Compound(h)
+  
+case "Plot3d"
+  ged_plot3d(h)
+case "Fac3d"
+  ged_fac3d(h)
+case "Text"
+  ged_text(h)
+case "Legend"
+ged_legend(h)
+case "Arc"
+  ged_arc(h)
+case "Segs"
+  ged_segs(h)    
+case "Champ"
+  ged_champ(h)
+case "Fec"
+  ged_fec(h)
+case "Grayplot"
+  ged_grayplot(h)
+case "Matplot"
+  ged_matplot(h)
+case "Axis"
+  ged_axis(h)
+end
+endfunction
+  
+function setStyle(sty)
+  global ged_handle; h=ged_handle
+  h.polyline_style=find(sty==['interpolated','staircase', ...
+                   'barplot','arrowed','filled' 'bar'])
+endfunction
+function setLineStyle(sty)
+  global ged_handle; h=ged_handle
+  h.line_style=find(sty==[ "solid" "dash" "dash dot" "longdash dot" ..
+                   "bigdash dot" "bigdash longdash"])
+  
+endfunction
+function setMarkStyle(sty)
+  global ged_handle; h=ged_handle
+  h.mark_style=find(sty==["dot" "plus" "cross" "star" "filled diamond" ..
+  "diamond" "triangle up" "triangle down" "diamond plus" "circle" ..
+  "asterisk" "square" "triangle right" "triangle left" "pentagram"])-1
+endfunction
+function setFontStyle(ftn)
+  global ged_handle; h=ged_handle
+  h.font_style=find(ftn==["Courier" "Symbol" "Times",..
+                   "Times Italic" "Times Bold" "Times Bold Italic",..
+                  "Helvetica"  "Helvetica Italic" "Helvetica Bold",..
+                  "Helvetica Bold Italic"])-1
+endfunction
+
+function setLabelsFontStyle(label,ftn)
+   global ged_handle; h=ged_handle
+select label
+case "t"
+  h.title.font_style=find(ftn==["Courier" "Symbol" "Times",..
+                   "Times Italic" "Times Bold" "Times Bold Italic",..
+                  "Helvetica"  "Helvetica Italic" "Helvetica Bold",..
+                  "Helvetica Bold Italic"])-1
+case "x"
+  h.x_label.font_style=find(ftn==["Courier" "Symbol" "Times",..
+                   "Times Italic" "Times Bold" "Times Bold Italic",..
+                  "Helvetica"  "Helvetica Italic" "Helvetica Bold",..
+                  "Helvetica Bold Italic"])-1
+case "y"
+  h.y_label.font_style=find(ftn==["Courier" "Symbol" "Times",..
+                   "Times Italic" "Times Bold" "Times Bold Italic",..
+                  "Helvetica"  "Helvetica Italic" "Helvetica Bold",..
+                  "Helvetica Bold Italic"])-1
+case "z"
+  h.z_label.font_style=find(ftn==["Courier" "Symbol" "Times",..
+                   "Times Italic" "Times Bold" "Times Bold Italic",..
+                  "Helvetica"  "Helvetica Italic" "Helvetica Bold",..
+                  "Helvetica Bold Italic"])-1
+end;
+endfunction
+
+
+// Axes data (data_bounds)
+function setXdb(xmin, xmax)
+  global ged_handle; h=ged_handle
+  tmp=h.data_bounds;
+  tmp(1,1)=xmin;
+  tmp(2,1)=xmax;
+  h.data_bounds=tmp;
+//  tst=execstr('h.data_bounds=tmp','errcatch','n');
+//  if tst<>0 then
+//   disp 'Warning: X data_bounds must contain double'
+//  end
+endfunction
+
+
+function setYdb(ymin, ymax)
+  global ged_handle; h=ged_handle
+  tmp=h.data_bounds;
+  tmp(1,2)=ymin;
+  tmp(2,2)=ymax;
+  h.data_bounds=tmp;
+//  tst=execstr('h.data_bounds=tmp','errcatch','n');
+//  if tst<>0 then
+//   disp 'Warning: Y data_bounds must contain double'
+//  end
+endfunction
+
+function setZdb(zmin, zmax)
+  global ged_handle; h=ged_handle
+ select h.view
+     case "2d"
+      drawlater();
+      h.view='3d';
+      tmp=h.data_bounds;
+      tmp(1,3)=zmin;
+      tmp(2,3)=zmax;
+      h.data_bounds=tmp;
+      h.view='2d';
+      drawnow();
+//      tst=execstr('h.data_bounds=tmp','errcatch','n');
+//      h.view='2d';
+//      if tst<>0 then
+//       disp 'Warning: Z data_bounds must contain double'
+//      end
+     case "3d"
+      tmp=h.data_bounds;
+      tmp(1,3)=zmin;
+      tmp(2,3)=zmax;
+      h.data_bounds=tmp;
+//      tst=execstr('h.data_bounds=tmp','errcatch','n');
+//      if tst<>0 then
+//        disp 'Warning: Z data_bounds must contain double'
+//      end
+     end
+endfunction
+
+
+function LogtoggleX( tog)
+ global ged_handle; h=ged_handle
+
+ h.log_flags=tog+part(h.log_flags,2);
+
+
+//tst=execstr("global h;h.log_flags=tog+part(h.log_flags,2)",'errcatch','n');
+
+//if tst<>0 then
+//   disp 'Warning: X bounds must be strictly positive'
+//end
+endfunction
+
+function LogtoggleY( tog)
+ global ged_handle; h=ged_handle
+
+ h.log_flags=part(h.log_flags,1)+tog;
+
+
+//tst=execstr("global h;h.log_flags=part(h.log_flags,1)+tog",'errcatch','n');
+
+//if tst<>0 then
+//   disp 'Warning: Y bounds must be strictly positive'
+//end
+
+endfunction
+
+
+function LogtoggleZ( tog)
+ global ged_handle; h=ged_handle
+
+ h.log_flags=part(h.log_flags,1)+part(h.log_flags,2)+tog;
+
+
+//tst=execstr("global h;h.log_flags=part(h.log_flags,1)+tog",'errcatch','n');
+
+//if tst<>0 then
+//   disp 'Warning: Z bounds must be strictly positive'
+//end
+
+endfunction
+
+
+
+function [haxe] = getparaxe( h )
+
+htmp = h;
+haxe = [];
+while htmp.type<>'Axes' do
+  htmp = htmp.parent
+end
+
+haxe = htmp;
+endfunction
+
+
+
+
+// Rectangle data
+function setXval(val)
+  global ged_handle; h=ged_handle
+  tmp=h.data;
+  tmp(1)=val;
+  tst=execstr('h.data=tmp','errcatch','n');
+  if tst<>0 then
+   disp 'Warning: Y data must contain double'
+  end
+endfunction
+
+function setYval(val)
+  global ged_handle; h=ged_handle
+  tmp=h.data;
+  tmp(2)=val;
+  tst=execstr('h.data=tmp','errcatch','n');
+  if tst<>0 then
+   disp 'Warning: Y data must contain double'
+  end
+endfunction
+
+function setZval(val)
+  global ged_handle; h=ged_handle
+  ax=getparaxe(h);
+ select ax.view
+     case "2d"
+      drawlater();
+      ax.view='3d';
+      tmp=h.data;
+      tmp(3)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      ax.view='2d';
+      drawnow();
+      if tst<>0 then
+       disp 'Warning: Z data must contain double'
+      end
+     case "3d"
+      tmp=h.data;
+      tmp(3)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      if tst<>0 then
+        disp 'Warning: Z data must contain double'
+      end
+     end
+endfunction
+
+
+function setWval(val)
+  global ged_handle; h=ged_handle
+ ax=getparaxe(h);
+ select ax.view
+     case "2d"
+      drawlater();
+      ax.view='3d';
+      tmp=h.data;
+      tmp(4)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      ax.view='2d';
+      drawnow();
+      if tst<>0 then
+       disp 'Warning: Width data must contain double'
+      end
+     case "3d"
+      tmp=h.data;
+      tmp(4)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      if tst<>0 then
+        disp 'Warning: Width data must contain double'
+      end
+     end
+endfunction
+
+
+function setHval(val)
+  global ged_handle; h=ged_handle
+ ax=getparaxe(h);
+ select ax.view
+     case "2d"
+      drawlater();
+      ax.view='3d';
+      tmp=h.data;
+      tmp(5)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      ax.view='2d';
+      drawnow();
+      if tst<>0 then
+       disp 'Warning: Height data must contain double'
+      end
+     case "3d"
+      tmp=h.data;
+      tmp(5)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      if tst<>0 then
+        disp 'Warning: Height data must contain double'
+      end
+     end
+endfunction
+
+
+// complement for Arc entity
+function setA1val(val)
+  global ged_handle; h=ged_handle
+ ax=getparaxe(h);
+ select ax.view
+     case "2d"
+      drawlater();
+      ax.view='3d';
+      tmp=h.data;
+      tmp(6)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      ax.view='2d';
+      drawnow();
+      if tst<>0 then
+       disp 'Warning: Width data must contain double'
+      end
+     case "3d"
+      tmp=h.data;
+      tmp(6)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      if tst<>0 then
+        disp 'Warning: a1 data must contain double'
+      end
+     end
+endfunction
+
+function setA2val(val)
+  global ged_handle; h=ged_handle
+ ax=getparaxe(h);
+ select ax.view
+     case "2d"
+      drawlater();
+      ax.view='3d';
+      tmp=h.data;
+      tmp(7)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      ax.view='2d';
+      drawnow();
+      if tst<>0 then
+       disp 'Warning: Width data must contain double'
+      end
+     case "3d"
+      tmp=h.data;
+      tmp(7)=val;
+      tst=execstr('h.data=tmp','errcatch','n');
+      if tst<>0 then
+        disp 'Warning: a2 data must contain double'
+      end
+     end
+endfunction
+
+
+//Fec
+function setZb(min, max)
+  global ged_handle; h=ged_handle
+  tmp=h.z_bounds;
+  tmp(1,1)=min;
+  tmp(1,2)=max;
+  tst=execstr('h.z_bounds=tmp','errcatch','n');
+  if tst<>0 then
+   disp 'Warning: X data_bounds must contain double'
+  end
+endfunction
+
+
+
+////////////////////////////////
+// Scilab Command Interface ////
+////////////////////////////////
+//Plot3d
+function set3dtlistXYZ (X,Y,Z)
+  global ged_handle; h=ged_handle
+  ged_tmp_tlist = tlist(["3d","x","y","z"],X,Y,Z)
+  h.data=ged_tmp_tlist;
+  clear ged_tmp_tlist;
+endfunction
+
+function set3dtlistXYZC (X,Y,Z,COLOR)
+  global ged_handle; h=ged_handle
+  ged_tmp_tlist = tlist(["3d","x","y","z","color"],X,Y,Z,COLOR)
+  h.data=ged_tmp_tlist;
+  clear ged_tmp_tlist;
+endfunction
+
+function setGrayplottlist(X,Y,Z)
+  global ged_handle; h=ged_handle
+  ged_tmp_tlist = tlist(["grayplotdata","x","y","z"],X,Y,Z)
+  h.data=ged_tmp_tlist;
+  clear ged_tmp_tlist;
+endfunction
+
+//Champ
+function setchamptlistXYFXFY (X,Y,FX,FY)
+  global ged_handle; h=ged_handle
+  ged_tmp_tlist = tlist(["champdata","x","y","fx","fy"],X,Y,FX,FY)
+  h.data=ged_tmp_tlist;
+  clear ged_tmp_tlist;
+endfunction
+
+
+///////////////////////////////
+// Edit Data using sciGUI /////
+///////////////////////////////
+
+function EditData(TheData,datastring)
+// TheData must be a real scalar or matrix
+global ged_handle; h=ged_handle
+
+// I declare ged_tmp ged_tmp_string WINDOW as global
+global ged_tmp;
+global ged_tmp_string;
+global WINDOW;
+
+ged_tmp_string = datastring;
+
+ged_tmp=TheData;
+
+WINDOW = GEDeditvar("ged_tmp")
+
+endfunction
+
+
+function CloseEditorSaveData()
+// Called when closing data editor
+
+global ged_handle; // To leave here because used when doing execstr(ged_tmp_string...
+global ged_tmp;
+global ged_tmp_string;
+global WINDOW;
+
+Nan = %nan // to avoid error message because of special Nan display
+
+ged_tmp=GEDeditvar_get(WINDOW);
+
+execstr(ged_tmp_string+"= ged_tmp");
+
+clearglobal ged_tmp ged_tmp_string WINDOW
+clear ged_tmp ged_tmp_string WINDOW
+
+endfunction
+
+
+function outvar=GEDeditvar_get(winId)
+// Simple variable editor - import data
+// This file is part of sciGUI toolbox
+// Copyright (C) 2004 Jaime Urzua Grez
+// mailto:jaime_urzua@yahoo.com
+// rev. 0.1
+  //
+// This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; either version 2 of the License, or
+//(at your option) any later version.
+
+//disp("Please wait...");
+outvar=[];
+base="sciGUITable(win,"+string(winId)+",data";
+varType=evstr(TCL_GetVar(base+',type)'));
+varni=evstr(TCL_GetVar(base+',ni)'));
+varnj=evstr(TCL_GetVar(base+',nj)'));
+for j=1:varnj,
+       ww=[];
+       for i=1:varni,
+               q=TCL_GetVar(base+','+string(i)+','+string(j)+')');
+               if (varType~=10) then
+                       if (varType==4) then
+                               if ((q=="T")|(q=="t")) then
+                                       ww=[ww;%t];
+                               else
+                                       ww=[ww;%f];
+                               end
+                       else
+                               ww=[ww;evstr(q)];
+                       end
+               else
+                       ww=[ww;q];
+               end
+       end
+       outvar=[outvar ww];
+end
+endfunction
+
+function [WINID] = GEDeditvar(varargin)
+// Simple Variable Editor
+// This file is part of sciGUI toolbox
+// Copyright (C) 2004 Jaime Urzua Grez 
+// mailto:jaime_urzua@yahoo.com
+// rev. 0.2 2004/06/24
+//
+// This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; either version 2 of the License, or
+//(at your option) any later version.
+  
+  sciGUI_init()
+  
+  [%_nams]=who('get');
+  %_loc_type=type(varargin(1))
+  if (%_loc_type~=10) then error(42), end
+  %_in_list=find(%_nams==varargin(1));
+  if (%_in_list==[]) then error(42), end
+  execstr("%_loc_var="+varargin(1));
+  %_loc_type=type(%_loc_var);
+  %_allo=find([1;4;10]==%_loc_type);
+  if (%_allo==[]) then error(42), end
+
+  //disp("Please wait...");
+  %_loc_nam=varargin(1);
+  %_loc_ni=size(%_loc_var,1);
+  %_loc_nj=size(%_loc_var,2);
+  %_loc_type=string(%_loc_type);
+
+  TCL_EvalStr("set EdVarLoc [GEDsciGUIEditVar -1]");
+
+  %_winId=TCL_GetVar("EdVarLoc");
+
+  TCL_SetVar("sciGUITable(win,"+%_winId+",data,name)",%_loc_nam);
+  TCL_SetVar("sciGUITable(win,"+%_winId+",data,type)",string(%_loc_type));
+  TCL_SetVar("sciGUITable(win,"+%_winId+",data,ni)",string(%_loc_ni));
+  TCL_SetVar("sciGUITable(win,"+%_winId+",data,nj)",string(%_loc_nj));
+
+  //
+  // This is a slow manner to move the data ...
+  // Anyone have a faster method than TCL_SetVar
+  // I would like set some tcl variable like varname(pos_i,pos_j)
+  //
+  Nb_data=(%_loc_nj)*(%_loc_ni)
+ // disp("Nb_data=")
+ // disp(Nb_data);
+ // winWB=waitbar('Loading data...');
+ // tmp = 0;
+ // waitbar(tmp,winWB);
+
+  for %_j=1:%_loc_nj,
+    for %_i=1:%_loc_ni,
+      %_value=string(%_loc_var(%_i,%_j));
+      %_varname="sciGUITable(win,"+%_winId+",data,"+string(%_i)+","+string(%_j)+")";
+      TCL_SetVar(%_varname,%_value);
+    end
+
+  //tmp = ((%_j)*(%_loc_ni)) / Nb_data;
+  //tmp = tmp *100; tmp = int(tmp); tmp = tmp /100;
+  //disp("tmp dans for=")
+  //disp(tmp)
+  //waitbar(tmp,winWB);
+  end
+
+
+ // disp("%_winId=");
+ // disp(%_winId);
+ // disp("type(%_winId)=");
+ // disp(type(%_winId));
+ // disp("winWB=");
+ // disp(winWB);
+ // disp("type(winWB)=");
+ // disp(type(winWB));
+ // disp("AVANT DrawGrid");
+
+  TCL_EvalStr("GEDsciGUIEditVarDrawGrid "+%_winId)
+  WINID = %_winId;
+
+endfunction
+
+
+// for the ticks arrays Locations and Labels (inside TLIST)
+
+function ged_tablo=GetTab(val,index)
+//disp("ICI")
+ged_tablo(index) =val
+endfunction
+
+
+function ged_tablo=GetTab2(val,index,ged_tablo)
+//disp("ICI")
+ged_tablo(index) =val
+endfunction
+
+function setTicksTList(XYZ,locations,labels)
+global ged_handle;h= ged_handle;
+
+TL=tlist(['ticks','locations','labels'],locations,labels);
+
+if XYZ=='X'
+ h.x_ticks=TL;
+elseif XYZ=='Y'
+ h.y_ticks=TL;
+elseif XYZ=='Z'
+ h.z_ticks=TL;
+end
+
+endfunction
+
+
+// Is called by ged_axes 
+
+function LoadTicks2TCL(h)
+global ged_handle;ged_handle=h;
+
+TCL_SetVar("Xaxes_visibleToggle",h.axes_visible(1))
+TCL_SetVar("Yaxes_visibleToggle",h.axes_visible(2))
+TCL_SetVar("Zaxes_visibleToggle",h.axes_visible(3))
+
+TCL_SetVar("SubticksEntryX",string(h.sub_ticks(1)))
+TCL_GetVar("SubticksEntryX")
+
+// disp("h.sub_ticks(1) =")
+// disp(h.sub_ticks(1));
+
+TCL_SetVar("SubticksEntryY",string(h.sub_ticks(2)))
+
+select h.view
+case "2d" 
+  drawlater(); // postpon the drawings due to switching from 2d to 3d mode (for example)
+  // in order to know the complete data set (z data for axes...)
+  h.view='3d'
+  
+  TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3)))
+  h.view='2d'
+  drawnow();
+case "3d"
+  TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3)))
+end
+
+TCL_SetVar("XautoticksToggle",h.auto_ticks(1))
+TCL_SetVar("YautoticksToggle",h.auto_ticks(2))
+TCL_SetVar("ZautoticksToggle",h.auto_ticks(3))
+
+//ticks value: X axis
+ticks = h.x_ticks;
+sizeticks = size(ticks.locations,1);
+TCL_SetVar("nbticks_x",string(sizeticks));
+for i=1:sizeticks
+  val= "LOCATIONS_X("+string(i)+")";
+  TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+  val= "LABELS_X("+string(i)+")";
+  TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+end
+
+//ticks value: Y axis
+ticks = h.y_ticks;
+sizeticks = size(ticks.locations,1);
+TCL_SetVar("nbticks_y",string(sizeticks));
+for i=1:sizeticks
+  val= "LOCATIONS_Y("+string(i)+")";
+  TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+  val= "LABELS_Y("+string(i)+")";
+  TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+end
+
+//ticks value: Z axis
+ticks = h.z_ticks;
+sizeticks = size(ticks.locations,1);
+TCL_SetVar("nbticks_z",string(sizeticks));
+for i=1:sizeticks
+  val= "LOCATIONS_Z("+string(i)+")";
+  TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+  val= "LABELS_Z("+string(i)+")";
+  TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+end
+
+endfunction
+
+
+
+function Subtickstoggle( tog, index)
+ global ged_handle; h=ged_handle
+
+ subticks=h.sub_ticks;
+ subticks(index)=tog;
+//disp("subticks vaut:")
+//disp(subticks)
+
+ h.sub_ticks = subticks;
+endfunction
+
+
+// when clicking on Ticks button : REload ticks is called
+
+function ReLoadTicks2TCL(h)
+  global ged_handle;ged_handle=h;
+
+  TCL_SetVar("Xaxes_visibleToggle",h.axes_visible(1))
+  TCL_SetVar("Yaxes_visibleToggle",h.axes_visible(2))
+  TCL_SetVar("Zaxes_visibleToggle",h.axes_visible(3))
+
+  ticks = h.x_ticks;
+  sizeticks = size(ticks.locations,1);
+  if (sizeticks <> 0)
+   TCL_EvalStr("unset LOCATIONS_X");
+   TCL_EvalStr("unset LABELS_X");
+  end
+  
+  ticks = h.y_ticks;
+  sizeticks = size(ticks.locations,1);
+  if (sizeticks <> 0)
+   TCL_EvalStr("unset LOCATIONS_Y");
+   TCL_EvalStr("unset LABELS_Y");
+  end
+  
+  ticks = h.z_ticks;
+  sizeticks = size(ticks.locations,1);
+  if (sizeticks <> 0)
+   TCL_EvalStr("unset LOCATIONS_Z");
+   TCL_EvalStr("unset LABELS_Z");
+  end
+  
+  TCL_SetVar("SubticksEntryX",string(h.sub_ticks(1)))
+//  TCL_GetVar("SubticksEntryX")
+ // disp("h.sub_ticks(1) =")
+ // disp(h.sub_ticks(1));
+
+  TCL_SetVar("SubticksEntryY",string(h.sub_ticks(2)))
+
+  select h.view
+   case "2d" 
+    drawlater();
+    h.view='3d'
+    TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3)))
+    h.view='2d'
+    drawnow();
+   case "3d"
+     TCL_SetVar("SubticksEntryZ",string(h.sub_ticks(3)))
+   end
+
+  TCL_SetVar("XautoticksToggle",h.auto_ticks(1))
+  TCL_SetVar("YautoticksToggle",h.auto_ticks(2))
+  TCL_SetVar("ZautoticksToggle",h.auto_ticks(3))
+
+  //ticks value: X axis
+  ticks = h.x_ticks;
+  sizeticks = size(ticks.locations,1);
+  TCL_SetVar("nbticks_x",string(sizeticks));
+  for i=1:sizeticks
+    val= "LOCATIONS_X("+string(i)+")";
+      TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+//      disp("i vaut:");
+//      disp(i);
+    val= "LABELS_X("+string(i)+")";
+      TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+  end
+
+  //ticks value: Y axis
+  ticks = h.y_ticks;
+  sizeticks = size(ticks.locations,1);
+  TCL_SetVar("nbticks_y",string(sizeticks));
+  for i=1:sizeticks
+    val= "LOCATIONS_Y("+string(i)+")";
+      TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+     val= "LABELS_Y("+string(i)+")";
+      TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+  end
+
+ //ticks value: Z axis
+  ticks = h.z_ticks;
+  sizeticks = size(ticks.locations,1);
+  TCL_SetVar("nbticks_z",string(sizeticks));
+  for i=1:sizeticks
+    val= "LOCATIONS_Z("+string(i)+")";
+      TCL_EvalStr('set '+val+" "+string(ticks.locations(i)));
+    val= "LABELS_Z("+string(i)+")";
+      TCL_EvalStr('set '+val+" {"+ticks.labels(i)+"}");
+  end
+
+endfunction
+
+
+
+function DestroyGlobals()
+global ged_current_figure
+
+if find(ged_current_figure==winsid()) then
+  xset('window',ged_current_figure)
+end 
+
+// ged is closed
+TCL_UnsetVar("sciGedIsAlive");
+
+clearglobal ged_current_figure
+clear ged_current_figure
+
+// disp("PASSE PAR DestroyGlobals Scilab");
+endfunction
+
+
+function ged_delete_entity()
+  [btn,xc,yc]=xclick()
+   [xc,yc]=xchange(xc,yc,'f2i')
+  h=ged_getobject([xc,yc])
+  if h<>[] then delete(h),end
+endfunction
+
+function ged_move_entity()
+  [btn,xc,yc]=xclick()
+  pos=[xc,yc]
+  [xc,yc]=xchange(xc,yc,'f2i')
+  [r,ax]=ged_getobject([xc,yc])
+  cur_ax=gca(),sca(ax)
+  [xc,yc]=xchange(xc,yc,'i2f');pos=[xc,yc]
+  if r==[] return,end
+  f=gcf();pix=f.pixmap;f.pixmap='on'
+  rep(3)=-1
+  select r.type
+  case 'Rectangle' then
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data(1:2)= r.data(1:2)+(rep(1:2)-pos)
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+  case 'Segs' then //Segment
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data=r.data+ones(2,1)*(rep(1:2)-pos)
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+  case 'Polyline' then //Polyline
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data(:,1:2)=r.data(:,1:2)+ones(r.data(:,1))*(rep(1:2)-pos)
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+   case 'Arc' then //Circle
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data(1:2)= r.data(1:2)+(rep(1:2)-pos)
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+  case 'Text' then
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data(1:2)= r.data(1:2)+(rep(1:2)-pos)
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+  case 'Label' then
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.position= r.position+(rep(1:2)-pos)
+      r.auto_position = "off"
+      pos=rep(1:2)
+      show_pixmap()
+    end 
+    
+  end
+  sca(cur_ax)
+  f.pixmap=stripblanks(pix)
+endfunction
+
+function ged_copy_entity()
+  [btn,xc,yc]=xclick()
+  [xc,yc]=xchange(xc,yc,'f2i')
+  r=ged_getobject([xc,yc])
+  if r==[] return,end
+  twinkle(r,1);        
+  save(TMPDIR+'/G_Clipboard',r)
+  //make the axes containning the clicked point the current one
+  sca(ged_select_axes(xc,yc))
+endfunction
+
+
+function ged_paste_entity()
+  
+  // check the file
+  [info,err] = fileinfo(TMPDIR + '/G_Clipboard' ) ;
+  
+  if err <> 0 then
+    return ;
+  end
+  
+  // create the saved object
+  load(TMPDIR+'/G_Clipboard') ;
+
+//  a=gca();b=a.data_bounds;
+//  move(r,[-1 1]*a.data_bounds/20)
+endfunction
+
+function axes =  ged_select_axes(x,y)
+// x and y are pixel coord.
+f=gcf()
+nb_axes = size(f.children,'*') // for now Iconsider that children of a figure are of type Axes
+axes_size = f.axes_size // given in pixels
+axes_size = [axes_size axes_size];
+
+for i=1:nb_axes
+  axes = f.children(i);
+  cur_axes_bounds = axes.axes_bounds;
+  rect = cur_axes_bounds.*axes_size; // rectangle in pixels (margins inside)
+  
+  rect(3) = rect(3) + rect(1);
+  rect(4) = rect(4) + rect(2);
+  if (x>rect(1) & x<rect(3) & y>rect(2) & y<rect(4)) then
+     return 
+  end
+end
+axes=[]
+endfunction
diff --git a/scilab/modules/graphics/macros/ged_insert.sci b/scilab/modules/graphics/macros/ged_insert.sci
new file mode 100644 (file)
index 0000000..f8feff2
--- /dev/null
@@ -0,0 +1,229 @@
+function ged_insert(k,win)
+//xset, xget used because ged should handle both old and new style
+  
+  global active men  
+  
+  //check if user changes is mind 
+  active=active+1;men=k
+  if  active>1 then return,end
+  
+  ged_current_figure=xget('window')
+  xset('window',win) 
+  isold=get('figure_style')=='old'
+  if isold then 
+    message('this menu does not apply to old style graphics')
+    xset('window',ged_current_figure)
+    return
+  end
+
+  scf(win);
+  ged_cur_fig_handle=gcf();
+  
+  mess1 = "Press the right mouse button (during a while) to stop the line creation";
+  mess2 = "Press any mouse button to complete the object drawing"
+  entities=['Rectangle','Segment','Polyline','Arrow','Double Arrow', ...
+           'Text','Circle']
+  
+  default_axes = gca(); // get the default axes where we start
+  f=gcf();
+  job='annotation'
+  if job=='annotation' then axes = get_insertion_axes(job,f),end
+
+  [k,xc,yc]=ged_click()
+    
+  pix=f.pixmap; f.pixmap='on'
+  default_axes = gca(); // get the default axes where we start
+  rep(3)=-1
+  select k
+  case -100 then //window has been closed
+     ged_insert_end(),return
+  case 1 then //Single Line
+    axes = get_insertion_axes(job,f,default_axes,xc,yc)
+    [xc,yc] = xchange(xc,yc,'f2i'); // I pass to pixel
+    sca(axes);  // I change axes and therefore change the scale
+    [xc,yc] = xchange(xc,yc,'i2f'); // in the new scale I recompute the corresponding pixel values
+    xpoly([xc;xc],[yc;yc])
+    show_pixmap()
+    r=gce();r.foreground=-1;
+    r.clip_state='off';
+    xinfo(mess2)
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data=[xc,yc;rep(1),rep(2)]
+      show_pixmap()
+      xinfo(mess2)
+    end 
+  case 2 then //Polyline (stroken line)
+    axes = get_insertion_axes(job,f,default_axes,xc,yc)
+    [xc,yc] = xchange(xc,yc,'f2i');
+    sca(axes);
+    [xc,yc] = xchange(xc,yc,'i2f');
+    xpoly([xc;xc],[yc;yc])
+    show_pixmap()
+    r=gce();r.foreground=-1;
+    r.data(:,3)=0.;
+    r.clip_state='off';
+    xinfo(mess1)
+    while %t
+      rep(3)=-1;
+      while rep(3)==-1 do
+       rep=xgetmouse(0)
+       r.data($,:)= [rep(1),rep(2),0]
+       show_pixmap()
+       xinfo(mess1)
+      end 
+      if or(rep(3)==[2 5 -100]) then break,end
+      r.data=[r.data;r.data($,:)]
+    end
+  case 3 // Arrow (single arrow)
+    axes = get_insertion_axes(job,f,default_axes,xc,yc)
+    [xc,yc] = xchange(xc,yc,'f2i');
+    sca(axes);
+    [xc,yc] = xchange(xc,yc,'i2f');
+    xpoly([xc;xc],[yc;yc])
+    show_pixmap()
+    r=gce();r.foreground=-1;
+    r.data(:,3)=0.;
+    r.polyline_style = 4;
+    r.arrow_size_factor=10; // change the factor to have a nice arrow
+    r.clip_state='off';
+    xinfo(mess2)
+    yc = [];
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data($,:)= [rep(1),rep(2),0]
+      show_pixmap()
+      xinfo(mess2)
+    end 
+//   case 4 // Double Arrow
+//      axes = get_insertion_axes(job,f,default_axes,xc,yc)
+//     [xc,yc] = xchange(xc,yc,'f2i');
+//     sca(axes);
+//     [xc,yc] = xchange(xc,yc,'i2f');
+//     xpoly([xc;xc],[yc;yc])
+//     r1=gce();r.foreground=-1;
+//     r1.data(:,3)=0.;
+//     r1.polyline_style = 4;
+//     r1.arrow_size_factor=5; // change the factor to have a nice arrow
+//     r1.clip_state='off';
+//     
+//     // second polyline (for the seconf arrow from end to origin)
+//     xpoly([xc;xc],[yc;yc])
+//     //xpoly([r.data(2,1);r.data(1,1)],[r.data(2,2);r.data(1,2)])
+//     r2=gce();r.foreground=-1;
+//     r2.data(:,3)=0.;
+//     r2.polyline_style = 4;
+//     r2.arrow_size_factor=5; // change the factor to have a nice arrow
+//     r2.clip_state='off';
+//     
+//     xinfo(mess2)
+//     show_pixmap()
+//     while rep(3)==-1 do
+//       rep=xgetmouse(0,[%t %t])
+//       drawlater();
+//       r1.data($,:)= [rep(1),rep(2),0]
+//       r2.data(1,:)= [rep(1),rep(2),0]
+//       drawnow();
+//       show_pixmap()
+//       xinfo(mess2)
+//     end 
+  
+  case 4 then //Text
+    // open a dialog to enter the text
+    text = x_dialog("Enter the new text here.","") ;
+    if ( text <> [] & text <> "" ) then
+      // do nothing if cancel button has been pressed or no text entered
+      // get the position of the text
+      xstring( xc, yc, text ) ;
+    end
+      show_pixmap() ;
+  case 5 then //Rectangle
+    axes = get_insertion_axes(job,f,default_axes,xc,yc)
+    [xc,yc] = xchange(xc,yc,'f2i');
+    sca(axes);
+    [xc,yc] = xchange(xc,yc,'i2f'); 
+    xrect(xc,yc,0,0)
+    show_pixmap()
+    r=gce();r.foreground=-1;
+    r.clip_state='off';
+    xinfo(mess2)
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data=[mini(xc,rep(1)),maxi(yc,rep(2)),abs(xc-rep(1)),abs(yc-rep(2))]
+      show_pixmap()
+      xinfo(mess2)
+    end    
+  case 6 then //Circle
+     axes = get_insertion_axes(job,f,default_axes,xc,yc)
+    [xc,yc] = xchange(xc,yc,'f2i');
+    sca(axes);
+    [xc,yc] = xchange(xc,yc,'i2f');
+    xarc(xc,yc,0,0,0,64*360)
+    show_pixmap()
+    r=gce();r.foreground=-1;
+    r.clip_state='off';
+    xinfo(mess2)
+    while rep(3)==-1 do
+      rep=xgetmouse(0,[%t %t])
+      r.data=[mini(xc,rep(1)),maxi(yc,rep(2)),abs(xc-rep(1)),abs(yc-rep(2)),0,64*360]
+      show_pixmap()
+      xinfo(mess2)
+    end 
+  end
+  ged_insert_end()
+endfunction
+
+
+
+function axes = get_insertion_axes(job,f,default_axes,xc,yc)
+  if job=='annotation' then //special axes used
+    axes=f.children(1)
+    if axes.user_data=="annotation" then return,end
+    //  create a new specialized axes at left bottom of the window
+    //it shoud be better if the annotation axes be directly attached to
+    //the figure (to be done)
+    axes=newaxes();
+    axes.user_data="annotation"
+    axes.axes_bounds=[0,1,0.15,0.15];
+    axes.margins=[0 0 0 0];
+    axes.axes_visible = ["off","off","off"]
+    axes.background=f.background;
+  else //get the axes containing the point xc,yc
+    //the point  xc,yc is given in user coordinate relative to the 
+    //default_axes axes entity.
+    nb_axes = size(f.children,'*') 
+    // for now I consider that all children of a figure are of type Axes
+    axes_size = f.axes_size // given in pixels
+    axes_size = [axes_size axes_size];
+    [x,y]=xchange(xc,yc,'f2i')
+    found=%f
+    for i=1:nb_axes
+      axes = f.children(i);
+      cur_axes_bounds = axes.axes_bounds;
+      rect = cur_axes_bounds.*axes_size; // rectangle in pixels (margins inside)
+      rect(3) = rect(3) + rect(1);
+      rect(4) = rect(4) + rect(2);
+      if (x>rect(1) & x<rect(3) & y>rect(2) & y<rect(4)) then  found=%t,break,end
+    end
+    if ~found then axes=[],end
+  end
+endfunction
+
+function  ged_insert_end()
+  if or(win==winsid()) then //  the window still exists
+    sca(default_axes); // resume the default axes
+    f=gcf()
+    f.pixmap=stripblanks(pix)
+    clearglobal active men  
+  end
+  if win<>ged_current_figure then xset('window',ged_current_figure),end
+
+endfunction
+function [men,xc,yc]=ged_click()
+  global  men
+  [btn,xc,yc]=xclick()
+  if btn==-100 then men=-100,end
+  for k=1:3,end
+  job=men
+endfunction
diff --git a/scilab/modules/graphics/macros/genfac3d.sci b/scilab/modules/graphics/macros/genfac3d.sci
new file mode 100644 (file)
index 0000000..935c53e
--- /dev/null
@@ -0,0 +1,60 @@
+function [xx,yy,zz]=genfac3d(x,y,zmat,mask)
+       
+       // genfac - transforms  standard 3d data to four sides facets representation
+       //%Syntax
+       // [xx,yy,zz]=genfac3d(x,y,zmat,mask)
+       //%Parameters
+       // zmat      : matrix , zmat(i,j)= F(x(j),y(i))
+       // x        : x axis coordinates vector
+       // y        : y axis coordinates vector
+       // mask     : boolean optional matrix with same size as zmat used to select 
+       //            entries of zmat to be represented by facets
+       // xx,yy,zz :4xn  matrices. xx(:,i),yy(:,i),zz(:,i) are respectively the 
+       //           x-axis,y-axis and z-axis coordinates of the ith facet
+       //%Examples
+       //  genfac3d() 
+       //!
+       // Copyright INRIA
+       
+       [lhs,rhs]=argn(0)
+       
+       if rhs <= 0 then   // demo
+               
+               title_demo = [
+                       '';
+                       'Demo of genfac3d()';
+                       '========================================';
+                       ''];
+               
+               s_mat=[
+                       't=(0:10)''*%pi/5;';
+                       'zmat=sin(t)*cos(t'');';
+                       '[xx,yy,zz]=genfac3d(t,t,zmat,zmat>=0);';
+                       'plot3d(xx,yy,zz)'];
+               
+               write(%io(2),title_demo);
+               write(%io(2),s_mat);
+               write(%io(2),' ');
+               execstr(s_mat);
+               return
+       end
+
+[nr,nc]=size(zmat)
+indy=(ones(1,nc-1).*.[0;1;1;0]+(1:nc-1).*.[1;1;1;1]).*.ones(1,nr-1);
+indx=ones(1,nc-1).*.(ones(1,nr-1).*.[0;0;1;1]+(1:nr-1).*.[1;1;1;1]);
+[nrl,nrc]=size(indx)
+indx=matrix(indx,nrl*nrc,1);
+indy=matrix(indy,nrl*nrc,1);
+indz=indx+(nr)*(indy-1*ones(indy));
+[nrl,nrc]=size(indx);
+xx=matrix(x(indx),4,nrl*nrc/4);
+yy=matrix(y(indy),4,nrl*nrc/4);
+zz=matrix(zmat(indz),4,nrl*nrc/4);
+if rhs==4 then 
+  zl=matrix(mask(indz),4,nrl*nrc/4);
+  [xin,yin]=find(zl);
+  zz=zz(:,yin);
+  xx=xx(:,yin);
+  yy=yy(:,yin);
+end
+endfunction
diff --git a/scilab/modules/graphics/macros/getColorIndex.sci b/scilab/modules/graphics/macros/getColorIndex.sci
new file mode 100644 (file)
index 0000000..2eb44f6
--- /dev/null
@@ -0,0 +1,68 @@
+//
+//Author : F.Leray
+//Copyright INRIA
+//
+
+function opt1 = getColorIndex(ColorString)
+
+str = convstr(ColorString);
+// 1) COLORS
+
+//Colors
+Table      = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' ..
+       'k' 'white'     'none' 'auto' 'flat' 'interp']
+//ColorVal = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' ..
+//      'black' 'white' 'none' 'auto' 'flat' 'interp']
+//                                      |       |
+//                                  only used with 'surf' command
+
+//color management
+//difficulty here since we have to allow every kind of writings:
+//i.e:
+//magenta can be set by: 'm' 'ma' 'mag' 'mage' 'magen' 'magent' or at least 'magenta'
+//
+
+opt1=-1;
+str  = convstr(PropertyValue);
+
+k=find(part(Table,1:length(str))==str);
+
+c1 = part(str,1); // We get the first character
+
+if (k == [] | (size(k,'*') > 1 & c1 <> 'b'))
+  warning("Error in Color property : bad argument specified");
+  return;
+end
+
+if c1=='b' // special case here : we have to distinguish between black and blue colors
+  c2 = part(str,2);
+  if (c2 == 'l')
+    c3 = part(str,3);
+    if (c3 == 'a')
+      k=7; // k is set to black color
+    else  
+      k=3; // k is set to blue color
+    end
+  else
+    k=3; // k is set to blue color
+  end
+end
+
+opt = Table(k);
+for i=1:length(str)
+  if part(opt,i) <> part(str,i)
+    break;
+  end
+end
+
+opt1 = k;
+
+str = part(str,i:length(str));
+
+if (size(opt1,'*') > 1)  // unreachable case normally
+  warning("Error in Property specification : too much properties specified")
+  return;
+end
+
+
+endfunction
diff --git a/scilab/modules/graphics/macros/getLineSpec.sci b/scilab/modules/graphics/macros/getLineSpec.sci
new file mode 100644 (file)
index 0000000..c62f8d8
--- /dev/null
@@ -0,0 +1,126 @@
+//
+//Author : F.Leray
+//Copyright INRIA
+//
+
+function [Color,Line,LineStyle,Marker,MarkerStyle,MarkerSize,fail]=getLineSpec(str,current_figure,cur_draw_mode) 
+
+LineStyle=1;
+Color=[];
+MarkerStyle=[];
+MarkerSize=1;
+LineStyle=1;
+fail=0;
+
+//conversion to lower format
+str = convstr(str);
+
+// 1) LINE STYLE
+// Line type modifiers
+
+if strindex(str,'--')
+  str=strsubst(str,'--','');
+  LineStyle=2;
+  Line = %T;
+elseif strindex(str,'-.')
+  str=strsubst(str,'-.','');
+  LineStyle=4;
+  Line = %T;
+elseif strindex(str,':')
+  str=strsubst(str,':','');
+  LineStyle=5;
+  Line = %T;
+elseif strindex(str,'-')
+  str=strsubst(str,'-','');
+  LineStyle=1;
+  Line = %T;
+end
+
+//
+
+//disp("str vaut:::::::: 1/2")
+//disp(str)
+
+// 2) COLORS + MARKS STYLE
+
+opt1=[];
+
+//Marks
+Table = [ '+' 'o' '*' '.' 'x' 'square' 'diamond' '^' 'v' '>' '<' 'pentagram'];
+MarksStyleVal=[1 9 10 0 2 11 5 6 7 12 13 14];
+//MarksSizeVal =[4 3 7  1 3  3 4 3 3  3  3  3];
+//MarksSizeVal =[6 6 6  6 6  6 6 6 6  6  6  6]; // size is given in points now (25.02.05)
+
+//Colors
+Table= [Table 'red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' 'k' 'white']
+ColorVal   = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' 'black' 'white']
+
+//color management
+//difficulty here since we have to allow every kind of writings:
+//i.e:
+//magenta can be set by: 'm' 'ma' 'mag' 'mage' 'magen' 'magent' or at least 'magenta'
+//
+
+
+str = str+'@';
+
+while length(str) > 1
+  c1 = part(str,1); // We get the first character
+  k=find(part(Table,1)==c1);
+
+  if (k == [] | (size(k,'*') > 1 & c1 <> 'b'))
+    warning("Error in LineSpec property : bad argument specified");
+    ResetFigureDDM(current_figure, cur_draw_mode);
+    return;
+  end
+
+  if c1=='b' // special case here : we have to distinguish between black and blue colors
+    c2 = part(str,2);
+    if (c2 == 'l')
+      c3 = part(str,3);
+      if (c3 == 'a')
+       k=19; // k is set to black color
+      else  
+       k=15; // k is set to blue color
+      end
+    else
+      k=15; // k is set to blue color
+    end
+  end
+
+  opt = Table(k);
+  for i=1:length(str)
+    if part(opt,i) <> part(str,i)
+      break;
+    end
+  end
+
+  opt1 = [opt1 k];
+  
+  str = part(str,i:length(str));
+
+end
+
+
+// LineSpec is parsed now
+//Marker = %F;
+//Line   = %T;
+
+for i=1:size(opt1,'*')
+
+  if (opt1(i) <= 12)
+    Marker = %T;
+    MarkerStyle = MarksStyleVal(opt1(i));
+    MarkerSize  = 6; 
+//MarkerSize  = MarksSizeVal (opt1(i));
+//    disp("MarkerSize =");
+//    disp(MarkerSize);
+  else
+    Color = color(ColorVal(opt1(i)-12));
+  end
+
+end
+
+
+endfunction
+// end of getLineSpec
\ No newline at end of file
diff --git a/scilab/modules/graphics/macros/getPlotPropertyName.sci b/scilab/modules/graphics/macros/getPlotPropertyName.sci
new file mode 100644 (file)
index 0000000..a661d4f
--- /dev/null
@@ -0,0 +1,64 @@
+//
+//Author : F.Leray
+//Copyright INRIA
+//
+
+function [PName] = getPlotPropertyName(PropertyName,current_figure,cur_draw_mode)
+
+//conversion to lower format
+err = execstr('str = convstr(PropertyName);','m');
+
+if err <> 0
+  mprintf("plot syntax error (help plot for info)\n");
+  warning("Error %d : in getPlotPropertyName called by plot\n");
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+end
+
+Table    = ['clipping' 'color'      'foreground' 'linestyle' 'linewidth' 'thickness' 'marker' ..
+       'markstyle' 'markeredgecolor' 'markforeground' 'markerfacecolor'  'markbackground' ..
+       'markersize' 'marksize' 'visible' 'xdata' 'ydata' 'zdata'];
+TableEQ =  ['clipping' 'foreground' 'foreground' 'linestyle' 'thickness' 'thickness' 'markstyle'..
+       'markstyle'  'markforeground' 'markforeground' 'markbackground' 'markbackground' .. 
+       'marksize'   'marksize' 'visible' 'xdata' 'ydata' 'zdata']; // equivalent Table
+
+opt1=[];
+
+k=find(part(Table,1:length(str))==str);
+
+if (k == [])
+  warning("Error in Property specification : bad argument specified");
+  PName=[];
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+elseif ( size(k,'*') > 1)
+  if or(find(k==7)) // case PropertyName == 'marker'
+    k=7; // set to PropertyName == 'marker' only
+  else
+    warning("Ambiguous line property");
+    PName=[];
+    ResetFigureDDM(current_figure, cur_draw_mode);
+    return;
+  end
+end
+
+opt = Table(k);
+for i=1:length(str)
+  if part(opt,i) <> part(str,i)
+    break;
+  end
+end
+
+opt1 = [opt1 k];
+
+str = part(str,i:length(str));
+
+if (size(opt1,'*') > 1)
+  warning("Error in Property specification : too much properties specified");
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+end
+
+PName = TableEQ(opt1);
+
+endfunction
diff --git a/scilab/modules/graphics/macros/getSurfPropertyName.sci b/scilab/modules/graphics/macros/getSurfPropertyName.sci
new file mode 100644 (file)
index 0000000..563dbb6
--- /dev/null
@@ -0,0 +1,65 @@
+//
+//Author : F.Leray
+//Copyright INRIA
+//
+
+function [PName] = getSurfPropertyName(PropertyName,current_figure,cur_draw_mode)
+
+//conversion to lower format
+str = convstr(PropertyName);
+
+
+Table    = ['cdata' 'colordata' 'cdata_mapping' 'cdatamapping' 'colordatamapping' ..
+    'cdatamode'     'colordatamode' 'clipping' 'edgecolor'   'foreground' 'facecolor' ..
+    'linestyle' 'linewidth' 'thickness' 'marker' .. 
+    'markstyle' 'markeredgecolor' 'markforeground' 'markerfacecolor'  'markbackground' ..
+    'markersize' 'marksize' 'visible' 'xdata' 'ydata' 'zdata'];
+
+TableEQ =  ['colordata' 'colordata' 'colordatamapping' 'colordatamapping' 'colordatamapping' ..
+    'colordatamode' 'colordatamode' 'clipping' 'foreground'  'foreground' 'facecolor' ..
+    'linestyle' 'thickness' 'thickness' 'markstyle' ..
+    'markstyle'  'markforeground' 'markforeground' 'markbackground' 'markbackground' .. 
+    'marksize'   'marksize' 'visible' 'xdata' 'ydata' 'zdata']; // equivalent Table
+
+opt1=[];
+
+k=find(part(Table,1:length(str))==str);
+
+if (k == [])
+  warning("Error in Property specification : bad argument specified");
+  PName=[];
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+elseif ( size(k,'*') > 1)
+  if or(find(k==14)) // case PropertyName == 'marker'
+    k=14; // set to PropertyName == 'marker' only
+  elseif or(find(k==2)) // case PropertyName == 'colordata'
+    k=2;
+  else
+    warning("Ambiguous surface property");
+    PName=[];
+    ResetFigureDDM(current_figure, cur_draw_mode);
+    return;
+  end
+end
+
+opt = Table(k);
+for i=1:length(str)
+  if part(opt,i) <> part(str,i)
+    break;
+  end
+end
+
+opt1 = [opt1 k];
+
+str = part(str,i:length(str));
+
+if (size(opt1,'*') > 1)
+  warning("Error in Property specification : too much properties specified");
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+end
+
+PName = TableEQ(opt1);
+
+endfunction
diff --git a/scilab/modules/graphics/macros/getTitleLabelPropertyNam.sci b/scilab/modules/graphics/macros/getTitleLabelPropertyNam.sci
new file mode 100644 (file)
index 0000000..375d30e
--- /dev/null
@@ -0,0 +1,56 @@
+function [PName] = getTitleLabelPropertyNam(PropertyName,current_figure,cur_draw_mode)
+// Copyright INRIA
+// GETTITLELABELPROPERTYNAME function
+// is used by the functions title, xlabel, ylabel, zlabel
+// this function gets the matlab properties names and repalce them by the equivalent scilab properties names, using Table and TableEQ  
+// F.Belahcene
+
+//conversion to lower format
+str = convstr(PropertyName);
+
+
+Table    = [ 'visible' 'fontname' 'fontangle' 'fontsize' 'rotation' ..
+             'position' 'color' 'edgecolor' 'backgroundcolor' ];
+
+TableEQ =  [ 'visible' 'font_style' 'font_style' 'font_size' 'font_angle' ..
+             'position' 'font_foreground' 'foreground' 'background'] 
+
+//TableEQ =  [ 'visible' 'font_style' 'font_style' 'font_size' 'font_angle' ..
+  //           'position' 'foreground' 'background' .. 
+    //         'visible' 'fill_mode' 'auto_position' 'auto_rotation']; // equivalent Table
+
+opt1=[];
+
+k=find(part(Table,1:length(str))==str);
+
+if (k == [])
+  warning("Error in Property specification : bad argument specified");
+  PName=[];
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+elseif ( size(k,'*') > 1)
+    warning("Ambiguous text property");
+    PName=[];
+    ResetFigureDDM(current_figure, cur_draw_mode);
+    return;
+end
+
+opt = Table(k);
+for i=1:length(str)
+  if part(opt,i) <> part(str,i)
+    break;
+  end
+end
+
+opt1 = [opt1 k];
+
+str = part(str,i:length(str));
+
+if (size(opt1,'*') > 1)
+  warning("Error in Property specification : too much properties specified");
+  ResetFigureDDM(current_figure, cur_draw_mode);
+  return;
+end
+
+PName = TableEQ(opt1);
+endfunction
diff --git a/scilab/modules/graphics/macros/getcolor.sci b/scilab/modules/graphics/macros/getcolor.sci
new file mode 100644 (file)
index 0000000..50e6a16
--- /dev/null
@@ -0,0 +1,162 @@
+function [c] = getcolor(Title,cini)
+// Copyright INRIA
+[lhs,rhs] = argn(0)
+if rhs==0 then
+  Title = "";
+  cini = 1;
+elseif rhs==1 then
+  if type(Title)~=10 then
+    error("getcolor: argument must be a string")
+  end;
+  cini = 1;
+elseif rhs==2 then
+  if type(Title)~=10|type(cini)~=1|size(cini,"*")~=1 then
+    error("getcolor: arguments must be a string and an integer")
+  end;
+else
+  error("function ""color"" must have 1 or 3 arguments")
+end;
+
+if winsid()~=[] then
+  if get("figure_style")=="old" then
+    cmap = xget("colormap");
+  else
+    cmap = get(gcf(),"color_map");
+  end;
+  curwin = xget("window");
+else
+  cmap = []
+  curwin = []
+end;
+win = max(winsid()+1);
+xset("window",win);
+
+if get("figure_style")=="old" then
+  set("figure_style","new");
+end;
+sdf;
+sda;
+f = gcf();
+if cmap~=[] then
+  f.color_map = cmap;
+else
+  cmap = f.color_map;
+end;
+
+N = size(cmap,1);
+wdim = [1,1];
+r = wdim(1)/wdim(2);
+n = round(sqrt(N/r));
+m = int(n*r);
+H = m*30;
+W = n*30;
+f.figure_size = [H,W];
+
+if ~MSDOS then
+  delmenu(win,"3D Rot.")
+  delmenu(win,"UnZoom")
+  delmenu(win,"Zoom")
+  delmenu(win,"Edit")
+  delmenu(win,"File")
+  delmenu(win,"Insert")
+else
+  hidetoolbar(win)
+  // French
+  delmenu(win,"&Fichier")
+  delmenu(win,"&Editer")
+  delmenu(win,"&Outils")
+  delmenu(win,"&Inserer")
+  // English
+  delmenu(win,"&File")
+  delmenu(win,"&Edit")
+  delmenu(win,"&Tools")
+  delmenu(win,"&Insert")
+end;
+
+dx = wdim(1)/m;
+dy = wdim(2)/n;
+x = -dx;
+y = wdim(2);
+R = [0;0;dx*0.95;dy*0.95];
+rects = [];
+for k = 1:N
+  if modulo(k,n)==1 then
+    x = x+dx;
+    y = wdim(2);
+  end;
+  rects = [rects,R+[x;y;0;0]];
+  y = y-dy;
+end;
+
+if Title~="" then
+  xsetech([-1/8,0,1+1/6,1+1/6-1/8],[0,0,wdim(1),wdim(2)]);
+else
+  xsetech([-1/8,-1/8,1+1/6,1+1/6],[0,0,wdim(1),wdim(2)]);
+end;
+// rectangles with the colors
+xrects(rects,1:N);
+// frame around the colors
+r = m*n-N;
+ddx = 0.05*dx;
+ddy = 0.05*dy;
+if r==0 then
+  xpoly([-ddx,1,1,-ddx],[0,0,1+ddy,1+ddy],"lines",1);
+else
+  xpoly([-ddx,1-1/n,1-1/n,1,1,-ddx],[0,0,r/m,r/m,1+ddy,1+ddy],"lines",1);
+end;
+
+// title
+if Title~="" then
+  xtitle(Title);
+  t = gce();
+  t.font_size = 4;
+  t.font_style = 6;
+end;
+
+k1 = min(max(cini,1),N);
+xrects(rects(eye(),k1),-k1);
+e = gce();
+rector = e.children;
+rector.thickness = 4;
+rector.foreground = color(255*(1-cmap(k1,1)),255*(1-cmap(k1,2)),255*(1-cmap(k1,3)));
+
+//add a menu and its callback
+done = %f;
+addmenu(win,"File",["Ok","Cancel"]);
+execstr("File_"+string(win)+"=[""done=%t;k=k1;"";""done=%t;k=[]""]")
+cmdok = "execstr(File_"+string(win)+"(1))";
+cmdcancel = "execstr(File_"+string(win)+"(2))";
+
+c_i = 0;
+c = cini;
+while %t
+  [c_i,cx,cy,cw,str] = xclick();
+  if c_i==(-2) then
+    if str==cmdok then k = k1; c = k; break;end;
+    if str==cmdcancel then k = []; c = []; break;end;
+  end;
+  if c_i==(-100) then k = []; break;end;
+  mc = int(cx/dx)+1;
+  nc = n-int(cy/dy);
+  k = (mc-1)*n+nc;
+  if or(c_i==[0,3])&k<=N&k>0 then
+    if k1~=0 then
+      move(rector,[rects(1,k)-rects(1,k1),rects(2,k)-rects(2,k1)]);
+      rector.foreground = color(255*(1-cmap(k,1)),255*(1-cmap(k,2)),255*(1-cmap(k,3)));
+    end;
+    k1 = k;
+    name = rgb2name(cmap(k,eye())*255);
+    xinfo("Color number "+string(k)+": R="+string(floor(cmap(k,1)*255))+" G="+string(floor(cmap(k,2)*255))+" B="+string(floor(cmap(k,3)*255))+" Name="""+name(1)+"""");
+  
+