CPathItem.cpp 874 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "CPathItem.h"
  2. #include <QPen>
  3. CPathItem::CPathItem(QGraphicsItem *parent) : QGraphicsPathItem(parent) { }
  4. int CPathItem::lineWidth() const
  5. {
  6. QPen pen = this->pen();
  7. return pen.width();
  8. }
  9. void CPathItem::setLineWidth(int width)
  10. {
  11. QPen pen = this->pen();
  12. pen.setWidth(width);
  13. setPen(pen);
  14. }
  15. QColor CPathItem::lineColor() const
  16. {
  17. QPen pen = this->pen();
  18. return pen.color();
  19. }
  20. void CPathItem::setLineColor(QColor color)
  21. {
  22. QPen pen = this->pen();
  23. pen.setColor(color);
  24. setPen(pen);
  25. }
  26. QColor CPathItem::fillColor() const
  27. {
  28. QBrush brush = this->brush();
  29. return brush.color();
  30. }
  31. void CPathItem::setFillColor(QColor color)
  32. {
  33. setBrush(color);
  34. }
  35. void CPathItem::setHighlighted(bool highlighted)
  36. {
  37. setLineColor(highlighted ? Qt::blue : Qt::transparent);
  38. setFillColor(highlighted ? Qt::gray : Qt::white);
  39. }