diff options
author | Karl Berry <karl@freefriends.org> | 2007-09-21 23:38:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-09-21 23:38:07 +0000 |
commit | 86e969af419d5eb4673019935c7c52666852b8ab (patch) | |
tree | d4d63a7f6afc1e53f25ba5baa6f212ab32863b99 /Master/texmf-dist/metapost/metaobj/metaobj.mp | |
parent | 09801452f2b04ec137e6733202a86ad7e014a5e5 (diff) |
metaobj doc in metapost (luecking, 23 Jul 2007 13:47:15)
git-svn-id: svn://tug.org/texlive/trunk@5000 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/metaobj/metaobj.mp')
-rw-r--r-- | Master/texmf-dist/metapost/metaobj/metaobj.mp | 458 |
1 files changed, 395 insertions, 63 deletions
diff --git a/Master/texmf-dist/metapost/metaobj/metaobj.mp b/Master/texmf-dist/metapost/metaobj/metaobj.mp index ea7401c58ef..8daf16e0d3b 100644 --- a/Master/texmf-dist/metapost/metaobj/metaobj.mp +++ b/Master/texmf-dist/metapost/metaobj/metaobj.mp @@ -1,9 +1,17 @@ -% metaobj.mp 0.83 +% metaobj.mp 0.93 % D. Roegel (roegel@loria.fr) % January 15 - June 14, 2001 % November 13, 2001 % December 5, 2001 % December 23, 2002 +% March 23, 2004 +% April 9, 2004 +% May 27, 2004 +% June 1, 2004 +% October 5, 2005 +% October 23, 2005 +% May 1st, 2006 +% June 18, 2006 % % MetaPost bug: % ------------ @@ -67,7 +75,84 @@ % but never reported to me since); % all other such misuses (in five other macros) % have been corrected. -% +% 0.84 March 23, 2004: bug correction in newCircle (usually, only half +% of the cardinal points were correctly positionned) +% (bug noticed by Stephan Hennig, +% comp.text.tex, 2004-03-18 14:55:54 PST) +% The bug is also visible on page 43 of the manual, +% when the use of posA(n) is shown. +% It will be corrected in future versions of +% the manual. +% 0.85 April 9, 2004: arctime renamed into arctime_ +% to avoid conflict with the cmarrows package +% (bug noticed by Stephan Hennig, +% comp.text.tex) +% 0.86 May 27, 2004: treemode made a global option of trees +% (bug noticed by Stephan Hennig) +% (Actually, a number of local options should be +% made global, and will probably be made so soon.) +% 0.87 June 1, 2004: - in drawTree, the root is unfilled only when +% there are fan children; before, it was always done +% (bug noticed by Stephan Hennig, May 29, 2004) +% - in all tc... macros, ntreepos was replaced +% by treeroot (bug noticed by Stephan Hennig, May 29, 2004) +% - labshift option now works when labels are attached +% to paths +% 0.88 October 5, 2005: - in newMatrix, the largest and tallest elements +% were not correctly computed when the options +% matrixnodehsize or matrixnodevsize were positive; +% surprisingly, these options had never been tested. +% (bug noticed by Stephan Hennig, September 2005) +% 0.89 October 23, 2005: - in newMatrix, the bounding box was not correctly +% computed when the options +% matrixnodehsize or matrixnodevsize were positive; +% (bug noticed by Stephan Hennig, October 2005) +% - also in newMatrix, the vertical distance between +% two rows was not correctly computed when the option +% matrixnodevsize was positive (the horizontal +% distance problem was corrected for version 0.88, +% but this one was forgotten) +% (bug noticed by Stephan Hennig, October 2005) +% 0.90 May 1st, 2006: - in ObjLabel, user labels were only +% correctly positionned when the c point of the +% object was at the origin, because I had forgotten +% to translate the label. Incidentally, the bug +% occurred right next to the labshift bug corrected +% for version 0.87. +% (bug noticed by Stephan Hennig, May 2004, +% who reminded me on April 30, 2006) +% 0.91 June 18, 2006: - connections such as ncdiag didn't use +% global defaults for angleA and angleB +% (bug noticed by Stephan Hennig, 18 June 2006) +% This was corrected in macro nc__. +% 0.92 Sep 27, 2006: - define_local_picture_option added +% for labels on connections +% (this change, and those up to Oct. 5, +% were prompted by Steffen Reith +% Steffen Reith <streit@streit.cc>) +% 0.921 Oct 2, 2006: - labpos, labpic, labdist, labangle +% and labdir can now be used with immediate +% connections +% Oct 3, 2006: - the objpathlabel_ macro had a bug related +% to the change of version 0.90, in that +% labels were not correctly positioned if +% the object was not centered at the origin; +% the problem had only partly been corrected +% in version 0.90; +% Oct 5, 2006: - finished the label code for connections +% added to objects (nc_core_) +% - the labdist option is now recognized also +% for ObjLabel +% 0.923 Nov 10, 2006: - additional testing in nc__ for the case +% where the two object centers are the same; +% - new `curvemax' option for nccurve +% (prompted by Steffen Reith +% Steffen Reith <streit@streit.cc>) +% - `nccurve_' was extended to improve +% its behavior when the curve is looping +% 0.93 Dec 3, 2006: - improvement of Container class +% to be mentioned in LGC2 +% (this class was suggested by Michael Schwarz) % % The code has a lot of formatting for the mft program, but mft (even % with Ulrick Vieth's changes) can't be used, because metaobj's code @@ -77,8 +162,8 @@ if known metaobj_version: expandafter endinput; fi; numeric metaobj_version;string metaobj_date; -metaobj_version=0.83; -metaobj_date="2002/12/23"; +metaobj_version=0.93; +metaobj_date="2006/12/03"; % The banner: message "******* metaobj " & decimal (metaobj_version) & " (c) D. Roegel (" & metaobj_date & ") *******";message ""; @@ -1306,20 +1391,20 @@ vardef duplicateObj(suffix n,m)= save gen_n_;string gen_n_;gen_n_=generisize_(str n); % we copy the options and their values: if known m.options_: - if gen_n_=str n: + %if (gen_n_=str n): % UNSURE IF THIS SHOULD ALWAYS BE COMMENTED (October 23, 2005) if unknown n.options_: expandafter string sc_(gen_n_).options_; fi; - fi; + %fi n.options_=m.options_; forsuffixes $:=sc_(n.options_): % each |$| suffix starts with a |_| - if gen_n_=str n: + %if gen_n_=str n: % UNSURE IF THIS SHOULD ALWAYS BE COMMENTED (October 23, 2005) if expandafter unknown sc_(str n & ".option" & str $ & "_"): sc_(TypeOf(sc_(str m & ".option" & str $ & "_")) & " " & gen_n_ & ".option" & str $ & "_"); fi; - fi; + %fi; n.sc_("option" & str $ & "_")=m.sc_("option" & str $ & "_"); endfor; fi; @@ -2263,6 +2348,10 @@ def define_local_boolean_option(expr s)= define_local_type_option("boolean",s); enddef; +def define_local_picture_option(expr s)= + define_local_type_option("picture",s); +enddef; + def settodefaultifnotknown_(expr opname)(text type)(expr default)= if expandafter unknown sc_("o_" & opname & "_val"): expandafter save sc_("o_" & opname & "_val"); @@ -2349,7 +2438,7 @@ define_global_boolean_option("fit"); % This definition must not be a |vardef| because % the scope of the |save| is the whole constructor. % The name |treemode| was chosen for compatibility with PSTricks. -define_local_string_option("treemode"); +define_global_string_option("treemode"); % PSTricks compatibility: % This corresponds to PSTricks |treenodesize|; @@ -2371,13 +2460,20 @@ define_local_boolean_option("hideleaves"); % draw functions for connections define_local_string_option("cdraw"); +% label for connections +define_local_picture_option("labpic"); +define_local_numeric_option("labdist"); + + + % This is a list of all the stored options of a path. % This list is defined so that it is easy to loop % over all options. def pathoptions_= _draw_,_connect_,posA,posB,armA,armB,offsetA,offsetB, name,linecolor,border,bordercolor,linestyle,doubleline,doublesep, - arrows,angleA,angleB,arcangleA,arcangleB,linewidth,nodesepA,nodesepB, + arrows,angleA,angleB,arcangleA,arcangleB,curvemax, + linewidth,nodesepA,nodesepB, loopsize,linearc,linetensionA,linetensionB, visible,boxsize,boxheight,boxdepth,pathfilled,pathfillcolor, coilarmA,coilarmB,coilheight,coilwidth,coilaspect,coilinc @@ -2386,6 +2482,7 @@ enddef; % default values for curves: numeric curve_linewidth_default, curve_arcangleA_default,curve_arcangleB_default, + curve_curvemax_default, curve_armA_default,curve_armB_default,curve_loopsize_default, curve_linetensionA_default,curve_linetensionB_default, curve_linearc_default, @@ -2395,9 +2492,14 @@ numeric curve_linewidth_default, curve_coilarmA_default,curve_coilarmB_default, curve_coilheight_default,curve_coilwidth_default, curve_coilaspect_default,curve_coilinc_default; +% default values for curves (non stored options) +numeric curve_labpos_default,curve_labangle_default,curve_labdist_default; + + curve_linewidth_default=.5bp; curve_arcangleA_default=10; curve_arcangleB_default=10; +curve_curvemax_default=1; curve_armA_default=5mm; curve_armB_default=5mm; curve_loopsize_default=0.25cm; @@ -2419,6 +2521,10 @@ curve_coilaspect_default=45; % same as in PSTricks curve_coilinc_default=90; % 20 is better when |coilaspect|=0 % (the PSTricks default is 10, but it seems unnecessary in most cases) +curve_labpos_default=0.5; +curve_labangle_default=0.0; +curve_labdist_default=1; % ratio + boolean curve_visible_default,curve_doubleline_default, curve_pathfilled_default; curve_visible_default=true; @@ -2629,6 +2735,9 @@ define_local_color_option("pathfillcolor"); define_local_numeric_option("linetensionA"); define_local_numeric_option("linetensionB"); +% maximum distance for loops produced by nccurve +define_local_numeric_option("curvemax"); % added Nov 10, 2006 + % thickness for connections define_local_numeric_option("linewidth"); @@ -2899,6 +3008,7 @@ enddef; % It must have been defined with |addPathArray|. vardef addPath@#(suffix n)(expr i)(text p)= save p_,untied;path p_;boolean untied;untied=true; + % n is _spath_ or _upath_ if known @#c:untied:=false;fi; % we temporarily tie the object if necessary if untied:@#c=origin;fi; @@ -2920,7 +3030,7 @@ vardef addPath@#(suffix n)(expr i)(text p)= ObjPointArray(n.ip_)(0); fi; fi; - xpart(@#n[i])=@#n.ip_.n_+1; + xpart(@#n[i])=@#n.ip_.n_+1; % path number % we add each point of the path |p_| to the |ip_| array: for j:=0 upto length p_-1: addPointToArray@#(point j of p_)(n.ip_); @@ -3203,20 +3313,44 @@ def nc__(suffix $)(suffix n,m)(expr f)(suffix p)= fi; if unknown o_angleA_val: save o_angleA_val;numeric o_angleA_val; - if numeric n: - o_angleA_val= - angle(m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))); - else: - o_angleA_val=angle(m-n); + if known curve_angleA_default: % added 18 June 2006 + o_angleA_val=curve_angleA_default; + else: + if numeric n: + if m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))<>(0,0): + o_angleA_val= + angle(m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))); + else: + o_angleA_val=0; + fi; + else: + if m-n<>(0,0): + o_angleA_val=angle(m-n); + else: + o_angleA_val=0; + fi; + fi; fi; fi; if unknown o_angleB_val: save o_angleB_val;numeric o_angleB_val; - if numeric n: - o_angleB_val= - angle(m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))); - else: - o_angleB_val=angle(m-n); + if known curve_angleB_default: % added 18 June 2006 + o_angleB_val=curve_angleB_default; + else: + if numeric n: + if m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))<>(0,0): + o_angleB_val= + angle(m.sc_(CLOV_("posB"))-n.sc_(CLOV_("posA"))); + else: + o_angleB_val=0; + fi; + else: + if m-n<>(0,0): + o_angleB_val=angle(m-n); + else: + o_angleB_val=0; + fi; + fi; fi; fi; @@ -3245,6 +3379,25 @@ vardef nc_inc_@#(suffix p)= endfor; enddef; +% This macro draws a label on an immediate curve % ZZZZZZZZ +% (created Sep. 28, 2006) +vardef nc_label_(expr p)= + if known o_labpic_val: + if known o_labangle_val: + o_labangle_val:=o_labangle_val + +angle(direction (o_labpos_val*length(p)) of p); + o_labpic_val:=o_labpic_val rotated o_labangle_val; + fi; + save shift_;pair shift_; + shift_:=(0,0); % default + if known o_labdir_val: + shift_:=clabshift_*CLOV_("labdist"); + fi; + label(o_labpic_val, + (point (CLOV_("labpos")*length(p)) of p) shifted shift_); + fi; +enddef; + % This is the main function that distinguishes if a curve is in % or out of an object (that is, if it will follow the object or not), % and if it links two objects or two points. @@ -3257,9 +3410,19 @@ vardef nc_core_@#(suffix n)(suffix p)(text pa)(text pb)= if str @# <> "": % we are in an object (deferred curve) if numeric n: + % @#p.n_ = path number addPath@#(p,@#p.n_,pa); + if known o_labpic_val: + ObjLabel@#(o_labpic_val) "labpathid(" & decimal(-@#p.n_) & ")"; %AAAAAA + % in the above, labpos is already taken into account if set + fi; + else: addPath@#(p,@#p.n_,pb); + if known o_labpic_val: + ObjLabel@#(o_labpic_val) "labpathid(" & decimal(-@#p.n_) & ")"; %AAAAAA + % in the above, labpos is already taken into account if set + fi; fi; else: % we are not in an object (immediate curve) @@ -3269,10 +3432,14 @@ vardef nc_core_@#(suffix n)(suffix p)(text pa)(text pb)= sc_(LocalOptionValue("cdraw","cdraw_default")) ()(0) % value irrelevant, but first parameter empty (pa); + % if necessary, a label is drawn + nc_label_(pa); % added Sep. 28, 2006 else: sc_(LocalOptionValue("cdraw","cdraw_default")) ()(0) % value irrelevant, but first parameter empty (pb); + % if necessary, a label is drawn + nc_label_(pb); % added Sep. 28, 2006 fi; fi; fi; @@ -3383,14 +3550,29 @@ vardef rnccurve@#(text n)(text m) text options = enddef; vardef nccurve_(suffix $)(suffix n,m)(suffix p)= - nc_core_$(n)(p) - (object_(n)("A"){dir(o_angleA_val)} - ..tension CLOV_("linetensionA") and CLOV_("linetensionB") - ..{dir(o_angleB_val)}object_(m)("B") - cutbefore BpathObj(n) cutafter BpathObj(m)) - (objectpoint_(n)("A"){dir(o_angleA_val)} - ..tension CLOV_("linetensionA") and CLOV_("linetensionB") - ..{dir(o_angleB_val)}objectpoint_(m)("B")); + if n=m: % case added Nov. 10, 2006 + nc_core_$(n)(p) + (object_(n)("A"){dir(o_angleA_val)} + ..{dir(180+o_angleB_val)-dir(o_angleA_val)} + (object_(n)("A")+CLOV_("curvemax")*1cm + *dir(.5[o_angleA_val,180+o_angleB_val])) + ..{dir(o_angleB_val)}object_(m)("B") + cutbefore BpathObj(n) cutafter BpathObj(m)) + (objectpoint_(n)("A"){dir(o_angleA_val)} + ..{dir(180+o_angleB_val)-dir(o_angleA_val)} + (object_(n)("A")+CLOV_("curvemax")*1cm + *dir(.5[o_angleA_val,180+o_angleB_val])) + ..{dir(o_angleB_val)}objectpoint_(m)("B")); + else: + nc_core_$(n)(p) + (object_(n)("A"){dir(o_angleA_val)} + ..tension CLOV_("linetensionA") and CLOV_("linetensionB") + ..{dir(o_angleB_val)}object_(m)("B") + cutbefore BpathObj(n) cutafter BpathObj(m)) + (objectpoint_(n)("A"){dir(o_angleA_val)} + ..tension CLOV_("linetensionA") and CLOV_("linetensionB") + ..{dir(o_angleB_val)}objectpoint_(m)("B")); + fi; enddef; % variant for matrices: @@ -3407,7 +3589,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tccurve@#(text ai)(text bi) text options= - nccurve@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + nccurve@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3444,7 +3626,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcline@#(text ai)(text bi) text options= - ncline@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncline@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3483,7 +3665,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcarc@#(text ai)(text bi) text options= - ncarc@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncarc@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3529,7 +3711,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcangle@#(text ai)(text bi) text options= - ncangle@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncangle@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3576,7 +3758,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcangles@#(text ai)(text bi) text options= - ncangles@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncangles@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3621,7 +3803,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcdiag@#(text ai)(text bi) text options= - ncdiag@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncdiag@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3665,7 +3847,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcdiagg@#(text ai)(text bi) text options= - ncdiagg@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncdiagg@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3718,7 +3900,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcbar@#(text ai)(text bi) text options= - ncbar@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncbar@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -3766,14 +3948,14 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcloop@#(text ai)(text bi) text options= - ncloop@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncloop@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |firstpart| returns the time elapsed between the beginning of |p| % and the point where the distance to the origin (on |p|) is |d| def firstpart_(expr d,p)= - arctime(d/arclength(p),p) + arctime_(d/arclength(p),p) enddef; % Cut a path |p| in pieces of approximate arclength |d| @@ -3898,10 +4080,10 @@ def frac(expr i)= enddef; % function giving the time with respect to arclength: -% arctime 0 of p=beginning -% arctime 1 of p=end +% arctime_ 0 of p=beginning +% arctime_ 1 of p=end % -vardef arctime(expr i,p)= +vardef arctime_(expr i,p)= save t; hide( if i=0: t=0; @@ -3925,11 +4107,11 @@ vardef arctime(expr i,p)= enddef; def arcpoint(expr i,p)= - (point arctime(i,p) of p) + (point arctime_(i,p) of p) enddef; def arcdirection(expr i,p)= - (direction arctime(i,p) of p) + (direction arctime_(i,p) of p) enddef; @@ -3972,7 +4154,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tccoil@#(text ai)(text bi) text options= - nccoil@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + nccoil@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; @@ -4015,7 +4197,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tczigzag@#(text ai)(text bi) text options= - nczigzag@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + nczigzag@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; @@ -4087,7 +4269,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcbox@#(text ai)(text bi) text options= - ncbox@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncbox@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -4158,7 +4340,7 @@ enddef; % This cannot be used to connect nodes that are not in the same tree. % It is simpler to name the nodes in order to achieve trans-connections. vardef tcarcbox@#(text ai)(text bi) text options= - ncarcbox@#(ntreepos(@#)(ai))(ntreepos(@#)(bi)) options; + ncarcbox@#(treeroot(@#)(ai))(treeroot(@#)(bi)) options; enddef; % |@#| is the object to which a line is added @@ -4278,6 +4460,19 @@ def labshift_(suffix $)= ) enddef; +% variant for curve labels: +def clabshift_= + (2 % 2 instead of 1 in the original code + *labeloffset*laboff.sc_(o_labdir_val) + - + (labxf.sc_(o_labdir_val)*(lrcorner o_labpic_val) + + labyf.sc_(o_labdir_val)*(ulcorner o_labpic_val) + + (1-labxf.sc_(o_labdir_val)-labyf.sc_(o_labdir_val)) + *(llcorner o_labpic_val) + ) + ) +enddef; + % not used def opposite_(expr c)= if c="n": "s" @@ -4325,13 +4520,15 @@ vardef ObjLabel@#(expr p) text options = tmpoff=@#sc_(o_labcard_val); fi; else: - tmpoff=objpathlabel_(@#); + settodefaultifnotknown_("labshift")(pair)((0,0)); % added June 1, 2004 + tmpoff=objpathlabel_(@#)+@#c+o_labshift_val; % o_labshift_val added June 1, 2004 + % and @#c on May 1, 2006 if known o_labangle_val: @#ipic_[@#ipic_.n_]:=@#ipic_[@#ipic_.n_] rotated o_labangle_val; fi; fi; if known o_labdir_val: - @#ipic_.off_[@#ipic_.off_.n_]=tmpoff+labshift_(@#); + @#ipic_.off_[@#ipic_.off_.n_]=tmpoff+labshift_(@#)*CLOV_("labdist"); else: @#ipic_.off_[@#ipic_.off_.n_]=tmpoff; fi; @@ -4372,9 +4569,16 @@ vardef objpathlabel_(suffix $)= endfor; fi; save untied;boolean untied;untied=true; - if known $c:untied:=false;fi; - % we temporarily tie the object if necessary - if untied:$c=origin;fi; + if known $c:untied:=false; + save obj_pos;pair obj_pos; + obj_pos=$c; + untieObj($); + fi; + % we temporarily retie the object to the origin if necessary + % (before Oct. 3, 2006, this was only done when the object + % was not tied, but it produced wrong results when + % the center of the object was not the origin) + $c=origin; if pathn>0: tmpoff=point (o_labpos_val*length(Path$(_spath_,pathn))) of Path$(_spath_,pathn); @@ -4393,7 +4597,11 @@ vardef objpathlabel_(suffix $)= fi; fi; % if the object was initially untied, we untie it - if untied:untieObj($);fi; + if untied:untieObj($); + else: % retie it correctly: + untieObj($); + $c=obj_pos; + fi; ) tmpoff enddef; @@ -4819,6 +5027,9 @@ def TreeRootPath_(suffix sb)= enddef; vardef drawTree(suffix n)= + save fanchildren; + boolean fanchildren; + fanchildren=false; drawFramedOrFilledObject_(n); % pickup pencircle scaled 2pt; % draw n.nw--n.ne--n.se--n.sw--cycle withcolor red; @@ -4830,7 +5041,8 @@ vardef drawTree(suffix n)= % only connections to non empty boxes: if not isEmptyBox(obj(obj(n.subt).sb[i])): if isHFan(Obj(TreeRootObj_(obj(obj(n.subt).sb[i])))) or - isVFan(Obj(TreeRootObj_(obj(obj(n.subt).sb[i])))): + isVFan(Obj(TreeRootObj_(obj(obj(n.subt).sb[i])))): + fanchildren:=true; drawfan_(n,Obj(TreeRootObj_(obj(obj(n.subt).sb[i]))))(i,false); else: % drawn by |drawMemorizedPaths_| @@ -4838,7 +5050,9 @@ vardef drawTree(suffix n)= fi; endfor; % |unfill| is necessary to cut points of fans - unfill BpathObj(obj(n.root)); + if fanchildren: + unfill BpathObj(obj(n.root)); + fi; drawObj(obj(n.root)); enddef; @@ -5937,7 +6151,7 @@ vardef newMatrix@#(expr Nx,Ny)(text elements) text options = endfor; else: for i:=1 upto Nx: - @#ht[i]=1; + @#ht[i]=1+(i-1)*Ny; % bug corrected on October 5, 2005 endfor; fi; @@ -5963,7 +6177,7 @@ vardef newMatrix@#(expr Nx,Ny)(text elements) text options = endfor; else: for i:=1 upto Ny: - @#wd[i]=1; + @#wd[i]=i; % bug corrected on October 5, 2005 endfor; fi; % The basic equations are: @@ -6001,14 +6215,21 @@ vardef newMatrix@#(expr Nx,Ny)(text elements) text options = "hide(l=length(s);)" & "substring if i>l: (l-1,l) else: (i-1,i) fi of s " & "enddef; " & + if OptionValue@#("matrixnodehsize")>=0: + "xpart(obj(@#sb[@#wd[1]]).c-@#w)=" & + decimal (OptionValue@#("matrixnodehsize")/2+OptionValue@#("dx")) &";" & + "xpart(@#e-obj(@#sb[@#wd[@#ny]]).c)=" & + decimal (OptionValue@#("matrixnodehsize")/2+OptionValue@#("dx")) &";" & + else: "xpart(obj(@#sb[@#wd[1]]).w-@#w)=" & decimal (OptionValue@#("dx")) &";" & "xpart(@#e-obj(@#sb[@#wd[@#ny]]).e)=" & decimal (OptionValue@#("dx")) &";" & + fi "for i:=1 upto @#ny-1:"; if OptionValue@#("matrixnodehsize")>=0: eq:=eq & "xpart(obj(@#sb[@#wd[i+1]]).c-obj(@#sb[@#wd[i]]).c)=" & - decimal (OptionValue@#("matrixnodehsize")) &";"; + decimal (OptionValue@#("matrixnodehsize")) &";"; else: eq:=eq & "xpart(obj(@#sb[@#wd[i+1]]).w-obj(@#sb[@#wd[i]]).e)=" & @@ -6026,13 +6247,20 @@ vardef newMatrix@#(expr Nx,Ny)(text elements) text options = "fi;" & "endfor;" & "endfor;" & + if OptionValue@#("matrixnodevsize")>=0: + "ypart(@#n-obj(@#sb[@#ht[1]]).c)=" & + decimal (OptionValue@#("matrixnodevsize")/2+OptionValue@#("dy")) &";" & + "ypart(obj(@#sb[@#ht[@#nx]]).c-@#s)=" & + decimal (OptionValue@#("matrixnodevsize")/2+OptionValue@#("dy")) &";" & + else: "ypart(@#n-obj(@#sb[@#ht[1]]).n)=" & decimal (OptionValue@#("dy")) &";" & "ypart(obj(@#sb[@#ht[@#nx]]).s-@#s)=" & decimal (OptionValue@#("dy")) &";" & + fi "for i:=1 upto @#nx-1:"; if OptionValue@#("matrixnodevsize")>=0: eq:=eq & - "ypart(obj(@#sb[@#ht[i]]).s-obj(@#sb[@#ht[i+1]]).n)=" & + "ypart(obj(@#sb[@#ht[i]]).c-obj(@#sb[@#ht[i+1]]).c)=" & decimal (OptionValue@#("matrixnodevsize")) &";"; else: eq:=eq & @@ -7089,8 +7317,11 @@ vardef newCircle@#(expr v) text options= StandardObjectOrPictureContainerSetup(v); ObjNumeric cdx,cdy; % computed dx and dy if (numeric v) or (picture v) or (string v): % object or picture + % correction of bug discovered by Stephan Hennig + % (comp.text.tex, 2004-03-18) @#cdx=(@#a++@#b)+OptionValue@#("circmargin")-@#a; - @#cdy=(@#a++@#b)+OptionValue@#("circmargin")-@#b; + %@#cdy=(@#a++@#b)+OptionValue@#("circmargin")-@#b; % DR 23/3/2004 + @#cdy=@#cdx+@#a-@#b; % DR 23/3/2004 %@#cdx=@#cdy=pathsel__(@#a,@#b)(max(@#a,@#b),OptionValue@#("circmargin"), % (@#a+d_,0){up}...(0,@#b+d_){left}); else: @@ -7102,10 +7333,14 @@ vardef newCircle@#(expr v) text options= elseif (picture v) or (string v): ".5[@#isw,@#ine]=@#p.off", % picture offset fi - "@#ise-@#isw=(" & decimal(2*max(@#a,@#b)+2*@#cdx) + % correction of bug discovered by Stephan Hennig + % (comp.text.tex, 2004-03-18) + % "@#ise-@#isw=(" & decimal(2*max(@#a,@#b)+2*@#cdx) % DR 23/3/2004 + "@#ise-@#isw=(" & decimal(2*(@#a+@#cdx)) % DR 23/3/2004 %decimal(@#a++@#b+OptionValue@#("circmargin")) & ",0)", - "@#ine-@#ise=(0," & decimal(2*max(@#a,@#b)+2*@#cdy) + %"@#ine-@#ise=(0," & decimal(2*max(@#a,@#b)+2*@#cdy) % DR 23/3/2004 + "@#ine-@#ise=(0," & decimal(2*(@#b+@#cdy)) % DR 23/3/2004 %decimal(@#a++@#b+OptionValue@#("circmargin")) & ")"; StandardTies; @@ -7307,6 +7542,103 @@ setObjectDefaultOption("DEllipse")("shadowcolor")(black); % It would of course be easy to create triple boxes, triple circles, etc. %===================================================================== +% The Container class was suggested by Michael Schwarz +% (<mi-schwarz@gmx.de>) +% (Emails from May 20, 2006) +% THIS CODE HAS NOT YET BEEN CHECKED (added October 8, 2006) +% CODE IMPROVED ON December 3, 2006. + +setObjectDefaultOption("Container")("filled")(false); +setObjectDefaultOption("Container")("fillcolor")(black); +setObjectDefaultOption("Container")("framed")(false); +setObjectDefaultOption("Container")("framewidth")(.5bp); +setObjectDefaultOption("Container")("framecolor")(black); +setObjectDefaultOption("Container")("framestyle")(""); +setObjectDefaultOption("Container")("shadow")(false); +setObjectDefaultOption("Container")("shadowcolor")(black); +setObjectDefaultOption("Container")("dx")(0); +setObjectDefaultOption("Container")("dy")(0); + +vardef newContainer@#(text sublist) text options = + save i,topC, botC, lftC, rtC, topS, botS, lftS, rtS, floating, + n, firstsub, $; + boolean floating; + string firstsub; + ExecuteOptions(@#)(options); + assignObj(@#,"Container"); + StandardInterface; + + n:=0; + forsuffixes $=sublist: + if incr(n)=1 : firstsub:= str $; fi; + endfor; + ObjSubArray(sub_)(n); % |n| is the number of elements + i=0; + forsuffixes $:=sublist:i:=i+1; + SubObjectOfArray(sub_[i],$); + endfor; + + if known(obj(firstsub).c): + floating := false; + else: + floating := true; + obj(firstsub).scantokens(firstPointOf_(firstsub)) = origin; + fi; + + forsuffixes $=sublist: + topS := findrec_top_most.$; + botS := findrec_bot_most.$; + lftS := findrec_lft_most.$; + rtS := findrec_rt_most.$; + if known topC: + if topS > topC : topC := topS; fi; + else: + topC := topS; + fi; + + if known botC: + if botS < botC : botC := botS; fi; + else: + botC := botS; + fi; + + if known lftC: + if lftS < lftC : lftC := lftS; fi; + else: + lftC := lftS; + fi; + + if known rtC: + if rtS > rtC : rtC := rtS; fi; + else: + rtC := rtS; + fi; + endfor; + + ObjCode StandardEquations, + "@#nw = (" & decimal (lftC-OptionValue@#("dx")) & "," & + decimal (topC+OptionValue@#("dy")) & ")", + "@#se = (" & decimal (rtC+OptionValue@#("dx")) & "," & + decimal (botC-OptionValue@#("dy")) & ")"; + StandardTies; + if floating: untieObj(@#); fi; +enddef; + +streamline("Container")("(text t)")("suffixlist(t)"); + +def BpathContainer(suffix n)= StandardBpath(n) enddef; + +vardef drawContainer(suffix n) = + save i; + drawFramedOrFilledObject_(n); + for i=1 upto n.sub_.n_: + drawObj(obj(n.sub_[i])); + endfor; + drawMemorizedPaths_(n); +enddef; + + +%===================================================================== % Definitions specific to the |BB| class (Bounding Box) % Sometimes, we want to make a new object hiding the positions % of an object. For instance, if we rotate an object upside down, |