RSS

(root)/ocaml-gnuplot/trunk : 51 : gnuplot_common_.ml

« back to all changes in this revision

Viewing changes to gnuplot_common_.ml

Christophe Troestler
2009-03-27 21:12:13
Revision ID: christophe.troestler@umons.ac.be-20090327211213-fm1p5vtwwnkj91bp
Added Wxt interactive interface (and used it in the demos).

Show diffs side-by-side

added added

removed removed

1
 
(* Copyright (C) 2001-2004
 
1
(* Copyright (C) 2001-2009
2
2
 
3
3
     Christophe Troestler
4
4
     email: Christophe.Troestler@umh.ac.be
14
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
15
15
   LICENSE for more details.
16
16
*)
17
 
(*  $Id: gnuplot_common_.ml,v 1.3 2007-11-27 23:07:22 chris_77 Exp $  *)
18
17
 
19
18
 
20
19
(**********************************************************************
406
405
    + (if sp.z2.draw then 32 else 0) + (if sp.z2.draw_top then 64 else 0) in
407
406
  output_string gp ("set border " ^ (string_of_int borders) ^ "\n");
408
407
  let axis xy a a2 =
409
 
    let setxy = "set " ^ xy
410
 
    and unsetxy = "unset" ^ xy in
 
408
    (* let setxy = "set " ^ xy in *)
 
409
    let unsetxy = "unset" ^ xy in
411
410
    fprintf gp "set %srange [%s:%s];"
412
411
      xy (range_of_float a.min) (range_of_float a.max);
413
412
    if a.tics then
504
503
 
505
504
type device =
506
505
  | X
 
506
  | Wxt
507
507
  | PS of string   (* Postscript *)
508
508
  | EPS of string  (* Encapsulated PostScript *)
509
509
  | EPSLaTeX of string (* picture environment including a PS file *)
664
664
        else (y /. aspect, y)
665
665
    | None, None ->
666
666
        let x = match dev with
667
 
          | X | PNG _ | SVG _ -> 550. (* pixels *)
 
667
          | X | Wxt | PNG _ | SVG _ -> 550. (* pixels *)
668
668
          | PS _ | EPS _ | EPSLaTeX _ | MP _ | MF _ | FIG _ ->
669
669
              100. (* milimeters *) in
670
670
        if aspect <= 0. then invalid_arg "Gnuplot.init: aspect <= 0"
692
692
        if not offline then Gnuplot_sys.set_terminal_X gp xsize ysize color;
693
693
        (* no need to set output *)
694
694
        (1., 1., "default")
 
695
    | Wxt ->
 
696
        let pgmname = Filename.basename Sys.argv.(0) in
 
697
        fprintf gp "set term wxt title \"OCaml Gnuplot: %s\" enhanced \
 
698
          %spersist noraise\n" pgmname (if persist then "" else "no");
 
699
        (1., 1., "default")
695
700
    | PS(s) ->
696
701
        if xsize >= ysize then begin
697
702
          fprintf gp "set terminal postscript landscape enhanced %s\n" scolor;
716
721
        (xsize /. 5. *. inches_per_mm, ysize /. 3. *. inches_per_mm,
717
722
         "default")
718
723
    | FIG(s) ->
719
 
        fprintf gp "set terminal fig %s size %.15g %.15g metric dashed textnormal depth 50\n"
 
724
        fprintf gp "set terminal fig %s size %.15g %.15g metric dashed \
 
725
          textnormal depth 50\n"
720
726
          scolor (xsize /. 10.) (ysize /. 10.); (* fig: size in centimeters *)
721
727
        set_output s;
722
728
        (1., 1., "default")
815
821
      to_gplot = gp;
816
822
      gp_extra = extra;
817
823
      closed = false;
818
 
      interactive = (dev = X);
 
824
      interactive = (dev = X || dev = Wxt);
819
825
      max_inline = if offline then max_int else max_inline;
820
826
      buf_inline = Buffer.create (max_inline * 34);
821
827
      newpage = "unset multiplot\n" ^ begin_new_page;
960
966
  if g.closed then failwith "Gnuplot.free";
961
967
  if tag = system_tag then
962
968
    invalid_arg "Gnuplot.free: cannot change the system tag";
963
 
  let sp = g.subpage.(g.sub) in
964
969
  try
965
970
    let q = Tags.find tag g.subpage.(g.sub).tags in
966
971
    empty_plot_queue q

Loggerhead 1.17 is a web-based interface for Bazaar branches