示例#1
0
int main(int argc, char** argv) {
	if (argc != 5) {
		printf("program '%s' halted \n", argv[0]);
		printf("exactly four arguments (transformation command line, transformation prefix, input file, output file without ending) expected \n");

		return EXIT_FAILURE;
	}

	const char* transformationCommand = argv[1];
	const char* transformationPrefix = argv[2];
	const char* inputFile = argv[3];
	const char* outputFile = argv[4];

	printf("transformationCommand is '%s'\n", transformationCommand);
	printf("transformationPrefix is '%s'\n", transformationPrefix);
	printf("inputFile is '%s'\n", inputFile);
	printf("outputFile is '%s'\n", outputFile);

	char* executingTransformationCommand = replaceInString(transformationCommand, "%IN", inputFile);
	executingTransformationCommand = replaceInString(executingTransformationCommand, "%OUT", outputFile);
	executingTransformationCommand = replaceInString(executingTransformationCommand, "%PRE", transformationPrefix);

	printf("\nrun following transformation command:\n'%s'\n", executingTransformationCommand);

	int returnOfTransformation = system(executingTransformationCommand);

	if (returnOfTransformation) {
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}
示例#2
0
void CImgVolumeReader::printMetaInfo(const MetaDataOwner& metaDataOwner, std::string key) const {
    if (auto metaData = metaDataOwner.getMetaData<StringMetaData>(key)) {
        std::string metaStr = metaData->get();
        replaceInString(metaStr, "\n", ", ");
        key[0] = static_cast<char>(toupper(key[0]));
        LogInfo(key << ": " << metaStr);
    }
}
示例#3
0
void PythonEditorWidget::readFile() {
    std::ifstream file(scriptFileName_.c_str());
    std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
    file.close();
    replaceInString(text, "\t", "    ");
    pythonCode_->setPlainText(text.c_str());
    script_.setSource(text);
    unsavedChanges_ = false;
}
示例#4
0
void MPVMVolumeReader::printMetaInfo(MetaDataOwner* metaDataOwner, std::string key) {
    StringMetaData* metaData = metaDataOwner->getMetaData<StringMetaData>(key);
    if (metaData) {
        std::string metaStr = metaData->get();
        replaceInString(metaStr, "\n", ", ");
        key[0] = static_cast<char>(toupper(key[0]));
        LogInfo(key << ": " << metaStr);
    }
}
示例#5
0
QString Nuria::RestfulHttpNode::compilePathRegEx (QString path) {
	static const QRegularExpression rx ("{([^}]+)}(.|$)");
	path = replaceInString (rx, path, insertRegularExpression);
	
	path.prepend ("^");
	path.append ("$");
	
	return path;
}
示例#6
0
std::shared_ptr<ShaderResource> ShaderManager::getShaderResource(std::string key) {
    auto it1 = shaderResources_.find(key);
    if (it1 != shaderResources_.end()) {
        if(!it1->second.expired()) {
            return it1->second.lock();
        } else {
            shaderResources_.erase(it1);
        }
    }

    std::string key2{ key };
    replaceInString(key2, "/", "_");
    replaceInString(key2, ".", "_");
    auto it0 = shaderResources_.find(key2);
    if (it0 != shaderResources_.end()) {
        if (!it0->second.expired()) {
            return it0->second.lock();
        } else {
            shaderResources_.erase(it0);
        }
    }

    if (filesystem::fileExists(key)) {
        auto resource = std::make_shared<FileShaderResource>(key, key);
        shaderResources_[key] = resource;
        return resource;
    }

    auto it2 = util::find_if(shaderSearchPaths_, [&](const std::string& path) {
        return filesystem::fileExists(path + "/" + key);
    });
    if (it2 != shaderSearchPaths_.end()) {
        std::string file = *it2 + "/" + key;

        auto resource = std::make_shared<FileShaderResource>(key, file);
        shaderResources_[key] = resource;
        return resource;
    }

    return nullptr;
}
示例#7
0
std::string parseTypeIdName(std::string str) {

#if defined(__clang__) || defined(__GNUC__)
    struct handle {
        char* p;
        handle(char* ptr) : p(ptr) {}
        ~handle() { std::free(p); }
    };
    const char* cstr = str.c_str();
    int status = -4;
    handle result(abi::__cxa_demangle(cstr, nullptr, nullptr, &status));
    if (status == 0) str = result.p;
#else
    replaceInString(str, "class", "");
    replaceInString(str, "const", "");
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64)
    replaceInString(str, "__ptr64", "");
#endif
#endif
    replaceInString(str, "inviwo::", "");
    return removeFromString(removeFromString(str, '*'), ' ');
}
示例#8
0
void PyInviwo::addModulePath(const std::string& path) {
    if (!Py_IsInitialized()) {
        LogWarn("addModulePath(): not initialized");
        return;
    }

    std::string pathConv = path;
    replaceInString(pathConv, "\\", "/");
    std::string runString = "import sys\n";
    runString.append(std::string("sys.path.append('") + pathConv + std::string("')"));
    int ret = PyRun_SimpleString(runString.c_str());

    if (ret != 0) LogWarn("Failed to add '" + pathConv + "' to Python module search path");
}
示例#9
0
void Settings::loadFromDisk(){
    std::stringstream ss;
    ss << identifier_ << ".ivs";
    std::string filename = ss.str();
    replaceInString(filename," ","_");
    filename = InviwoApplication::getPtr()->getPath(InviwoApplication::PATH_SETTINGS, "/" + filename);

    isDeserializing_ = true;
    if(filesystem::fileExists(filename)){
        IvwDeserializer d(filename);
        deserialize(d);
    }
    isDeserializing_ = false;
}
示例#10
0
void Settings::saveToDisk() {
    if (isDeserializing_) return;

    std::stringstream ss;
    ss << identifier_ << ".ivs";
    std::string filename = ss.str();
    replaceInString(filename, " ", "_");
    try {
        IvwSerializer s(
            InviwoApplication::getPtr()->getPath(InviwoApplication::PATH_SETTINGS, "/" + filename, true));
        serialize(s);
        s.writeFile();
    } catch (std::exception e) {
        LogWarn("Could not write settings");
    }
}
示例#11
0
void PythonInfoWidget::onModuleRegistered(PyModule* module) {
    QScrollArea* tab = new QScrollArea(tabWidget_);
    tab->setWidgetResizable(true);
    QWidget* content = new QWidget(tab);
    std::vector<PyMethod*> methods =  module->getPyMethods();
    QGridLayout* layout = new QGridLayout();
    layout->setColumnStretch(2,1);
    QLabel* funcLabel = new QLabel("Function");
    QLabel* paramLabel = new QLabel("Parameters");
    QLabel* descLabel = new QLabel("Description");
    QFont font = funcLabel->font();
    font.setPointSize(font.pointSize()+1);
    font.setBold(true);
    funcLabel->setFont(font);
    paramLabel->setFont(font);
    descLabel->setFont(font);

    layout->addWidget(funcLabel,0,0);
    layout->addWidget(paramLabel,0,1);
    layout->addWidget(descLabel,0,2);
    layout->addWidget(new QLabel("<hr />"),1,0,1,3);

    int row = 0;
    for (int i = 0; i<static_cast<int>(methods.size()); ++i) {
        row = i*2 + 2;
        QLabel* functionNameLabel = new QLabel(methods[i]->getName().c_str());
        functionNameLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
        layout->addWidget(functionNameLabel,row,0);
        std::string params = methods[i]->getParamDesc();
        replaceInString(params," , ","<br />");
        layout->addWidget(new QLabel(params.c_str()),row,1);
        QLabel* desc = new QLabel(methods[i]->getDesc().c_str());
        desc->setWordWrap(true);
        layout->addWidget(desc,row,2);
        layout->addWidget(new QLabel("<hr />"),row+1,0,1,3);
    }

    if(row)
        layout->addItem(new QSpacerItem(10,10,QSizePolicy::Minimum,QSizePolicy::Expanding),row+2,0);

    content->setLayout(layout);
    tab->setWidget(content);
    tabWidget_->addTab(tab,module->getModuleName());
}
示例#12
0
std::vector<std::string> splitStringWithMultipleDelimiters(const std::string& str,
                                                           std::vector<char> delimiters) {
    if (!delimiters.size()) {
        // adding default delimiters
        delimiters.push_back('_');
        delimiters.push_back('+');
        delimiters.push_back('-');
        delimiters.push_back('.');
        delimiters.push_back(' ');
    }

    std::string tempString = str;
    char lastDelimiter = delimiters[delimiters.size() - 1];

    for (size_t i = 0; i < delimiters.size() - 1; i++)
        replaceInString(tempString, toString(delimiters[i]), toString(lastDelimiter));

    return splitString(tempString, lastDelimiter);
}
示例#13
0
void HelpWidget::showDocForClassName(std::string classIdentifier) {
    current_ = classIdentifier;
    
    if (!helpEngine_) return;
    
    QString path("qthelp://org.inviwo/doc/docpage-%1.html");

    QUrl foundUrl = helpEngine_->findFile(QUrl(path.arg(QString::fromStdString(classIdentifier))));
    if (foundUrl.isValid()) {
        helpBrowser_->setSource(foundUrl);
        return;
    } 

    replaceInString(classIdentifier, ".", "_8");
    foundUrl = helpEngine_->findFile(QUrl(path.arg(QString::fromStdString(classIdentifier))));
    if (foundUrl.isValid()) {
        helpBrowser_->setSource(foundUrl);
        return;
    }

    helpBrowser_->setText(QString("No documentation available"));
}
示例#14
0
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++;
    }
}
示例#15
0
void ShaderManager::addShaderResource(std::string key, std::string src) {
    replaceInString(src, "NEWLINE", "\n");
    auto resource = std::make_shared<StringShaderResource>(key, src);
    ownedResources_.push_back(resource);
    shaderResources_[key] = std::weak_ptr<ShaderResource>(resource);
}