#pragma once #include "WindowAppBlockStandardBase.h" // Goto工具的接口序号 #define GOTO_INPUT_INDX 0 #define GOTO_OUTPUT_INDX 1 /// /// Goto类型的工具功能块图 /// class WindowAppBlockGoto : public WindowAppBlockStandardBase { Q_OBJECT // 添加这一行,否则会出现警告:Warning: qobject_cast to QGraphicsItem will not work! Q_INTERFACES(QGraphicsItem) public: WindowAppBlockGoto(TOOL* pNewTool, POU* Pou, bool bShowOnly = false, QGraphicsObject*parent = nullptr); ~WindowAppBlockGoto(); // 绑定输出接口(注意此处是Output绑定到Tool中) void bindOutputInterface(const TOOL* pTool); // 设定本Item的自定义类型 enum { Type = ITEM_TYPE_GOTO }; int type() const { // 针对该 item 启用 qgraphicsitem_cast return Type; } // 是否bool输入接口取反 bool m_bNegation; protected slots: // 绘制Goto控件 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override; // 双击弹出配置对话框 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); protected: // 绘制功能块 void DrawBlock(QPainter* painter); // 更新矩形区域的尺寸 virtual void updateRect(); protected: // 输出接口的指针 _INTERFACE* m_pGotoInf; };