18#include "MainWindow.hpp"
20#include <QApplication>
21#include <QCoreApplication>
22#include <QErrorMessage>
31#include "src/models/AppSettings.hpp"
32#include "src/ui/widgets/License.hpp"
33#include "src/ui/widgets/Help.hpp"
34#include "src/ui/widgets/TimeInputField.hpp"
35#include "src/ui/widgets/Timeline.hpp"
36#include "src/ui/TimeUnit.hpp"
37#include "src/ui/windows/FilterPopup.hpp"
38#include "src/ui/widgets/About.hpp"
39#include "src/ui/widgets/TraceOverviewDock.hpp"
40#include "src/ui/widgets/InformationDock.hpp"
41#include "src/ui/widgets/infostrategies/InformationDockSlotStrategy.hpp"
42#include "src/ui/widgets/infostrategies/InformationDockTraceStrategy.hpp"
43#include "src/ui/widgets/infostrategies/InformationDockCommunicationStrategy.hpp"
44#include "src/ui/widgets/infostrategies/InformationDockCollectiveCommunicationStrategy.hpp"
48 if (this->filepath.isEmpty()) {
54 this->createToolBars();
55 this->createDockWidgets();
56 this->createCentralWidget();
60MainWindow::~MainWindow() {
62 delete this->callbacks;
64 delete this->settings;
66 delete this->traceOverview;
67 delete this->information;
69 delete this->licenseWindow;
70 delete this->helpWindow;
71 delete this->aboutWindow;
74void MainWindow::createMenus() {
75 auto menuBar = this->menuBar();
78 auto openTraceAction =
new QAction(tr(
"&Open..."),
this);
79 openTraceAction->setShortcut(tr(
"Ctrl+O"));
81 auto openRecentMenu =
new QMenu(tr(
"&Open recent"));
83 auto emptyAction = openRecentMenu->addAction(tr(
"&(Empty)"));
84 emptyAction->setEnabled(
false);
88 auto recentAction =
new QAction(recent, openRecentMenu);
89 openRecentMenu->addAction(recentAction);
90 connect(recentAction, &QAction::triggered, [&,
this] {
91 this->openNewWindow(recent);
94 openRecentMenu->addSeparator();
96 auto clearRecentMenuAction =
new QAction(tr(
"&Clear history"));
97 openRecentMenu->addAction(clearRecentMenuAction);
98 connect(clearRecentMenuAction, &QAction::triggered, [&] {
100 openRecentMenu->clear();
104 auto quitAction =
new QAction(tr(
"&Quit"),
this);
105 quitAction->setShortcut(tr(
"Ctrl+Q"));
106 connect(quitAction, SIGNAL(triggered()),
this, SLOT(close()));
108 auto fileMenu = menuBar->addMenu(tr(
"&File"));
109 fileMenu->addAction(openTraceAction);
110 fileMenu->addMenu(openRecentMenu);
111 fileMenu->addSeparator();
112 fileMenu->addAction(quitAction);
115 auto filterAction =
new QAction(tr(
"&Filter"));
116 filterAction->setShortcut(tr(
"Ctrl+S"));
117 connect(filterAction, SIGNAL(triggered()),
this, SLOT(
openFilterPopup()));
119 auto searchAction =
new QAction(tr(
"&Find"));
120 searchAction->setShortcut(tr(
"Ctrl+F"));
121 connect(searchAction, SIGNAL(triggered()),
this, SLOT(
openFilterPopup()));
123 auto resetZoomAction =
new QAction(tr(
"&Reset zoom"));
124 connect(resetZoomAction, SIGNAL(triggered()),
this, SLOT(
resetZoom()));
125 resetZoomAction->setShortcut(tr(
"Ctrl+R"));
127 auto widgetMenu =
new QMenu(tr(
"Tool Windows"));
129 auto showOverviewAction =
new QAction(tr(
"Show &trace overview"));
130 showOverviewAction->setCheckable(
true);
131 connect(showOverviewAction, SIGNAL(toggled(
bool)), this->traceOverview, SLOT(setVisible(
bool)));
132 connect(this->traceOverview, SIGNAL(visibilityChanged(
bool)), showOverviewAction, SLOT(setChecked(
bool)));
134 auto showDetailsAction =
new QAction(tr(
"Show &detail view"));
135 showDetailsAction->setCheckable(
true);
136 connect(showDetailsAction, SIGNAL(toggled(
bool)), this->information, SLOT(setVisible(
bool)));
137 connect(this->information, SIGNAL(visibilityChanged(
bool)), showDetailsAction, SLOT(setChecked(
bool)));
139 widgetMenu->addAction(showOverviewAction);
140 widgetMenu->addAction(showDetailsAction);
142 auto viewMenu = menuBar->addMenu(tr(
"&View"));
143 viewMenu->addAction(filterAction);
144 viewMenu->addAction(searchAction);
145 viewMenu->addAction(resetZoomAction);
146 viewMenu->addMenu(widgetMenu);
149 auto minimizeAction =
new QAction(tr(
"&Minimize"));
150 minimizeAction->setShortcut(tr(
"Ctrl+M"));
151 connect(minimizeAction, SIGNAL(triggered()),
this, SLOT(showMinimized()));
153 auto windowMenu = menuBar->addMenu(tr(
"&Window"));
154 windowMenu->addAction(minimizeAction);
157 auto showLicenseAction =
new QAction(tr(
"&View license"));
158 connect(showLicenseAction, &QAction::triggered,
this, [
this] {
159 if(!this->licenseWindow) this->licenseWindow =
new License;
160 this->licenseWindow->show();
162 auto showHelpAction =
new QAction(tr(
"&Show help"));
163 showHelpAction->setShortcut(tr(
"F1"));
164 connect(showHelpAction, &QAction::triggered,
this, [
this] {
165 if(!this->helpWindow) this->helpWindow =
new Help;
166 this->helpWindow->show();
168 auto showAboutQtAction =
new QAction(tr(
"&About Qt"));
169 connect(showAboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
170 auto showAboutAction =
new QAction(tr(
"&About"));
171 showAboutAction->setShortcut(tr(
"Shift+F1"));
172 connect(showAboutAction, &QAction::triggered,
this, [
this] {
173 if(!this->aboutWindow) this->aboutWindow=
new About;
174 this->aboutWindow->show();
177 auto helpMenu = menuBar->addMenu(tr(
"&Help"));
178 helpMenu->addAction(showLicenseAction);
179 helpMenu->addAction(showHelpAction);
180 helpMenu->addAction(showAboutQtAction);
181 helpMenu->addAction(showAboutAction);
184void MainWindow::createToolBars() {
191 this->bottomToolbar =
new QToolBar(
this);
192 this->bottomToolbar->setMovable(
false);
193 this->addToolBar(Qt::BottomToolBarArea, this->bottomToolbar);
195 auto bottomContainerWidget =
new QWidget(this->bottomToolbar);
196 auto containerLayout =
new QHBoxLayout(bottomContainerWidget);
197 bottomContainerWidget->setLayout(containerLayout);
201 bottomContainerWidget);
204 containerLayout->addWidget(this->startTimeInputField);
206 bottomContainerWidget);
208 containerLayout->addWidget(this->endTimeInputField);
210 connect(data, SIGNAL(beginChanged(types::TraceTime)), this->startTimeInputField, SLOT(setTime(types::TraceTime)));
211 connect(data, SIGNAL(endChanged(types::TraceTime)), this->endTimeInputField, SLOT(setTime(types::TraceTime)));
213 this->bottomToolbar->addWidget(bottomContainerWidget);
217void MainWindow::createDockWidgets() {
226 connect(information, SIGNAL(zoomToWindow(types::TraceTime, types::TraceTime)), data,
227 SLOT(setSelection(types::TraceTime, types::TraceTime)));
231 this->addDockWidget(Qt::RightDockWidgetArea, this->information);
234 this->addDockWidget(Qt::TopDockWidgetArea, this->traceOverview);
237void MainWindow::createCentralWidget() {
238 auto timeline =
new Timeline(data,
this);
239 this->setCentralWidget(timeline);
242QString MainWindow::promptFile() {
243 auto newFilePath = QFileDialog::getOpenFileName(
this, QFileDialog::tr(
"Open trace"), QString(),
244 QFileDialog::tr(
"OTF Traces (*.otf *.otf2)"));
247 if (newFilePath.isEmpty()) {
248 auto errorMsg =
new QErrorMessage(
nullptr);
249 errorMsg->showMessage(
"The chosen file is invalid!");
255void MainWindow::loadTrace() {
256 this->reader =
new otf2::reader::reader(this->filepath.toStdString());
259 this->reader->set_callback(*callbacks);
260 this->reader->read_definitions();
261 this->reader->read_events();
263 auto slots = this->callbacks->
getSlots();
266 auto trace =
new FileTrace(slots, communications, collectives, this->callbacks->
duration());
271void MainWindow::loadSettings() {
282 auto connection = connect(&filterPopup, SIGNAL(filterChanged(
Filter)), this->data, SLOT(setFilter(
Filter)));
286 disconnect(connection);
290 auto path = this->promptFile();
291 this->openNewWindow(path);
294void MainWindow::openNewWindow(QString path) {
295 QProcess::startDetached(
296 QFileInfo(QCoreApplication::applicationFilePath()).absoluteFilePath(),
A widget showcasing information about this software.
static AppSettings & getInstance()
void recentlyOpenedFilesClear()
Clears the recently opened files list.
Trace representing the whole trace loaded from trace files.
Class containing options to filter the view.
A widget which provides users with information about the various views and controls available in the ...
A widget showcasing displaying license information about this software.
MainWindow(QString filepath=QString())
Creates a new instance of the MainWindow class.
void resetZoom()
Resets the zoom to show the entire trace.
void openNewTrace()
Asks for a new trace file and opens the trace.
void openFilterPopup()
Opens and shows the FilterPopup.
Class implementing handlers for the otf readers events.
std::vector< Slot * > getSlots()
Returns all read slots.
std::vector< Communication * > getCommunications()
Returns all read point to point communications.
otf2::chrono::duration duration() const
std::vector< CollectiveCommunicationEvent * > getCollectiveCommunications()
Returns all read collective communications.
A base class for all elements with a start and end time.
virtual types::TraceTime getEndTime() const =0
Returns the end time of the current object.
virtual types::TraceTime getStartTime() const =0
Returns the start time of the current object.
Container widget for actual view and axis labels.
Model class providing access to data and pub/sub architecture of change events.
ViewSettings * getSettings() const
Returns the current view settings.
types::TraceTime getTotalRuntime() const
void setSelectionBegin(types::TraceTime newBegin)
Trace * getFullTrace() const
Returns the entire trace.
void setSelectionEnd(types::TraceTime newEnd)
void setSelection(types::TraceTime newBegin, types::TraceTime newEnd)
A DockWidget holding a TraceOverviewTimelineView.
The ViewSettings class encapsulates settings for the main view.
Filter getFilter() const
Returns the current filter.