Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Fix #9 Optimal parameter for newthead distance #33

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
language: generic
os: linux

install:
- cd ci/
- source texlive.sh
- cd ..

cache:
directories:
- /tmp/texlive
- $HOME/.texlive
- /tmp/tlpkg

addons:
apt:
packages:
- ghostscript
- realpath

before_script:
- git fetch --unshallow --tags || true

script: |
set -e
cd doc/latex/pgf-umlsd
while : ; do
$engine -shell-escape -halt-on-error -interaction=nonstopmode pgf-umlsd-manual.tex
grep -q -E "(There were undefined references|Rerun to get (cross-references|the bars) right)" *.log || break
[ "$(( thisrun=$(( thisrun + 1 )) ))" -lt 5 ] || { echo "Reruns exceeded"; exit 1; }
done
if [ "$engine" = "latex" ]; then
dvips pgf-umlsd-manual.dvi
ps2pdf pgf-umlsd-manual.ps
fi
cd -

after_success: |
git ls-files | sed '/^\./d;/^ci/d' | tee FILES
echo doc/latex/pgf-umlsd/pgf-umlsd-manual.pdf | tee -a FILES
tar --xform='s$\(doc\|tex\)/latex/pgf-umlsd/$$g' \
--xform='s$^$pgf-umlsd/$g' \
-cvf pgf-umlsd.tar.gz $(cat FILES)

jobs:
include:
- env: engine=lualatex

- env: engine=pdflatex

- env: engine=xelatex

- env: engine=latex

deploy:
provider: releases
token: $GH_TOKEN
file_glob: true
file:
- "*.zip"
- "doc/latex/pgf-umlsd/pgf-umlsd-manual.pdf"
skip_cleanup: true
overwrite: true
on:
tags: true
condition: $engine = lualatex
4 changes: 2 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ alternatively under the terms of the General Public License (GPL) Version 2.

The terms of each license can be found in the source repository:

Apache License: ./LICENSE-LPPL1.3c.txt
GPL2 License: ./LICENSE-GPL2.txt
LaTeX Project Public License: doc/latex/pgf-umlsd/LICENSE-LPPL1.3c.txt
General Public License 2: doc/latex/pgf-umlsd/LICENSE-GPL2.txt
3 changes: 0 additions & 3 deletions README

This file was deleted.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# pgf-umlsd

[![Travis Build Status][travis-svg]][travis-link]

Some LaTeX macros for UML Sequence Diagrams.

Please go to the official repository at https://github.com/pgf-tikz/pgf-umlsd
or the official mailing list at https://tug.org/mailman/listinfo/pgf-tikz to
submit bug reports, request new features, etc.

Please read pgf-umlsd-manual.pdf for more information.

## License

pgf-umlsd is released under the terms of both the LPPL v1.3c and the GPL v2.

[travis-svg]: https://travis-ci.com/pgf-tikz/pgf-umlsd.svg?branch=master
[travis-link]: https://travis-ci.com/pgf-tikz/pgf-umlsd
10 changes: 10 additions & 0 deletions ci/texlive.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
selected_scheme scheme-infraonly
TEXDIR /tmp/texlive
TEXMFCONFIG ~/.texlive/texmf-config
TEXMFHOME ~/texmf
TEXMFLOCAL /tmp/texlive/texmf-local
TEXMFSYSCONFIG /tmp/texlive/texmf-config
TEXMFSYSVAR /tmp/texlive/texmf-var
TEXMFVAR ~/.texlive/texmf-var
option_doc 0
option_src 0
81 changes: 81 additions & 0 deletions ci/texlive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env sh

export PATH=/tmp/texlive/bin/x86_64-linux:$PATH

# Check for cached version
if ! command -v texlua > /dev/null; then
# Obtain TeX Live
curl -LO http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzf install-tl-unx.tar.gz
cd install-tl-20*

# Install a minimal system
./install-tl --profile=../texlive.profile

cd ..
fi

# Update infra first
tlmgr update --self

# Binaries and fonts
tlmgr install \
dvips \
ec \
latex \
latex-bin \
luaotfload \
luatex \
luatexbase \
metafont \
mfware \
xetex

# Install all the required packages
tlmgr install \
atbegshi \
atveryend \
auxhook \
bigintcalc \
bitset \
epstopdf-pkg \
etexcmds \
geometry \
gettitlestring \
graphics \
graphics-cfg \
graphics-def \
hycolor \
hyperref \
iftex \
infwarerr \
intcalc \
kvdefinekeys \
kvoptions \
kvsetkeys \
l3backend \
latex \
latexconfig \
letltxmacro \
listings \
ltxcmds \
mptopdf \
ms \
pdfescape \
pdftexcmds \
pgf \
refcount \
rerunfilecheck \
uniquecounter \
url \
xcolor

# Keep no backups (not required, simply makes cache bigger)
tlmgr option -- autobackup 0

# Update the TL install but add nothing new
tlmgr update --self --all --no-auto-install

