void InviwoApplication::printApplicationInfo() { LogInfoCustom("InviwoInfo", "Inviwo Version: " << IVW_VERSION); LogInfoCustom("InviwoInfo", "Base Path: " << getBasePath()); std::string config = ""; #ifdef CMAKE_GENERATOR config += std::string(CMAKE_GENERATOR); #endif #if defined(CMAKE_BUILD_TYPE) config += " [" + std::string(CMAKE_BUILD_TYPE) + "]"; #elif defined(CMAKE_INTDIR) config += " [" + std::string(CMAKE_INTDIR) + "]"; #endif if (config != "") LogInfoCustom("InviwoInfo", "Config: " << config); }
cl::Program OpenCL::buildProgram(const std::string& fileName, const std::string& defines, const cl::CommandQueue& queue) { cl::Context context = queue.getInfo<CL_QUEUE_CONTEXT>(); cl::Device device = queue.getInfo<CL_QUEUE_DEVICE>(); // build the program from the source in the file std::ifstream file(fileName.c_str()); TextFileReader fileReader(fileName); std::string prog; try { prog = fileReader.read(); } catch (std::ifstream::failure&) {} std::string concatenatedDefines = OpenCL::getPtr()->getIncludeDefine() + defines; cl::Program::Sources source(1, std::make_pair(prog.c_str(), prog.length()+1)); cl::Program program(context, source); try { program.build(std::vector<cl::Device>(1, device), concatenatedDefines.c_str()); std::string buildLog = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(device); // Output log if it contains any info if (buildLog.size() > 1) LogInfoCustom("OpenCL", fileName << " build info:" << std::endl << buildLog); } catch (cl::Error& e) { OpenCL::printBuildError(std::vector<cl::Device>(1, device), program, fileName); throw e; } return program; }
void InviwoApplicationQt::initialize(registerModuleFuncPtr regModuleFunc) { LogInfoCustom("InviwoInfo", "Qt Version " << QT_VERSION_STR); InviwoApplication::initialize(regModuleFunc); // Since QtWidgets are not a module we have to register it our self InviwoModule* module = new QtWidgetModule(); registerModule(module); module->initialize(); }
bool util::xmlCopyMatchingCompositeProperty(TxElement* node, const CompositeProperty& prop) { ticpp::Iterator<ticpp::Element> child; for (child = child.begin(node); child != child.end(); child++) { std::string name; child->GetValue(&name); std::string type = child->GetAttributeOrDefault("type", ""); std::string id = child->GetAttributeOrDefault("identifier", ""); if ((type == "CompositeProperty" || type == "org.inviwo.CompositeProperty") && prop.getIdentifier() == id) { LogInfoCustom("VersionConverter", " Found Composite with same identifier"); TxElement* newChild = node->InsertEndChild(*(child.Get()))->ToElement(); newChild->SetAttribute("type", prop.getClassIdentifier()); return true; } } return false; }
bool util::xmlCopyMatchingSubPropsIntoComposite(TxElement* node, const CompositeProperty& prop) { TxElement propitem("Property"); propitem.SetAttribute("type", prop.getClassIdentifier()); propitem.SetAttribute("identifier", prop.getIdentifier()); propitem.SetAttribute("displayName", prop.getDisplayName()); propitem.SetAttribute("key", prop.getIdentifier()); TxElement list("Properties"); propitem.InsertEndChild(list); node->InsertEndChild(propitem); std::vector<Property*> props = prop.getProperties(); bool res = false; for (auto& p : props) { bool match = false; ticpp::Iterator<ticpp::Element> child; for (child = child.begin(node); child != child.end(); child++) { std::string name; child->GetValue(&name); std::string type = child->GetAttributeOrDefault("type", ""); std::string id = child->GetAttributeOrDefault("identifier", ""); if (p->getIdentifier() == id && (p->getClassIdentifier() == type || p->getClassIdentifier() == splitString(type, '.').back())) { LogInfoCustom("VersionConverter", " Match for sub property: " + joinString(p->getPath(), ".") + " found in type: " << type << " id: " << id); list.InsertEndChild(*(child.Get())); match = true; } } res = res && match; } return res; }
void util::saveAllCanvases(ProcessorNetwork* network, std::string dir, std::string name, std::string ext) { int i = 0; for (auto cp : network->getProcessorsByType<inviwo::CanvasProcessor>()) { std::stringstream ss; ss << dir << "/"; if (name == "") { ss << cp->getIdentifier(); } else if(name.find("UPN") != std::string::npos) { std::string tmp = name; replaceInString(tmp, "UPN", cp->getIdentifier()); ss << tmp; } else { ss << name << i + 1; } ss << ext; LogInfoCustom("Inviwo", "Saving canvas to: " + ss.str()); cp->saveImageLayer(ss.str()); i++; } }