From 01f8b14e647efc20e59d23f9a2f73f3d3bffd622 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Mon, 25 Oct 2021 12:06:58 +0200 Subject: [PATCH] Navigate to tracetime when analysis plot is doubleclicked --- DRAMSys/traceAnalyzer/tracefiletab.cpp | 33 ++++++++++++++++++++++++++ DRAMSys/traceAnalyzer/tracefiletab.h | 7 ++++++ 2 files changed, 40 insertions(+) diff --git a/DRAMSys/traceAnalyzer/tracefiletab.cpp b/DRAMSys/traceAnalyzer/tracefiletab.cpp index e6368c31..0db0d23c 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.cpp +++ b/DRAMSys/traceAnalyzer/tracefiletab.cpp @@ -41,10 +41,12 @@ #include "businessObjects/commentmodel.h" #include "businessObjects/configmodels.h" #include "businessObjects/pythoncaller.h" +#include "businessObjects/tracetime.h" #include "presentation/traceselector.h" #include "qmessagebox.h" #include "queryeditor.h" #include "qwt_legend.h" +#include "qwt_plot_canvas.h" #include "qwt_plot_curve.h" #include "qwt_plot_histogram.h" #include "qwt_plot_layout.h" @@ -53,6 +55,7 @@ #include "qwt_scale_draw.h" #include "qwt_scale_widget.h" #include "ui_tracefiletab.h" + #include #include #include @@ -139,6 +142,10 @@ void TraceFileTab::initNavigatorAndItsDependentWidgets(QString path) ui->selectedTransactionTree->init(navigator); //ui->debugMessages->init(navigator,ui->traceplot); + + ui->bandwidthPlot->canvas()->installEventFilter(this); + ui->powerPlot->canvas()->installEventFilter(this); + ui->bufferPlot->canvas()->installEventFilter(this); } void TraceFileTab::setUpFileWatcher(QString path) @@ -298,6 +305,32 @@ void TraceFileTab::on_latencyTreeView_doubleClicked(const QModelIndex &index) } } +bool TraceFileTab::eventFilter(QObject *object, QEvent *event) +{ + if (auto canvas = qobject_cast(object)) + { + if (event->type() == QEvent::MouseButtonDblClick) + { + QMouseEvent *mouseEvent = static_cast(event); + + if (mouseEvent->button() != Qt::LeftButton) + return false; + + QwtPlot *plot = canvas->plot(); + + double realTime = plot->invTransform(QwtPlot::xBottom, mouseEvent->x()); + + // Convert from seconds to picoseconds + traceTime time = realTime * 1000 * 1000 * 1000 * 1000; + + navigator->navigateToTime(time); + return true; + } + } + + return QWidget::eventFilter(object, event); +} + void TraceFileTab::on_startLatencyAnalysis_clicked() { // Setup Database: diff --git a/DRAMSys/traceAnalyzer/tracefiletab.h b/DRAMSys/traceAnalyzer/tracefiletab.h index fb4c9392..4fafc317 100644 --- a/DRAMSys/traceAnalyzer/tracefiletab.h +++ b/DRAMSys/traceAnalyzer/tracefiletab.h @@ -84,6 +84,13 @@ public: protected: void closeEvent(QCloseEvent *event) override; + /** + * Used to respond to double click events in the analysis + * plots to navigate quickly to the corresponding tracetime. + * May be moved into a seperate class at a later point in time. + */ + bool eventFilter(QObject *object, QEvent *event) override; + private: QString path; Ui::TraceFileTab *ui;