Esempio n. 1
0
void PyInviwo::initPythonCInterface(Python3Module* module) {
    if (isInit_) return;

    isInit_ = true;
    LogInfo("Python version: " + toString(Py_GetVersion()));
    wchar_t programName[] = L"PyInviwo";
    Py_SetProgramName(programName);

    Py_InitializeEx(false);

    if (!Py_IsInitialized()) {
        LogError("Python is not Initialized");
        return;
    }

    PyEval_InitThreads();
    importModule("builtins");
    importModule("sys");

    dict_ = PyImport_GetModuleDict();
    registerPyModule(&Inviwo_Internals_Module_Def, "inviwo_internal");
    registerPyModule(&Inviwo_Module_Def, "inviwo");

    addModulePath(module->getPath() + "/scripts");
    initOutputRedirector(module);
}
Esempio n. 2
0
void PyInviwo::initDefaultInterfaces() {
    inviwoInternalPyModule_ = new PyModule("inviwo_internal");
    inviwoInternalPyModule_->addMethod(new PyStdOutCatcher());

    inviwoPyModule_ = new PyModule("inviwo");
    inviwoPyModule_->addMethod(new PySetPropertyValueMethod());
    inviwoPyModule_->addMethod(new PySetPropertyMaxValueMethod());
    inviwoPyModule_->addMethod(new PySetPropertyMinValueMethod());
    inviwoPyModule_->addMethod(new PyGetPropertyValueMethod());
    inviwoPyModule_->addMethod(new PyGetPropertyMaxValueMethod());
    inviwoPyModule_->addMethod(new PyGetPropertyMinValueMethod());
    inviwoPyModule_->addMethod(new PyClickButtonMethod());
    inviwoPyModule_->addMethod(new PySetCameraFocusMethod());
    inviwoPyModule_->addMethod(new PySetCameraUpMethod());
    inviwoPyModule_->addMethod(new PySetCameraPosMethod());
    inviwoPyModule_->addMethod(new PyListPropertiesMethod());
    inviwoPyModule_->addMethod(new PyListProcessorsMethod());
    inviwoPyModule_->addMethod(new PyCanvasCountMethod());
    inviwoPyModule_->addMethod(new PyResizeCanvasMethod());
    inviwoPyModule_->addMethod(new PyWaitMethod());
    inviwoPyModule_->addMethod(new PySnapshotMethod());
    inviwoPyModule_->addMethod(new PySnapshotCanvasMethod());
    inviwoPyModule_->addMethod(new PyGetBasePathMethod());
    inviwoPyModule_->addMethod(new PyGetWorkspaceSavePathMethod());
    inviwoPyModule_->addMethod(new PyGetVolumePathMethod());
    inviwoPyModule_->addMethod(new PyGetDataPathMethod());
    inviwoPyModule_->addMethod(new PyGetImagePathMethod());
    inviwoPyModule_->addMethod(new PyGetModulePathMethod());
    inviwoPyModule_->addMethod(new PyGetTransferFunctionPath());
    inviwoPyModule_->addMethod(new PyGetMemoryUsage());
    inviwoPyModule_->addMethod(new PyClearResourceManage());
    inviwoPyModule_->addMethod(new PyEnableEvaluation());
    inviwoPyModule_->addMethod(new PyDisableEvaluation());
    inviwoPyModule_->addMethod(new PySaveTransferFunction());
    inviwoPyModule_->addMethod(new PyLoadTransferFunction());
    inviwoPyModule_->addMethod(new PyClearTransferfunction());
    inviwoPyModule_->addMethod(new PyAddTransferFunction());

    registerPyModule(inviwoPyModule_);
    registerPyModule(inviwoInternalPyModule_);
}