#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: cbg_m2fig
#
# Causal bond graph: mfile format to fig file format
# The resultant fig file is the original _abg.fig with
# additional causal strokes superimposed.
#
# P.J.Gawthrop May 1996
# Copyright (c) P.J.Gawthrop, 1996.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12 2001/03/23 14:55:03 gawthrop
## Fixed cosmetic bugs -- component display
##
## Revision 1.11 2000/12/28 12:19:49 peterg
## *** empty log message ***
##
## Revision 1.10 2000/09/14 12:04:48 peterg
## New 2 parameter version
##
## Revision 1.9 1998/01/23 13:31:23 peterg
## $RMATRIX --> $MATRIX
##
## Revision 1.8 1996/12/07 19:23:07 peterg
## Registered agian.
##
# Revision 1.7 1996/11/09 19:04:34 peterg
# Removed cp $1_$1_cbg.fig $1_cbg.fig.
#
## Revision 1.6 1996/11/06 15:58:46 peterg
## Changed Matrix to RMATRIX
##
# Revision 1.5 1996/11/02 10:16:50 peterg
# Changed stroke length to 150
#
# Revision 1.4 1996/08/25 09:28:59 peter
# More error handling.
#
## Revision 1.3 1996/08/24 14:40:31 peter
## Error handling included.
##
## Revision 1.2 1996/08/08 18:07:31 peter
## Sorted out naming scheme for files
##
## Revision 1.1 1996/08/05 20:13:56 peter
## Initial revision
##
###############################################################
# Remove the old log file
rm -f cbg_m2fig.log
rm -f mtt_info.txt
# The following sets up the fig header file for the system
# and each sub system.
# (ls $1_*_cbg.m \
# | sed 's/\(.*_\)\(.*_\)cbg.m/cp \2fig.fig \1\2cbg.fig/' \
#| sh ) 2>mtt_error.txt
#sh $1_type.sh 'cp ' '_fig.fig ' '_cbg.fig'> mtt_error.txt
# Copy the unchaging part of the figure file
cat $1_head.fig $1_port.fig $1_bnd.fig $1_art.fig> $2_cbg.fig
#Inform user
echo Creating $2_cbg.fig -- component type $1
# Use matrix manipulation to accomplish the transformation
$MATRIX <<EOF 2>mtt_error.txt > cbg_m2fig.log
system_type = "$1"
system_name = "$2"
thick = 3; length = 150; red = 4; blue = 1; green = 12; font = 18;
cbg2fig(system_name, system_type, '', ...
length, thick, blue, ...
font, green, red);
EOF
#cp $1_$1_cbg.fig $1_cbg.fig 2>> mtt_error.txt
# Print errors, if any.
mtt_error mtt_error.txt