GLWidget::GLWidget() { // Update the Widget after a frameswap connect( this, SIGNAL( frameSwapped() ), this, SLOT( update() ) ); // Exit the application connect( this, SIGNAL( exitFlag() ), QApplication::instance(), SLOT( quit() ) ); // Rotate Clockwise connect( this, SIGNAL( rotateClockwise( bool ) ), this, SLOT( set_rotate_cw( bool ) ) ); connect( this, SIGNAL( rotateClockwiseMoon( bool ) ), this, SLOT( set_rotate_cw_moon( bool ) ) ); // Translate Clockwise connect( this, SIGNAL( translateClockwise( bool ) ), this, SLOT( set_translate_cw( bool ) ) ); connect( this, SIGNAL( translateClockwiseMoon( bool ) ), this, SLOT( set_translate_cw_moon( bool ) ) ); // Context Menu context_menu = new QMenu(); setContextMenuPolicy(Qt::CustomContextMenu); action_pause = context_menu->addAction("Unpause All"); action_exit = context_menu->addAction("Exit Program"); // Context Menu Request connect( this, SIGNAL( customContextMenuRequested( const QPoint ) ), this, SLOT( contextMenuRequested( QPoint ) ) ); // Context Menu Pause All connect( action_pause, SIGNAL( triggered() ), this, SLOT( pause() ) ); // Context Menu Quit connect( action_exit, SIGNAL( triggered() ), QApplication::instance(), SLOT( quit() ) ); // Set the initial scene transform3d.setTranslation( 3.0 * sin( 0.0f ), 0, 3.0 * cos( 0.0f ) ); transform3d.translate( 0.0f, 0.0f, -10.0f ); transform3d_2.scale( 0.5f ); transform3d_2.setTranslation( transform3d.translation().x() + 2.0f * sin( 0.0f ), transform3d.translation().y(), transform3d.translation().z() + 2.0f * cos( 0.0f ) ); camera3d.rotate( -25.0f, 1.0f, 0.0f, 0.0f ); camera3d.translate( 0.0f, 3.5f, 0.0f ); // Initialize planet system helper variables is_paused = true; rotate_cw = false; translate_cw = true; rotate_cw_moon = true; translate_cw_moon = false; setOrbitString(); }
// // INPUT EVENTS //////////////////////////////////////////////////////////// // void GLWidget::keyPressEvent( QKeyEvent* event ) { switch( event->key() ) { // Planet Controls case Qt::Key_Up: emit set_translate_cw( false ); break; case Qt::Key_Down: emit set_translate_cw( true ); break; case Qt::Key_Left: emit set_rotate_cw( false ); break; case Qt::Key_Right: emit set_rotate_cw( true ); break; // Moon Controls case Qt::Key_W: emit set_translate_cw_moon( false ); break; case Qt::Key_S: emit set_translate_cw_moon( true ); break; case Qt::Key_A: emit set_rotate_cw_moon( false ); break; case Qt::Key_D: emit set_rotate_cw_moon( true ); break; case Qt::Key_Escape: emit exitFlag(); break; default: break; } }
bool SdlApp::update() { handleInput(); return exitFlag(); }