| 835 | } |
| 836 | |
| 837 | PyObject* Gui::ApplicationPy::sSetActiveDocument(PyObject* /*self*/, PyObject* args) |
| 838 | { |
| 839 | Document* pcDoc = nullptr; |
| 840 | |
| 841 | do { |
| 842 | char* pstr = nullptr; |
| 843 | if (PyArg_ParseTuple(args, "s", &pstr)) { |
| 844 | pcDoc = Application::Instance->getDocument(pstr); |
| 845 | if (!pcDoc) { |
| 846 | PyErr_Format(PyExc_NameError, "Unknown document '%s'", pstr); |
| 847 | return nullptr; |
| 848 | } |
| 849 | break; |
| 850 | } |
| 851 | |
| 852 | PyErr_Clear(); |
| 853 | PyObject* doc = nullptr; |
| 854 | if (PyArg_ParseTuple(args, "O!", &(App::DocumentPy::Type), &doc)) { |
| 855 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast) |
| 856 | pcDoc = Application::Instance->getDocument( |
| 857 | static_cast<App::DocumentPy*>(doc)->getDocumentPtr() |
| 858 | ); |
| 859 | if (!pcDoc) { |
| 860 | PyErr_Format(PyExc_KeyError, "Unknown document instance"); |
| 861 | return nullptr; |
| 862 | } |
| 863 | break; |
| 864 | } |
| 865 | } while (false); |
| 866 | |
| 867 | if (!pcDoc) { |
| 868 | PyErr_SetString(PyExc_TypeError, "Either string or App.Document expected"); |
| 869 | return nullptr; |
| 870 | } |
| 871 | |
| 872 | requirePythonMainThread("FreeCADGui.setActiveDocument"); |
| 873 | |
| 874 | if (Application::Instance->activeDocument() != pcDoc) { |
| 875 | Gui::MDIView* view = pcDoc->getActiveView(); |
| 876 | getMainWindow()->setActiveWindow(view); |
| 877 | } |
| 878 | |
| 879 | Py_Return; |
| 880 | } |
| 881 | |
| 882 | PyObject* ApplicationPy::sGetDocument(PyObject* /*self*/, PyObject* args) |
| 883 | { |
nothing calls this directly
no test coverage detected