GraphicsPathItem.h 839 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "preheader.h"
  3. #include "GraphicsItem.h"
  4. class GraphicsPathItem : public GraphicsItem
  5. {
  6. public:
  7. GraphicsPathItem(const QPainterPath &painterPath ,GraphicsItem * parent);
  8. void setPath(QPainterPath path_in)
  9. {
  10. prepareGeometryChange();
  11. //_path = path_in;
  12. // _boundingRect =_path.boundingRect();
  13. update();
  14. }
  15. QRectF boundingRect() const;
  16. QPainterPath shape() const;
  17. virtual void resizeTo(SizeHandleRect::Direction dir, const QPointF & point );
  18. virtual QRectF rect() const { return QRectF(-m_width / 2 , -m_height / 2 , m_width,m_height) ;}
  19. protected:
  20. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
  21. protected:
  22. qreal m_width;
  23. qreal m_height;
  24. mutable QRectF _boundingRect;
  25. QPainterPath _path;
  26. };