Kind of working
This commit is contained in:
1 parent
010eb30209
commit
00eb160c8b
4 files changed
+147
-68
No files matched your search
@@ -11,6 +11,10 @@ function newCoordinateSystem () {
|
||||
let thisObject = {
|
||||
min: undefined,
|
||||
max: undefined,
|
||||
parentMin: undefined,
|
||||
parentMax: undefined,
|
||||
childrenMin: undefined,
|
||||
childrenMax: undefined,
|
||||
maxHeight: undefined,
|
||||
maxWidth: undefined,
|
||||
scale: undefined,
|
||||
@@ -24,6 +28,8 @@ function newCoordinateSystem () {
|
||||
HORIZONTAL_MARGIN_INVERSE_FACTOR: 0.20,
|
||||
VERTICAL_MARGIN_INVERSE_FACTOR: 0.10,
|
||||
physics: physics,
|
||||
reportParentXValue: reportParentXValue,
|
||||
reportParentYValue: reportParentYValue,
|
||||
reportXValue: reportXValue,
|
||||
reportYValue: reportYValue,
|
||||
zoomX: zoomX,
|
||||
@@ -47,6 +53,23 @@ function newCoordinateSystem () {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.parentMin = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.parentMax = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.childrenMin = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
thisObject.childrenMax = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
thisObject.scale = {
|
||||
x: 0,
|
||||
y: 0
|
||||
@@ -57,11 +80,12 @@ function newCoordinateSystem () {
|
||||
|
||||
let newXMax = -VERY_LARGE_NUMBER
|
||||
let newXMin = VERY_LARGE_NUMBER
|
||||
let noXValueReported = true
|
||||
|
||||
let newYMax = -VERY_LARGE_NUMBER
|
||||
let newYMin = VERY_LARGE_NUMBER
|
||||
let noYValueReported = true
|
||||
|
||||
let parentMinChanged = false
|
||||
let parentMaxChanged = false
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -84,59 +108,140 @@ function newCoordinateSystem () {
|
||||
recalculateScale()
|
||||
}
|
||||
|
||||
function reportXValue (value) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (value < newXMin) {
|
||||
newXMin = value
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (value > newXMax) {
|
||||
newXMax = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportYValue (value) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (value < newYMin) {
|
||||
newYMin = value
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (value > newYMax) {
|
||||
newYMax = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportParentXValue (min, max) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (thisObject.parentMin.x !== min) {
|
||||
thisObject.parentMin.x = min
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (thisObject.parentMax.x !== max) {
|
||||
thisObject.parentMax.x = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportParentYValue (min, max) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (thisObject.parentMin.y !== min) {
|
||||
thisObject.parentMin.y = min
|
||||
}
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (thisObject.parentMax.y !== max) {
|
||||
thisObject.parentMax.y = max
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function physics () {
|
||||
let mustRecalculate = false
|
||||
|
||||
if ((thisObject.autoMinXScale === true || thisObject.autoMaxXScale === true) && noXValueReported === false) {
|
||||
if (thisObject.autoMaxXScale === true && thisObject.max.x !== newXMax) {
|
||||
thisObject.max.x = newXMax
|
||||
mustRecalculate = true
|
||||
if ((thisObject.autoMinXScale === true || thisObject.autoMaxXScale === true)) {
|
||||
if (thisObject.autoMaxXScale === true && thisObject.childrenMax.x !== newXMax && newXMax !== -VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMax.x = newXMax
|
||||
}
|
||||
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
newXMax = -VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
if (thisObject.autoMinXScale === true && thisObject.min.x !== newXMin) {
|
||||
thisObject.min.x = newXMin
|
||||
if (thisObject.autoMinXScale === true && thisObject.childrenMin.x !== newXMin && newXMin !== VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMin.x = newXMin
|
||||
newXMin = VERY_LARGE_NUMBER
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
newXMin = VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
/* Reseting this to start over at each cycle. */
|
||||
noXValueReported = true
|
||||
|
||||
if (mustRecalculate === true) {
|
||||
thisObject.eventHandler.raiseEvent('X-Range Changed')
|
||||
}
|
||||
}
|
||||
|
||||
if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true) && noYValueReported === false) {
|
||||
if (thisObject.autoMaxYScale === true && thisObject.max.y !== newYMax) {
|
||||
thisObject.max.y = newYMax
|
||||
mustRecalculate = true
|
||||
if ((thisObject.autoMinYScale === true || thisObject.autoMaxYScale === true)) {
|
||||
if (thisObject.autoMaxYScale === true && thisObject.childrenMax.y !== newYMax && newYMax !== -VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMax.y = newYMax
|
||||
}
|
||||
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
newYMax = -VERY_LARGE_NUMBER
|
||||
}
|
||||
|
||||
if (thisObject.autoMinYScale === true && thisObject.min.y !== newYMin) {
|
||||
thisObject.min.y = newYMin
|
||||
if (thisObject.autoMinYScale === true && thisObject.childrenMin.y !== newYMin && newYMin !== VERY_LARGE_NUMBER) {
|
||||
thisObject.childrenMin.y = newYMin
|
||||
newYMin = VERY_LARGE_NUMBER
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
newYMin = VERY_LARGE_NUMBER
|
||||
}
|
||||
}
|
||||
|
||||
/* Reseting this to start over at each cycle. */
|
||||
noYValueReported = true
|
||||
/* Here we will see if any of the children or parent values modify the current status quo */
|
||||
/* Min */
|
||||
let minX = Math.min(thisObject.childrenMin.x, thisObject.parentMin.x)
|
||||
let minY = Math.min(thisObject.childrenMin.y, thisObject.parentMin.y)
|
||||
let maxX = Math.max(thisObject.childrenMax.x, thisObject.parentMax.x)
|
||||
let maxY = Math.max(thisObject.childrenMax.y, thisObject.parentMax.y)
|
||||
|
||||
if (thisObject.parentMin.x === 0) {
|
||||
minX = thisObject.childrenMin.x
|
||||
}
|
||||
|
||||
if (thisObject.parentMin.y === 0) {
|
||||
minY = thisObject.childrenMin.y
|
||||
}
|
||||
|
||||
if (thisObject.parentMax.x === 0) {
|
||||
maxX = thisObject.childrenMax.x
|
||||
}
|
||||
|
||||
if (thisObject.parentMax.y === 0) {
|
||||
maxY = thisObject.childrenMax.y
|
||||
}
|
||||
|
||||
if (minX !== 0 && thisObject.min.x !== minX) {
|
||||
thisObject.min.x = minX
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (minY !== 0 && thisObject.min.y !== minY) {
|
||||
thisObject.min.y = minY
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (maxX !== 0 && thisObject.max.x !== maxX) {
|
||||
thisObject.max.x = maxX
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (maxY !== 0 && thisObject.max.y !== maxY) {
|
||||
thisObject.max.y = maxY
|
||||
mustRecalculate = true
|
||||
}
|
||||
|
||||
if (mustRecalculate === true) {
|
||||
@@ -144,26 +249,11 @@ function newCoordinateSystem () {
|
||||
}
|
||||
}
|
||||
|
||||
function reportXValue (value) {
|
||||
if (thisObject.autoMinXScale === true) {
|
||||
if (value < newXMin) { newXMin = value }
|
||||
noXValueReported = false
|
||||
}
|
||||
if (thisObject.autoMaxXScale === true) {
|
||||
if (value > newXMax) { newXMax = value }
|
||||
noXValueReported = false
|
||||
}
|
||||
}
|
||||
function recalculateScale (event) {
|
||||
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
|
||||
|
||||
function reportYValue (value) {
|
||||
if (thisObject.autoMinYScale === true) {
|
||||
if (value < newYMin) { newYMin = value }
|
||||
noYValueReported = false
|
||||
}
|
||||
if (thisObject.autoMaxYScale === true) {
|
||||
if (value > newYMax) { newYMax = value }
|
||||
noYValueReported = false
|
||||
}
|
||||
thisObject.eventHandler.raiseEvent('Scale Changed', event)
|
||||
}
|
||||
|
||||
function zoomX (factor, mousePosition, container) {
|
||||
@@ -196,13 +286,6 @@ function newCoordinateSystem () {
|
||||
}
|
||||
}
|
||||
|
||||
function recalculateScale (event) {
|
||||
thisObject.scale.x = thisObject.maxWidth * thisObject.HORIZONTAL_MARGIN_FACTOR / (thisObject.max.x - thisObject.min.x)
|
||||
thisObject.scale.y = thisObject.maxHeight * thisObject.VERTICAL_MARGIN_FACTOR / (thisObject.max.y - thisObject.min.y)
|
||||
|
||||
thisObject.eventHandler.raiseEvent('Scale Changed', event)
|
||||
}
|
||||
|
||||
function initializeX (minValue, maxValue, maxWidth) {
|
||||
thisObject.min.x = minValue.x // * 0.999; // 0.1% less
|
||||
thisObject.max.x = maxValue.x // * 1.001; // 0.1% more
|
||||
|
||||
@@ -80,7 +80,7 @@ function newPlottersManager () {
|
||||
}
|
||||
|
||||
function initialize (pLayersPanel) {
|
||||
/* Remember the Layers Panel */
|
||||
/* Remember this */
|
||||
layersPanel = pLayersPanel
|
||||
|
||||
/* Listen to the event of change of status */
|
||||
@@ -244,7 +244,7 @@ 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. */
|
||||
/* If the plotter of this card is not on our Active Plotters list, then we remove it. */
|
||||
for (let i = 0; i < thisObject.connectors.length; i++) {
|
||||
let connector = thisObject.connectors[i]
|
||||
if (connector.layer.payload.node.id === layer.payload.node.id) {
|
||||
|
||||
@@ -36,6 +36,7 @@ function newTimeMachine () {
|
||||
}
|
||||
|
||||
let timeMachineCoordinateSystem = newCoordinateSystem()
|
||||
timeMachineCoordinateSystem.name = 'TIME MACHINE'
|
||||
|
||||
let mouse = {
|
||||
position: {
|
||||
|
||||
@@ -31,6 +31,8 @@ function newTimelineChart () {
|
||||
|
||||
let timeMachineCoordinateSystem
|
||||
let timelineChartCoordinateSystem = newCoordinateSystem()
|
||||
timelineChartCoordinateSystem.name = 'TIMELINE CHART'
|
||||
|
||||
let coordinateSystem
|
||||
|
||||
let layersPanel
|
||||
@@ -43,7 +45,6 @@ function newTimelineChart () {
|
||||
let timeFrameScaleEventSuscriptionId
|
||||
let timeFrameScaleMouseOverEventSuscriptionId
|
||||
let scaleChangedEventSubscriptionId
|
||||
let xRangeChangedEventSubscriptionId
|
||||
|
||||
let drawScales = false
|
||||
let mouse = {
|
||||
@@ -63,8 +64,7 @@ function newTimelineChart () {
|
||||
}
|
||||
|
||||
function finalize () {
|
||||
coordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
timelineChartCoordinateSystem.eventHandler.stopListening(xRangeChangedEventSubscriptionId)
|
||||
timeMachineCoordinateSystem.eventHandler.stopListening(scaleChangedEventSubscriptionId)
|
||||
|
||||
if (thisObject.layersManager !== undefined) {
|
||||
finalizeLayersManager()
|
||||
@@ -147,7 +147,6 @@ function newTimelineChart () {
|
||||
onMouseOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver)
|
||||
onMouseNotOverEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver)
|
||||
scaleChangedEventSubscriptionId = timeMachineCoordinateSystem.eventHandler.listenToEvent('Scale Changed', onScaleChanged)
|
||||
xRangeChangedEventSubscriptionId = timelineChartCoordinateSystem.eventHandler.listenToEvent('X-Range Changed', xRangeChanged)
|
||||
}
|
||||
|
||||
function initializeCoordinateSystem () {
|
||||
@@ -234,15 +233,6 @@ function newTimelineChart () {
|
||||
}
|
||||
}
|
||||
|
||||
function xRangeChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
/* We need to re trasmit the changes on the x Range of the timelinechart coordinate system to the time machine coordinate system so that its scale is syncronized. */
|
||||
timeMachineCoordinateSystem.min.x = timelineChartCoordinateSystem.min.x
|
||||
timeMachineCoordinateSystem.max.x = timelineChartCoordinateSystem.max.x
|
||||
timeMachineCoordinateSystem.recalculateScale()
|
||||
}
|
||||
}
|
||||
|
||||
function onScaleChanged (event) {
|
||||
if (thisObject.rateScale !== undefined) {
|
||||
thisObject.rateScale.onUpstreamScaleChanged(event)
|
||||
@@ -330,9 +320,14 @@ function newTimelineChart () {
|
||||
}
|
||||
|
||||
function thisObjectPhysics () {
|
||||
timelineChartCoordinateSystem.reportXValue(timeMachineCoordinateSystem.min.x)
|
||||
timelineChartCoordinateSystem.reportXValue(timeMachineCoordinateSystem.max.x)
|
||||
timelineChartCoordinateSystem.reportParentXValue(timeMachineCoordinateSystem.min.x, timeMachineCoordinateSystem.max.x)
|
||||
timelineChartCoordinateSystem.physics()
|
||||
|
||||
/* Only if the plotter manager has some layer turned on, we will pass the min and max upstream. */
|
||||
if (thisObject.plotterManager !== undefined && thisObject.plotterManager.connectors.length > 0) {
|
||||
timeMachineCoordinateSystem.reportXValue(timelineChartCoordinateSystem.childrenMin.x)
|
||||
timeMachineCoordinateSystem.reportXValue(timelineChartCoordinateSystem.childrenMax.x)
|
||||
}
|
||||
}
|
||||
|
||||
function syncWithDesignerLayersManager () {
|
||||
|
||||
Reference in new issue
Block a user