Esempio n. 1
0
CMainWindow::CMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CMainWindow),
    m_currentTab(nullptr)
{
    ui->setupUi(this);
    ui->tabWidget->setUsesScrollButtons(true);
    ui->tabWidget->setElideMode(Qt::ElideNone);
    ui->tabWidget->setTabsClosable(true);
    ui->tabWidget->setMovable(true);
    connect(ui->glView, SIGNAL(initialized()), this, SLOT(onViewerInitialized()));
    CResourceManager* resourceManager = CResourceManager::instance().get();
    connect(resourceManager, SIGNAL(newPak(CPakTreeWidget*)), this, SLOT(onNewPak(CPakTreeWidget*)));
    connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged()));
    connect(ui->actionLoad_Basepath, &QAction::triggered, this, &CMainWindow::_loadBasePath);
    connect(ui->glView, &CGLViewer::movementSpeedChanged, [=](float val){
        ui->horizontalSlider->setUpdatesEnabled(false);
        ui->horizontalSlider->setValue((int)((val * 100) / 1.0));
        ui->horizontalSlider->setUpdatesEnabled(true);
    });

    connect(ui->horizontalSlider, &QSlider::valueChanged, [=](int val){
        if (!ui->horizontalSlider->updatesEnabled())
            return;
        ui->horizontalSlider->setUpdatesEnabled(false);
        ui->glView->setMovementSpeed((float)(val / 100.f));
        ui->horizontalSlider->setValue((int)((ui->glView->movementSpeed() * 100) / 1.0));
        ui->horizontalSlider->setUpdatesEnabled(true);
    });

    installEventFilter(CKeyboardManager::instance());
    ui->actionMode0          ->setChecked(QSettings().value("mode0",           true ).toBool());
    ui->actionMode1          ->setChecked(QSettings().value("mode1",           true ).toBool());
    ui->actionMode2          ->setChecked(QSettings().value("mode2",           true ).toBool());
    ui->actionMode3          ->setChecked(QSettings().value("mode3",           true ).toBool());
    ui->actionMode4And5      ->setChecked(QSettings().value("mode4And5",       true ).toBool());
    ui->actionMode6          ->setChecked(QSettings().value("mode6",           true ).toBool());
    ui->actionMode7          ->setChecked(QSettings().value("mode7",           true ).toBool());
    ui->actionEnableTextures ->setChecked(QSettings().value("enableTextures",  true ).toBool());
    ui->actionDrawPoints     ->setChecked(QSettings().value("drawPoints",      false).toBool());
    ui->actionDrawJointNames ->setChecked(QSettings().value("drawJointNames",  false).toBool());
    ui->actionDrawBoundingBox->setChecked(QSettings().value("drawBoundingBox", false).toBool());
    ui->actionDrawCollision  ->setChecked(QSettings().value("drawCollision",   false).toBool());
    ui->actionWireframe      ->setChecked(QSettings().value("wireframe",       false).toBool());

    m_fpsUpdateTimer.setInterval(50);
    QMenuBar* bar = this->menuBar();
    QHBoxLayout* previewLayout = new QHBoxLayout(bar);
    previewLayout->addStretch();
    QLabel* previewLabel  = new QLabel(bar);
    previewLabel->setObjectName("previewLabel");
    previewLabel->setText("<b>UNSTABLE BUILD</b>");
    previewLayout->setContentsMargins(150, 0, 6, 0);
    previewLayout->addWidget(previewLabel);
    bar->setLayout(previewLayout);
    statusBar()->addPermanentWidget(&m_cameraPosition);
}