diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/metapost/mptrees/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf | bin | 388957 -> 429600 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex | 246 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/mptrees/mptrees.mp | 198 |
4 files changed, 354 insertions, 92 deletions
diff --git a/Master/texmf-dist/doc/metapost/mptrees/README.md b/Master/texmf-dist/doc/metapost/mptrees/README.md index c038dca046a..ee9e901ceab 100644 --- a/Master/texmf-dist/doc/metapost/mptrees/README.md +++ b/Master/texmf-dist/doc/metapost/mptrees/README.md @@ -1,4 +1,4 @@ -Package mptrees - Version 17.05 - May 10, 2017 +Package mptrees - Version 17.06 - June 1, 2017 This package provides MetaPost tools for drawing simple probability trees. One command and several parameters to control the output are provided. diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf Binary files differindex f86d52150ce..816b302304c 100644 --- a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf +++ b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex index 78fb19f8b14..e1a2387913a 100644 --- a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex +++ b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex @@ -208,9 +208,9 @@ \setcounter{tocdepth}{2} -%\setlength{\columnsep}{25pt} -%\tableofcontents -%\setlength{\columnsep}{10pt} +\setlength{\columnsep}{25pt} +\tableofcontents +\setlength{\columnsep}{10pt} \newcommand{\ijc}{[i][j]} @@ -228,15 +228,15 @@ dirtree:=0; \section{Overview} -This package is intended to simplify the drawing of probability trees with \MP. It provides one command and several parameters to control the output. +This package is intended to simplify the drawing of probability trees with \MP. It provides one main command and several parameters to control the output. It can be used in standalone files with two compilations (\verb|latexmp| package is loaded) but it can also be used with Lua\LaTeX{} and \verb|luamplib| package. \begin{description} -\item[tree\ijc (dim1,dim2,...)(ev1,prob1,ev2,prob2,...)] probability tree located in column \verb|i| and row \verb|j| (see figure below). \verb|dim1|, \verb|dim2|,... can be numerics or pairs and control the dimension of the tree. \verb|ev1|, \verb|prob1|... are strings and will be printed (using \verb|latexmp|) at the end of the edge (the event) and above the edge (the probability). +\item[tree\ijc (dim1,dim2,...)(ev1,prob1,ev2,prob2,...)] probability tree located in column \verb|i| and row \verb|j| (see figure below). \verb|dim1|, \verb|dim2|,... can be numerics or pairs and control the dimension of the tree. \verb|ev1|, \verb|prob1|... can be strings or pictures and will be printed (using \verb|latexmp| if strings) at the end of the edge (the event) and above the edge (the probability). -\item[shiftev, scaleprob, posprob, typeprob, proboffset, dirtree] numerics controlling the scale and position of the probability label, the direction of the tree... +%\item[shiftev, scaleprob, posprob, typeprob, proboffset, dirtree] numerics controlling the scale and position of the probability label, the direction of the tree... \end{description} @@ -266,7 +266,8 @@ endfig; \end{center} -\section{Different kinds of trees} +\section{Trees} +\subsection{Different kinds of trees} \begin{description} \item[tree\ijc (width,vspace)(ev1,prob1,ev2,prob2,...)] regular tree where \verb|width| is the horizontal width of the tree and \verb|vspace| the vertical space between two consecutive nodes. @@ -275,7 +276,7 @@ endfig; string dim[]; dim[4]:="4 cm";dim[3]:="3 cm";dim[2]:="2 cm";dim[1]:="1 cm"; dim[15]:="1.5 cm";dim[25]:="2.5 cm";dim[11]:="-1 cm"; -dim[22]:="-2 cm"; +dim[22]:="-2 cm";dim[7]:="7cm"; \end{codecache} @@ -339,29 +340,118 @@ draw tree[2][1]((3cm,2cm),(4cm,-1cm))("$B$","$q$","$C$","$r$"); \begin{codecache} extra_endfig:=""; \end{codecache} +\end{description} + +\subsection{Start and end labels} +\begin{description} +\item[startlabel(s)] Print \verb|s| (can be a string or a picture) at the origin of the tree. + +\begin{exemple}[0.65] + draw startlabel("$S$"); + draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$"); +\end{exemple} + +\item[endlabel\ijc(s)] Print \verb|s| at the end of a branch. The space between the previous label ans \verb|s| is controlled by the numeric \verb|endlabelspace| which defaults to \verb|1cm|. + +\begin{exemplev}{1} + draw startlabel("$S$"); + draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$"); + draw tree[2][2](2cm,1cm)("$A$","$p$","$B$","$q$"); + draw endlabel[2][1]("$SA$"); + draw endlabel[3][1]("$SBA$"); + draw endlabel[3][2]("$SBB$"); +\end{exemplev} \end{description} -\section{Parameters} +\section{Direction} \begin{description} -\item[shiftev] The origin of each tree is located where the bounding box of the previous event's name ends. Thus subtrees may begin at different places. The numeric \verb|shiftev| indicates the horizontal space between the end of the edges and the beginning of following trees. It should be used inside the first set of parameters of the tree (see example below). +\item[dirtree] All trees are construct horizontally by default. \verb|ditree| indicates the angle in degrees between the horizontal and the main direction of the tree. Default is $0$. + + \begin{exemplev}{1} - draw arbre[1][1](80,120)("$A$","$0.5$","$\overline{A}$","$0.5$"); - draw arbre[2][1](70,40)("Yes","$p$","No","$q$","Maybe","$r$"); - draw arbre[2][2](70,40,"shiftev:=1.5cm")("Yes","$p$","No","$q$","Maybe","$r$"); - draw arbre[3][1](50,20)("$B$","$b$","$C$","$c$"); - draw arbre[3][2](50,20)("$B$","$b$","$C$","$c$"); - draw arbre[3][3](50,20)("$B$","$b$","$C$","$c$"); - draw arbre[3][4](50,20)("$B$","$b$","$C$","$c$"); - draw arbre[3][5](50,20)("$B$","$b$","$C$","$c$"); - draw arbre[3][6](50,20)("$B$","$b$","$C$","$c$"); +dirtree:=135; +draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$"); +draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$"); +draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$"); \end{exemplev} -\item[scaleprob] numeric controlling the scale of the label above the edge (the probability). Default is $0.85$. +\begin{exemplev}{1} +dirtree:=-60; +draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$"); +draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$"); +draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$"); +\end{exemplev} -\item[posprob] numeric controlling the position of the label above the edge. Default is $0.6$. +\begin{codecache} +dirtree:=0;dirlabel:=0; +\end{codecache} + +\item[dirlabel] With dirtree, the whole tree is rotated. With \verb|dirlabel|, only the position of the labels is changed so the given coordinates are the real ones. May be useful for vertical trees. + +\begin{exemplev}{1} +dirlabel:=90; +draw tree[1][1]((-1cm,2cm),(1cm,2cm))("$A$","$p$","$B$","$q$"); +draw tree[2][1]((-0.5cm,2cm),(0.5cm,2cm))("$C$","$c$","$D$","$d$"); +draw tree[2][2]((-0.5cm,2cm),(0.5cm,2cm))("$E$","$e$","$F$","$f$"); +\end{exemplev} + +\begin{codecache} +dirlabel:=0; +\end{codecache} + +\end{description} + +\section{Dealing with alignment} +\begin{description} +\item[shiftev] The origin of each tree is located where the bounding box of the previous event's name ends. Thus subtrees may begin at different places. The numeric \verb|shiftev| indicates the horizontal space between the end of the edges and the beginning of following trees. + +It can be used inside the first set of parameters of the tree (see example below) or as a global variable. + + +\begin{exemplev}{1} + draw tree[1][1](80,120)("$A$","$0.5$","$\overline{A}$","$0.5$"); + draw tree[2][1](70,40)("Yes","$p$","No","$q$","Maybe","$r$"); + draw tree[2][2](70,40,"shiftev:=1.5cm")("Yes","$p$","No","$q$","Maybe","$r$"); + draw tree[3][1](50,20)("$B$","$b$","$C$","$c$"); + draw tree[3][2](50,20)("$B$","$b$","$C$","$c$"); + draw tree[3][3](50,20)("$B$","$b$","$C$","$c$"); + draw tree[3][4](50,20)("$B$","$b$","$C$","$c$"); + draw tree[3][5](50,20)("$B$","$b$","$C$","$c$"); + draw tree[3][6](50,20)("$B$","$b$","$C$","$c$"); +\end{exemplev} + + +\item[abscoord] With the boolean \verb|abscoord| set to \verb|true|, all the coordinates are given from the origin of the \emph{first} tree instead of the origin of the subtree, which make easier the alignment of all the subtrees. +\end{description} + + +\begin{codecache} +extra_endfig:="drawoptions(withcolor red);"; +extra_endfig:=extra_endfig & "drawdblarrow ((0,0)--(7cm,0)) shifted (0,2.25cm);label.top(textext(dim[7]),(3.5cm,2.25cm));"; +extra_endfig:=extra_endfig & "drawdblarrow ((0,0)--(0,2cm)) shifted (-0.5cm,0);label.lft(textext(dim[2]),(-0.5cm,1cm));"; +\end{codecache} + +\begin{exemplev}{1} +abscoord:=true; +draw tree[1][1](3cm,2cm)("$A$","$p$","Blabla","$q$"); +draw tree[2][1]((7cm,2cm),(7cm,0.5cm))("$A$","$p$","$B$","$q$"); +draw tree[2][2]((7cm,-0.5cm),(7cm,-2cm))("$A$","$p$","$B$","$q$"); +\end{exemplev} + +\begin{codecache} +extra_endfig:=""; +abscoord:=false; +\end{codecache} + + +\section{Parameters} +\begin{description} + + +\item[scaleprob] numeric controlling the scale of the label above the edge (the probability). Default is $0.85$. \begin{exemple}[0.65] scaleprob:=1.5; @@ -372,6 +462,22 @@ extra_endfig:=""; scaleprob:=0.85; \end{codecache} + +\item[scaleev] numeric controlling the scale of the label at the end of the edge (the event). Default is $1$. + +\begin{exemple}[0.65] + scaleev:=2; + draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$"); +\end{exemple} + +\begin{codecache} +scaleev:=1; +\end{codecache} + + +\item[posprob] numeric controlling the position of the label above the edge. Default is $0.6$. + + \begin{exemple}[0.65] posprob:=0.8; draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$"); @@ -416,29 +522,40 @@ typeprob:=1; draw tree[1][1](3cm,3cm)("$A$","$p+q+r$","$B$","$s$"); \end{exemple} +\begin{codecache} +proboffset:=3bp; +\end{codecache} +\item[edgearrow] When the boolean \verb|edgearrow| is set to true, edges end with an arrow. Default is \verb|false|. -\item[dirtree] All trees are construct horizontally by default. \verb|ditree| indicates the angle in degrees between the horizontal and the main direction of the tree. Default is $0$. -\end{description} +\begin{exemple}[0.65] + edgearrow:=true; + draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$"); +\end{exemple} \begin{codecache} -proboffset:=3bp; +edgearrow:=false; \end{codecache} -\begin{exemplev}{1} -dirtree:=135; -draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$"); -draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$"); -draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$"); -\end{exemplev} +\item[endedgeshift] vertical space added at the end of the edge. Default is $0$. Useful when various edges end at the same point +\begin{exemple}[0.65] + draw startlabel("$S$"); + draw tree[1][1]((3cm,-1cm))("$A$","$p$"); +\end{exemple} -\begin{exemplev}{1} -dirtree:=-60; -draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$"); -draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$"); -draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$"); -\end{exemplev} + +\begin{exemple}[0.65] + endedgeshift:=10; + draw startlabel("$S$"); + draw tree[1][1]((3cm,-1cm))("$A$","$p$"); +\end{exemple} + +\begin{codecache} +endedgeshift:=0; +\end{codecache} + +\end{description} \section{Embedded code in \LaTeX{} files} @@ -528,9 +645,66 @@ endfig; \end{minipage} \end{center} +\section{Examples} + +\begin{exemplev}[0.9]{1} +u:=0.4cm; +dirlabel:=90; +abscoord:=true; +endlabelspace:=0.5cm; +draw startlabel("S"); +draw tree[1][1]((-5.5u,4u),(5.5u,8u))("NP","","VP",""); +draw tree[2][1]((-8.5u,12u),(-2.5u,8u))("A","","NP",""); +draw tree[2][2]((3.5u,12u),(7.5u,12u))("V","","Adv",""); +draw tree[3][2]((-4.5u,12u),(-0.5u,12u))("A","","N",""); +draw endlabel[3][1]("Colorless"); +draw endlabel[4][1]("green"); +draw endlabel[4][2]("ideas"); +draw endlabel[3][3]("sleep"); +draw endlabel[3][4]("furiously"); +\end{exemplev} +\begin{codecache} +endlabelspace:=1cm; +\end{codecache} +\begin{exemplev}[0.9]{1} +u:=1cm; +dirlabel:=-90; +abscoord:=true; +scaleev:=2; +label.top(textext("\Large Tree diagram of $(2x+1)(x-1)$"),(0,1cm)); +draw startlabel("$\times$"); +draw tree[1][1]((-2u,-1.5u),(2u,-1.5u))("$+$","","$-$",""); +draw tree[2][1]((-3u,-3.5u),(-1u,-3.5u))("$\times$","","$1$",""); +draw tree[2][2]((1u,-3.5u),(3u,-3.5u))("$x$","","$2$",""); +draw tree[3][1]((-4u,-5.5u),(-2u,-5.5u))("$2$","","$x$",""); +\end{exemplev} + +\begin{codecache} +dirlabel:=0; +abscoord:=false; +scaleev:=1; +\end{codecache} +\begin{exemplev}{1} +posprob:=0.5; +typeprob:=3; +shiftev:=1.5cm; +edgearrow:=true; +u:=0.2cm; +vardef paral = ((2,-2)--(6,2)--(0,2)--(-4,-2)--cycle) scaled u enddef; +vardef rhombus = ((3,0)--(0,6)--(-3,0)--(0,-6)--cycle) scaled u enddef; +vardef rectangle = ((3,5)--(-3,5)--(-3,-5)--(3,-5)--cycle) scaled u enddef; +vardef square = ((3,3)--(-3,3)--(-3,-3)--(3,-3)--cycle) scaled u enddef; +draw startlabel(paral); +draw tree[1][1](5cm,4cm)(rhombus,"Diagonals perpendicular",% + rectangle,"Diagonals of equal length"); +endedgeshift:=5; +draw tree[2][1]((5cm,-2cm))("","Diagonals of equal length"); +draw tree[2][2]((5cm,2cm))(square,"Diagonals perpendicular"); +\end{exemplev} + \begin{codecache} end \end{codecache} diff --git a/Master/texmf-dist/metapost/mptrees/mptrees.mp b/Master/texmf-dist/metapost/mptrees/mptrees.mp index 73adff12cf6..d9a5e49833c 100644 --- a/Master/texmf-dist/metapost/mptrees/mptrees.mp +++ b/Master/texmf-dist/metapost/mptrees/mptrees.mp @@ -2,7 +2,7 @@ %% mptrees.mp %% %% Probability trees with MetaPost %% %% o.peault@posteo.net %% -%% Version 17.05 (May 2017) %% +%% Version 17.06 (June 2017) %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % This work may be distributed and/or modified under the conditions of @@ -22,12 +22,19 @@ posprob:=0.6; numeric scaleprob; scaleprob:=0.85; % échelle de l'étiquette sur la branche -numeric dirtree; % direction de l'arbre +numeric scaleev; +scaleev:=1; % échelle de l'évènement + +numeric dirtree,dirlabel; % direction de l'arbre dirtree:=0; +dirlabel:=0; numeric proboffset; % redéfinition temporaire de labeloffset pour affichage probas proboffset:=labeloffset; +numeric endedgeshift; +endedgeshift:=0; + pair Orig_arbre[][]; % sommet de l'arbre i,j Orig_arbre[1][1]:=origin; @@ -37,44 +44,109 @@ numeric countligne[]; % nombre de ligne pour le niveau i numeric typedec; % 0 origine dépend de la taille de l'évènement, 1 taille fixée numeric shiftev; % taille du décalage dans le cas où typedec=1 +shiftev:=0; % dans ce cas, typedec =0 +extra_beginfig:=extra_beginfig & "shiftev:=0;"; % remise à zéro en début de figure numeric typeprob; % affichage de la proba sur la branche typeprob:=1; +boolean abscoord; % Coordonnée absolues +abscoord=false; + +string branchtype,endlabeltype; +branchtype="segment"; +endlabeltype="none"; + +boolean edgearrow; +edgearrow:=false; + +numeric endlabelspace; +endlabelspace:=1cm; + + +% Étiquette au début de l'arbre +vardef startlabel(expr s)= + if dirtree<>0: dirlabel:=dirtree fi; + if dirlabel>0: + theevlabel(labelarbres(s) scaled scaleev,origin,-180+dirlabel) + else: + theevlabel(labelarbres(s) scaled scaleev,origin,180+dirlabel) + fi +enddef; + + +% Étiquettes de fin d'arbre +vardef colonne.endlabel[]= + @ +enddef; + +vardef endlabel[][](expr s)= + save i,j,tmpbranchtype,tmpabscoord,tmps; + numeric i,j; + string tmpbranchtype,tmps; + boolean tmpabscoord; + i:=colonne.#@; + j:=@; + if string s: tmps:= "\strut " & s else: tmps:=s fi; + tmpbranchtype:=branchtype; + branchtype:=endlabeltype; + tmpabscoord:=abscoord; + abscoord:=false; + tree[i][j]((endlabelspace,0) rotated (dirlabel-dirtree))(tmps,"") + hide(branchtype:=tmpbranchtype;abscoord:=tmpabscoord;) +enddef; + vardef labelarbres(expr s)= save p; picture p; if picture s: p=s + elseif path s: p=image(draw s) else: p=textext(s) fi; p enddef; + +% longueur du segment qui traverse la figure p selon l'angle inc +vardef longdir(expr p,inc)= + if urcorner p = llcorner p: + 0 + elseif (abs inc <= abs angle (urcorner p -llcorner p)) or (abs inc > 180 - abs angle (urcorner p -llcorner p)): + abs((lrcorner p - llcorner p)/cosd(inc)) + else: + abs((ulcorner p - llcorner p)/sind(inc)) + fi +enddef; + vardef theevlabel(expr s,z,inc)= save p; picture p; save d; numeric d; if picture s: p=s - else: p = textext(s) scaled defaultscale + else: p = textext(s) fi; - if abs inc < abs angle (urcorner p -llcorner p): - d=abs(0.5(lrcorner p - llcorner p)/cosd(inc)) - else: - d=abs(0.5(ulcorner p - llcorner p)/sind(inc)) - fi; - p shifted (z - 0.5(lrcorner p - llcorner p) - 0.5(ulcorner p - llcorner p) + (d+labeloffset)*dir(inc)) + d=0.5*longdir(p,inc); +% p shifted (z - 0.5(lrcorner p - llcorner p) - 0.5(ulcorner p - llcorner p) + (d+labeloffset)*dir(inc)) + p shifted (z - center p + (d+labeloffset)*dir(inc)) enddef; def evlabel = draw theevlabel enddef; + vardef thelabelbranchehaut(expr Ori,Fin,Fig)= interim labeloffset:=proboffset; + save M,pp; + pair M; path pp; + pp=dessinbranche(Ori,Fin); + M= point (arctime posprob*(arclength pp) of pp) of pp; + M:=M + 0.5(llcorner Fig - lrcorner Fig); if xpart Ori <= xpart Fin: - thelabel.rt(Fig rotated -(dirtree+90),origin) rotated (dirtree+90) shifted posprob[Ori,Fin] + M:=M+proboffset*unitvector(dir (dirlabel+90)) else: - thelabel.rt(Fig rotated -(dirtree-90),origin) rotated (dirtree-90) shifted posprob[Ori,Fin] - fi + M:=M-proboffset*unitvector(dir (dirlabel+90)) + fi; + Fig shifted M enddef; @@ -89,8 +161,6 @@ enddef; - - vardef thelabelbranchesuper(expr Ori,Fin,Fig)= save figtmp; picture figtmp; @@ -122,19 +192,40 @@ vardef thelabelbranche(expr Ori,Fin,Fig)= fi enddef; +%%%%%%%% Dessin de la branche +vardef dessinbranche(expr Ori,Fin)= + if branchtype="segment": + Ori--Fin + else: + Ori--Fin + fi +enddef; -%%%%%%%% Dessin complet de la branche +%%%%%%%% Dessin complet de la branche (avec proba, évènement vardef branche_abs(expr Ori,Fin,Eve,Pro)= - save figtmp,thelab,figlab; + save figtmp,thelab,figlab,tmpshft; picture figtmp,thelab,figlab; + numeric tmpshft; thelab:=labelarbres(Pro) scaled scaleprob; - figlab:=thelabelbranche(Ori,Fin rotatedaround(Ori,dirtree),thelab); + if ypart Ori > ypart Fin: %le décalage se fait en fonction de la direction de la branche + tmpshft:=endedgeshift + else: + tmpshft:=-endedgeshift + fi; + figlab:=thelabelbranche(Ori,(Fin+ (0,tmpshft)) rotatedaround(Ori,dirtree),thelab); figtmp=image(% - draw Ori--Fin rotatedaround(Ori,dirtree); + if branchtype<>"none": + if edgearrow: + drawarrow + else: + draw + fi + dessinbranche(Ori,Fin + (0,tmpshft)) rotatedaround(Ori,dirtree) + fi; draw figlab; - evlabel(Eve,Fin rotatedaround(Ori,dirtree),dirtree) + evlabel(Eve,Fin rotatedaround(Ori,dirtree),dirlabel) ); figtmp enddef; @@ -150,6 +241,7 @@ vardef _arbre_(expr Ori)(text t)(text r)= % (pt)(pt1,pt2...)(ev,proba,ev,proba.. picture figtmp,labeltmp[]; numeric counttmp,countlab; pair Fintmp[]; + if dirtree<>0: dirlabel:=dirtree fi; if colonne_cour=1: for i=1 upto 6: countligne[i]:=0; endfor fi figtmp=image(% counttmp:=0; @@ -163,11 +255,12 @@ vardef _arbre_(expr Ori)(text t)(text r)= % (pt)(pt1,pt2...)(ev,proba,ev,proba.. labeltmp[countlab]:=labelarbres(i); if countlab=2: counttmp:=counttmp+1;countligne[colonne_cour+1]:=countligne[colonne_cour+1]+1; - draw branche_abs(Ori,Fintmp[counttmp],labeltmp[1],labeltmp[2]); + draw branche_abs(Ori,Fintmp[counttmp],labeltmp[1] scaled scaleev,labeltmp[2]); Orig_arbre[colonne_cour+1][countligne[colonne_cour+1]]:=Fintmp[counttmp] shifted - if typedec=0: (lrcorner labeltmp[1]-llcorner labeltmp[1]+2labeloffset*(1,0)) + if typedec=0: ((longdir(labeltmp[1] scaled scaleev,dirlabel)+2labeloffset)*(1,0)) else: (shiftev,0) fi + if dirtree=0: rotatedaround(Fintmp[counttmp],dirlabel) fi rotatedaround(Ori,dirtree); countlab:=0 fi; @@ -201,11 +294,19 @@ vardef arbre_decv(expr Ori,horiz,Ymax)(text t)(text r)= save Fin,compt,Ytmp; numeric compt,Ytmp; pair Fin[]; - Fin[0]:=Ori+(horiz,Ymax); + if abscoord: + Fin[0]:=(horiz,Ymax) + else: + Fin[0]:=Ori+(horiz,Ymax) + fi; compt:=0;Ytmp:=Ymax; for i=t: compt:=compt+1;Ytmp:=i; - Fin[compt]:=Ori+(horiz,Ytmp); + if abscoord: + Fin[compt]:=(horiz,Ytmp) + else: + Fin[compt]:=Ori+(horiz,Ytmp) + fi; endfor def ptarr= Fin[0] @@ -221,13 +322,21 @@ vardef arbre_fixe(expr Ori,horiz,Ymax,decy)(text r)= save Fin,compt,compt_par; numeric compt,compt_par; pair Fin[]; - Fin[0]:=Ori+(horiz,Ymax); + if abscoord: + Fin[0]:=(horiz,Ymax + ypart Ori) + else: + Fin[0]:=Ori+(horiz,Ymax) + fi; compt:=0;compt_par:=0; for i=r: compt:=compt+1;compt_par:=compt_par+1; if compt_par=2: compt_par:=0; - Fin[compt/2]:=Ori+(horiz,Ymax-decy*compt/2); + if abscoord: + Fin[compt/2]:=(0, ypart Ori) + (horiz,Ymax-decy*compt/2) + else: + Fin[compt/2]:=Ori+(horiz,Ymax-decy*compt/2) + fi; fi endfor def ptarr= @@ -255,11 +364,11 @@ enddef; vardef reg.arbre[][](text t)(text r)= save compt,decal; -% numeric compt,decal[],shiftev; numeric compt,decal[]; colonne_cour:=colonne.#@; ligne_cour:=@; typedec:=0; + if shiftev<>0: typedec:=1 fi; compt:=0; for i=t: if numeric i: @@ -283,6 +392,7 @@ vardef comp.arbre[][](text t)(text r)= colonne_cour:=colonne.#@; ligne_cour:=@; typedec:=0; + if shiftev<>0: typedec:=1 fi; save tmp_compt; numeric tmp_compt; tmp_compt:=0; @@ -292,7 +402,10 @@ vardef comp.arbre[][](text t)(text r)= scantokens i fi; endfor - def tmp_text= + if abscoord: + def tmp_text=t enddef + else: + def tmp_text= % Si abscoord tmp_text=t for i=t: hide(tmp_compt:=tmp_compt+1;) if (tmp_compt>1) and (not string i): @@ -301,37 +414,11 @@ vardef comp.arbre[][](text t)(text r)= Orig_arbre[colonne_cour][ligne_cour]+i fi endfor - enddef; + enddef + fi; _arbre_(Orig_arbre[colonne_cour][ligne_cour])(tmp_text)(r) enddef; - -vardef ddec.arbre[][](text t)(text r)= - save decal; - numeric decal[]; - colonne_cour:=colonne.#@; - ligne_cour:=@; - typedec:=0; - save tmp_compt; - numeric tmp_compt; - tmp_compt:=0; - for i=t: - if numeric i: - tmp_compt:=tmp_compt+1; - decal[tmp_compt]:=i - else: - typedec:=1; - scantokens i - fi; - endfor - def tmp_text= - -decal[3] - for i=4 upto tmp_compt: - ,-decal[i] - endfor - enddef; - arbre_var(Orig_arbre[colonne_cour][ligne_cour],decal[1],decal[2])(tmp_text)(r) -enddef; %%%%%%%%%%%%%%%%%%%%%%%%% Modif 10/16 - Décalage par rapport à l'origine vardef dec.arbre[][](text t)(text r)= @@ -340,6 +427,7 @@ vardef dec.arbre[][](text t)(text r)= colonne_cour:=colonne.#@; ligne_cour:=@; typedec:=0; + if shiftev<>0: typedec:=1 fi; save tmp_compt; numeric tmp_compt; tmp_compt:=0; |