| 17 | } |
| 18 | |
| 19 | void |
| 20 | Square::paint(QPainter& painter) { |
| 21 | |
| 22 | painter.setBrush(brush_); |
| 23 | painter.setPen(pen_); |
| 24 | |
| 25 | std::vector<QPoint> plist = dynamics_->getPositionList(); |
| 26 | std::vector<QPoint>::iterator idx = plist.begin(); |
| 27 | QBrush black( QColor(0x33, 0x33, 0x33), Qt::SolidPattern); |
| 28 | QBrush white( QColor(0xFF, 0xFF, 0xFF), Qt::SolidPattern); |
| 29 | QBrush brush; |
| 30 | |
| 31 | while (idx != plist.end()) { |
| 32 | painter.drawRect(idx->x() - bounds_.width()/2, |
| 33 | idx->y() - bounds_.height()/2, |
| 34 | bounds_.width(), |
| 35 | bounds_.height()); |
| 36 | if (targeted_) |
| 37 | brush = black; |
| 38 | else |
| 39 | brush = white; |
| 40 | |
| 41 | painter.setBrush(brush); |
| 42 | int X0 = idx->x(); |
| 43 | int Y0 = idx->y(); |
| 44 | int W = bounds_.width()/3; |
| 45 | int H = bounds_.height()/3; |
| 46 | painter.setBrush(brush); |
| 47 | painter.drawRect(X0 - W/2, |
| 48 | Y0 - H/2, |
| 49 | W, |
| 50 | H); |
| 51 | painter.setBrush(brush_); |
| 52 | |
| 53 | ++idx; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | Square::~Square() { |
| 58 | } |