| 42 | // box to handle data extractions |
| 43 | |
| 44 | TaskPostExtraction::TaskPostExtraction(ViewProviderFemPostObject* view, QWidget* parent) |
| 45 | : TaskPostWidget(view, Gui::BitmapFactory().pixmap("FEM_PostHistogram"), QString(), parent) |
| 46 | { |
| 47 | // we load the python implementation, and try to get the widget from it, to add |
| 48 | // directly our widget |
| 49 | |
| 50 | setWindowTitle(tr("Data and Extractions")); |
| 51 | |
| 52 | Base::PyGILStateLocker lock; |
| 53 | |
| 54 | |
| 55 | try { |
| 56 | Py::Module mod(PyImport_ImportModule("femguiutils.data_extraction"), true); |
| 57 | if (mod.isNull()) { |
| 58 | Base::Console().error("Unable to import data extraction widget\n"); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | Py::Callable method(mod.getAttr(std::string("DataExtraction"))); |
| 63 | Py::Tuple args(1); |
| 64 | args.setItem(0, Py::Object(view->getPyObject())); |
| 65 | m_panel = Py::Object(method.apply(args)); |
| 66 | } |
| 67 | catch (Py::Exception&) { |
| 68 | Base::PyException e; // extract the Python error text |
| 69 | e.reportException(); |
| 70 | } |
| 71 | |
| 72 | if (m_panel.hasAttr(std::string("widget"))) { |
| 73 | Py::Object pywidget(m_panel.getAttr(std::string("widget"))); |
| 74 | |
| 75 | Gui::PythonWrapper wrap; |
| 76 | if (wrap.loadCoreModule()) { |
| 77 | if (auto* widget = qobject_cast<QWidget*>(wrap.toQObject(pywidget))) { |
| 78 | // finally we have the usable QWidget. Add to us! |
| 79 | |
| 80 | auto layout = new QVBoxLayout(); |
| 81 | layout->addWidget(widget); |
| 82 | setLayout(layout); |
| 83 | return; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // if we are here something went wrong! |
| 89 | Base::Console().error("Unable to import data extraction widget\n"); |
| 90 | }; |
| 91 | |
| 92 | TaskPostExtraction::~TaskPostExtraction() |
| 93 | { |
nothing calls this directly
no test coverage detected