MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / TaskPostExtraction

Method TaskPostExtraction

src/Mod/Fem/Gui/TaskPostExtraction.cpp:44–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42// box to handle data extractions
43
44TaskPostExtraction::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
92TaskPostExtraction::~TaskPostExtraction()
93{

Callers

nothing calls this directly

Calls 11

pixmapMethod · 0.80
loadCoreModuleMethod · 0.80
toQObjectMethod · 0.80
QStringClass · 0.50
ObjectClass · 0.50
isNullMethod · 0.45
errorMethod · 0.45
getPyObjectMethod · 0.45
applyMethod · 0.45
reportExceptionMethod · 0.45
addWidgetMethod · 0.45

Tested by

no test coverage detected