Skip to content

Commit 3065002

Browse files
committed
add labels3d
1 parent 1ca1f02 commit 3065002

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

Changes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- rationalise/unify ::Objects classes
44
- trigrid3d $colours is now per-vertex
55
- coordinate inputs now converted to float, so pass right type if want flow
6+
- add labels3d
67

78
2.102 2025-04-11
89
- fix scrolling out with mousewheel/double-touch-scroll in GLUT
@@ -22,7 +23,7 @@
2223
2.099 2025-01-06
2324
- add licence information
2425

25-
2.098 2024-01-04
26+
2.098 2025-01-04
2627
- Graphics::TriD::Rout::{combcoords,attract,repulse} moved to ImageND
2728

2829
2.097 2024-12-09

lib/PDL/Demos/TriD1.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ my @demo = (
206206
my $graph = PDL::Graphics::TriD::get_new_graph(); # also clears
207207
hold3d();
208208
nokeeptwiddling3d();
209-
PDL::Graphics::TriD::graph_object(
210-
my $lab = PDL::Graphics::TriD::Labels->new($c,{Strings => \@names}));
209+
my $lab = labels3d($c,{Strings => \@names});
211210
PDL::Graphics::TriD::graph_object(
212211
my $lin = PDL::Graphics::TriD::Arrows->new(
213212
$c, {From => $from, To => $to}));

lib/PDL/Graphics/TriD.pm

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Example:
361361
- mesh of surface
362362
363363
Note: a mesh is defined by two sets of lines at
364-
right-angles (i.e. this is how is differs from
364+
right-angles (i.e. this is how it differs from
365365
line3d).
366366
367367
See module documentation for more information on
@@ -526,6 +526,25 @@ value using the set_color_table function.
526526
527527
Implemented by L<PDL::Graphics::TriD::Contours>.
528528
529+
=head2 labels3d
530+
531+
=for ref
532+
533+
Labels at specified 3D coordinates.
534+
535+
Implemented by L<PDL::Graphics::TriD::Labels>.
536+
537+
=for usage
538+
539+
labels3d ndarray(3,x), {OPTIONS}
540+
labels3d [CONTEXT], {OPTIONS}
541+
542+
=for example
543+
544+
Example:
545+
546+
pdl> $coords = yvals(3)->append(zeroes 2); labels3d $coords, {Strings=>[0..2]}
547+
529548
=head2 hold3d, release3d
530549
531550
=for ref
@@ -709,7 +728,7 @@ use PDL::Exporter;
709728
use PDL::Core ''; # barf
710729
our @ISA = qw/PDL::Exporter/;
711730
our @EXPORT_OK = qw/imag3d_ns imag3d line3d mesh3d lattice3d points3d
712-
trigrid3d trigrid3d_ns line3d_segs
731+
trigrid3d trigrid3d_ns line3d_segs labels3d
713732
contour3d spheres3d describe3d imagrgb imagrgb3d hold3d release3d
714733
keeptwiddling3d nokeeptwiddling3d close3d
715734
twiddle3d grabpic3d tridsettings/;
@@ -868,13 +887,21 @@ sub PDL::imagrgb {
868887

869888
# Plotting routines that use the 3D graph
870889

890+
*labels3d=*labels3d=\&PDL::labels3d;
891+
sub PDL::labels3d {
892+
&checkargs;
893+
my $obj = PDL::Graphics::TriD::Labels->new(@_);
894+
print "labels3d: object is $obj\n" if $PDL::Graphics::TriD::verbose;
895+
graph_object($obj);
896+
}
897+
871898
# Call: line3d([$x,$y,$z],[$color]);
872899
*line3d=*line3d=\&PDL::line3d;
873900
sub PDL::line3d {
874-
&checkargs;
875-
my $obj = PDL::Graphics::TriD::LineStrip->new(@_);
876-
print "line3d: object is $obj\n" if($PDL::Graphics::TriD::verbose);
877-
graph_object($obj);
901+
&checkargs;
902+
my $obj = PDL::Graphics::TriD::LineStrip->new(@_);
903+
print "line3d: object is $obj\n" if($PDL::Graphics::TriD::verbose);
904+
graph_object($obj);
878905
}
879906

880907
*line3d_segs=*line3d_segs=\&PDL::line3d_segs;

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ This provides the following class hierarchy:
1616
├ PDL::Graphics::TriD::Lines separate lines
1717
├ PDL::Graphics::TriD::LineStrip continuous paths
1818
├ PDL::Graphics::TriD::Trigrid polygons
19-
└ PDL::Graphics::TriD::Lattice colored lattice, maybe filled/shaded
19+
├ PDL::Graphics::TriD::Lattice colored lattice, maybe filled/shaded
20+
├ PDL::Graphics::TriD::Arrows lines with arrowheads
21+
└ PDL::Graphics::TriD::Labels text labels
2022
2123
=head1 DESCRIPTION
2224

0 commit comments

Comments
 (0)