Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independent time conductor related handling for plot synchronization. #7956

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/api/time/IndependentTimeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,18 @@
}
}

/**
* @returns {boolean}
* @override
*/
isFixed() {
if (this.upstreamTimeContext) {
return this.upstreamTimeContext.isFixed(...arguments);
} else {
return super.isFixed(...arguments);

Check warning on line 370 in src/api/time/IndependentTimeContext.js

View check run for this annotation

Codecov / codecov/patch

src/api/time/IndependentTimeContext.js#L370

Added line #L370 was not covered by tests
}
}

/**
* @returns {number}
* @override
Expand Down Expand Up @@ -400,7 +412,7 @@
}

/**
* Reset the time context to the global time context
* Reset the time context from the global time context
*/
resetContext() {
if (this.upstreamTimeContext) {
Expand Down Expand Up @@ -428,6 +440,8 @@
// Emit bounds so that views that are changing context get the upstream bounds
this.emit('bounds', this.getBounds());
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
// Also emit the mode in case it's different from previous time context
this.emit(TIME_CONTEXT_EVENTS.modeChanged, this.#copy(this.getMode()));
}

/**
Expand Down Expand Up @@ -502,6 +516,8 @@
// Emit bounds so that views that are changing context get the upstream bounds
this.emit('bounds', this.getBounds());
this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds());
// Also emit the mode in case it's different from the global time context
this.emit(TIME_CONTEXT_EVENTS.modeChanged, this.#copy(this.getMode()));
// now that the view's context is set, tell others to check theirs in case they were following this view's context.
this.globalTimeContext.emit('refreshContext', viewKey);
}
Expand Down
9 changes: 8 additions & 1 deletion src/api/time/TimeAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import { FIXED_MODE_KEY, REALTIME_MODE_KEY } from '@/api/time/constants';
import IndependentTimeContext from '@/api/time/IndependentTimeContext';

import { TIME_CONTEXT_EVENTS } from './constants';
import GlobalTimeContext from './GlobalTimeContext.js';

/**
Expand Down Expand Up @@ -142,7 +143,7 @@ class TimeAPI extends GlobalTimeContext {
addIndependentContext(key, value, clockKey) {
let timeContext = this.getIndependentContext(key);

//stop following upstream time context since the view has it's own
//stop following upstream time context since the view has its own
timeContext.resetContext();

if (clockKey) {
Expand All @@ -152,6 +153,12 @@ class TimeAPI extends GlobalTimeContext {
timeContext.setMode(FIXED_MODE_KEY, value);
}

// Also emit the mode in case it's different from the previous time context
timeContext.emit(
TIME_CONTEXT_EVENTS.modeChanged,
JSON.parse(JSON.stringify(timeContext.getMode()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use structuredClone over JSON cloning, unless there is a good reason not to.

);

// Notify any nested views to update, pass in the viewKey so that particular view can skip getting an upstream context
this.emit('refreshContext', key);

Expand Down
1 change: 1 addition & 0 deletions src/plugins/plot/MctPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ export default {
this.followTimeContext();
},
followTimeContext() {
this.updateMode();
this.updateDisplayBounds(this.timeContext.getBounds());
this.timeContext.on('modeChanged', this.updateMode);
this.timeContext.on('boundsChanged', this.updateDisplayBounds);
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/timeConductor/independent/IndependentTimeConductor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,20 @@ export default {
this.timeContext.off(TIME_CONTEXT_EVENTS.modeChanged, this.setTimeOptionsMode);
},
setTimeOptionsClock(clock) {
// If the user has persisted any time options, then don't override them with global settings.
if (this.independentTCEnabled) {
return;
}
this.setTimeOptionsOffsets();
this.timeOptions.clock = clock.key;
},
setTimeOptionsMode(mode) {
this.setTimeOptionsOffsets();
this.timeOptions.mode = mode;
// If the user has persisted any time options, then don't override them with global settings.
if (this.independentTCEnabled) {
this.setTimeOptionsOffsets();
this.timeOptions.mode = mode;
this.isFixed = this.timeOptions.mode === FIXED_MODE_KEY;
}
},
setTimeOptionsOffsets() {
this.timeOptions.clockOffsets =
Expand Down
Loading