# Install PGF
tlmgr init-usertree --usertree `realpath ..`
export TEXMFHOME=`realpath ..`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion demo/distance.tex → doc/latex/pgf-umlsd/demo/distance.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
\newthread{a}{:A}
\newinst{b}{:B}
\newinst[1]{c}{:C}
\newinst[2]{d}{:D}
\newinst[1.5]{d}{:D}
\newthread{e}{:E}[1]
\end{sequencediagram}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
88 changes: 51 additions & 37 deletions pgf-umlsd.sty → tex/latex/pgf-umlsd/pgf-umlsd.sty
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
\ProvidesPackage{pgf-umlsd}[2011/07/27 v0.6 Some LaTeX macros for UML
Sequence Diagrams.]

\RequirePackage{xparse}
\RequirePackage{tikz}
\usetikzlibrary{arrows,shadows}

Expand Down Expand Up @@ -68,13 +69,27 @@ Sequence Diagrams.]
\newcounter{threadnum}
\newcounter{seqlevel} % level
\newcounter{callevel}
\newcounter{callselflevel}
\newcounter{blocklevel}

% From https://tex.stackexchange.com/questions/155776/check-if-counter-exists
% Tests if a counter has already been defined.
% Usage:
% \pgf@umlsd@ifcounter{counter name}{action if exists}{action else}
\newcommand*\pgf@umlsd@ifcounter[1]{%
\ifcsname c@#1\endcsname
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}

