WindowAppBlockGoto.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "WindowAppBlockStandardBase.h"
  3. // Goto工具的接口序号
  4. #define GOTO_INPUT_INDX 0
  5. #define GOTO_OUTPUT_INDX 1
  6. /// <summary>
  7. /// Goto类型的工具功能块图
  8. /// </summary>
  9. class WindowAppBlockGoto : public WindowAppBlockStandardBase
  10. {
  11. Q_OBJECT
  12. // 添加这一行,否则会出现警告:Warning: qobject_cast to QGraphicsItem will not work!
  13. Q_INTERFACES(QGraphicsItem)
  14. public:
  15. WindowAppBlockGoto(TOOL* pNewTool, POU* Pou, bool bShowOnly = false, QGraphicsObject*parent = nullptr);
  16. ~WindowAppBlockGoto();
  17. // 绑定输出接口(注意此处是Output绑定到Tool中)
  18. void bindOutputInterface(const TOOL* pTool);
  19. // 设定本Item的自定义类型
  20. enum { Type = ITEM_TYPE_GOTO };
  21. int type() const
  22. {
  23. // 针对该 item 启用 qgraphicsitem_cast
  24. return Type;
  25. }
  26. // 是否bool输入接口取反
  27. bool m_bNegation;
  28. protected slots:
  29. // 绘制Goto控件
  30. void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
  31. // 双击弹出配置对话框
  32. void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
  33. protected:
  34. // 绘制功能块
  35. void DrawBlock(QPainter* painter);
  36. // 更新矩形区域的尺寸
  37. virtual void updateRect();
  38. protected:
  39. // 输出接口的指针
  40. _INTERFACE* m_pGotoInf;
  41. };