%
% RTD Simulator - Plot tracer curves
%
% Bob Newell, January 1996
%
function [newobjects, change] = rtdplot( fname, results, objects )
[npts, n] = size( results );
nobjects = n - 1;
change = 0;
%
% extract data to plot
%
time = results(:,1);
finished = 0;
while finished == 0,
%
% plot according to current scale factors 
%
  data = [];
  leg = [];
  for i = 1:nobjects,
    if objects(i,12) > 0,
      data = [ data objects(i,12) * results(:,i+1) ];
	  leg = [ leg; [ 'Object ' num2str(i) ] ]; 
    end;
  end;
%
% now the graphics part
%
  h = figure;  
  plot( time, data );
  xlabel( 'Time in Days' );
  ylabel( 'Tracer' );
  title( ['RTD Simulation "' fname '"'] );
  legend( leg );
%  t = waitforbuttonpress;
%  close( h );
  t = input( 'Change scaling (0=no,1=yes) > ' );
  if t > 0,
    for i = 1:nobjects,
      disp( ['Object ' num2str(i) ', scaling = ' ...
                 num2str( objects(i,12) )] );
    end;
    i = input( 'Object > ' );
    if i > 0,
      if i <= nobjects,
        objects(i,12) = input( 'New scaling > ' );
        change = 1;
      end;
    end;
  else
    finished = 1;
  end;
end;
%
newobjects = objects;
return;
