You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.3 KiB
Plaintext
91 lines
2.3 KiB
Plaintext
|
|
package GLObjectWindow;
|
|
|
|
use strict;
|
|
|
|
use TQt;
|
|
use TQt::isa qw(TQt::Widget);
|
|
use TQt::attributes qw(
|
|
file
|
|
frame
|
|
menu
|
|
box
|
|
xpos
|
|
ypos
|
|
zpos
|
|
);
|
|
|
|
use GLBox;
|
|
|
|
sub NEW
|
|
{
|
|
shift->SUPER::NEW(@_);
|
|
|
|
# Create a menu
|
|
file = TQt::PopupMenu( this );
|
|
file->insertItem( "Exit", TQt::app(), TQT_SLOT 'quit()', TQt::KeySequence(int &CTRL + &Key_Q ));
|
|
|
|
# Create a menu bar
|
|
menu = TQt::MenuBar( this );
|
|
menu->setSeparator( &TQt::MenuBar::InWindowsStyle );
|
|
menu->insertItem("&File", file );
|
|
|
|
# Create a nice frame to put around the OpenGL widget
|
|
frame = TQt::Frame( this, "frame" );
|
|
frame->setFrameStyle( &TQt::Frame::Sunken | &TQt::Frame::Panel );
|
|
frame->setLineWidth( 2 );
|
|
|
|
# Create our OpenGL widget
|
|
box = GLBox( frame, "glbox");
|
|
|
|
# Create the three sliders; one for each rotation axis
|
|
xpos = TQt::Slider ( 0, 360, 60, 0, &TQt::Slider::Vertical, this, "xsl" );
|
|
xpos->setTickmarks( &TQt::Slider::Left );
|
|
TQt::Object::connect( xpos, TQT_SIGNAL 'valueChanged(int)', box, TQT_SLOT 'setXRotation(int)' );
|
|
|
|
ypos = TQt::Slider ( 0, 360, 60, 0, &TQt::Slider::Vertical, this, "ysl" );
|
|
ypos->setTickmarks( &TQt::Slider::Left );
|
|
TQt::Object::connect( ypos, TQT_SIGNAL 'valueChanged(int)', box, TQT_SLOT 'setYRotation(int)' );
|
|
|
|
zpos = TQt::Slider ( 0, 360, 60, 0, &TQt::Slider::Vertical, this, "zsl" );
|
|
zpos->setTickmarks( &TQt::Slider::Left );
|
|
TQt::Object::connect( zpos, TQT_SIGNAL 'valueChanged(int)', box, TQT_SLOT 'setZRotation(int)' );
|
|
|
|
|
|
# Now that we have all the widgets, put them into a nice layout
|
|
|
|
# Put the sliders on top of each other
|
|
my $vlayout = TQt::VBoxLayout( 20, "vlayout");
|
|
$vlayout->addWidget( xpos );
|
|
$vlayout->addWidget( ypos );
|
|
$vlayout->addWidget( zpos );
|
|
|
|
# Put the GL widget inside the frame
|
|
my $flayout = TQt::HBoxLayout( frame, 2, 2, "flayout");
|
|
$flayout->addWidget( box, 1 );
|
|
|
|
# Top level layout, puts the sliders to the left of the frame/GL widget
|
|
my $hlayout = TQt::HBoxLayout( this, 20, 20, "hlayout");
|
|
$hlayout->setMenuBar( menu );
|
|
$hlayout->addLayout( $vlayout );
|
|
$hlayout->addWidget( frame, 1 );
|
|
}
|
|
|
|
1;
|
|
|
|
package main;
|
|
|
|
use TQt;
|
|
use GLObjectWindow;
|
|
|
|
my $a = TQt::Application(\@ARGV);
|
|
|
|
my $w = GLObjectWindow;
|
|
$w->resize(350,350);
|
|
$w->show;
|
|
|
|
$a->setMainWidget( $w);
|
|
|
|
exit $a->exec;
|
|
|