dot 901 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#! /bin/bash

# This hack is a wrapper to GraphViz dot that removes any nodes that
# are contained in the following list.

LABELS_TO_FILTER="QObject Item"

ARGS=$@

for ARG in ${ARGS}
do
  if [ -e ${ARG} ]
  then
    FILENAME=$(basename "${ARG}")
    EXT="${FILENAME##*.}"

    if [ ${EXT} == "dot" ]
    then
      DOT_FILE=${ARG}

      for LABEL_TO_FILTER in ${LABELS_TO_FILTER}
      do
        NODE_NAME=$(grep "label=\"${LABEL_TO_FILTER}\"" ${DOT_FILE} | awk '{print $1}')

        if [[ ! -z "${NODE_NAME}" ]]
        then
          echo "${NODE_NAME} is labelled ${LABEL_TO_FILTER}, filtering..."
          sed -i -e "/${NODE_NAME}/d" ${DOT_FILE}
        fi
      done

      break
    fi
  fi
done

37 38 39 40 41 42 43 44 45 46
if [[ -x "/usr/local/bin/dot" ]]  
then
  /usr/local/bin/dot ${ARGS}
elif [[ -x "/usr/bin/dot" ]]
then 
  /usr/bin/dot ${ARGS}
else
  echo "Program dot not found: See file doc/dot"
  exit 1
fi