diff options
author | Karl Berry <karl@freefriends.org> | 2007-11-06 19:39:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-11-06 19:39:24 +0000 |
commit | 647ffa0224624c3d97c119efaef5191bdaff3067 (patch) | |
tree | d2103bd9f56be6d93b9f879e263380c802709a88 /Master/texmf-dist/metapost/blockdraw_mp | |
parent | 59d409e3e827d1630055bbbb9a2606005b1f035c (diff) |
new metapost package blockdraw_mp (22jan07)
git-svn-id: svn://tug.org/texlive/trunk@5381 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/blockdraw_mp')
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/blockdraw.mp | 310 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/bonddemo.mp | 63 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/bondgraph.mp | 226 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/cascadedemo.mp | 73 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/docblockprefs.mp | 18 | ||||
-rw-r--r-- | Master/texmf-dist/metapost/blockdraw_mp/shiftoff.mp | 130 |
6 files changed, 820 insertions, 0 deletions
diff --git a/Master/texmf-dist/metapost/blockdraw_mp/blockdraw.mp b/Master/texmf-dist/metapost/blockdraw_mp/blockdraw.mp new file mode 100644 index 00000000000..1396f574ea4 --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/blockdraw.mp @@ -0,0 +1,310 @@ +%% blockdraw.mp +%% Copyright 2006 Henrik Tidefelt +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained´. +% +% The Current Maintainer of this work is Henrik Tidefelt, +% tidefelt@isy.liu.se. +% +% This work, referred to as blockdraw.mp, consists of the files +% shiftoff.mp +% blockdraw.mp +% bondgraph.mp +% blockdraw_mp.pdf + +numeric longblockrx; +numeric longblockry; +numeric smallblockr; +longblockrx := 0.7cm; +longblockry := 0.4cm; +smallblockr := 0.3cm; + +numeric connectionlw; +numeric blocklw; +connectionlw := 0.8pt; +blocklw = connectionlw; + +numeric textscale; +textscale := 1; + +boolean implicitdraw; +implicitdraw := true; + +input shiftoff; + +def sizedblock(expr txt, z, rx, ry ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic also shiftoff( txt scaled textscale, to_center ); + addto tmppic doublepath (-rx,-ry)--(-rx,ry)--(rx,ry)--(rx,-ry)--cycle withpen pencircle scaled blocklw; + tmppic := tmppic shifted z; + if implicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; +def longblock(expr txt, z ) = + sizedblock( txt, z, longblockrx, longblockry ) +enddef; +def squareblock(expr txt, z ) = + sizedblock( txt, z, smallblockr, smallblockr ) +enddef; +def roundblock(expr txt, z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic also shiftoff( txt scaled textscale, to_center ); + addto tmppic doublepath (smallblockr,0)...(0,smallblockr)...(-smallblockr,0)...(0,-smallblockr)...cycle withpen pencircle scaled blocklw; + tmppic := tmppic shifted z; + if implicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; +def splitdot(expr z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic contour fullcircle scaled 2.5connectionlw shifted z; + if implicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; +def termcircle(expr z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic doublepath fullcircle scaled 7connectionlw shifted z; + if implicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; +def pointpicture(expr z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic contour fullcircle scaled 0 shifted z; + tmppic + endgroup +enddef; + +def mspoint( expr pth, mediation, slide ) = +(point (arctime mediation * arclength(pth) + slide of pth) of pth) +enddef; +def hhconnect(expr pa, pb, mediation, slide ) = + begingroup + save mid, respath; + numeric mid; + path respath; + mid := (mediation)[ xpart pa, xpart pb ] + (if (xpart pb) > (xpart pa): 1 else: -1 fi) * slide; + respath := pa--( mid, ypart pa )--( mid, ypart pb )--pb; + if implicitdraw: + drawarrow respath withpen pencircle scaled connectionlw; + fi + respath + endgroup +enddef; +def vvconnect(expr pa, pb, mediation, slide ) = + begingroup + save mid, respath; + numeric mid; + path respath; + mid := (mediation)[ ypart pa, ypart pb ] + (if (ypart pb) > (ypart pa): 1 else: -1 fi) * slide; + respath := pa--( xpart pa, mid )--( xpart pb, mid )--pb; + if implicitdraw: + drawarrow respath withpen pencircle scaled connectionlw; + fi + respath + endgroup +enddef; +def hvconnect(expr pa, pb ) = + begingroup + save respath; + path respath; + respath := pa--( xpart pb, ypart pa )--pb; + if implicitdraw: + drawarrow respath withpen pencircle scaled connectionlw; + fi + respath + endgroup +enddef; +def vhconnect(expr pa, pb ) = + begingroup + save respath; + path respath; + respath := pa--( xpart pa, ypart pb )--pb; + if implicitdraw: + drawarrow respath withpen pencircle scaled connectionlw; + fi + respath + endgroup +enddef; + +def conlabel(expr shiftdir, txt, z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := shiftoffwlm( txt scaled textscale, shiftdir ) shifted z; + if implicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; + +def leftpoint(expr pic, n, i ) = + (i/(n+1))[llcorner pic,ulcorner pic] +enddef; +def rightpoint(expr pic, n, i ) = + (i/(n+1))[lrcorner pic,urcorner pic] +enddef; +def bottompoint(expr pic, n, i ) = + (i/(n+1))[llcorner pic,lrcorner pic] +enddef; +def toppoint(expr pic, n, i ) = + (i/(n+1))[ulcorner pic,urcorner pic] +enddef; +def llconnect(expr pica, picb, slide ) = + begingroup + hhconnect( leftpoint( pica, 1, 1 ), leftpoint( picb, 1, 1 ), 0.5, slide ) + endgroup +enddef; +def rrconnect(expr pica, picb, slide ) = + begingroup + hhconnect( rightpoint( pica, 1, 1 ), rightpoint( picb, 1, 1 ), 0.5, slide ) + endgroup +enddef; +def ttconnect(expr pica, picb, slide ) = + begingroup + vvconnect( toppoint( pica, 1, 1 ), toppoint( picb, 1, 1 ), 0.5, slide ) + endgroup +enddef; +def bbconnect(expr pica, picb, slide ) = + begingroup + vvconnect( bottompoint( pica, 1, 1 ), bottompoint( picb, 1, 1 ), 0.5, slide ) + endgroup +enddef; +def lrconnect(expr pica, picb ) = + begingroup + hhconnect( leftpoint( pica, 1, 1 ), rightpoint( picb, 1, 1 ), 0.5, 0 ) + endgroup +enddef; +def rlconnect(expr pica, picb ) = + begingroup + hhconnect( rightpoint( pica, 1, 1 ), leftpoint( picb, 1, 1 ), 0.5, 0 ) + endgroup +enddef; +def btconnect(expr pica, picb ) = + begingroup + vvconnect( bottompoint( pica, 1, 1 ), toppoint( picb, 1, 1 ), 0.5, 0 ) + endgroup +enddef; +def tbconnect(expr pica, picb ) = + begingroup + vvconnect( toppoint( pica, 1, 1 ), bottompoint( picb, 1, 1 ), 0.5, 0 ) + endgroup +enddef; +def ltconnect(expr pica, picb ) = + begingroup + hvconnect( leftpoint( pica, 1, 1 ), toppoint( picb, 1, 1 ) ) + endgroup +enddef; +def lbconnect(expr pica, picb ) = + begingroup + hvconnect( leftpoint( pica, 1, 1 ), bottompoint( picb, 1, 1 ) ) + endgroup +enddef; +def rtconnect(expr pica, picb ) = + begingroup + hvconnect( rightpoint( pica, 1, 1 ), toppoint( picb, 1, 1 ) ) + endgroup +enddef; +def rbconnect(expr pica, picb ) = + begingroup + hvconnect( rightpoint( pica, 1, 1 ), bottompoint( picb, 1, 1 ) ) + endgroup +enddef; +def tlconnect(expr pica, picb ) = + begingroup + vhconnect( toppoint( pica, 1, 1 ), leftpoint( picb, 1, 1 ) ) + endgroup +enddef; +def trconnect(expr pica, picb ) = + begingroup + vhconnect( toppoint( pica, 1, 1 ), rightpoint( picb, 1, 1 ) ) + endgroup +enddef; +def blconnect(expr pica, picb ) = + begingroup + vhconnect( bottompoint( pica, 1, 1 ), leftpoint( picb, 1, 1 ) ) + endgroup +enddef; +def brconnect(expr pica, picb ) = + begingroup + vhconnect( bottompoint( pica, 1, 1 ), rightpoint( picb, 1, 1 ) ) + endgroup +enddef; + +def connect(expr pica, picb ) = + begingroup + save rxa, rya, rxb, ryb; + numeric rxa; + numeric rya; + numeric rxb; + numeric ryb; + save ca, cb; + pair ca; + pair cb; + rxa = 0.5 * ((xpart lrcorner pica) - (xpart llcorner pica)); + rya = 0.5 * ((ypart ulcorner pica) - (ypart llcorner pica)); + rxb = 0.5 * ((xpart lrcorner picb) - (xpart llcorner picb)); + ryb = 0.5 * ((ypart ulcorner picb) - (ypart llcorner picb)); + ca = center pica; + cb = center picb; + if (xpart ca) < (xpart cb) - ( rxa + rxb ): + if (ypart ca) < (ypart cb) - ( rya + ryb ): + rbconnect( pica, picb ) + elseif (ypart ca) > (ypart cb) + ( rya + ryb ): + rtconnect( pica, picb ) + else: + rlconnect( pica, picb ) + fi + elseif (xpart ca) > (xpart cb) + ( rxa + rxb ): + if (ypart ca) < (ypart cb) - ( rya + ryb ): + lbconnect( pica, picb ) + elseif (ypart ca) > (ypart cb) + ( rya + ryb ): + ltconnect( pica, picb ) + else: + lrconnect( pica, picb ) + fi + else: + if (ypart ca) < (ypart cb) - ( rya + ryb ): + tbconnect( pica, picb ) + elseif (ypart ca) > (ypart cb) + ( rya + ryb ): + btconnect( pica, picb ) + else: + hvconnect( center pica, center picb ) + fi + fi + endgroup +enddef; diff --git a/Master/texmf-dist/metapost/blockdraw_mp/bonddemo.mp b/Master/texmf-dist/metapost/blockdraw_mp/bonddemo.mp new file mode 100644 index 00000000000..3f74bd9abe9 --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/bonddemo.mp @@ -0,0 +1,63 @@ +verbatimtex +%& latex +\documentclass[a4]{article} +\begin{document} +etex + +input bondgraph; +def pjunction(expr z ) = + junction( btex p etex, z ) +enddef; +def sjunction(expr z ) = + junction( btex s etex, z ) +enddef; +def tfjunction(expr z, arrowdir, lbl ) = + junctionlbl( btex TF etex, arrowdir, lbl, z, true ) +enddef; +def gyjunction(expr z, arrowdir, lbl ) = + junctionlbl( btex GY etex, arrowdir, lbl, z, false ) +enddef; + +beginfig( -1 ) + numeric u; + u := 2cm; + ahlength := 0.15*u; + + picture j[]; + j1 := sjunction( (1u,1u) ); + j2 := gyjunction( (2u,1u), to_rt, btex $\mu$ etex ); + j3 := sjunction( (3u,1u) ); + j4 := tfjunction( (4u,1u), to_rt, btex $r$ etex ); + j5 := pjunction( (5u,1u) ); + j6 := sjunction( (5u,-0.5u) ); + j7 := sjunction( (5u,2u) ); + + tbond( bgconnect( j1, j2 ) ); + hbond( bgconnect( j2, j3 ) ); + tbond( bgconnect( j3, j4 ) ); + tbond( bgconnect( j4, j5 ) ); + hbond( bgconnect( j5, j6 ) ); + tbond( bgconnect( j5, j7 ) ); + + tbond( terminalfr( j1, btex R: $\phi_{1}(\bullet)$ etex, (1u,0u) ) ); + hbond( terminalfr( j1, btex I: $m_{1}$ etex, (1u,2u) ) ); + hbond( terminalfr( j3, btex I: $m_{2}$ etex, (3u,2u) ) ); + tbond( terminalfr( j3, btex R: $R_{2}$ etex, (center j3)+1u*dir(-120) ) ); + tbond( terminalfr( j3, btex R: $R_{3}$ etex, (center j3)+1u*dir(-60) ) ); + + hbond( terminalto( j6, btex $S_{\mathrm{e}}$ etex, (center j6)+(-1u,0u) ) ); + hbond( terminalfr( j6, btex I: $m_{3}$ etex, (center j6)+(1u,0u) ) ); + + tbond( terminalfr( j7, btex C: $C_{1}$ etex, (4u,2u) ) ); + tbond( terminalfr( j7, btex R: $R_{1}$ etex, (6u,2u) ) ); + + path con; + picture lab; + + con := terminalto( j1, btex $S_{\mathrm{e}}$ etex, (0u,1u) ); + hbond( con ); + flowlabel( con, btex f etex ); + effortlabel( con, btex e etex ); + +endfig; +end; diff --git a/Master/texmf-dist/metapost/blockdraw_mp/bondgraph.mp b/Master/texmf-dist/metapost/blockdraw_mp/bondgraph.mp new file mode 100644 index 00000000000..ba5d861d14d --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/bondgraph.mp @@ -0,0 +1,226 @@ +%% bondgraph.mp +%% Copyright 2007 Henrik Tidefelt +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained´. +% +% The Current Maintainer of this work is Henrik Tidefelt, +% tidefelt@isy.liu.se. +% +% This work, referred to as blockdraw.mp, consists of the files +% shiftoff.mp +% blockdraw.mp +% bondgraph.mp +% blockdraw_mp.pdf +% +% +% === Notes regarding the backward incompatible changes of 2007-01-21. === +% +% As it was discovered that MetaPost uses the verbatimtex construct only in +% the file it appears in, it was concluded that package files cannot contain +% any content that depends on the LaTeX preamble. In other words, any +% btex ... etex constructs must be moved from package files to the application +% sources from where the package files are included. +% +% With the definition of, say, p-junction blocks in the application source, +% it is easy to change notation from the letters "p" and "s" to the numbers +% "0" and "1". +% +% The obvious drawback, beside backward incompatibility, is that this will +% cause a lot of code replication, making bond graph source files +% less concise, and require multiple file search-and-replace actions when +% changing junction notation for a collection of graphs. However, since +% MetaPost only allows literal character strings in the btex ... etex +% construct, these inconveniences seem impossible to work around. Ideas, +% anyone? + +input blockdraw; +implicitdraw := false; + +boolean junctionimplicitdraw; +junctionimplicitdraw := true; + +boolean useopenbonds; +useopenbonds := false; + +connectionlw := 0.5pt; +ahlength := 3mm; +bboxmargin := 1.5mm; + +def withbbmargin(expr pic ) = + begingroup + save tmppic; + picture tmppic; + tmppic = pic; + setbounds tmppic to bbox pic; + tmppic + endgroup +enddef; + +def junction(expr txt, z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := nullpicture; + addto tmppic also shiftoff( txt scaled textscale, to_center ); + setbounds tmppic to (-smallblockr,-smallblockr)--(-smallblockr,smallblockr)--(smallblockr,smallblockr)--(smallblockr,-smallblockr)--cycle; + tmppic := tmppic shifted z; + if junctionimplicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; + + +def junctionlbl(expr txt, arrowdir, lbl, z, arrow ) = + begingroup + save tmppic, ahlength, p, d; + ahlength := 1mm; + path p; + numeric d; + picture tmppic; + tmppic := nullpicture; + addto tmppic also shiftoff( txt scaled textscale, to_center ); + + if arrowdir = to_top: + p := ((lrcorner tmppic)--(urcorner tmppic)) shifted ( z + (connectionlw + 2*ahlength*sind(0.5*ahangle),0) ); + d = to_rt; + elseif arrowdir = to_lft: + p := ((urcorner tmppic)--(ulcorner tmppic)) shifted ( z + (0,connectionlw + 2*ahlength*sind(0.5*ahangle)) ); + d = to_top; + elseif arrowdir = to_bot: + p := ((urcorner tmppic)--(lrcorner tmppic)) shifted ( z + (connectionlw + 2*ahlength*sind(0.5*ahangle),0) ); + d = to_rt; + elseif arrowdir = to_rt: + p := ((ulcorner tmppic)--(urcorner tmppic)) shifted ( z + (0,connectionlw + 2*ahlength*sind(0.5*ahangle)) ); + d = to_top; + fi + + setbounds tmppic to (-smallblockr,-smallblockr)--(-smallblockr,smallblockr)--(smallblockr,smallblockr)--(smallblockr,-smallblockr)--cycle; + tmppic := tmppic shifted z; + + if junctionimplicitdraw: + if arrow: + drawarrow p withpen pencircle scaled connectionlw; + fi + draw conlabel( d, lbl, mspoint( p, 0.5, 0 ) ); + draw tmppic; + fi + tmppic + endgroup +enddef; + +def terminal(expr d, txt, z ) = + begingroup + save tmppic; + picture tmppic; + tmppic := shiftoff( withbbmargin( txt scaled textscale ), d ) shifted ( z - smallblockr * dir_to( d ) ); + if junctionimplicitdraw: + draw tmppic; + fi + tmppic + endgroup +enddef; + +def ignorepicture(expr pic ) = + show 0 +enddef; + +def terminalto(expr j, txt, z ) = + begingroup + ignorepicture( terminal( to_dir( z - (center j) ), txt, z ) ); + bgconnect( pointpicture( z ) , j ) + endgroup +enddef; + +def terminalfr(expr j, txt, z ) = + begingroup + ignorepicture( terminal( to_dir( z - (center j) ), txt, z ) ); + bgconnect( j, pointpicture( z ) ) + endgroup +enddef; + +def bgconnect(expr pica, picb ) = + begingroup + save d; + pair d; + if (center pica) = (center picb): + d := (1,0); + else: + d := unitvector( (center picb) - (center pica) ); + fi + ((center pica)+d*smallblockr)--((center picb)-d*smallblockr) + endgroup +enddef; + +def bond(expr p ) = + begingroup + save t; + numeric t; + t := arctime arclength(p) - ahlength of p; + save z; + pair z; + z = (point t of p) + dir(angle(direction t of p)+90) * ahlength*sind(0.5*ahangle); + save res; + path res; + if useopenbonds: + draw p--z withpen pencircle scaled connectionlw + else: + draw p withpen pencircle scaled connectionlw; + res = (subpath (t,infinity) of p)--z--cycle; + filldraw res withpen pencircle scaled connectionlw + fi + endgroup +enddef; + +def causalmark(expr p, where ) = + begingroup + save d; + numeric d; + d = angle( direction where of p ); + if where = 0: + d := d + 180; + fi + save z; + pair z; + z = ( point where of p ) + dir(d) * connectionlw; + save res; + path res; + res = (z+dir(d+90)*ahlength*sind(0.5*ahangle))--(z+dir(d-90)*ahlength*sind(0.5*ahangle)); + draw res withpen pencircle scaled (2*connectionlw) + endgroup +enddef; + +def hbond(expr p ) = + begingroup + bond( p ); + causalmark( p, infinity ) + endgroup +enddef; + +def tbond(expr p ) = + begingroup + bond( p ); + causalmark( p, 0 ) + endgroup +enddef; + +def flowlabel(expr p, txt ) = +% the midpoint has typically singular direction, so we can't do the obvious: +% draw( conlabel( to_dir( dir( angle( direction (0.5*length(p)) of p ) - 90 ) ), txt, mspoint( p, 0.5, 0 ) ) ) + draw conlabel( to_dir( dir( angle( (point infinity of p) - (point 0 of p) ) - 90 ) ), txt, mspoint( p, 0.5, 0 ) ) withpen pencircle scaled connectionlw +enddef; + +def effortlabel(expr p, txt ) = +% the midpoint has typically singular direction, so we can't do the obvious: +% draw( conlabel( to_dir( dir( angle( direction (0.5*length(p)) of p ) + 90 ) ), txt, mspoint( p, 0.5, 0 ) ) ) + draw conlabel( to_dir( dir( angle( (point infinity of p) - (point 0 of p) ) + 90 ) ), txt, mspoint( p, 0.5, 0 ) ) withpen pencircle scaled connectionlw +enddef; diff --git a/Master/texmf-dist/metapost/blockdraw_mp/cascadedemo.mp b/Master/texmf-dist/metapost/blockdraw_mp/cascadedemo.mp new file mode 100644 index 00000000000..26c919bb83a --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/cascadedemo.mp @@ -0,0 +1,73 @@ +verbatimtex +%& latex +\documentclass[a4]{article} +\begin{document} +etex + +input blockdraw; +input ./docblockprefs; + + +beginfig( -1 ) + + % The controller box has corners (x1,y1), (x2,y2) + % The inner system box has corners (x3,y3), (x4,y4) + y1 := -2u; + y2 := 1.3u; + y3 := -1.4u; + y4 := 1u; + + picture reg[]; + reg1 := longblock( btex Reg.~1 etex, (-1u,0) ); + reg2 := longblock( btex Reg.~2 etex, (-4u,0) ); + + picture G[]; + G1 := longblock( btex $G_{1}$ etex, (1.5u,0) ); + G2 := longblock( btex $G_{2}$ etex, (4u,0) ); + + picture terminator[]; + terminator1 := pointpicture( leftpoint( reg2, 2, 2 ) - (1u,0) ); + terminator2 := pointpicture( (5.5u,0) ); + + path con; + picture lab; + + con := hhconnect( center( terminator1 ), leftpoint( reg2, 2, 2 ), 0.5, 0 ); + lab := conlabel( to_ulft, btex $y_{\mathrm{ref}}$ etex, point infinity of con ); + x1 := xpart( mspoint( con, 0.2, 0 ) ); + + con := hhconnect( rightpoint( reg2, 2, 2 ), leftpoint( reg1, 2, 2 ), 0.5, 0 ); + lab := conlabel( to_urt, btex $z_{\mathrm{ref}}$ etex, point 0 of con ); + x3 := xpart( mspoint( con, 0.6, 0 ) ); + + con := rlconnect( reg1, G1 ); + lab := conlabel( to_top, btex $u$ etex, mspoint( con, 0.8, 0 ) ); + x2 := xpart( mspoint( con, 0.3, 0 ) ); + + picture split[]; + + con := rlconnect( G1, G2 ); + lab := conlabel( to_top, btex $z$ etex, mspoint( con, 0.8, 0 ) ); + split1 := splitdot( mspoint( con, 0.3, 0 ) ); + x4 := xpart( mspoint( con, 0.5, 0 ) ); + + con := rlconnect( G2, terminator2 ); + lab := conlabel( to_top, btex $y$ etex, mspoint( con, 0.8, 0 ) ); + split2 := splitdot( mspoint( con, 0.4, 0 ) ); + + % Draw boxes + draw (x1,y1)--(x1,y2)--(x2,y2)--(x2,y1)--cycle withpen pencircle scaled dashlw dashed gldash1; + draw (x3,y3)--(x3,y4)--(x4,y4)--(x4,y3)--cycle withpen pencircle scaled dashlw dashed gldash2; + + % Draw broken connections + pair p; + p := ( x2, 0.5[y1,y3] ); + con := vhconnect( center split2, p ); + con := hhconnect( p, leftpoint( reg2, 2, 1 ), 1, 0.4u ); + + p := ( x2, 1.5[y1,y3] ); + con := vhconnect( center split1, p ); + con := hhconnect( p, leftpoint( reg1, 2, 1 ), 1, 0.4u ); + +endfig; +end; diff --git a/Master/texmf-dist/metapost/blockdraw_mp/docblockprefs.mp b/Master/texmf-dist/metapost/blockdraw_mp/docblockprefs.mp new file mode 100644 index 00000000000..1aa63c0f01e --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/docblockprefs.mp @@ -0,0 +1,18 @@ +numeric u; +u := 1cm; + +numeric dashlw; +dashlw := 0.3pt; +picture gldash[]; +gldash1 := dashpattern( on 0.25u off 0.25u ); +gldash2 := dashpattern( on 0.5u off 0.1u on 0.1u off 0.1u on 0.1u off 0.1u ); + +longblockrx := 0.7u; +longblockry := 0.4u; +smallblockr := 0.3u; +connectionlw := 0.8pt; +textscale := 1; + +shiftofflabelmargin := 2bboxmargin; +pickup pencircle scaled connectionlw; + diff --git a/Master/texmf-dist/metapost/blockdraw_mp/shiftoff.mp b/Master/texmf-dist/metapost/blockdraw_mp/shiftoff.mp new file mode 100644 index 00000000000..b5ad73f834c --- /dev/null +++ b/Master/texmf-dist/metapost/blockdraw_mp/shiftoff.mp @@ -0,0 +1,130 @@ +%% shiftoff.mp +%% Copyright 2006 Henrik Tidefelt +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained´. +% +% The Current Maintainer of this work is Henrik Tidefelt, +% tidefelt@isy.liu.se. +% +% This work, referred to as blockdraw.mp, consists of the files +% shiftoff.mp +% blockdraw.mp +% bondgraph.mp +% blockdraw_mp.pdf + +numeric to_lft; +to_lft = 0; +numeric to_llft; +to_llft = 1; +numeric to_bot; +to_bot = 2; +numeric to_lrt; +to_lrt = 3; +numeric to_rt; +to_rt = 4; +numeric to_urt; +to_urt = 5; +numeric to_top; +to_top = 6; +numeric to_ulft; +to_ulft = 7; +numeric to_center; +to_center = 8; + +def to_dir(expr z ) = + if (xpart z) > 0: + if (ypart z) > 0: + if abs(xpart z) > 2*abs(ypart z): + to_rt + elseif abs(ypart z) > 2*abs(xpart z): + to_top + else: + to_urt + fi + else: + if abs(xpart z) > 2*abs(ypart z): + to_rt + elseif abs(ypart z) > 2*abs(xpart z): + to_bot + else: + to_lrt + fi + fi + else: + if (ypart z) > 0: + if abs(xpart z) > 2*abs(ypart z): + to_lft + elseif abs(ypart z) > 2*abs(xpart z): + to_top + else: + to_ulft + fi + else: + if abs(xpart z) > 2*abs(ypart z): + to_lft + elseif abs(ypart z) > 2*abs(xpart z): + to_bot + else: + to_llft + fi + fi + fi +enddef; + +def dir_to(expr d ) = + dir( 180 + d * 45 ) +enddef; + +def shiftoff(expr pic, corner ) = + if corner = to_lft: + (pic shifted ((-center pic)+((xpart llcorner pic)-(xpart center pic),0))) + elseif corner = to_llft: + (pic shifted ((-center pic)+(llcorner pic)-(center pic))) + elseif corner = to_bot: + (pic shifted ((-center pic)+(0,(ypart llcorner pic)-(ypart center pic)))) + elseif corner = to_lrt: + (pic shifted ((-center pic)+(lrcorner pic)-(center pic))) + elseif corner = to_rt: + (pic shifted ((-center pic)+((xpart lrcorner pic)-(xpart center pic),0))) + elseif corner = to_urt: + (pic shifted ((-center pic)+(urcorner pic)-(center pic))) + elseif corner = to_top: + (pic shifted ((-center pic)+(0,(ypart ulcorner pic)-(ypart center pic)))) + elseif corner = to_ulft: + (pic shifted ((-center pic)+(ulcorner pic)-(center pic))) + else: + (pic shifted (-center pic)) + fi +enddef; + +numeric shiftofflabelmargin; +shiftofflabelmargin := bboxmargin; +def shiftoffwlm(expr pic, corner ) = + if corner = to_lft: + (pic shifted ((-center pic)+((xpart llcorner pic)-(xpart center pic),0)+(-shiftofflabelmargin,0))) + elseif corner = to_llft: + (pic shifted ((-center pic)+(llcorner pic)-(center pic)+(-shiftofflabelmargin,-shiftofflabelmargin))) + elseif corner = to_bot: + (pic shifted ((-center pic)+(0,(ypart llcorner pic)-(ypart center pic))+(0,-shiftofflabelmargin))) + elseif corner = to_lrt: + (pic shifted ((-center pic)+(lrcorner pic)-(center pic)+(shiftofflabelmargin,-shiftofflabelmargin))) + elseif corner = to_rt: + (pic shifted ((-center pic)+((xpart lrcorner pic)-(xpart center pic),0)+(shiftofflabelmargin,0))) + elseif corner = to_urt: + (pic shifted ((-center pic)+(urcorner pic)-(center pic)+(shiftofflabelmargin,shiftofflabelmargin))) + elseif corner = to_top: + (pic shifted ((-center pic)+(0,(ypart ulcorner pic)-(ypart center pic))+(0,shiftofflabelmargin))) + elseif corner = to_ulft: + (pic shifted ((-center pic)+(ulcorner pic)-(center pic)+(-shiftofflabelmargin,shiftofflabelmargin))) + else: + (pic shifted (-center pic)) + fi +enddef; |