| 901 | } |
| 902 | |
| 903 | bool PlotWidget::eventFilter(QObject* obj, QEvent* event) { |
| 904 | if (PlotWidgetBase::eventFilter(obj, event)) { |
| 905 | return true; |
| 906 | } |
| 907 | if (event->type() == QEvent::Destroy || obj != qwtPlot()->canvas()) { |
| 908 | return false; |
| 909 | } |
| 910 | |
| 911 | if (event->type() == QEvent::MouseButtonPress) { |
| 912 | auto* mouse_event = static_cast<QMouseEvent*>(event); |
| 913 | if (mouse_event->button() == Qt::LeftButton && mouse_event->modifiers() == Qt::ShiftModifier && !isXYPlot()) { |
| 914 | const QwtScaleMap x_map = qwtPlot()->canvasMap(QwtPlot::xBottom); |
| 915 | const QwtScaleMap y_map = qwtPlot()->canvasMap(QwtPlot::yLeft); |
| 916 | emit trackerMoved( |
| 917 | QPointF(x_map.invTransform(mouse_event->pos().x()), y_map.invTransform(mouse_event->pos().y()))); |
| 918 | return true; |
| 919 | } |
| 920 | if (mouse_event->button() == Qt::RightButton && mouse_event->modifiers() == Qt::NoModifier) { |
| 921 | canvasContextMenuTriggered(mouse_event->pos()); |
| 922 | return true; |
| 923 | } |
| 924 | } |
| 925 | if (event->type() == QEvent::MouseMove) { |
| 926 | auto* mouse_event = static_cast<QMouseEvent*>(event); |
| 927 | if (mouse_event->buttons() == Qt::LeftButton && mouse_event->modifiers() == Qt::ShiftModifier && !isXYPlot()) { |
| 928 | const QwtScaleMap x_map = qwtPlot()->canvasMap(QwtPlot::xBottom); |
| 929 | const QwtScaleMap y_map = qwtPlot()->canvasMap(QwtPlot::yLeft); |
| 930 | emit trackerMoved( |
| 931 | QPointF(x_map.invTransform(mouse_event->pos().x()), y_map.invTransform(mouse_event->pos().y()))); |
| 932 | return true; |
| 933 | } |
| 934 | // Mouse hover inspector (buttonShowpoint). Doesn't consume the event so |
| 935 | // panning/zooming/etc keep working underneath. Gate by show_points_ so |
| 936 | // the hot path stays a single bool read when the toggle is off. |
| 937 | if (show_points_) { |
| 938 | showPointValues(mouse_event->pos()); |
| 939 | } |
| 940 | } |
| 941 | if (event->type() == QEvent::Leave && obj == qwtPlot()->canvas()) { |
| 942 | if (show_point_marker_ != nullptr && show_point_marker_->isVisible()) { |
| 943 | show_point_marker_->setVisible(false); |
| 944 | show_point_text_->setVisible(false); |
| 945 | replot(); |
| 946 | } |
| 947 | } |
| 948 | return false; |
| 949 | } |
| 950 | |
| 951 | void PlotWidget::onExternallyResized(const QRectF& rect) { |
| 952 | if (curveList().empty()) { |