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

Method PythonGroupCommand

src/Gui/Command.cpp:1658–1698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1656//===========================================================================
1657
1658PythonGroupCommand::PythonGroupCommand(const char* name, PyObject* pcPyCommand)
1659 : Command(StringCache::New(name))
1660 , _pcPyCommand(pcPyCommand)
1661{
1662 sGroup = "Python";
1663
1664 Py_INCREF(_pcPyCommand);
1665
1666 // call the method "GetResources()" of the command object
1667 _pcPyResource = Interpreter().runMethodObject(_pcPyCommand, "GetResources");
1668 // check if the "GetResources()" method returns a Dict object
1669 if (!PyDict_Check(_pcPyResource)) {
1670 throw Base::TypeError(
1671 "PythonGroupCommand::PythonGroupCommand(): Method GetResources() of the Python "
1672 "command object returns the wrong type (has to be dict)"
1673 );
1674 }
1675
1676 // check for command type
1677 std::string cmdType = getResource("CmdType");
1678 if (!cmdType.empty()) {
1679 int type = 0;
1680 if (cmdType.find("AlterDoc") != std::string::npos) {
1681 type += int(AlterDoc);
1682 }
1683 if (cmdType.find("Alter3DView") != std::string::npos) {
1684 type += int(Alter3DView);
1685 }
1686 if (cmdType.find("AlterSelection") != std::string::npos) {
1687 type += int(AlterSelection);
1688 }
1689 if (cmdType.find("ForEdit") != std::string::npos) {
1690 type += int(ForEdit);
1691 }
1692 eType = type;
1693 }
1694
1695 auto& rcCmdMgr = Gui::Application::Instance->commandManager();
1696
1697 connPyCmdInitialized = rcCmdMgr.signalPyCmdInitialized.connect([this]() { this->onActionInit(); });
1698}
1699
1700PythonGroupCommand::~PythonGroupCommand()
1701{

Callers

nothing calls this directly

Calls 5

runMethodObjectMethod · 0.80
onActionInitMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected