diff options
Diffstat (limited to 'Master/texmf-dist/metapost/metauml/metauml_paths.mp')
-rw-r--r-- | Master/texmf-dist/metapost/metauml/metauml_paths.mp | 109 |
1 files changed, 105 insertions, 4 deletions
diff --git a/Master/texmf-dist/metapost/metauml/metauml_paths.mp b/Master/texmf-dist/metapost/metauml/metauml_paths.mp index cb307f8df00..d0fc27bb332 100644 --- a/Master/texmf-dist/metapost/metauml/metauml_paths.mp +++ b/Master/texmf-dist/metapost/metauml/metauml_paths.mp @@ -24,12 +24,113 @@ def pathDirect(expr pA,pB) = pA--pB enddef; -vardef pathManhattanX(expr pA,pB) = - pA--(xpart(pB), ypart(pA))--pB +vardef pathManhattanX(text twoParams) = + pair pointA__, pointB__; + string paramA_str__, paramB_str__; + boolean paramA_isObject__, paramB_isObject__; + + paramA_isObject__ := true; + paramB_isObject__ := true; + + boolean isFirstParam__; + isFirstParam__ := true; + + %string twoParams; + %twoParams := ""; + + %twoParams := str paramA & ", " & str paramB; + %%includeonce% show "the two params are: " & twoParams; + + forsuffixes param__ = twoParams: + + if isFirstParam__: + isFirstParam__ := false; + paramA_str__ := str param__; + %includeonce% show "paramA_str__ <-- " & paramA_str__; + + if not known (scantokens (paramA_str__ & ".className")): + %includeonce% show "paramA is not an object"; + paramA_isObject__ := false; + fi; + else: + paramB_str__ := str param__; + %includeonce% show "paramB_str__ <-- " & paramB_str__; + + if not known (scantokens (paramB_str__ & ".className")): + %includeonce% show "paramB is not an object"; + paramB_isObject__ := false; + fi; + fi; + endfor; + + %includeonce% show paramA_str__; + %includeonce% show paramA_isObject__; + + %includeonce% show paramB_str__; + %includeonce% show paramB_isObject__; + + string stringPath__; + stringPath__ := "(0,0)--(50,50)"; + + if (not paramA_isObject__) and (not paramB_isObject__): + %includeonce% show "Both are points!"; + + + stringPath__ := paramA_str__ & "--(xpart " & paramB_str__ & ", ypart " & paramA_str__ & ") -- " & paramB_str__; + %includeonce% show stringPath__; + else: + pair refPointA__, refPointB__; + if paramA_isObject__: + refPointA__ := scantokens (paramA_str__ & ".c"); + else: + refPointA__ := scantokens paramA_str__; + fi; + if paramB_isObject__: + refPointB__ := scantokens (paramB_str__ & ".c"); + else: + refPointB__ := scantokens paramB_str__; + fi; + + %includeonce% show "Reference point A: "; + %includeonce% show refPointA__; + %includeonce% show "Reference point B: "; + %includeonce% show refPointB__; + + numeric dx__, dy__; + dx__ := xpart refPointB__ - xpart refPointA__; + dy__ := ypart refPointB__ - ypart refPointA__; + + string addornmentA__; + addornmentA__ := ""; + string addornmentB__; + addornmentB__ := ""; + + if (paramA_isObject__): + if (dx__ > 0): + addornmentA__ := ".e"; + else: + addornmentA__ := ".w"; + fi; + fi; + + if (paramB_isObject__): + if (dy__ > 0): + addornmentB__ := ".s"; + else: + addornmentB__ := ".n"; + fi; + fi; + stringPath__ := "pathManhattanX(" & paramA_str__ & addornmentA__ & ", " & paramB_str__ & addornmentB__ & ")"; + + %includeonce% show stringPath; + %includeonce% show "-------------------> recursive call"; + fi; + + scantokens stringPath__ enddef; -vardef rpathManhattanX(expr pA,pB) = - pB--(xpart(pB), ypart(pA))--pA +vardef rpathManhattanX(text twoParams) = + reverse pathManhattanX(twoParams) enddef; vardef pathManhattanY(expr pA,pB) = |