PDL has a OpenGL 3D extension. Maybe that can serve as a starting point.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
| [reply] |
There are OpenGL and OpenGL::Simple, but I'm not aware of any widget sets for either that would make displaying (3d) graphs easier.
| [reply] |
is it possible to include these as interactive widgets in a program written by perl/tk?
| [reply] |
| [reply] |
PDL's OpenGL stuff can be displayed in a Tk window. How interactive it is, is debatable......you can rotate with left-click drag, and zoom in/out with a right-click drag. Here is an example. (Don't ask for too many answers from me. The OpenGL coordinate view-space is "relative" to the largest axis, NOT straight cartesian. It's hard to explain it's behavior, but when you try and plot, you will see what I mean. I just hacked this :-) )
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use PDL;
use PDL::Graphics::TriD;
use PDL::Graphics::TriD::Contours;
use PDL::Graphics::TriD::GL;
use PDL::Graphics::TriD::Tk;
my $TriDW; # declare the graph object in main, defined in initializ
+e
my $MW = MainWindow->new();
my $bframe = $MW->Frame()->pack( -side => 'top', -fill => 'x' );
# This is the TriD Tk widget it is a Tk Frame widget and has all of th
+e
# attributes of a Frame
$TriDW = $MW->Tk()->pack( -expand => 1, -fill => 'both');
# The exit button
my $e_button = $bframe->Button(
-text => "Exit",
-command => sub { exit }
)->pack( -side => 'right', -anchor => 'nw', -fill => 'y' );
# Sets a default focus style for viewport
#setfocusstyle( 'Pointer' );
# This sets the graphic that will be displayed when the window is firs
+t opened
$e_button->bind( "<Configure>", [
sub {
my $but = shift;
Torusdemos();
$e_button->bind( "<Configure>", '' );
} ]
);
$TriDW->MainLoop;
sub Torusdemos {
my ( $bh ) = @_;
return unless defined $TriDW->{ GLwin };
my $graph;
$graph = $TriDW->{ GLwin }->current_viewport->graph();
# define the graph object
$graph = new PDL::Graphics::TriD::Graph();
$graph->default_axes();
my $data;
my $s = 40;
my $a = zeroes 2 * $s, $s / 2;
my $t = $a->xlinvals( 0, 6.284 );
my $u = $a->ylinvals( 0, 6.284 );
my $o = 0.5;
my $i = 0.1;
my $v = $o + $i * sin $u;
my $x = $v * sin $t;
my $y = $v * cos $t;
my $z = $i * cos( $u ) + $o * sin( 3 * $t );
# color
$data = new PDL::Graphics::TriD::SLattice(
[ $x, $y, $z ],
[
0.5 * ( 1 + sin $t ),
0.5 * ( 1 + cos $t ),
0.25 * ( 2 + cos( $u ) + sin( 3 * $t ) )
]
);
# black and white
# $data = new PDL::Graphics::TriD::SLattice_S( [ $x, $y, $z ] );
$graph->add_dataseries( $data, 'Torus-demo' );
$graph->scalethings();
$TriDW->current_viewport()->delete_graph( $graph );
$TriDW->current_viewport()->graph( $graph );
$TriDW->refresh();
}
| [reply] [d/l] |
Dear Zentara,
In order to understand PDL graphics, I tried to run it.... but fail. There is no PDL::Graphics::TriD::Tk; or any such module.
#Can't locate use PDL::Graphics::TriD::Tk; :(
Please help me in this regard.
Thanks
www.bioinformaticsonline.com
| [reply] |
| [reply] |