You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
732 B

  1. #include "light.h"
  2. #include <QPainter>
  3. #include <QStyleOptionGraphicsItem>
  4. Light::Light(const QString &type) : Item(type)
  5. {
  6. }
  7. QRectF Light::boundingRect() const
  8. {
  9. return QRectF(0, 0, 50, 50);
  10. }
  11. void Light::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
  12. {
  13. painter->setRenderHint(QPainter::Antialiasing);
  14. if (type_ == "指示灯") {
  15. painter->drawEllipse(0,0,50,50);
  16. }
  17. if (option->state & QStyle::State_Selected) {
  18. QPen pen(Qt::DashLine);
  19. pen.setColor(Qt::blue);
  20. pen.setWidth(2);
  21. painter->setPen(pen);
  22. painter->setBrush(Qt::NoBrush);
  23. painter->drawRect(boundingRect());
  24. }
  25. }