CPathItem.cpp 1.5 KB

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