bool CSPMSession::loadFile(const QString & fileName) { void * file; if (cspm_session_load_file(_hsSession, (void *) fileName.toStdWString().c_str(), &file)) { if (_file != NULL) { cspm_file_free(_file); } _file = file; _fileName = fileName; _procCallNames = QStringList(); _procCallNamesLoaded = false; _procs->clear(); _events->clear(); QString disp = QFileInfo(_fileName).baseName().replace(QRegExp("[^0-9a-z]"), ""); _displayName = disp; int i = 0; QMap<QString, CSPMSession *> sessions = ProgramState::get()->getSessions(); while (sessions.contains(_displayName)) { _displayName = disp + QString::number(i++); } getWarnings(); return true; } else { getWarnings(); getErrors(); return false; } }
void ModelBaker::handleFinishedMaterialBaker() { auto baker = qobject_cast<MaterialBaker*>(sender()); if (baker) { if (!baker->hasErrors()) { // this MaterialBaker is done and everything went according to plan qCDebug(model_baking) << "Adding baked material to FST mapping " << baker->getBakedMaterialData(); QString relativeBakedMaterialURL = _modelURL.fileName(); auto baseName = relativeBakedMaterialURL.left(relativeBakedMaterialURL.lastIndexOf('.')); relativeBakedMaterialURL = baseName + BAKED_MATERIAL_EXTENSION; auto materialResource = baker->getNetworkMaterialResource(); if (materialResource) { for (auto materialName : materialResource->parsedMaterials.names) { QJsonObject json; json[QString("mat::" + QString(materialName.c_str()))] = relativeBakedMaterialURL + "#" + materialName.c_str(); _materialMappingJSON.push_back(json); } } } else { // this material failed to bake - this doesn't fail the entire bake but we need to add the errors from // the material to our warnings _warningList << baker->getWarnings(); } } else { handleWarning("Failed to bake the materials for model with URL " + _modelURL.toString()); } bakeMaterialMap(); }
// collect warnings, concat into a string static char *getWarningsStr(MySqlDb *dbImpl) { static const int maxToReport = 5; char *warnings[maxToReport]; int numReturned = getWarnings(dbImpl, maxToReport, warnings); char *warningsStr = stString_join("\n", (const char**)warnings, numReturned); for (int i = 0; i < numReturned; i++) { stSafeCFree(warnings[i]); } return warningsStr; }
void StatusHolder::raise() { if (getError()) { Arg::StatusVector tmp(getErrors()); tmp << Arg::StatusVector(getWarnings()); m_raised = true; tmp.raise(); } }
bool CSPMSession::reload() { if (_file != NULL) { void * sess = cspm_session_create(); void * file; if (cspm_session_load_file(sess, (void *) _fileName.toStdWString().c_str(), &file)) { cspm_file_free(_file); cspm_session_free(_hsSession); _file = file; _hsSession = sess; _procCallNames = QStringList(); _procCallNamesLoaded = false; _procs->clear(); _events->clear(); getWarnings(); return true; } else { // To avoid repeating code, briefly change _hsSession. void * temp = _hsSession; _hsSession = sess; getWarnings(); getErrors(); _hsSession = temp; cspm_session_free(sess); return false; } } // No file, so this is a blank session - we don't add anything so there's nothing // to change, nothing to do. return true; }
void ModelBaker::handleFinishedMaterialMapBaker() { auto baker = qobject_cast<MaterialBaker*>(sender()); if (baker) { if (!baker->hasErrors()) { // this MaterialBaker is done and everything went according to plan qCDebug(model_baking) << "Adding baked material to FST mapping " << baker->getBakedMaterialData(); QString materialName; { auto materialResource = baker->getNetworkMaterialResource(); if (materialResource) { auto url = materialResource->getURL(); if (!url.isEmpty()) { QString urlString = url.toDisplayString(); auto index = urlString.lastIndexOf("#"); if (index != -1) { materialName = urlString.right(urlString.length() - index); } } } } QJsonObject json; json[QString(_materialMapping.front().first.c_str())] = baker->getMaterialData() + BAKED_MATERIAL_EXTENSION + materialName; _materialMappingJSON.push_back(json); } else { // this material failed to bake - this doesn't fail the entire bake but we need to add the errors from // the material to our warnings _warningList << baker->getWarnings(); } } else { handleWarning("Failed to bake the materialMap for model with URL " + _modelURL.toString() + " and mapping target " + _materialMapping.front().first.c_str()); } _materialMapping.erase(_materialMapping.begin()); bakeMaterialMap(); }