From 30820dce9792a7c496004a3392e8f92c0cc21631 Mon Sep 17 00:00:00 2001 From: Wim Leers Date: Sun, 9 Jan 2011 22:45:33 +0000 Subject: [PATCH] Finalized the BarTree visualization. Several minor improvements, leading to a better whole. --- Visualizer/BarTreeVisualization.cpp | 26 +++++++++++++++++++------- Visualizer/BarTreeVisualization.h | 4 +++- Visualizer/MainWindow.cpp | 1 - 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Visualizer/BarTreeVisualization.cpp b/Visualizer/BarTreeVisualization.cpp index 5f852b3..6ec167f 100644 --- a/Visualizer/BarTreeVisualization.cpp +++ b/Visualizer/BarTreeVisualization.cpp @@ -5,10 +5,13 @@ BarTreeVisualization::BarTreeVisualization(QWidget *parent) : QWebView(parent) { connect(this, SIGNAL(loadFinished(bool)), SLOT(loadHasFinished(bool))); // See explanation at BarTreeVisualization::timerEvent(). - startTimer(BARTREEVISUALIZATION_DATA_REFRESH_INTERVAL); + this->initialTimerID = this->startTimer(20); + this->firstRenderDone = false; // Load the visualization in the web view. this->load(QUrl("qrc:/BarTree/BarTree.html")); + this->nextEventSequence = NULL; + this->currentEventSequence = NULL; } void BarTreeVisualization::loadHasFinished(bool ok) { @@ -21,10 +24,6 @@ void BarTreeVisualization::eventSequenceChanged(QVector * events) { this->mutex.unlock(); } -void BarTreeVisualization::highlightEventLocation(int msecs, const QString & eventType) { - qDebug() << eventType; -} - /** * Periodically (BARTREEVISUALIZATION_DATA_REFRESH_INTERVAL intervals) poll * to see if there's a new event sequence to draw. We do this using polling @@ -37,6 +36,12 @@ void BarTreeVisualization::timerEvent(QTimerEvent *) { if (!this->pageHasLoaded) return; + if (!this->firstRenderDone) { + this->firstRenderDone = true; + this->killTimer(this->initialTimerID); + this->startTimer(BARTREEVISUALIZATION_DATA_REFRESH_INTERVAL); + } + // Make the next event sequence the current, if any, and send it to the // web view. if (this->nextEventSequence != NULL) { @@ -61,6 +66,8 @@ void BarTreeVisualization::sendEventSequenceToWebView() { QString inputType, eventType, modifier, details; QStringList detailsList; Event * event; + QTime timer; + timer.start(); // Count frequencies. foreach (event, *this->currentEventSequence) { @@ -217,9 +224,14 @@ void BarTreeVisualization::sendEventSequenceToWebView() { } data = level1; + qDebug() << "[BarTree] Calculated statistics in " << timer.elapsed() << "ms."; + timer.restart(); QString json = QxtJSON::stringify(data); - qDebug() << "Generated JSON:" << json; + qDebug() << "[BarTree] Generated JSON in " << timer.elapsed() << "ms."; + timer.restart(); this->mainFrame->evaluateJavaScript(QString("barTreeView.loadData(%1);").arg(json)); + this->update(); + qDebug() << "[BarTree] QWebView updated in " << timer.elapsed() << "ms."; } /** @@ -230,7 +242,7 @@ double BarTreeVisualization::calcTotalFreq(const QMap & frequencie static double totalFrequency; totalFrequency = 0; - foreach(key, frequencies.keys()) { + foreach (key, frequencies.keys()) { totalFrequency += frequencies[key]; } diff --git a/Visualizer/BarTreeVisualization.h b/Visualizer/BarTreeVisualization.h index ef53a73..666e44e 100644 --- a/Visualizer/BarTreeVisualization.h +++ b/Visualizer/BarTreeVisualization.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "Event.h" @@ -28,7 +29,6 @@ class BarTreeVisualization : public QWebView { public slots: void loadHasFinished(bool ok); void eventSequenceChanged(QVector * events); - void highlightEventLocation(int msecs, const QString & eventType); protected: void timerEvent(QTimerEvent *); @@ -40,6 +40,8 @@ public slots: QVector * nextEventSequence; QMutex mutex; bool pageHasLoaded; + bool firstRenderDone; + int initialTimerID; }; #endif // BARTREEVISUALIZATION_H diff --git a/Visualizer/MainWindow.cpp b/Visualizer/MainWindow.cpp index 2c83fb7..d8f4602 100644 --- a/Visualizer/MainWindow.cpp +++ b/Visualizer/MainWindow.cpp @@ -28,7 +28,6 @@ void MainWindow::createContent() { connect(timeLineVis, SIGNAL(timeSpanChanged(int, int)), database, SLOT(loadEvents(int, int))); connect(timeLineVis, SIGNAL(onEventShapeClicked(int, const QString &)), heatMapVis, SLOT(highlightEventLocation(int))); - connect(timeLineVis, SIGNAL(onEventShapeClicked(int, const QString &)), barTreeVis, SLOT(highlightEventLocation(int, const QString &))); vbox = new QVBoxLayout(); vbox->addWidget(heatMapVis);