Overview
Comment:Prepared for recursive version.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: b130008abdd8d7a8e47feade878d9a4107192ae435ab0319d0067f096c0da96e
User & Date: gawthrop@users.sourceforge.net on 1996-08-05 20:15:39
Other Links: branch diff | manifest | tags
Context
1996-08-08
08:30:06
The cbg filename contains the system name - this makes things easier
when setting up the m to fig translation and m to ese translation
check-in: a124243583 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1996-08-05
20:15:39
Prepared for recursive version. check-in: b130008abd user: gawthrop@users.sourceforge.net tags: origin/master, trunk
20:13:56
Initial revision check-in: fae876e2c4 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/m/cbg2fig.m from [b284843cfc] to [ee1de59493].

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
37
38

39
40
41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

73
74
75
76
77
78
79

80




81
























82
83
84
85
86
87
88
-
-
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+

















+
+
+



+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+






-
+
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







function cbg2fig(bonds, cbonds, rbonds, ...
                 rcomponents, status, systemname, ...
function cbg2fig(system_name, ...
                 system_type, full_name, ...
                 stroke_length, stroke_thickness, stroke_colour, ...
                 comp_font, comp_colour_u, comp_colour_o, ...
                 filename)


	     
%
%
                 comp_font, comp_colour_u, comp_colour_o)
% $$$ function cbg2fig(bonds, cbonds, rbonds, ...
% $$$                  rcomponents, status, system_name, ...
% $$$                  stroke_length, stroke_thickness, stroke_colour, ...
% $$$                  comp_font, comp_colour_u, comp_colour_o, ...
% $$$                  filename)
% $$$ 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Matlab function  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.1  1996/08/05 18:12:25  peter
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if nargin<4
  stroke_length = 20;
end;

if nargin<5
  stroke_thickness = 2;
end;

if nargin<6
  stroke_colour = 1; %Blue
end;

if nargin<7
  comp_font = 18; %Helvetica bold
end;

if nargin<8
  comp_colour_u = 12; %Green
end;

if nargin<9
  comp_colour_o = 4; %Red
end;

% Create the (full) system name
if length(full_name)==0
  full_name = system_name;
  system_type = system_name;
else
  full_name = [full_name, '_', system_name];
end;

% Get the raw and the processed bonds
eval(['[rbonds,rstrokes,rcomponents] = ', system_type, '_rbg;']);
eval(['[bonds] = ', system_type, '_abg;']);

% Get the causal bonds
eval(['[cbonds,status]=', full_name, '_cbg;']);

%Check sizes
% Check sizes
[N_components,Columns] = size(rcomponents);
if (Columns ~= 13)
  error('Incorrect rcomponents matrix: must have 13 columns');
end;
M_components = Columns;


% Setup file - append to the cbg file
if nargin<7
  stroke_length = 20;
end;

filenum = fopen([full_name, '_cbg.fig'], 'a');
if nargin<8
  stroke_thickness = 2;
end;

if nargin<9
  stroke_colour = 1; %Blue
end;

if nargin<10
  comp_font = 18; %Helvetica bold
end;

if nargin<11
  comp_colour_u = 12; %Green
end;

if nargin<12
  comp_colour_o = 4; %Red
end;

if nargin<13
  filename = 'stdout';
end;


% Rotation matrix
rot = [0 -1; 1 0];


% Determine coordinates of the arrow end of the bond and the other end
% and other geometry
108
109
110
111
112
113
114
115

116
117

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139

140
141
142
143
144
145
146
123
124
125
126
127
128
129

130
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151

152
153

154
155
156
157
158
159
160
161







-
+

-
+



















-
+

-
+







    sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector(i,:)');
    stroke_end_2 = stroke_end_1 - stroke_length*sig*unit_stroke_vector(i,:);
    

    %print the fig3 format firstline spec.
    polyline = 2; 
    firstline = fig3(polyline,stroke_thickness,stroke_colour);
    fprintf(filename, '%s\n', firstline);
    fprintf(filenum, '%s\n', firstline);

    fprintf(filename, '	%4.0f %4.0f %4.0f %4.0f \n', ...
    fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	stroke_end_1(1), stroke_end_1(2), ...
	stroke_end_2(1), stroke_end_2(2) );
  end;

  for i = index_f % Do the flow stroke - same side as arrow

    if cbonds(i,2)==1 % Stroke at arrow end
      stroke_end_1 = arrow_end(i,:);
    else
      stroke_end_1 = other_end(i,:);
    end;
    
    sig = sign(unit_arrow_vector(i,:)*unit_stroke_vector(i,:)');
    stroke_end_2 = stroke_end_1 + stroke_length*sig*unit_stroke_vector(i,:);
    

    %print the fig3 format firstline spec.
    polyline = 2; 
    firstline = fig3(polyline,stroke_thickness,stroke_colour);
    fprintf(filename, '%s\n', firstline);
    fprintf(filenum, '%s\n', firstline);

    fprintf(filename, '	%4.0f %4.0f %4.0f %4.0f \n', ...
    fprintf(filenum, '	%4.0f %4.0f %4.0f %4.0f \n', ...
	stroke_end_1(1), stroke_end_1(2), ...
	stroke_end_2(1), stroke_end_2(2) );
  end;
end;

% Print all the components - coloured acording to causality.
for i = 1:N_components
155
156
157
158
159
160
161
162

163
164
165

166
167

168
169

170
171
172
173


174
175
176
177
178
179
180
170
171
172
173
174
175
176

177
178
179

180
181

182
183

184

185
186

187
188
189
190
191
192
193
194
195







-
+


-
+

-
+

-
+
-


-
+
+







  if status(i)==1  %Then over causal
    fig_params(3) = comp_colour_o;
    fig_params(6) = comp_font;
  end;


  %Now print the component in fig format
  eval(['[comp_type,comp_name] = ', systemname, '_cmp(i);']);
  eval(['[comp_type,comp_name] = ', system_name, '_cmp(i);']);
  Terminator = '\\001';   
  for j = 1:length(fig_params)
    fprintf(filename, '%1.0f ', fig_params(j));
    fprintf(filenum, '%1.0f ', fig_params(j));
  end;
  fprintf(filename, '%1.0f %1.0f ', coords(1), coords(2)); 
  fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); 
  % don't print the auto-numbered labels
  fprintf(filename, '%s:%s%s\n', comp_type, comp_name, Terminator);
  fprintf(filenum, '%s:%s%s\n', comp_type, comp_name, Terminator);
  
end;


% Close the file
fclose(filenum);








MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]