home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / GRAPHICS.DI$ / ORIENT.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  2.1 KB  |  70 lines

  1. function o = orient(or)
  2. %ORIENT    Hardcopy paper orientation.
  3. %       ORIENT LANDSCAPE causes subsquent PRINT operations from the current
  4. %       figure window to generate output in full-page landscape orientation
  5. %       on the paper.
  6. %       ORIENT PORTRAIT returns to the default PORTRAIT orientation with
  7. %       the figure window occupying a rectangle with aspect ration 4/3 in 
  8. %       the middle of the page.
  9. %       ORIENT TALL causes the figure window to map to the whole page
  10. %       in portrait orientation.
  11. %       ORIENT, by itself, returns a string containing the current paper
  12. %       orientation, either PORTRAIT, LANDSCAPE or TALL.
  13. %
  14. %       ORIENT is an M-file that sets the PaperOrientation and PaperPosition
  15. %       properties of the current figure window.
  16. %
  17. %    See also PRINT.
  18.  
  19. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  20.  
  21. if nargin == 0
  22.     o = lower(get(gcf,'PaperOrientation'));
  23.     if strcmp(o,'portrait')
  24.        pp = get(gcf,'PaperPosition');
  25.        ps = get(gcf,'PaperSize');
  26.        if all(pp([3,4]) == ps) & ps(1) < ps(2)
  27.           o = 'tall';
  28.        end
  29.     end
  30.     return
  31. end
  32.  
  33. do = lower(get(gcf,'DefaultFigurePaperOrientation'));
  34. drect = get(0,'DefaultFigurePaperPosition');
  35. frectpin = [.25 2.5 8 6];
  36. or = lower(or);
  37. if strcmp(or,'portrait')
  38.     set(gcf,'PaperOrientation','portrait')
  39.     if strcmp(do,'portrait')
  40.         set(gcf,'PaperPosition',drect)
  41.     else
  42.         un = get(gcf,'PaperUnits');
  43.         set(gcf,'PaperUnits','inches');
  44.         set(gcf,'PaperPosition',frectpin);
  45.         set(gcf,'PaperUnits',un);
  46.     end
  47. elseif strcmp(or,'landscape')
  48.     set(gcf,'PaperOrientation',or);
  49.     if strcmp(do,'landscape')
  50.         set(gcf,'PaperPosition',drect)
  51.     else
  52.         un = get(gcf,'PaperUnits');
  53.         set(gcf,'PaperUnits','inches');
  54.         ps = get(gcf,'PaperSize');
  55.         rect = [0 0 ps];
  56.         set(gcf,'PaperPosition',rect);
  57.         set(gcf,'PaperUnits',un);
  58.     end
  59. elseif strcmp(or,'tall')
  60.     set(gcf,'PaperOrientation','portrait')
  61.     un = get(gcf,'PaperUnits');
  62.     set(gcf,'PaperUnits','inches');
  63.     ps = get(gcf,'PaperSize');
  64.     rect = [0 0 ps];
  65.     set(gcf,'PaperPosition',rect);
  66.     set(gcf,'PaperUnits',un);
  67. else
  68.     error('Unknown command option.')
  69. end
  70.