/** * @brief Python脚本接口类声明 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ #ifndef _FITKPYTHONINTERFACE_H_ #define _FITKPYTHONINTERFACE_H_ #include "FITKPythonAPI.h" #include class QObject; class QWidget; class QStringList; class QMutex; namespace Python { class PythonAgent; /** * @brief Python脚本接口声明类,该类为单例类 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ class FITKPythonAPI FITKPythonInterface { public: /** * @brief 获取单例对象 * @return FITKPythonInterface* * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ static FITKPythonInterface* getInstance(); /** * @brief 添加PythonQt装饰器 * @param[i] obj 装饰器对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void addDecorator(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 registerCPPClass(const char* typeName, const char* parentTypeName = nullptr, const char* package = nullptr); /** * @brief python脚本请求 * @param[i] script python脚本 * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ void submit(const QString &script); /** * @brief python脚本请求 * @param[i] scripts Python脚本组 * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ void submit(const QStringList &scripts); /** * @brief python脚本文件请求 * @param[i] filePath 脚本文件 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ void submitFile(const QString &filePath); /** * @brief 保存历史脚本 * @param[i] filePath 文件路径 * @return true 保存成功 * @return false 保存失败 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ bool saveScriptHistory(const QString &filePath); /** * @brief 导入python包体,默认全部导入 * @param[i] package python包体 * @author BaGuijun (baguijun@163.com) * @date 2024-03-01 */ void importPython(const QString package = "*"); /** * @brief 获取python可视化界面 * @return QWidget* * @author BaGuijun (baguijun@163.com) * @date 2024-02-27 */ QWidget* getPyWidget(); private: /** * @brief Construct a new FITKPythonInterface object * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ FITKPythonInterface(); /** * @brief Destroy the FITKPythonInterface object * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ ~FITKPythonInterface(); private: /** * @brief 互斥锁对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-29 */ static QMutex m_mutex; /** * @brief 单例对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ static FITKPythonInterface* m_interface; /** * @brief PythonQt代理类对象 * @author BaGuijun (baguijun@163.com) * @date 2024-02-26 */ PythonAgent* m_pyAgent = nullptr; }; } #endif