Exemplo n.º 1
0
void ModelBaker::handleModelNetworkReply() {
    auto requestReply = qobject_cast<QNetworkReply*>(sender());

    if (requestReply->error() == QNetworkReply::NoError) {
        qCDebug(model_baking) << "Downloaded" << _modelURL;

        // grab the contents of the reply and make a copy in the output folder
        QFile copyOfOriginal(_originalOutputModelPath);

        qDebug(model_baking) << "Writing copy of original model file to" << _originalOutputModelPath << copyOfOriginal.fileName();

        if (!copyOfOriginal.open(QIODevice::WriteOnly)) {
            // add an error to the error list for this model stating that a duplicate of the original model could not be made
            handleError("Could not create copy of " + _modelURL.toString() + " (Failed to open " + _originalOutputModelPath + ")");
            return;
        }
        if (copyOfOriginal.write(requestReply->readAll()) == -1) {
            handleError("Could not create copy of " + _modelURL.toString() + " (Failed to write)");
            return;
        }

        // close that file now that we are done writing to it
        copyOfOriginal.close();

        // emit our signal to start the import of the model source copy
        emit modelLoaded();
    } else {
        // add an error to our list stating that the model could not be downloaded
        handleError("Failed to download " + _modelURL.toString());
    }
}
Exemplo n.º 2
0
/**
 * @brief InfoManager::addProject Create project in this manager
 * @param name Name of the project
 * @param baseDir Path to given project
 * @return Return false if manager contains this project, true otherwise
 */
bool InfoManager::addProject(QString name, QDir baseDir)
{
    if(projects.contains(name))
        return false;

    MetaProject* proj = new MetaProject(name, baseDir);

    projects[name] = proj;
    emit projectCreated(name);

    if(activeProject.isEmpty())
        setActiveProject(name);

    connect(proj,SIGNAL(shaderCreated(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(shaderDestroyed(QString,MetaShader::SHADERTYPE)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(shProgCreated(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(shaderDestroyed(QString,MetaShader::SHADERTYPE)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(textureCreated(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(textureDestroyed(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(uniformCreated(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(uniformDestroyed(QString)),this,SLOT(projectChanged(QString)));
    connect(proj,SIGNAL(modelLoaded()),this,SLOT(projectChanged()));

    return true;
}
Exemplo n.º 3
0
void ModelBaker::saveSourceModel() {
    // check if the FBX is local or first needs to be downloaded
    if (_modelURL.isLocalFile()) {
        // load up the local file
        QFile localModelURL { _modelURL.toLocalFile() };

        qDebug() << "Local file url: " << _modelURL << _modelURL.toString() << _modelURL.toLocalFile() << ", copying to: " << _originalOutputModelPath;

        if (!localModelURL.exists()) {
            //QMessageBox::warning(this, "Could not find " + _modelURL.toString(), "");
            handleError("Could not find " + _modelURL.toString());
            return;
        }

        localModelURL.copy(_originalOutputModelPath);

        // emit our signal to start the import of the model source copy
        emit modelLoaded();
    } else {
        // remote file, kick off a download
        auto& networkAccessManager = NetworkAccessManager::getInstance();

        QNetworkRequest networkRequest;

        // setup the request to follow re-directs and always hit the network
        networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
        networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
        networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);

        networkRequest.setUrl(_modelURL);

        qCDebug(model_baking) << "Downloading" << _modelURL;
        auto networkReply = networkAccessManager.get(networkRequest);

        connect(networkReply, &QNetworkReply::finished, this, &ModelBaker::handleModelNetworkReply);
    }

    if (_mappingURL.isEmpty()) {
        outputUnbakedFST();
    }
}
Exemplo n.º 4
0
Controls::Controls(QWidget *parent)
    : QMainWindow(parent)
    , m_ui(new Ui::Controls)
    , m_view(0)
    , m_scaleLinked(true)
{
    m_ui->setupUi(this);
    connect(m_ui->actionQuit, SIGNAL(triggered()),
            this, SLOT(close()));

    m_view = new Viewer(m_ui->frame);
    QHBoxLayout *lay = new QHBoxLayout();
    lay->addWidget(m_view);
    m_ui->frame->setLayout(lay);
    connect(m_view, SIGNAL(manualControlEngaged()),
            this, SLOT(setManualControl()));

    QString initialModel = populateModelMenu();

    m_model = new Model(this);

    connect(this, SIGNAL(openFile(QString)),
            m_model, SLOT(setFullPath(QString)));
    connect(this, SIGNAL(openFile(QString)),
            this, SLOT(addRecentFiles(QString)));

    connect(m_model, SIGNAL(modelLoaded(QString)),
            this, SLOT(loadModelDefaults(QString)));
    connect(m_model, SIGNAL(modelLoaded(QString)),
            this, SLOT(loadSettings(QString)));
    connect(m_model, SIGNAL(modelLoaded(QString)),
            this, SLOT(setWindowTitle(QString)));
    connect(m_model, SIGNAL(modelLoaded(QString)),
            m_ui->treeView, SLOT(expandAll()));

    connect(m_model, SIGNAL(modelUnloaded(QString)),
            this, SLOT(saveModelDefaults(QString)));
    connect(m_model, SIGNAL(modelUnloaded(QString)),
            this, SLOT(saveSettings(QString)));
    connect(m_model, SIGNAL(modelLoadTime(int)),
            this , SLOT(fileLoadTimeNotified(int)));
    connect(m_model, SIGNAL(modelTriangles(int)),
            this, SLOT(triangleCountUpdated(int)));

    m_triangleCount = new QLabel(tr("0 triangles"));
    m_ui->statusbar->addPermanentWidget(m_triangleCount);

    m_view->setModel(m_model);
    m_ui->treeView->setModel(m_model);
    m_view->setTreeView(m_ui->treeView);

    emit openFile(initialModel);

    connect(m_ui->actionForce_Smooth, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->actionForce_Faceted, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->actionNative_Indices, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->actionCorrect_Normals, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->actionCorrect_Acute, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->actionShow_Warnings, SIGNAL(triggered(bool)),
            this, SLOT(optionMenuToggled(bool)));
    connect(m_ui->generateQmlPushButton, SIGNAL(clicked()),
            m_ui->actionSave_QML, SIGNAL(triggered()));
}