示例#1
0
void Simulator::keyPressEvent(QKeyEvent* event)
{
    switch(event->key())
    {
    case Qt::Key_H:
        homeView();
        break;
    case Qt::Key_Up:
        zoomIn = true;
        break;
    case Qt::Key_Down:
        zoomOut = true;
        break;
    case Qt::Key_Right:
        panRight = true;
        break;
    case Qt::Key_Left:
        panLeft = true;
        break;
    }
}
示例#2
0
//!
//! Constructor of the ViewportPanel class.
//!
//! \param parent The parent widget the created instance will be a child of.
//! \param flags Extra widget options.
//!
ViewportPanel::ViewportPanel ( QWidget *parent /* = 0 */, Qt::WindowFlags flags /* = 0 */ ) :
    ViewPanel(ViewPanel::T_Viewport, parent, flags),
    m_viewportWidget(0),
    m_fullscreen(false),
    m_stageActionGroup(0),
    m_cameraComboBox(0),
    // m_cameraCreator(false),
	// m_fogSpinBox(new QDoubleSpinBox(this)),
	// m_fogCheckBox(new QCheckBox(this)),
    // m_fogColorButton(new QPushButton(this)),
    m_backgroundColorButton(new QPushButton(this))
{
    setupUi(this);

    m_viewportWidget = new ViewportWidget(this);
    //m_viewportWidget = new ViewportWidget(this, 1, 0, 1);
    unsigned int selectedStageIndex = m_viewportWidget->getStageIndex();
    ui_vboxLayout->addWidget(m_viewportWidget);

    connect(m_viewportWidget, SIGNAL(viewChanged(ViewingParameters *)), SLOT(updateCamera(ViewingParameters *)));

    // set up connections for main tool bar actions
    connect(ui_homeAction, SIGNAL(triggered()), m_viewportWidget, SLOT(homeView()));
    connect(ui_wireframeAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(setWireframe(bool)));
    connect(ui_backfaceCullingAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(setBackfaceCulling(bool)));
    // connect(ui_originAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(toggleOrigin()));
    // connect(ui_centerPointAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(toggleCenterPoint()));
    connect(ui_orientationIndicatorAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(toggleOrientationIndicator()));
    connect(ui_gridAction, SIGNAL(toggled(bool)), m_viewportWidget, SLOT(toggleGrid()));
#ifdef USE_STEREO    
    connect(ui_stereoAction, SIGNAL(toggled(bool)), this, SLOT(toggleFullscreen(bool)));
    connect(ui_stereoDialogAction, SIGNAL(triggered()), this, SLOT(showStereoDialog()));
#endif
	// connect(m_fogSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeFog(double)));
	// connect(m_fogCheckBox, SIGNAL(stateChanged(int)), this, SLOT(changeFog(int)));
    // connect(m_fogColorButton, SIGNAL(pressed()), this, SLOT(changeFogColor()));
    connect(m_backgroundColorButton, SIGNAL(pressed()), this, SLOT(changeBackgroundColor()));

    // initialize main tool bar actions
    ui_wireframeAction->setChecked(false);
    ui_backfaceCullingAction->setChecked(false);
    ui_gridAction->setChecked(true);
    ui_orientationIndicatorAction->setChecked(true);
    ui_stereoAction->setChecked(false);
    // ui_overlayOnlyAction->setChecked(false);
    // m_parameterMap["overlayOnly"] = "0";


    // create an action group for the stage actions
    m_stageActionGroup = new QActionGroup(this);
    for (unsigned int stageIndex = 1; stageIndex <= NUMBER_OF_STAGES; ++stageIndex) {
        QString text;
        if (stageIndex < 10)
            text = QString("Stage &%1").arg(stageIndex);
        else if (stageIndex == 10)
            text = "Stage 1&0";
        else
            text = QString("Stage %1").arg(stageIndex);
        QIcon icon (QString(":/stage%1Icon").arg(stageIndex));
        QAction *stageAction = new QAction(icon, text, m_stageActionGroup);
        QVariant indexVariant(stageIndex);
        stageAction->setData(indexVariant);
        connect(stageAction, SIGNAL(toggled(bool)), SLOT(selectStage()));
        stageAction->setCheckable(true);
        if (stageIndex == selectedStageIndex) {
            stageAction->setChecked(true);
            m_parameterMap["stageIndex"] = QString::number(stageIndex);
        }
    }
    //connect(m_stageActionGroup, SIGNAL(triggered(QAction *)), SLOT(selectStage(QAction *)));

    // create the stages drop-down menu
    QMenu *stagesMenu = new QMenu("Stages Menu", this);
    stagesMenu->addActions(m_stageActionGroup->actions());
    ui_stagesMenuAction->setMenu(stagesMenu);
}