Scales only visible if there is at least one layer on

This commit is contained in:
Luis Fernando Molina committed 2020-02-02 12:35:10 +01:00
1 parent 69518c1e13
commit c737a74168
4 files changed
+49 -24

No files matched your search

+21 -20
View File
@@ -4,8 +4,6 @@ function newPlottersManager () {
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let connectors = []
let timeFrame = INITIAL_TIME_PERIOD
let datetime = NEW_SESSION_INITIAL_DATE
@@ -13,6 +11,7 @@ function newPlottersManager () {
fitFunction: undefined,
container: undefined,
payload: undefined,
connectors: [],
setDatetime: setDatetime,
setTimeFrame: setTimeFrame,
setCoordinateSystem: setCoordinateSystem,
@@ -22,6 +21,8 @@ function newPlottersManager () {
finalize: finalize
}
thisObject.connectors = []
let initializationReady = false
let layersPanel
let onLayerStatusChangedEventSuscriptionId
@@ -39,8 +40,8 @@ function newPlottersManager () {
layersPanel.container.eventHandler.stopListening(onLayerStatusChangedEventSuscriptionId)
layersPanel = undefined
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
/* Then the panels. */
for (let j = 0; j < connector.panels.length; j++) {
canvas.panelsSpace.destroyPanel(connector.panels[j])
@@ -61,7 +62,7 @@ function newPlottersManager () {
connector = undefined
}
connectors = []
thisObject.connectors = []
coordinateSystem = undefined
thisObject.container.finalize()
@@ -210,7 +211,7 @@ function newPlottersManager () {
connector.layer.panels = connector.panels
}
connectors.push(connector)
thisObject.connectors.push(connector)
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initializePlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) }
}
@@ -229,8 +230,8 @@ function newPlottersManager () {
if (layer.status === LAYER_STATUS.LOADING) {
/* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */
let found = false
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
if (connector.layer.payload.node.id === layer.payload.node.id) {
found = true
}
@@ -244,8 +245,8 @@ function newPlottersManager () {
}
if (layer.status === LAYER_STATUS.OFF) {
/* If the plotter of this card is not on our Active Plotters list, then we remove it. */
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
if (connector.layer.payload.node.id === layer.payload.node.id) {
/* Then the panels. */
for (let j = 0; j < connector.panels.length; j++) {
@@ -259,7 +260,7 @@ function newPlottersManager () {
connector.plotter.finalize()
}
finalizeStorage(connector.storage)
connectors.splice(i, 1) // Delete item from array.
thisObject.connectors.splice(i, 1) // Delete item from array.
return // We already found the product woth changes and processed it.
}
}
@@ -268,8 +269,8 @@ function newPlottersManager () {
function setTimeFrame (pTimeFrame) {
timeFrame = pTimeFrame
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
connector.layer.setTimeFrame(timeFrame)
connector.storage.setTimeFrame(timeFrame)
connector.plotter.setTimeFrame(timeFrame)
@@ -278,8 +279,8 @@ function newPlottersManager () {
function setDatetime (pDatetime) {
datetime = pDatetime
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
connector.layer.setDatetime(pDatetime)
connector.storage.setDatetime(pDatetime)
connector.plotter.setDatetime(pDatetime)
@@ -288,8 +289,8 @@ function newPlottersManager () {
function setCoordinateSystem (pCoordinateSystem) {
coordinateSystem = pCoordinateSystem
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[i]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[i]
connector.plotter.setCoordinateSystem(coordinateSystem)
}
}
@@ -298,10 +299,10 @@ function newPlottersManager () {
}
function draw () {
if (connectors === undefined) { return } // We need to wait
if (thisObject.connectors === undefined) { return } // We need to wait
/* First the Product Plotters. */
for (let i = 0; i < connectors.length; i++) {
let connector = connectors[connectors.length - i - 1]
for (let i = 0; i < thisObject.connectors.length; i++) {
let connector = thisObject.connectors[thisObject.connectors.length - i - 1]
connector.plotter.draw()
}
}
+2
View File
@@ -361,9 +361,11 @@ function newTimelineChart () {
function childrenPhysics () {
if (thisObject.rateScale !== undefined) {
thisObject.rateScale.layersOn = thisObject.plotterManager.connectors.length
thisObject.rateScale.physics()
}
if (thisObject.timeFrameScale !== undefined) {
thisObject.timeFrameScale.layersOn = thisObject.plotterManager.connectors.length
thisObject.timeFrameScale.physics()
}
}
+13 -2
View File
@@ -11,6 +11,7 @@ function newRateScale () {
minValue: undefined,
maxValue: undefined,
isVisible: true,
layersOn: undefined,
setScale: setScale,
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
physics: physics,
@@ -323,13 +324,17 @@ function newRateScale () {
if (thisObject.payload.parentNode.type === 'Timeline Chart') {
if (thisObject.payload.parentNode.payload.parentNode !== undefined) {
if (thisObject.payload.parentNode.payload.parentNode.rateScale !== undefined) {
displaceFactor++
if (thisObject.payload.parentNode.payload.parentNode.rateScale.payload.isVisible === true) {
displaceFactor++
}
}
for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) {
let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i]
if (timelineChart.rateScale !== undefined) {
if (thisObject.payload.node.id !== timelineChart.rateScale.id) {
displaceFactor++
if (timelineChart.rateScale.payload.isVisible === true) {
displaceFactor++
}
} else {
break
}
@@ -366,11 +371,17 @@ function newRateScale () {
thisObject.container.frame.position.x = ratePoint.x - thisObject.container.frame.width
thisObject.isVisible = true
thisObject.payload.isVisible = true
if (thisObject.container.frame.position.y + thisObject.container.frame.height * 2 > bottonCorner.y ||
thisObject.container.frame.position.y - thisObject.container.frame.height * 1 < upCorner.y ||
thisObject.container.frame.position.x < upCorner.x
) {
thisObject.isVisible = false
thisObject.payload.isVisible = false
}
if (thisObject.layersOn === 0) {
thisObject.isVisible = false
thisObject.payload.isVisible = false
}
}
+13 -2
View File
@@ -7,6 +7,7 @@ function newTimeFrameScale () {
fitFunction: undefined,
payload: undefined,
isVisible: true,
layersOn: undefined,
onMouseOverSomeTimeMachineContainer: onMouseOverSomeTimeMachineContainer,
draw: draw,
drawForeground: drawForeground,
@@ -144,13 +145,17 @@ function newTimeFrameScale () {
if (thisObject.payload.parentNode.type === 'Timeline Chart') {
if (thisObject.payload.parentNode.payload.parentNode !== undefined) {
if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale !== undefined) {
displaceFactor++
if (thisObject.payload.parentNode.payload.parentNode.timeFrameScale.payload.isVisible === true) {
displaceFactor++
}
}
for (let i = 0; i < thisObject.payload.parentNode.payload.parentNode.timelineCharts.length; i++) {
let timelineChart = thisObject.payload.parentNode.payload.parentNode.timelineCharts[i]
if (timelineChart.timeFrameScale !== undefined) {
if (thisObject.payload.node.id !== timelineChart.timeFrameScale.id) {
displaceFactor++
if (timelineChart.timeFrameScale.payload.isVisible === true) {
displaceFactor++
}
} else {
break
}
@@ -179,9 +184,15 @@ function newTimeFrameScale () {
thisObject.container.frame.position.y = timePoint.y - thisObject.container.frame.height
thisObject.isVisible = true
thisObject.payload.isVisible = true
if (thisObject.container.frame.position.y + thisObject.container.frame.height > bottonCorner.y ||
thisObject.container.frame.position.y - thisObject.container.frame.height * 3 < upCorner.y) {
thisObject.isVisible = false
thisObject.payload.isVisible = false
}
if (thisObject.layersOn === 0) {
thisObject.isVisible = false
thisObject.payload.isVisible = false
}
}