@@ -859,7 +859,7 @@ sub close {
859859}
860860
861861sub display {
862- my ($this ) = @_ ;
862+ my ($this ) = @_ ;
863863 return unless defined ($this );
864864 $this -> {_GLObject }-> set_window; # for multiwindow support
865865 print " display: calling glClear()\n " if $PDL::Graphics::TriD::verbose ;
@@ -891,64 +891,13 @@ sub display {
891891
892892# should this really be in viewport?
893893sub read_picture {
894- my ($this ) = @_ ;
895- my ($w ,$h ) = @{$this }{qw/ Width Height/ };
896- my $res = PDL-> zeroes(PDL::byte,3,$w ,$h );
897- glPixelStorei(GL_UNPACK_ALIGNMENT,1);
898- glPixelStorei(GL_PACK_ALIGNMENT,1);
899- glReadPixels_c(0,0,$w ,$h ,GL_RGB,GL_UNSIGNED_BYTE,$res -> make_physical-> address_data);
900- return $res ;
901- }
902- }
903-
904- {
905- package # hide from PAUSE
906- PDL::Graphics::TriD::EventHandler;
907- use fields qw/ X Y Buttons VP/ ;
908- sub new {
909- my $class = shift ;
910- my $vp = shift ;
911- my $self = fields::new($class );
912- $self -> {X } = -1;
913- $self -> {Y } = -1;
914- $self -> {Buttons } = [];
915- $self -> {VP } = $vp ;
916- $self ;
917- }
918- sub event {
919- my ($this ,$type ,@args ) = @_ ;
920- print " EH: " ,ref ($this )," $type (" ,join (" ," ,@args )," )\n " if $PDL::Graphics::TriD::verbose ;
921- return if !defined $type ;
922- my $retval ;
923- if ($type eq ' motion' ) {
924- return if (my $but = $args [0]) < 0;
925- print " MOTION $args [0]\n " if $PDL::Graphics::TriD::verbose ;
926- if ($this -> {Buttons }[$but ] and $this -> {VP }{Active }) {
927- print " calling " .($this -> {Buttons }[$but ])." ->mouse_moved ($this ->{X},$this ->{Y},$args [1],$args [2])...\n " if $PDL::Graphics::TriD::verbose ;
928- $retval = $this -> {Buttons }[$but ]-> mouse_moved(@$this {qw( X Y) }, @args [1,2]);
929- }
930- @$this {qw( X Y) } = @args [1,2];
931- } elsif ($type eq ' buttonpress' ) {
932- my $but = $args [0]-1;
933- print " BUTTONPRESS $but \n " if $PDL::Graphics::TriD::verbose ;
934- @$this {qw( X Y) } = @args [1,2];
935- $retval = $this -> {Buttons }[$but ]-> ButtonPress(@args [1,2])
936- if $this -> {Buttons }[$but ];
937- } elsif ($type eq ' buttonrelease' ) {
938- my $but = $args [0]-1;
939- print " BUTTONRELEASE $but \n " if $PDL::Graphics::TriD::verbose ;
940- $retval = $this -> {Buttons }[$but ]-> ButtonRelease($args [1],$args [2])
941- if $this -> {Buttons }[$but ];
942- } elsif ($type eq ' reshape' ) {
943- # Kludge to force reshape of the viewport associated with the window -CD
944- print " ConfigureNotify (" .join (" ," ,@args )." )\n " if $PDL::Graphics::TriD::verbose ;
945- print " viewport is $this ->{VP}\n " if $PDL::Graphics::TriD::verbose ;
946- }
947- $retval ;
948- }
949- sub set_button {
950- my ($this ,$butno ,$act ) = @_ ;
951- $this -> {Buttons }[$butno ] = $act ;
894+ my ($this ) = @_ ;
895+ my ($w ,$h ) = @{$this }{qw/ Width Height/ };
896+ my $res = PDL-> zeroes(PDL::byte,3,$w ,$h );
897+ glPixelStorei(GL_UNPACK_ALIGNMENT,1);
898+ glPixelStorei(GL_PACK_ALIGNMENT,1);
899+ glReadPixels_c(0,0,$w ,$h ,GL_RGB,GL_UNSIGNED_BYTE,$res -> make_physical-> address_data);
900+ return $res ;
952901}
953902}
954903
0 commit comments