diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f9d0e18..0c24cfe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,6 +36,8 @@ qt5_wrap_ui(ui_mainwindow.h mainwindow.ui) qt5_wrap_ui(ui_metricrangedialog.h metricrangedialog.ui) qt5_wrap_ui(ui_visoptionsdialog.h visoptionsdialog.ui) qt5_wrap_ui(ui_taskpropertywindow.h taskpropertywindow.ui) +qt5_wrap_ui(ui_filterdialog.h filterdialog.ui) +qt5_wrap_ui(ui_addfunctionsdialog.h addfunctionsdialog.ui) # Sources and UI Files set(Ravel_SOURCES @@ -73,6 +75,8 @@ set(Ravel_SOURCES primaryentitygroup.cpp metrics.cpp taskpropertywindow.cpp + filterdialog.cpp + addfunctionsdialog.cpp ${ADDED_SOURCES} ) @@ -114,6 +118,8 @@ set(Ravel_HEADERS primaryentitygroup.h metrics.h taskpropertywindow.h + filterdialog.h + addfunctionsdialog.h ${ADDED_HEADERS} ) @@ -122,6 +128,8 @@ set(Ravel_UIC ui_visoptionsdialog.h ui_metricrangedialog.h ui_taskpropertywindow.h + ui_filterdialog.h + ui_addfunctionsdialog.h ) # Build Target diff --git a/src/Ravel.pro b/src/Ravel.pro index 48084e3..c301235 100644 --- a/src/Ravel.pro +++ b/src/Ravel.pro @@ -62,7 +62,9 @@ SOURCES += main.cpp \ primaryentitygroup.cpp \ entitygroup.cpp \ importfunctor.cpp \ - taskpropertywindow.cpp + taskpropertywindow.cpp \ + filterdialog.cpp \ + addfunctionsdialog.cpp HEADERS += \ trace.h \ @@ -99,13 +101,17 @@ HEADERS += \ entitygroup.h \ ravelutils.h \ importfunctor.h \ - taskpropertywindow.h + taskpropertywindow.h \ + filterdialog.h \ + addfunctionsdialog.h FORMS += \ mainwindow.ui \ visoptionsdialog.ui \ metricrangedialog.ui \ - taskpropertywindow.ui + taskpropertywindow.ui \ + filterdialog.ui \ + addfunctionsdialog.ui HOME = $$system(echo $HOME) diff --git a/src/addfunctionsdialog.cpp b/src/addfunctionsdialog.cpp new file mode 100644 index 0000000..34557d4 --- /dev/null +++ b/src/addfunctionsdialog.cpp @@ -0,0 +1,398 @@ +#include "addfunctionsdialog.h" +#include "ui_addfunctionsdialog.h" +#include "trace.h" +#include "function.h" +#include "event.h" +#include "ravelutils.h" + +AddFunctionsDialog::AddFunctionsDialog(QWidget *parent, QList _traces, QSet _filterEvents) : + QDialog(parent), + traces(_traces), + start(0), + end(0), + duration(0), + option(0), + allClicked(false), + matchingFunctions(QMap()), + matchingEvents(QList()), + selectedEvents(_filterEvents), + deletedEvents(QSet()), + ui(new Ui::AddFunctionsDialog) +{ + ui->setupUi(this); + ui->filterTable->setColumnWidth(0, 50); + ui->filterStartLabel->setVisible(false); + ui->filterStart->setVisible(false); + ui->filterEndLabel->setVisible(false); + ui->filterEnd->setVisible(false); + ui->filterDurationLabel->setVisible(false); + ui->filterDuration->setVisible(false); + ui->filterSec->setVisible(false); + ui->filterMSec->setVisible(false); + ui->filterNSec->setVisible(false); + + ui->filterRadioGroup->setId(ui->filterSec, 0); + ui->filterRadioGroup->setId(ui->filterMSec, 1); + ui->filterRadioGroup->setId(ui->filterNSec, 2); + + connect(ui->filterOptions, SIGNAL(currentIndexChanged(int)), this, SLOT(switchVisibility(int))); + connect(ui->filterButton, SIGNAL(clicked()), this, SLOT(captureInput())); + connect(ui->selectAllFunctions, SIGNAL(clicked(bool)), this, SLOT(selectAll(bool))); + connect(ui->filterTable, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(addToSelectedEvents(QTableWidgetItem*))); + connect(ui->filterStart, SIGNAL(valueChanged(double)), this, SLOT(captureStartTime(double))); + connect(ui->filterEnd, SIGNAL(valueChanged(double)), this, SLOT(captureEndTime(double))); + connect(ui->filterDuration, SIGNAL(valueChanged(double)), this, SLOT(captureDuration(double))); + connect(ui->filterRadioGroup, SIGNAL(buttonClicked(int)), this, SLOT(captureOption(int))); +} + +AddFunctionsDialog::~AddFunctionsDialog() +{ + delete ui; +} + +QSet AddFunctionsDialog::getSelectedEvents() +{ + return this->selectedEvents; +} + +QSet AddFunctionsDialog::getDeletedEvents() +{ + return this->deletedEvents; +} + +void AddFunctionsDialog::switchVisibility(int option) +{ + switch(option) + { + case 0: + case 1: ui->filterStringLabel->setVisible(true); + ui->filterString->setVisible(true); + ui->filterButton->setVisible(true); + ui->filterStartLabel->setVisible(false); + ui->filterStart->setVisible(false); + ui->filterEndLabel->setVisible(false); + ui->filterEnd->setVisible(false); + ui->filterDurationLabel->setVisible(false); + ui->filterDuration->setVisible(false); + ui->filterSec->setVisible(false); + ui->filterMSec->setVisible(false); + ui->filterNSec->setVisible(false); + break; + case 2: ui->filterStringLabel->setVisible(false); + ui->filterString->setVisible(false); + ui->filterButton->setVisible(false); + ui->filterStartLabel->setVisible(true); + ui->filterStart->setVisible(true); + ui->filterEndLabel->setVisible(true); + ui->filterEnd->setVisible(true); + ui->filterDurationLabel->setVisible(false); + ui->filterDuration->setVisible(false); + ui->filterSec->setVisible(false); + ui->filterMSec->setVisible(false); + ui->filterNSec->setVisible(false); + break; + case 3: ui->filterStringLabel->setVisible(false); + ui->filterString->setVisible(false); + ui->filterButton->setVisible(true); + ui->filterStartLabel->setVisible(false); + ui->filterStart->setVisible(false); + ui->filterEndLabel->setVisible(false); + ui->filterEnd->setVisible(false); + ui->filterDurationLabel->setVisible(true); + ui->filterDuration->setVisible(true); + ui->filterSec->setVisible(true); + ui->filterMSec->setVisible(true); + ui->filterNSec->setVisible(true); + break; + } +} + +void AddFunctionsDialog::captureInput() +{ + if (ui->filterOptions->currentIndex() == 0 || ui->filterOptions->currentIndex() == 1) + { + QString filterString = ui->filterString->toPlainText(); + this->matchingEvents.clear(); + this->matchingFunctions.clear(); + ui->filterTable->clear(); + filterByString(filterString); + } + else if (ui->filterOptions->currentIndex() == 3) + { + if (duration > 0) + filterByDuration(duration, option); + } +} + +void AddFunctionsDialog::captureStartTime(double time) +{ + if (ui->filterOptions->currentIndex() == 2) + { + start = time; + if (start < end && end != 0) + { + filterByTime(start, end); + } + } +} + +void AddFunctionsDialog::captureEndTime(double time) +{ + if (ui->filterOptions->currentIndex() == 2) + { + end = time; + if (start < end && end != 0) + { + filterByTime(start, end); + } + } +} + +void AddFunctionsDialog::captureDuration(double time) +{ + if (ui->filterOptions->currentIndex() == 3) + { + duration = time; + } +} + +void AddFunctionsDialog::captureOption(int id) +{ + option = id; +} + +void AddFunctionsDialog::selectAll(bool checked) +{ + if (checked) + { + if (this->matchingEvents.size()) + { + allClicked = true; + for (int counter = 0; counter != this->matchingEvents.size(); ++counter) + { + QTableWidgetItem *checkBox = ui->filterTable->item(counter, 0); + checkBox->setCheckState(Qt::Checked); + this->selectedEvents.insert(this->matchingEvents[counter]); + } + } + } + else + { + if (allClicked) + { + allClicked = false; + for (int counter = 0; counter != this->matchingEvents.size(); ++counter) + { + QTableWidgetItem *checkBox = ui->filterTable->item(counter, 0); + checkBox->setCheckState(Qt::Unchecked); + } + this->selectedEvents.clear(); + } + } +} + +void AddFunctionsDialog::addToSelectedEvents(QTableWidgetItem *item) +{ + if (item->column() == 0 && item->checkState() == Qt::Checked) + this->selectedEvents.insert(this->matchingEvents[item->row()]); + else if (item->column() == 0 && item->checkState() == Qt::Unchecked) + { + if (this->selectedEvents.contains(this->matchingEvents[item->row()])) + { + this->deletedEvents.insert(this->matchingEvents[item->row()]); + this->selectedEvents.remove(this->matchingEvents[item->row()]); + } + } +} + +void AddFunctionsDialog::getMatches(QString string) +{ + for (QList::Iterator trc = this->traces.begin(); + trc != this->traces.end(); ++trc) + { + for (QMap::Iterator fnc = (*trc)->functions->begin(); + fnc != (*trc)->functions->end(); ++fnc) + { + switch (ui->filterOptions->currentIndex()) + { + case 0: + { + QRegExp rx(string); + rx.setPatternSyntax(QRegExp::Wildcard); + if (rx.exactMatch(fnc.value()->name) && string.size() != 0) + this->matchingFunctions.insert(fnc.key(), fnc.value()); + break; + } + case 1: + { + if (!QString::compare(fnc.value()->name, string, Qt::CaseInsensitive)) + this->matchingFunctions.insert(fnc.key(), fnc.value()); + break; + } + } + } + } +} + +void AddFunctionsDialog::filterByString(QString name) +{ + if (!this->traces.empty()) + { + getMatches(name); + for (QMap::Iterator fnc = this->matchingFunctions.begin(); + fnc != this->matchingFunctions.end(); ++fnc) + { + for (QList::Iterator trc = this->traces.begin(); + trc != this->traces.end(); ++trc) + { + for (QVector *>::Iterator eitr = (*trc)->events->begin(); + eitr != (*trc)->events->end(); ++eitr) + { + for (QVector::Iterator itr = (*eitr)->begin(); + itr != (*eitr)->end(); ++itr) + { + if (fnc.key() == (*itr)->function) + { + if (!this->matchingEvents.contains(*itr)) + this->matchingEvents.append(*itr); + } + } + } + } + } + populateTable(); + } +} + +void AddFunctionsDialog::filterByTime(unsigned long long start, unsigned long long end) +{ + if (!this->traces.empty()) + { + for (QList::Iterator trc = this->traces.begin(); + trc != this->traces.end(); ++trc) + { + for (QVector *>::Iterator eitr = (*trc)->events->begin(); + eitr != (*trc)->events->end(); ++eitr) + { + for (QVector::Iterator itr = (*eitr)->begin(); + itr != (*eitr)->end(); ++itr) + { + if ((*itr)->enter >= start && (*itr)->exit <= end) + { + if (!this->matchingEvents.contains(*itr)) { + this->matchingEvents.append(*itr); + } + } + } + } + } + populateTable(); + } +} + +double AddFunctionsDialog::decideFactor(QString units, QString option_units) // Might need to add other possibilities as mentioned in getUnits function +{ + if (!QString::compare(units, "s", Qt::CaseInsensitive)) + { + if (!QString::compare(option_units, "ns", Qt::CaseInsensitive)) + return 1e+9; + else if (!QString::compare(option_units, "ms", Qt::CaseInsensitive)) + return 1000; + } + else if (!QString::compare(units, "ms", Qt::CaseInsensitive)) + { + if (!QString::compare(option_units, "s", Qt::CaseInsensitive)) + return 0.001; + else if (!QString::compare(option_units, "ns", Qt::CaseInsensitive)) + return 1e+6; + } + else if (!QString::compare(units, "ns", Qt::CaseInsensitive)) + { + if (!QString::compare(option_units, "s", Qt::CaseInsensitive)) + return 1e-9; + else if (!QString::compare(option_units, "ms", Qt::CaseInsensitive)) + return 1e-6; + } + +} + +void AddFunctionsDialog::filterByDuration(unsigned long long duration, int option) +{ + QString units = RavelUtils::RavelUtils::getUnits(this->traces[0]->units); // Is this correct? + QString option_units; + bool change = false; + switch (option) { + case 0: + option_units = "s"; + break; + case 1: + option_units = "ms"; + break; + case 2: + option_units = "ns"; + break; + } + if (QString::compare(units, option_units, Qt::CaseInsensitive)) + change = true; + + if (!this->traces.empty()) + { + for (QList::Iterator trc = this->traces.begin(); + trc != this->traces.end(); ++trc) + { + for (QVector *>::Iterator eitr = (*trc)->events->begin(); + eitr != (*trc)->events->end(); ++eitr) + { + for (QVector::Iterator itr = (*eitr)->begin(); + itr != (*eitr)->end(); ++itr) + { + unsigned long long time = abs((*itr)->exit - (*itr)->enter); + if (change) + { + double factor = decideFactor(units, option_units); + time *= factor; + } + if ( time >= duration) + { + if (!this->matchingEvents.contains(*itr)) { + this->matchingEvents.append(*itr); + } + } + } + } + } + populateTable(); + } +} + +void AddFunctionsDialog::populateTable() +{ + ui->filterTable->setRowCount(this->matchingEvents.size()); + qDebug("Size = " + QString::number(this->matchingEvents.size()).toLatin1()); + int counter = 0; + foreach (Event * evt, this->matchingEvents) + { + QTableWidgetItem *lastItemCheckBox = new QTableWidgetItem(); + if (this->selectedEvents.contains(evt)) + lastItemCheckBox->setCheckState(Qt::Checked); + else + lastItemCheckBox->setCheckState(Qt::Unchecked); + ui->filterTable->setItem(counter, 0, lastItemCheckBox); + QTableWidgetItem *lastItemStart = new QTableWidgetItem(QString::number(evt->enter)); + ui->filterTable->setItem(counter, 1, lastItemStart); + QTableWidgetItem *lastItemEnd = new QTableWidgetItem(QString::number(evt->exit)); + ui->filterTable->setItem(counter, 2, lastItemEnd); + + for (QList::Iterator trc = this->traces.begin(); + trc != this->traces.end(); ++trc) + { + if ((*trc)->functions->contains(evt->function)) + { + QTableWidgetItem *lastItemName = new QTableWidgetItem((*trc)->functions->value(evt->function)->name); + ui->filterTable->setItem(counter, 3, lastItemName); + break; + } + } + counter++; + } +} diff --git a/src/addfunctionsdialog.h b/src/addfunctionsdialog.h new file mode 100644 index 0000000..810a02d --- /dev/null +++ b/src/addfunctionsdialog.h @@ -0,0 +1,59 @@ +#ifndef ADDFUNCTIONSDIALOG_H +#define ADDFUNCTIONSDIALOG_H + +#include +#include +#include + +class Trace; +class Function; +class Event; + +namespace Ui { +class AddFunctionsDialog; +} + +class AddFunctionsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AddFunctionsDialog(QWidget *parent = 0, + QList _traces = QList(), + QSet _selectedEvents = QSet()); + QSet getSelectedEvents(); + QSet getDeletedEvents(); + ~AddFunctionsDialog(); + +public slots: + void switchVisibility(int); + void captureInput(); + void selectAll(bool); + void addToSelectedEvents(QTableWidgetItem *); + void captureStartTime(double); + void captureEndTime(double); + void captureDuration(double); + void captureOption(int); + +private: + Ui::AddFunctionsDialog *ui; + QList traces; + unsigned long long start; + unsigned long long end; + unsigned long long duration; + int option; + QMap matchingFunctions; + QList matchingEvents; + QSet selectedEvents; + QSet deletedEvents; + bool allClicked; + + void getMatches(QString string); + void filterByString(QString name); + void filterByTime(unsigned long long start, unsigned long long end); + void filterByDuration(unsigned long long duration, int option); + void populateTable(); + double decideFactor(QString, QString); +}; + +#endif // ADDFUNCTIONSDIALOG_H diff --git a/src/addfunctionsdialog.ui b/src/addfunctionsdialog.ui new file mode 100644 index 0000000..c682b1e --- /dev/null +++ b/src/addfunctionsdialog.ui @@ -0,0 +1,343 @@ + + + AddFunctionsDialog + + + + 0 + 0 + 532 + 356 + + + + Dialog + + + + + 180 + 320 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 120 + 10 + 391 + 31 + + + + + Regular Expression + + + + + Function Name + + + + + Start and End Time + + + + + Time Duration + + + + + + + 20 + 10 + 101 + 31 + + + + Filter Syntax + + + + + true + + + + 20 + 280 + 101 + 31 + + + + Filter String + + + + + true + + + + 120 + 280 + 301 + 31 + + + + + + + 20 + 280 + 81 + 31 + + + + Start Time + + + + + + 270 + 280 + 71 + 31 + + + + End Time + + + + + + 20 + 50 + 491 + 221 + + + + true + + + + Select + + + + + Start Time + + + + + End Time + + + + + Name + + + + + + + 20 + 320 + 111 + 23 + + + + Select All + + + + + + 100 + 280 + 161 + 31 + + + + 0 + + + 10000000000000000000.000000000000000 + + + + + + 340 + 280 + 171 + 31 + + + + 0 + + + 10000000000000000000.000000000000000 + + + + + + 430 + 280 + 89 + 31 + + + + Filter + + + + + + 20 + 280 + 81 + 31 + + + + Duration + + + + + + 100 + 280 + 161 + 31 + + + + 0 + + + 10000000000000000000.000000000000000 + + + + + + 270 + 280 + 50 + 31 + + + + s + + + false + + + filterRadioGroup + + + + + + 320 + 280 + 50 + 31 + + + + ms + + + filterRadioGroup + + + + + + 370 + 280 + 50 + 31 + + + + ns + + + true + + + filterRadioGroup + + + + + + + buttonBox + accepted() + AddFunctionsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddFunctionsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + + + + diff --git a/src/filterdialog.cpp b/src/filterdialog.cpp new file mode 100644 index 0000000..fe4e429 --- /dev/null +++ b/src/filterdialog.cpp @@ -0,0 +1,130 @@ +#include "filterdialog.h" +#include "ui_filterdialog.h" +#include "addfunctionsdialog.h" +#include "trace.h" +#include "event.h" +#include "function.h" +#include + +FilterDialog::FilterDialog(QWidget *parent, QList _traces, QSet _filterEvents) : + QDialog(parent), + traces(_traces), + filterApplied(false), + addFuncDialog(NULL), + filterEvents(_filterEvents), + ui(new Ui::FilterDialog) +{ + ui->setupUi(this); + if (!filterEvents.empty()) + { + foreach (Event * evt, filterEvents) + { + ui->infoFunctions->insertRow(ui->infoFunctions->rowCount()); + QTableWidgetItem *lastItemStart = new QTableWidgetItem(QString::number(evt->enter)); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 0, lastItemStart); + QTableWidgetItem *lastItemEnd = new QTableWidgetItem(QString::number(evt->exit)); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 1, lastItemEnd); + + for (QList::Iterator trc = traces.begin(); + trc != traces.end(); ++trc) + { + if ((*trc)->functions->contains(evt->function)) + { + QTableWidgetItem *lastItemName = new QTableWidgetItem((*trc)->functions->value(evt->function)->name); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 2, lastItemName); + break; + } + } + } + } + connect(ui->addFunctions, SIGNAL(clicked()), this, SLOT(openAddFunctionsDialog())); + connect(ui->importFunctions, SIGNAL(clicked()), this, SLOT(openImportFunctionsDialog())); +} + +FilterDialog::~FilterDialog() +{ + delete ui; +} + +QSet FilterDialog::getFilterEvents() +{ + return filterEvents; +} + +void FilterDialog::openAddFunctionsDialog() +{ + delete addFuncDialog; + qDebug(ui->addFunctions->text().toLatin1()); + if (!filterEvents.empty()) + addFuncDialog = new AddFunctionsDialog(this, traces, filterEvents); + else + addFuncDialog = new AddFunctionsDialog(this, traces); + int dialogCode = addFuncDialog->exec(); + if (dialogCode == QDialog::Accepted) + { + QSet selectedEvents = addFuncDialog->getSelectedEvents(); + QSet deletedEvents = addFuncDialog->getDeletedEvents(); + if (!selectedEvents.empty()) + { + foreach (Event * evt, selectedEvents) + { + if (!filterEvents.contains(evt)) + { + ui->infoFunctions->insertRow(ui->infoFunctions->rowCount()); + QTableWidgetItem *lastItemStart = new QTableWidgetItem(QString::number(evt->enter)); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 0, lastItemStart); + QTableWidgetItem *lastItemEnd = new QTableWidgetItem(QString::number(evt->exit)); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 1, lastItemEnd); + + for (QList::Iterator trc = traces.begin(); + trc != traces.end(); ++trc) + { + if ((*trc)->functions->contains(evt->function)) + { + QTableWidgetItem *lastItemName = new QTableWidgetItem((*trc)->functions->value(evt->function)->name); + ui->infoFunctions->setItem(ui->infoFunctions->rowCount() - 1, 2, lastItemName); + break; + } + } + filterEvents.insert(evt); + } + } + foreach (Event * evt, deletedEvents) + { + if (filterEvents.contains(evt)) + { + QString eventName; + for (QList::Iterator trc = traces.begin(); + trc != traces.end(); ++trc) + { + if ((*trc)->functions->contains(evt->function)) + { + eventName = (*trc)->functions->value(evt->function)->name; + break; + } + } + for (int counter = 0; counter < ui->infoFunctions->rowCount(); ++counter) + { + if (ui->infoFunctions->item(counter, 0)->text() == QString::number(evt->enter) && + ui->infoFunctions->item(counter, 1)->text() == QString::number(evt->exit) && + ui->infoFunctions->item(counter, 2)->text() == eventName) + { + ui->infoFunctions->removeRow(counter); + break; + } + } + filterEvents.remove(evt); + } + } + if (!filterEvents.empty()) + filterApplied = true; + else + filterApplied = false; + } + } +} + +void FilterDialog::openImportFunctionsDialog() +{ + qDebug(ui->importFunctions->text().toLatin1()); +} diff --git a/src/filterdialog.h b/src/filterdialog.h new file mode 100644 index 0000000..5dbba4f --- /dev/null +++ b/src/filterdialog.h @@ -0,0 +1,42 @@ +#ifndef FILTERDIALOG_H +#define FILTERDIALOG_H + +#include +#include + +class AddFunctionsDialog; +class Trace; +class Event; + +namespace Ui { +class FilterDialog; +} + +class FilterDialog : public QDialog +{ + Q_OBJECT + +public: + explicit FilterDialog(QWidget *parent = 0, + QList _traces = QList(), + QSet _filterEvents = QSet()); + ~FilterDialog(); + QSet getFilterEvents(); + bool filterApplied; + +public slots: + void openAddFunctionsDialog(); + void openImportFunctionsDialog(); + +private: + Ui::FilterDialog *ui; + QList traces; + QSet filterEvents; + + // Add functions + AddFunctionsDialog *addFuncDialog; + + // Import Functions +}; + +#endif // FILTERDIALOG_H diff --git a/src/filterdialog.ui b/src/filterdialog.ui new file mode 100644 index 0000000..3d6cb2b --- /dev/null +++ b/src/filterdialog.ui @@ -0,0 +1,131 @@ + + + FilterDialog + + + + 0 + 0 + 511 + 300 + + + + Dialog + + + + + 150 + 260 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 400 + 20 + 91 + 25 + + + + Add + + + + + + 400 + 50 + 91 + 25 + + + + Import + + + + + + 10 + 10 + 381 + 241 + + + + 3 + + + false + + + true + + + false + + + + Start Time + + + + + End Time + + + + + Name + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0d10c98..ef5d586 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,6 +35,7 @@ #include "visoptionsdialog.h" #include "importfunctor.h" #include "taskpropertywindow.h" +#include "filterdialog.h" #include #include @@ -62,6 +63,7 @@ MainWindow::MainWindow(QWidget *parent) : visoptions(new VisOptions()), visdialog(NULL), taskwindow(NULL), + filterdialog(NULL), activetracename(""), activetraces(QStack()), dataDirectory("") @@ -121,6 +123,9 @@ MainWindow::MainWindow(QWidget *parent) : SLOT(launchVisOptions())); ui->actionVisualization->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V)); + connect(ui->actionFilters, SIGNAL(triggered()), this, SLOT(launchFilterOptions())); + ui->actionFilters->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); + connect(ui->actionPhysical_Time, SIGNAL(triggered()), this, SLOT(togglePhysicalTime())); ui->actionPhysical_Time->setShortcut(QKeySequence(Qt::ALT + Qt::Key_P)); @@ -243,6 +248,21 @@ void MainWindow::launchVisOptions() viswidgets[i]->repaint(); } +void MainWindow::launchFilterOptions() +{ + delete filterdialog; + if (!viswidgets[TIMEVIS]->getFilterEvents().empty()) + filterdialog = new FilterDialog(this, this->traces, viswidgets[TIMEVIS]->getFilterEvents()); + else + filterdialog = new FilterDialog(this, this->traces); + int dialogCode = filterdialog->exec(); + if (dialogCode == QDialog::Accepted && filterdialog->filterApplied) + { + viswidgets[TIMEVIS]->setFilterApplied(true); + viswidgets[TIMEVIS]->setFilterEvents(filterdialog->getFilterEvents()); + } +} + void MainWindow::importTracebyGUI() { // Now get the Trace File diff --git a/src/mainwindow.h b/src/mainwindow.h index b316417..3e32e50 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -37,6 +37,8 @@ class VisWidget; class VisOptions; class VisOptionsDialog; class TaskPropertyWindow; +class TraditionalVis; +class FilterDialog; class QAction; class ImportFunctor; @@ -64,6 +66,7 @@ class MainWindow : public QMainWindow public slots: void launchVisOptions(); + void launchFilterOptions(); // Signal relays void pushTime(float start, float stop, bool jump = false); @@ -123,6 +126,7 @@ public slots: VisOptionsDialog * visdialog; TaskPropertyWindow * taskwindow; + FilterDialog *filterdialog; QString activetracename; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 842c5dd..6dd69e3 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -264,7 +264,7 @@ 0 0 1600 - 25 + 22 @@ -280,6 +280,7 @@ Options + @@ -381,6 +382,11 @@ Save Current Trace + + + Filters + + diff --git a/src/traditionalvis.cpp b/src/traditionalvis.cpp index b2159b9..a771ce5 100644 --- a/src/traditionalvis.cpp +++ b/src/traditionalvis.cpp @@ -480,9 +480,14 @@ void TraditionalVis::paintEvents(QPainter *painter) for (QVector::Iterator root = roots->begin(); root != roots->end(); ++root) { - paintNotStepEvents(painter, *root, position, entity_spacing, - barheight, blockheight, &extents, &drawComms, - &selectedComms); + if (filterApplied && filterEvents.contains(*root)) + paintNotStepEvents(painter, *root, position, entity_spacing, + barheight, blockheight, &extents, &drawComms, + &selectedComms); + else if (!filterApplied) + paintNotStepEvents(painter, *root, position, entity_spacing, + barheight, blockheight, &extents, &drawComms, + &selectedComms); } } diff --git a/src/viswidget.cpp b/src/viswidget.cpp index 3c47c6c..5794c6d 100644 --- a/src/viswidget.cpp +++ b/src/viswidget.cpp @@ -48,11 +48,13 @@ VisWidget::VisWidget(QWidget *parent, VisOptions * _options) : changeSource(false), border(20), drawnEvents(QMap()), + filterEvents(QSet()), selected_entities(QList()), selected_event(NULL), task_property_event(NULL), hover_event(NULL), - closed(false) + closed(false), + filterApplied(false) { setFocusPolicy(Qt::StrongFocus); // GLWidget options @@ -231,11 +233,25 @@ void VisWidget::setClosed(bool _closed) closed = _closed; } +void VisWidget::setFilterApplied(bool _filterApplied) +{ + filterApplied = _filterApplied; +} + void VisWidget::setVisOptions(VisOptions * _options) { options = _options; } +void VisWidget::setFilterEvents(QSet _filterEvents) +{ + filterEvents = _filterEvents; +} + +QSet VisWidget::getFilterEvents() +{ + return filterEvents; +} // Draws a timescale (physical). Note this can fail if the span is short // enough which can happen when we find no events. diff --git a/src/viswidget.h b/src/viswidget.h index 6639eb0..385c15b 100644 --- a/src/viswidget.h +++ b/src/viswidget.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "visoptions.h" #include "commdrawinterface.h" @@ -55,8 +56,11 @@ class VisWidget : public QGLWidget, public CommDrawInterface virtual QSize sizeHint() const; void setClosed(bool _closed); + void setFilterApplied(bool _filterApplied); bool isClosed() { return closed; } void setVisOptions(VisOptions * _options); + void setFilterEvents(QSet _filterEvents); + QSet getFilterEvents(); QWidget * container; virtual int getHeight() { return rect().height(); } @@ -104,11 +108,13 @@ public slots: // Interactions QMap drawnEvents; + QSet filterEvents; QList selected_entities; Event * selected_event; Event * task_property_event; Event * hover_event; bool closed; + bool filterApplied; static const int initTimeSpan = 90000; static const int timescaleHeight = 20;