Motiv
Marvelous OTF2 Traces Interactive Visualizer
Loading...
Searching...
No Matches
FilterPopup.cpp
1/*
2 * Marvelous OTF2 Traces Interactive Visualizer (MOTIV)
3 * Copyright (C) 2023 Florian Gallrein, Björn Gehrke
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include <QGridLayout>
19#include <QRadioButton>
20#include <QCheckBox>
21#include <QPushButton>
22#include "FilterPopup.hpp"
23
24FilterPopup::FilterPopup(const Filter &filter, QWidget *parent, const Qt::WindowFlags &f)
25 : QDialog(parent, f), filter_(filter) {
26
27 auto *grid = new QGridLayout();
28
29 // Show checkboxes for different slot kinds
30 auto slotKindsGroupBox = new QGroupBox(tr("Function calls"));
31 mpiSlotKindCheckBox = new QCheckBox(tr("Show &MPI function calls"));
32 mpiSlotKindCheckBox->setChecked(filter_.getSlotKinds() & SlotKind::MPI);
33 openMpSlotKindCheckBox = new QCheckBox(tr("Show &OpenMp function calls"));
34 openMpSlotKindCheckBox->setChecked(filter_.getSlotKinds() & SlotKind::OpenMP);
35 plainSlotKindCheckBox = new QCheckBox(tr("Show &plain function calls"));
36 plainSlotKindCheckBox->setChecked(filter_.getSlotKinds() & SlotKind::Plain);
37
38 auto vbox = new QVBoxLayout();
39 vbox->addWidget(mpiSlotKindCheckBox);
40 vbox->addWidget(openMpSlotKindCheckBox);
41 vbox->addWidget(plainSlotKindCheckBox);
42
43 vbox->addStretch(1);
44 slotKindsGroupBox->setLayout(vbox);
45
46 grid->addWidget(slotKindsGroupBox, 0, 0);
47
48 auto okButton = new QPushButton(tr("&Ok"));
49 okButton->setDefault(true);
50 connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
51 auto cancelButton = new QPushButton(tr("&Cancel"));
52 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
53
54 grid->addWidget(cancelButton, 1, 0, Qt::AlignLeft);
55 grid->addWidget(okButton, 1, 1, Qt::AlignRight);
56
57
58 connect(this, SIGNAL(accepted()), this, SLOT(updateFilter()));
59
60 setLayout(grid);
61 setWindowTitle(tr("Set filter"));
62 setModal(true);
63}
64
66 auto slotKinds = static_cast<SlotKind>(
67 SlotKind::Plain * plainSlotKindCheckBox->isChecked() |
68 SlotKind::OpenMP * openMpSlotKindCheckBox->isChecked() |
69 SlotKind::MPI * mpiSlotKindCheckBox->isChecked());
70
71 filter_.setSlotKinds(slotKinds);
72
73 Q_EMIT filterChanged(filter_);
74}
void filterChanged(Filter)
void updateFilter()
Definition: FilterPopup.cpp:65
FilterPopup(const Filter &filter, QWidget *parent=nullptr, const Qt::WindowFlags &f=Qt::WindowFlags())
Definition: FilterPopup.cpp:24
Class containing options to filter the view.
Definition: Filter.hpp:28
SlotKind getSlotKinds() const
Returns the kinds of slots that should be rendered.
Definition: Filter.cpp:20
void setSlotKinds(SlotKind slotKinds)
Sets the slots that should be rendered.
Definition: Filter.cpp:24