Motiv
Marvelous OTF2 Traces Interactive Visualizer
Loading...
Searching...
No Matches
TraceDataProxy.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 "TraceDataProxy.hpp"
19#include "src/models/UITrace.hpp"
20
21TraceDataProxy::TraceDataProxy(FileTrace *trace, ViewSettings *settings, QObject *parent)
22 : QObject(parent), trace(trace), settings(settings), begin(trace->getStartTime()),
23 end(trace->getStartTime() + trace->getRuntime()) {
24 updateSelection();
25}
26
27TraceDataProxy::~TraceDataProxy() {
28 delete this->selection;
29 delete this->trace;
30}
31
33 return this->selection;
34}
35
36types::TraceTime TraceDataProxy::getBegin() const {
37 return this->begin;
38}
39
40types::TraceTime TraceDataProxy::getEnd() const {
41 return this->end;
42}
43
44void TraceDataProxy::setSelectionBegin(types::TraceTime newBegin) {
45 setSelection(newBegin, end);
46}
47
48void TraceDataProxy::setSelectionEnd(types::TraceTime newEnd) {
49 setSelection(begin, newEnd);
50}
51
53 return settings;
54}
55
56
57types::TraceTime TraceDataProxy::getTotalRuntime() const {
58 return trace->getRuntime();
59}
60
61void TraceDataProxy::updateSelection() {
62 delete selection;
63 auto subtrace = trace->subtrace(begin, end);
64 selection = UITrace::forResolution(subtrace, subtrace->getRuntime() / 1920);
65 Q_EMIT selectionChanged(begin, end);
66}
67
68void TraceDataProxy::setSelection(types::TraceTime newBegin, types::TraceTime newEnd) {
69 newBegin = qMax(types::TraceTime(0), newBegin);
70 newEnd = qMin(getTotalRuntime(), newEnd);
71
72 newBegin = qMin(newEnd, newBegin);
73 newEnd = qMax(newBegin, newEnd);
74
75 auto oldBegin = begin;
76 auto oldEnd = end;
77
78 begin = newBegin;
79 end=newEnd;
80
81 if(oldBegin != begin) {
82 Q_EMIT beginChanged(begin);
83 }
84
85 if(oldEnd != end) {
86 Q_EMIT endChanged(end);
87 }
88
89 if(oldBegin != begin || oldEnd != end) {
90 updateSelection();
91 }
92}
93
95 Q_EMIT infoElementSelected(newSlot);
96}
97
99 settings->setFilter(filter);
100
101 Q_EMIT filterChanged(filter);
102}
103
105 return trace;
106}
Trace representing the whole trace loaded from trace files.
Definition: Filetrace.hpp:27
Class containing options to filter the view.
Definition: Filter.hpp:28
Trace * subtrace(otf2::chrono::duration from, otf2::chrono::duration to) override
Creates a subtrace of the current trace.
Definition: SubTrace.cpp:93
otf2::chrono::duration getRuntime() const override
Returns the runtime of the current trace.
Definition: SubTrace.cpp:46
A base class for all elements with a start and end time.
void endChanged(types::TraceTime newEnd)
ViewSettings * getSettings() const
Returns the current view settings.
types::TraceTime getTotalRuntime() const
void setFilter(Filter filter)
types::TraceTime getBegin() const
Returns the selected start time.
void setSelectionBegin(types::TraceTime newBegin)
Trace * getSelection() const
Returns the current selection.
TraceDataProxy(FileTrace *trace, ViewSettings *settings, QObject *parent=nullptr)
Constructs a new TraceDataProxy.
void selectionChanged(types::TraceTime newBegin, types::TraceTime newEnd)
Trace * getFullTrace() const
Returns the entire trace.
void beginChanged(types::TraceTime newBegin)
void setTimeElementSelection(TimedElement *newSlot)
types::TraceTime getEnd() const
Returns the selected end time.
void setSelectionEnd(types::TraceTime newEnd)
void setSelection(types::TraceTime newBegin, types::TraceTime newEnd)
void filterChanged(Filter)
void infoElementSelected(TimedElement *)
Abstract base class for a trace.
Definition: Trace.hpp:52
static UITrace * forResolution(Trace *trace, otf2::chrono::duration timePerPixel)
Definition: UITrace.cpp:43
The ViewSettings class encapsulates settings for the main view.
void setFilter(Filter filter)
Sets the current filter.