| 4635 | } |
| 4636 | |
| 4637 | void CartesianPlotPrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) { |
| 4638 | if (!isVisible() || m_printing) |
| 4639 | return; |
| 4640 | |
| 4641 | if ((mouseMode == CartesianPlot::MouseMode::ZoomXSelection || mouseMode == CartesianPlot::MouseMode::ZoomYSelection) && (!m_selectionBandIsShown) |
| 4642 | && m_insideDataRect) { |
| 4643 | painter->setPen(zoomSelectPen); |
| 4644 | painter->drawLine(m_selectionStartLine); |
| 4645 | } else if (m_selectionBandIsShown) { |
| 4646 | QPointF selectionStart = m_selectionStart; |
| 4647 | if (m_selectionStart.x() > dataRect.right()) |
| 4648 | selectionStart.setX(dataRect.right()); |
| 4649 | if (m_selectionStart.x() < dataRect.left()) |
| 4650 | selectionStart.setX(dataRect.left()); |
| 4651 | if (m_selectionStart.y() > dataRect.bottom()) |
| 4652 | selectionStart.setY(dataRect.bottom()); |
| 4653 | if (m_selectionStart.y() < dataRect.top()) |
| 4654 | selectionStart.setY(dataRect.top()); |
| 4655 | |
| 4656 | QPointF selectionEnd = m_selectionEnd; |
| 4657 | if (m_selectionEnd.x() > dataRect.right()) |
| 4658 | selectionEnd.setX(dataRect.right()); |
| 4659 | if (m_selectionEnd.x() < dataRect.left()) |
| 4660 | selectionEnd.setX(dataRect.left()); |
| 4661 | if (m_selectionEnd.y() > dataRect.bottom()) |
| 4662 | selectionEnd.setY(dataRect.bottom()); |
| 4663 | if (m_selectionEnd.y() < dataRect.top()) |
| 4664 | selectionEnd.setY(dataRect.top()); |
| 4665 | painter->save(); |
| 4666 | painter->setPen(zoomSelectPen); |
| 4667 | painter->drawRect(QRectF(selectionStart, selectionEnd)); |
| 4668 | painter->setBrush(Qt::blue); |
| 4669 | painter->setOpacity(0.2); |
| 4670 | painter->drawRect(QRectF(selectionStart, selectionEnd)); |
| 4671 | painter->restore(); |
| 4672 | } else if (mouseMode == CartesianPlot::MouseMode::Crosshair) { |
| 4673 | painter->setPen(crossHairPen); |
| 4674 | |
| 4675 | // horizontal line |
| 4676 | double x1 = dataRect.left(); |
| 4677 | double y1 = m_crosshairPos.y(); |
| 4678 | double x2 = dataRect.right(); |
| 4679 | double y2 = y1; |
| 4680 | painter->drawLine(x1, y1, x2, y2); |
| 4681 | |
| 4682 | // vertical line |
| 4683 | x1 = m_crosshairPos.x(); |
| 4684 | y1 = dataRect.bottom(); |
| 4685 | x2 = x1; |
| 4686 | y2 = dataRect.top(); |
| 4687 | painter->drawLine(x1, y1, x2, y2); |
| 4688 | } |
| 4689 | |
| 4690 | // draw cursor lines if available |
| 4691 | if (cursor0Enable || cursor1Enable) { |
| 4692 | painter->save(); |
| 4693 | painter->setPen(cursorLine->pen()); |
| 4694 | painter->setOpacity(cursorLine->opacity()); |