/** * * @file PythonAgent.h * @brief PythonQt代理类 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 * */ #ifndef _PYTHONAGENT_H_ #define _PYTHONAGENT_H_ #include #include #include class QObject; class QWidget; class PythonQtScriptingConsole; namespace Python { /** * @brief PythonQt代理类 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ class PythonAgent { public: /** * @brief Construct a new Python Agent object * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ PythonAgent(); /** * @brief Destroy the Python Agent object * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ ~PythonAgent(); /** * @brief 向PythonQt中添加装饰器 * @param[i] obj 装饰器对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void addPyQtDecorator(QObject* obj); /** * @brief 向PythonQt中注册c++类 * @param[i] typeName 注册类名称 * @param[i] parentTypeName 父类名称 * @param[i] package 包体名称(包体为空时为private) * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void registerPyQtCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr); /** * @brief 执行脚本文件 * @param[i] file 脚本文件 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void submitScriptFile(const QString &ScriptFile); /** * @brief 执行脚本 * @param[i] Script 脚本 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void submitScript(const QString &Script); /** * @brief 执行脚本组 * @param[i] Scripts 脚本组 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void submitScript(const QStringList &Scripts); /** * @brief 历史脚本保存 * @param[i] filePath 文件路径 * @return true * @return false * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ bool saveScriptHistory(const QString &filePath); /** * @brief 获取python可视化界面 * @return QWidget* * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ QWidget* getPyWidget(); /** * @brief 判断注册的类名是否存在 * @param[i] typeName 注册类名称 * @return true 注册类存在 * @return false 注册类不存在 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ bool classIsExist(const char* typeName); private: /** * @brief 互斥锁对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ static QMutex m_mutex; /** * @brief PythonQt main模块对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ PythonQtObjectPtr m_mainModule; /** * @brief 注册的类名称合集 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ QStringList m_regClassNames = {}; /** * @brief python控制台 * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ PythonQtScriptingConsole* m_Console = nullptr; }; } #endif