home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / softsys / matlab / 234 < prev    next >
Encoding:
Text File  |  1993-01-28  |  5.8 KB  |  237 lines

  1. Newsgroups: comp.soft-sys.matlab
  2. Path: sparky!uunet!spool.mu.edu!news.nd.edu!control!jeff
  3. From: jeff@control.nd.edu (Jeffrey C. Kantor)
  4. Subject: Matlab4.0 vs. Framemaker 3.1.1
  5. Message-ID: <1993Jan28.222050.15220@news.nd.edu>
  6. Sender: news@news.nd.edu (USENET News System)
  7. Reply-To: jeff@control.nd.edu
  8. Organization: University of Notre Dame
  9. Date: Thu, 28 Jan 1993 22:20:50 GMT
  10. Lines: 225
  11.  
  12. I've finally sorted out the problem of importing matlab eps files into 
  13. framemaker. The important thing to do is remove the %%EOF line that
  14. matlab sticks at the end of the file. I did this by inserted a short
  15. sed script into print.m.
  16.  
  17. The second modification I  made to print.m was to not add the preview information.
  18. I'm using Openview 3.0, and framemaker will render the eps file directly, so
  19. the preview info is redundant for me. Print.m appears to always add -preview
  20. to the eps files, whether or not you wanted that to happen. I commented out
  21. this part of print.m
  22.  
  23. My version of print.m is attached below. Use at your own risk.
  24.  
  25. Jeff Kantor
  26. Notre Dame
  27.  
  28. function print(arg1,arg2,arg3,arg4,arg5)
  29. %PRINT    Print graph or save graph to file.
  30. %    PRINT <filename> saves the current Figure window in PostScript
  31. %    format to the designated filename, overwriting it if it 
  32. %    already exists. If the specified filename does not include an
  33. %    extension, ".ps" or ".eps" is appended to the filename.
  34. %    If the filename is omitted, the Figure is sent directly to the
  35. %    printer as specified in PRINTOPT.
  36. %
  37. %    Syntax: PRINT [ -ddevice] [ -append ] <filename>
  38. %
  39. %    Available device options are:
  40. %       -dps    - PostScript for black and white printers
  41. %       -dpsc   - PostScript for color printers
  42. %       -dps2   - Level 2 PostScript for black and white printers
  43. %       -dpsc2  - Level 2 PostScript for color printers
  44. %
  45. %       -deps   - Encapsulated PostScript (EPSF)
  46. %       -depsc  - Encapsulated Color PostScript (EPSF)
  47. %       -deps2  - Encapsulated Level 2 PostScript (EPSF)
  48. %       -depsc2 - Encapsulated Level 2 Color PostScript (EPSF)
  49. %
  50. %    Other PRINT options are:
  51. %       -append - Append the graph to file, rather than overwriting
  52. %
  53. %    PRINT, by itself, or with a device name, sends the contents
  54. %    of the current Figure window to the printer.  See PRINTOPT
  55. %    to control printing defaults.
  56. %
  57. %    See also PRINTOPT, ORIENT.
  58.  
  59. %    Copyright (c) 1984-92 by The MathWorks, Inc.
  60.  
  61. %
  62. % list of all supported devices, for input validation
  63. %
  64. devices = [
  65.     'ps   '
  66.     'psc  '
  67.     'ps2  '
  68.     'ps2c '
  69.     'psc2 '
  70.     'eps  '
  71.     'epsc '
  72.     'eps2 '
  73.     'eps2c'
  74.     'epsc2'
  75. ];
  76.  
  77. options = [
  78.     'append '
  79.     'preview'
  80. ];
  81.  
  82. printplot = 0;
  83. isEps = 0;
  84. num_opt_args = 0;
  85. filename = [];
  86.  
  87. [lprcmd, dev] = printopt;
  88.  
  89. for i=1:nargin
  90.     cur_arg = eval(['arg', num2str(i)]);
  91.     if (cur_arg(1) ~= '-')
  92.         if isempty(filename)
  93.             filename = cur_arg;
  94.         else
  95.             error('Multiple inputs that look like filenames, no ''-''.');
  96.         end
  97.  
  98.     elseif (cur_arg(2) == 'd')
  99.         %
  100.         % verify device given is supported
  101.         % device proper starts after '-d', if only '-d'
  102.         % we echo out possible choices
  103.         %
  104.         dev = cur_arg;
  105.         match = 0;
  106.         wasError = 0;
  107.         if ( size(dev,2) > 2 )
  108.             wasError = 1;
  109.             for r = 1:size(devices,1)
  110.                 if strcmp( deblank(dev(3:size(dev,2))), deblank(devices(r,:)) )
  111.                     match = 1;
  112.                     break;
  113.                 end
  114.             end
  115.             if ~match
  116.                 disp('Illegal device specified.');
  117.             end
  118.         end
  119.         if ~match
  120.             disp('Supported devices are:')
  121.             disp(devices);
  122.             if wasError
  123.                 error(' ');
  124.             else
  125.                 return;
  126.             end
  127.         end
  128.         if (dev(3) == 'e')
  129.             isEps = 1;
  130.         end
  131.  
  132.     else
  133.         %
  134.         % verify any given options are supported
  135.         %
  136.         match = 0;
  137.         if size(cur_arg,2) > 1
  138.             op = cur_arg(2:size(cur_arg,2));
  139.             for r = 1:size(options,1)
  140.                 c = min(size(op,2), size(options(r,:),2));
  141.                 if strcmp(op(1:c), options(r,1:c))
  142.                     match = 1;
  143.                     break;
  144.                 end
  145.             end
  146.         end
  147.         if ~match
  148.             error(['Illegal option ''' op ''' given.'])
  149.         end
  150.         num_opt_args = num_opt_args + 1;
  151.         eval(['opt_arg', num2str(num_opt_args), ' = cur_arg;']);
  152.     end
  153. end
  154.  
  155. if isempty(filename)
  156.     if (isEps == 1)
  157.         error('Filename must be specified.')
  158.     end
  159.     % Generate a unique filename
  160.     t = fix(clock);
  161.     filename = ['tp' sprintf('%02.0f%02.0f%02.0f.ps',t(4),t(5),t(6))];
  162.     printplot = 1;
  163. end
  164.  
  165. % Append appropriate extension to filename if not there already
  166. if ~any(filename == '.')
  167.     if (isEps)
  168.         filename = [filename '.eps'];
  169.     else
  170.         filename = [filename '.ps'];
  171.     end
  172. end
  173.  
  174. % Create objects on screen if not already there
  175. drawnow
  176.  
  177. % EPS file gets Adobe standard EPSI bitmap preview
  178. % Bring figure to top of window stacking order for screen capture
  179. %if (isEps)
  180. %    num_opt_args = num_opt_args + 1;
  181. %    eval(['opt_arg', num2str(num_opt_args), ' = ''-preview'';']);
  182. %    figure(gcf)
  183. %end    
  184.  
  185. % Invert B&W color properties of Figure and child objects
  186. if strcmp( 'on', get(gcf,'InvertHardcopy') )
  187.     cinvert( gcf );
  188. end
  189.  
  190. % if not color, set lines and text to a color contrasting background
  191. if isempty( find('c' == dev) )
  192.     lineTextColors = blt;
  193. end
  194.  
  195. if (num_opt_args == 0)
  196.     hardcopy(gcf, filename, dev)
  197. elseif (num_opt_args == 1)
  198.     hardcopy(gcf, filename, dev, opt_arg1)
  199. elseif (num_opt_args == 2)
  200.     hardcopy(gcf, filename, dev, opt_arg1, opt_arg2)
  201. elseif (num_opt_args == 3)
  202.     hardcopy(gcf, filename, dev, opt_arg1, opt_arg2, opt_arg3)
  203. elseif (num_opt_args == 4)
  204.     hardcopy(gcf, filename, dev, opt_arg1, opt_arg2, opt_arg3, opt_arg4)
  205. end
  206.  
  207. if isEps
  208.   eval(['!sed ''s/%%EOF//''',' ',filename,' >temp']);
  209.   eval(['!mv -f temp ',filename]);
  210. end
  211.  
  212.  
  213. % set color of lines and text back to what they were
  214. if isempty( find('c' == dev) )
  215.     blt(lineTextColors);
  216. end
  217.  
  218. % Invert back the W&B color properties of Figure and child objects
  219. if strcmp( 'on', get(gcf,'InvertHardcopy') )
  220.     cinvert( gcf );
  221. end
  222.  
  223. %
  224. % Discard all the object invalidations that occured as a result of changing
  225. % colors. All objects are back to their previous state, but they don't 
  226. % know that and won't draw themselves.
  227. %
  228. if isempty( find('c' == dev) ) | strcmp( 'on', get(gcf,'InvertHardcopy') )
  229.     drawnow('discard')
  230. end
  231.  
  232. if printplot
  233.     lprcmd = [lprcmd,' ',filename];
  234.     eval(['!',lprcmd]);
  235. end
  236.  
  237.