% new an instance
% Example:
% \newinst[edge distance]{var}{name:class}
\newcommand{\newinst}[3][0.2]{
\pgf@umlsd@ifcounter{callselflevel#2}
{\setcounter{callselflevel#2}{0}}
{\newcounter{callselflevel#2}}
\stepcounter{instnum}
\path (inst\thepreinst.east)+(#1,0) node[inststyle] (inst\theinstnum)
{\ifpgfumlsdunderline
Expand All @@ -96,9 +111,9 @@ Sequence Diagrams.]

% new an instance thread
% Example:
% \newinst[color]{var}{name}{class}
\newcommand{\newthread}[3][gray!30]{
\newinst{#2}{#3}
% \newthread[color]{var}{name:class}[edge distance]
\NewDocumentCommand{\newthread}{O{gray!30}mmO{0.2}}{
\newinst[#4]{#2}{#3}
\stepcounter{threadnum}
\node[below of=inst\theinstnum,node distance=0.8cm] (thread\thethreadnum) {};
\tikzstyle{threadcolor\thethreadnum}=[fill=#1]
Expand Down Expand Up @@ -126,7 +141,7 @@ Sequence Diagrams.]
}
}
{
\ifthenelse{\equal{\f\thecallevel}{\t\thecallevel}}
\ifthenelse{\equal{\pgf@umlsd@f@thecallevel}{\pgf@umlsd@t@thecallevel}}
{
\end{callself}
}
Expand All @@ -146,17 +161,17 @@ Sequence Diagrams.]

\draw[->,>=triangle 60] ({cf\thecallevel}) -- (ct\thecallevel)
node[midway, above] {#3};
\def\l\thecallevel{#1}
\def\f\thecallevel{#2}
\def\t\thecallevel{#4}
\def\pgf@umlsd@l@thecallevel{#1}
\def\pgf@umlsd@f@thecallevel{#2}
\def\pgf@umlsd@t@thecallevel{#4}
\def\returnvalue{#5}
\tikzstyle{threadstyle}+=[instcolor#2]
}
{
\addtocounter{seqlevel}{\l\thecallevel}
\addtocounter{seqlevel}{\pgf@umlsd@l@thecallevel}
\path
(\f\thecallevel)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rf\thecallevel) {}
(\t\thecallevel.\threadbias)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rt\thecallevel) {};
(\pgf@umlsd@f@thecallevel)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rf\thecallevel) {}
(\pgf@umlsd@t@thecallevel.\threadbias)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rt\thecallevel) {};
\draw[dashed,->,>=angle 60] ({rt\thecallevel}) -- (rf\thecallevel)
node[midway, above]{\returnvalue};
\drawthread{ct\thecallevel}{rt\thecallevel}
Expand All @@ -171,30 +186,30 @@ Sequence Diagrams.]
\newenvironment*{callself}[4][1]{
\stepcounter{seqlevel}
\stepcounter{callevel} % push
\stepcounter{callselflevel}
\def\pgf@umlsd@l@thecallevel{#1}
\def\pgf@umlsd@f@thecallevel{#2}
\def\pgf@umlsd@t@thecallevel{#2}
\stepcounter{callselflevel\pgf@umlsd@f@thecallevel}

\path
(#2)+(\thecallselflevel*0.1-0.1,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (sc\thecallevel) {}
(#2)+(\arabic{callselflevel\pgf@umlsd@f@thecallevel}*0.1-0.1,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (sc\thecallevel) {}
({sc\thecallevel}.east)+(0,-0.33*\unitfactor) node (scb\thecallevel) {};

\draw[->,>=triangle 60] ({sc\thecallevel}.east) -- ++(0.8,0)
node[near start, above right] {#3} -- ++(0,-0.33*\unitfactor)
-- (scb\thecallevel);
\def\l\thecallevel{#1}
\def\f\thecallevel{#2}
\def\t\thecallevel{#2}
\def\returnvalue{#4}
\tikzstyle{threadstyle}+=[instcolor#2]
}{
\addtocounter{seqlevel}{\l\thecallevel}
\path (\f\thecallevel)+(\thecallselflevel*0.1-0.1,-\theseqlevel*\unitfactor-0.33*\unitfactor) node
\addtocounter{seqlevel}{\pgf@umlsd@l@thecallevel}
\path (\pgf@umlsd@f@thecallevel)+(\arabic{callselflevel\pgf@umlsd@f@thecallevel}*0.1-0.1,-\theseqlevel*\unitfactor-0.33*\unitfactor) node
(sct\thecallevel) {};

\draw[dashed,->,>=angle 60] ({sct\thecallevel}.east) node
(sce\thecallevel) {} -- ++(0.8,0) -- node[midway, right]{\returnvalue} ++(0,-0.33*\unitfactor) -- ++(-0.8,0);
\drawthread{scb\thecallevel}{sce\thecallevel}
\addtocounter{callevel}{-1} % pop
\addtocounter{callselflevel}{-1}
\addtocounter{callselflevel\pgf@umlsd@f@thecallevel}{-1}
}

% message between threads
Expand Down Expand Up @@ -224,20 +239,20 @@ Sequence Diagrams.]
\newcommand*{\messself}[3][1]{
\stepcounter{seqlevel}
\stepcounter{callevel} % push
\stepcounter{callselflevel}
\def\l\thecallevel{#1}
\def\f\thecallevel{#2}
\def\pgf@umlsd@l@thecallevel{#1}
\def\pgf@umlsd@f@thecallevel{#2}
\stepcounter{callselflevel\pgf@umlsd@f@thecallevel}
\path
(\f\thecallevel)+(\thecallselflevel*0.1-0.1,-\theseqlevel*\unitfactor-0.33*\unitfactor)
(\pgf@umlsd@f@thecallevel)+(\arabic{callselflevel\pgf@umlsd@f@thecallevel}*0.1-0.1,-\theseqlevel*\unitfactor-0.33*\unitfactor)
node
(sct\thecallevel) {};
\addtocounter{seqlevel}{\l\thecallevel}
\addtocounter{seqlevel}{\pgf@umlsd@l@thecallevel}
\draw[->,>=angle 60] ({sct\thecallevel}.east) node
(sce\thecallevel) {} -- ++(0.8,0) -- node[midway, right]{#3}
++(0,-\l\thecallevel*\unitfactor) -- ++(-0.8,0);
++(0,-\pgf@umlsd@l@thecallevel*\unitfactor) -- ++(-0.8,0);

\addtocounter{callevel}{-1} % pop
\addtocounter{callselflevel}{-1}
\addtocounter{callselflevel\pgf@umlsd@f@thecallevel}{-1}
}

% message between threads
Expand Down Expand Up @@ -265,16 +280,16 @@ node

\draw[->,>=angle 60] ({cf\thecallevel}) -- (ct\thecallevel)
node[midway, above] {#3};
\def\l\thecallevel{#1}
\def\f\thecallevel{#2}
\def\t\thecallevel{#4}
\def\pgf@umlsd@l@thecallevel{#1}
\def\pgf@umlsd@f@thecallevel{#2}
\def\pgf@umlsd@t@thecallevel{#4}
\tikzstyle{threadstyle}+=[instcolor#2]
}
{
\addtocounter{seqlevel}{\l\thecallevel}
\addtocounter{seqlevel}{\pgf@umlsd@l@thecallevel}
\path
(\f\thecallevel)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rf\thecallevel) {}
(\t\thecallevel.\threadbias)+(0,-\theseqlevel*\unitfactor-0.3*\unitfactor) node (rt\thecallevel) {};
(\pgf@umlsd@f@thecallevel)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (rf\thecallevel) {}
(\pgf@umlsd@t@thecallevel.\threadbias)+(0,-\theseqlevel*\unitfactor-0.3*\unitfactor) node (rt\thecallevel) {};
\drawthread{ct\thecallevel}{rt\thecallevel}
\addtocounter{callevel}{-1} % pop
}
Expand Down Expand Up @@ -331,10 +346,10 @@ node
% the environment of sequence diagram
\newenvironment{sequencediagram}{
% declare layers
\pgfdeclarelayer{umlsd@background}
\pgfdeclarelayer{umlsd@threadlayer}
\pgfsetlayers{umlsd@background,umlsd@threadlayer,main}

\pgfdeclarelayer{umlsd@background}%
\pgfdeclarelayer{umlsd@threadlayer}%
\pgfsetlayers{umlsd@background,umlsd@threadlayer,main}%
%
\begin{tikzpicture}
\setlength{\unitlength}{1cm}
\tikzstyle{sequence}=[coordinate]
Expand All @@ -357,7 +372,6 @@ node
\setcounter{threadnum}{0}
\setcounter{seqlevel}{0}
\setcounter{callevel}{0}
\setcounter{callselflevel}{0}
\setcounter{blocklevel}{0}

% origin
Expand Down