| 54 | } |
| 55 | |
| 56 | void LissajousTrace::paint_back(QPainter &p, int left, int right, QColor fore, QColor back) |
| 57 | { |
| 58 | assert(_view); |
| 59 | |
| 60 | fore.setAlpha(view::View::BackAlpha); |
| 61 | const int height = _viewport->height(); |
| 62 | const int width = right - left; |
| 63 | const int square = min(width, height); |
| 64 | const QPoint leftTop = QPoint(width > square ? (width-square)/2 : 0, |
| 65 | height > square ? (height-square)/2 : 0); |
| 66 | _border = QRect(leftTop.x(), leftTop.y(), square, square); |
| 67 | |
| 68 | QPen solidPen(fore); |
| 69 | solidPen.setStyle(Qt::SolidLine); |
| 70 | p.setPen(solidPen); |
| 71 | p.setBrush(back.black() > 0x80 ? back.darker() : back.lighter()); |
| 72 | p.drawRect(_border); |
| 73 | |
| 74 | QPen dashPen(fore); |
| 75 | dashPen.setStyle(Qt::DashLine); |
| 76 | p.setPen(dashPen); |
| 77 | |
| 78 | const double spanY =square / DIV_NUM; |
| 79 | |
| 80 | for (int i = 1; i < DIV_NUM; i++) { |
| 81 | const double posY = _border.top() + spanY * i; |
| 82 | p.drawLine(_border.left(), posY, _border.right(), posY); |
| 83 | } |
| 84 | |
| 85 | const double spanX = square / DIV_NUM; |
| 86 | |
| 87 | for (int i = 1; i < DIV_NUM; i++) { |
| 88 | const double posX = _border.left() + spanX * i; |
| 89 | p.drawLine(posX, _border.top(), posX, _border.bottom()); |
| 90 | } |
| 91 | |
| 92 | fore.setAlpha(view::View::ForeAlpha); |
| 93 | p.setPen(fore); |
| 94 | p.drawText(_border.marginsRemoved(QMargins(10, 10, 10, 10)), |
| 95 | L_S(STR_PAGE_DLG, S_ID(IDS_DLG_LISSAJOUS_FIGURE), "Lissajous Figure"), Qt::AlignTop | Qt::AlignLeft); |
| 96 | |
| 97 | _view->set_back(true); |
| 98 | } |
| 99 | |
| 100 | void LissajousTrace::paint_mid(QPainter &p, int left, int right, QColor fore, QColor back) |
| 101 | { |