mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
[TC] Fix clock option selection
This commit is contained in:
parent
fff75d111e
commit
cd8c0fa72f
@ -169,23 +169,20 @@ define(
|
|||||||
TimeConductorController.prototype.selectMenuOption = function (newOption, oldOption) {
|
TimeConductorController.prototype.selectMenuOption = function (newOption, oldOption) {
|
||||||
if (newOption !== oldOption) {
|
if (newOption !== oldOption) {
|
||||||
var config = this.getConfig(this.timeAPI.timeSystem(), newOption.clock);
|
var config = this.getConfig(this.timeAPI.timeSystem(), newOption.clock);
|
||||||
|
if (!config) {
|
||||||
/*
|
// Clock does not support this timeSystem, fallback to first
|
||||||
* If there is no configuration defined for the selected clock
|
// option provided for clock.
|
||||||
* and time system default to the first time system that
|
config = this.config.menuOptions.filter(function (menuOption) {
|
||||||
* configuration is available for.
|
return menuOption.clock === (newOption.clock && newOption.clock.key);
|
||||||
*/
|
})[0];
|
||||||
if (config === undefined) {
|
|
||||||
var timeSystem = this.timeSystemsForClocks[newOption.key][0];
|
|
||||||
this.$scope.timeSystemModel.selected = timeSystem;
|
|
||||||
this.setTimeSystemFromView(timeSystem.key);
|
|
||||||
config = this.getConfig(timeSystem, newOption.clock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newOption.key === 'fixed') {
|
if (config.clock) {
|
||||||
this.timeAPI.stopClock();
|
this.timeAPI.clock(config.clock, config.clockOffsets);
|
||||||
|
this.timeAPI.timeSystem(config.timeSystem);
|
||||||
} else {
|
} else {
|
||||||
this.timeAPI.clock(newOption.key, config.clockOffsets);
|
this.timeAPI.stopClock();
|
||||||
|
this.timeAPI.timeSystem(config.timeSystem, config.bounds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -211,6 +208,11 @@ define(
|
|||||||
|
|
||||||
(config.menuOptions || []).forEach(function (menuOption) {
|
(config.menuOptions || []).forEach(function (menuOption) {
|
||||||
var clockKey = menuOption.clock || 'fixed';
|
var clockKey = menuOption.clock || 'fixed';
|
||||||
|
var clock = this.getClock(clockKey);
|
||||||
|
|
||||||
|
if (clock !== undefined) {
|
||||||
|
clocks[clock.key] = clock;
|
||||||
|
}
|
||||||
|
|
||||||
var timeSystem = this.timeSystems[menuOption.timeSystem];
|
var timeSystem = this.timeSystems[menuOption.timeSystem];
|
||||||
if (timeSystem !== undefined) {
|
if (timeSystem !== undefined) {
|
||||||
@ -349,10 +351,10 @@ define(
|
|||||||
* @param {Clock} clock
|
* @param {Clock} clock
|
||||||
*/
|
*/
|
||||||
TimeConductorController.prototype.setViewFromClock = function (clock) {
|
TimeConductorController.prototype.setViewFromClock = function (clock) {
|
||||||
var newClockKey = clock && clock.key;
|
var newClockKey = clock ? clock.key : 'fixed';
|
||||||
var timeSystems = this.timeSystemsForClocks[newClockKey || 'fixed'];
|
var timeSystems = this.timeSystemsForClocks[newClockKey];
|
||||||
var menuOption = this.menu.options.filter(function (option) {
|
var menuOption = this.menu.options.filter(function (option) {
|
||||||
return option.key === (newClockKey || 'fixed');
|
return option.key === (newClockKey);
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
this.menu.selected = menuOption;
|
this.menu.selected = menuOption;
|
||||||
@ -381,9 +383,7 @@ define(
|
|||||||
|
|
||||||
this.isFixed = clock === undefined;
|
this.isFixed = clock === undefined;
|
||||||
|
|
||||||
if (clock !== undefined) {
|
if (clock === undefined) {
|
||||||
this.setViewFromOffsets(this.timeAPI.clockOffsets());
|
|
||||||
} else {
|
|
||||||
this.setViewFromBounds(this.timeAPI.bounds());
|
this.setViewFromBounds(this.timeAPI.bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,34 +404,14 @@ define(
|
|||||||
var clock = this.menu.selected.clock;
|
var clock = this.menu.selected.clock;
|
||||||
var timeSystem = this.timeSystems[key];
|
var timeSystem = this.timeSystems[key];
|
||||||
var config = this.getConfig(timeSystem, clock);
|
var config = this.getConfig(timeSystem, clock);
|
||||||
var bounds;
|
|
||||||
|
|
||||||
this.$scope.timeSystemModel.selected = timeSystem;
|
this.$scope.timeSystemModel.selected = timeSystem;
|
||||||
|
|
||||||
/**
|
|
||||||
* Time systems require default bounds to be specified when they
|
|
||||||
* are set
|
|
||||||
*/
|
|
||||||
if (clock === undefined) {
|
if (clock === undefined) {
|
||||||
bounds = config.bounds;
|
this.timeAPI.timeSystem(timeSystem, config.bounds);
|
||||||
this.timeAPI.timeSystem(timeSystem, bounds);
|
|
||||||
} else {
|
} else {
|
||||||
bounds = {
|
this.timeAPI.clock(clock, config.clockOffsets);
|
||||||
start: clock.currentValue() + config.clockOffsets.start,
|
this.timeAPI.timeSystem(timeSystem);
|
||||||
end: clock.currentValue() + config.clockOffsets.end
|
|
||||||
};
|
|
||||||
//Has time system change resulted in offsets change (based on config)?
|
|
||||||
this.timeAPI.timeSystem(timeSystem, bounds);
|
|
||||||
var configOffsets = config.clockOffsets;
|
|
||||||
var apiOffsets = this.timeAPI.clockOffsets();
|
|
||||||
|
|
||||||
//Checking if a clock is actually set on the Time API before
|
|
||||||
// trying to set offsets.
|
|
||||||
if (this.timeAPI.clock() !== undefined &&
|
|
||||||
(configOffsets.start !== apiOffsets.start ||
|
|
||||||
configOffsets.end !== apiOffsets.end)) {
|
|
||||||
this.timeAPI.clockOffsets(configOffsets);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user