CPathItem.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "CPathItem.h"
  2. #include <QPen>
  3. #include <QPainter>
  4. CPathItem::CPathItem(QGraphicsItem *parent) : QGraphicsPathItem(parent)
  5. {
  6. applySettings();
  7. }
  8. int CPathItem::lineWidth() const
  9. {
  10. return m_lineWidth;
  11. }
  12. void CPathItem::setLineWidth(int w)
  13. {
  14. m_lineWidth = w;
  15. applySettings();
  16. }
  17. QColor CPathItem::normaLineColor() const
  18. {
  19. return m_normalLineColor;
  20. }
  21. void CPathItem::setNormalLineColor(QColor c)
  22. {
  23. m_normalLineColor = c;
  24. applySettings();
  25. }
  26. QColor CPathItem::highlightLineColor() const
  27. {
  28. return m_highlightLineColor;
  29. }
  30. void CPathItem::setHighlightLineColor(QColor c)
  31. {
  32. m_highlightLineColor = c;
  33. applySettings();
  34. }
  35. QColor CPathItem::normalFillColor() const
  36. {
  37. return m_normalFillColor;
  38. }
  39. void CPathItem::setNormalFillColor(QColor c)
  40. {
  41. m_normalFillColor = c;
  42. applySettings();
  43. }
  44. QColor CPathItem::highlightFillColor() const
  45. {
  46. return m_highlightFillColor;
  47. }
  48. void CPathItem::setHighlightFillColor(QColor c)
  49. {
  50. m_highlightFillColor = c;
  51. applySettings();
  52. }
  53. bool CPathItem::highlighted() const
  54. {
  55. return m_highlighted;
  56. }
  57. void CPathItem::setHighlighted(bool h)
  58. {
  59. m_highlighted = h;
  60. applySettings();
  61. }
  62. void CPathItem::applySettings()
  63. {
  64. QPen pen = this->pen();
  65. pen.setWidth(m_lineWidth);
  66. pen.setColor(m_highlighted ? m_highlightLineColor : m_normalLineColor);
  67. setPen(pen);
  68. setBrush(m_highlighted ? m_highlightFillColor : m_normalFillColor);
  69. }