Mercurial > hg > octave-lyh
annotate scripts/plot/orient.m @ 13485:59d266f7ed89
Removed plotter tab.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Wed, 27 Apr 2011 14:21:28 +0200 |
parents | b0084095098e |
children | 72c96de7a403 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2001-2011 Paul Kienzle |
5364 | 2 ## |
5365 | 3 ## This file is part of Octave. |
5364 | 4 ## |
5365 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5365 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
5364 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5364 | 18 |
5365 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} orient (@var{orientation}) | |
6895 | 21 ## Set the default print orientation. Valid values for |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
22 ## @var{orientation} include @code{"landscape"}, @code{"portrait"}, |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
23 ## and @code{"tall"}. |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
24 ## |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
25 ## The @code{"tall"} option sets the orientation to portait and fills |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
26 ## the page with the plot, while leaving a 0.25in border. |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
27 ## |
6895 | 28 ## If called with no arguments, return the default print orientation. |
5365 | 29 ## @end deftypefn |
5364 | 30 |
5365 | 31 ## Author: Paul Kienzle |
32 ## Adapted-By: jwe | |
5364 | 33 |
6257 | 34 function retval = orient (varargin) |
5365 | 35 |
6257 | 36 nargs = nargin; |
5364 | 37 |
8248 | 38 if (nargs > 0 && numel (varargin{1}) == 1 && isfigure (varargin{1})) |
6257 | 39 cf = varargin{1}; |
40 varargin(1) = []; | |
41 nargs--; | |
42 else | |
43 cf = gcf (); | |
44 endif | |
45 | |
46 if (nargs == 0) | |
47 retval = get (cf, "paperorientation"); | |
5364 | 48 elseif (nargin == 1) |
6257 | 49 orientation = varargin{1}; |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
8189
diff
changeset
|
50 if (strcmpi (orientation, "landscape") || strcmpi (orientation, "portrait")) |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
51 if (! strcmpi (get (cf, "paperorientation"), orientation)) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
52 ## FIXME - with the proper listeners in place there won't be a need to set |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
53 ## the papersize and paperpostion here. |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
54 papersize = get (cf, "papersize"); |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
55 paperposition = get (cf, "paperposition"); |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
56 set (cf, "paperorientation", orientation); |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
57 set (cf, "papersize", papersize([2, 1])); |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
58 set (cf, "paperposition", paperposition([2, 1, 4, 3])); |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
59 endif |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
60 elseif (strcmpi (varargin{1}, 'tall')) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
61 orient ("portrait"); |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
62 papersize = get (cf, "papersize"); |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
63 set (cf, "paperposition", [0.25, 0.25, (papersize - 0.5)]); |
5364 | 64 else |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
9832
diff
changeset
|
65 error ("orient: unknown ORIENTATION"); |
5364 | 66 endif |
67 else | |
6046 | 68 print_usage (); |
5364 | 69 endif |
70 | |
71 endfunction | |
72 | |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
73 %!shared papersize, paperposition, tallpaperposition, hfig |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
74 %! papersize = [8.5, 11]; |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
75 %! paperposition = [0.25, 2.5, 8, 6]; |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
76 %! tallpaperposition = [0.25, 0.25, (papersize-0.5)]; |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
77 %! hfig = figure (); |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
78 %! set (hfig, "visible", "off") |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
79 %! set (hfig, "paperorientation", "portrait") |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
80 %! set (hfig, "papersize", papersize) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
81 %! set (hfig, "paperposition", paperposition) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
82 %!test |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
83 %! orient portrait |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
84 %! assert (orient, "portrait") # default |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
85 %! assert (get (hfig, "papersize"), papersize) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
86 %! assert (get (hfig, "paperposition"), paperposition) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
87 %!test |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
88 %! orient landscape |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
89 %! assert (orient,"landscape") # change to landscape |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
90 %! assert (get (hfig, "papersize"), papersize([2, 1])) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
91 %! assert (get (hfig, "paperposition"), paperposition([2, 1, 4, 3])) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
92 %!test |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
93 %! orient portrait # change back to portrait |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
94 %! assert (orient, "portrait") |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
95 %! assert (get (hfig, "papersize"), papersize) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
96 %! assert (get (hfig, "paperposition"), paperposition) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
97 %!test |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
98 %! orient landscape |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
99 %! orient tall |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
100 %! assert (orient, "portrait") |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
101 %! assert (get (hfig, "papersize"), papersize) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
102 %! assert (get (hfig, "paperposition"), tallpaperposition) |
11473
44032aac5223
Correct failing error() tests due to change in capitalization of previous changeset.
Rik <octave@nomad.inbox5.com>
parents:
11472
diff
changeset
|
103 %!fail ("orient ('nobody')", "unknown ORIENTATION") |
9832
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
104 %!test |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
105 %! orient portrait # errors don't change the state |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
106 %! assert (orient, "portrait") |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
107 %! assert (get (hfig, "papersize"), papersize) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
108 %! assert (get (hfig, "paperposition"), tallpaperposition) |
cd0c4a5a12c8
orient.m: Flip papersize and paperposition when orientation changes. Add support for 'tall' option. Add tests.
Ben Abbott <bpabbott@mac.com>
parents:
8920
diff
changeset
|
109 %! close (hfig) |