Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file helpers.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133(**************************************************************************)(* *)(* Copyright (C) Johannes Kanig, Stephane Lescuyer *)(* Jean-Christophe Filliatre, Romain Bardou and Francois Bobot *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)(* *)(**************************************************************************)openPathopenBoxopenCommand(* puts labels at given points with given text *)letdotlabels?(pos=`Center)lslp=seq(List.map2(funsp->dotlabel~pos(Picture.texs)p)lslp)letdraw_simple_arrow?color?pen?dashed?style?outd?ind?sepab=Arrow.simple?color?pen?dashed(Box.strip?sep(Arrow.simple_point_point?style?outd?indab))letdraw_label_arrow?color?pen?dashed?style?outd?ind?pos?seplabab=letp=Arrow.simple_point_point?style?outd?ind?sepabinArrow.simple?color?pen?dashedp++label?poslab(Path.point0.5p)letdraw_labelbox_arrow?color?pen?dashed?style?outd?ind?pos?seplabab=draw_label_arrow?color?pen?dashed?style?outd?ind?pos?sep(Picture.make(Box.drawlab))abletsubboxeswithinab=matchwithinwithNone->(a,b)|Somex->(Box.subax,Box.subbx)letbox_arrow?within?color?pen?dashed?style?outd?ind?sepab=leta,b=subboxeswithinabinArrow.simple?color?pen?dashed(Box.cpath?style?outd?ind?sepab)letbox_line?within?color?pen?dashed?style?outd?ind?sepab=leta,b=subboxeswithinabindraw?color?pen?dashed(Box.cpath?style?outd?ind?sepab)letbox_point_line?within?color?pen?dashed?style?outd?ind?sepab=leta=matchwithinwithNone->a|Somex->Box.subaxindraw?color?pen?dashed(Box.cpath_left?style?outd?ind?sepab)letpoint_box_line?within?color?pen?dashed?style?outd?ind?sepab=letb=matchwithinwithNone->b|Somex->Box.subbxindraw?color?pen?dashed(Box.cpath_right?style?outd?ind?sepab)letbox_label_line?within?color?pen?dashed?style?outd?ind?sep?poslabab=leta,b=subboxeswithinabinletp=Box.cpath?style?outd?ind?sepabindraw?color?pen?dashedp++label?poslab(Path.point0.5p)letbox_label_arrow?within?color?pen?dashed?style?outd?ind?sep?poslabab=leta,b=subboxeswithinabinletp=Box.cpath?style?outd?ind?sepabinArrow.simple?color?pen?dashedp++label?poslab(Path.point0.5p)(* TODO unify all these functions *)letbox_labelbox_arrow?within?color?pen?dashed?style?outd?ind?sep?poslabab=box_label_arrow?within?color?pen?dashed?style?outd?ind?sep?pos(Picture.make(Box.drawlab))abletloop_aux?within?(pos=`South)?(dist=2.)b=letb=matchwithinwithNone->b|Somex->Box.subbxinletc=Box.ctrbinletx=Point.segmentdistc(Box.cornerposb)inb,c,xletbox_loop?within?color?pen?dashed?style?outd?ind?sep?pos?dist?(angle=90.)b=letb,c,x=loop_aux?within?pos?distbinletoutd,ind=letrad=atan2(Point.ypartx-.Point.ypartc)(Point.xpartx-.Point.xpartc)inlettheta=180.*.rad/.Compute.piinleta=angle/.2.in(matchoutdwithNone->vec(Point.dir(theta-.a))|Somed->d),(matchindwithNone->vec(Point.dir(theta+.180.+.a))|Somed->d)inletp=Path.pathk?style[knotp~r:outdc;knotpx;knotp~l:indc]inletp=strip?sep(P.cut_after(bpathb)(P.cut_before(bpathb)p))inArrow.simple?color?pen?dashedpletbox_label_loop?within?color?pen?dashed?style?outd?ind?sep?(pos=`South)?dist?anglelabb=letb,_,x=loop_aux?within~pos?distbinbox_loop?within?color?pen?dashed?style?outd?ind?sep~pos?dist?angleb++letpos=matchposwith`Custom_->None|#Command.positionasp->Somepinlabel?poslabxletpointer_start_pen=Pen.scale(Num.bp4.)Pen.circleletbox_pointer_arrow?within?color?pen?dashed?style?outd?indab=leta,b=subboxeswithinabinletr,l=(outd,ind)inletp=Path.pathk?style[Path.knotp?r(ctra);Path.knotp?l(ctrb)]inletp=Path.cut_after(bpathb)pinCommand.draw~pen:pointer_start_pen(pathp[Path.point0.p])++Arrow.simple?color?pen?dashedp(***
let hboxjoin ?color ?pen ?dashed ?dx ?dy ?pos ?spacing pl =
(* align the pictures in pl, put them in boxes and connect these boxes *)
let bl = Box.halign_to_box ?dx ?pos ?spacing pl in
match bl with
| [] -> nop
| hd::tl ->
let cmd,_ =
List.fold_left
(fun (cmd,b1) b2 ->
Box.draw b2 ++ box_arrow ?color ?pen ?dashed b1 b2 ++ cmd,b2 )
(Box.draw hd,hd) tl
in
cmd
***)