Mercurial > hg > octave-lyh
annotate scripts/plot/trimesh.m @ 17280:8ce6cdd272eb
Support TeX elements in FreeType renderer.
* libinterp/corefcn/txt-eng.cc: New file. Contains mapping from symbol
name to character code, in Unicode and MS symbol.
* libinterp/corefcn/modules.mk (COREFCN_SRC): Add txt-eng.cc.
* libinterp/corefcn/oct-tex-lexer.ll: Add "\n" to rules applicable to
".", as
the latter does not include new line characters.
* libinterp/corefcn/oct-tex-parser.yy: Remove debug statements.
* libinterp/corefcn/txt-eng.ft.cc (gripe_missing_glyph,
gripe_glyph_render): Change signature from char to FT_ULong.
(ft_render::ft_render): Adapt to new/removed members.
(ft_render::~ft_render): Remove use of fonts member.
(ft_render::set_font): Likewise. Use font instead.
(ft_render::push_new_line): Likewise. Change meaning of yoffset and
initialize line_yoffset.
(ft_render::update_line_bbox): New method.
(ft_render::set_mode): Change meaning of yoffset and initialize
line_yoffset.
(ft_render::process_character): New method.
(ft_render::visit(text_element_string)): Use it.
(ft_render::visit(text_element_list),
ft_render::visit(text_element_subscript),
ft_render::visit(text_element_superscript),
ft_render::visit(text_element_color),
ft_render::visit(text_element_fontsize),
ft_render::visit(text_element_fontname),
ft_render::visit(text_element_fontstyle),
ft_render::visit(text_element_symbol)): New methods.
(ft_render::set_color): Use color member instead of red/green/blue.
* libinterp/corefcn/txt-eng-ft.h (ft_render::visit(text_element_list),
ft_render::visit(text_element_subscript),
ft_render::visit(text_element_superscript),
ft_render::visit(text_element_color),
ft_render::visit(text_element_fontsize),
ft_render::visit(text_element_fontname),
ft_render::visit(text_element_fontstyle),
ft_render::visit(text_element_symbol)): New methods.
(ft_render::update_line_bbox, ft_render::process_character): New
methods.
(ft_render::current_face): Removed method.i
(ft_render::font): New member, replaces obsolete ft_render::fonts.
(ft_render::line_yoffset): New member.
(ft_render::color): New member, replaces obsolete red, green and blue.
(ft_render::ft_font::ft_font()): Implement default constructor.
(ft_render::ft_font::operator=): Fix incorrect use of FT_Reference_Face
return value.
(ft_render::ft_font::is_valid): New method.
* libinterp/corefcn/txt-eng.h (class text_element_symbol, class
text_element_fontname, class text_element_fontsize, class
text_element_fontname, class text_element_fontstyle, class
text_element_color): Add forward definition.
(text_element_symbol::invalid_code): New enum.
(text_element_symbol::code): New member.
(text_element_symbol::text_element_symbol): Initialize it.
(text_element_symbol::get_symbol_code): New method.
(text_element_fontstyle::get_fontstyle): New method.
(text_element_fontname::get_fontname): Renamed from fontname.
(text_element_fontsize::get_fontsize): Renamed from fontsize.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 18 Aug 2013 16:36:46 -0400 |
parents | 26589abbc78d |
children | 000be929e835 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
6823 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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. | |
6823 | 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. | |
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/>. | |
6823 | 18 |
19 ## -*- texinfo -*- | |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
20 ## @deftypefn {Function File} {} trimesh (@var{tri}, @var{x}, @var{y}, @var{z}, @var{c}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
21 ## @deftypefnx {Function File} {} trimesh (@var{tri}, @var{x}, @var{y}, @var{z}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
22 ## @deftypefnx {Function File} {} trimesh (@var{tri}, @var{x}, @var{y}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
23 ## @deftypefnx {Function File} {} trimesh (@dots{}, @var{prop}, @var{val}, @dots{}) |
7650 | 24 ## @deftypefnx {Function File} {@var{h} =} trimesh (@dots{}) |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
25 ## Plot a 3-D triangular wireframe mesh. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
26 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
27 ## In contrast to @code{mesh}, which plots a mesh using rectangles, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
28 ## @code{trimesh} plots the mesh using triangles. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13747
diff
changeset
|
29 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
30 ## @var{tri} is typically the output of a Delaunay triangulation over the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
31 ## grid of @var{x}, @var{y}. Every row of @var{tri} represents one triangle |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
32 ## and contains three indices into [@var{x}, @var{y}] which are the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
33 ## vertices of the triangles in the x-y plane. @var{z} determines the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
34 ## height above the plane of each vertex. If no @var{z} input is given then |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
35 ## the triangles are plotted as a 2-D figure. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
36 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
37 ## The color of the trimesh is computed by linearly scaling the @var{z} values |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
38 ## to fit the range of the current colormap. Use @code{caxis} and/or |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
39 ## change the colormap to control the appearance. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
40 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
41 ## Optionally, the color of the mesh can be specified independently of @var{z} |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
42 ## by supplying a color matrix, @var{c}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
43 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
44 ## Any property/value pairs are passed directly to the underlying patch object. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
45 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
46 ## The optional return value @var{h} is a graphics handle to the created patch |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
47 ## object. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
48 ## @seealso{mesh, tetramesh, triplot, trisurf, delaunay, patch, hidden} |
6823 | 49 ## @end deftypefn |
50 | |
51 function h = trimesh (tri, x, y, z, varargin) | |
52 | |
53 if (nargin < 3) | |
6826 | 54 print_usage (); |
6823 | 55 endif |
56 | |
57 if (nargin == 3) | |
58 triplot (tri, x, y); | |
59 elseif (ischar (z)) | |
60 triplot (tri, x, y, z, varargin{:}); | |
61 else | |
17130
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
62 hax = newplot (); |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
63 handle = patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri, |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14245
diff
changeset
|
64 "FaceColor", "none", "EdgeColor", __next_line_color__ (), |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
65 varargin{:}); |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
66 if (! ishold ()) |
17130
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
67 set (hax, "view", [-37.5, 30], |
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
68 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
6823 | 69 endif |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
70 if (nargout > 0) |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
71 h = handle; |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
72 endif |
6823 | 73 endif |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
74 |
6823 | 75 endfunction |
76 | |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
77 |
6823 | 78 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
79 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
80 %! old_state = rand ('state'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
81 %! restore_state = onCleanup (@() rand ('state', old_state)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
82 %! rand ('state', 10); |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
83 %! N = 10; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
84 %! x = 3 - 6 * rand (N, N); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
85 %! y = 3 - 6 * rand (N, N); |
6823 | 86 %! z = peaks (x, y); |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
87 %! tri = delaunay (x(:), y(:)); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
9051
diff
changeset
|
88 %! trimesh (tri, x(:), y(:), z(:)); |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
89 |