Index: mttroot/mtt/bin/trans/m/cbg2fig.m ================================================================== --- mttroot/mtt/bin/trans/m/cbg2fig.m +++ mttroot/mtt/bin/trans/m/cbg2fig.m @@ -1,7 +1,6 @@ -function cbg2fig(system_name, ... - system_type, full_name, ... +function cbg2fig(system_name, system_type, full_name, ... stroke_length, stroke_thickness, stroke_colour, ... comp_font, comp_colour_u, comp_colour_o) ## cbg2fig - converts causal bg to figure ## @@ -22,10 +21,14 @@ ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% Version control history ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% $Id$ ## %% $Log$ + ## %% Revision 1.13 2000/09/14 09:12:19 peterg + ## %% Fixed stroke orientation bug with bent bonds + ## %% Uses new info from the _rbg.m file - 4 new cols in rbonds + ## %% ## %% Revision 1.12 2000/09/14 08:07:00 peterg ## %% Reformated as an Octave function ## %% ## %% Revision 1.11 2000/01/18 14:52:02 peterg ## %% Removed recursion --- maybe put back via a flag later @@ -98,11 +101,10 @@ bs = setstr(92); ## Create the (full) system name if strcmp(full_name,'') full_name = system_name; - system_type = system_name; else full_name = [full_name, '_', system_name]; end; full_name_type = [full_name, '_', system_type]; @@ -117,19 +119,18 @@ ## Setup file - append to the fig file filenum = fopen(fig_name, 'a'); ## Get the raw and the processed bonds eval(['[rbonds,rstrokes,rcomponents] = ', system_type, '_rbg;']); - %eval(['[bonds,components,n_ports] = ', system_type, '_abg;']); eval(["ABG = ", system_type, "_abg;"]); bonds=ABG.bonds; ## Original number of bonds [n_bonds,junk] = size(rbonds); ## Get the causal bonds - %eval(['[cbonds,status]=', full_name, '_cbg;']); + #eval(['[cbonds,status]=', full_name, '_cbg;']); eval(["CBG = ", full_name, "_cbg;"]); cbonds=CBG.bonds; ## Check sizes [Rows,Columns] = size(rcomponents); @@ -174,26 +175,18 @@ ## Get indices of bonds with changed causality -- but ignore the extra bonds ## due to vector bond expansion changed_e = bonds(1:n_bonds,1)~=cbonds(1:n_bonds,1); changed_f = bonds(1:n_bonds,2)~=cbonds(1:n_bonds,2); changed = changed_e|changed_f; - ## Don't do port bonds - #if n_ports>0 - # port_bonds = sort(abs(components(1:n_ports,1))); - # changed(port_bonds) = zeros(n_ports,1); - # changed_e(port_bonds) = zeros(n_ports,1); - # changed_f(port_bonds) = zeros(n_ports,1); - #end - - index_e = getindex(changed_e,1)' - index_f = getindex(changed_f,1)' + + index_e = getindex(changed_e,1)'; + index_f = getindex(changed_f,1)'; index_ef = getindex(changed,1)'; ## Print the new strokes in fig format if index_ef(1,1)>0 for i = index_e # Do the effort stroke - opp. side to arrow - if cbonds(i,1)==1 # Stroke at arrow end bond_vector = arrow_end_direction(i,:); # Directional vector stroke_end_1 = arrow_end(i,:); else bond_vector = other_end_direction(i,:); # Directional vector @@ -217,11 +210,10 @@ 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 bond_vector = arrow_end_direction(i,:); # Directional vector stroke_end_1 = arrow_end(i,:); else bond_vector = other_end_direction(i,:); # Directional vector @@ -245,11 +237,11 @@ stroke_end_2(1), stroke_end_2(2) ); end; end; ## Print all the components - coloured acording to causality. - for i = 1:N_ports+N_components + for i = 1+N_ports:N_ports+N_components if i>N_ports # Subsystem comp_name = CBG.subsystemlist(i-N_ports,:); eval(["comp_status = CBG.subsystems.", comp_name, ".status;"]); else comp_name = CBG.portlist(i,:); @@ -270,11 +262,11 @@ fig_params(6) = comp_font; end; ## Now print the component in fig format - eval(['[comp_type,comp_name] = ', system_type, '_cmp(i)']); + eval(['[comp_type,comp_name] = ', system_type, '_cmp(i);']); if index(comp_name,"mtt")==1 # Its a dummy name typename = comp_type; # just show type else typename = [comp_type,":",comp_name]; @@ -281,36 +273,19 @@ endif; Terminator = [bs, '001']; for j = 1:length(fig_params) fprintf(filenum, '%1.0f ', fig_params(j)); - end; + endfor + fprintf(filenum, '%1.0f %1.0f ', coords(1), coords(2)); fprintf(filenum, '%s%s\n', typename, Terminator); - - # % If it's a subsystem (ie not a component), do the fig file for that as - # % well - # if comp_type=='0' - # comp_type='zero'; - # endif - - # if comp_type=='1' - # comp_type='one'; - # endif - - - # if (exist([comp_type,'_cause'])==0) - # cbg2fig(comp_name, ... - # comp_type, full_name, ... - # stroke_length, stroke_thickness, stroke_colour, ... - # comp_font, comp_colour_u, comp_colour_o); - # endif endfor ## Close the file fclose(filenum); return endfunction