PyObject* py_snapshot(PyObject* self, PyObject* args) { static PythonParameterParser tester(1); std::string filename, canvasName = ""; if (tester.parse(args, filename, canvasName)== -1) { return nullptr; } CanvasProcessor* canvas = nullptr; if (canvasName.size() != 0) { canvas = dynamic_cast<CanvasProcessor*>( InviwoApplication::getPtr()->getProcessorNetwork()->getProcessorByIdentifier( canvasName)); } else { if (InviwoApplication::getPtr() && InviwoApplication::getPtr()->getProcessorNetwork()) { std::vector<CanvasProcessor*> canvases = InviwoApplication::getPtr() ->getProcessorNetwork() ->getProcessorsByType<CanvasProcessor>(); if (canvases.size() != 0) canvas = InviwoApplication::getPtr() ->getProcessorNetwork() ->getProcessorsByType<CanvasProcessor>()[0]; } } if (!canvas) { PyErr_SetString(PyExc_TypeError, "snapshot() no canvas found"); return nullptr; } canvas->saveImageLayer(filename.c_str()); Py_RETURN_NONE; }
PyObject* py_snapshot(PyObject* /*self*/, PyObject* args) { static PySnapshotMethod p; if (!p.testParams(args)) return nullptr; std::string canvasName = ""; std::string filename = std::string(PyValueParser::parse<std::string>(PyTuple_GetItem(args, 0))); if (PyTuple_Size(args) == 2) { canvasName = std::string(PyValueParser::parse<std::string>(PyTuple_GetItem(args, 1))); } CanvasProcessor* canvas = nullptr; if (canvasName.size() != 0) { canvas = dynamic_cast<CanvasProcessor*>( InviwoApplication::getPtr()->getProcessorNetwork()->getProcessorByIdentifier(canvasName)); } else { if (InviwoApplication::getPtr() && InviwoApplication::getPtr()->getProcessorNetwork()) { std::vector<CanvasProcessor*> canvases = InviwoApplication::getPtr() ->getProcessorNetwork() ->getProcessorsByType<CanvasProcessor>(); if (canvases.size() != 0) canvas = InviwoApplication::getPtr() ->getProcessorNetwork() ->getProcessorsByType<CanvasProcessor>()[0]; } } if (!canvas) { PyErr_SetString(PyExc_TypeError, "snapshot() no canvas found"); return nullptr; } canvas->saveImageLayer(filename.c_str()); Py_RETURN_NONE; }